// Created on: 1993-07-02
// Created by: Martine LANGLOIS
// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
//:n6 abv 15.02.99: S4132: adding translation of polyline
//:p0 abv 19.02.99: management of 'done' flag improved; trimmed_curve treated
#include <StepGeom_Polyline.hxx>
#include <StepToGeom_MakePolyline.hxx>
#include <StepToGeom_MakeTrimmedCurve.hxx>
+#include <Geom_BSplineCurve.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve))) {
const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)
Bspli = Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)::DownCast(SC);
- return StepToGeom_MakeBSplineCurve::Convert(Bspli,*((Handle(Geom_BSplineCurve)*)&CC));
+ return StepToGeom_MakeBSplineCurve::Convert(Bspli,Handle(Geom_BSplineCurve)::DownCast (CC));
}
if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnots))) {
const Handle(StepGeom_BSplineCurveWithKnots)
Bspli = Handle(StepGeom_BSplineCurveWithKnots)::DownCast(SC);
- return StepToGeom_MakeBSplineCurve::Convert(Bspli,*((Handle(Geom_BSplineCurve)*)&CC));
+ return StepToGeom_MakeBSplineCurve::Convert(Bspli,Handle(Geom_BSplineCurve)::DownCast (CC));
}
if (SC->IsKind(STANDARD_TYPE(StepGeom_TrimmedCurve))) {
const Handle(StepGeom_TrimmedCurve) L = Handle(StepGeom_TrimmedCurve)::DownCast(SC);
- return StepToGeom_MakeTrimmedCurve::Convert(L,*((Handle(Geom_TrimmedCurve)*)&CC));
+ return StepToGeom_MakeTrimmedCurve::Convert(L,Handle(Geom_TrimmedCurve)::DownCast (CC));
}
// STEP BezierCurve, UniformCurve and QuasiUniformCurve are transformed into
// 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());
Knots->SetValue(2, 1.);
BSPL->SetKnotMultiplicities(Kmult);
BSPL->SetKnots(Knots);
- return StepToGeom_MakeBSplineCurve::Convert(BSPL,*((Handle(Geom_BSplineCurve)*)&CC));
+ return StepToGeom_MakeBSplineCurve::Convert(BSPL,Handle(Geom_BSplineCurve)::DownCast (CC));
}
if (SC->IsKind(STANDARD_TYPE(StepGeom_UniformCurve))) {
-//#ifdef DEBUG
-// cout << "Warning : converting UniformCurve onto BSplineCurveWithKnots" << endl;
-//#endif
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());
}
BSPL->SetKnotMultiplicities(Kmult);
BSPL->SetKnots(Knots);
- return StepToGeom_MakeBSplineCurve::Convert(BSPL,*((Handle(Geom_BSplineCurve)*)&CC));
+ return StepToGeom_MakeBSplineCurve::Convert(BSPL,Handle(Geom_BSplineCurve)::DownCast (CC));
}
if (SC->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformCurve))) {
-//#ifdef DEBUG
-// cout << "Warning : converting QuasiUniformCurve onto BSplineCurveWithKnots" << endl;
-//#endif
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());
Kmult->SetValue(nbK, BSPL->Degree() + 1);
BSPL->SetKnotMultiplicities(Kmult);
BSPL->SetKnots(Knots);
- return StepToGeom_MakeBSplineCurve::Convert(BSPL,*((Handle(Geom_BSplineCurve)*)&CC));
+ return StepToGeom_MakeBSplineCurve::Convert(BSPL,Handle(Geom_BSplineCurve)::DownCast (CC));
}
if (SC->IsKind(STANDARD_TYPE(StepGeom_UniformCurveAndRationalBSplineCurve))) {
-//#ifdef DEBUG
-// cout << "Warning : converting Rational UniformCurve onto BSplineCurveWithKnots" << endl;
-//#endif
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 ++) {
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));
+ return StepToGeom_MakeBSplineCurve::Convert(RBSPL,Handle(Geom_BSplineCurve)::DownCast (CC));
}
if (SC->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformCurveAndRationalBSplineCurve))) {
-//#ifdef DEBUG
-// cout << "Warning : converting Rational QuasiUniformCurve onto BSplineCurveWithKnots" << endl;
-//#endif
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));
+ return StepToGeom_MakeBSplineCurve::Convert(RBSPL,Handle(Geom_BSplineCurve)::DownCast (CC));
}
if (SC->IsKind(STANDARD_TYPE(StepGeom_Polyline))) { //:n6 abv 15 Feb 99
const Handle(StepGeom_Polyline) PL = Handle(StepGeom_Polyline)::DownCast (SC);
- return StepToGeom_MakePolyline::Convert(PL,*((Handle(Geom_BSplineCurve)*)&CC));
+ return StepToGeom_MakePolyline::Convert(PL,Handle(Geom_BSplineCurve)::DownCast (CC));
}
return Standard_False;
}