mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
270
src/Geom2dConvert/Geom2dConvert.cdl
Executable file
270
src/Geom2dConvert/Geom2dConvert.cdl
Executable file
@@ -0,0 +1,270 @@
|
||||
-- File: Geom2dConvert.cdl
|
||||
-- Created: Thu Oct 3 14:34:29 1991
|
||||
-- Author: Jean Claude VAUTHIER
|
||||
---Copyright: Matra Datavision 1991, 1992
|
||||
|
||||
package Geom2dConvert
|
||||
|
||||
--- Purpose :
|
||||
-- This package provides an implementation of algorithmes to do
|
||||
-- the conversion between equivalent geometric entities from
|
||||
-- package Geom2d.
|
||||
-- It gives the possibility :
|
||||
-- . to obtain the B-spline representation of bounded curves.
|
||||
-- . to split a B-spline curve into several B-spline curves
|
||||
-- with some constraints of continuity,
|
||||
-- . to convert a B-spline curve into several Bezier curves
|
||||
-- or surfaces.
|
||||
-- All the geometric entities used in this package are bounded.
|
||||
-- References :
|
||||
-- . Generating the Bezier Points of B-spline curves and surfaces
|
||||
-- (Wolfgang Bohm) CAGD volume 13 number 6 november 1981
|
||||
-- . On NURBS: A Survey (Leslie Piegl) IEEE Computer Graphics and
|
||||
-- Application January 1991
|
||||
-- . Curve and surface construction using rational B-splines
|
||||
-- (Leslie Piegl and Wayne Tiller) CAD Volume 19 number 9 november
|
||||
-- 1987
|
||||
-- . A survey of curve and surface methods in CAGD (Wolfgang BOHM)
|
||||
-- CAGD 1 1984
|
||||
|
||||
uses Standard, TColStd, TColGeom2d,gp, Geom2d, Convert,GeomAbs
|
||||
|
||||
is
|
||||
|
||||
|
||||
class BSplineCurveKnotSplitting;
|
||||
--- Purpose :
|
||||
-- This algorithm searches the knot values corresponding to the
|
||||
-- splitting of a given B-spline curve into several arcs with
|
||||
-- the same continuity. The continuity order is given at the
|
||||
-- construction time. It is possible to compute the curve arcs
|
||||
-- corresponding to this splitting with the method of package
|
||||
-- SplitBSplineCurve.
|
||||
|
||||
|
||||
|
||||
class BSplineCurveToBezierCurve;
|
||||
--- Purpose :
|
||||
-- This algorithm converts a B-spline curve from the package Geom
|
||||
-- into several Bezier curves.
|
||||
|
||||
class CompCurveToBSplineCurve;
|
||||
--- Purpose :
|
||||
-- This algorithm converts and concat sevral curve in a
|
||||
-- B-spline curve.
|
||||
class ApproxCurve;
|
||||
---Purpose : -- Convert a curve to BSpline by Approximation
|
||||
--
|
||||
|
||||
SplitBSplineCurve (C : BSplineCurve from Geom2d;
|
||||
FromK1, ToK2 : Integer;
|
||||
SameOrientation : Boolean = Standard_True)
|
||||
returns mutable BSplineCurve from Geom2d
|
||||
--- Purpose :
|
||||
-- This method computes the arc of B-spline curve between the two
|
||||
-- knots FromK1 and ToK2. If C is periodic the arc has the same
|
||||
-- orientation as C if SameOrientation = Standard_True.
|
||||
-- If C is not periodic SameOrientation is not used for the
|
||||
-- computation and C is oriented from the knot fromK1 to the
|
||||
-- knot toK2.
|
||||
-- We just keep the local definition of C between the knots
|
||||
-- FromK1 and ToK2. The returned B-spline curve has its first
|
||||
-- and last knots with a multiplicity equal to degree + 1, where
|
||||
-- degree is the polynomial degree of C.
|
||||
-- The indexes of the knots FromK1 and ToK2 doesn't include the
|
||||
-- repetition of multiple knots in their definition.
|
||||
raises OutOfRange from Standard,
|
||||
--- Purpose :
|
||||
-- Raised if FromK1 or ToK2 are out of the bounds
|
||||
-- [FirstUKnotIndex, LastUKnotIndex]
|
||||
DomainError from Standard;
|
||||
--- Purpose : Raised if FromK1 = ToK2
|
||||
|
||||
|
||||
|
||||
SplitBSplineCurve (C : BSplineCurve from Geom2d;
|
||||
FromU1, ToU2 : Real;
|
||||
ParametricTolerance : Real;
|
||||
SameOrientation : Boolean = Standard_True)
|
||||
returns mutable BSplineCurve from Geom2d
|
||||
--- Purpose :
|
||||
-- This function computes the segment of B-spline curve between the
|
||||
-- parametric values FromU1, ToU2.
|
||||
-- If C is periodic the arc has the same orientation as C if
|
||||
-- SameOrientation = True.
|
||||
-- If C is not periodic SameOrientation is not used for the
|
||||
-- computation and C is oriented fromU1 toU2.
|
||||
-- If U1 and U2 and two parametric values we consider that
|
||||
-- U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and
|
||||
-- ParametricTolerance must be greater or equal to Resolution
|
||||
-- from package gp.
|
||||
raises DomainError from Standard;
|
||||
--- Purpose :
|
||||
-- Raised if FromU1 or ToU2 are out of the parametric bounds of the
|
||||
-- curve (The tolerance criterion is ParametricTolerance).
|
||||
-- Raised if Abs (FromU1 - ToU2) <= ParametricTolerance
|
||||
-- Raised if ParametricTolerance < Resolution from gp.
|
||||
|
||||
|
||||
|
||||
CurveToBSplineCurve (C : Curve from Geom2d ;
|
||||
Parameterisation : ParameterisationType from Convert
|
||||
= Convert_TgtThetaOver2)
|
||||
returns mutable BSplineCurve from Geom2d
|
||||
--- Purpose : This function converts a non infinite curve from
|
||||
-- Geom into a B-spline curve. C must be an ellipse or a
|
||||
-- circle or a trimmed conic or a trimmed line or a Bezier
|
||||
-- curve or a trimmed Bezier curve or a BSpline curve or a
|
||||
-- trimmed BSpline curve or an Offset curve or a trimmed
|
||||
-- Offset curve.
|
||||
-- The returned B-spline is not periodic except if C is a
|
||||
-- Circle or an Ellipse.
|
||||
-- ParameterisationType applies only if the curve is a Circle
|
||||
-- or an ellipse :
|
||||
-- TgtThetaOver2,
|
||||
-- TgtThetaOver2_1,
|
||||
-- TgtThetaOver2_2,
|
||||
-- TgtThetaOver2_3,
|
||||
-- TgtThetaOver2_4,
|
||||
-- Purpose: this is the classical rational parameterisation
|
||||
-- 2
|
||||
-- 1 - t
|
||||
-- cos(theta) = ------
|
||||
-- 2
|
||||
-- 1 + t
|
||||
--
|
||||
-- 2t
|
||||
-- sin(theta) = ------
|
||||
-- 2
|
||||
-- 1 + t
|
||||
--
|
||||
-- t = tan (theta/2)
|
||||
--
|
||||
-- with TgtThetaOver2 the routine will compute the number of spans
|
||||
-- using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1
|
||||
-- with TgtThetaOver2_N, N spans will be forced: an error will
|
||||
-- be raized if (ULast - UFirst) >= PI and N = 1,
|
||||
-- ULast - UFirst >= 2 PI and N = 2
|
||||
--
|
||||
-- QuasiAngular,
|
||||
-- here t is a rational function that approximates
|
||||
-- theta ----> tan(theta/2).
|
||||
-- Neverthless the composing with above function yields exact
|
||||
-- functions whose square sum up to 1
|
||||
-- RationalC1 ;
|
||||
-- t is replaced by a polynomial function of u so as to grant
|
||||
-- C1 contiuity across knots.
|
||||
-- Exceptions
|
||||
-- Standard_DomainError if the curve C is infinite.
|
||||
-- Standard_ConstructionError:
|
||||
-- - if C is a complete circle or ellipse, and if
|
||||
-- Parameterisation is not equal to
|
||||
-- Convert_TgtThetaOver2 or to Convert_RationalC1, or
|
||||
-- - if C is a trimmed circle or ellipse and if
|
||||
-- Parameterisation is equal to
|
||||
-- Convert_TgtThetaOver2_1 and if U2 - U1 >
|
||||
-- 0.9999 * Pi where U1 and U2 are
|
||||
-- respectively the first and the last parameters of the
|
||||
-- trimmed curve (this method of parameterization
|
||||
-- cannot be used to convert a half-circle or a
|
||||
-- half-ellipse, for example), or
|
||||
-- - if C is a trimmed circle or ellipse and
|
||||
-- Parameterisation is equal to
|
||||
-- Convert_TgtThetaOver2_2 and U2 - U1 >
|
||||
-- 1.9999 * Pi where U1 and U2 are
|
||||
-- respectively the first and the last parameters of the
|
||||
-- trimmed curve (this method of parameterization
|
||||
-- cannot be used to convert a quasi-complete circle or ellipse).
|
||||
raises DomainError;
|
||||
|
||||
|
||||
|
||||
ConcatG1(ArrayOfCurves : in out Array1OfBSplineCurve from TColGeom2d;
|
||||
ArrayOfToler : in Array1OfReal from TColStd;
|
||||
ArrayOfConcatenated : out HArray1OfBSplineCurve from TColGeom2d;
|
||||
ClosedFlag : in Boolean from Standard ;
|
||||
ClosedTolerance : in Real from Standard);
|
||||
--- Purpose : This Method concatenates G1 the ArrayOfCurves as far
|
||||
-- as it is possible.
|
||||
-- ArrayOfCurves[0..N-1]
|
||||
-- ArrayOfToler contains the biggest tolerance of the two
|
||||
-- points shared by two consecutives curves.
|
||||
-- Its dimension: [0..N-2]
|
||||
-- ClosedTolerance indicates if the ArrayOfCurves is closed.
|
||||
-- In this case ClosedTolerance contains the biggest tolerance
|
||||
-- of the two points which are at the closure.
|
||||
-- Otherwise its value is 0.0
|
||||
|
||||
|
||||
ConcatC1(ArrayOfCurves : in out Array1OfBSplineCurve from TColGeom2d;
|
||||
ArrayOfToler : in Array1OfReal from TColStd;
|
||||
ArrayOfIndices : out HArray1OfInteger from TColStd;
|
||||
ArrayOfConcatenated : out HArray1OfBSplineCurve from TColGeom2d;
|
||||
ClosedFlag : in Boolean from Standard ;
|
||||
ClosedTolerance : in Real from Standard);
|
||||
--- Purpose : This Method concatenates C1 the ArrayOfCurves as far
|
||||
-- as it is possible.
|
||||
-- ArrayOfCurves[0..N-1]
|
||||
-- ArrayOfToler contains the biggest tolerance of the two
|
||||
-- points shared by two consecutives curves.
|
||||
-- Its dimension: [0..N-2]
|
||||
-- ClosedTolerance indicates if the ArrayOfCurves is closed.
|
||||
-- In this case ClosedTolerance contains the biggest tolerance
|
||||
-- of the two points which are at the closure.
|
||||
-- Otherwise its value is 0.0
|
||||
--
|
||||
ConcatC1(ArrayOfCurves : in out Array1OfBSplineCurve from TColGeom2d;
|
||||
ArrayOfToler : in Array1OfReal from TColStd;
|
||||
ArrayOfIndices : out HArray1OfInteger from TColStd;
|
||||
ArrayOfConcatenated : out HArray1OfBSplineCurve from TColGeom2d;
|
||||
ClosedFlag : in Boolean from Standard ;
|
||||
ClosedTolerance : in Real from Standard;
|
||||
AngularTolerance : in Real from Standard) ;
|
||||
--- Purpose : This Method concatenates C1 the ArrayOfCurves as far
|
||||
-- as it is possible.
|
||||
-- ArrayOfCurves[0..N-1]
|
||||
-- ArrayOfToler contains the biggest tolerance of the two
|
||||
-- points shared by two consecutives curves.
|
||||
-- Its dimension: [0..N-2]
|
||||
-- ClosedTolerance indicates if the ArrayOfCurves is closed.
|
||||
-- In this case ClosedTolerance contains the biggest tolerance
|
||||
-- of the two points which are at the closure.
|
||||
-- Otherwise its value is 0.0
|
||||
|
||||
C0BSplineToC1BSplineCurve(BS : in out BSplineCurve from Geom2d;
|
||||
Tolerance : in Real from Standard);
|
||||
--- Purpose : This Method reduces as far as it is possible the
|
||||
-- multiplicities of the knots of the BSpline BS.(keeping the geometry).
|
||||
-- It returns a new BSpline which could still be C0.
|
||||
-- tolerance is a geometrical tolerance
|
||||
|
||||
|
||||
C0BSplineToArrayOfC1BSplineCurve(BS : in BSplineCurve from Geom2d;
|
||||
tabBS : out HArray1OfBSplineCurve from TColGeom2d;
|
||||
Tolerance :in Real from Standard);
|
||||
--- Purpose :This Method reduces as far as it is possible the
|
||||
-- multiplicities of the knots of the BSpline BS.(keeping the geometry).
|
||||
-- It returns an array of BSpline C1.
|
||||
-- Tolerance is a geometrical tolerance
|
||||
|
||||
C0BSplineToArrayOfC1BSplineCurve( BS : in BSplineCurve from Geom2d;
|
||||
tabBS : out HArray1OfBSplineCurve from TColGeom2d;
|
||||
AngularTolerance : in Real from Standard;
|
||||
Tolerance : in Real from Standard) ;
|
||||
--- Purpose :This Method reduces as far as it is possible the
|
||||
-- multiplicities of the knots of the BSpline BS.(keeping the geometry).
|
||||
-- It returns an array of BSpline C1.
|
||||
-- tolerance is a geometrical tolerance
|
||||
|
||||
|
||||
|
||||
end Geom2dConvert;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1596
src/Geom2dConvert/Geom2dConvert.cxx
Executable file
1596
src/Geom2dConvert/Geom2dConvert.cxx
Executable file
File diff suppressed because it is too large
Load Diff
63
src/Geom2dConvert/Geom2dConvert_ApproxCurve.cdl
Executable file
63
src/Geom2dConvert/Geom2dConvert_ApproxCurve.cdl
Executable file
@@ -0,0 +1,63 @@
|
||||
-- File: GeomConvert_ApproxCurve.cdl
|
||||
-- Created: Thu Sep 11 15:08:38 1997
|
||||
-- Author: Roman BORISOV
|
||||
-- <rbv@toctox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
class ApproxCurve from Geom2dConvert
|
||||
---Purpose: A framework to convert a 2D curve to a BSpline.
|
||||
-- This is done by approximation within a given tolerance.
|
||||
|
||||
uses
|
||||
Curve from Geom2d,
|
||||
BSplineCurve from Geom2d,
|
||||
Shape from GeomAbs,
|
||||
OutOfRange from Standard
|
||||
|
||||
raises OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
Create (Curve: Curve from Geom2d;
|
||||
Tol2d: Real;
|
||||
Order: Shape from GeomAbs;
|
||||
MaxSegments: Integer;
|
||||
MaxDegree: Integer) returns ApproxCurve from Geom2dConvert;
|
||||
---Purpose: Constructs an approximation framework defined by
|
||||
-- - the 2D conic Curve
|
||||
-- - the tolerance value Tol2d
|
||||
-- - the degree of continuity Order
|
||||
-- - the maximum number of segments allowed MaxSegments
|
||||
-- - the highest degree MaxDegree which the
|
||||
-- polynomial defining the BSpline is allowed to have.
|
||||
|
||||
Curve(me) returns BSplineCurve from Geom2d;
|
||||
---Purpose: Returns the 2D BSpline curve resulting from the
|
||||
-- approximation algorithm.
|
||||
|
||||
IsDone(me) returns Boolean from Standard;
|
||||
---Purpose: returns Standard_True if the approximation has
|
||||
-- been done with within requiered tolerance
|
||||
|
||||
HasResult(me) returns Boolean;
|
||||
---Purpose: returns Standard_True if the approximation did come out
|
||||
-- with a result that is not NECESSARELY within the required tolerance
|
||||
|
||||
MaxError(me) returns Real from Standard;
|
||||
---Purpose: Returns the greatest distance between a point on the
|
||||
-- source conic and the BSpline curve resulting from the
|
||||
-- approximation. (>0 when an approximation
|
||||
-- has been done, 0 if no approximation)
|
||||
|
||||
Dump(me; o: in out OStream);
|
||||
---Purpose: Print on the stream o information about the object
|
||||
|
||||
fields
|
||||
myCurve : Curve from Geom2d;
|
||||
myIsDone : Boolean from Standard;
|
||||
myHasResult : Boolean from Standard;
|
||||
myBSplCurve : BSplineCurve from Geom2d;
|
||||
myMaxError : Real from Standard;
|
||||
|
||||
end ApproxCurve;
|
162
src/Geom2dConvert/Geom2dConvert_ApproxCurve.cxx
Executable file
162
src/Geom2dConvert/Geom2dConvert_ApproxCurve.cxx
Executable file
@@ -0,0 +1,162 @@
|
||||
// File: GeomConvert_ApproxCurve.cxx
|
||||
// Created: Thu Sep 11 15:50:30 1997
|
||||
// Author: Roman BORISOV
|
||||
// <rbv@toctox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <Geom2dConvert_ApproxCurve.ixx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <Geom2dAdaptor_HCurve.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <AdvApprox_PrefAndRec.hxx>
|
||||
#include <AdvApprox_ApproxAFunction.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//class : Geom2dConvert_ApproxCurve_Eval
|
||||
//purpose: evaluator class for approximation
|
||||
//=======================================================================
|
||||
|
||||
class Geom2dConvert_ApproxCurve_Eval : public AdvApprox_EvaluatorFunction
|
||||
{
|
||||
public:
|
||||
Geom2dConvert_ApproxCurve_Eval (const Handle(Adaptor2d_HCurve2d)& theFunc,
|
||||
Standard_Real First, Standard_Real Last)
|
||||
: fonct(theFunc) { StartEndSav[0] = First; StartEndSav[1] = Last; }
|
||||
|
||||
virtual void Evaluate (Standard_Integer *Dimension,
|
||||
Standard_Real StartEnd[2],
|
||||
Standard_Real *Parameter,
|
||||
Standard_Integer *DerivativeRequest,
|
||||
Standard_Real *Result, // [Dimension]
|
||||
Standard_Integer *ErrorCode);
|
||||
|
||||
private:
|
||||
Handle(Adaptor2d_HCurve2d) fonct;
|
||||
Standard_Real StartEndSav[2];
|
||||
};
|
||||
|
||||
void Geom2dConvert_ApproxCurve_Eval::Evaluate (Standard_Integer *Dimension,
|
||||
Standard_Real StartEnd[2],
|
||||
Standard_Real *Param, // Parameter at which evaluation
|
||||
Standard_Integer *Order, // Derivative Request
|
||||
Standard_Real *Result,// [Dimension]
|
||||
Standard_Integer *ErrorCode)
|
||||
{
|
||||
*ErrorCode = 0;
|
||||
Standard_Real par = *Param;
|
||||
|
||||
// Dimension is incorrect
|
||||
if (*Dimension!=2) {
|
||||
*ErrorCode = 1;
|
||||
}
|
||||
// Parameter is incorrect
|
||||
if ( par < StartEnd[0] || par > StartEnd[1] ) {
|
||||
*ErrorCode = 2;
|
||||
}
|
||||
if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
|
||||
{
|
||||
fonct = fonct->Trim(StartEnd[0],StartEnd[1],Precision::PConfusion());
|
||||
StartEndSav[0]=StartEnd[0];
|
||||
StartEndSav[1]=StartEnd[1];
|
||||
}
|
||||
|
||||
gp_Pnt2d pnt;
|
||||
gp_Vec2d v1, v2;
|
||||
|
||||
switch (*Order) {
|
||||
case 0:
|
||||
pnt = fonct->Value(par);
|
||||
Result[0] = pnt.X();
|
||||
Result[1] = pnt.Y();
|
||||
break;
|
||||
case 1:
|
||||
fonct->D1(par, pnt, v1);
|
||||
Result[0] = v1.X();
|
||||
Result[1] = v1.Y();
|
||||
break;
|
||||
case 2:
|
||||
fonct->D2(par, pnt, v1, v2);
|
||||
Result[0] = v2.X();
|
||||
Result[1] = v2.Y();
|
||||
break;
|
||||
default:
|
||||
Result[0] = Result[1] = 0.;
|
||||
*ErrorCode = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Geom2dConvert_ApproxCurve::Geom2dConvert_ApproxCurve(const Handle(Geom2d_Curve)& Curve,const Standard_Real Tol2d,const GeomAbs_Shape Order,const Standard_Integer MaxSegments,const Standard_Integer MaxDegree)
|
||||
{
|
||||
Handle(Geom2dAdaptor_HCurve) HCurve = new Geom2dAdaptor_HCurve (Curve);
|
||||
|
||||
// Initialisation of input parameters of AdvApprox
|
||||
|
||||
Standard_Integer Num1DSS=0, Num2DSS=1, Num3DSS=0;
|
||||
Handle(TColStd_HArray1OfReal) OneDTolNul, ThreeDTolNul;
|
||||
Handle(TColStd_HArray1OfReal) TwoDTol = new TColStd_HArray1OfReal(1,Num2DSS);
|
||||
TwoDTol->Init(Tol2d);
|
||||
|
||||
Standard_Real First = Curve->FirstParameter();
|
||||
Standard_Real Last = Curve->LastParameter();
|
||||
|
||||
Standard_Integer NbInterv_C2 = HCurve->NbIntervals(GeomAbs_C2);
|
||||
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2+1);
|
||||
HCurve->Intervals(CutPnts_C2,GeomAbs_C2);
|
||||
Standard_Integer NbInterv_C3 = HCurve->NbIntervals(GeomAbs_C3);
|
||||
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3+1);
|
||||
HCurve->Intervals(CutPnts_C3,GeomAbs_C3);
|
||||
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
|
||||
|
||||
myMaxError = 0;
|
||||
|
||||
Geom2dConvert_ApproxCurve_Eval ev (HCurve, First, Last);
|
||||
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
|
||||
OneDTolNul, TwoDTol, ThreeDTolNul,
|
||||
First, Last, Order,
|
||||
MaxDegree, MaxSegments,
|
||||
ev, CutTool);
|
||||
|
||||
myIsDone = aApprox.IsDone();
|
||||
myHasResult = aApprox.HasResult();
|
||||
|
||||
if (myHasResult) {
|
||||
TColgp_Array1OfPnt2d Poles(1,aApprox.NbPoles());
|
||||
aApprox.Poles2d(1,Poles);
|
||||
Handle(TColStd_HArray1OfReal) Knots = aApprox.Knots();
|
||||
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
|
||||
Standard_Integer Degree = aApprox.Degree();
|
||||
myBSplCurve = new Geom2d_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
|
||||
myMaxError = aApprox.MaxError(2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Handle(Geom2d_BSplineCurve) Geom2dConvert_ApproxCurve::Curve() const
|
||||
{
|
||||
return myBSplCurve;
|
||||
}
|
||||
|
||||
Standard_Boolean Geom2dConvert_ApproxCurve::IsDone() const
|
||||
{
|
||||
return myIsDone;
|
||||
}
|
||||
|
||||
Standard_Boolean Geom2dConvert_ApproxCurve::HasResult() const
|
||||
{
|
||||
return myHasResult;
|
||||
}
|
||||
|
||||
Standard_Real Geom2dConvert_ApproxCurve::MaxError() const
|
||||
{
|
||||
return myMaxError;
|
||||
}
|
||||
|
||||
void Geom2dConvert_ApproxCurve::Dump(Standard_OStream& o) const
|
||||
{
|
||||
o << "******* Dump of ApproxCurve *******" << endl;
|
||||
o << "******* Error " << MaxError() << endl;
|
||||
}
|
||||
|
112
src/Geom2dConvert/Geom2dConvert_BSplineCurveKnotSplitting.cdl
Executable file
112
src/Geom2dConvert/Geom2dConvert_BSplineCurveKnotSplitting.cdl
Executable file
@@ -0,0 +1,112 @@
|
||||
-- File: BSplineCurveKnotSplitting.cdl
|
||||
-- Created: Thu Oct 3 15:54:16 1991
|
||||
---Copyright: Matra Datavision 1991, 1992
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class BSplineCurveKnotSplitting from Geom2dConvert
|
||||
|
||||
|
||||
|
||||
--- Purpose : An algorithm to determine points at which a BSpline
|
||||
-- curve should be split in order to obtain arcs of the same continuity.
|
||||
-- If you require curves with a minimum continuity for
|
||||
-- your computation, it is useful to know the points
|
||||
-- between which an arc has a continuity of a given
|
||||
-- order. For a BSpline curve, the discontinuities are
|
||||
-- localized at the knot values. Between two knot values
|
||||
-- the BSpline is infinitely and continuously
|
||||
-- differentiable. At a given knot, the continuity is equal
|
||||
-- to: Degree - Mult, where Degree is the
|
||||
-- degree of the BSpline curve and Mult is the multiplicity of the knot.
|
||||
-- It is possible to compute the arcs which correspond to
|
||||
-- this splitting using the global function
|
||||
-- SplitBSplineCurve provided by the package Geom2dConvert.
|
||||
-- A BSplineCurveKnotSplitting object provides a framework for:
|
||||
-- - defining the curve to be analysed and the required degree of continuity,
|
||||
-- - implementing the computation algorithm, and
|
||||
-- - consulting the results.
|
||||
|
||||
uses Array1OfInteger from TColStd,
|
||||
HArray1OfInteger from TColStd,
|
||||
BSplineCurve from Geom2d
|
||||
|
||||
raises DimensionError from Standard,
|
||||
RangeError from Standard
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create (BasisCurve : BSplineCurve from Geom2d; ContinuityRange : Integer)
|
||||
returns BSplineCurveKnotSplitting
|
||||
--- Purpose : Determines points at which the BSpline curve
|
||||
-- BasisCurve should be split in order to obtain arcs
|
||||
-- with a degree of continuity equal to ContinuityRange.
|
||||
-- These points are knot values of BasisCurve. They
|
||||
-- are identified by indices in the knots table of BasisCurve.
|
||||
-- Use the available interrogation functions to access
|
||||
-- computed values, followed by the global function
|
||||
-- SplitBSplineCurve (provided by the package
|
||||
-- Geom2dConvert) to split the curve.
|
||||
-- Exceptions
|
||||
-- Standard_RangeError if ContinuityRange is less than zero.
|
||||
raises RangeError;
|
||||
|
||||
|
||||
NbSplits (me) returns Integer is static;
|
||||
--- Purpose :Returns the number of points at which the analysed
|
||||
-- BSpline curve should be split, in order to obtain arcs
|
||||
-- with the continuity required by this framework.
|
||||
-- All these points correspond to knot values. Note that
|
||||
-- the first and last points of the curve, which bound the
|
||||
-- first and last arcs, are counted among these splitting points.
|
||||
|
||||
|
||||
Splitting (me; SplitValues : in out Array1OfInteger)
|
||||
--- Purpose : Loads the SplitValues table with the split knots
|
||||
-- values computed in this framework. Each value in the
|
||||
-- table is an index in the knots table of the BSpline
|
||||
-- curve analysed by this algorithm.
|
||||
-- The values in SplitValues are given in ascending
|
||||
-- order and comprise the indices of the knots which
|
||||
-- give the first and last points of the curve. Use two
|
||||
-- consecutive values from the table as arguments of the
|
||||
-- global function SplitBSplineCurve (provided by the
|
||||
-- package Geom2dConvert) to split the curve.
|
||||
-- Exceptions
|
||||
-- Standard_DimensionError if the array SplitValues
|
||||
-- was not created with the following bounds:
|
||||
-- - 1, and
|
||||
-- - the number of split points computed in this
|
||||
-- framework (as given by the function NbSplits).
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
|
||||
SplitValue (me; Index : Integer) returns Integer
|
||||
--- Purpose :Returns the split knot of index Index to the split knots
|
||||
-- table computed in this framework. The returned value
|
||||
-- is an index in the knots table of the BSpline curve
|
||||
-- analysed by this algorithm.
|
||||
-- Notes:
|
||||
-- - If Index is equal to 1, the corresponding knot
|
||||
-- gives the first point of the curve.
|
||||
-- - If Index is equal to the number of split knots
|
||||
-- computed in this framework, the corresponding
|
||||
-- point is the last point of the curve.
|
||||
-- Exceptions
|
||||
-- Standard_RangeError if Index is less than 1 or
|
||||
-- greater than the number of split knots computed in this framework.
|
||||
raises RangeError
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
splitIndexes : HArray1OfInteger;
|
||||
|
||||
end BSplineCurveKnotSplitting;
|
||||
|
102
src/Geom2dConvert/Geom2dConvert_BSplineCurveKnotSplitting.cxx
Executable file
102
src/Geom2dConvert/Geom2dConvert_BSplineCurveKnotSplitting.cxx
Executable file
@@ -0,0 +1,102 @@
|
||||
//File Geom2dConvert_BSplineCurveKnotSplitting.cxx
|
||||
//Jean-Claude Vauthier 27 November 1991
|
||||
//Passage sur C1 Aout 1992
|
||||
|
||||
#include <Geom2dConvert_BSplineCurveKnotSplitting.ixx>
|
||||
#include <Standard_RangeError.hxx>
|
||||
|
||||
#include <BSplCLib.hxx>
|
||||
|
||||
typedef Handle(Geom2d_BSplineCurve) Handle(BSplineCurve);
|
||||
typedef TColStd_Array1OfInteger Array1OfInteger;
|
||||
typedef TColStd_HArray1OfInteger HArray1OfInteger;
|
||||
|
||||
|
||||
|
||||
|
||||
Geom2dConvert_BSplineCurveKnotSplitting::
|
||||
Geom2dConvert_BSplineCurveKnotSplitting (
|
||||
|
||||
const Handle(BSplineCurve)& BasisCurve,
|
||||
const Standard_Integer ContinuityRange
|
||||
|
||||
) {
|
||||
|
||||
|
||||
if (ContinuityRange < 0) Standard_RangeError::Raise();
|
||||
|
||||
Standard_Integer FirstIndex = BasisCurve->FirstUKnotIndex();
|
||||
Standard_Integer LastIndex = BasisCurve->LastUKnotIndex();
|
||||
|
||||
Standard_Integer Degree = BasisCurve->Degree();
|
||||
|
||||
if (ContinuityRange == 0) {
|
||||
splitIndexes = new HArray1OfInteger (1, 2);
|
||||
splitIndexes->SetValue (1, FirstIndex);
|
||||
splitIndexes->SetValue (2, LastIndex);
|
||||
}
|
||||
else {
|
||||
Standard_Integer NbKnots = BasisCurve->NbKnots();
|
||||
Array1OfInteger Mults (1, NbKnots);
|
||||
BasisCurve->Multiplicities (Mults);
|
||||
Standard_Integer Mmax = BSplCLib::MaxKnotMult (Mults, FirstIndex, LastIndex);
|
||||
if (Degree - Mmax >= ContinuityRange) {
|
||||
splitIndexes = new HArray1OfInteger (1, 2);
|
||||
splitIndexes->SetValue (1, FirstIndex);
|
||||
splitIndexes->SetValue (2, LastIndex);
|
||||
}
|
||||
else {
|
||||
Array1OfInteger Split (1, LastIndex - FirstIndex + 1);
|
||||
Standard_Integer NbSplit = 1;
|
||||
Standard_Integer Index = FirstIndex;
|
||||
Split (NbSplit) = Index;
|
||||
Index++;
|
||||
NbSplit++;
|
||||
while (Index < LastIndex) {
|
||||
if (Degree - Mults (Index) < ContinuityRange) {
|
||||
Split (NbSplit) = Index;
|
||||
NbSplit++;
|
||||
}
|
||||
Index++;
|
||||
}
|
||||
Split (NbSplit) = Index;
|
||||
splitIndexes = new HArray1OfInteger (1, NbSplit);
|
||||
for (Standard_Integer i = 1; i <= NbSplit; i++) {
|
||||
splitIndexes->SetValue (i, Split (i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Standard_Integer Geom2dConvert_BSplineCurveKnotSplitting::NbSplits () const {
|
||||
|
||||
return splitIndexes->Length();
|
||||
}
|
||||
|
||||
|
||||
Standard_Integer Geom2dConvert_BSplineCurveKnotSplitting::SplitValue (
|
||||
|
||||
const Standard_Integer Index
|
||||
|
||||
) const {
|
||||
|
||||
Standard_RangeError_Raise_if (
|
||||
Index < 1 || Index > splitIndexes->Length(), " ");
|
||||
return splitIndexes->Value (Index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Geom2dConvert_BSplineCurveKnotSplitting::Splitting (
|
||||
|
||||
Array1OfInteger& SplitValues
|
||||
|
||||
) const {
|
||||
|
||||
for (Standard_Integer i = 1; i <= splitIndexes->Length(); i++){
|
||||
SplitValues (i) = splitIndexes->Value (i);
|
||||
}
|
||||
}
|
119
src/Geom2dConvert/Geom2dConvert_BSplineCurveToBezierCurve.cdl
Executable file
119
src/Geom2dConvert/Geom2dConvert_BSplineCurveToBezierCurve.cdl
Executable file
@@ -0,0 +1,119 @@
|
||||
-- File: Geom2d_BSplineCurve.cdl
|
||||
-- Created: Wed Mar 24 17:35:29 1993
|
||||
-- Author: DUB
|
||||
-- <DUB@fuegox>
|
||||
-- Copyright: Matra Datavision 1993
|
||||
|
||||
class BSplineCurveToBezierCurve from Geom2dConvert
|
||||
|
||||
--- Purpose :An algorithm to convert a BSpline curve into a series
|
||||
-- of adjacent Bezier curves.
|
||||
-- A BSplineCurveToBezierCurve object provides a framework for:
|
||||
-- - defining the BSpline curve to be converted
|
||||
-- - implementing the construction algorithm, and
|
||||
-- - consulting the results.
|
||||
-- References :
|
||||
-- Generating the Bezier points of B-spline curves and surfaces
|
||||
-- (Wolfgang Bohm) CAD volume 13 number 6 november 1981
|
||||
|
||||
|
||||
uses
|
||||
Array1OfReal from TColStd,
|
||||
Array1OfBezierCurve from TColGeom2d,
|
||||
BezierCurve from Geom2d,
|
||||
BSplineCurve from Geom2d
|
||||
|
||||
|
||||
raises
|
||||
DimensionError from Standard,
|
||||
DomainError from Standard,
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create (BasisCurve : BSplineCurve) returns BSplineCurveToBezierCurve;
|
||||
--- Purpose : Computes all the data needed to convert
|
||||
-- - the BSpline curve BasisCurve, into a series of adjacent Bezier arcs.
|
||||
-- The result consists of a series of BasisCurve arcs
|
||||
-- limited by points corresponding to knot values of the curve.
|
||||
-- Use the available interrogation functions to ascertain
|
||||
-- the number of computed Bezier arcs, and then to
|
||||
-- construct each individual Bezier curve (or all Bezier curves).
|
||||
-- Note: ParametricTolerance is not used.
|
||||
|
||||
Create (BasisCurve : BSplineCurve;
|
||||
U1, U2 : Real;
|
||||
ParametricTolerance : Real)
|
||||
returns BSplineCurveToBezierCurve
|
||||
--- Purpose : Computes all the data needed to convert
|
||||
-- the portion of the BSpline curve BasisCurve
|
||||
-- limited by the two parameter values U1 and U2
|
||||
-- for Example if there is a Knot Uk and
|
||||
-- Uk < U < Uk + ParametricTolerance/2 the last curve
|
||||
-- corresponds to the span [Uk-1, Uk] and not to [Uk, Uk+1]
|
||||
-- The result consists of a series of BasisCurve arcs
|
||||
-- limited by points corresponding to knot values of the curve.
|
||||
-- Use the available interrogation functions to ascertain
|
||||
-- the number of computed Bezier arcs, and then to
|
||||
-- construct each individual Bezier curve (or all Bezier curves).
|
||||
-- Note: ParametricTolerance is not used.
|
||||
-- Raises DomainError if U1 or U2 are out of the parametric bounds of the basis
|
||||
-- curve [FirstParameter, LastParameter]. The Tolerance criterion
|
||||
-- is ParametricTolerance.
|
||||
-- Raised if Abs (U2 - U1) <= ParametricTolerance.
|
||||
raises DomainError;
|
||||
|
||||
|
||||
Arc (me : in out; Index : Integer) returns mutable BezierCurve
|
||||
--- Purpose :Constructs and returns the Bezier curve of index
|
||||
-- Index to the table of adjacent Bezier arcs
|
||||
-- computed by this algorithm.
|
||||
-- This Bezier curve has the same orientation as the
|
||||
-- BSpline curve analyzed in this framework.
|
||||
-- Exceptions
|
||||
-- Standard_OutOfRange if Index is less than 1 or
|
||||
-- greater than the number of adjacent Bezier arcs
|
||||
-- computed by this algorithm.
|
||||
raises OutOfRange
|
||||
is static;
|
||||
|
||||
|
||||
Arcs (me : in out; Curves : in out Array1OfBezierCurve)
|
||||
--- Purpose :Constructs all the Bezier curves whose data is
|
||||
-- computed by this algorithm and loads these curves
|
||||
-- into the Curves table.
|
||||
-- The Bezier curves have the same orientation as the
|
||||
-- BSpline curve analyzed in this framework.
|
||||
-- Exceptions
|
||||
-- Standard_DimensionError if the Curves array was
|
||||
-- not created with the following bounds:
|
||||
-- - 1 , and
|
||||
-- - the number of adjacent Bezier arcs computed by
|
||||
-- this algorithm (as given by the function NbArcs).
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
Knots(me; TKnots : out Array1OfReal from TColStd)
|
||||
---Purpose: This methode returns the bspline's knots associated to
|
||||
-- the converted arcs
|
||||
-- Raises DimensionError if the length of Curves is not equal to
|
||||
-- NbArcs + 1
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
NbArcs (me) returns Integer is static;
|
||||
--- Purpose :
|
||||
-- Returns the number of BezierCurve arcs.
|
||||
-- If at the creation time you have decomposed the basis curve
|
||||
-- between the parametric values UFirst, ULast the number of
|
||||
-- BezierCurve arcs depends on the number of knots included inside
|
||||
-- the interval [UFirst, ULast].
|
||||
-- If you have decomposed the whole basis B-spline curve the number
|
||||
-- of BezierCurve arcs NbArcs is equal to the number of knots less
|
||||
-- one.
|
||||
|
||||
fields
|
||||
|
||||
myCurve : BSplineCurve from Geom2d;
|
||||
end BSplineCurveToBezierCurve;
|
143
src/Geom2dConvert/Geom2dConvert_BSplineCurveToBezierCurve.cxx
Executable file
143
src/Geom2dConvert/Geom2dConvert_BSplineCurveToBezierCurve.cxx
Executable file
@@ -0,0 +1,143 @@
|
||||
// File: Geom2dConvert_BSplineCurveToBezierCurve.cxx
|
||||
// Created: Tue Mar 12 15:51:42 1996
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@fuegox>
|
||||
|
||||
|
||||
#include <Geom2dConvert_BSplineCurveToBezierCurve.ixx>
|
||||
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Geom2dConvert_BSplineCurveToBezierCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Geom2dConvert_BSplineCurveToBezierCurve::Geom2dConvert_BSplineCurveToBezierCurve (const Handle(Geom2d_BSplineCurve)& BasisCurve)
|
||||
{
|
||||
myCurve = Handle(Geom2d_BSplineCurve)::DownCast(BasisCurve->Copy());
|
||||
// periodic curve can't be converted correctly by two main reasons:
|
||||
// last pole (equal to first one) is missing;
|
||||
// poles recomputation using default boor scheme is fails.
|
||||
if(myCurve->IsPeriodic()) myCurve->SetNotPeriodic();
|
||||
Standard_Real Uf = myCurve->FirstParameter();
|
||||
Standard_Real Ul = myCurve->LastParameter();
|
||||
myCurve->Segment(Uf,Ul);
|
||||
myCurve->IncreaseMultiplicity(myCurve->FirstUKnotIndex(),
|
||||
myCurve->LastUKnotIndex(),
|
||||
myCurve->Degree());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Geom2dConvert_BSplineCurveToBezierCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Geom2dConvert_BSplineCurveToBezierCurve::Geom2dConvert_BSplineCurveToBezierCurve
|
||||
(const Handle(Geom2d_BSplineCurve)& BasisCurve,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Real ParametricTolerance)
|
||||
{
|
||||
if (U2 - U1 < ParametricTolerance)
|
||||
Standard_DomainError::Raise("GeomConvert_BSplineCurveToBezierSurface");
|
||||
|
||||
Standard_Real Uf = U1, Ul = U2;
|
||||
Standard_Real PTol = ParametricTolerance/2 ;
|
||||
|
||||
Standard_Integer I1, I2;
|
||||
myCurve = Handle(Geom2d_BSplineCurve)::DownCast(BasisCurve->Copy());
|
||||
if(myCurve->IsPeriodic()) myCurve->SetNotPeriodic();
|
||||
|
||||
myCurve->LocateU(U1, PTol, I1, I2);
|
||||
if (I1==I2) { // On est sur le noeud
|
||||
if ( myCurve->Knot(I1) > U1) Uf = myCurve->Knot(I1);
|
||||
}
|
||||
|
||||
myCurve->LocateU(U2, PTol, I1, I2);
|
||||
if (I1==I2) { // On est sur le noeud
|
||||
if ( myCurve->Knot(I1) < U2) Ul = myCurve->Knot(I1);
|
||||
}
|
||||
|
||||
|
||||
myCurve->Segment(Uf, Ul);
|
||||
myCurve->IncreaseMultiplicity(myCurve->FirstUKnotIndex(),
|
||||
myCurve->LastUKnotIndex(),
|
||||
myCurve->Degree());
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Arc
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom2d_BezierCurve) Geom2dConvert_BSplineCurveToBezierCurve::Arc
|
||||
(const Standard_Integer Index)
|
||||
{
|
||||
if ( Index < 1 || Index > myCurve->NbKnots()-1) {
|
||||
Standard_OutOfRange::Raise("Geom2dConvert_BSplineCurveToBezierCurve");
|
||||
}
|
||||
Standard_Integer Deg = myCurve->Degree();
|
||||
|
||||
TColgp_Array1OfPnt2d Poles(1,Deg+1);
|
||||
|
||||
Handle(Geom2d_BezierCurve) C;
|
||||
if ( myCurve->IsRational()) {
|
||||
TColStd_Array1OfReal Weights(1,Deg+1);
|
||||
for ( Standard_Integer i = 1; i <= Deg+1; i++) {
|
||||
Poles(i) = myCurve->Pole(i+Deg*(Index-1));
|
||||
Weights(i) = myCurve->Weight(i+Deg*(Index-1));
|
||||
}
|
||||
C = new Geom2d_BezierCurve(Poles,Weights);
|
||||
}
|
||||
else {
|
||||
for ( Standard_Integer i = 1; i <= Deg+1; i++) {
|
||||
Poles(i) = myCurve->Pole(i+Deg*(Index-1));
|
||||
}
|
||||
C = new Geom2d_BezierCurve(Poles);
|
||||
}
|
||||
return C;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Arcs
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Geom2dConvert_BSplineCurveToBezierCurve::Arcs
|
||||
(TColGeom2d_Array1OfBezierCurve& Curves)
|
||||
{
|
||||
Standard_Integer n = NbArcs();
|
||||
for ( Standard_Integer i = 1; i <= n; i++) {
|
||||
Curves(i) = Arc(i);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Knots
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Geom2dConvert_BSplineCurveToBezierCurve::Knots
|
||||
(TColStd_Array1OfReal& TKnots) const
|
||||
{
|
||||
Standard_Integer ii, kk;
|
||||
for (ii = 1, kk = TKnots.Lower();
|
||||
ii <=myCurve->NbKnots(); ii++, kk++)
|
||||
TKnots(kk) = myCurve->Knot(ii);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbArcs
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer Geom2dConvert_BSplineCurveToBezierCurve::NbArcs() const
|
||||
{
|
||||
return (myCurve->NbKnots()-1);
|
||||
}
|
54
src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cdl
Executable file
54
src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cdl
Executable file
@@ -0,0 +1,54 @@
|
||||
-- File: Geom2dConvert_CompCurveToBSplineCurve.cdl
|
||||
-- Created: Tue Apr 29 11:35:23 1997
|
||||
-- Author: Stagiaire Francois DUMONT
|
||||
-- <dum@brunox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
class CompCurveToBSplineCurve from Geom2dConvert
|
||||
|
||||
---Purpose: Concat sevral curve in an BSplineCurve
|
||||
|
||||
uses
|
||||
ParameterisationType from Convert,
|
||||
BoundedCurve from Geom2d,
|
||||
BSplineCurve from Geom2d
|
||||
|
||||
--raises
|
||||
|
||||
is
|
||||
|
||||
Create (BasisCurve : BoundedCurve from Geom2d;
|
||||
Parameterisation : ParameterisationType from Convert
|
||||
= Convert_TgtThetaOver2)
|
||||
---Purpose: Initialize the algorithme with one curve
|
||||
-- - Parameterisation is used to convert
|
||||
returns CompCurveToBSplineCurve;
|
||||
|
||||
Add (me : in out;
|
||||
NewCurve : BoundedCurve from Geom2d;
|
||||
Tolerance: Real from Standard;
|
||||
After : Boolean from Standard = Standard_False)
|
||||
---Purpose: Append a curve in the BSpline
|
||||
-- Return False if the curve is not G0 with the BSplineCurve.
|
||||
-- Tolerance is used to check continuity and decrease
|
||||
-- Multiplicty at the common Knot
|
||||
-- After is usefull if BasisCurve is a closed curve .
|
||||
returns Boolean;
|
||||
|
||||
|
||||
Add (me : in out;
|
||||
FirstCurve : in out BSplineCurve from Geom2d;
|
||||
SecondCurve: in out BSplineCurve from Geom2d;
|
||||
After : Boolean from Standard)
|
||||
---Purpose: Concat two BSplineCurves.
|
||||
is private;
|
||||
|
||||
BSplineCurve(me) returns BSplineCurve from Geom2d;
|
||||
|
||||
fields
|
||||
myCurve : BSplineCurve from Geom2d;
|
||||
myTol : Real;
|
||||
myType : ParameterisationType from Convert;
|
||||
|
||||
end CompCurveToBSplineCurve;
|
194
src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx
Executable file
194
src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx
Executable file
@@ -0,0 +1,194 @@
|
||||
// File: Geom2dConvert_CompCurveToBSplineCurve.cxx
|
||||
// Created: Tue Apr 29 11:19:42 1997
|
||||
// Author: Stagiaire Francois DUMONT
|
||||
// <dum@brunox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <Geom2dConvert_CompCurveToBSplineCurve.ixx>
|
||||
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <Geom2dConvert.hxx>
|
||||
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
|
||||
Geom2dConvert_CompCurveToBSplineCurve::
|
||||
Geom2dConvert_CompCurveToBSplineCurve(const Handle(Geom2d_BoundedCurve)& BasisCurve,
|
||||
const Convert_ParameterisationType Parameterisation) :
|
||||
myTol(Precision::Confusion()),
|
||||
myType(Parameterisation)
|
||||
{
|
||||
Handle(Geom2d_BSplineCurve) Bs =
|
||||
Handle(Geom2d_BSplineCurve)::DownCast(BasisCurve);
|
||||
if (!Bs.IsNull()) {
|
||||
myCurve = Handle(Geom2d_BSplineCurve)::DownCast(BasisCurve->Copy());
|
||||
}
|
||||
else {
|
||||
myCurve = Geom2dConvert::CurveToBSplineCurve (BasisCurve, myType);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Geom2dConvert_CompCurveToBSplineCurve::
|
||||
Add(const Handle(Geom2d_BoundedCurve)& NewCurve,
|
||||
const Standard_Real Tolerance,
|
||||
const Standard_Boolean After)
|
||||
{
|
||||
myTol = Tolerance;
|
||||
// Convertion
|
||||
Handle(Geom2d_BSplineCurve) Bs =
|
||||
Handle(Geom2d_BSplineCurve)::DownCast(NewCurve);
|
||||
if (!Bs.IsNull() ) {
|
||||
Bs = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve->Copy());
|
||||
}
|
||||
else {
|
||||
Bs = Geom2dConvert::CurveToBSplineCurve (NewCurve, myType);
|
||||
}
|
||||
|
||||
Standard_Integer LBs = Bs->NbPoles(), LCb = myCurve->NbPoles();
|
||||
|
||||
// myCurve est elle fermee ?
|
||||
if (myCurve->Pole(LCb).Distance(myCurve->Pole(1))< myTol){
|
||||
if(After){
|
||||
// Ajout Apres ?
|
||||
if (myCurve->Pole(LCb).Distance(Bs->Pole(LBs)) < myTol) {Bs->Reverse();}
|
||||
if (myCurve->Pole(LCb).Distance(Bs->Pole(1)) < myTol) {
|
||||
Add(myCurve, Bs, Standard_True);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
else{
|
||||
// Ajout avant ?
|
||||
if (myCurve->Pole(1).Distance(Bs->Pole(1)) < myTol) {Bs->Reverse();}
|
||||
if (myCurve->Pole(1).Distance(Bs->Pole(LBs)) < myTol) {
|
||||
Add(Bs, myCurve, Standard_False);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Ajout Apres ?
|
||||
else {
|
||||
|
||||
Standard_Real d1 = myCurve->Pole(LCb).Distance(Bs->Pole(1));
|
||||
Standard_Real d2 = myCurve->Pole(LCb).Distance(Bs->Pole(LBs));
|
||||
if (( d1 < myTol) || ( d2 < myTol)) {
|
||||
if (d2 < d1) {Bs->Reverse();}
|
||||
Add(myCurve, Bs, Standard_True);
|
||||
return Standard_True;
|
||||
}
|
||||
// Ajout avant ?
|
||||
else {
|
||||
d1 = myCurve->Pole(1).Distance(Bs->Pole(1));
|
||||
d2 = myCurve->Pole(1).Distance(Bs->Pole(LBs));
|
||||
if ( (d1 < myTol) || (d2 < myTol)) {
|
||||
if (d1 < d2) {Bs->Reverse();}
|
||||
Add(Bs, myCurve, Standard_False );
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
void Geom2dConvert_CompCurveToBSplineCurve::Add(
|
||||
Handle(Geom2d_BSplineCurve)& FirstCurve,
|
||||
Handle(Geom2d_BSplineCurve)& SecondCurve,
|
||||
const Standard_Boolean After)
|
||||
{
|
||||
// Harmonisation des degres.
|
||||
Standard_Integer Deg = Max(FirstCurve->Degree(), SecondCurve->Degree());
|
||||
if (FirstCurve->Degree() < Deg) { FirstCurve->IncreaseDegree(Deg); }
|
||||
if (SecondCurve->Degree() < Deg) { SecondCurve->IncreaseDegree(Deg); }
|
||||
|
||||
// Declarationd
|
||||
Standard_Real L1, L2, U_de_raccord;
|
||||
Standard_Integer ii, jj;
|
||||
Standard_Real Ratio=1, Ratio1, Ratio2, Delta1, Delta2;
|
||||
Standard_Integer NbP1 = FirstCurve->NbPoles(), NbP2 = SecondCurve->NbPoles();
|
||||
Standard_Integer NbK1 = FirstCurve->NbKnots(), NbK2 = SecondCurve->NbKnots();
|
||||
TColStd_Array1OfReal Noeuds (1, NbK1+NbK2-1);
|
||||
TColgp_Array1OfPnt2d Poles (1, NbP1+ NbP2-1);
|
||||
TColStd_Array1OfReal Poids (1, NbP1+ NbP2-1);
|
||||
TColStd_Array1OfInteger Mults (1, NbK1+NbK2-1);
|
||||
|
||||
// Ratio de reparametrisation (C1 si possible)
|
||||
L1 = FirstCurve->DN(FirstCurve->LastParameter(), 1).Magnitude();
|
||||
L2 = SecondCurve->DN(SecondCurve->FirstParameter(), 1). Magnitude();
|
||||
|
||||
if ( (L1 > Precision::Confusion()) && (L2 > Precision::Confusion()) ) {
|
||||
Ratio = L1 / L2;
|
||||
}
|
||||
if ( (Ratio < Precision::Confusion()) || (Ratio > 1/Precision::Confusion()) ) {Ratio = 1;}
|
||||
|
||||
if (After) {
|
||||
// On ne bouge pas la premiere courbe
|
||||
Ratio1 = 1;
|
||||
Delta1 = 0;
|
||||
Ratio2 = 1/Ratio;
|
||||
Delta2 = Ratio2*SecondCurve->Knot(1) - FirstCurve->Knot(NbK1);
|
||||
U_de_raccord = FirstCurve->LastParameter();
|
||||
}
|
||||
else {
|
||||
// On ne bouge pas la seconde courbe
|
||||
Ratio1 = Ratio;
|
||||
Delta1 = Ratio1*FirstCurve->Knot(NbK1) - SecondCurve->Knot(1);
|
||||
Ratio2 = 1;
|
||||
Delta2 = 0;
|
||||
U_de_raccord = SecondCurve->FirstParameter();
|
||||
}
|
||||
|
||||
// Les Noeuds
|
||||
|
||||
for (ii=1; ii<NbK1; ii++) {
|
||||
Noeuds(ii) = Ratio1*FirstCurve->Knot(ii) - Delta1;
|
||||
Mults(ii) = FirstCurve->Multiplicity(ii);
|
||||
}
|
||||
Noeuds(NbK1) = U_de_raccord;
|
||||
Mults(NbK1) = FirstCurve->Degree();
|
||||
for (ii=2, jj=NbK1+1; ii<=NbK2; ii++, jj++) {
|
||||
Noeuds(jj) = Ratio2*SecondCurve->Knot(ii) - Delta2;
|
||||
Mults(jj) = SecondCurve->Multiplicity(ii);
|
||||
}
|
||||
Ratio = FirstCurve->Weight(NbP1) ;
|
||||
Ratio /= SecondCurve->Weight(1) ;
|
||||
// Les Poles et Poids
|
||||
for (ii=1; ii<NbP1; ii++) {
|
||||
Poles(ii) = FirstCurve->Pole(ii);
|
||||
Poids(ii) = FirstCurve->Weight(ii);
|
||||
}
|
||||
for (ii=1, jj=NbP1; ii<=NbP2; ii++, jj++) {
|
||||
Poles(jj) = SecondCurve->Pole(ii);
|
||||
//
|
||||
// attentiion les poids ne se raccord pas forcement C0
|
||||
// d'ou Ratio
|
||||
//
|
||||
Poids(jj) = Ratio * SecondCurve->Weight(ii);
|
||||
}
|
||||
|
||||
// Creation de la BSpline
|
||||
myCurve = new (Geom2d_BSplineCurve) (Poles, Poids, Noeuds, Mults, Deg);
|
||||
|
||||
// Reduction eventuelle de la multiplicite
|
||||
Standard_Boolean Ok = Standard_True;
|
||||
Standard_Integer M = Mults(NbK1);
|
||||
while ( (M>0) && Ok) {
|
||||
M--;
|
||||
Ok = myCurve->RemoveKnot(NbK1, M, myTol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Handle(Geom2d_BSplineCurve) Geom2dConvert_CompCurveToBSplineCurve::BSplineCurve() const
|
||||
{
|
||||
return myCurve;
|
||||
}
|
Reference in New Issue
Block a user