1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0030731: Modeling Data - B-Spline should have explicit data check error messages

Error messages have been added in throw statements.
This commit is contained in:
Benjamin Bihler
2019-05-23 15:49:50 +03:00
committed by msv
parent e3249d8e5a
commit 1b827f0484
4 changed files with 113 additions and 101 deletions

View File

@@ -63,20 +63,20 @@ static void CheckCurveData
const Standard_Boolean Periodic)
{
if (Degree < 1 || Degree > Geom2d_BSplineCurve::MaxDegree()) {
throw Standard_ConstructionError("BSpline curve : invalid degree");
throw Standard_ConstructionError("BSpline curve: invalid degree");
}
if (CPoles.Length() < 2) throw Standard_ConstructionError("BSpline curve : at least 2 poles required");
if (CKnots.Length() != CMults.Length()) throw Standard_ConstructionError("BSpline curve : Knot and Mult array size mismatch");
if (CPoles.Length() < 2) throw Standard_ConstructionError("BSpline curve: at least 2 poles required");
if (CKnots.Length() != CMults.Length()) throw Standard_ConstructionError("BSpline curve: Knot and Mult array size mismatch");
for (Standard_Integer I = CKnots.Lower(); I < CKnots.Upper(); I++) {
if (CKnots (I+1) - CKnots (I) <= Epsilon (Abs(CKnots (I)))) {
throw Standard_ConstructionError("BSpline curve : Knots interval values too close");
throw Standard_ConstructionError("BSpline curve: Knots interval values too close");
}
}
if (CPoles.Length() != BSplCLib::NbPoles(Degree,Periodic,CMults))
throw Standard_ConstructionError("BSpline curve : # Poles and degree mismatch");
throw Standard_ConstructionError("BSpline curve: # Poles and degree mismatch");
}
//=======================================================================
@@ -183,7 +183,7 @@ Geom2d_BSplineCurve::Geom2d_BSplineCurve
Periodic);
if (Weights.Length() != Poles.Length())
throw Standard_ConstructionError("Geom2d_BSplineCurve :Weights and Poles array size mismatch");
throw Standard_ConstructionError("Geom2d_BSplineCurve: Weights and Poles array size mismatch");
Standard_Integer i;
for (i = Weights.Lower(); i <= Weights.Upper(); i++) {
@@ -234,7 +234,7 @@ void Geom2d_BSplineCurve::IncreaseDegree
if (Degree == deg) return;
if (Degree < deg || Degree > Geom2d_BSplineCurve::MaxDegree()) {
throw Standard_ConstructionError("BSpline curve : IncreaseDegree : bad degree value");
throw Standard_ConstructionError("BSpline curve: IncreaseDegree: bad degree value");
}
Standard_Integer FromK1 = FirstUKnotIndex ();
@@ -407,7 +407,7 @@ Standard_Boolean Geom2d_BSplineCurve::RemoveKnot
Standard_Integer I2 = LastUKnotIndex ();
if (Index < I1 || Index > I2) {
throw Standard_OutOfRange("BSpline curve : RemoveKnot : index out of range");
throw Standard_OutOfRange("BSpline curve: RemoveKnot: index out of range");
}
const TColgp_Array1OfPnt2d & oldpoles = poles->Array1();
@@ -462,12 +462,12 @@ void Geom2d_BSplineCurve::InsertPoleAfter
const gp_Pnt2d& P,
const Standard_Real Weight)
{
if (Index < 0 || Index > poles->Length()) throw Standard_OutOfRange("BSpline curve : InsertPoleAfter: Index and #pole mismatch");
if (Index < 0 || Index > poles->Length()) throw Standard_OutOfRange("BSpline curve: InsertPoleAfter: Index and #pole mismatch");
if (Weight <= gp::Resolution()) throw Standard_ConstructionError("BSpline curve : InsertPoleAfter: Weight too small");
if (Weight <= gp::Resolution()) throw Standard_ConstructionError("BSpline curve: InsertPoleAfter: Weight too small");
if (knotSet == GeomAbs_NonUniform || knotSet == GeomAbs_PiecewiseBezier) {
throw Standard_ConstructionError("BSpline curve : InsertPoleAfter : bad knotSet type");
throw Standard_ConstructionError("BSpline curve: InsertPoleAfter: bad knotSet type");
}
const TColStd_Array1OfReal& cknots = knots->Array1();
@@ -564,12 +564,12 @@ void Geom2d_BSplineCurve::InsertPoleBefore
void Geom2d_BSplineCurve::RemovePole
(const Standard_Integer Index)
{
if (Index < 1 || Index > poles->Length()) throw Standard_OutOfRange("BSpline curve :RemovePole : Index and #pole mismatch");
if (Index < 1 || Index > poles->Length()) throw Standard_OutOfRange("BSpline curve: RemovePole: Index and #pole mismatch");
if (poles->Length() <= 2) throw Standard_ConstructionError("BSpline curve : RemovePole : #pole is already minimum");
if (poles->Length() <= 2) throw Standard_ConstructionError("BSpline curve: RemovePole: #pole is already minimum");
if (knotSet == GeomAbs_NonUniform || knotSet == GeomAbs_PiecewiseBezier)
throw Standard_ConstructionError("BSpline curve : RemovePole: bad knotSet type");
throw Standard_ConstructionError("BSpline curve: RemovePole: bad knotSet type");
Standard_Integer i;
Handle(TColStd_HArray1OfReal) nknots =
@@ -813,20 +813,20 @@ void Geom2d_BSplineCurve::SetKnot
(const Standard_Integer Index,
const Standard_Real K)
{
if (Index < 1 || Index > knots->Length()) throw Standard_OutOfRange("BSpline curve : SetKnot: Index and #pole mismatch");
if (Index < 1 || Index > knots->Length()) throw Standard_OutOfRange("BSpline curve: SetKnot: Index and #knots mismatch");
Standard_Real DK = Abs(Epsilon (K));
if (Index == 1) {
if (K >= knots->Value(2) - DK) throw Standard_ConstructionError("BSpline curve :SetKnot :K out of range");
if (K >= knots->Value(2) - DK) throw Standard_ConstructionError("BSpline curve: SetKnot: K out of range");
}
else if (Index == knots->Length()) {
if (K <= knots->Value (knots->Length()-1) + DK) {
throw Standard_ConstructionError("BSpline curve : SetKnot : K out of range");
throw Standard_ConstructionError("BSpline curve: SetKnot: K out of range");
}
}
else {
if (K <= knots->Value(Index-1) + DK ||
K >= knots->Value(Index+1) - DK ) {
throw Standard_ConstructionError("BSpline curve : SetKnot: K out of range");
throw Standard_ConstructionError("BSpline curve: SetKnot: K out of range");
}
}
if (K != knots->Value (Index)) {
@@ -1043,7 +1043,7 @@ void Geom2d_BSplineCurve::SetPole
(const Standard_Integer Index,
const gp_Pnt2d& P)
{
if (Index < 1 || Index > poles->Length()) throw Standard_OutOfRange("BSpline curve : SetPole : index and #pole mismatch");
if (Index < 1 || Index > poles->Length()) throw Standard_OutOfRange("BSpline curve: SetPole: index and #pole mismatch");
poles->SetValue (Index, P);
maxderivinvok = 0;
}
@@ -1071,9 +1071,9 @@ void Geom2d_BSplineCurve::SetWeight
(const Standard_Integer Index,
const Standard_Real W)
{
if (Index < 1 || Index > poles->Length()) throw Standard_OutOfRange("BSpline curve : SetWeight: Index and #pole mismatch");
if (Index < 1 || Index > poles->Length()) throw Standard_OutOfRange("BSpline curve: SetWeight: Index and #pole mismatch");
if (W <= gp::Resolution ()) throw Standard_ConstructionError("BSpline curve : SetWeight: Weight too small");
if (W <= gp::Resolution ()) throw Standard_ConstructionError("BSpline curve: SetWeight: Weight too small");
Standard_Boolean rat = IsRational() || (Abs(W - 1.) > gp::Resolution());
@@ -1111,7 +1111,7 @@ void Geom2d_BSplineCurve::MovePoint(const Standard_Real U,
{
if (Index1 < 1 || Index1 > poles->Length() ||
Index2 < 1 || Index2 > poles->Length() || Index1 > Index2) {
throw Standard_OutOfRange("BSpline curve : MovePoint: Index and #pole mismatch");
throw Standard_OutOfRange("BSpline curve: MovePoint: Index and #pole mismatch");
}
TColgp_Array1OfPnt2d npoles(1, poles->Length());
gp_Pnt2d P0;