For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Line - Face intersection

CHABAUD's picture
Forums: 

I use GeomAPI_IntCS to perform the intersection between a line and a face.
It seams to work fine except that the performance (time to compute) have been drastically decreased comparing to a previous Cascade version.

How to fix the precision ?

I also try IntCurvesFace_Intersection which is faster but give incorrect result.

Anybody could help ?

Rob Bachrach's picture

Assuming that you are performing many intersection checks (like one line and many faces), you can limit the number of checks by comparing their bounding boxes for intersection first. You might want to look at the Bnd package for bounding box classes (Bnd_Box) and classes to compare a box to a list of boxes for intersections (Bnd_BoundSortBox).

CHABAUD's picture

Thanks a lot Rob for your response. More information :
I want to perform many line-face intersection but for each test I only have 1 face.

I used the folowing code :
gp_Pnt depart(pos.X(),pos.Y(),pos.Z());
gp_Dir direction(dir.X(),dir.Y(),dir.Z());
GC_MakeLine mkLine(depart, direction);

BRepAdaptor_Surface surface(MyFace);
const GeomAdaptor_Surface& geomAdapSurf = surface.Surface();
const Handle(Geom_Surface)& geomSurf = geomAdapSurf.Surface();

GeomAPI_IntCS inCS;
inCS.Perform(mkLine.Value(),geomSurf);

if (inCS.IsDone())
{
if (inCS.NbPoints() == 0)
...

I just need a precision of 1e-3 mm fot the intersected point.

Previously I was using IntCurvesFace_Intersector instead of GeomAPI_IntCS. It was faster but with Cascade 5.2 there is a bug which seams to be fixed using GeomAPI_IntCS (except the time needed for the compuation).

Rob Bachrach's picture

Even along these lines, my code found a substantial speed increase when I intersected the bounding box of the face with the line before performing the intersection calculation. In many cases, intersecting a line with the 6 bounding planes of a box is much faster than intersecting with an arbitrary surface.

CHABAUD's picture

I will try your suggestion but I don't think it will help because in my case the line always intersect the face.

It seams than the default precision is 1e-9, I just need 1e-3, do you know how to set the precision for GeomAPI_IntCS.

Thanks in advance.

Hugues's picture

I suggest you try the class IntCurvesFace_ShapeIntersector, it does its job pretty quick. Quicker than what you can obtain from classes GeomAPI_IntCS or BRepIntCurveSurface_Inter.
Also look the thread :
http://www.opencascade.org/org/forum/thread_5436/

Spéciale dédicace à tous les francophones.

CHABAUD's picture

I have just tested IntCurvesFace_ShapeIntersector as suggested but the result is the same than with IntCurvesFace_Intersector.
It is fast but false.
GeomAPI_IntCS is slow but gives correct results.

I will try Rob suggestion

Hugues's picture

What do you mean by a "false result"? Dooes it generate points that are really out of space or points that seem correct but that do not satisfy your precision criterion?
To tell you the truth i encountered some rare bugs too with the "bounded" computation of IntCurvesFace_ShapeIntersector objects.
By "bounded" I mean the intersection of a segment between faces. But with a line-based computation (i.e. inf_param=-infinity and sup_param=+infinity) I get correct intersection points.

CHABAUD's picture

With the same surface and line I get 1 intersection with GeomAPI_IntCS and it is correct because I know it is correct.
With IntCurvesFace_Intersector or IntCurvesFace_ShapeIntersector this intersection point is not seen. Perform returns no intersection.
I used 0.0 to 1e8 for bounded values.

CHABAUD's picture

Dear Hugues.
Instead of using 0.0 and 1e8 for bounded values passed to Perform I tried to use -Infinite and +Infinite and... this is working !!!
It is not understandable as the intersected distance is about 5mm.
Thank you for your remark concerning bounded values.

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.