Commit 6e9d647d authored by amandaghassaei's avatar amandaghassaei
Browse files

remove problem of vertex intersections

parent e5e0945e
...@@ -204,11 +204,9 @@ function initPattern(globals){ ...@@ -204,11 +204,9 @@ function initPattern(globals){
triangulationsRaw = _triangulationsRaw; triangulationsRaw = _triangulationsRaw;
mergeVertices(); mergeVertices();
console.log(vertices);
console.log(vertices.length); //remove duplicates for each set of edges
console.log(mountains); //remove vertices that are not useful
console.log(valleys);
console.log(outlines);
var allEdges = outlines.concat(mountains).concat(valleys).concat(cuts).concat(triangulationsRaw); var allEdges = outlines.concat(mountains).concat(valleys).concat(cuts).concat(triangulationsRaw);
polygons = findPolygons(allEdges); polygons = findPolygons(allEdges);
...@@ -269,7 +267,6 @@ function initPattern(globals){ ...@@ -269,7 +267,6 @@ function initPattern(globals){
function mergeVertices(){ function mergeVertices(){
vertices = verticesRaw.slice(); vertices = verticesRaw.slice();
console.log(vertices.length);
var tolSq = globals.vertTol*globals.vertTol; var tolSq = globals.vertTol*globals.vertTol;
var combined = []; var combined = [];
...@@ -308,12 +305,12 @@ function initPattern(globals){ ...@@ -308,12 +305,12 @@ function initPattern(globals){
if (allEdges[k][0] == js[i] || allEdges[k][1] == js[i]) vertexEdges.push(k); if (allEdges[k][0] == js[i] || allEdges[k][1] == js[i]) vertexEdges.push(k);
} }
if (vertexEdges.length>1){ if (vertexEdges.length>1){
goodVertices.push([vertices[i], js[i]].concat(vertexEdges)); goodVertices.push([vertices[js[i]], js[i]].concat(vertexEdges));
_weededVertices.splice(i, 1); _weededVertices.splice(i, 1);
} }
} }
} }
outlines = outlinesRaw.slice(); outlines = outlinesRaw.slice();
mountains = mountainsRaw.slice(); mountains = mountainsRaw.slice();
valleys = valleysRaw.slice(); valleys = valleysRaw.slice();
...@@ -344,12 +341,11 @@ function initPattern(globals){ ...@@ -344,12 +341,11 @@ function initPattern(globals){
var newIndex = mergedVertices.length; var newIndex = mergedVertices.length;
var oldIndex = goodVertices[i][1]; var oldIndex = goodVertices[i][1];
mergedVertices.push(goodVertices[i][0]); mergedVertices.push(goodVertices[i][0]);
for (var j=0;j<goodVertices[i].length-2;j++){ for (var j=2;j<goodVertices[i].length;j++){
var edge = allEdges[goodVertices[i][j+2]]; var edge = allEdges[goodVertices[i][j]];
edge[edge.indexOf(oldIndex)] = newIndex; edge[edge.indexOf(oldIndex)] = newIndex;
} }
} }
vertices = mergedVertices; vertices = mergedVertices;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment