How to trim a Curve with two point on it?

jianbaoxia

CAD master
Hi Bros, I'm JianBaoXia.
I get a BSpline curve, and two point on it.
I want to trim the curve and get the segment of the curve between the two points.
I try to do it through Geom_TrimmedCurve, however, it needs convert the two points to parameter values U1 and U2.
In surface I know xyz can convert to uv through ShapeAnalysis_Surface.ValueOfUV().
But there are not same tool in ShapeAnalysis_Curve.
The parameter values always make me confuse.

It's my honor to get advice from you!
 

jianbaoxia

CAD master
@Andrey God, I made it success! Thanks so much! 😃 😃
There is my demo:
Code:
int main()
{
    // ===========
    std::string filePath = "C:/Users/14656/Desktop/Program/Open Cascade/Demo/";
    // ===========
    Handle(Geom_Circle) aCir = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 1);
    gp_Pnt p1(1, 0, 0);
    gp_Pnt p2(0, 1, 0);
    Standard_Real u1;
    Standard_Real u2;
    GeomLib_Tool::Parameter(aCir, p1, Precision::Confusion(), u1);
    GeomLib_Tool::Parameter(aCir, p2, Precision::Confusion(), u2);
    std::cout << "u1:" << u1 << std::endl;
    std::cout << "u2:" << u2 << std::endl;

    Handle(Geom_TrimmedCurve) shape = new Geom_TrimmedCurve(aCir, u1, u2);
    TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(shape);
    WriteStepFile(aEdge, filePath + "aEdge.step");


    return 0;
}
1658245037450.png
 
Top