Null Pointer Exception during Triangulation
See original GitHub issueCaused by: java.lang.NullPointerException
at org.dyn4j.geometry.decompose.SweepLine.regular(SweepLine.java:258)
at org.dyn4j.geometry.decompose.SweepLine.createTriangulation(SweepLine.java:128)
at org.dyn4j.geometry.decompose.SweepLine.triangulate(SweepLine.java:79)
This seems to occur at random points during triangulation. I’m triangulating polygons sliced from an STL that had ~25000 triangles to create an STL surface, so there’s a lot of opportunity to hit edge cases I suspect. Unfortunately it also means that there’s a ton of prior calculations and tracking down why it happens is a minor nightmare…
For reference this happens via this code:
public List<Triangle> toTrianglesInPlane(List<Point3D> points) {
SweepLine sl = new SweepLine();
List<Vector2> vector2s = projectToPlane(points);
return sl.triangulate(vector2s.toArray(new Vector2[]{}));
}
Since at this point I’m only dealing with planes orthogonal to the Z axis the project to plane code is trivial… There are multiple threads running this in parallel but the Point3D objects are immutable and as you can see the code creates a new Sweepline within each thread so unless you reference mutable statics it should be safe.
(Dyn4j 3.3.0)
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
HE_Mesh Voronoi Example from share & tell Null Pointer Exception ...
Exception in thread "Animation Thread" java.lang.NullPointerException. at wblut.geom.triangulate.Triangulation.splitEdge(Triangulation.java:942).
Read more >java - What is a NullPointerException, and how do I fix it?
A null pointer exception is thrown when an application attempts to use null in a case where an object is required. These include:...
Read more >How to Fix and Avoid NullPointerException in Java - Rollbar
The NullPointerException occurs due to a situation in application code where an uninitialized object is attempted to be accessed or modified.
Read more >NULL pointer returned in calloc - C / C++ - Bytes
Hello, I am currently facing a problem with a calloc function call which returns a NULL pointer while in a debugging environment. If...
Read more >Cannot obtain triangulation (Handle_Poly_Triangulation is ...
So the point is, triangles.IsNull() is always false here, even though the are faces in the shape, I can't get to any triangles....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@wnbittle @gus-asf I have reproduction polygons for this bug + some more cases for triangulation, I will upload them shortly.
@gus-asf I think your polygons are ill-shaped (self intersections probably?). But then SweepLine should have checks for those cases and throw an appropriate error.
I’m going to close this and track this issue from #75 . I’ve moved the sample you provided over there as well.