1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0025699: Crash while importing STeP file

1) Try-catch block was added on a StepToTopoDS_TranslateEdgeLoop::Init() to
catch Standard_ConstructionError during the Curve conversion.

2) Checks of BSpline curve degree added to prevent construction error when converting edges to BSpline_Curve.
3) Warning message was added in case of incorrect curve definition.

Correct of the test cases according to the new error message added with fix

Conflicts:
	tests/de/step_1/R9

Modified test cases according to new reference data
This commit is contained in:
akz
2015-02-13 16:34:08 +03:00
committed by bugmaster
parent 2c7b466ce6
commit d088c9c2a1
6 changed files with 53 additions and 22 deletions

View File

@@ -33,6 +33,7 @@
#include <StepGeom_Polyline.hxx>
#include <StepToGeom_MakePolyline.hxx>
#include <StepToGeom_MakeTrimmedCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
@@ -63,8 +64,11 @@ Standard_Boolean StepToGeom_MakeBoundedCurve::Convert
// STEP BSplineCurve before being mapped onto CAS.CADE/SF
if (SC->IsKind(STANDARD_TYPE(StepGeom_BezierCurve))) {
const Handle(StepGeom_BezierCurve) BzC = Handle(StepGeom_BezierCurve)::DownCast(SC);
Standard_Integer aDegree = BzC->Degree();
if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
return Standard_False;
const Handle(StepGeom_BSplineCurveWithKnots) BSPL = new StepGeom_BSplineCurveWithKnots;
BSPL->SetDegree(BzC->Degree());
BSPL->SetDegree(aDegree);
BSPL->SetControlPointsList(BzC->ControlPointsList());
BSPL->SetCurveForm(BzC->CurveForm());
BSPL->SetClosedCurve(BzC->ClosedCurve());
@@ -82,8 +86,11 @@ Standard_Boolean StepToGeom_MakeBoundedCurve::Convert
}
if (SC->IsKind(STANDARD_TYPE(StepGeom_UniformCurve))) {
const Handle(StepGeom_UniformCurve) UC = Handle(StepGeom_UniformCurve)::DownCast(SC);
Standard_Integer aDegree = UC->Degree();
if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
return Standard_False;
const Handle(StepGeom_BSplineCurveWithKnots) BSPL = new StepGeom_BSplineCurveWithKnots;
BSPL->SetDegree(UC->Degree());
BSPL->SetDegree(aDegree);
BSPL->SetControlPointsList(UC->ControlPointsList());
BSPL->SetCurveForm(UC->CurveForm());
BSPL->SetClosedCurve(UC->ClosedCurve());
@@ -103,8 +110,11 @@ Standard_Boolean StepToGeom_MakeBoundedCurve::Convert
if (SC->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformCurve))) {
const Handle(StepGeom_QuasiUniformCurve) QUC =
Handle(StepGeom_QuasiUniformCurve)::DownCast(SC);
Standard_Integer aDegree = QUC->Degree();
if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
return Standard_False;
const Handle(StepGeom_BSplineCurveWithKnots) BSPL = new StepGeom_BSplineCurveWithKnots;
BSPL->SetDegree(QUC->Degree());
BSPL->SetDegree(aDegree);
BSPL->SetControlPointsList(QUC->ControlPointsList());
BSPL->SetCurveForm(QUC->CurveForm());
BSPL->SetClosedCurve(QUC->ClosedCurve());
@@ -126,10 +136,13 @@ Standard_Boolean StepToGeom_MakeBoundedCurve::Convert
if (SC->IsKind(STANDARD_TYPE(StepGeom_UniformCurveAndRationalBSplineCurve))) {
const Handle(StepGeom_UniformCurveAndRationalBSplineCurve) RUC =
Handle(StepGeom_UniformCurveAndRationalBSplineCurve)::DownCast(SC);
Standard_Integer aDegree = RUC->Degree();
if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
return Standard_False;
const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) RBSPL =
new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve;
// Compute Knots and KnotsMultiplicity
const Standard_Integer nbK = RUC->NbControlPointsList() + RUC->Degree() + 1;
const Standard_Integer nbK = RUC->NbControlPointsList() + aDegree + 1;
const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK);
const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK);
for (Standard_Integer iUC = 1 ; iUC <= nbK ; iUC ++) {
@@ -137,7 +150,7 @@ Standard_Boolean StepToGeom_MakeBoundedCurve::Convert
Knots->SetValue(iUC, iUC - 1.);
}
// Initialize the BSplineCurveWithKnotsAndRationalBSplineCurve
RBSPL->Init(RUC->Name(), RUC->Degree(), RUC->ControlPointsList(), RUC->CurveForm(),
RBSPL->Init(RUC->Name(), aDegree, RUC->ControlPointsList(), RUC->CurveForm(),
RUC->ClosedCurve(), RUC->SelfIntersect(), Kmult, Knots, StepGeom_ktUnspecified,
RUC->WeightsData());
return StepToGeom_MakeBSplineCurve::Convert(RBSPL,*((Handle(Geom_BSplineCurve)*)&CC));
@@ -145,20 +158,23 @@ Standard_Boolean StepToGeom_MakeBoundedCurve::Convert
if (SC->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformCurveAndRationalBSplineCurve))) {
const Handle(StepGeom_QuasiUniformCurveAndRationalBSplineCurve) RQUC =
Handle(StepGeom_QuasiUniformCurveAndRationalBSplineCurve)::DownCast(SC);
Standard_Integer aDegree = RQUC->Degree();
if (aDegree < 1 || aDegree > Geom_BSplineCurve::MaxDegree())
return Standard_False;
const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) RBSPL =
new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve;
// Compute Knots and KnotsMultiplicity
const Standard_Integer nbK = RQUC->NbControlPointsList() - RQUC->Degree() + 1;
const Standard_Integer nbK = RQUC->NbControlPointsList() - aDegree + 1;
const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK);
const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK);
for (Standard_Integer iRQUC = 1 ; iRQUC <= nbK ; iRQUC ++) {
Kmult->SetValue(iRQUC, 1);
Knots->SetValue(iRQUC, iRQUC - 1.);
}
Kmult->SetValue(1, RQUC->Degree() + 1);
Kmult->SetValue(nbK, RQUC->Degree() + 1);
Kmult->SetValue(1, aDegree + 1);
Kmult->SetValue(nbK, aDegree + 1);
// Initialize the BSplineCurveWithKnotsAndRationalBSplineCurve
RBSPL->Init(RQUC->Name(), RQUC->Degree(), RQUC->ControlPointsList(), RQUC->CurveForm(),
RBSPL->Init(RQUC->Name(), aDegree, RQUC->ControlPointsList(), RQUC->CurveForm(),
RQUC->ClosedCurve(), RQUC->SelfIntersect(), Kmult, Knots, StepGeom_ktUnspecified,
RQUC->WeightsData());
return StepToGeom_MakeBSplineCurve::Convert(RBSPL,*((Handle(Geom_BSplineCurve)*)&CC));