Commit c541cfe0 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

refactoring: remove generic but fixed data types from mesh element and...

refactoring: remove generic but fixed data types from mesh element and introduce the property concept.
parent d19861c2
......@@ -6,11 +6,8 @@ import java.util.function.Function;
import org.vadere.meshing.mesh.gen.PMesh;
import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.simulator.models.potential.solver.calculators.mesh.PotentialPoint;
import org.vadere.state.scenario.Agent;
import org.vadere.util.data.cellgrid.IPotentialPoint;
import org.vadere.util.geometry.shapes.IPoint;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
public abstract class SimulationModel<T extends DefaultSimulationConfig> extends DefaultModel {
......@@ -42,8 +39,8 @@ public abstract class SimulationModel<T extends DefaultSimulationConfig> extends
return config;
}
public IMesh<? extends IPotentialPoint, ?, ?, ?, ?, ?> getDiscretization() {
return new PMesh<IPotentialPoint, Object, Object>((x,y) -> new PotentialPoint(x,y));
public IMesh<?, ?, ?> getDiscretization() {
return new PMesh();
}
/*public double getPotential(final int x, final int y) {
......
......@@ -7,7 +7,6 @@ import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.state.scenario.Stairs;
import org.vadere.util.data.cellgrid.IPotentialPoint;
import org.vadere.util.geometry.shapes.Vector2D;
import org.vadere.util.geometry.shapes.VCircle;
import org.vadere.util.geometry.shapes.VLine;
......@@ -598,9 +597,9 @@ public abstract class DefaultRenderer {
protected void renderMesh(
@NotNull final Graphics2D g,
@NotNull final IMesh<? extends IPotentialPoint, ?, ?, ?, ?, ?> mesh,
@NotNull final IMesh<?, ?, ?> mesh,
@NotNull final VRectangle bound) {
MeshRenderer<? extends IPotentialPoint, ?, ?, ?, ?, ?> meshRenderer = new MeshRenderer<>(mesh);
MeshRenderer<?, ?, ?> meshRenderer = new MeshRenderer<>(mesh);
//meshRenderer.renderGraphics(g, bound);
}
......
......@@ -13,7 +13,6 @@ import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Topography;
import org.vadere.util.data.cellgrid.IPotentialPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.function.Function;
......@@ -32,7 +31,7 @@ public class OnlineVisualization implements PassiveCallback {
public final IPotentialField potentialFieldTarget;
public final Agent selectedAgent;
public final IPotentialField potentialField;
public final Function<Agent, IMesh<? extends IPotentialPoint, ?, ?, ?, ?, ?>> discretizations;
public final Function<Agent, IMesh<?, ?, ?>> discretizations;
public ObservationAreaSnapshotData(
final double simTimeInSec,
......@@ -40,7 +39,7 @@ public class OnlineVisualization implements PassiveCallback {
@Nullable final IPotentialField potentialFieldTarget,
@Nullable final IPotentialField potentialField,
@Nullable final Agent selectedAgent,
@Nullable final Function<Agent, IMesh<? extends IPotentialPoint, ?, ?, ?, ?, ?>> discretizations) {
@Nullable final Function<Agent, IMesh<?, ?, ?>> discretizations) {
this.simTimeInSec = simTimeInSec;
this.scenario = scenario;
this.potentialFieldTarget = potentialFieldTarget;
......@@ -124,7 +123,7 @@ public class OnlineVisualization implements PassiveCallback {
synchronized (model.getDataSynchronizer()) {
/* Push new snapshot of the observation area to the draw thread. */
IPotentialField pft = (model.config.isShowTargetPotentialField() && potentialFieldTarget != null) ? potentialFieldTarget.getSolution() : null;
Function<Agent, IMesh<? extends IPotentialPoint, ?, ?, ?, ?, ?>> discretizations = (model.config.isShowTargetPotentielFieldMesh() && potentialFieldTarget != null) ? potentialFieldTarget.getDiscretization() : null;
Function<Agent, IMesh<?, ?, ?>> discretizations = (model.config.isShowTargetPotentielFieldMesh() && potentialFieldTarget != null) ? potentialFieldTarget.getDiscretization() : null;
IPotentialField pedPotentialField = null;
Agent selectedAgent = null;
......
......@@ -14,9 +14,7 @@ import org.vadere.gui.onlinevisualization.OnlineVisualization;
import org.vadere.meshing.mesh.gen.PMesh;
import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.models.potential.solver.calculators.mesh.PotentialPoint;
import org.vadere.state.scenario.*;
import org.vadere.util.data.cellgrid.IPotentialPoint;
import org.vadere.util.geometry.shapes.IPoint;
import org.vadere.util.voronoi.VoronoiDiagram;
......@@ -37,7 +35,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
private IPotentialField potentialField = null;
private Function<Agent, IMesh<? extends IPotentialPoint, ?, ?, ?, ?, ?>> discretizations = null;
private Function<Agent, IMesh<?, ?, ?>> discretizations = null;
private Agent agent = null;
......@@ -209,12 +207,12 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
}
@Override
public IMesh<? extends IPotentialPoint, ?, ?, ?, ?, ?> getDiscretization() {
public IMesh<?, ?, ?> getDiscretization() {
if(agent != null && discretizations != null && config.isShowTargetPotentielFieldMesh() && agent.equals(getSelectedElement())) {
return discretizations.apply(agent);
}
return new PMesh<IPotentialPoint, Object, Object>((x, y) -> new PotentialPoint(x, y));
return new PMesh();
}
@Override
......
......@@ -15,7 +15,6 @@ import org.vadere.util.geometry.shapes.VPolygon;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.math.DistanceFunction;
import org.vadere.meshing.mesh.triangulation.improver.eikmesh.EikMeshPoint;
import org.vadere.meshing.mesh.gen.MeshPanel;
import org.vadere.meshing.mesh.triangulation.improver.eikmesh.impl.AEikMesh;
......@@ -53,21 +52,21 @@ public class RecordTriangulationMovie {
bbound,
obstacleShapes);
Function<AFace<Object>, Color> colorFunction1 = f -> {
Function<AFace, Color> colorFunction1 = f -> {
float q = Math.max(0.0f, Math.min(1.0f, (float) meshImprover.faceToQuality(f)));
return new Color(q, q, q);
};
Function<AFace<EikMeshPoint>, Color> colorFunction2 = f -> {
Function<AFace, Color> colorFunction2 = f -> {
return ColorHelper.numberToHurColor((float)f.getId() / meshImprover.getMesh().getNumberOfFaces());
};
//ColorHelper.numberToHurColor((float)f.getId() / meshImprover.getMesh().getNumberOfFaces());
//new ColorHelper(meshImprover.getMesh().getNumberOfFaces()).numberToColor(f.getId());
MeshRenderer<EikMeshPoint, Object, Object, AVertex<EikMeshPoint>, AHalfEdge<Object>, AFace<Object>> meshRenderer = new MeshRenderer<>(
MeshRenderer<AVertex, AHalfEdge, AFace> meshRenderer = new MeshRenderer<>(
meshImprover.getMesh(), f -> false, colorFunction1);
MeshPanel<EikMeshPoint, Object, Object, AVertex<EikMeshPoint>, AHalfEdge<Object>, AFace<Object>> distmeshPanel = new MeshPanel<>(
MeshPanel<AVertex, AHalfEdge, AFace> distmeshPanel = new MeshPanel<>(
meshRenderer, bbound.getWidth()*1000, bbound.getHeight()*1000);
JFrame frame = distmeshPanel.display();
......@@ -119,7 +118,7 @@ public class RecordTriangulationMovie {
}
public static void addPictures(Recorder recorder,
MeshRenderer<EikMeshPoint, Object, Object, AVertex<EikMeshPoint>, AHalfEdge<Object>, AFace<Object>> renderer,
MeshRenderer<AVertex, AHalfEdge, AFace> renderer,
int frames,
int width,
int height) throws IOException {
......
......@@ -46,7 +46,7 @@ public class ActionRenameScenario extends AbstractAction {
ProjectWriter.renameScenario(scenario, model.getCurrentProjectPath(), newName);
model.saveScenarioToDisk(scenario);
// remove and insert the element such that the table is still sorted by name
// remove and insertVertex the element such that the table is still sorted by name
model.getScenarioTableModel().replace(scenario, new VadereScenarioTableModel.VadereDisplay(scenario, VadereState.INITIALIZED));
model.refreshScenarioNames();
/*
......
......@@ -398,11 +398,11 @@ public class TopographyWindow extends JPanel {
getActionMap().put("copy-element", copyElementAction);
TopographyAction insertCopiedElementAction =
new ActionInsertCopiedElement("insert copied element", panelModel, undoSupport);
new ActionInsertCopiedElement("insertVertex copied element", panelModel, undoSupport);
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
"insert-copied-element");
getActionMap().put("insert-copied-element", insertCopiedElementAction);
"insertVertex-copied-element");
getActionMap().put("insertVertex-copied-element", insertCopiedElementAction);
// delete element
TopographyAction deleteElement =
......
......@@ -20,7 +20,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
......@@ -44,7 +43,7 @@ public class WeilerAtherton {
public static class WeilerPoint extends VPoint {
private boolean isIntersectionPoint;
private boolean isInside;
@Nullable private PVertex<WeilerPoint, Object, Object> twinPoint;
@Nullable private PVertex twinPoint;
public WeilerPoint(@NotNull final VPoint point, final boolean isIntersectionPoint, final boolean inside) {
super(point.x, point.y);
......@@ -61,7 +60,7 @@ public class WeilerAtherton {
isInside = inside;
}
public void setTwinPoint(@NotNull final PVertex<WeilerPoint, Object, Object> twinPoint) {
public void setTwinPoint(@NotNull final PVertex twinPoint) {
this.twinPoint = twinPoint;
}
......@@ -70,7 +69,7 @@ public class WeilerAtherton {
}
@Nullable
public PVertex<WeilerPoint, Object, Object> getTwinPoint() {
public PVertex getTwinPoint() {
return twinPoint;
}
......@@ -100,11 +99,11 @@ public class WeilerAtherton {
*
* @return two faces which represents two polygons including their intersection points (in CW order)
*/
public Pair<PFace<WeilerPoint, Object, Object>, PFace<WeilerPoint, Object, Object>> constructIntersectionFaces(
public Pair<PFace, PFace> constructIntersectionFaces(
@NotNull final VPolygon subject,
@NotNull final PMesh<WeilerPoint, Object, Object> subjectMesh,
@NotNull final PMesh subjectMesh,
@NotNull final VPolygon clipping,
@NotNull final PMesh<WeilerPoint, Object, Object> clippingMesh) {
@NotNull final PMesh clippingMesh) {
Set<VPoint> clipPointSet = new HashSet<>();
Set<VPoint> subPointSet = new HashSet<>();
......@@ -112,18 +111,18 @@ public class WeilerAtherton {
clipPointSet.addAll(clipping.getPath());
subPointSet.addAll(subject.getPath());
PFace<WeilerPoint, Object, Object> subjectFace = subjectMesh.toFace(subject.getPath()
PFace subjectFace = subjectMesh.toFace(subject.getPath()
.stream()
.map(p -> new WeilerPoint(p, false, clipPointSet.contains(p) || clipping.contains(p)))
.collect(Collectors.toList()));
PFace<WeilerPoint, Object, Object> clippingFace = clippingMesh.toFace(clipping.getPath()
PFace clippingFace = clippingMesh.toFace(clipping.getPath()
.stream()
.map(p -> new WeilerPoint(p, false, subPointSet.contains(p) || subject.contains(p)))
.collect(Collectors.toList()));
List<VPoint> intersectionPoints = new ArrayList<>();
PVertex<WeilerPoint, Object, Object> ip = null;
PVertex ip = null;
// compute intersections and add those to the two faces, this implementation is rather slow!
......@@ -131,12 +130,12 @@ public class WeilerAtherton {
int count = 0;
while (intersectionFound) {
List<PHalfEdge<WeilerPoint, Object, Object>> clippingEdges = clippingMesh.getEdges(clippingFace);
List<PHalfEdge<WeilerPoint, Object, Object>> subjectEdges = subjectMesh.getEdges(subjectFace);
List<PHalfEdge> clippingEdges = clippingMesh.getEdges(clippingFace);
List<PHalfEdge> subjectEdges = subjectMesh.getEdges(subjectFace);
intersectionFound = false;
for(PHalfEdge<WeilerPoint, Object, Object> clippingEdge : clippingEdges) {
for(PHalfEdge<WeilerPoint, Object, Object> subjectEdge : subjectEdges) {
for(PHalfEdge clippingEdge : clippingEdges) {
for(PHalfEdge subjectEdge : subjectEdges) {
Optional<VPoint> optIntersectionPoint = equalIntersectionPoints(subjectEdge, subjectMesh, clippingEdge, clippingMesh);
if(!optIntersectionPoint.isPresent()) {
VLine l1 = subjectMesh.toLine(subjectEdge);
......@@ -160,20 +159,22 @@ public class WeilerAtherton {
if(intersectionPoint != null) {
WeilerPoint wp1 = new WeilerPoint(intersectionPoint, true, false);
WeilerPoint wp2 = new WeilerPoint(intersectionPoint, true, false);
VPoint wp1 = intersectionPoint;
VPoint wp2 = intersectionPoint;
PHalfEdge<WeilerPoint, Object, Object> prev = clippingMesh.getPrev(subjectEdge);
PHalfEdge<WeilerPoint, Object, Object> innerPrev = subjectMesh.getPrev(clippingEdge);
PHalfEdge prev = clippingMesh.getPrev(subjectEdge);
PHalfEdge innerPrev = subjectMesh.getPrev(clippingEdge);
PVertex<WeilerPoint, Object, Object> ip1 = IPolyConnectivity.splitEdge(subjectEdge, wp1, subjectMesh);
PVertex<WeilerPoint, Object, Object> ip2 = IPolyConnectivity.splitEdge(clippingEdge, wp2, clippingMesh);
PVertex ip1 = IPolyConnectivity.splitEdge(subjectEdge, wp1, subjectMesh);
subjectMesh.setData(ip1, "intersection", true);
subjectMesh.setData(ip1, "inside", true);
subjectMesh.getPoint(ip1).setInside(true);
clippingMesh.getPoint(ip2).setInside(true);
PVertex ip2 = IPolyConnectivity.splitEdge(clippingEdge, wp2, clippingMesh);
clippingMesh.setData(ip2, "intersection", true);
clippingMesh.setData(ip2, "inside", true);
wp1.setTwinPoint(ip2);
wp2.setTwinPoint(ip1);
clippingMesh.setData(ip2, "twin", ip1);
subjectMesh.setData(ip1, "twin", ip2);
intersectionPoints.add(intersectionPoint);
intersectionFound = true;
......@@ -210,61 +211,47 @@ public class WeilerAtherton {
* @return a point which is the intersection point or null / empty if the two edges did not have an geometrical equal point
*/
private Optional<VPoint> equalIntersectionPoints(
@NotNull final PHalfEdge<WeilerPoint, Object, Object> subjectEdge,
@NotNull final PMesh<WeilerPoint, Object, Object> subjectMesh,
@NotNull final PHalfEdge<WeilerPoint, Object, Object> clippingEdge,
@NotNull final PMesh<WeilerPoint, Object, Object> clippingMesh) {
PVertex<WeilerPoint, Object, Object> v1 = subjectMesh.getVertex(subjectMesh.getPrev(subjectEdge));
PVertex<WeilerPoint, Object, Object> v2 = subjectMesh.getVertex(subjectEdge);
PVertex<WeilerPoint, Object, Object> u1 = clippingMesh.getVertex(clippingMesh.getPrev(clippingEdge));
PVertex<WeilerPoint, Object, Object> u2 = clippingMesh.getVertex(clippingEdge);
WeilerPoint p1 = subjectMesh.getPoint(v1);
WeilerPoint p2 = subjectMesh.getPoint(v2);
WeilerPoint q1 = clippingMesh.getPoint(u1);
WeilerPoint q2 = clippingMesh.getPoint(u2);
if(p1.equals(q1) && !p1.isIntersectionPoint()) {
return Optional.of(connectWeilerPoints(v1, p1, u1, q1));
} else if(p1.equals(q2) && !p1.isIntersectionPoint()) {
return Optional.of(connectWeilerPoints(v1, p1, u2, q2));
} else if(p2.equals(q1) && !p2.isIntersectionPoint()) {
return Optional.of(connectWeilerPoints(v2, p2, u1, q1));
} else if(p2.equals(q2) && !p2.isIntersectionPoint()) {
return Optional.of(connectWeilerPoints(v2, p2, u2, q2));
@NotNull final PHalfEdge subjectEdge,
@NotNull final PMesh subjectMesh,
@NotNull final PHalfEdge clippingEdge,
@NotNull final PMesh clippingMesh) {
PVertex v1 = subjectMesh.getVertex(subjectMesh.getPrev(subjectEdge));
PVertex v2 = subjectMesh.getVertex(subjectEdge);
PVertex u1 = clippingMesh.getVertex(clippingMesh.getPrev(clippingEdge));
PVertex u2 = clippingMesh.getVertex(clippingEdge);
VPoint p1 = subjectMesh.toPoint(v1);
VPoint p2 = subjectMesh.toPoint(v2);
VPoint q1 = clippingMesh.toPoint(u1);
VPoint q2 = clippingMesh.toPoint(u2);
boolean intersection1 = subjectMesh.getData(v1, "intersection", Boolean.class).get();
boolean intersection2 = subjectMesh.getData(v2, "intersection", Boolean.class).get();
if(p1.equals(q1) && !intersection1) {
subjectMesh.setData(v1, "intersection", true);
clippingMesh.setData(u1, "intersection", true);
return Optional.of(p1);
} else if(p1.equals(q2) && !intersection1) {
subjectMesh.setData(v1, "intersection", true);
clippingMesh.setData(u2, "intersection", true);
return Optional.of(p1);
} else if(p2.equals(q1) && !intersection2) {
subjectMesh.setData(v2, "intersection", true);
clippingMesh.setData(u1, "intersection", true);
return Optional.of(p2);
} else if(p2.equals(q2) && !intersection2) {
subjectMesh.setData(v2, "intersection", true);
clippingMesh.setData(u2, "intersection", true);
return Optional.of(p2);
}
else {
return Optional.empty();
}
}
/**
* Sets the twin of two points. This is necessary if there are two points of the original polygons
* which are geometrically the same. If this is the case those two points are intersection points but
* they already exists.
*
* @param v the vertex of the first point
* @param p the weiler point of the first point
* @param u the vertex of the second point
* @param q the weilper point of the second point
*
* @return a new intersection point
*/
private VPoint connectWeilerPoints(
@NotNull final PVertex<WeilerPoint, Object, Object> v,
@NotNull final WeilerPoint p,
@NotNull final PVertex<WeilerPoint, Object, Object> u,
@NotNull final WeilerPoint q) {
p.setIntersectionPoint(true);
q.setIntersectionPoint(true);
p.setTwinPoint(u);
q.setTwinPoint(v);
return new VPoint(p);
}
/**
* Executes the Weiler-Atherton-Algorithm for all of its polygons.
*
......@@ -364,30 +351,30 @@ public class WeilerAtherton {
VPolygon clipping = GeometryUtils.isCCW(clippingCandidat) ? clippingCandidat : clippingCandidat.revertOrder();
PMesh<WeilerPoint, Object, Object> subjectMesh = new PMesh<>((x,y) -> new WeilerPoint(new VPoint(x,y), false, false));
PMesh<WeilerPoint, Object, Object> clippingMesh = new PMesh<>((x,y) -> new WeilerPoint(new VPoint(x,y), false, false));
PMesh subjectMesh = new PMesh();
PMesh clippingMesh = new PMesh();
//List<VPolygon> result = new ArrayList<>(2);
/**
* (1) construct the list connections
*/
Pair<PFace<WeilerPoint, Object, Object>, PFace<WeilerPoint, Object, Object>> pair = constructIntersectionFaces(subject, subjectMesh, clipping, clippingMesh);
Pair<PFace, PFace> pair = constructIntersectionFaces(subject, subjectMesh, clipping, clippingMesh);
PFace<WeilerPoint, Object, Object> subjectFace = pair.getFirst();
PFace<WeilerPoint, Object, Object> clippingFace = pair.getSecond();
PFace subjectFace = pair.getFirst();
PFace clippingFace = pair.getSecond();
Set<PHalfEdge<WeilerPoint, Object, Object>> subjectExitingEdges = subjectMesh
Set<PHalfEdge> subjectExitingEdges = subjectMesh
.streamEdges(subjectFace)
.filter(edge -> subjectMesh.getPoint(edge).isIntersectionPoint())
.filter(edge -> subjectMesh.getData(subjectMesh.getVertex(edge), "intersection", Boolean.class).get())
.filter(edge ->
contains(clipping, subjectMesh.getPoint(subjectMesh.getPrev(edge))) &&
!contains(clipping, subjectMesh.getPoint(subjectMesh.getNext(edge))))
.collect(Collectors.toSet());
Set<PHalfEdge<WeilerPoint, Object, Object>> subjectEnteringEdges = subjectMesh
Set<PHalfEdge> subjectEnteringEdges = subjectMesh
.streamEdges(subjectFace)
.filter(edge -> subjectMesh.getPoint(edge).isIntersectionPoint())
.filter(edge -> subjectMesh.getData(subjectMesh.getVertex(edge), "intersection", Boolean.class).get())
.filter(edge ->
contains(clipping, subjectMesh.getPoint(subjectMesh.getNext(edge))) &&
!contains(clipping, subjectMesh.getPoint(subjectMesh.getPrev(edge)))
......@@ -396,9 +383,9 @@ public class WeilerAtherton {
List<VPoint> points = new ArrayList<>();
List<VPolygon> polygons = new ArrayList<>();
PMesh<WeilerPoint, Object, Object> mesh = subjectMesh;
PMesh mesh = subjectMesh;
Set<PHalfEdge<WeilerPoint, Object, Object>> intersectionSet = cap ? subjectEnteringEdges : subjectExitingEdges;
Set<PHalfEdge> intersectionSet = cap ? subjectEnteringEdges : subjectExitingEdges;
// cup will preserve the polyons.
if(intersectionSet.isEmpty()) {
......@@ -435,22 +422,22 @@ public class WeilerAtherton {
}
while (!intersectionSet.isEmpty()) {
PHalfEdge<WeilerPoint, Object, Object> subjectEdge = intersectionSet.iterator().next();
PHalfEdge<WeilerPoint, Object, Object> subjectTwin = clippingMesh.getEdge(subjectMesh.getPoint(subjectEdge).getTwinPoint());
PHalfEdge<WeilerPoint, Object, Object> next = subjectEdge;
PHalfEdge subjectEdge = intersectionSet.iterator().next();
PHalfEdge subjectTwin = clippingMesh.getEdge(subjectMesh.getData(subjectMesh.getVertex(subjectEdge), "twin", PVertex.class).get());
PHalfEdge next = subjectEdge;
intersectionSet.remove(subjectEdge);
do {
next = mesh.getNext(next);
var v = mesh.getVertex(next);
// adaptPath
if(mesh.getPoint(next).isIntersectionPoint()) {
if(mesh.getData(v, "intersection", Boolean.class).get()) {
/*
* Special case!
*/
PVertex<WeilerPoint, Object, Object> twinPoint = mesh.getPoint(next).getTwinPoint();
PMesh<WeilerPoint, Object, Object> twinMesh = mesh.equals(subjectMesh) ? clippingMesh : subjectMesh;
PHalfEdge<WeilerPoint, Object, Object> twinPointEdge = twinMesh.getEdge(twinPoint);
var twinPoint = mesh.getData(v, "twin", PVertex.class).get();
PMesh twinMesh = mesh.equals(subjectMesh) ? clippingMesh : subjectMesh;
PHalfEdge twinPointEdge = twinMesh.getEdge(twinPoint);
VPoint prevTwinPoint = new VPoint(twinMesh.getPoint(twinMesh.getPrev(twinPointEdge)));
VPoint prevPoint = new VPoint(mesh.getPoint(mesh.getPrev(next)));
......@@ -459,7 +446,7 @@ public class WeilerAtherton {
if(!prevTwinPoint.equals(prevPoint)) {
mesh = mesh.equals(subjectMesh) ? clippingMesh : subjectMesh;
next = mesh.getEdge(mesh.getPoint(next).getTwinPoint());
next = mesh.getEdge(mesh.getData(mesh.getVertex(next), "twin", PVertex.class).get());
}
}
......@@ -588,6 +575,8 @@ public class WeilerAtherton {
return construct(subjectCandidat, clippingCandidat, true);
}
//private PVertex<VPoint, Object, Object> getTwin(@NotNull final PVertex<VPoint, Object, Object> v, PMesh<VPoint, Object, >)
/**
* Executes the Weiler-Atherton-Algorithm for two polygons.
*
......
......@@ -4,7 +4,7 @@ import org.vadere.meshing.mesh.impl.PSLG;
import org.vadere.meshing.mesh.triangulation.EdgeLengthFunctionApprox;
import org.vadere.meshing.mesh.triangulation.triangulator.impl.PRuppertsTriangulator;
import org.vadere.meshing.utils.io.poly.PolyGenerator;
import org.vadere.util.geometry.shapes.VPoint;
import java.io.IOException;
import java.io.InputStream;
......@@ -19,11 +19,11 @@ public class BackgroundMeshExamples {
PSLG pslg = PolyGenerator.toPSLGtoVShapes(inputStream);
double theta = 10;
PRuppertsTriangulator<VPoint, Double, Double> ruppert = new PRuppertsTriangulator<>(
PRuppertsTriangulator ruppert = new PRuppertsTriangulator(
pslg,
p -> Double.POSITIVE_INFINITY,
theta,
(x, y) -> new VPoint(x, y));
theta
);
EdgeLengthFunctionApprox edgeLengthFunctionApprox = new EdgeLengthFunctionApprox(pslg);
edgeLengthFunctionApprox.printPython();
......
package org.vadere.meshing.examples;
import org.vadere.meshing.mesh.gen.MeshPanel;
import org.vadere.meshing.mesh.impl.VPMesh;
import org.vadere.meshing.mesh.gen.PMesh;
import org.vadere.meshing.mesh.triangulation.triangulator.gen.GenRandomPointsSetTriangulator;
import org.vadere.util.geometry.shapes.VRectangle;
......@@ -20,7 +20,7 @@ public class DelaunayTriangulationExamples {
// define a random point set triangulator
int numberOfPoint = 5000;
GenRandomPointsSetTriangulator randomTriangulator = new GenRandomPointsSetTriangulator(new VPMesh(), numberOfPoint, bound);
GenRandomPointsSetTriangulator randomTriangulator = new GenRandomPointsSetTriangulator(new PMesh(), numberOfPoint, bound);
// fill in the points into the empty triangulation
randomTriangulator.generate();
......
package org.vadere.meshing.examples;
import org.vadere.meshing.mesh.gen.PMesh;
import org.vadere.meshing.mesh.gen.PMeshSuppliert;
import org.vadere.meshing.mesh.impl.PMeshPanel;
import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.meshing.mesh.inter.IPointConstructor;
import org.vadere.meshing.mesh.triangulation.IEdgeLengthFunction;
import org.vadere.meshing.mesh.triangulation.improver.eikmesh.gen.GenEikMesh;
......@@ -25,12 +23,9 @@ import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.math.IDistanceFunction;
import java.io.BufferedInputStream;