Commit 38b380fc authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

before changing initial point generation of DSMesh

parent 68c2406f
......@@ -15,6 +15,9 @@ public class VLine extends Line2D.Double {
public VLine(final VPoint p1, final VPoint p2) {
super(p1.getX(), p1.getY(), p2.getX(), p2.getY());
if(p1.equals(p2)) {
throw new IllegalArgumentException(p1 + " is equal " + p2);
}
this.p1 = p1;
this.p2 = p2;
}
......
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;
}
}
......@@ -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.93;
final static double qualityMeasurement = 0.95;
final static double MINIMUM = 0.25;
final static double DENSITYWEIGHT = 2;
final static int NPOINTS = 100000;
......
......@@ -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)));
......
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