on_mesh and line intersect problem

attchment has a test 3dm file ,which incloud a mesh and a line,
when I using IntersectLine will get 4 intersect point,but these 4 intersect poins are the same point,and is just equle the end point of the line.
attchment also has the whole test code of my pluginIntersectMeshLine.rar (47.9 KB)

please help me to see what problem in my codes

Maybe it is better to use the ON_MeshXLine class to calculate the Mesh/Line intersection, instead of the function of ON_MeshTree?

Let me know if this sample code is helpful.


Thanks to all.
your codes also get the wrong result just as my codes .

I want to try to use ON_MeshXLine ,but I don,t know How to use this class.
can you give me same example codes and test it using my test 3dm file in my attachment.

With the model you posted, the sample command I posted finds a single (1) intersection through the mesh face with index = 2059. See the attached image

Perhaps I don’t have all of the information?

thanks for your anser.I also try your codes ,and
I know why I will get a wrong result now
when I set the tolerance to 1.0 or 0.1 will get a wrong result,
when I set the tolerance to 0 will get a right reslut.
I think maybe this is also a bug of the intersect functhion.
because In fact ,I need set the tolerance to 1.0 or a more big number sometimes.

please help me to see why the tol must be set to 0

do you have time to see why when I set the tolerance to 1.0 or 0.1 will get a wrong result?
Thanks very much!

I’m confused. If it calculates the correct intersection without a tolerance, why do you want to specify one?

1 Like

Because In my actually plugin sometimes I need set the tolerance to 0.0,but sometime maybe set to 1.0 ,or 2.0.even other any nunbers,this depends on my specific application。

can your help me debug why when tol is not 0,intersect will failed?

@dale, @NiceDay added a tolerance to your sample code, nothing else is modified in the code.

The SampleLineMeshIntersect command finds two points at the lower end of the line. Can you explain what is wrong here? Thanks.

LineCurveIntersect.rar (172.0 KB)

No I cannot, but I will report the issue. In general, though, there should be no reason to specify a tolerance when intersecting a mesh with a line, as there is always an answer.