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");
rs.DoWork();
Mesh mesh = (Mesh) rs.Entities[0];
design1.Entities.Add(mesh, Color.Beige);
Line line = new Line(new Point3D(-80, -15, 40), new Point3D(80, -15, 30));
design1.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) {
design1.Entities.Add(new devDept.Eyeshot.Entities.Point(triangle.IntersectionPoint, 4), Color.Red);
}
Comments
Hello Benigno,
thanks for sharing above code fragment to be used with the geometric kernel directly. I have tried it out and it did not work in the first place.
I have found out that a call to
is required before trying to find the intersections. This builds up the Octree-structure.
Please, add this to the sample code, if I am right!
Kind regards, Olaf
Hi Olaf,
Since the Octree is a Work Unit you need to call DoWork() method to compute data as well.
I fixed the article, thanks for reporting it.
Please sign in to leave a comment.