diff --git a/assets/Tessellations/test.svg b/assets/Tessellations/test.svg index b2d3700ff0a0d973c7e8ec726a80e83e85b6cf88..b9c7b4d0f3e2d3ba1be8131635433d4abccfae58 100644 --- a/assets/Tessellations/test.svg +++ b/assets/Tessellations/test.svg @@ -3,8 +3,8 @@ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="3456px" height="6912px" viewBox="0 0 3456 6912" enable-background="new 0 0 3456 6912" xml:space="preserve"> -<path fill="none" stroke="#000000" stroke-miterlimit="10" d="M775.294,1121.176l582.353-764.706 M1840,1185.882L1357.646,356.47 - M1840,1185.882l-1064.706-64.706"/> -<path fill="none" stroke="#FF0000" stroke-miterlimit="10" d="M1064.715,741.129L1840,1185.882"/> -<line fill="none" stroke="#000000" stroke-miterlimit="10" x1="1840" y1="1184.875" x2="1840" y2="1186.382"/> +<rect x="765.766" y="680" fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" width="1747.059" height="1541.176"/> +<line fill="none" stroke="#0000FF" stroke-miterlimit="10" x1="765.766" y1="680" x2="2512.823" y2="2221.177"/> +<line fill="none" stroke="#0000FF" stroke-miterlimit="10" x1="765.766" y1="2221.177" x2="1639.294" y2="1450.589"/> +<line fill="none" stroke="#FF0000" stroke-miterlimit="10" x1="1639.294" y1="1450.589" x2="2512.823" y2="680"/> </svg> diff --git a/index.html b/index.html index 88d2ff80753383c5727e2738ab70c0ed6b1beea1..5f4d970b323fbf8cd9b4e67095118b69a6ac6689 100755 --- a/index.html +++ b/index.html @@ -1092,7 +1092,7 @@ </button> <b>EXPORT FOLD</b><br/><br/> Filename: <input id="foldFilename" value="" placeholder="" class="bigInput text form-control" type="text"> .fold<br/><br/> - Author: <input id="foldAuthor" value="Amanda Ghassaei" placeholder="" class="bigInput text form-control" type="text"><br/><br/> + Author: <input id="foldAuthor" value="" placeholder="" class="bigInput text form-control" type="text"><br/><br/> Scale: <input value="" placeholder="" class="float exportScale form-control" type="text"> Units: <div class="btn-group"> diff --git a/js/model.js b/js/model.js index 170193d20194d33f06dac895b6ec9d6b67ff99cc..f9f1072cc6b357912445a6dd5854fe17b738974f 100755 --- a/js/model.js +++ b/js/model.js @@ -115,7 +115,7 @@ function initModel(globals){ valleyLines.visible = globals.edgesVisible && globals.valleysVisible; facetLines.visible = globals.edgesVisible && globals.panelsVisible; hingeLines.visible = globals.edgesVisible && globals.passiveEdgesVisible; - borderLines = globals.edgesVisible && globals.boundaryEdgesVisible; + borderLines.visible = globals.edgesVisible && globals.boundaryEdgesVisible; cutLines.visible = false; } diff --git a/js/pattern.js b/js/pattern.js index 5ad56e745a272a94ec47f7de28b291bd798104ef..4c9333365958e1670104170e87f0f1682954268f 100755 --- a/js/pattern.js +++ b/js/pattern.js @@ -27,8 +27,6 @@ function initPattern(globals){ var triangulationsRaw = []; var hingesRaw = []; - var vertices = [];//list of vertex3's (after processing) - //refs to vertex indices var mountains = []; var valleys = []; var borders = []; @@ -103,7 +101,7 @@ function initPattern(globals){ var stroke = obj.attr("stroke"); if (stroke === undefined) { if (obj.attr("style") && $(obj)[0].style.stroke) { - return $(obj)[0].style.stroke; + return ($(obj)[0].style.stroke).toLowerCase(); } return null; } @@ -349,9 +347,10 @@ function initPattern(globals){ //find max and min vertices var max = new THREE.Vector3(-Infinity,-Infinity,-Infinity); var min = new THREE.Vector3(Infinity,Infinity,Infinity); - for (var i=0;i<vertices.length;i++){ - max.max(vertices[i]); - min.min(vertices[i]); + for (var i=0;i<foldData.vertices_coords.length;i++){ + var vertex = new THREE.Vector3(foldData.vertices_coords[i][0], foldData.vertices_coords[i][1], foldData.vertices_coords[i][2]); + max.max(vertex); + min.min(vertex); } if (min.x === Infinity){ if (badColors.length == 0) globals.warn("no geometry found in file"); @@ -373,14 +372,15 @@ function initPattern(globals){ svg.setAttribute('viewBox', viewBoxTxt); for (var i=0;i<foldData.edges_vertices.length;i++){ var line = document.createElementNS(ns, 'line'); - var vertex = vertices[foldData.edges_vertices[i][0]]; + var edge = foldData.edges_vertices[i]; + var vertex = foldData.vertices_coords[edge[0]]; line.setAttribute('stroke', colorForAssignment(foldData.edges_assignment[i])); line.setAttribute('opacity', opacityForAngle(foldData.edges_foldAngles[i])); - line.setAttribute('x1', vertex.x); - line.setAttribute('y1', vertex.z); - vertex = vertices[foldData.edges_vertices[i][1]]; - line.setAttribute('x2', vertex.x); - line.setAttribute('y2', vertex.z); + line.setAttribute('x1', vertex[0]); + line.setAttribute('y1', vertex[2]); + vertex = foldData.vertices_coords[edge[1]]; + line.setAttribute('x2', vertex[0]); + line.setAttribute('y2', vertex[2]); line.setAttribute('stroke-width', strokeWidth); svg.appendChild(line); } @@ -430,23 +430,21 @@ function initPattern(globals){ foldData = FOLD.filter.collapseNearbyVertices(foldData, globals.vertTol); foldData = FOLD.filter.removeLoopEdges(foldData);//remove edges that points to same vertex foldData = FOLD.filter.subdivideCrossingEdges_vertices(foldData, globals.vertTol);//find intersections ad add vertices/edges + foldData = FOLD.convert.edges_vertices_to_vertices_vertices_unsorted(foldData); - console.log(JSON.stringify(foldData)); foldData = removeStrayVertices(foldData);//delete stray anchors removeRedundantVertices(foldData, 0.01);//remove vertices that split edge console.log(JSON.stringify(foldData)); - FOLD.convert.sort_vertices_vertices(foldData); + foldData.vertices_vertices = FOLD.convert.sort_vertices_vertices(foldData); console.log(JSON.stringify(foldData)); foldData = FOLD.convert.vertices_vertices_to_faces_vertices(foldData); - console.log(JSON.stringify(foldData)); + foldData = reverseFaceOrder(foldData);//set faces to counter clockwise // var foldData = triangulatePolys(foldData); - vertices = [];//todo need this? for (var i=0;i<foldData.vertices_coords.length;i++){ var vertex = foldData.vertices_coords[i]; - foldData.vertices_coords[i] = [vertex[0], 0, vertex[1]]; - vertices.push(new THREE.Vector3(vertex[0], 0, vertex[1])); + foldData.vertices_coords[i] = [vertex[0], 0, vertex[1]];//make vertices_coords 3d } mountains = FOLD.filter.mountainEdges(foldData); valleys = FOLD.filter.valleyEdges(foldData); @@ -465,6 +463,13 @@ function initPattern(globals){ globals.model.buildModel(foldData, allCreaseParams, getAllEdges()); } + function reverseFaceOrder(fold){ + for (var i=0;i<fold.faces_vertices.length;i++){ + fold.faces_vertices[i].reverse() + } + return fold; + } + function getFacesAndVerticesForEdges(fold){ var allCreaseParams = [];//face1Ind, vertInd, face2Ind, ver2Ind, edgeInd, angle var faces = fold.faces_vertices; @@ -550,7 +555,16 @@ function initPattern(globals){ } if (numRedundant == 0) return fold; console.warn(numRedundant + " redundant vertices found"); - return FOLD.filter.remapField(fold, 'vertices', old2new); + fold = FOLD.filter.remapField(fold, 'vertices', old2new); + // _.each(fold.vertices_vertices, function(vertex_vertices){ + // for (var i=vertex_vertices.length-1;i>=0;i--){ + // if (vertex_vertices[i] === null) vertex_vertices.splice(i,1); + // } + // }); + //todo fix vertices_vertices w/o recompute + fold.vertices_vertices = null; + fold = FOLD.convert.edges_vertices_to_vertices_vertices_unsorted(fold); + return fold; } function mergeEdge(fold, v1, v2, v3){ @@ -727,8 +741,8 @@ function initPattern(globals){ } } - function getPolygons(){ - return polygons[0]; + function getPolygons(){//todo export fold complete + return foldData.faces_vertices; } return {