Finally I got a OCC code sequence that segfaults and is independent of FreeCAD:

Code: Select all

` TColgp_Array1OfPnt poles(1,6); `

poles(1) = gp_Pnt(537.277,-284.089,0.0);

poles(2) = gp_Pnt(575.138,-218.104,0.0);

poles(3) = gp_Pnt(636.797,-282.468,0.0);

poles(4) = gp_Pnt(664.38,-217.56,0.0);

poles(5) = gp_Pnt(721.71,-280.84,0.0);

poles(6) = gp_Pnt(759.57,-214.31,0.0);

TColStd_Array1OfReal weights(1,6);

weights(1) = 1.0;

weights(2) = 1.0;

weights(3) = 1.0;

weights(4) = 1.0;

weights(5) = 1.0;

weights(6) = 1.0;

TColStd_Array1OfReal weights2(1,7);

weights2(1) = 12.99;

weights2(2) = 12.99;

weights2(3) = 12.99;

weights2(4) = 12.99;

weights2(5) = 1.0;

weights2(6) = 12.99;

weights2(7) = 12.99;

TColStd_Array1OfReal knots(1,4);

knots(1) = 0.0;

knots(2) = 0.33333333333;

knots(3) = 0.66666666666;

knots(4) = 1.0;

TColStd_Array1OfInteger mults(1,4);

mults(1) = 4;

mults(2) = 1;

mults(3) = 1;

mults(4) = 4;

Geom_BSplineCurve * mybsp = new Geom_BSplineCurve(poles, weights, knots, mults, 3, false, true);

mybsp->IncreaseMultiplicity(2,2);

TColgp_Array1OfPnt poles2(1,mybsp->NbPoles());

mybsp->Poles(poles2);

//TColStd_Array1OfReal weights2(1,mybsp->NbPoles());

//mybsp->Weights(weights2);

TColStd_Array1OfReal knots2(1,mybsp->NbKnots());

mybsp->Knots(knots2);

TColStd_Array1OfInteger mults2(1,mybsp->NbKnots());

mybsp->Multiplicities(mults2);

for (Standard_Integer it = 1; it <= poles.Length(); it++) {

mybsp->SetPole(it, poles2(it), weights2(it));

}

for (Standard_Integer it = 1; it <= knots.Length(); it++) {

mybsp->SetKnot(it, knots2(it), mults2(it));

}

Standard_Real k2 = mybsp->Knot(1);

GeomLProp_CLProps prop(mybsp,k2,0,Precision::Confusion());

const gp_Pnt &point=prop.Value();

When I execute this, linked to our FreeCAD OCE: 6.8.0.oce-0.17, it segfaults in the last but one line (GeomLProp_CLProps prop(mybsp,k2,0,Precision::Confusion());).

It only segfaults if the checkrational parameter above ( the last true in Geom_BSplineCurve * mybsp = new Geom_BSplineCurve(poles, weights, knots, mults, 3, false, true);), is set to true.

What I understand is that, if the bspline was created with equal weights and we asked to check if it is rational (I think this is to optimize for polynomic), then we do the knot multiplicity increase, and then we add weights that are different, thus rational, something goes wrong when asking the point of a parameter.

This FreeCAD branch:

https://github.com/abdullahtahiriyo/Fre ... c_segfault would execute the code above if:

1. Create an sketch, and in the sketch a bspline of at least 5 poles (so that it has at least a knot for degree 3).

2. Hit the "X" button in the Bspline bar:

- knottool_occ_fix.png (8.41 KiB) Viewed 238 times

I will try to do something excised from FreeCAD to report it...

**Maybe somebody with more OCC experience could take a look to the code above, to see if there is something off in my code**