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
ac9a63b4
Commit
ac9a63b4
authored
May 06, 2017
by
amandaghassaei
Browse files
ignore stray vertices
parent
ac66c067
Changes
1
Hide whitespace changes
Inline
Side-by-side
js/pattern.js
View file @
ac9a63b4
...
...
@@ -296,17 +296,28 @@ function initPattern(globals){
}
}
if
(
_weededVertices
.
length
>
0
){
alert
(
"
Some vertices are not fully connected, try increasing vertex merge tolerance
"
);
return
;
}
outlines
=
outlinesRaw
.
slice
();
mountains
=
mountainsRaw
.
slice
();
valleys
=
valleysRaw
.
slice
();
cuts
=
cutsRaw
.
slice
();
triangulations
=
triangulationsRaw
.
slice
();
var
strays
=
findStrayVertices
();
combined
.
concat
(
strays
);
for
(
var
i
=
0
;
i
<
strays
.
length
;
i
++
){
for
(
var
j
=
0
;
j
<
_weededVertices
.
length
;
j
++
){
if
(
vertices
[
strays
[
i
]].
equals
(
_weededVertices
[
j
])){
_weededVertices
.
splice
(
j
,
1
);
break
;
}
}
}
if
(
_weededVertices
.
length
>
0
){
alert
(
"
Some vertices are not fully connected, try increasing vertex merge tolerance
"
);
return
;
}
removeCombinedFromSet
(
combined
,
outlines
);
removeCombinedFromSet
(
combined
,
mountains
);
removeCombinedFromSet
(
combined
,
valleys
);
...
...
@@ -315,6 +326,24 @@ function initPattern(globals){
vertices
=
mergedVertices
;
}
function
findStrayVertices
(){
var
connected
=
[];
for
(
var
i
=
0
;
i
<
vertices
.
length
;
i
++
){
connected
.
push
(
false
);
}
var
allEdges
=
outlines
.
concat
(
mountains
).
concat
(
valleys
).
concat
(
cuts
).
concat
(
triangulations
);
for
(
var
i
=
0
;
i
<
allEdges
.
length
;
i
++
){
var
edge
=
allEdges
[
i
];
connected
[
edge
[
0
]]
=
true
;
connected
[
edge
[
1
]]
=
true
;
}
var
strays
=
[];
for
(
var
i
=
0
;
i
<
vertices
.
length
;
i
++
){
if
(
!
connected
[
i
])
strays
.
push
(
i
);
}
return
strays
;
}
function
triangulatePolys
(
polygonData
,
allEdges
,
_vertices
,
shouldRotateFace
){
if
(
_vertices
===
undefined
)
_vertices
=
vertices
;
var
polygons
=
polygonData
[
0
];
...
...
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