Degenerate Curves

Hi All,

I read a lot of topics here about degenerate curves, but I didn't find what I'm looking for.

I'm importing some step files and I have some degenerate curves:

Is it really necessary maintain these curves? if not, how can I delete within lost links between edges and curves?
(I already tried to use ShapeFix_Wire and I have no success)

Could someone help me?
Thanks in Advance

Roman Lygin's picture

As you know some surfaces has so called singularities - parts of its 2D parametric space (U,V) which corresponds to a single point in 3D space (X,Y,Z). The classic example is a sphere which 2D space is [0, 2*Pi] x [-Pi/2, Pi/2]. The south and north pole in 3D space are represented by V-isolines in 2D space as follows:
- south pole: V = -R (any U)
- north pole: V = R (any U)
Consider the Earth - there is no longitude for South and North Poles, they are marked as latitudes 90 South and 90 North respectively.

Open CASCADE requires that a face's wire represents a closed contour both in 2D parametric space and in 3D space. To achieve that, edges with parametric curves (pcurves) lying in surface singularities are marked as degenerated (i.e. have special flag IsDegenerated and has no 3D curve).
Consider the face that is created when using BRepPrimAPI_MakeSphere. It has a wire of 4 edges, 2 of which have pcurves going along U=-R and U=R and have no 3D curve.

Draw> pload ALL
Draw> psphere s 10
Draw> explore s f
Draw> dump s_1
Draw> av2d
Draw> pcurve s_1
Draw> 2dfit

Hope this helps.

tmacedo29's picture

Hi Roman Lygin,

Thank you very much for your answer!

My problem is I'm using a different display program, and I'm sending to it my curves to display. And I want to avoid these degenerated curves because it causes problems when user select it.

Could you help me?

Thanks in Advance.

Roman Lygin's picture

By "different display program" do you mean something your own developed, not OCC visualization ? Do you compute triangulation (e.g. with BRepMesh) before that ? If you do, then you must preserve degenerated edges, at least to compute the triangulation. pcurves of degenerated edges are used to calculate points of the triangulation in 2D space.

If in your own "different display program" you iterate over edges, you could add a check if the edge is degenerated and ignore it.

for (....) {
const TopoDS_Edge& anEdge = ...;
if (BRep_Tool::Degenerated (anEdge)) {

If you are certain that removal of the degenerated edges is really what you want, you could use ShapeBuild_ReShape to remove such edges

Handle(ShapeBuild_ReShape) aReshape = new ShapeBuild_ReShape;
for (....) {
const TopoDS_Edge& anEdge = ...;
if (BRep_Tool::Degenerated (anEdge)) {
aReshape->Remove (anEdge);
TopoDS_Shape aNewShape = aReshape->Apply(); //new shape without degenerated edges

However beware that this shape becomes invalid from OCC point of view and can hardly be used in its algorithms (visualization, meshing, topological operations, etc)

Hope this will be helpful.