22
33import java .lang .foreign .MemorySegment ;
44import java .util .ArrayList ;
5- import java .util .Arrays ;
6- import java .util .HashMap ;
75import java .util .List ;
8- import java .util .Map ;
96
107import com .cadoodlecad .manifold .ManifoldBindings ;
118import com .cadoodlecad .manifold .ManifoldBindings .ManifoldError ;
1613import eu .mihosoft .vrl .v3d .Transform ;
1714import eu .mihosoft .vrl .v3d .Vector3d ;
1815import eu .mihosoft .vrl .v3d .Vertex ;
19- import eu .mihosoft .vrl .v3d .ext .org .poly2tri .PolygonUtil ;
2016
2117public class CSGManifold3d {
2218 private final ManifoldBindings manifold ;
23- // private final Manifold3dExporter exporter;
24- // private final Manifold3dImporter importer;
19+ // private final Manifold3dExporter exporter;
20+ // private final Manifold3dImporter importer;
2521
2622 public CSGManifold3d () throws Exception {
2723 this .manifold = new ManifoldBindings ();
28- // exporter = new Manifold3dExporter(manifold);
29- // importer = new Manifold3dImporter(manifold);
24+ // exporter = new Manifold3dExporter(manifold);
25+ // importer = new Manifold3dImporter(manifold);
3026 }
3127
32-
3328 /**
3429 * Converts a JCSG {@link CSG} into a native manifold {@link MemorySegment}.
3530 *
@@ -49,7 +44,6 @@ public MemorySegment toManifold(CSG csg) throws Throwable {
4944 if (csg == null )
5045 throw new IllegalArgumentException ("csg must not be null" );
5146
52-
5347 double [] vertices = csg .getVertices ();
5448
5549 long [] triangles = csg .getTriangles ();
@@ -91,7 +85,6 @@ public CSG fromManifold(MemorySegment ms) throws Throwable {
9185 return new CSG (verts , tris );
9286 }
9387
94-
9588 /**
9689 * Slices the given CSG at Z=0 and returns the resulting cross-section as a list
9790 * of JCSG {@link Polygon} objects.
@@ -109,7 +102,7 @@ public CSG fromManifold(MemorySegment ms) throws Throwable {
109102 * the solid to slice
110103 * @return closed polygon contours of the cross-section at Z=0, never
111104 * {@code null}, may be empty if the plane misses the solid
112- * @throws Throwable
105+ * @throws Throwable
113106 * @throws RuntimeException
114107 * wrapping any native call failure
115108 */
@@ -257,25 +250,24 @@ private void checkResult(MemorySegment... memorySegments) throws Throwable {
257250 for (int i = 0 ; i < memorySegments .length ; i ++) {
258251 MemorySegment ms = memorySegments [i ];
259252 ManifoldError err = manifold .status (ms );
260- //System.out.println("Status of Manifold Op is "+result);
253+ // System.out.println("Status of Manifold Op is "+result);
261254 if (err != ManifoldError .NO_ERROR ) {
262255 System .out .println ("Status: " + err );
263256 System .out .println ("Verts: " + manifold .numVert (ms ));
264257 System .out .println ("Tris: " + manifold .numTri (ms ));
265258 System .out .println ("Genus: " + manifold .genus (ms ));
266259 throw new NonManifoldShapeError ("Error was " + err );
267260 } else {
268- //System.out.println("Manifold check ok!");
261+ // System.out.println("Manifold check ok!");
269262 }
270263 }
271264 }
272265
273-
274266 public CSG hull (List <Vector3d > points ) throws Throwable {
275267 ArrayList <double []> pts = new ArrayList <double []>();
276268 for (int i = 0 ; i < points .size (); i ++) {
277269 Vector3d v = points .get (i );
278- double [] p = new double [] { v .x , v .y , v .z };
270+ double [] p = new double []{ v .x , v .y , v .z };
279271 pts .add (p );
280272 }
281273 MemorySegment mem = null ;
@@ -293,10 +285,8 @@ public CSG hull(List<Vector3d> points) throws Throwable {
293285 }
294286 }
295287
296-
297288 public void delete (MemorySegment back ) throws Throwable {
298289 manifold .delete (back );
299290 }
300291
301-
302292}
0 commit comments