Skip to content

Commit be64b75

Browse files
committed
hole detection added (still not working because paths are wrong)
1 parent 3af7468 commit be64b75

File tree

1 file changed

+5
-36
lines changed

1 file changed

+5
-36
lines changed

src/main/java/eu/mihosoft/vrl/v3d/Edge.java

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Optional;
1313
import java.util.stream.Collectors;
1414
import java.util.stream.Stream;
15+
import eu.mihosoft.vrl.v3d.ext.org.poly2tri.PolygonUtil;
1516

1617
/**
1718
*
@@ -282,7 +283,7 @@ public static List<Polygon> boundaryPathsWithHoles(List<Polygon> boundaryPaths)
282283
result.get(maxIndex).getStorage().
283284
set(KEY_POLYGON_HOLES, holes);
284285
}
285-
286+
286287
holes.add(result.get(i));
287288
}
288289
}
@@ -349,7 +350,7 @@ private static List<Polygon> boundaryPaths(List<Edge> boundaryEdges) {
349350
edge = boundaryEdges.get(startIndex);
350351
used[startIndex] = true;
351352
}
352-
353+
353354
}
354355

355356
System.out.println("paths: " + result.size());
@@ -611,7 +612,7 @@ private static List<Edge> boundaryEdgesOfPlaneGroup(List<Polygon> planeGroup) {
611612
List<Edge> realBndEdges = bndEdgeStream.
612613
filter(be -> edges.stream().filter(
613614
e -> falseBoundaryEdgeSharedWithOtherEdge(be, e)
614-
).count() == 0).collect(Collectors.toList());
615+
).count() == 0).collect(Collectors.toList());
615616

616617
//
617618
// System.out.println("#bnd-edges: " + realBndEdges.size()
@@ -638,41 +639,9 @@ private static List<Polygon> boundaryPolygonsOfPlaneGroup(
638639

639640
if (!holesOfPresult.isPresent()) {
640641
result.add(p);
641-
continue;
642-
}
643-
644-
List<Polygon> holesOfP = holesOfPresult.get();
645-
646-
List<Polygon> simplePs = new ArrayList<>();
647-
simplePs.add(p);
648-
649-
for (Polygon hP : holesOfP) {
650-
Bounds b = hP.getBounds();
651-
Vector3d p1 = b.getMin();
652-
Vector3d p2 = b.getMax();
653-
Vector3d p3 = Vector3d.ZERO;
654-
Plane cutPlane = Plane.createFromPoints(p1, p2, p3);
655-
656-
List<Polygon> coplanar = new ArrayList<>();
657-
List<Polygon> frontAndBack = new ArrayList<>();
658-
659-
for (Polygon sP : simplePs) {
660-
// does not work
661-
cutPlane.splitPolygon(sP, coplanar, coplanar, frontAndBack, frontAndBack);
662-
}
663-
664-
simplePs = frontAndBack;
665-
666-
System.out.println("simple: " + simplePs.size() + ", front&back: " + frontAndBack.size() + ", colpanar: " + coplanar.size());
667-
668-
}
669-
670-
if (holesOfP.isEmpty()) {
671-
result.add(p);
672642
} else {
673-
result.addAll(simplePs);
643+
result.addAll(PolygonUtil.concaveToConvex(p));
674644
}
675-
676645
}
677646

678647
return result;

0 commit comments

Comments
 (0)