Skip to content

Commit 3ed53dd

Browse files
committed
adding option to have triangualtion be done without changing winding
1 parent 62b1940 commit 3ed53dd

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ else if (somePointsInBack) {
421421
}
422422
if (f.size() >= 3) {
423423
try {
424-
front.add(new Polygon(f, polygon.getStorage(),false,polygon.plane).setColor(polygon.getColor()));
424+
Polygon fpoly = new Polygon(f, polygon.getStorage(),false,polygon.plane).setColor(polygon.getColor());
425+
front.add(fpoly);
425426
} catch (Exception ex) {
426427
System.err.println("Pruning bad polygon Plane::splitPolygon");
427428
// skip adding broken polygon here
@@ -431,7 +432,8 @@ else if (somePointsInBack) {
431432
}
432433
if (b.size() >= 3) {
433434
try {
434-
back.add(new Polygon(b, polygon.getStorage(),false,polygon.plane).setColor(polygon.getColor()));
435+
Polygon bpoly = new Polygon(b, polygon.getStorage(),false,polygon.plane).setColor(polygon.getColor());
436+
back.add(bpoly);
435437
} catch (Exception ex) {
436438
// ex.printStackTrace();
437439
System.err.println("Pruning bad polygon Plane::splitPolygon");

src/main/java/eu/mihosoft/vrl/v3d/ext/org/poly2tri/PolygonUtil.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,22 @@ private PolygonUtil() {
9494
//
9595
// return result;
9696
// }
97-
9897
/**
9998
* Concave to convex.
10099
*
101100
* @param incoming the concave
102101
* @return the list
103102
*/
104-
public static List<Polygon> concaveToConvex(Polygon incoming) {
103+
public static List<Polygon> concaveToConvex(Polygon incoming){
104+
return concaveToConvex(incoming,true);
105+
}
106+
/**
107+
* Concave to convex.
108+
*
109+
* @param incoming the concave
110+
* @return the list
111+
*/
112+
public static List<Polygon> concaveToConvex(Polygon incoming, boolean toCCW) {
105113
List<Polygon> result = new ArrayList<>();
106114

107115
if (incoming == null)
@@ -175,7 +183,7 @@ public static List<Polygon> concaveToConvex(Polygon incoming) {
175183
}
176184

177185
boolean cw = !Extrude.isCCW(concave);
178-
if (cw)
186+
if (cw&&toCCW)
179187
concave = Extrude.toCCW(concave);
180188
if (debug) {
181189
Debug3dProvider.clearScreen();

0 commit comments

Comments
 (0)