Search code examples
javajavafxgeometryjavafx-8javafx-3d

Error when creating an object TriangulatedMesh


enter image description here I want to create a figure in the form of the letter T
When I create an object with these points, the exception drops
Has anyone come across this?

I use FXyz3D

final List<Point3D> points = new ArrayList<>(//I am trying to create an array of points (x, y, 0)
Arrays.asList(
new Point3D(0,150,0),
new Point3D(0, 90,0),
new Point3D(10,90,0),
new Point3D(30,90,0),
new Point3D(40,90,0),
new Point3D(10,0,0),
new Point3D(30,0,0),
new Point3D(40,150,0))
            );
TriangulatedMesh customShape = new 
TriangulatedMesh(points,20);//Exception falls on this place


This is the console output when I run the program

I can’t understand what the problem is.

Exception in Application start method
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.RuntimeException: Intersecting Constraints
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:657)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.edgeEvent(DTSweep.java:631)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.edgeEvent(DTSweep.java:626)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.edgeEvent(DTSweep.java:348)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.sweep(DTSweep.java:110)
	at org.poly2tri.triangulation.delaunay.sweep.DTSweep.triangulate(DTSweep.java:72)
	at org.poly2tri.Poly2Tri.triangulate(Poly2Tri.java:108)
	at org.poly2tri.Poly2Tri.triangulate(Poly2Tri.java:60)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.createMesh(TriangulatedMesh.java:285)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.createMesh(TriangulatedMesh.java:218)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.updateMesh(TriangulatedMesh.java:112)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.<init>(TriangulatedMesh.java:103)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.<init>(TriangulatedMesh.java:93)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.<init>(TriangulatedMesh.java:90)
	at org.fxyz3d.shapes.primitives.TriangulatedMesh.<init>(TriangulatedMesh.java:82)
	at sampleFxyz3D.Sample.start(Sample.java:89)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
	... 1 more
Exception running application sampleFxyz3D.Sample


Solution

  • final List<Point3D> points = new ArrayList<>(Arrays.asList(
    
                new Point3D(0, 90,0),
                new Point3D(0,150,0),
    
                new Point3D(40,150,0),
                new Point3D(40,90,0),
    
                new Point3D(30,90,0),
                new Point3D(30,0,0),
    
                new Point3D(10,0,0),
                new Point3D(10,90,0)
        )
                );
    

    It is important that points are ordered forming a closed polygon.