How to Split bspline curve in subcurves(bspline)

Hi all,

Is there a method to split a bspline curve into two completely independent curves?

I have to reverse a secondary curve and I don't want to reverse the original one. They must be independent.

GeomAdaptor_Curve allows me to use a portion of the curve, but the underlined curve is always the same.
When I reverse a portion of the curve, I reverse the entire curve!

I have see the theBSpline->Copy(); methot but it generate a GeomGeometry * element . How can I recreate as bspline ?

Mikhail Sazonov's picture

Geom_BSplineCurve is a descendant class of Geom_Geometry. So, you need just to downcast it to obtain a bspline curve.

Marco Balen's picture

Hi Mikhail,

I have downcasted the pointer and it seems works.
So, When I have to invert the subcurve I copy original curve ,do the invertion and then I also get the inverted parameters.
TheSpline = Handle(Geom_BSplineCurve)::DownCast(TheSpline->Copy());
TheSpline->Reverse();
double utmp = Umax;
Umax = TheSpline->ReversedParameter(Umin);
Umin = TheSpline->ReversedParameter(utmp);

But I think I can avoid this procedure if I can split the curve in sub independent curve as first operation.
Do you know a method to do this ?

Mikhail Sazonov's picture

What is wrong to you in this procedure? Anyway to leave the original curve untouched you need to make a copy.
You can also consider the method Segment() that modifies the curve using new range.

Marco Balen's picture

Hi Mikhail,

I am trying to optimize and generalize the procedure and if I have to copy the curve before inverse it, I do it.
I hte actual procedure I can get or reconduce some curves to a bspline (Ellipse,Hyperbola,Parabola,BSplineCurve), copy it if I have to reverse, than reverse and use the original or reversed curve as i need.
But it seems I cannod do this Bezier or "Other curves".
Is there a method to handle the curve to an Higher level ?
I explain.
I have an BRepAdaptor_Curve() from and Edge with the underlined curve.
From the BRepAdaptor_Curve() I can get the type of the curve and I can reconduce some curve to bspline, but I can also get an GeomAdaptor_Curve() with the method Curve().
With the GeomAdaptor_Curve() I can get an handle to the Geom_Curve with the method Curve().
Than I can reverse the curve(also if it is a Bezier or other curve), I can get also the Reversed parameters.
But, in this case I have also to copy the curve before reverse it ?
If so, How can I copy the Geom_Curve() ?

Thanks for your support

Mikhail Sazonov's picture

If you get Geom_Curve from BRepAdaptor_Curve with the method Curve() you get the curve belonging to the edge. If you modify it you will harm the edge.
Geom_Curve inherits Geom_Geometry, which is the base of any geometry, and the pure virtual method Copy is defined there. We have already discussed it above. What is wrong in using it?
But I wonder why do you need to get reversed curve? Why cannot you use the curve (BRepAdaptor or Geom) directly and use orientation of edge if it is needed to adjust the algorithm to take it into account?

Marco Balen's picture

Hi Mikhail,
I am managing a Geom_Curve now and it seems works.
I have preferred to invert the original curve because I have to split it and approximate the sub curves with lines, arcs or Helix and I seems to better invert the element only one times and proceed to analize it always from start to end instead of check every time if I have to generate lines ,arcs or helix in the right way instead the revers way.
I wiil take in account your suggestion.

Thanks for your support