Fast intersection between Line and Mesh 🗲

Revised for version 12. Now, viewportLayout1 is of type Model.


From Eyeshot version 12 and beyond, Line/Mesh intersection computation speed can be improved using the Mesh.BuildOctree() method.

The 3D space will be partitioned recursively in octants until the maxNumTriangles threshold is reached.

ReadSTL rs = new ReadSTL("bunny.stl");

Mesh mesh = (Mesh)rs.Entities[0];
viewportLayout1.Entities.Add(mesh, Color.Beige);
Line line = new Line(new Point3D(-80, -15, 40), new Point3D(80, -15, 30));
viewportLayout1.Entities.Add(line, Color.Red);

mesh.BuildOctree(); // builds octree data structure

Segment3D segment = new Segment3D(line.StartPoint, line.EndPoint);
IList<HitTriangle> trianglesHit = mesh.FindClosestTriangle(null, segment);

foreach (HitTriangle triangle in trianglesHit) 
   viewportLayout1.Entities.Add(new devDept.Eyeshot.Entities.Point(triangle.IntersectionPoint, 4), Color.Red);
Was this article helpful?
1 out of 2 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.