Commit 9c467b36 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

fix an incorrect endless recursion call.

parent d2188ac0
Pipeline #272516 passed with stages
in 131 minutes and 31 seconds
......@@ -192,7 +192,7 @@ public class MeshQuantityPrinting {
bufferedWriterQualities2.write("iteration quality\n");
BufferedWriter bufferedWriterAngles = IOUtils.getWriter("angles_eik.csv", dir);
bufferedWriterAngles.write("iteration angle3D\n");
bufferedWriterAngles.write("iteration angle\n");
int init = 1;
while (!meshImprover.isInitialized()) {
......@@ -255,7 +255,7 @@ public class MeshQuantityPrinting {
bufferedWriterQualities2.write("iteration quality\n");
BufferedWriter bufferedWriterAngles = IOUtils.getWriter("angles_dist.csv", dir);
bufferedWriterAngles.write("iteration angle3D\n");
bufferedWriterAngles.write("iteration angle\n");
int iteration = 1;
while (iteration < maxIteration+1) {
......
......@@ -1390,7 +1390,7 @@ public interface IPolyConnectivity<V extends IVertex, E extends IHalfEdge, F ext
}
default void removeFaceAtBoundary(@NotNull final F face, @NotNull final F boundary, final boolean deleteIsolatedVertices) {
removeFaceAtBoundary(face, boundary, deleteIsolatedVertices);
removeFaceAtBoundary(face, boundary, deleteIsolatedVertices, true);
}
/**
......
......@@ -2734,7 +2734,8 @@ public interface ITriConnectivity<V extends IVertex, E extends IHalfEdge, F exte
* this might happen if the line intersects a point, in this case both neighbouring edges are feasible
*/
if(inEdge == null) {
inEdge = getMesh().streamEdges(startFace).filter(e -> isLeftOf(p.getX(), p.getY(), e)).findAny().get();
Optional<E> optEdge = getMesh().streamEdges(startFace).filter(e -> isLeftOf(p.getX(), p.getY(), e)).findAny();
inEdge = optEdge.get();
}
}
......
......@@ -17,7 +17,7 @@ public class Parameters {
public final static boolean uniform = false;
public final static String method = "Distmesh"; // "Distmesh" or "Density"
public final static double qualityMeasurement = 0.95;
public final static double qualityConvergence = 0.01;
public final static double qualityConvergence = 0.0;
public final static double MINIMUM = 0.25;
public final static double DENSITYWEIGHT = 2;
public final static int NPOINTS = 100000;
......@@ -26,5 +26,5 @@ public class Parameters {
public final static int SEGMENTDIVISION = 0;
//TODO increase this
public final static int MAX_NUMBER_OF_STEPS = 200;
public final static int HIGHEST_LEGAL_TEST = 10;
public final static int HIGHEST_LEGAL_TEST = Integer.MAX_VALUE;
}
......@@ -651,6 +651,9 @@ public class GenEikMesh<V extends IVertex, E extends IHalfEdge, F extends IFace>
// TODO: Get rid of VPoint
VPoint p1p2 = p1.subtract(p2);
double len = p1p2.distanceToOrigin();
if(len <= GeometryUtils.DOUBLE_EPS) {
return new VPoint(0, 0);
}
double desiredLen = 0.9 * Math.sqrt(3) * getDesiredEdgeLength(p1, p2);
double ratio = len / desiredLen;
double absForce = f.apply(ratio);
......@@ -1379,9 +1382,11 @@ public class GenEikMesh<V extends IVertex, E extends IHalfEdge, F extends IFace>
IPoint velocity = getForce(vertex);
double factor = 1.0;
IPoint movement = velocity.scalarMultiply(delta * factor);
while(!move(vertex, vertex.getX() + movement.getX(), vertex.getY() + movement.getY())) {
int count = 0;
while(!move(vertex, vertex.getX() + movement.getX(), vertex.getY() + movement.getY()) && count < 10) {
factor /= 2.0;
movement = velocity.scalarMultiply(delta * factor);
count++;
}
}
......
......@@ -16,13 +16,19 @@ import org.vadere.meshing.mesh.triangulation.IEdgeLengthFunction;
import org.vadere.meshing.mesh.triangulation.improver.eikmesh.impl.PEikMesh;
import org.vadere.meshing.mesh.triangulation.triangulator.impl.PRuppertsTriangulator;
import org.vadere.meshing.utils.color.Colors;
import org.vadere.meshing.utils.io.IOUtils;
import org.vadere.meshing.utils.io.tex.TexGraphGenerator;
import org.vadere.util.geometry.GeometryUtils;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VPolygon;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.logging.Logger;
import org.vadere.util.math.IDistanceFunction;
import java.awt.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.function.Function;
import java.util.function.Predicate;
......@@ -30,7 +36,6 @@ import java.util.function.Predicate;
public class MeshConstructor {
private static Logger logger = Logger.getLogger(MeshConstructor.class);
public IMesh<PVertex, PHalfEdge, PFace> pslgToCoarsePMesh(@NotNull final PSLG pslg, final boolean viszalize) {
VRectangle bound = GeometryUtils.boundRelativeSquared(pslg.getSegmentBound().getPoints(), 0.3);
PSLG boundedPSLG = pslg.conclose(bound);
......@@ -67,10 +72,14 @@ public class MeshConstructor {
logger.info("construct distance function");
IDistanceFunction distanceFunctionApproximation = new DistanceFunctionApproxBF(pslg, distanceFunction, () -> new PMesh());
IEdgeLengthFunction edgeLengthFunction = p -> hmin + smoothness * Math.abs(((DistanceFunctionApproxBF) distanceFunctionApproximation).apply(p));
IEdgeLengthFunction edgeLengthFunction = p -> hmin + smoothness * Math.abs((distanceFunctionApproximation).apply(p));
EdgeLengthFunctionApprox edgeLengthFunctionApprox = new EdgeLengthFunctionApprox(pslg, edgeLengthFunction, p -> hmax);
edgeLengthFunctionApprox.smooth(smoothness);
logger.info("construct element size function");
//((DistanceFunctionApproxBF) distanceFunctionApproximation).printPython();
//edgeLengthFunctionApprox.printPython();
//edgeLengthFunctionApprox.printPython();
......@@ -105,9 +114,41 @@ public class MeshConstructor {
while (!meshImprover.isFinished()) {
synchronized (meshImprover.getMesh()) {
meshImprover.improve();
logger.info("quality = " + meshImprover.getQuality());
}
meshPanel.repaint();
}
logger.info("generation completed.");
/*BufferedWriter meshWriter = null;
try {
File dir = new File("/Users/bzoennchen/Development/workspaces/hmRepo/PersZoennchen/PhD/trash/generated/eikmesh/");
BufferedWriter bufferedWriterQualities1 = IOUtils.getWriter("qualities1_eik.csv", dir);
bufferedWriterQualities1.write("iteration quality\n");
BufferedWriter bufferedWriterQualities2 = IOUtils.getWriter("qualities2_eik.csv", dir);
bufferedWriterQualities2.write("iteration quality\n");
BufferedWriter bufferedWriterAngles = IOUtils.getWriter("angles_eik.csv", dir);
bufferedWriterAngles.write("iteration angle\n");
bufferedWriterQualities1.write(printQualities(200, meshImprover.getMesh(), f -> meshImprover.getTriangulation().faceToQuality(f)));
bufferedWriterQualities1.close();
bufferedWriterQualities2.write(printQualities(200, meshImprover.getMesh(), f -> meshImprover.getTriangulation().faceToLongestEdgeQuality(f)));
bufferedWriterQualities2.close();
bufferedWriterAngles.write(printAngles(200, meshImprover.getMesh()));
bufferedWriterAngles.close();
meshWriter = IOUtils.getWriter("kaiserslautern_mittel.tex", dir);
meshWriter.write(TexGraphGenerator.toTikz(meshImprover.getMesh(), f -> Colors.YELLOW, e -> Color.BLACK, vertexColorFunction, 1.0f, true));
meshWriter.close();
} catch (IOException e) {
e.printStackTrace();
}*/
} else {
meshImprover.generate();
}
......@@ -167,4 +208,34 @@ public class MeshConstructor {
return meshImprover.getMesh();
}
// delete this code
private static String printAngles(int iteration, IMesh<PVertex, PHalfEdge, PFace> mesh){
StringBuilder builder = new StringBuilder();
for(PFace face : mesh.getFaces()) {
for(PHalfEdge edge : mesh.getEdges(face)) {
VPoint p1 = mesh.toPoint(edge);
VPoint p2 = mesh.toPoint(mesh.getNext(edge));
VPoint p3 = mesh.toPoint(mesh.getPrev(edge));
builder.append(iteration);
builder.append(" ");
builder.append(GeometryUtils.angle(p1, p2, p3));
builder.append("\n");
}
}
return builder.toString();
}
private static String printQualities(int iteration, IMesh<PVertex, PHalfEdge, PFace> mesh, Function<PFace, Double> rho){
StringBuilder builder = new StringBuilder();
for(PFace face : mesh.getFaces()) {
double quality = rho.apply(face);
builder.append(iteration);
builder.append(" ");
builder.append(quality);
builder.append("\n");
}
return builder.toString();
}
}
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