Commit 73892c53 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

remove triangles from the triangulation if they intersect any obstacle.

parent d5f26c20
......@@ -532,6 +532,10 @@ public abstract class DefaultModel<T extends DefaultConfig> extends Observable i
fireChangeViewportEvent(bound);
}
}
psDistmesh.cleanUp();
triangulation = psDistmesh.getTriangles();
setChanged();
fireChangeViewportEvent(bound);
});
t.start();
......
......@@ -124,16 +124,16 @@ public class VRectangle extends Rectangle2D.Double implements VShape {
return new VPolygon(this);
}
@Override
public boolean intersect(final VShape shape) {
if(shape instanceof VRectangle){
return intersects(((VRectangle)shape));
}
else if(shape instanceof VPolygon) {
return shape.intersect(this);
}
else {
throw new UnsupportedOperationException("not yet implemented");
}
}
@Override
public boolean intersect(final VShape shape) {
if(shape instanceof VRectangle){
return intersects(((VRectangle)shape));
}
else if(shape instanceof VPolygon) {
return shape.intersect(this);
}
else {
throw new UnsupportedOperationException("not yet implemented");
}
}
}
......@@ -100,6 +100,14 @@ public class PSDistmesh {
return steps >= Parameters.MAX_NUMBER_OF_STEPS;
}
/**
* Remove all triangles intersecting any obstacle shape.
*/
public void cleanUp() {
triangulation = triangulation.stream()
.filter(triple -> obstacles.stream().noneMatch(obstacle -> tripleToTriangle(triple).intersect(obstacle))).collect(Collectors.toSet());
}
/*
Stellt den Verlauf der Iterationen dar. Innerhalb der while(true) passiert eine Iteration des Algorithmus
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment