Commit 5bf617f9 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

remove triangles from the triangulation if they intersect any obstacle.

parent ebda746d
......@@ -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();
......
......@@ -188,4 +188,9 @@ public class VCircle implements VShape {
public ShapeType getType() {
return ShapeType.CIRCLE;
}
@Override
public boolean intersect(final VShape shape) {
throw new UnsupportedOperationException("not yet implemented");
}
}
......@@ -436,4 +436,17 @@ public class VPolygon extends Path2D.Double implements VShape {
public ShapeType getType() {
return ShapeType.POLYGON;
}
@Override
public boolean intersect(final VShape shape) {
if(shape instanceof VPolygon) {
return intersects((VPolygon) shape);
}
else if(shape instanceof VRectangle){
return intersects(((VRectangle)shape));
}
else {
throw new UnsupportedOperationException("not yet implemented");
}
}
}
package org.vadere.util.geometry.shapes;
import java.awt.geom.PathIterator;
import java.awt.geom.Rectangle2D;
import org.vadere.util.geometry.GeometryUtils;
......@@ -118,4 +119,21 @@ public class VRectangle extends Rectangle2D.Double implements VShape {
public ShapeType getType() {
return ShapeType.RECTANGLE;
}
public VPolygon toPolygon() {
return new VPolygon(this);
}
@Override
public boolean intersect(final VShape shape) {
if(shape instanceof VPolygon) {
return toPolygon().intersects((VPolygon) shape);
}
else if(shape instanceof VRectangle){
return intersects(((VRectangle)shape));
}
else {
throw new UnsupportedOperationException("not yet implemented");
}
}
}
......@@ -220,4 +220,9 @@ public class VRing implements VShape {
return ShapeType.RING;
}
@Override
public boolean intersect(VShape shape) {
throw new UnsupportedOperationException("not yet implemented.");
}
}
......@@ -26,4 +26,7 @@ public interface VShape extends Shape, Cloneable {
VPoint getCentroid();
ShapeType getType();
boolean intersect(VShape shape);
}
......@@ -82,6 +82,7 @@ public class PSDistmesh {
step();
test = qualityCheck();
}
cleanUp();
}
public boolean hasConverged() {
......@@ -94,6 +95,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