Commit 61ec0d94 authored by amandaghassaei's avatar amandaghassaei

debugging

parent 788eaf85
...@@ -226,43 +226,67 @@ function initPattern(globals){ ...@@ -226,43 +226,67 @@ function initPattern(globals){
} }
function removeRedundantVertices(set){ function removeRedundantVertices(set){
// var badVertices = []; var badVertices = [];
// for (var i=0;i<vertices.length;i++){ for (var i=0;i<vertices.length;i++){
// var vertexEdges = []; var vertexEdges = [];
// for (var j=0;j<=set.length;j++){ for (var j=0;j<set.length;j++){
// if (set[j][0] == i || set[j][1] == i) vertexEdges.push(j); if (set[j][0] == i || set[j][1] == i) vertexEdges.push(j);
// } }
// if (vertexEdges.length == 2){ if (vertexEdges.length == 2){
// var edge1 = set[vertexEdges[0]]; var edge1 = set[vertexEdges[0]];
// var edge2 = set[vertexEdges[1]]; var edge2 = set[vertexEdges[1]];
// var angle1 = Math.atan2(vertices[edge1[0]].z-vertices[edge1[1]].z, vertices[edge1[0]].x-vertices[edge1[1]].x); var angle1 = Math.atan2(vertices[edge1[0]].z-vertices[edge1[1]].z, vertices[edge1[0]].x-vertices[edge1[1]].x);
// var angle2 = Math.atan2(vertices[edge2[0]].z-vertices[edge2[1]].z, vertices[edge2[0]].x-vertices[edge2[1]].x); var angle2 = Math.atan2(vertices[edge2[0]].z-vertices[edge2[1]].z, vertices[edge2[0]].x-vertices[edge2[1]].x);
// if (Math.abs(angle1-angle2) < 0.01 || Math.abs(angle1-angle2-Math.PI) < 0.01){ if (Math.abs(angle1-angle2) < 0.01 || Math.abs(angle1-angle2-Math.PI) < 0.01){
// badVertices.push(i); badVertices.push(i);
// var v1 = edge1[0]; var v1 = edge1[0];
// if (v1 = i) v1 = edge1[1]; if (v1 == i) v1 = edge1[1];
// var v2 = edge2[0]; var v2 = edge2[0];
// if (v2 = i) v2 = edge2[1]; if (v2 == i) v2 = edge2[1];
// set[vertexEdges[0]] = [v1, v2];//favor outlines over mtn valleys var angle = set[vertexEdges[0]][2];
// set.splice(vertexEdges[1], 1);//delete extra if (set[vertexEdges[1]][2] != angle) console.warn("different types of edges being joined");
// }
// } var set1 = getSetForIndex(vertexEdges[0]);
// } var set2 = getSetForIndex(vertexEdges[1]);
// if (badVertices.length>0){
// set1[getIndexInSet(vertexEdges[0])] = [v1, v2, angle];//favor outlines over mtn valleys
// set2.splice(getIndexInSet(vertexEdges[1]), 1);//delete extra
// }
// // for (var j=0;j<=set.length;j++){ }
// // if (set[j][0] == i || set[j][1] == i) vertexEdges.push(j); }
// // } if (badVertices.length>0){
// //
// removeDuplicates(outlines, outlines); //bad vertices in ascending order
// removeDuplicates(mountains, mountains); for (var i=badVertices.length-1;i>=0;i--){
// removeDuplicates(valleys, valleys); vertices.splice(badVertices[i], 1);
// removeDuplicates(cuts, cuts); // for (var j=badVertices[i];j<set.length;j++){
// removeDuplicates(triangulations, triangulations); // set[j][0]--;
// removeRedundantVertices(set); // set[j][1]--;
// } // }
}
removeDuplicates(outlines, outlines);
removeDuplicates(mountains, mountains);
removeDuplicates(valleys, valleys);
removeDuplicates(cuts, cuts);
removeDuplicates(triangulations, triangulations);
removeRedundantVertices(set);
}
}
function getSetForIndex(i){
if (i<outlines.length) return outlines;
if (i<mountains.length+outlines.length) return mountains;
if (i<valleys.length+mountains.length+outlines.length) return valleys;
if (i<cuts.length+valleys.length+mountains.length+outlines.length) return cuts;
return triangulations;
}
function getIndexInSet(i){
if (i<outlines.length) return i;
if (i<mountains.length+outlines.length) return i-outlines.length;
if (i<valleys.length+mountains.length+outlines.length) return i-outlines.length-mountains.length;
if (i<cuts.length+valleys.length+mountains.length+outlines.length) return i-outlines.length-mountains.length-valleys.length;
return i-outlines.length-mountains.length-valleys.length-cuts.length;
} }
function removeDuplicates(set1, set2){ function removeDuplicates(set1, set2){
......
Markdown is supported
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