diff --git a/src/BSplCLib/BSplCLib_2.cxx b/src/BSplCLib/BSplCLib_2.cxx index acef2d983a..0ae8628e5c 100644 --- a/src/BSplCLib/BSplCLib_2.cxx +++ b/src/BSplCLib/BSplCLib_2.cxx @@ -1157,82 +1157,97 @@ void BSplCLib::MergeBSplineKnots index, num_knots ; if (StartValue < EndValue - Tolerance) { - TColStd_Array1OfReal knots1(1,Knots1.Length()) ; - TColStd_Array1OfReal knots2(1,Knots2.Length()) ; - degree = Degree1 + Degree2 ; - index = 1 ; + TColStd_Array1OfReal knots1(1, Knots1.Length()); + TColStd_Array1OfReal knots2(1, Knots2.Length()); + degree = Degree1 + Degree2; + index = 1; - for (ii = Knots1.Lower() ; ii <= Knots1.Upper() ; ii++) { - knots1(index) = Knots1(ii) ; - index += 1 ; + for (ii = Knots1.Lower(); ii <= Knots1.Upper(); ii++) { + knots1(index) = Knots1(ii); + index += 1; } - index = 1 ; + index = 1; - for (ii = Knots2.Lower() ; ii <= Knots2.Upper() ; ii++) { - knots2(index) = Knots2(ii) ; - index += 1 ; + for (ii = Knots2.Lower(); ii <= Knots2.Upper(); ii++) { + knots2(index) = Knots2(ii); + index += 1; } BSplCLib::Reparametrize(StartValue, - EndValue, - knots1) ; - - BSplCLib::Reparametrize(StartValue, - EndValue, - knots2) ; - num_knots = 0 ; - jj = 1 ; + EndValue, + knots1); - for (ii = 1 ; ii <= knots1.Length() ; ii++) { + BSplCLib::Reparametrize(StartValue, + EndValue, + knots2); + num_knots = 0; + jj = 1; + + for (ii = 1; ii <= knots1.Length(); ii++) { while (jj <= knots2.Length() && knots2(jj) <= knots1(ii) - Tolerance) { - jj += 1 ; - num_knots += 1 ; + jj += 1; + num_knots += 1; } while (jj <= knots2.Length() && knots2(jj) <= knots1(ii) + Tolerance) { - jj += 1 ; + jj += 1; } - num_knots += 1 ; + num_knots += 1; } - NewKnots = - new TColStd_HArray1OfReal(1,num_knots) ; + NewKnots = + new TColStd_HArray1OfReal(1, num_knots); NewMults = - new TColStd_HArray1OfInteger(1,num_knots) ; - num_knots = 1 ; - jj = 1 ; + new TColStd_HArray1OfInteger(1, num_knots); + num_knots = 1; + jj = 1; - for (ii = 1 ; ii <= knots1.Length() ; ii++) { + for (ii = 1; ii <= knots1.Length(); ii++) { while (jj <= knots2.Length() && knots2(jj) <= knots1(ii) - Tolerance) { - NewKnots->ChangeArray1()(num_knots) = knots2(jj) ; - NewMults->ChangeArray1()(num_knots) = Mults2(jj) + Degree1 ; - jj += 1 ; - num_knots += 1 ; + NewKnots->ChangeArray1()(num_knots) = knots2(jj); + NewMults->ChangeArray1()(num_knots) = Mults2(jj) + Degree1; + jj += 1; + num_knots += 1; } - set_mults_flag = 0 ; + set_mults_flag = 0; while (jj <= knots2.Length() && knots2(jj) <= knots1(ii) + Tolerance) { - continuity = Min(Degree1 - Mults1(ii), Degree2 - Mults2(jj)) ; - set_mults_flag = 1 ; - NewMults->ChangeArray1()(num_knots) = degree - continuity ; - jj += 1 ; + continuity = Min(Degree1 - Mults1(ii), Degree2 - Mults2(jj)); + set_mults_flag = 1; + NewMults->ChangeArray1()(num_knots) = degree - continuity; + jj += 1; } - NewKnots->ChangeArray1()(num_knots) = knots1(ii) ; - if (! set_mults_flag) { - NewMults->ChangeArray1()(num_knots) = Mults1(ii) + Degree2 ; + NewKnots->ChangeArray1()(num_knots) = knots1(ii); + if (!set_mults_flag) { + NewMults->ChangeArray1()(num_knots) = Mults1(ii) + Degree2; } - num_knots += 1 ; + num_knots += 1; } - num_knots -= 1 ; - NewMults->ChangeArray1()(1) = degree + 1 ; - NewMults->ChangeArray1()(num_knots) = degree + 1 ; - index = 0 ; + num_knots -= 1; + NewMults->ChangeArray1()(1) = degree + 1; + NewMults->ChangeArray1()(num_knots) = degree + 1; + index = 0; - for (ii = 1 ; ii <= num_knots ; ii++) { - index += NewMults->Value(ii) ; + for (ii = 1; ii <= num_knots; ii++) { + index += NewMults->Value(ii); } - NumPoles = index - degree - 1 ; + NumPoles = index - degree - 1; + } + else + { + degree = Degree1 + Degree2; + num_knots = 2; + NewKnots = + new TColStd_HArray1OfReal(1, num_knots); + NewKnots->ChangeArray1()(1) = StartValue; + NewKnots->ChangeArray1()(num_knots) = EndValue; + + NewMults = + new TColStd_HArray1OfInteger(1, num_knots); + NewMults->ChangeArray1()(1) = degree + 1; + NewMults->ChangeArray1()(num_knots) = degree + 1; + NumPoles = BSplCLib::NbPoles(degree, Standard_False, NewMults->Array1()); } } diff --git a/src/Geom2dConvert/Geom2dConvert.cxx b/src/Geom2dConvert/Geom2dConvert.cxx index dd3ba3da94..a120df013b 100644 --- a/src/Geom2dConvert/Geom2dConvert.cxx +++ b/src/Geom2dConvert/Geom2dConvert.cxx @@ -515,7 +515,6 @@ static Handle(Geom2d_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCu Handle(TColStd_HArray1OfReal) resKnots; Handle(TColStd_HArray1OfInteger) resMults; Standard_Real start_value,end_value; - Standard_Real tolerance=Precision::Confusion(); Standard_Integer resNbPoles,degree, ii,jj, aStatus; @@ -527,6 +526,7 @@ static Handle(Geom2d_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCu BS->KnotSequence(BSFlatKnots); start_value = BSKnots(1); end_value = BSKnots(BS->NbKnots()); + Standard_Real tolerance = 10.*Epsilon(Abs(end_value)); a->Knots(aKnots); a->Poles(aPoles); @@ -565,22 +565,6 @@ static Handle(Geom2d_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCu degree, resDenPoles, aStatus); -// BSplCLib::FunctionMultiply(law_evaluator, -// BS->Degree(), -// BSFlatKnots, -// BSPoles, -// resFlatKnots, -// degree, -// resNumPoles, -// aStatus); -// BSplCLib::FunctionMultiply(law_evaluator, -// BS->Degree(), -// BSFlatKnots, -// BSWeights, -// resFlatKnots, -// degree, -// resDenPoles, -// aStatus); for (ii=1;ii<=resNbPoles;ii++) for(jj=1;jj<=2;jj++) resPoles(ii).SetCoord(jj,resNumPoles(ii).Coord(jj)/resDenPoles(ii)); @@ -1339,24 +1323,22 @@ void Geom2dConvert::ConcatC1(TColGeom2d_Array1OfBSplineCurve& ArrayOf Curve1Poles(ii).SetCoord(jj,Curve1Poles(ii).Coord(jj)*Curve1Weights(ii)); //POP pour NT Geom2dConvert_reparameterise_evaluator ev (aPolynomialCoefficient); -// BSplCLib::FunctionReparameterise(reparameterise_evaluator, BSplCLib::FunctionReparameterise(ev, Curve1->Degree(), Curve1FlatKnots, Curve1Poles, FlatKnots, - aNewCurveDegree, + aNewCurveDegree, NewPoles, aStatus ); - TColStd_Array1OfReal NewWeights(1, FlatKnots.Length() - (aNewCurveDegree + 1)); -// BSplCLib::FunctionReparameterise(reparameterise_evaluator, + TColStd_Array1OfReal NewWeights(1, FlatKnots.Length() - (aNewCurveDegree + 1)); BSplCLib::FunctionReparameterise(ev, Curve1->Degree(), Curve1FlatKnots, Curve1Weights, FlatKnots, - aNewCurveDegree, + aNewCurveDegree, NewWeights, aStatus ); diff --git a/tests/bugs/modalg_8/bug33179 b/tests/bugs/modalg_8/bug33179 new file mode 100644 index 0000000000..3ed700aca4 --- /dev/null +++ b/tests/bugs/modalg_8/bug33179 @@ -0,0 +1,9 @@ +puts "================================" +puts "0033179: Modeling Algorithms - Crash in in ShapeFix_Shape with the attached object, when healing for fixing SameParameterFlag" +puts "================================" + +restore [locate_data_file bug33179.brep] s + +fsameparameter s +checkshape s +