Commit 7eb83cde authored by Matthias Betz's avatar Matthias Betz
Browse files

fixes

parent 0a760af4
Pipeline #12384 failed with stage
in 1 minute and 35 seconds
...@@ -88,8 +88,11 @@ public class SolidSelfIntCheckAABB extends Check { ...@@ -88,8 +88,11 @@ public class SolidSelfIntCheckAABB extends Check {
CheckResult cr; CheckResult cr;
// Build BVH on polygons, but compute AABBs from the *original* polygons // Build BVH on polygons, but compute AABBs from the *original* polygons
BoundingVolumeHierarchyTree<Polygon> tree = BoundingVolumeHierarchyTree<Polygon> tree =
new BoundingVolumeHierarchyTree<>(polys, p -> AABB.of(p.getOriginal())); new BoundingVolumeHierarchyTree.Builder<Polygon>()
.elements(polys)
.function(p -> AABB.of(p.getOriginal()))
.build();
// TODO: comparison with older version without tree // TODO: comparison with older version without tree
List<PolygonIntersection> intersections = List<PolygonIntersection> intersections =
SelfIntersectionUtil.calculateSolidSelfIntersection(g, 0.001, tree); SelfIntersectionUtil.calculateSolidSelfIntersection(g, 0.001, tree);
......
...@@ -84,7 +84,7 @@ public class NestedRingsCheck extends Check { ...@@ -84,7 +84,7 @@ public class NestedRingsCheck extends Check {
@Override @Override
public void check(Polygon p) { public void check(Polygon p) {
if (useAabbFilter) { if (p.getInnerRings().size() > 3) {
checkWithBoundingBoxFilter(p); checkWithBoundingBoxFilter(p);
} else { } else {
checkOriginal(p); checkOriginal(p);
......
...@@ -204,10 +204,8 @@ public class RingSelfIntCheck extends Check { ...@@ -204,10 +204,8 @@ public class RingSelfIntCheck extends Check {
} }
} }
BoundingVolumeHierarchyTree<Edge> edgeTree = new BoundingVolumeHierarchyTree<>( BoundingVolumeHierarchyTree<Edge> edgeTree = BoundingVolumeHierarchyTree.newBinary(
edges, edges, e -> AABB.of(e.getFrom(), e.getTo(), epsilon));
e -> AABB.of(e.getFrom(), e.getTo(), epsilon),
BoundingVolumeHierarchyTree.BuildConfig.binaryDefault());
for (int i = 0; i < edges.size(); i++) { for (int i = 0; i < edges.size(); i++) {
Edge e1 = edges.get(i); Edge e1 = edges.get(i);
...@@ -263,11 +261,9 @@ public class RingSelfIntCheck extends Check { ...@@ -263,11 +261,9 @@ public class RingSelfIntCheck extends Check {
} }
List<Edge> edges = getEdgesForRing(lr); List<Edge> edges = getEdgesForRing(lr);
BoundingVolumeHierarchyTree<Vertex> vertexTree = new BoundingVolumeHierarchyTree<>( BoundingVolumeHierarchyTree<Vertex> vertexTree =
vertices, BoundingVolumeHierarchyTree.newBinary(vertices, v -> AABB.of(v, epsilon));
v -> AABB.of(v, epsilon),
BoundingVolumeHierarchyTree.BuildConfig.binaryDefault());
for (Edge e : edges) { for (Edge e : edges) {
if (checkForPointsTouchingEdgeTree(lr, e, vertexTree)) { if (checkForPointsTouchingEdgeTree(lr, e, vertexTree)) {
...@@ -275,10 +271,8 @@ public class RingSelfIntCheck extends Check { ...@@ -275,10 +271,8 @@ public class RingSelfIntCheck extends Check {
} }
} }
BoundingVolumeHierarchyTree<Edge> edgeTree = new BoundingVolumeHierarchyTree<>( BoundingVolumeHierarchyTree<Edge> edgeTree = BoundingVolumeHierarchyTree.newBinary(
edges, edges, e -> AABB.of(e.getFrom(), e.getTo(), epsilon));
e -> AABB.of(e.getFrom(), e.getTo(), epsilon),
BoundingVolumeHierarchyTree.BuildConfig.binaryDefault());
for (int i = 0; i < edges.size(); i++) { for (int i = 0; i < edges.size(); i++) {
Edge e1 = edges.get(i); Edge e1 = edges.get(i);
......
...@@ -133,21 +133,18 @@ public class SelfIntersectionUtil { ...@@ -133,21 +133,18 @@ public class SelfIntersectionUtil {
public static List<PolygonIntersection> calculateSolidSelfIntersectionWithTree( public static List<PolygonIntersection> calculateSolidSelfIntersectionWithTree(
Geometry g, Geometry g,
double delta, double delta,
BoundingVolumeHierarchyTree.BuildConfig treeConfig) { BoundingVolumeHierarchyTree.Builder<Integer> treeConfig) {
List<TesselatedPolygon> tesselatedPolygons = tesselateAndFilter(g, delta); List<TesselatedPolygon> tesselatedPolygons = tesselateAndFilter(g, delta);
List<Integer> indices = new ArrayList<>(tesselatedPolygons.size()); List<Integer> indices = new ArrayList<>(tesselatedPolygons.size());
for (int i = 0; i < tesselatedPolygons.size(); i++) { for (int i = 0; i < tesselatedPolygons.size(); i++) {
indices.add(i); indices.add(i);
} }
treeConfig.elements(indices).function(index -> AABB.of(tesselatedPolygons.get(index).getOriginal()));
// Build BVH on polygon indices, while computing AABBs from the original polygons // Build BVH on polygon indices, while computing AABBs from the original polygons
BoundingVolumeHierarchyTree<Integer> tree = BoundingVolumeHierarchyTree<Integer> tree = treeConfig.build();
new BoundingVolumeHierarchyTree<>(
indices,
index -> AABB.of(tesselatedPolygons.get(index).getOriginal()),
treeConfig
);
List<PolygonIntersection> intersections = new ArrayList<>(); List<PolygonIntersection> intersections = new ArrayList<>();
...@@ -187,7 +184,7 @@ public class SelfIntersectionUtil { ...@@ -187,7 +184,7 @@ public class SelfIntersectionUtil {
return calculateSolidSelfIntersectionWithTree( return calculateSolidSelfIntersectionWithTree(
g, g,
delta, delta,
BoundingVolumeHierarchyTree.BuildConfig.binaryDefault() new BoundingVolumeHierarchyTree.Builder<Integer>().binaryDefault()
); );
} }
......
package de.hft.stuttgart.citydoctor2.checks.util; package de.hft.stuttgart.citydoctor2.checks.util;
import static org.junit.Assert.*; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.List; import java.util.List;
import org.junit.Test; import org.citygml4j.core.model.CityGMLVersion;
import org.citygml4j.core.model.core.CityModel;
import org.junit.jupiter.api.Test;
import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration; import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration;
import de.hft.stuttgart.citydoctor2.database.UnconnectedCache;
import de.hft.stuttgart.citydoctor2.datastructure.Building; import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel; import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry; import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
...@@ -15,13 +20,30 @@ import de.hft.stuttgart.citydoctor2.datastructure.Lod; ...@@ -15,13 +20,30 @@ import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon; import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.bht.AABB; import de.hft.stuttgart.citydoctor2.datastructure.bht.AABB;
import de.hft.stuttgart.citydoctor2.datastructure.bht.BoundingVolumeHierarchyTree; import de.hft.stuttgart.citydoctor2.datastructure.bht.BoundingVolumeHierarchyTree;
import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException; import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser; import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException; import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection; import de.hft.stuttgart.citydoctor2.utils.PolygonIntersection;
public class SolidSelfIntersectionBVHUtilTest { public class SolidSelfIntersectionBVHUtilTest {
@Test
public void testWriteModel() throws CityDoctorWriteException {
Building b = new Building();
b.addGeometry(GeometryTestUtils.createGoodGeometry());
b.setGmlObject(new org.citygml4j.core.model.building.Building());
UnconnectedCache unconnectedCache = new UnconnectedCache();
CityDoctorModel model = new CityDoctorModel(
new ParserConfiguration(8, false), new File("test.gml"), unconnectedCache);
model.setParsedCityGMLVersion(CityGMLVersion.v2_0);
model.setCityModel(new CityModel());
model.addBuilding(b);
model.saveAs("test.gml", false);
}
@Test @Test
public void testBVHCalculateOnKnownGoodModel() throws CityGmlParseException, InvalidGmlFileException { public void testBVHCalculateOnKnownGoodModel() throws CityGmlParseException, InvalidGmlFileException {
...@@ -42,7 +64,7 @@ public class SolidSelfIntersectionBVHUtilTest { ...@@ -42,7 +64,7 @@ public class SolidSelfIntersectionBVHUtilTest {
assertTrue("Expected at least 2 polygons", polys.size() > 1); assertTrue("Expected at least 2 polygons", polys.size() > 1);
BoundingVolumeHierarchyTree<Polygon> tree = BoundingVolumeHierarchyTree<Polygon> tree =
new BoundingVolumeHierarchyTree<>(polys, p -> AABB.of(p.getOriginal())); BoundingVolumeHierarchyTree.newBinary(polys, p -> AABB.of(p.getOriginal()));
double delta = 0.001; double delta = 0.001;
......
Supports Markdown
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