Habrador / Computational-geometry

Computational Geometry Unity library with implementations of intersection algorithms, triangulations like delaunay, voronoi diagrams, polygon clipping, bezier curves, ear clipping, convex hulls, mesh simplification, etc
https://www.habrador.com/
MIT License
1.25k stars 149 forks source link

Constrained delaunay failing at PointTriangulationIntersection.TriangulationWalk #8

Open johnetc opened 3 years ago

johnetc commented 3 years ago

Hello. I'm trying to create a constrained delaunay graph using _Delaunay.ConstrainedBySloan and I'm getting the below error:

NullReferenceException: Object reference not set to an instance of an object Habrador_Computational_Geometry.PointTriangulationIntersection.TriangulationWalk

_Habrador Computational Geometry Library/1. Intersection/PointTriangulationIntersection.cs:149

My parameters are in the right clockwise (or anti clockwise) direction so I'm not sure what I'm missing.

Is there anything you can suggest that might help? I couldn't see a functioning example for constrained delaunay other than the ear clipping one, and that seems to fail with more than one hole in a square hull. Thanks!

korobetski commented 2 years ago

Same for me, here is the complete error flow :

NullReferenceException: Object reference not set to an instance of an object
Habrador_Computational_Geometry.PointTriangulationIntersection.TriangulationWalk (Habrador_Computational_Geometry.MyVector2 p, Habrador_Computational_Geometry.HalfEdgeFace2 startTriangle, Habrador_Computational_Geometry.HalfEdgeData2 triangulationData, System.Collections.Generic.List`1[T] visitedTriangles) (at Assets/Plugin/Habrador/1. Intersection/PointTriangulationIntersection.cs:149)
Habrador_Computational_Geometry.DelaunayIncrementalSloan.InsertNewPointInTriangulation (Habrador_Computational_Geometry.MyVector2 p, Habrador_Computational_Geometry.HalfEdgeData2 triangulationData, System.Int32& missedPoints, System.Int32& flippedEdges) (at Assets/Plugin/Habrador/4. Triangulation/Delaunay/DelaunayIncrementalSloan.cs:98)
Habrador_Computational_Geometry.DelaunayIncrementalSloan.GenerateTriangulation (System.Collections.Generic.HashSet`1[T] points, Habrador_Computational_Geometry.HalfEdgeData2 triangulationData) (at Assets/Plugin/Habrador/4. Triangulation/Delaunay/DelaunayIncrementalSloan.cs:63)
Habrador_Computational_Geometry._Delaunay.PointByPoint (System.Collections.Generic.HashSet`1[T] points, Habrador_Computational_Geometry.HalfEdgeData2 triangleData) (at Assets/Plugin/Habrador/4. Triangulation/Delaunay/_Delaunay.cs:27)
Habrador_Computational_Geometry.DelaunayToVoronoiAlgorithm.GenerateVoronoiDiagram (System.Collections.Generic.HashSet`1[T] sites) (at Assets/Plugin/Habrador/5. Voronoi diagram/DelaunayToVoronoiAlgorithm.cs:17)
Habrador_Computational_Geometry._Voronoi.DelaunyToVoronoi (System.Collections.Generic.HashSet`1[T] sites) (at Assets/Plugin/Habrador/5. Voronoi diagram/_Voronoi.cs:13)
xknmdss commented 8 months ago

same for me NullReferenceException: Object reference not set to an instance of an object Habrador_Computational_Geometry.PointTriangulationIntersection.TriangulationWalk (Habrador_Computational_Geometry.MyVector2 p, Habrador_Computational_Geometry.HalfEdgeFace2 startTriangle, Habrador_Computational_Geometry.HalfEdgeData2 triangulationData, System.Collections.Generic.List1[T] visitedTriangles) (at Assets/Scripts/1. Intersection/PointTriangulationIntersection.cs:149) Habrador_Computational_Geometry.DelaunayIncrementalSloan.InsertNewPointInTriangulation (Habrador_Computational_Geometry.MyVector2 p, Habrador_Computational_Geometry.HalfEdgeData2 triangulationData, System.Int32& missedPoints, System.Int32& flippedEdges) (at Assets/Scripts/4. Triangulation/Delaunay/DelaunayIncrementalSloan.cs:98) Habrador_Computational_Geometry.DelaunayIncrementalSloan.GenerateTriangulation (System.Collections.Generic.HashSet1[T] points, Habrador_Computational_Geometry.HalfEdgeData2 triangulationData) (at Assets/Scripts/4. Triangulation/Delaunay/DelaunayIncrementalSloan.cs:63) Habrador_Computational_Geometry._Delaunay.PointByPoint (System.Collections.Generic.HashSet1[T] points, Habrador_Computational_Geometry.HalfEdgeData2 triangleData) (at Assets/Scripts/4. Triangulation/Delaunay/_Delaunay.cs:27) Habrador_Computational_Geometry.ConstrainedDelaunaySloan.GenerateTriangulation (System.Collections.Generic.HashSet1[T] points, System.Collections.Generic.List1[T] hull, System.Collections.Generic.HashSet1[T] holes, System.Boolean shouldRemoveTriangles, Habrador_Computational_Geometry.HalfEdgeData2 triangleData) (at Assets/Scripts/4. Triangulation/Delaunay/ConstrainedDelaunaySloan.cs:40) ProjectPointsToTerrain.CreateHighlightedArea (UnityEngine.Vector3[] boundaryPoints) (at Assets/ProjectPointsToTerrain.cs:146) IconManager.OnClickCropIcon (Crop crop, UnityEngine.Transform transform, System.String areaId, System.Collections.Generic.List1[T] boundary) (at Assets/IconManager.cs:358) CropIconController.SpanSecondContent () (at Assets/CropIconController.cs:42) CropIconController.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/CropIconController.cs:36) UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1] functor) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272) UnityEngine.EventSystems.EventSystem:Update() (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:530)