Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
897bde6e
Commit
897bde6e
authored
Feb 10, 2017
by
Benedikt Zoennchen
Browse files
fixing the problem with non-acute triangles for the FMM
parent
f4280343
Changes
13
Hide whitespace changes
Inline
Side-by-side
VadereUtils/src/org/vadere/util/geometry/shapes/VCone.java
View file @
897bde6e
package
org.vadere.util.geometry.shapes
;
import
org.jetbrains.annotations.NotNull
;
import
org.omg.CORBA.portable.ValueOutputStream
;
import
org.vadere.util.geometry.GeometryUtils
;
/**
...
...
@@ -48,6 +47,7 @@ public class VCone {
/*
* TODO: test
*/
public
boolean
overlapLineSegment
(
final
VLine
line
)
{
VPoint
a
=
new
VPoint
(
line
.
getX1
(),
line
.
getY1
());
VPoint
b
=
new
VPoint
(
line
.
getX2
(),
line
.
getY2
());
...
...
@@ -61,7 +61,7 @@ public class VCone {
VPoint
v3
=
new
VPoint
(-
direction
.
getY
(),
direction
.
getX
());
double
t1
=
v2
.
crossProduct
(
v1
)
/
v2
.
scalarProduct
(
v3
);
double
t2
=
v1
.
scalarProduct
(
v3
)
/
v2
.
scalarProduct
(
v3
);
assert
Double
.
isFinite
(
t1
)
&&
Double
.
isFinite
(
t2
);
// the line segment from a to b intersect the cone?
...
...
VadereUtils/src/org/vadere/util/potential/calculators/EikonalSolverFMMAcuteTriangulation.java
View file @
897bde6e
package
org.vadere.util.potential.calculators
;
public
class
EikonalSolverFMMAcuteTriangulation
implements
EikonalSolver
{
@Override
public
void
initialize
()
{
...
...
VadereUtils/src/org/vadere/util/triangulation/UniformTriangulation.java
View file @
897bde6e
...
...
@@ -2,7 +2,10 @@ package org.vadere.util.triangulation;
import
org.vadere.util.geometry.shapes.IPoint
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -29,7 +32,9 @@ public class UniformTriangulation<P extends IPoint> extends DelaunayTriangulatio
this
.
minTriangleSideLength
=
minTriangleSideLength
;
this
.
pointConstructor
=
pointConstructor
;
for
(
P
point
:
generatePointSet
())
{
List
<
P
>
pointList
=
new
ArrayList
<
P
>(
generatePointSet
());
Collections
.
shuffle
(
pointList
);
for
(
P
point
:
pointList
)
{
insert
(
point
);
}
}
...
...
VadereUtils/src/org/vadere/util/triangulation/adaptive/IEdgeLengthFunction.java
View file @
897bde6e
...
...
@@ -19,6 +19,7 @@ public interface IEdgeLengthFunction extends Function<IPoint,Double> {
return
new
DensityEdgeLenFunction
(
densityFunc
,
regionBoundingBox
);
}
static
IEdgeLengthFunction
create
(
final
VRectangle
regionBoundingBox
,
final
Collection
<?
extends
VShape
>
obstacles
,
final
IDistanceFunction
distanceFunc
){
...
...
VadereUtils/src/org/vadere/util/triangulation/adaptive/PSDistmesh.java
View file @
897bde6e
...
...
@@ -21,7 +21,7 @@ import java.util.*;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
public
class
PSDistmesh
{
public
class
PSDistmesh
{
private
Set
<
MeshPoint
>
points
=
new
HashSet
<>();
private
Set
<
MLine
<
MeshPoint
>>
lines
=
new
HashSet
<>();
private
IncrementalTriangulation
<
MeshPoint
,
PHalfEdge
<
MeshPoint
>,
PFace
<
MeshPoint
>>
bowyerWatson
;
...
...
@@ -108,7 +108,7 @@ public class PSDistmesh {
.filter(triple -> obstacles.stream().noneMatch(
obstacle ->
tripleToTriangle(triple).intersect(obstacle))).collect(Collectors.toSet());*/
reTriangulate
();
//
reTriangulate();
/*obstacles.stream()
.filter(shape -> shape instanceof VRectangle)
.map(shape -> (VRectangle)shape).forEach(rect -> {
...
...
VadereUtils/src/org/vadere/util/triangulation/adaptive/Parameters.java
View file @
897bde6e
...
...
@@ -10,7 +10,7 @@ public class Parameters {
public
final
static
double
h0
=
0.15
;
public
final
static
boolean
uniform
=
false
;
public
final
static
String
method
=
"Distmesh"
;
// "Distmesh" or "Density"
final
static
double
qualityMeasurement
=
0.87
5
;
final
static
double
qualityMeasurement
=
0.87
;
final
static
double
MINIMUM
=
0.25
;
final
static
double
DENSITYWEIGHT
=
2
;
final
static
int
NPOINTS
=
100000
;
...
...
VadereUtils/src/org/vadere/util/triangulation/adaptive/PerssonStrangDistmesh.java
View file @
897bde6e
...
...
@@ -38,7 +38,6 @@ public class PerssonStrangDistmesh {
boolean
uniform
,
Function
<
VPoint
,
Double
>
density
,
String
method
)
{
long
now
=
System
.
currentTimeMillis
();
this
.
h0
=
h0
;
this
.
geps
=
.
001
*
h0
;
this
.
deps
=
1.4901
e
-
8
*
h0
;
...
...
@@ -88,6 +87,10 @@ public class PerssonStrangDistmesh {
addAll
(
obstacles
);
add
(
box
);
}});
}
public
void
execude
()
{
long
now
=
System
.
currentTimeMillis
();
setOldPointsToInf
();
work
();
Date
date
=
new
Date
(
System
.
currentTimeMillis
()
-
now
);
...
...
VadereUtils/src/org/vadere/util/triangulation/adaptive/TestEnhancedVersion.java
View file @
897bde6e
...
...
@@ -62,7 +62,7 @@ public class TestEnhancedVersion extends JFrame {
double
quality
=
meshGenerator
.
qualityCheck
();
while
(
quality
<
0.
87
)
{
while
(
quality
<
0.
95
)
{
System
.
out
.
println
(
"quality:"
+
quality
);
meshGenerator
.
step
();
/*try {
...
...
VadereUtils/src/org/vadere/util/triangulation/adaptive/TestEnhancedVersion2.java
View file @
897bde6e
...
...
@@ -65,6 +65,8 @@ public class TestEnhancedVersion2 extends JFrame {
setDefaultCloseOperation
(
WindowConstants
.
EXIT_ON_CLOSE
);
setVisible
(
true
);
new
Thread
(()
->
meshGenerator
.
execude
()).
start
();
while
(
true
)
{
try
{
Thread
.
sleep
(
1000
);
...
...
VadereUtils/tests/org/vadere/util/geometry/TestBoyerWatson.java
deleted
100644 → 0
View file @
f4280343
package
org.vadere.util.geometry
;
import
org.apache.commons.lang3.tuple.Triple
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.vadere.util.geometry.data.DAG
;
import
org.vadere.util.geometry.data.HalfEdge
;
import
org.vadere.util.triangulation.DelaunayTriangulation
;
import
org.vadere.util.triangulation.DAGElement
;
import
org.vadere.util.geometry.data.Face
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VTriangle
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Random
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
TestBoyerWatson
{
@Before
public
void
setUp
()
throws
Exception
{}
@Test
public
void
testFaceIterator
()
{
VPoint
p1
=
new
VPoint
(
0
,
0
);
VPoint
p2
=
new
VPoint
(
50
,
0
);
VPoint
p3
=
new
VPoint
(
50
,
50
);
VPoint
p4
=
new
VPoint
(
0
,
50
);
VPoint
p6
=
new
VPoint
(
50
,
50
);
VPoint
p5
=
new
VPoint
(
25
,
25
);
Set
<
VPoint
>
points
=
new
HashSet
<>();
points
.
add
(
p1
);
points
.
add
(
p2
);
points
.
add
(
p3
);
points
.
add
(
p4
);
points
.
add
(
p6
);
DelaunayTriangulation
<
VPoint
>
boyerWatsonImproved
=
new
DelaunayTriangulation
<>(
points
,
(
x
,
y
)
->
new
VPoint
(
x
,
y
));
boyerWatsonImproved
.
compute
();
Collection
<
VTriangle
>
triangulation
=
boyerWatsonImproved
.
getTriangles
();
triangulation
.
forEach
(
System
.
out
::
print
);
}
/* TODO: reimplement it
@Test
public void testSplit() {
VPoint p1 = new VPoint(0,0);
VPoint p2 = new VPoint(50, 0);
VPoint p3 = new VPoint(25, 25);
VPoint centerPoint = new VPoint(25, 10);
Set<VPoint> points = new HashSet<>();
points.add(p1);
points.add(p2);
points.add(p3);
Face<VPoint> face = Face.of(p1,p2,p3);
DAG<DAGElement<VPoint>> dag = new DAG<>(new DAGElement<>(face, Triple.of(p1,p2,p3)));
DelaunayTriangulation<VPoint> boyerWatsonImproved = new DelaunayTriangulation<>(points, (x, y) -> new VPoint(x, y));
HalfEdge<VPoint> result = boyerWatsonImproved.split(centerPoint, dag);
Set<VTriangle> triangulation = new HashSet<>(result.collectLeafs().stream().map(dagElement -> dagElement.getTriangle()).collect(Collectors.toList()));
Set<VTriangle> expectedResult = new HashSet<>(Arrays.asList(new VTriangle(p1, p2, centerPoint), new VTriangle(p2, p3, centerPoint), new VTriangle(p1, p3, centerPoint)));
assertTrue(testTriangulationEquality(triangulation, expectedResult));
}*/
@Test
public
void
testPerformance
()
{
Set
<
VPoint
>
points
=
new
HashSet
<>();
int
width
=
300
;
int
height
=
300
;
Random
r
=
new
Random
();
int
numberOfPoints
=
100000
;
for
(
int
i
=
0
;
i
<
numberOfPoints
;
i
++)
{
VPoint
point
=
new
VPoint
(
width
*
r
.
nextDouble
(),
height
*
r
.
nextDouble
());
points
.
add
(
point
);
}
long
ms
=
System
.
currentTimeMillis
();
DelaunayTriangulation
<
VPoint
>
bw
=
new
DelaunayTriangulation
<>(
points
,
(
x
,
y
)
->
new
VPoint
(
x
,
y
));
bw
.
compute
();
System
.
out
.
println
(
"runtime of the BowyerWatson for "
+
numberOfPoints
+
" vertices ="
+
(
System
.
currentTimeMillis
()
-
ms
));
}
private
static
boolean
testTriangulationEquality
(
final
Set
<
VTriangle
>
triangulation1
,
final
Set
<
VTriangle
>
triangulation2
)
{
if
(
triangulation1
.
size
()
!=
triangulation2
.
size
())
return
false
;
for
(
VTriangle
triangle1
:
triangulation1
)
{
boolean
found
=
false
;
for
(
VTriangle
triangle2
:
triangulation2
)
{
if
(
TestBoyerWatson
.
testTriangleEquality
(
triangle1
,
triangle2
)){
found
=
true
;
}
}
if
(!
found
)
return
false
;
}
return
true
;
}
private
static
boolean
testTriangleEquality
(
final
VTriangle
triangle1
,
final
VTriangle
triangle2
)
{
return
(
triangle2
.
p1
.
equals
(
triangle1
.
p1
)
&&
triangle2
.
p2
.
equals
(
triangle1
.
p2
)
&&
triangle2
.
p3
.
equals
(
triangle1
.
p3
))
||
(
triangle2
.
p1
.
equals
(
triangle1
.
p1
)
&&
triangle2
.
p2
.
equals
(
triangle1
.
p3
)
&&
triangle2
.
p3
.
equals
(
triangle1
.
p2
))
||
(
triangle2
.
p1
.
equals
(
triangle1
.
p2
)
&&
triangle2
.
p2
.
equals
(
triangle1
.
p1
)
&&
triangle2
.
p3
.
equals
(
triangle1
.
p3
))
||
(
triangle2
.
p1
.
equals
(
triangle1
.
p2
)
&&
triangle2
.
p2
.
equals
(
triangle1
.
p3
)
&&
triangle2
.
p3
.
equals
(
triangle1
.
p1
))
||
(
triangle2
.
p1
.
equals
(
triangle1
.
p3
)
&&
triangle2
.
p2
.
equals
(
triangle1
.
p2
)
&&
triangle2
.
p3
.
equals
(
triangle1
.
p1
))
||
(
triangle2
.
p1
.
equals
(
triangle1
.
p3
)
&&
triangle2
.
p2
.
equals
(
triangle1
.
p1
)
&&
triangle2
.
p3
.
equals
(
triangle1
.
p2
));
}
}
VadereUtils/tests/org/vadere/util/geometry/TestCone.java
View file @
897bde6e
...
...
@@ -15,8 +15,6 @@ 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
)));
...
...
VadereUtils/tests/org/vadere/util/potential/TestFFMNonUniformTriangulation.java
View file @
897bde6e
...
...
@@ -23,7 +23,6 @@ import java.io.FileWriter;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.swing.*
;
...
...
@@ -93,10 +92,5 @@ public class TestFFMNonUniformTriangulation {
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
while
(
true
)
{}
//assertTrue(0.0 == solver.getValue(5, 5));
//assertTrue(0.0 < solver.getValue(1, 7));
}
}
VadereUtils/tests/org/vadere/util/triangulation/TestBoyerWatson.java
View file @
897bde6e
package
org.vadere.util.triangulation
;
import
org.apache.commons.lang3.tuple.Triple
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.vadere.util.geometry.mesh.impl.PFace
;
import
org.vadere.util.geometry.mesh.inter.IMesh
;
import
org.vadere.util.geometry.mesh.impl.PHalfEdge
;
import
org.vadere.util.geometry.mesh.impl.PMesh
;
import
org.vadere.util.geometry.mesh.triangulations.IncrementalTriangulation
;
import
org.vadere.util.geometry.data.DAG
;
import
org.vadere.util.geometry.data.Face
;
import
org.vadere.util.geometry.data.HalfEdge
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VTriangle
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Random
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
TestBoyerWatson
{
private
IMesh
<
VPoint
,
PHalfEdge
<
VPoint
>,
PFace
<
VPoint
>>
mesh
;
@Before
public
void
setUp
()
throws
Exception
{
mesh
=
new
PMesh
<>((
x
,
y
)
->
new
VPoint
(
x
,
y
));
}
public
void
setUp
()
throws
Exception
{}
@Test
public
void
testFaceIterator
()
{
VPoint
p1
=
mesh
.
createVertex
(
0
,
0
);
VPoint
p2
=
mesh
.
createVertex
(
50
,
0
);
VPoint
p3
=
mesh
.
createVertex
(
50
,
50
);
VPoint
p4
=
mesh
.
createVertex
(
0
,
50
);
VPoint
p1
=
new
VPoint
(
0
,
0
);
VPoint
p2
=
new
VPoint
(
50
,
0
);
VPoint
p3
=
new
VPoint
(
50
,
50
);
VPoint
p4
=
new
VPoint
(
0
,
50
);
VPoint
p6
=
mesh
.
createVertex
(
50
,
50
);
VPoint
p5
=
mesh
.
createVertex
(
25
,
25
);
VPoint
p6
=
new
VPoint
(
50
,
50
);
VPoint
p5
=
new
VPoint
(
25
,
25
);
Set
<
VPoint
>
points
=
new
HashSet
<>();
points
.
add
(
p1
);
...
...
@@ -44,70 +39,34 @@ public class TestBoyerWatson {
points
.
add
(
p3
);
points
.
add
(
p4
);
points
.
add
(
p6
);
points
.
add
(
p5
);
IncrementalTriangulation
<
VPoint
,
PHalfEdge
<
VPoint
>,
PFace
<
VPoint
>>
delaunayTriangulation
=
new
IncrementalTriangulation
<>(
mesh
,
points
,
(
x
,
y
)
->
new
VPoint
(
x
,
y
));
delaunayTriangulation
.
compute
();
//delaunayTriangulation.finalize();
Set
<
VTriangle
>
triangulation
=
new
HashSet
<>(
delaunayTriangulation
.
getTriangles
());
Set
<
VPoint
>
triangle1
=
new
HashSet
<>();
triangle1
.
add
(
p1
);
triangle1
.
add
(
p5
);
triangle1
.
add
(
p4
);
Set
<
VPoint
>
triangle2
=
new
HashSet
<>();
triangle2
.
add
(
p1
);
triangle2
.
add
(
p2
);
triangle2
.
add
(
p5
);
Set
<
VPoint
>
triangle3
=
new
HashSet
<>();
triangle3
.
add
(
p2
);
triangle3
.
add
(
p3
);
triangle3
.
add
(
p5
);
Set
<
VPoint
>
triangle4
=
new
HashSet
<>();
triangle4
.
add
(
p4
);
triangle4
.
add
(
p5
);
triangle4
.
add
(
p3
);
Set
<
Set
<
VPoint
>>
pointSets
=
triangulation
.
stream
().
map
(
t
->
new
HashSet
<>(
t
.
getPoints
())).
collect
(
Collectors
.
toSet
());
Set
<
Set
<
VPoint
>>
expextedPointSets
=
new
HashSet
<>();
expextedPointSets
.
add
(
triangle1
);
expextedPointSets
.
add
(
triangle2
);
expextedPointSets
.
add
(
triangle3
);
expextedPointSets
.
add
(
triangle4
);
assertTrue
(
expextedPointSets
.
equals
(
pointSets
));
triangulation
.
forEach
(
System
.
out
::
println
);
DelaunayTriangulation
<
VPoint
>
boyerWatsonImproved
=
new
DelaunayTriangulation
<>(
points
,
(
x
,
y
)
->
new
VPoint
(
x
,
y
));
boyerWatsonImproved
.
compute
();
Collection
<
VTriangle
>
triangulation
=
boyerWatsonImproved
.
getTriangles
();
triangulation
.
forEach
(
System
.
out
::
print
);
}
@Test
public
void
testSplitTriangle
()
{
VPoint
p1
=
mesh
.
createVertex
(
0
,
0
);
VPoint
p2
=
mesh
.
createVertex
(
50
,
0
);
VPoint
p3
=
mesh
.
createVertex
(
25
,
25
);
VPoint
centerPoint
=
mesh
.
createVertex
(
25
,
10
);
public
void
testSplit
()
{
VPoint
p1
=
new
VPoint
(
0
,
0
);
VPoint
p2
=
new
VPoint
(
50
,
0
);
VPoint
p3
=
new
VPoint
(
25
,
25
);
VPoint
centerPoint
=
new
VPoint
(
25
,
10
);
Set
<
VPoint
>
points
=
new
HashSet
<>();
points
.
add
(
p1
);
points
.
add
(
p2
);
points
.
add
(
p3
);
IncrementalTriangulation
<
VPoint
,
PHalfEdge
<
VPoint
>,
PFace
<
VPoint
>>
delaunayTriangulation
=
new
IncrementalTriangulation
<>(
mesh
,
points
,
(
x
,
y
)
->
new
VPoint
(
x
,
y
));
delaunayTriangulation
.
compute
();
PFace
<
VPoint
>
face
=
delaunayTriangulation
.
locate
(
centerPoint
).
get
();
Face
<
VPoint
>
face
=
Face
.
of
(
p1
,
p2
,
p3
);
DAG
<
DAGElement
<
VPoint
>>
dag
=
new
DAG
<>(
new
DAGElement
<>(
face
,
Triple
.
of
(
p1
,
p2
,
p3
)));
d
elaunayTriangulation
.
splitTriangle
(
face
,
centerPoint
);
delaunayTriangul
at
i
on
.
finalize
(
);
D
elaunayTriangulation
<
VPoint
>
boyerWatsonImproved
=
new
DelaunayTriangulation
<>(
points
,
(
x
,
y
)
->
new
VPoint
(
x
,
y
)
);
HalfEdge
<
VPoint
>
result
=
boyerW
at
s
on
Improved
.
split
(
centerPoint
,
dag
);
Set
<
VTriangle
>
triang
les
=
new
HashSet
<>(
delaunayTriangulation
.
getTriangles
(
));
Set
<
VTriangle
>
triang
ulation
=
new
HashSet
<>(
result
.
collectLeafs
().
stream
().
map
(
dagElement
->
dagElement
.
getTriangle
()).
collect
(
Collectors
.
toList
()
));
Set
<
VTriangle
>
expectedResult
=
new
HashSet
<>(
Arrays
.
asList
(
new
VTriangle
(
p1
,
p2
,
centerPoint
),
new
VTriangle
(
p2
,
p3
,
centerPoint
),
new
VTriangle
(
p1
,
p3
,
centerPoint
)));
assertTrue
(
testTriangulationEquality
(
triang
les
,
expectedResult
));
assertTrue
(
testTriangulationEquality
(
triang
ulation
,
expectedResult
));
}
@Test
...
...
@@ -117,17 +76,16 @@ public class TestBoyerWatson {
int
height
=
300
;
Random
r
=
new
Random
();
int
numberOfPoints
=
1000
;
int
numberOfPoints
=
1000
00
;
for
(
int
i
=
0
;
i
<
numberOfPoints
;
i
++)
{
VPoint
point
=
mesh
.
createVertex
(
width
*
r
.
nextDouble
(),
height
*
r
.
nextDouble
());
VPoint
point
=
new
VPoint
(
width
*
r
.
nextDouble
(),
height
*
r
.
nextDouble
());
points
.
add
(
point
);
}
long
ms
=
System
.
currentTimeMillis
();
IncrementalTriangulation
<
VPoint
,
PHalfEdge
<
VPoint
>,
PFace
<
VPoint
>>
delaunayTriangulation
=
new
IncrementalTriangulation
<>(
mesh
,
points
,
(
x
,
y
)
->
new
VPoint
(
x
,
y
));
delaunayTriangulation
.
compute
();
DelaunayTriangulation
<
VPoint
>
bw
=
new
DelaunayTriangulation
<>(
points
,
(
x
,
y
)
->
new
VPoint
(
x
,
y
));
bw
.
compute
();
System
.
out
.
println
(
"runtime of the BowyerWatson for "
+
numberOfPoints
+
" vertices ="
+
(
System
.
currentTimeMillis
()
-
ms
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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