question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Null Pointer Exception during Triangulation

See original GitHub issue
Caused 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:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mtsamiscommented, Nov 2, 2019

@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.

0reactions
wnbittlecommented, Nov 5, 2019

I’m going to close this and track this issue from #75 . I’ve moved the sample you provided over there as well.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found