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

How exactly is BRepAlgo_Section working

Zettler's picture

Dear all,
I am heavily using the above mentioned function to make section cuts through a Shape.
I also generate PCurves during the sectioning command. Sometimes I get weird results (no Intersection at all, or a gp_Lin which has a start and end point far beyond the shape limits.

I tried to dig into the code to understand how exactly the sectioning is done, but its too complex for me.

So is there anybody out there who is able to help me understand the code, so that I am able to solve my problem??

Thank you very much in advance.


Bearloga's picture

Try using BRepAlgoAPI_Section, it is a different algorithm, and it may work better.

Zettler's picture

HI Bearloga and thx for your suggestion.

I already tried BRepAlgoAPI_Section and the result is even worse :(

I do not only want to "use" the functions, I also need to understand what is going on is there really nobody who knows how the algo work in general?

Thx in advance,


Bearloga's picture

It is interesting to see your problem shapes to intersect. Could you upload them somewhere?

Zettler's picture

Dear Bearloga,

I can upload them, no problem. In fact the problems come up from time to time, not exactly a special file. I work mainly on Step-CAD-Files. Only one surface which consists of different TopoDS_Faces. I need the cuts to get a tool path for my Cnc-Machines (its all in the FreeCAD Project on Sourceforge if you want to see the code directly :))
The problems in my case are sometimes related to the PCurves which are of type GeomAbs_Line. The problem with such a line is, that I cannot just use a GCPnts_QuasiUniformDeflection with it to get some points for my toolpath as the line is infinite.
Now I would like to reprogramm the cutting algo in a way that it produces only BSPline Curves and nothing else for the PCurves. I also would like to implement some other things but before I have to understand the code much better then I do currently :( Especially what is the Filler and how the actual Cut is done...

Bearloga's picture

Why do you use PCurves for getting your toolpath points rather than 3d curves?
If you get pcurve using BRepTool_CurveOnSurface then use 'first' and 'last' output parameters to restrict an infinite line. If on input you have only finite faces the algorithm should not produce infinite section edges. Rather each section edge contains a curve (that may be infinite) and two restricting parameters.
You may also use BRepAdaptor_Curve class to get the bounded curve that you can simply pass to GCPnts classes.

Zettler's picture

yes you are right. The input does not contain infinite faces, but the result is an infinite line which can be bounded by the first and last returned by BRepTool_CurveOnSurface. I use the PCurves because I also need the proper Surface Normal at the toolpath points. At the beginning of my programming I did take the 3d curves and used GeomAPI_ProjecttoFace to get the proper Normal but this was very time consuming. Now its much easier to handle.
Ah, another thing: I just tested the BRepAdaptor_Curve class and this one is exactly doing what I want. So for now my problems are solved...but for my PhD thesis I still need to know how the section algorithm is working in detail :(
Thx a lot for your help Bearloga.

Bearloga's picture

Saying about 3d curves and normals to surface, you did not need to re-project 3d points from curve back to surface. If you have an edge from which the 3d curve was given, and this edge contains also a pcurve for this surface, you can take the 2d point on surface simply evaluating pcurve with the same parameter as 3d curve.
But using pcurve to generate distribution of 3d points is not good, as a sequence of points in parametric space can take quite another form in 3d space, due to parametric distortions.
Concerning section algo insides, it is actually very complex algo, to understand how it works probably it is better to search some scientific articles to get background before diving into the code itself.

Zettler's picture

thx for this. I did not know that there might be some parametric distortions when using the pcurve directly and I also did not know the relationship between 3d curve and surface. I will convert everything like you suggested it.
Once again the algo: I already have a good background in NURBS, Intersection Algos and all this stuff...but in OCC there is so much stuff put around the actual Intersection Algos so that I am totally lost.
Do you have detailed knowledge of the different steps the algo goes through?

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.