Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
6fac4803
Commit
6fac4803
authored
Oct 29, 2018
by
Benedikt Zoennchen
Browse files
improve the resolvement of the special case of walking inside trinagles.
parent
6c45179a
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
VadereMeshing/src/org/vadere/meshing/mesh/gen/ConstrainedTriangulation.java
View file @
6fac4803
...
...
@@ -51,7 +51,7 @@ public class ConstrainedTriangulation<P extends IPoint, V extends IVertex<P>, E
if
(
optFace
.
isPresent
())
{
F
startFace
=
optFace
.
get
();
boolean
startFaceIsInvalid
=
faceIntersectsLine
(
startFace
,
new
VPoint
(
line
.
x1
,
line
.
y1
),
new
VPoint
(
line
.
x2
,
line
.
y2
));
LinkedList
<
F
>
invalidFaces
=
straightGatherWalk2D
(
line
.
x2
,
line
.
y2
,
startFace
);
LinkedList
<
E
>
invalidFaces
=
straightGatherWalk2D
(
line
.
x2
,
line
.
y2
,
startFace
);
if
(!
startFaceIsInvalid
)
{
invalidFaces
.
removeFirst
();
...
...
VadereMeshing/src/org/vadere/meshing/mesh/inter/IMesh.java
View file @
6fac4803
...
...
@@ -350,6 +350,17 @@ public interface IMesh<P extends IPoint, V extends IVertex<P>, E extends IHalfEd
*/
boolean
isHole
(
@NotNull
F
face
);
/**
* Returns true if the edge is a hole edge i.e. part of a hole in O(1) (there might be multiple holes
* and each hole is a boundary).
*
* @param edge the edge
* @return true if the edge is a hole edge, false otherwise
*/
default
boolean
isHole
(
@NotNull
E
edge
)
{
return
isHole
(
getFace
(
edge
));
}
/**
* Returns true if the vertex is a boundary vertex in O(d) worst case where d
* is the degree of the vertex. In general this should only cost O(1) if the data
...
...
VadereMeshing/src/org/vadere/meshing/mesh/inter/IPolyConnectivity.java
View file @
6fac4803
...
...
@@ -826,16 +826,47 @@ public interface IPolyConnectivity<P extends IPoint, V extends IVertex<P>, E ext
* Does not change the connectivity.
*
* @param p1 the first point of the undirected line
* @param p2 the
first
point of the undirected line
* @param p2 the
second
point of the undirected line
* @param edge the half-edge defining the line-segment
* @return true if the line-segment defined by the half-edge intersects the line (p1, p2)
*/
default
boolean
intersects
(
final
IPoint
p1
,
final
IPoint
p2
,
E
edge
)
{
V
v1
=
getMesh
().
getVertex
(
getMesh
().
getPrev
(
edge
));
V
v2
=
getMesh
().
getVertex
(
edge
);
return
intersects
(
p1
,
p2
,
v1
,
v2
);
}
/**
* Tests if the line-segment defined by the (v1,v2) intersects the line defined by p1 and p2 in O(1).
*
* Does not change the connectivity.
*
* @param p1 the first point of the undirected line
* @param p2 the second point of the undirected line
* @param v1 the first point of the line-segment
* @param v2 the second point of the line-segment
* @return true if the line-segment defined by (v1,v2) intersects the line (p1, p2)
*/
default
boolean
intersects
(
final
IPoint
p1
,
final
IPoint
p2
,
V
v1
,
V
v2
)
{
return
GeometryUtils
.
intersectLine
(
p1
.
getX
(),
p1
.
getY
(),
p2
.
getX
(),
p2
.
getY
(),
v1
.
getX
(),
v1
.
getY
(),
v2
.
getX
(),
v2
.
getY
());
}
/**
* Tests if the half-line-segment starting at p1 in the direction (p2-p1) intersects the line-segment defined by the half-edge in O(1).
*
* Does not change the connectivity.
*
* @param p1 the start point of the directed half-line-segment
* @param p2 the second point of the directed half-line-segment of direction (p2-p1).
* @param edge the half-edge defining the line-segment
* @return true if the half-line-segment starting at p1 in the direction (p2-p1) intersects the line-segment defined by the half-edge, false otherwise
*/
default
boolean
intersectsDirectional
(
final
IPoint
p1
,
final
IPoint
p2
,
E
edge
)
{
V
v1
=
getMesh
().
getVertex
(
getMesh
().
getPrev
(
edge
));
V
v2
=
getMesh
().
getVertex
(
edge
);
return
GeometryUtils
.
intersectHalfLineSegment
(
p1
.
getX
(),
p1
.
getY
(),
p2
.
getX
(),
p2
.
getY
(),
v1
.
getX
(),
v1
.
getY
(),
v2
.
getX
(),
v2
.
getY
());
}
/*default void fill_hole (final V v, final List<E> deletedEdges)
{
...
...
VadereMeshing/src/org/vadere/meshing/mesh/inter/ITriConnectivity.java
View file @
6fac4803
This diff is collapsed.
Click to expand it.
VadereMeshing/tests/org/vadere/geometry/triangulation/TestVisual.java
View file @
6fac4803
...
...
@@ -56,7 +56,7 @@ public class TestVisual {
Set
<
VPoint
>
points
=
new
HashSet
<>();
Random
r
=
new
Random
();
Random
r
=
new
Random
(
1
);
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
VPoint
point
=
new
VPoint
(
width
*
r
.
nextDouble
(),
height
*
r
.
nextDouble
());
points
.
add
(
point
);
...
...
@@ -67,7 +67,7 @@ public class TestVisual {
VPTriangulation
triangulation
=
IIncrementalTriangulation
.
createVPTriangulation
(
bound
);
triangulation
.
insert
(
points
);
triangulation
.
finish
();
//
triangulation.finish();
Set
<
VLine
>
edges
=
triangulation
.
getEdges
();
JFrame
window
=
new
JFrame
();
...
...
VadereSimulator/src/org/vadere/simulator/models/potential/solver/calculators/mesh/EikonalSolverFMMTriangulation.java
View file @
6fac4803
...
...
@@ -12,11 +12,9 @@ import org.vadere.meshing.mesh.inter.IMesh;
import
org.vadere.meshing.mesh.inter.IIncrementalTriangulation
;
import
org.vadere.meshing.mesh.inter.IVertex
;
import
org.vadere.util.geometry.shapes.IPoint
;
import
org.vadere.util.geometry.shapes.VCircle
;
import
org.vadere.util.geometry.shapes.VCone
;
import
org.vadere.util.geometry.shapes.VLine
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VRectangle
;
import
org.vadere.util.geometry.shapes.VShape
;
import
org.vadere.util.geometry.shapes.VTriangle
;
import
org.vadere.util.math.InterpolationUtil
;
...
...
@@ -29,7 +27,6 @@ import org.vadere.meshing.mesh.iterators.FaceIterator;
import
org.vadere.util.math.IDistanceFunction
;
import
java.awt.*
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.HashSet
;
...
...
@@ -412,7 +409,7 @@ public class EikonalSolverFMMTriangulation<P extends IPotentialPoint, V extends
Predicate
<
E
>
isEdgeInCone
=
e
->
isPointInCone
.
test
(
e
)
||
isPointInCone
.
test
(
getMesh
().
getPrev
(
e
));
LinkedList
<
F
>
visitedFaces
=
triangulation
.
straightWalk2DGather
(
halfEdge
,
face
,
direction2
,
isEdgeInCone
);
LinkedList
<
F
>
visitedFaces
=
triangulation
.
straightWalk2DGather
Directional
(
halfEdge
,
face
,
direction2
,
isEdgeInCone
);
F
destination
=
visitedFaces
.
getLast
();
SimpleTriCanvas
canvas
=
SimpleTriCanvas
.
simpleCanvas
(
getMesh
());
...
...
@@ -451,7 +448,7 @@ public class EikonalSolverFMMTriangulation<P extends IPotentialPoint, V extends
return mesh.isAtBoundary(e) || feasableEdgePred.test(e) || Utils.isRightOf(midPoint, midPoint.add(direction1), mesh.toPoint(e));
};
F newFace = triangulation.straightWalk2D(halfEdge, direction1, stopCondition);
F newFace = triangulation.straightWalk2D
Directional
(halfEdge, direction1, stopCondition);
if(!mesh.isBoundary(newFace)) {
return mesh.streamVertices(newFace).filter(v -> feasableVertexPred.test(v)).map(v -> mesh.getPoint(v)).findAny();
...
...
VadereSimulator/tests/org/vadere/simulator/models/potential/solver/TestFFMNonUniformTriangulation.java
View file @
6fac4803
...
...
@@ -82,7 +82,6 @@ public class TestFFMNonUniformTriangulation {
return
eikMesh
;
}
@Ignore
@Test
public
void
testTriangulationFMM
()
{
...
...
@@ -101,14 +100,8 @@ public class TestFFMNonUniformTriangulation {
triangulation
=
meshGenerator
.
getTriangulation
();
Predicate
<
PFace
<
PotentialPoint
>>
nonAccute
=
f
->
triangulation
.
getMesh
().
toTriangle
(
f
).
isNonAcute
();
MeshPanel
meshPanel
=
new
MeshPanel
(
meshGenerator
.
getMesh
(),
nonAccute
,
1000
,
1000
,
bbox
);
meshPanel
.
display
();
try
{
Thread
.
sleep
(
10000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
//MeshPanel meshPanel = new MeshPanel(meshGenerator.getMesh(), nonAccute, 1000, 1000, bbox);
//meshPanel.display();
//targetPoints.add(new MeshPoint(0, 0, false));
...
...
VadereUtils/src/org/vadere/util/geometry/GeometryUtils.java
View file @
6fac4803
...
...
@@ -418,6 +418,12 @@ public class GeometryUtils {
return
(
ccw1
<
0
&&
ccw2
>
0
)
||
(
ccw1
>
0
&&
ccw2
<
0
);
}
public
static
boolean
intersectLine
(
final
double
pX
,
final
double
pY
,
final
double
qX
,
final
double
qY
,
final
double
p1X
,
final
double
p1Y
,
final
double
p2X
,
final
double
p2Y
,
final
double
eps
)
{
double
ccw1
=
ccw
(
pX
,
pY
,
qX
,
qY
,
p1X
,
p1Y
);
double
ccw2
=
ccw
(
pX
,
pY
,
qX
,
qY
,
p2X
,
p2Y
);
return
(
ccw1
-
eps
<
0
&&
ccw2
+
eps
>
0
)
||
(
ccw1
+
eps
>
0
&&
ccw2
-
eps
<
0
);
}
public
static
VPoint
getIncenter
(
@NotNull
final
IPoint
p1
,
@NotNull
final
IPoint
p2
,
@NotNull
final
IPoint
p3
)
{
double
a
=
p1
.
distance
(
p2
);
double
b
=
p2
.
distance
(
p3
);
...
...
@@ -441,14 +447,18 @@ public class GeometryUtils {
* @return true if the line-segment intersects the half-line-segment defined, otherwise false.
*/
public
static
boolean
intersectHalfLineSegment
(
@NotNull
final
IPoint
p
,
@NotNull
final
IPoint
q
,
@NotNull
final
IPoint
p1
,
@NotNull
final
IPoint
p2
)
{
double
ccw1
=
ccw
(
p
,
q
,
p1
);
double
ccw2
=
ccw
(
p
,
q
,
p2
);
return
intersectHalfLineSegment
(
p
.
getX
(),
p
.
getY
(),
q
.
getX
(),
q
.
getY
(),
p1
.
getX
(),
p1
.
getY
(),
p2
.
getX
(),
p2
.
getY
());
}
public
static
boolean
intersectHalfLineSegment
(
final
double
pX
,
final
double
pY
,
final
double
qX
,
final
double
qY
,
final
double
p1X
,
final
double
p1Y
,
final
double
p2X
,
final
double
p2Y
)
{
double
ccw1
=
ccw
(
pX
,
pY
,
qX
,
qY
,
p1X
,
p1X
);
double
ccw2
=
ccw
(
pX
,
pY
,
qX
,
qY
,
p2X
,
p2Y
);
if
((
ccw1
<
0
&&
ccw2
>
0
))
{
return
isCCW
(
p
,
p2
,
p1
);
return
isCCW
(
p
X
,
pY
,
p2X
,
p2Y
,
p1X
,
p1Y
);
}
else
if
((
ccw1
>
0
&&
ccw2
<
0
))
{
return
isCCW
(
p
,
p1
,
p2
);
return
isCCW
(
p
X
,
pY
,
p1X
,
p1Y
,
p2X
,
p2Y
);
}
else
{
return
false
;
...
...
Write
Preview
Supports
Markdown
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