Commit 57c070f8 authored by amandaghassaei's avatar amandaghassaei
Browse files

debug pattern import

parent 66d1ea46
......@@ -65,6 +65,8 @@ function initDynamicModel(globals){
if (firstTime === undefined) firstTime = false;
initTexturesAndPrograms(globals.gpuMath, firstTime);
steps = parseInt(setSolveParams());
if(firstTime) runSolver();
}
var steps;
......@@ -75,8 +77,6 @@ function initDynamicModel(globals){
var textureDimFaces = 0;
var textureDimCreases = 0;
var textureDimNodeCreases = 0;
syncNodesAndEdges(true);
runSolver();
function reset(){
globals.gpuMath.step("zeroTexture", [], "u_position");
......
......@@ -121,6 +121,7 @@ $(function() {
globals.model = initModel(globals);
globals.staticSolver = initStaticSolver(globals);
globals.dynamicModel = initDynamicModel(globals);
// global.dynamicModel.syncNodesAndEdges(true);
// globals.staticSolver.syncNodesAndEdges();
globals.pattern = initPattern(globals);
globals.threeView.render();
......
......@@ -104,7 +104,8 @@ function initModel(globals){
}
oldCreases = null;
globals.staticSolver.syncNodesAndEdges();
globals.dynamicModel.syncNodesAndEdges(true);
// globals.staticSolver.syncNodesAndEdges();
}
function getNodes(){
......
......@@ -32,46 +32,46 @@ function initPattern(globals){
});
}
// loadSVG("assets/Tessellations/SimpleVertex.svg", function(svg){
// var _$svg = $(svg);
//
// //format all lines
// var $paths = _$svg.children("path");
// $paths.css({fill:"none", 'stroke-width':3, 'stroke-dasharray':"none"});
//
// var $outlines = $paths.filter(function(){
// var stroke = $(this).attr("stroke").toLowerCase();
// return stroke == "#000000" || stroke == "#000";
// });
// // $outlines.css({fill:'#ffffff'});
//
// var $mountains = $paths.filter(function(){
// var stroke = $(this).attr("stroke").toLowerCase();
// return stroke == "#ff0000" || stroke == "#f00";
// });
// $mountains.css({'stroke-dasharray':'12, 6, 3, 6'});
//
// var $valleys = $paths.filter(function(){
// var stroke = $(this).attr("stroke").toLowerCase();
// return stroke == "#0000ff" || stroke == "#00f";
// });
// $valleys.css({'stroke-dasharray':'7, 6, 7, 6'});
//
// var $cuts = $paths.filter(function(){
// var stroke = $(this).attr("stroke").toLowerCase();
// return stroke == "#00ff00" || stroke == "#0f0";
// });
//
// var $svg = $('<svg version="1.1" viewBox="'+_$svg.attr("viewBox")+'" id="mySVG" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> </svg>');
// $svg.append($outlines);
// $svg.append($mountains);
// $svg.append($valleys);
// $svg.append($cuts);
//
// $("#svgViewer").html($svg);
//
// parseSVG($outlines, $mountains, $valleys, $cuts);
// });
loadSVG("assets/Tessellations/SimpleVertex.svg", function(svg){
var _$svg = $(svg);
//format all lines
var $paths = _$svg.children("path");
$paths.css({fill:"none", 'stroke-width':3, 'stroke-dasharray':"none"});
var $outlines = $paths.filter(function(){
var stroke = $(this).attr("stroke").toLowerCase();
return stroke == "#000000" || stroke == "#000";
});
// $outlines.css({fill:'#ffffff'});
var $mountains = $paths.filter(function(){
var stroke = $(this).attr("stroke").toLowerCase();
return stroke == "#ff0000" || stroke == "#f00";
});
$mountains.css({'stroke-dasharray':'12, 6, 3, 6'});
var $valleys = $paths.filter(function(){
var stroke = $(this).attr("stroke").toLowerCase();
return stroke == "#0000ff" || stroke == "#00f";
});
$valleys.css({'stroke-dasharray':'7, 6, 7, 6'});
var $cuts = $paths.filter(function(){
var stroke = $(this).attr("stroke").toLowerCase();
return stroke == "#00ff00" || stroke == "#0f0";
});
var $svg = $('<svg version="1.1" viewBox="'+_$svg.attr("viewBox")+'" id="mySVG" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> </svg>');
$svg.append($outlines);
$svg.append($mountains);
$svg.append($valleys);
$svg.append($cuts);
$("#svgViewer").html($svg);
parseSVG($outlines, $mountains, $valleys, $cuts);
});
function parsePath(_verticesRaw, _segmentsRaw, $paths){
for (var i=0;i<$paths.length;i++){
......@@ -360,7 +360,6 @@ function initPattern(globals){
}
function findPolygons(allEdges){
//collect all edges connected to vertices
var vertEdges = [];
for (var i=0;i<vertices.length;i++){
......@@ -397,6 +396,7 @@ function initPattern(globals){
vertEdges[i] = sortedEdges;
}
var edgesDir1 = [];//vert lower index to vert higher index
var edgesDir2 = [];//vert higher index to vert lower index
for (var i=0;i<allEdges.length;i++){
......@@ -458,12 +458,13 @@ function initPattern(globals){
}
}
}
//remove boundary
for (var i=polygonEdges.length-1;i>=0;i--){
var containsInnerCrease = false;
for (var j=0;j<polygonEdges[i].length;j++){
if (polygonEdges[i][j]>=outlines.length){
var edgeIndex = polygonEdges[i][j];
if (edgeIndex < 0) edgeIndex = -edgeIndex-1;
if (edgeIndex>=outlines.length){
containsInnerCrease = true;
break;
}
......
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