Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
vadere
vadere
Commits
bfc21eb5
Commit
bfc21eb5
authored
Feb 16, 2017
by
Benedikt Zoennchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
before changing initial point generation of DSMesh
parent
f203307d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
+69
-0
VadereUtils/src/org/vadere/util/triangulation/FaceIterator.java
...Utils/src/org/vadere/util/triangulation/FaceIterator.java
+67
-0
VadereUtils/tests/org/vadere/util/geometry/TestCone.java
VadereUtils/tests/org/vadere/util/geometry/TestCone.java
+2
-0
No files found.
VadereUtils/src/org/vadere/util/triangulation/FaceIterator.java
0 → 100644
View file @
bfc21eb5
package
org.vadere.util.triangulation
;
import
org.vadere.util.geometry.data.Face
;
import
org.vadere.util.geometry.data.HalfEdge
;
import
org.vadere.util.geometry.shapes.IPoint
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.Set
;
import
java.util.function.Predicate
;
/**
* @author Benedikt Zoennchen
*
* @param <P>
*/
public
class
FaceIterator
<
P
extends
IPoint
>
implements
Iterator
<
Face
<
P
>>
{
private
LinkedList
<
Face
<
P
>>
facesToVisit
;
private
Set
<
Face
<
P
>>
visitedFaces
;
private
Predicate
<
Face
<
P
>>
facePredicate
;
public
FaceIterator
(
final
Face
<
P
>
face
,
final
Predicate
<
Face
<
P
>>
facePredicate
)
{
facesToVisit
=
new
LinkedList
<>();
Face
<
P
>
startFace
=
face
.
isBorder
()
?
face
.
getEdge
().
getTwin
().
getFace
()
:
face
;
if
(
startFace
.
isDestroyed
())
{
throw
new
IllegalArgumentException
(
"this face is already destroyed."
);
}
facesToVisit
.
add
(
startFace
);
visitedFaces
=
new
HashSet
<>();
this
.
facePredicate
=
facePredicate
;
}
public
FaceIterator
(
final
Face
<
P
>
face
)
{
this
(
face
,
f
->
true
);
}
@Override
public
boolean
hasNext
()
{
return
!
facesToVisit
.
isEmpty
();
}
@Override
public
Face
<
P
>
next
()
{
Face
<
P
>
nextFace
=
facesToVisit
.
removeFirst
();
visitedFaces
.
add
(
nextFace
);
for
(
HalfEdge
<
P
>
he
:
nextFace
)
{
Face
<
P
>
twinFace
=
he
.
getTwin
().
getFace
();
if
(
twinFace
.
isBorder
()
||
twinFace
.
isDestroyed
()
||
!
facePredicate
.
test
(
twinFace
))
{
visitedFaces
.
add
(
twinFace
);
}
if
(!
visitedFaces
.
contains
(
twinFace
))
{
facesToVisit
.
add
(
twinFace
);
}
visitedFaces
.
add
(
twinFace
);
}
return
nextFace
;
}
}
VadereUtils/tests/org/vadere/util/geometry/TestCone.java
View file @
bfc21eb5
...
...
@@ -15,6 +15,8 @@ public class TestCone {
// 90 degree cone
VCone
cone
=
new
VCone
(
new
VPoint
(
0
,
0
),
new
VPoint
(
1
,
1
),
Math
.
PI
/
2
);
assertTrue
(
cone
.
contains
(
new
VPoint
(
1
,
1
)));
assertTrue
(
cone
.
contains
(
new
VPoint
(
5
,
7
)));
assertTrue
(
cone
.
contains
(
new
VPoint
(
5
,
7000
)));
assertTrue
(
cone
.
contains
(
new
VPoint
(
1
,
0.00001
)));
assertTrue
(
cone
.
contains
(
new
VPoint
(
0.00001
,
1
)));
...
...
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