Fast intersection between Line and Mesh 🗲

2018-05-25_13-56-04.jpg

From Eyeshot version 11 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");
rs.DoWork();
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?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.