From: abv Date: Tue, 8 Mar 2016 16:39:15 +0000 (+0300) Subject: 0027234: Code duplication: Convert_CompBezierCurvesToBSplineCurve* in ShapeConstruct X-Git-Tag: V7_0_winwerth~91 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=9a9a3edfd8bf3d5e5290b28a05cab7c6c5973ff6 0027234: Code duplication: Convert_CompBezierCurvesToBSplineCurve* in ShapeConstruct Classes from ShapeConstruct duplicating the ones from Convert package are removed. Protection against joining segments when degree is 1 is introduced in Convert classes. Optimization previously made in Convert_CompBezierCurvesToBSplineCurve class (within #25256) is applied to 2d equivalent. Data for automatic upgrade procedure are extended to replace removed classes by their duplicates from Convert. // cout disabled unless OCCT_DEBUG is defined --- diff --git a/adm/upgrade.dat b/adm/upgrade.dat index 96872023a3..394af2cca7 100644 --- a/adm/upgrade.dat +++ b/adm/upgrade.dat @@ -1,5 +1,7 @@ [rename] BRepExtrema_OverlappedSubShapes BRepExtrema_MapOfIntegerPackedMapOfInteger +ShapeConstruct_CompBezierCurves2dToBSplineCurve2d Convert_CompBezierCurves2dToBSplineCurve2d +ShapeConstruct_CompBezierCurves2dToBSplineCurve Convert_CompBezierCurves2dToBSplineCurve [tcollection] AdvApp2Var_SequenceOfNode diff --git a/src/Convert/Convert_CompBezierCurves2dToBSplineCurve2d.cxx b/src/Convert/Convert_CompBezierCurves2dToBSplineCurve2d.cxx index 74c270f2e4..e02aa0b5f5 100644 --- a/src/Convert/Convert_CompBezierCurves2dToBSplineCurve2d.cxx +++ b/src/Convert/Convert_CompBezierCurves2dToBSplineCurve2d.cxx @@ -162,7 +162,7 @@ void Convert_CompBezierCurves2dToBSplineCurve2d::Perform() myDegree = Max( myDegree, (mySequence(i))->Length() -1); } - Standard_Real D1, D2, Lambda, Det=0; + Standard_Real Det=0; gp_Pnt2d P1, P2, P3; Standard_Integer Deg, Inc, MaxDegree = myDegree; TColgp_Array1OfPnt2d Points(1, myDegree+1); @@ -196,31 +196,25 @@ void Convert_CompBezierCurves2dToBSplineCurve2d::Perform() P2 = Points(1); P3 = Points(2); gp_Vec2d V1(P1, P2), V2(P2, P3); - D1 = P1.SquareDistance(P2); - D2 = P3.SquareDistance(P2); - Lambda = Sqrt(D2/D1); - // Processing of the tangency between the Bezier and the previous. // This allows guaranteeing at least continuity C1 if the tangents are coherent. - - // Test of angle at myAngular - - if (V1.Magnitude() > gp::Resolution() && - V2.Magnitude() > gp::Resolution() && - V1.IsParallel(V2, myAngular )) { - KnotsMultiplicities.Append(MaxDegree-1); - CurveKnVals(i) = CurveKnVals(i-1) * Lambda; - Det += CurveKnVals(i); - + Standard_Real D1 = V1.SquareMagnitude(); + Standard_Real D2 = V2.SquareMagnitude(); + if (MaxDegree > 1 && //rln 20.06.99 work-around + D1 > gp::Resolution() && D2 > gp::Resolution() && V1.IsParallel(V2, myAngular )) + { + Standard_Real Lambda = Sqrt(D2/D1); + KnotsMultiplicities.Append(MaxDegree - 1); + CurveKnVals(i) = CurveKnVals(i - 1) * Lambda; } else { - CurveKnVals(i) = 1.0e0 ; - Det += CurveKnVals(i) ; - CurvePoles.Append(Points(1)); - KnotsMultiplicities.Append(MaxDegree); + CurvePoles.Append(Points(1)); + KnotsMultiplicities.Append(MaxDegree); + CurveKnVals(i) = 1.0; } + Det += CurveKnVals(i); // Store poles. for (Standard_Integer j = 2 ; j <= MaxDegree ; j++) { diff --git a/src/Convert/Convert_CompBezierCurvesToBSplineCurve.cxx b/src/Convert/Convert_CompBezierCurvesToBSplineCurve.cxx index 2e7ae3de7d..24b766ffb4 100644 --- a/src/Convert/Convert_CompBezierCurvesToBSplineCurve.cxx +++ b/src/Convert/Convert_CompBezierCurvesToBSplineCurve.cxx @@ -51,9 +51,10 @@ void Convert_CompBezierCurvesToBSplineCurve::AddCurve P1 = mySequence.Last()->Value(mySequence.Last()->Upper()); P2 = Poles(Poles.Lower()); - // NYI - if ( !P1.IsEqual(P2,Precision::Confusion())) - cout << "Convert_CompBezierCurvesToBSplineCurve::Addcurve" << endl;; +#ifdef OCCT_DEBUG + if (!P1.IsEqual(P2, Precision::Confusion())) + cout << "Convert_CompBezierCurvesToBSplineCurve::Addcurve" << endl; +#endif } myDone = Standard_False; Handle(TColgp_HArray1OfPnt) HPoles = @@ -199,26 +200,26 @@ void Convert_CompBezierCurvesToBSplineCurve::Perform() Standard_Real D1 = V1.SquareMagnitude(); Standard_Real D2 = V2.SquareMagnitude(); - if (D1 > gp::Resolution() && D2 > gp::Resolution() && V1.IsParallel(V2, myAngular )) { + if (MaxDegree > 1 && //rln 20.06.99 work-around + D1 > gp::Resolution() && D2 > gp::Resolution() && V1.IsParallel(V2, myAngular )) + { Standard_Real Lambda = Sqrt(D2/D1); if(CurveKnVals(i-1) * Lambda > 10. * Epsilon(Det)) { KnotsMultiplicities.Append(MaxDegree-1); CurveKnVals(i) = CurveKnVals(i-1) * Lambda; - Det += CurveKnVals(i); } else { CurvePoles.Append(Points(1)); KnotsMultiplicities.Append(MaxDegree); CurveKnVals(i) = 1.0 ; - Det += CurveKnVals(i) ; } } else { CurvePoles.Append(Points(1)); KnotsMultiplicities.Append(MaxDegree); CurveKnVals(i) = 1.0 ; - Det += CurveKnVals(i) ; } + Det += CurveKnVals(i); // Store the poles. for (Standard_Integer j = 2 ; j <= MaxDegree ; j++) { diff --git a/src/ShapeConstruct/FILES b/src/ShapeConstruct/FILES index f83ac5bc43..bd6aa79765 100644 --- a/src/ShapeConstruct/FILES +++ b/src/ShapeConstruct/FILES @@ -1,9 +1,5 @@ ShapeConstruct.cxx ShapeConstruct.hxx -ShapeConstruct_CompBezierCurves2dToBSplineCurve2d.cxx -ShapeConstruct_CompBezierCurves2dToBSplineCurve2d.hxx -ShapeConstruct_CompBezierCurvesToBSplineCurve.cxx -ShapeConstruct_CompBezierCurvesToBSplineCurve.hxx ShapeConstruct_Curve.cxx ShapeConstruct_Curve.hxx ShapeConstruct_MakeTriangulation.cxx diff --git a/src/ShapeConstruct/ShapeConstruct_CompBezierCurves2dToBSplineCurve2d.cxx b/src/ShapeConstruct/ShapeConstruct_CompBezierCurves2dToBSplineCurve2d.cxx deleted file mode 100644 index 642fc3ffb6..0000000000 --- a/src/ShapeConstruct/ShapeConstruct_CompBezierCurves2dToBSplineCurve2d.cxx +++ /dev/null @@ -1,254 +0,0 @@ -// Created on: 1993-10-20 -// Created by: Bruno DUMORTIER -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// 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. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// modified 25/06/1996 PMN : Ajout d'une tolerance Angulaire dans le -// constructeur pour le test de continuite G1 (1 Radians c'etait trop -// cf BUG PRO4481) -//rln 20.06.99 work-around - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -//function : ShapeConstruct_CompBezierCurves2dToBSplineCurve2d -//purpose : -//======================================================================= -ShapeConstruct_CompBezierCurves2dToBSplineCurve2d:: -ShapeConstruct_CompBezierCurves2dToBSplineCurve2d( - const Standard_Real AngularTolerance) : - myAngular(AngularTolerance), - myDone(Standard_False) -{ -} - - -//======================================================================= -//function : AddCurve -//purpose : -//======================================================================= - -void ShapeConstruct_CompBezierCurves2dToBSplineCurve2d::AddCurve - (const TColgp_Array1OfPnt2d& Poles) -{ - if ( !mySequence.IsEmpty()) { - gp_Pnt2d P1,P2; - P1 = mySequence.Last()->Value(mySequence.Last()->Upper()); - P2 = Poles(Poles.Lower()); - -// User defined tolerance NYI -// Standard_ConstructionError_Raise_if -// ( !P1.IsEqual(P2,Precision::Confusion()), -// "ShapeConstruct_CompBezierCurves2dToBSplineCurve2d::Addcurve"); - - } - myDone = Standard_False; - Handle(TColgp_HArray1OfPnt2d) HPoles = - new TColgp_HArray1OfPnt2d(Poles.Lower(),Poles.Upper()); - HPoles->ChangeArray1() = Poles; - mySequence.Append(HPoles); -} - - -//======================================================================= -//function : Degree -//purpose : -//======================================================================= - -Standard_Integer ShapeConstruct_CompBezierCurves2dToBSplineCurve2d::Degree() -const { - return myDegree; -} - - -//======================================================================= -//function : NbPoles -//purpose : -//======================================================================= - -Standard_Integer ShapeConstruct_CompBezierCurves2dToBSplineCurve2d::NbPoles() -const { - return CurvePoles.Length(); -} - - -//======================================================================= -//function : Poles -//purpose : -//======================================================================= - -void ShapeConstruct_CompBezierCurves2dToBSplineCurve2d::Poles - (TColgp_Array1OfPnt2d& Poles) const -{ - Standard_Integer i, Lower = Poles.Lower(), Upper = Poles.Upper(); - Standard_Integer k = 1; - for (i = Lower; i <= Upper; i++) { - Poles(i) = CurvePoles(k++); - } -} - - -//======================================================================= -//function : NbKnots -//purpose : -//======================================================================= - -Standard_Integer ShapeConstruct_CompBezierCurves2dToBSplineCurve2d::NbKnots() -const { - return CurveKnots.Length(); -} - - -//======================================================================= -//function : KnotsAndMults -//purpose : -//======================================================================= - -void ShapeConstruct_CompBezierCurves2dToBSplineCurve2d::KnotsAndMults - (TColStd_Array1OfReal& Knots, - TColStd_Array1OfInteger& Mults ) const -{ - Standard_Integer i, LowerK = Knots.Lower(), UpperK = Knots.Upper(); - Standard_Integer LowerM = Mults.Lower(), UpperM = Mults.Upper(); - Standard_Integer k = 1; - for (i = LowerK; i <= UpperK; i++) { - Knots(i) = CurveKnots(k++); - } - k = 1; - for (i = LowerM; i <= UpperM; i++) { - Mults(i) = KnotsMultiplicities(k++); - } -} - - - - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -void ShapeConstruct_CompBezierCurves2dToBSplineCurve2d::Perform() -{ - myDone = Standard_True; - CurvePoles.Clear(); - CurveKnots.Clear(); - KnotsMultiplicities.Clear(); - Standard_Integer LowerI = 1; - Standard_Integer UpperI = mySequence.Length(); - Standard_Integer NbrCurv = UpperI-LowerI+1; - TColStd_Array1OfReal CurveKnVals (1,NbrCurv); - - Standard_Integer i; - myDegree = 0; - for ( i = 1; i <= mySequence.Length(); i++) { - myDegree = Max( myDegree, (mySequence(i))->Length() -1); - } - - Standard_Real D1, D2, Lambda, Det=0.; - gp_Pnt2d P1, P2, P3; - Standard_Integer Deg, Inc, MaxDegree = myDegree; - TColgp_Array1OfPnt2d Points(1, myDegree+1); - - for (i = LowerI ; i <= UpperI ; i++) { - // 1- Elever la courbe de Bezier au degre maximum. - Deg = mySequence(i)->Length()-1; - Inc = myDegree - Deg; - if ( Inc > 0) { - BSplCLib::IncreaseDegree(myDegree, - mySequence(i)->Array1(), BSplCLib::NoWeights(), - Points, BSplCLib::NoWeights()); - } - else { - Points = mySequence(i)->Array1(); - } - - // 2- Traiter le noeud de jonction entre 2 courbes de Bezier. - if (i == LowerI) { - // Traitement du noeud initial de la BSpline. - for (Standard_Integer j = 1 ; j <= MaxDegree ; j++) { - CurvePoles.Append(Points(j)); - } - CurveKnVals(1) = 1.; // Pour amorcer la serie. - KnotsMultiplicities.Append(MaxDegree+1); - Det = 1.; - } - - - if (i != LowerI) { - P2 = Points(1); - P3 = Points(2); - gp_Vec2d V1(P1, P2), V2(P2, P3); - D1 = P1.SquareDistance(P2); - D2 = P3.SquareDistance(P2); - Lambda = Sqrt(D2/D1); - - - // Traitement de la tangence entre la Bezier et sa precedente. - // Ceci permet d''assurer au moins une continuite C1 si - // les tangentes sont coherentes. - - - // Test de l'angle a myAngular - - if (V1.Magnitude() > gp::Resolution() && - V2.Magnitude() > gp::Resolution() && - V1.IsParallel(V2, myAngular) && - MaxDegree > 1) {//rln 20.06.99 work-around - KnotsMultiplicities.Append(MaxDegree-1); - CurveKnVals(i) = CurveKnVals(i-1) * Lambda; - Det += CurveKnVals(i); - - } - else { - CurveKnVals(i) = 1.0e0 ; - Det += CurveKnVals(i) ; - CurvePoles.Append(Points(1)); - KnotsMultiplicities.Append(MaxDegree); - } - - // Stocker les poles. - for (Standard_Integer j = 2 ; j <= MaxDegree ; j++) { - CurvePoles.Append(Points(j)); - } - - } - - - if (i == UpperI) { - // Traitement du noeud terminal de la BSpline. - CurvePoles.Append(Points(MaxDegree+1)); - KnotsMultiplicities.Append(MaxDegree+1); - } - P1 = Points(MaxDegree); - } - - // Corriger les valeurs nodales pour les faire varier dans [0.,1.]. - CurveKnots.Append(0.0); - for (i = 2 ; i <= NbrCurv ; i++) { - CurveKnots.Append(CurveKnots(i-1) + (CurveKnVals(i-1)/Det)); - } - CurveKnots.Append(1.0); -} - - diff --git a/src/ShapeConstruct/ShapeConstruct_CompBezierCurves2dToBSplineCurve2d.hxx b/src/ShapeConstruct/ShapeConstruct_CompBezierCurves2dToBSplineCurve2d.hxx deleted file mode 100644 index 3128d40093..0000000000 --- a/src/ShapeConstruct/ShapeConstruct_CompBezierCurves2dToBSplineCurve2d.hxx +++ /dev/null @@ -1,95 +0,0 @@ -// Created on: 1993-11-09 -// Created by: Modelistation -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// 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. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _ShapeConstruct_CompBezierCurves2dToBSplineCurve2d_HeaderFile -#define _ShapeConstruct_CompBezierCurves2dToBSplineCurve2d_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -class Standard_ConstructionError; - - -//! Converts a list of connecting Bezier Curves 2d to a -//! BSplineCurve 2d. -//! if possible, the continuity of the BSpline will be -//! increased to more than C0. -class ShapeConstruct_CompBezierCurves2dToBSplineCurve2d -{ -public: - - DEFINE_STANDARD_ALLOC - - - Standard_EXPORT ShapeConstruct_CompBezierCurves2dToBSplineCurve2d(const Standard_Real AngularTolerance = 1.0e-4); - - Standard_EXPORT void AddCurve (const TColgp_Array1OfPnt2d& Poles); - - //! Computes the algorithm. - Standard_EXPORT void Perform(); - - Standard_EXPORT Standard_Integer Degree() const; - - Standard_EXPORT Standard_Integer NbPoles() const; - - Standard_EXPORT void Poles (TColgp_Array1OfPnt2d& Poles) const; - - Standard_EXPORT Standard_Integer NbKnots() const; - - Standard_EXPORT void KnotsAndMults (TColStd_Array1OfReal& Knots, TColStd_Array1OfInteger& Mults) const; - - - - -protected: - - - - - -private: - - - - Convert_SequenceOfArray1OfPoles2d mySequence; - TColgp_SequenceOfPnt2d CurvePoles; - TColStd_SequenceOfReal CurveKnots; - TColStd_SequenceOfInteger KnotsMultiplicities; - Standard_Integer myDegree; - Standard_Real myAngular; - Standard_Boolean myDone; - - -}; - - - - - - - -#endif // _ShapeConstruct_CompBezierCurves2dToBSplineCurve2d_HeaderFile diff --git a/src/ShapeConstruct/ShapeConstruct_CompBezierCurvesToBSplineCurve.cxx b/src/ShapeConstruct/ShapeConstruct_CompBezierCurvesToBSplineCurve.cxx deleted file mode 100644 index c7d68530e4..0000000000 --- a/src/ShapeConstruct/ShapeConstruct_CompBezierCurvesToBSplineCurve.cxx +++ /dev/null @@ -1,250 +0,0 @@ -// Created on: 1993-10-20 -// Created by: Bruno DUMORTIER -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// 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. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// modified 25/06/1996 PMN : Ajout d'une tolerance Angulaire dans le -// constructeur pour le test de continuite G1 (1 Radians c'etait trop -// cf BUG PRO4481) -//rln 20.06.99 work-around - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -//function : ShapeConstruct_CompBezierCurvesToBSplineCurve -//purpose : -//======================================================================= -ShapeConstruct_CompBezierCurvesToBSplineCurve:: -ShapeConstruct_CompBezierCurvesToBSplineCurve( - const Standard_Real AngularTolerance) : - myAngular(AngularTolerance), - myDone(Standard_False) - -{ -} - - -//======================================================================= -//function : AddCurve -//purpose : -//======================================================================= - -void ShapeConstruct_CompBezierCurvesToBSplineCurve::AddCurve - (const TColgp_Array1OfPnt& Poles) -{ - if ( !mySequence.IsEmpty()) { - gp_Pnt P1,P2; - P1 = mySequence.Last()->Value(mySequence.Last()->Upper()); - P2 = Poles(Poles.Lower()); - - // NYI -// Standard_ConstructionError_Raise_if -// ( !P1.IsEqual(P2,Precision::Confusion()), -// "ShapeConstruct_CompBezierCurvesToBSplineCurve::Addcurve"); - } - myDone = Standard_False; - Handle(TColgp_HArray1OfPnt) HPoles = - new TColgp_HArray1OfPnt(Poles.Lower(),Poles.Upper()); - HPoles->ChangeArray1() = Poles; - mySequence.Append(HPoles); -} - - -//======================================================================= -//function : Degree -//purpose : -//======================================================================= - -Standard_Integer ShapeConstruct_CompBezierCurvesToBSplineCurve::Degree() const -{ - return myDegree; -} - - -//======================================================================= -//function : NbPoles -//purpose : -//======================================================================= - -Standard_Integer ShapeConstruct_CompBezierCurvesToBSplineCurve::NbPoles() const -{ - return CurvePoles.Length(); -} - - -//======================================================================= -//function : Poles -//purpose : -//======================================================================= - -void ShapeConstruct_CompBezierCurvesToBSplineCurve::Poles - (TColgp_Array1OfPnt& Poles) const -{ - Standard_Integer i, Lower = Poles.Lower(), Upper = Poles.Upper(); - Standard_Integer k = 1; - for (i = Lower; i <= Upper; i++) { - Poles(i) = CurvePoles(k++); - } -} - - -//======================================================================= -//function : NbKnots -//purpose : -//======================================================================= - -Standard_Integer ShapeConstruct_CompBezierCurvesToBSplineCurve::NbKnots() const -{ - return CurveKnots.Length(); -} - - -//======================================================================= -//function : KnotsAndMults -//purpose : -//======================================================================= - -void ShapeConstruct_CompBezierCurvesToBSplineCurve::KnotsAndMults - (TColStd_Array1OfReal& Knots, - TColStd_Array1OfInteger& Mults ) const -{ - Standard_Integer i, LowerK = Knots.Lower(), UpperK = Knots.Upper(); - Standard_Integer LowerM = Mults.Lower(), UpperM = Mults.Upper(); - Standard_Integer k = 1; - for (i = LowerK; i <= UpperK; i++) { - Knots(i) = CurveKnots(k++); - } - k = 1; - for (i = LowerM; i <= UpperM; i++) { - Mults(i) = KnotsMultiplicities(k++); - } -} - - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -void ShapeConstruct_CompBezierCurvesToBSplineCurve::Perform() -{ - myDone = Standard_True; - CurvePoles.Clear(); - CurveKnots.Clear(); - KnotsMultiplicities.Clear(); - Standard_Integer LowerI = 1; - Standard_Integer UpperI = mySequence.Length(); - Standard_Integer NbrCurv = UpperI-LowerI+1; - - TColStd_Array1OfReal CurveKnVals (1,NbrCurv); - - Standard_Integer i; - myDegree = 0; - for ( i = 1; i <= mySequence.Length(); i++) { - myDegree = Max( myDegree, (mySequence(i))->Length() -1); - } - - Standard_Real D1, D2, Lambda, Det=0.; - gp_Pnt P1, P2, P3; - Standard_Integer Deg, Inc, MaxDegree = myDegree; - TColgp_Array1OfPnt Points(1, myDegree+1); - - for (i = LowerI ; i <= UpperI ; i++) { - // 1- Elever la courbe de Bezier au degre maximum. - Deg = mySequence(i)->Length()-1; - Inc = myDegree - Deg; - if ( Inc > 0) { - BSplCLib::IncreaseDegree(myDegree, - mySequence(i)->Array1(), BSplCLib::NoWeights(), - Points, BSplCLib::NoWeights()); - } - else { - Points = mySequence(i)->Array1(); - } - - // 2- Traiter le noeud de jonction entre 2 courbes de Bezier. - if (i == LowerI) { - // Traitement du noeud initial de la BSpline. - for (Standard_Integer j = 1 ; j <= MaxDegree ; j++) { - CurvePoles.Append(Points(j)); - } - CurveKnVals(1) = 1.; // Pour amorcer la serie. - KnotsMultiplicities.Append(MaxDegree+1); - Det = 1.; - } - - - if (i != LowerI) { - P2 = Points(1); - P3 = Points(2); - gp_Vec V1(P1, P2), V2(P2, P3); - D1 = P1.SquareDistance(P2); - D2 = P3.SquareDistance(P2); - Lambda = Sqrt(D2/D1); - - - // Traitement de la tangence entre la Bezier et sa precedente. - // Ceci permet d''assurer au moins une continuite C1 si - // les tangentes sont coherentes. - - if (V1.Magnitude() > gp::Resolution() && - V2.Magnitude() > gp::Resolution() && - V1.IsParallel(V2, myAngular ) && - MaxDegree > 1) {//rln 20.06.99 work-around - KnotsMultiplicities.Append(MaxDegree-1); - CurveKnVals(i) = CurveKnVals(i-1) * Lambda; - Det += CurveKnVals(i); - - } - else { - CurvePoles.Append(Points(1)); - KnotsMultiplicities.Append(MaxDegree); - CurveKnVals(i) = 1.0e0 ; - Det += CurveKnVals(i) ; - } - - // Stocker les poles. - for (Standard_Integer j = 2 ; j <= MaxDegree ; j++) { - CurvePoles.Append(Points(j)); - } - - } - - - if (i == UpperI) { - // Traitement du noeud terminal de la BSpline. - CurvePoles.Append(Points(MaxDegree+1)); - KnotsMultiplicities.Append(MaxDegree+1); - } - P1 = Points(MaxDegree); - } - - // Corriger les valeurs nodales pour les faire varier dans [0.,1.]. - CurveKnots.Append(0.0); - for (i = 2 ; i <= NbrCurv ; i++) { - CurveKnots.Append(CurveKnots(i-1) + (CurveKnVals(i-1)/Det)); - } - CurveKnots.Append(1.0); -} - - diff --git a/src/ShapeConstruct/ShapeConstruct_CompBezierCurvesToBSplineCurve.hxx b/src/ShapeConstruct/ShapeConstruct_CompBezierCurvesToBSplineCurve.hxx deleted file mode 100644 index 366c945f21..0000000000 --- a/src/ShapeConstruct/ShapeConstruct_CompBezierCurvesToBSplineCurve.hxx +++ /dev/null @@ -1,95 +0,0 @@ -// Created on: 1993-10-20 -// Created by: Bruno DUMORTIER -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// 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. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _ShapeConstruct_CompBezierCurvesToBSplineCurve_HeaderFile -#define _ShapeConstruct_CompBezierCurvesToBSplineCurve_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -class Standard_ConstructionError; - - -//! Converts a list of connecting Bezier Curves to a -//! BSplineCurve. -//! if possible, the continuity of the BSpline will be -//! increased to more than C0. -class ShapeConstruct_CompBezierCurvesToBSplineCurve -{ -public: - - DEFINE_STANDARD_ALLOC - - - Standard_EXPORT ShapeConstruct_CompBezierCurvesToBSplineCurve(const Standard_Real AngularTolerance = 1.0e-4); - - Standard_EXPORT void AddCurve (const TColgp_Array1OfPnt& Poles); - - //! Computes the algorithm. - Standard_EXPORT void Perform(); - - Standard_EXPORT Standard_Integer Degree() const; - - Standard_EXPORT Standard_Integer NbPoles() const; - - Standard_EXPORT void Poles (TColgp_Array1OfPnt& Poles) const; - - Standard_EXPORT Standard_Integer NbKnots() const; - - Standard_EXPORT void KnotsAndMults (TColStd_Array1OfReal& Knots, TColStd_Array1OfInteger& Mults) const; - - - - -protected: - - - - - -private: - - - - Convert_SequenceOfArray1OfPoles mySequence; - TColgp_SequenceOfPnt CurvePoles; - TColStd_SequenceOfReal CurveKnots; - TColStd_SequenceOfInteger KnotsMultiplicities; - Standard_Integer myDegree; - Standard_Real myAngular; - Standard_Boolean myDone; - - -}; - - - - - - - -#endif // _ShapeConstruct_CompBezierCurvesToBSplineCurve_HeaderFile