Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
788eaf85
Commit
788eaf85
authored
May 09, 2017
by
amandaghassaei
Browse files
working on better svg parsing
parent
d7be6289
Changes
3
Show whitespace changes
Inline
Side-by-side
index.html
View file @
788eaf85
...
...
@@ -418,7 +418,7 @@
<li
class=
"dropdown navDropdown"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Examples
<b
class=
"caret"
></b></a>
<span
class=
"dropdown-arrow"
></span>
<ul
class=
"dropdown-menu"
>
<ul
class=
"dropdown-menu"
style=
"min-width: 200px;"
>
<li
class=
"dropdown-submenu"
>
<a
tabindex=
"-1"
>
Origami
<span
class=
"pull-right fui-arrow-right"
></span></a>
<ul
class=
"dropdown-menu"
>
...
...
js/importer.js
View file @
788eaf85
...
...
@@ -253,11 +253,11 @@ function initImporter(globals){
break
;
case
3
:
//outline
shouldSkip
=
true
;
creaseParams
.
push
(
-
Math
.
PI
)
;
break
;
case
2
:
//crease
creaseParams
.
push
(
Math
.
PI
);
//todo only mtn
creaseParams
.
push
(
Math
.
PI
);
break
;
}
if
(
!
shouldSkip
)
allCreaseParams
.
push
(
creaseParams
);
...
...
js/pattern.js
View file @
788eaf85
...
...
@@ -206,17 +206,78 @@ function initPattern(globals){
mergeVertices
();
//remove duplicates for each set of edges
removeDuplicates
(
outlines
,
outlines
);
removeDuplicates
(
mountains
,
mountains
);
removeDuplicates
(
valleys
,
valleys
);
removeDuplicates
(
cuts
,
cuts
);
removeDuplicates
(
triangulations
,
triangulations
);
//todo remove duplicates between sets?
//remove vertices that are not useful
removeRedundantVertices
(
outlines
.
concat
(
mountains
).
concat
(
valleys
).
concat
(
cuts
).
concat
(
triangulations
));
var
allEdges
=
outlines
.
concat
(
mountains
).
concat
(
valleys
).
concat
(
cuts
).
concat
(
triangulations
);
var
allEdges
=
outlines
.
concat
(
mountains
).
concat
(
valleys
).
concat
(
cuts
).
concat
(
triangulationsRaw
);
polygons
=
findPolygons
(
allEdges
);
console
.
log
(
polygons
[
0
]);
var
faces
=
triangulatePolys
(
polygons
,
allEdges
);
var
allCreaseParams
=
getFacesAndVerticesForEdges
(
faces
,
allEdges
);
globals
.
model
.
buildModel
(
faces
,
vertices
,
allEdges
,
allCreaseParams
);
}
function
removeRedundantVertices
(
set
){
// var badVertices = [];
// for (var i=0;i<vertices.length;i++){
// var vertexEdges = [];
// for (var j=0;j<=set.length;j++){
// if (set[j][0] == i || set[j][1] == i) vertexEdges.push(j);
// }
// if (vertexEdges.length == 2){
// var edge1 = set[vertexEdges[0]];
// 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 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){
// badVertices.push(i);
// var v1 = edge1[0];
// if (v1 = i) v1 = edge1[1];
// var v2 = edge2[0];
// if (v2 = i) v2 = edge2[1];
// set[vertexEdges[0]] = [v1, v2];//favor outlines over mtn valleys
// set.splice(vertexEdges[1], 1);//delete extra
// }
// }
// }
// if (badVertices.length>0){
//
//
//
// // for (var j=0;j<=set.length;j++){
// // if (set[j][0] == i || set[j][1] == i) vertexEdges.push(j);
// // }
// //
// removeDuplicates(outlines, outlines);
// removeDuplicates(mountains, mountains);
// removeDuplicates(valleys, valleys);
// removeDuplicates(cuts, cuts);
// removeDuplicates(triangulations, triangulations);
// removeRedundantVertices(set);
// }
}
function
removeDuplicates
(
set1
,
set2
){
for
(
var
i
=
set1
.
length
-
1
;
i
>=
0
;
i
--
){
for
(
var
j
=
i
-
1
;
j
>=
0
;
j
--
){
var
edge1
=
set1
[
i
];
var
edge2
=
set2
[
j
];
if
(
edge2
.
indexOf
(
edge1
[
0
])
>=
0
&&
edge2
.
indexOf
(
edge1
[
1
])
>=
0
){
set2
.
splice
(
j
,
1
);
j
--
;
}
}
}
}
function
getFacesAndVerticesForEdges
(
faces
,
allEdges
){
var
allCreaseParams
=
[];
//face1Ind, vertInd, face2Ind, ver2Ind, edgeInd, angle
for
(
var
i
=
outlines
.
length
;
i
<
allEdges
.
length
;
i
++
){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment