1
0
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:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
-- File: Geom2dAdaptor.cdl
-- Created: Thu Jun 3 18:47:19 1993
-- Author: Bruno DUMORTIER
-- <dub@topsn3>
---Copyright: Matra Datavision 1993
package Geom2dAdaptor
---Purpose: this package contains the geometric definition of
-- 2d curves compatible with the Adaptor package
-- templates.
uses
Geom2d,
GeomAbs,
Adaptor2d,
gp,
Standard,
TColStd,
TColgp
is
class Curve;
---Purpose: Similar to Curve2d from Adaptor2d with a Curve from Geom2d.
private class GHCurve instantiates GenHCurve2d from Adaptor2d
(Curve from Geom2dAdaptor);
class HCurve;
---Purpose: Inherited from GHCurve. Provides a curve
-- handled by reference.
--
-- Package methods
--
MakeCurve(HC : Curve2d from Adaptor2d) returns Curve from Geom2d
---Purpose: Creates a 2d curve from a HCurve2d. This
-- cannot process the OtherCurves.
raises
DomainError from Standard; -- if GeomAbs_OtherCurve
end Geom2dAdaptor;

View File

@@ -0,0 +1,98 @@
// File: Geom2dAdaptor.cxx
// Created: Mon May 30 18:53:01 1994
// Author: Remi LEQUETTE
// <rle@bravox>
#include <Geom2dAdaptor.ixx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Parab2d.hxx>
#include <gp_Hypr2d.hxx>
//=======================================================================
//function : MakeCurve
//purpose :
//=======================================================================
Handle(Geom2d_Curve) Geom2dAdaptor::MakeCurve
(const Adaptor2d_Curve2d& HC)
{
Handle(Geom2d_Curve) C2D;
switch (HC.GetType()) {
case GeomAbs_Line:
{
Handle(Geom2d_Line) GL = new Geom2d_Line(HC.Line());
C2D = GL;
}
break;
case GeomAbs_Circle:
{
Handle(Geom2d_Circle) GL = new Geom2d_Circle(HC.Circle());
C2D = GL;
}
break;
case GeomAbs_Ellipse:
{
Handle(Geom2d_Ellipse) GL = new Geom2d_Ellipse(HC.Ellipse());
C2D = GL;
}
break;
case GeomAbs_Parabola:
{
Handle(Geom2d_Parabola) GL = new Geom2d_Parabola(HC.Parabola());
C2D = GL;
}
break;
case GeomAbs_Hyperbola:
{
Handle(Geom2d_Hyperbola) GL = new Geom2d_Hyperbola(HC.Hyperbola());
C2D = GL;
}
break;
case GeomAbs_BezierCurve:
{
C2D = HC.Bezier();
}
break;
case GeomAbs_BSplineCurve:
{
C2D = HC.BSpline();
}
break;
case GeomAbs_OtherCurve:
Standard_DomainError::Raise("Geom2dAdaptor::MakeCurve, OtherCurve");
}
// trim the curve if necassary.
if (! C2D.IsNull() &&
(HC.FirstParameter() != C2D->FirstParameter()) ||
(HC.LastParameter() != C2D->LastParameter())) {
C2D = new Geom2d_TrimmedCurve
(C2D,HC.FirstParameter(),HC.LastParameter());
}
return C2D;
}

View File

@@ -0,0 +1,240 @@
-- File: Geom2dAdaptor_Curve.cdl
-- Created: Thu Jun 3 18:51:05 1993
-- Author: Bruno DUMORTIER
-- <dub@topsn3>
---Copyright: Matra Datavision 1993
class Curve from Geom2dAdaptor inherits Curve2d from Adaptor2d
---Purpose: An interface between the services provided by any
-- curve from the package Geom2d and those required
-- of the curve by algorithms which use it.
uses Vec2d from gp,
Pnt2d from gp,
Circ2d from gp,
Elips2d from gp,
Hypr2d from gp,
Parab2d from gp,
Lin2d from gp,
Array1OfReal from TColStd,
Curve from Geom2d,
BezierCurve from Geom2d,
BSplineCurve from Geom2d,
CurveType from GeomAbs,
Shape from GeomAbs,
HCurve2d from Adaptor2d
raises NoSuchObject from Standard,
ConstructionError from Standard,
OutOfRange from Standard,
DomainError from Standard
is
Create returns Curve from Geom2dAdaptor;
Create(C : Curve from Geom2d) returns Curve from Geom2dAdaptor;
Create(C : Curve from Geom2d; UFirst,ULast : Real)
returns Curve from Geom2dAdaptor
raises
ConstructionError from Standard;
---Purpose: ConstructionError is raised if Ufirst>Ulast
Load(me : in out; C : Curve from Geom2d);
Load(me : in out; C : Curve from Geom2d; UFirst,ULast : Real)
raises
ConstructionError from Standard;
---Purpose: ConstructionError is raised if Ufirst>Ulast
Curve(me) returns Curve from Geom2d
---C++: return const&
---C++: inline
is static;
FirstParameter(me) returns Real
---C++: inline
is redefined static;
LastParameter(me) returns Real
---C++: inline
is redefined static;
Continuity(me) returns Shape from GeomAbs
is redefined static;
NbIntervals(me; S : Shape from GeomAbs) returns Integer
---Purpose: If necessary, breaks the curve in intervals of
-- continuity <S>. And returns the number of
-- intervals.
is redefined static;
Intervals(me; T : in out Array1OfReal from TColStd;
S : Shape from GeomAbs)
---Purpose: Stores in <T> the parameters bounding the intervals
-- of continuity <S>.
--
-- The array must provide enough room to accomodate
-- for the parameters. i.e. T.Length() > NbIntervals()
raises
OutOfRange from Standard
is redefined static;
Trim(me; First, Last, Tol : Real) returns HCurve2d from Adaptor2d
---Purpose: Returns a curve equivalent of <me> between
-- parameters <First> and <Last>. <Tol> is used to
-- test for 3d points confusion.
raises
OutOfRange from Standard
---Purpose: If <First> >= <Last>
is redefined static;
IsClosed(me) returns Boolean
is redefined static;
IsPeriodic(me) returns Boolean
is redefined static;
Period(me) returns Real
raises
DomainError from Standard -- if the curve is not periodic
is redefined static;
Value(me; U : Real) returns Pnt2d from gp
--- Purpose : Computes the point of parameter U on the curve
is redefined static;
D0 (me; U : Real; P : out Pnt2d from gp)
--- Purpose : Computes the point of parameter U.
is redefined static;
D1 (me; U : Real; P : out Pnt2d from gp ; V : out Vec2d from gp)
--- Purpose : Computes the point of parameter U on the curve with its
-- first derivative.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C1.
is redefined static;
D2 (me; U : Real; P : out Pnt2d from gp; V1, V2 : out Vec2d from gp)
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C2.
is redefined static;
D3 (me; U : Real; P : out Pnt2d from gp; V1, V2, V3 : out Vec2d from gp)
--- Purpose :
-- Returns the point P of parameter U, the first, the second
-- and the third derivative.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C3.
is redefined static;
DN (me; U : Real; N : Integer) returns Vec2d from gp
--- Purpose :
-- The returned vector gives the value of the derivative for the
-- order of derivation N.
raises
DomainError from Standard,
--- Purpose : Raised if the continuity of the current interval
-- is not CN.
OutOfRange from Standard
--- Purpose : Raised if N < 1.
is redefined static;
Resolution(me; Ruv :Real) returns Real
---Purpose : returns the parametric resolution
is redefined static;
GetType(me) returns CurveType from GeomAbs
---C++: inline
is redefined static;
Line(me) returns Lin2d from gp
raises
NoSuchObject from Standard
is redefined static;
Circle(me) returns Circ2d from gp
raises
NoSuchObject from Standard
is redefined static;
Ellipse(me) returns Elips2d from gp
raises
NoSuchObject from Standard
is redefined static;
Hyperbola(me) returns Hypr2d from gp
raises
NoSuchObject from Standard
is redefined static;
Parabola(me) returns Parab2d from gp
raises
NoSuchObject from Standard
is redefined static;
Degree(me) returns Integer
raises
NoSuchObject from Standard
is redefined static;
IsRational(me) returns Boolean
raises
NoSuchObject from Standard
is redefined static;
NbPoles(me) returns Integer
raises
NoSuchObject from Standard
is redefined static;
NbKnots(me) returns Integer
raises
NoSuchObject from Standard
is redefined static;
Bezier(me) returns BezierCurve from Geom2d
raises
NoSuchObject from Standard
is redefined static;
BSpline(me) returns BSplineCurve from Geom2d
raises
NoSuchObject from Standard
is redefined static;
LocalContinuity(me; U1, U2 : Real) returns Shape from GeomAbs
is static private;
fields
myCurve : Curve from Geom2d ;
myTypeCurve : CurveType from GeomAbs ;
myFirst : Real from Standard ;
myLast : Real from Standard;
end Curve;

View File

@@ -0,0 +1,853 @@
// File: Geom2dAdaptor_Curve.cxx
// Created: Fri Jun 4 10:39:27 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
// 20/02/97 : PMN -> Positionement local sur BSpline (PRO6902)
// 10/07/97 : PMN -> Pas de calcul de resolution dans Nb(Intervals) (PRO9248)
// 20/10/97 : JPI -> traitement des offset curves
#define No_Standard_RangeError
#define No_Standard_OutOfRange
#include <Geom2dAdaptor_Curve.ixx>
#include <Geom2d_OffsetCurve.hxx>
#include <Geom2dAdaptor_HCurve.hxx>
#include <Adaptor2d_HCurve2d.hxx>
#include <BSplCLib.hxx>
#include <GeomAbs_Shape.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <Precision.hxx>
#include <gp.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
//#include <Geom2dConvert_BSplineCurveKnotSplitting.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_NotImplemented.hxx>
#define myBspl (*((Handle(Geom2d_BSplineCurve)*)&myCurve))
#define PosTol Precision::PConfusion()/2
//=======================================================================
//function : LocalContinuity
//purpose : Computes the Continuity of a BSplineCurve
// between the parameters U1 and U2
// The continuity is C(d-m)
// with d = degree,
// m = max multiplicity of the Knots between U1 and U2
//=======================================================================
GeomAbs_Shape Geom2dAdaptor_Curve::LocalContinuity(const Standard_Real U1,
const Standard_Real U2)
const {
Standard_NoSuchObject_Raise_if(myTypeCurve!=GeomAbs_BSplineCurve," ");
Standard_Integer Nb = myBspl->NbKnots();
Standard_Integer Index1 = 0;
Standard_Integer Index2 = 0;
Standard_Real newFirst, newLast;
TColStd_Array1OfReal TK(1,Nb);
TColStd_Array1OfInteger TM(1,Nb);
myBspl->Knots(TK);
myBspl->Multiplicities(TM);
BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,U1,myBspl->IsPeriodic(),
1,Nb,Index1,newFirst);
BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,U2,myBspl->IsPeriodic(),
1,Nb,Index2,newLast);
if ( Abs(newFirst-TK(Index1+1))<Precision::PConfusion()) {
if (Index1 < Nb)Index1++;
}
if ( Abs(newLast-TK(Index2))<Precision::PConfusion())
Index2--;
Standard_Integer MultMax;
// attention aux courbes peridiques.
if ( (myBspl->IsPeriodic()) && (Index1 == Nb) )
Index1 = 1;
if ( Index2 - Index1 <= 0) {
MultMax = 100; // CN entre 2 Noeuds consecutifs
}
else {
MultMax = TM(Index1+1);
for(Standard_Integer i = Index1+1;i<=Index2;i++) {
if ( TM(i)>MultMax) MultMax=TM(i);
}
MultMax = myBspl->Degree() - MultMax;
}
if ( MultMax <= 0) {
return GeomAbs_C0;
}
else if ( MultMax == 1) {
return GeomAbs_C1;
}
else if ( MultMax == 2) {
return GeomAbs_C2;
}
else if ( MultMax == 3) {
return GeomAbs_C3;
}
else {
return GeomAbs_CN;
}
}
//=======================================================================
//function : Geom2dAdaptor_Curve
//purpose :
//=======================================================================
Geom2dAdaptor_Curve::Geom2dAdaptor_Curve()
{
}
//=======================================================================
//function : Geom2dAdaptor_Curve
//purpose :
//=======================================================================
Geom2dAdaptor_Curve::Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C) {
Load(C,C->FirstParameter(),C->LastParameter());
}
//=======================================================================
//function : Geom2dAdaptor_Curve
//purpose :
//=======================================================================
Geom2dAdaptor_Curve::Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C,
const Standard_Real UFirst,
const Standard_Real ULast) {
if ( UFirst > ULast) Standard_ConstructionError::Raise();
Load(C,UFirst,ULast);
}
//=======================================================================
//function : Load
//purpose :
//=======================================================================
void Geom2dAdaptor_Curve::Load(const Handle(Geom2d_Curve)& C) {
Load(C,C->FirstParameter(),C->LastParameter());
}
//=======================================================================
//function : Load
//purpose :
//=======================================================================
void Geom2dAdaptor_Curve::Load(const Handle(Geom2d_Curve)& C,
const Standard_Real UFirst,
const Standard_Real ULast) {
if ( UFirst > ULast) Standard_ConstructionError::Raise();
myFirst = UFirst;
myLast = ULast;
if ( myCurve != C) {
myCurve = C;
Handle(Standard_Type) TheType = C->DynamicType();
if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Load((*((Handle(Geom2d_TrimmedCurve)*)&C))->BasisCurve(),
UFirst,ULast);
}
else if ( TheType == STANDARD_TYPE(Geom2d_Circle)) {
myTypeCurve = GeomAbs_Circle;
}
else if ( TheType ==STANDARD_TYPE(Geom2d_Line)) {
myTypeCurve = GeomAbs_Line;
}
else if ( TheType == STANDARD_TYPE(Geom2d_Ellipse)) {
myTypeCurve = GeomAbs_Ellipse;
}
else if ( TheType == STANDARD_TYPE(Geom2d_Parabola)) {
myTypeCurve = GeomAbs_Parabola;
}
else if ( TheType == STANDARD_TYPE(Geom2d_Hyperbola)) {
myTypeCurve = GeomAbs_Hyperbola;
}
else if ( TheType == STANDARD_TYPE(Geom2d_BezierCurve)) {
myTypeCurve = GeomAbs_BezierCurve;
}
else if ( TheType == STANDARD_TYPE(Geom2d_BSplineCurve)) {
myTypeCurve = GeomAbs_BSplineCurve;
}
else {
myTypeCurve = GeomAbs_OtherCurve;
}
}
}
// --
// -- Global methods - Apply to the whole curve.
// --
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom2dAdaptor_Curve::Continuity() const
{
if (myTypeCurve == GeomAbs_BSplineCurve) {
return LocalContinuity(myFirst, myLast);
}
else if (myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))){
GeomAbs_Shape S =
(*((Handle(Geom2d_OffsetCurve)*)&myCurve))->BasisCurve()->Continuity();
switch(S){
case GeomAbs_CN: return GeomAbs_CN;
case GeomAbs_C3: return GeomAbs_C2;
case GeomAbs_C2: return GeomAbs_C1;
case GeomAbs_C1: return GeomAbs_C0;
default:
Standard_NoSuchObject::Raise("Geom2dAdaptor_Curve::Continuity");
}
}
else if (myTypeCurve == GeomAbs_OtherCurve) {
Standard_NoSuchObject::Raise("Geom2dAdaptor_Curve::Continuity");
}
else {
return GeomAbs_CN;
}
// portage WNT
return GeomAbs_CN;
}
//=======================================================================
//function : NbIntervals
//purpose :
//=======================================================================
Standard_Integer Geom2dAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const
{
Standard_Integer myNbIntervals = 1;
Standard_Integer NbSplit;
if (myTypeCurve == GeomAbs_BSplineCurve) {
Standard_Integer FirstIndex = myBspl->FirstUKnotIndex();
Standard_Integer LastIndex = myBspl->LastUKnotIndex();
TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
if ( S > Continuity()) {
Standard_Integer Cont;
switch ( S) {
case GeomAbs_G1:
case GeomAbs_G2:
Standard_DomainError::Raise("Geom2dAdaptor_Curve::NbIntervals");
break;
case GeomAbs_C0:
myNbIntervals = 1;
break;
case GeomAbs_C1:
case GeomAbs_C2:
case GeomAbs_C3:
case GeomAbs_CN:
{
if ( S == GeomAbs_C1) Cont = 1;
else if ( S == GeomAbs_C2) Cont = 2;
else if ( S == GeomAbs_C3) Cont = 3;
else Cont = myBspl->Degree();
Standard_Integer Degree = myBspl->Degree();
Standard_Integer NbKnots = myBspl->NbKnots();
TColStd_Array1OfInteger Mults (1, NbKnots);
myBspl->Multiplicities (Mults);
NbSplit = 1;
Standard_Integer Index = FirstIndex;
Inter (NbSplit) = Index;
Index++;
NbSplit++;
while (Index < LastIndex)
{
if (Degree - Mults (Index) < Cont)
{
Inter (NbSplit) = Index;
NbSplit++;
}
Index++;
}
Inter (NbSplit) = Index;
Standard_Integer NbInt = NbSplit-1;
Standard_Integer Nb = myBspl->NbKnots();
Standard_Integer Index1 = 0;
Standard_Integer Index2 = 0;
Standard_Real newFirst, newLast;
TColStd_Array1OfReal TK(1,Nb);
TColStd_Array1OfInteger TM(1,Nb);
myBspl->Knots(TK);
myBspl->Multiplicities(TM);
BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myFirst,
myBspl->IsPeriodic(),
1,Nb,Index1,newFirst);
BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myLast,
myBspl->IsPeriodic(),
1,Nb,Index2,newLast);
// On decale eventuellement les indices
// On utilise une "petite" tolerance, la resolution ne doit
// servir que pour les tres longue courbes....(PRO9248)
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
Precision::PConfusion());
if ( Abs(newFirst-TK(Index1+1))< Eps) Index1++;
if ( newLast-TK(Index2)> Eps) Index2++;
myNbIntervals = 1;
for ( Standard_Integer i=1; i<=NbInt; i++)
if (Inter(i)>Index1 && Inter(i)<Index2) myNbIntervals++;
}
break;
}
}
}
else if (myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))){
GeomAbs_Shape BaseS=GeomAbs_C0;
switch(S){
case GeomAbs_G1:
case GeomAbs_G2:
Standard_DomainError::Raise("GeomAdaptor_Curve::NbIntervals");
break;
case GeomAbs_C0: BaseS = GeomAbs_C1; break;
case GeomAbs_C1: BaseS = GeomAbs_C2; break;
case GeomAbs_C2: BaseS = GeomAbs_C3; break;
default: BaseS = GeomAbs_CN;
}
Geom2dAdaptor_Curve C
((*((Handle(Geom2d_OffsetCurve)*)&myCurve))->BasisCurve());
myNbIntervals = C.NbIntervals(BaseS);
}
return myNbIntervals;
}
//=======================================================================
//function : Intervals
//purpose :
//=======================================================================
void Geom2dAdaptor_Curve::Intervals(TColStd_Array1OfReal& T,
const GeomAbs_Shape S ) const
{
Standard_Integer myNbIntervals = 1;
Standard_Integer NbSplit;
if (myTypeCurve == GeomAbs_BSplineCurve) {
Standard_Integer FirstIndex = myBspl->FirstUKnotIndex();
Standard_Integer LastIndex = myBspl->LastUKnotIndex();
TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
if ( S > Continuity()) {
Standard_Integer Cont;
switch ( S) {
case GeomAbs_G1:
case GeomAbs_G2:
Standard_DomainError::Raise("Geom2dAdaptor_Curve::NbIntervals");
break;
case GeomAbs_C0:
myNbIntervals = 1;
break;
case GeomAbs_C1:
case GeomAbs_C2:
case GeomAbs_C3:
case GeomAbs_CN:
{
if ( S == GeomAbs_C1) Cont = 1;
else if ( S == GeomAbs_C2) Cont = 2;
else if ( S == GeomAbs_C3) Cont = 3;
else Cont = myBspl->Degree();
Standard_Integer Degree = myBspl->Degree();
Standard_Integer NbKnots = myBspl->NbKnots();
TColStd_Array1OfInteger Mults (1, NbKnots);
myBspl->Multiplicities (Mults);
NbSplit = 1;
Standard_Integer Index = FirstIndex;
Inter (NbSplit) = Index;
Index++;
NbSplit++;
while (Index < LastIndex)
{
if (Degree - Mults (Index) < Cont)
{
Inter (NbSplit) = Index;
NbSplit++;
}
Index++;
}
Inter (NbSplit) = Index;
Standard_Integer NbInt = NbSplit-1;
Standard_Integer Nb = myBspl->NbKnots();
Standard_Integer Index1 = 0;
Standard_Integer Index2 = 0;
Standard_Real newFirst, newLast;
TColStd_Array1OfReal TK(1,Nb);
TColStd_Array1OfInteger TM(1,Nb);
myBspl->Knots(TK);
myBspl->Multiplicities(TM);
BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myFirst,
myBspl->IsPeriodic(),
1,Nb,Index1,newFirst);
BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myLast,
myBspl->IsPeriodic(),
1,Nb,Index2,newLast);
// On decale eventuellement les indices
// On utilise une "petite" tolerance, la resolution ne doit
// servir que pour les tres longue courbes....(PRO9248)
Standard_Real Eps = Min(Resolution(Precision::Confusion()),
Precision::PConfusion());
if ( Abs(newFirst-TK(Index1+1))< Eps) Index1++;
if ( newLast-TK(Index2)> Eps) Index2++;
Inter( 1) = Index1;
myNbIntervals = 1;
for ( Standard_Integer i=1; i<=NbInt; i++) {
if (Inter(i) > Index1 && Inter(i)<Index2 ) {
myNbIntervals++;
Inter(myNbIntervals) = Inter(i);
}
}
Inter(myNbIntervals+1) = Index2;
Standard_Integer ii = T.Lower() - 1;
for (Standard_Integer I=1;I<=myNbIntervals+1;I++) {
T(ii + I) = TK(Inter(I));
}
}
break;
}
}
}
else if (myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))){
GeomAbs_Shape BaseS=GeomAbs_C0;
switch(S){
case GeomAbs_G1:
case GeomAbs_G2:
Standard_DomainError::Raise("GeomAdaptor_Curve::NbIntervals");
break;
case GeomAbs_C0: BaseS = GeomAbs_C1; break;
case GeomAbs_C1: BaseS = GeomAbs_C2; break;
case GeomAbs_C2: BaseS = GeomAbs_C3; break;
default: BaseS = GeomAbs_CN;
}
Geom2dAdaptor_Curve C
((*((Handle(Geom2d_OffsetCurve)*)&myCurve))->BasisCurve());
myNbIntervals = C.NbIntervals(BaseS);
C.Intervals(T, BaseS);
}
T( T.Lower() ) = myFirst;
T( T.Lower() + myNbIntervals ) = myLast;
}
//=======================================================================
//function : Trim
//purpose :
//=======================================================================
Handle(Adaptor2d_HCurve2d) Geom2dAdaptor_Curve::Trim
(const Standard_Real First,
const Standard_Real Last,
// const Standard_Real Tol) const
const Standard_Real ) const
{
Handle(Geom2dAdaptor_HCurve) HE = new Geom2dAdaptor_HCurve(myCurve,First,Last);
return HE;
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2dAdaptor_Curve::IsClosed() const
{
if (!Precision::IsPositiveInfinite(myLast) &&
!Precision::IsNegativeInfinite(myFirst)) {
gp_Pnt2d Pd = Value(myFirst);
gp_Pnt2d Pf = Value(myLast);
return ( Pd.Distance(Pf) <= Precision::Confusion());
}
else
return Standard_False;
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2dAdaptor_Curve::IsPeriodic() const
{
if (myCurve->IsPeriodic())
return IsClosed();
else
return Standard_False;
}
//=======================================================================
//function : Period
//purpose :
//=======================================================================
Standard_Real Geom2dAdaptor_Curve::Period() const
{
return myCurve->LastParameter() - myCurve->FirstParameter();
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
gp_Pnt2d Geom2dAdaptor_Curve::Value(const Standard_Real U) const
{
if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
(U==myFirst || U==myLast) ) {
Standard_Integer Ideb, Ifin;
if (U==myFirst) {
myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (U==myLast) {
myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
return myBspl->LocalValue(U, Ideb, Ifin);
}
else {
return myCurve->Value( U);
}
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2dAdaptor_Curve::D0(const Standard_Real U, gp_Pnt2d& P) const
{
if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
(U==myFirst || U==myLast) ) {
Standard_Integer Ideb, Ifin;
if (U==myFirst) {
myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (U==myLast) {
myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
myBspl->LocalD0( U, Ideb, Ifin, P);
}
else {
myCurve->D0(U, P);
}
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2dAdaptor_Curve::D1(const Standard_Real U,
gp_Pnt2d& P, gp_Vec2d& V) const
{
if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
(U==myFirst || U==myLast) ) {
Standard_Integer Ideb, Ifin;
if (U==myFirst) {
myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (U==myLast) {
myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
myBspl->LocalD1( U, Ideb, Ifin, P, V);
}
else {
myCurve->D1( U, P, V);
}
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2dAdaptor_Curve::D2(const Standard_Real U,
gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
{
if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
(U==myFirst || U==myLast) ) {
Standard_Integer Ideb, Ifin;
if (U==myFirst) {
myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (U==myLast) {
myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
myBspl->LocalD2( U, Ideb, Ifin, P, V1, V2);
}
else {
myCurve->D2( U, P, V1, V2);
}
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2dAdaptor_Curve::D3(const Standard_Real U,
gp_Pnt2d& P, gp_Vec2d& V1,
gp_Vec2d& V2, gp_Vec2d& V3) const
{
if ( (myTypeCurve == GeomAbs_BSplineCurve) &&
(U==myFirst || U==myLast) ) {
Standard_Integer Ideb, Ifin;
if (U==myFirst) {
myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (U==myLast) {
myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
myBspl->LocalD3( U, Ideb, Ifin, P, V1, V2, V3);
}
else {
myCurve->D3( U, P, V1, V2, V3);
}
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
gp_Vec2d Geom2dAdaptor_Curve::DN(const Standard_Real U,
const Standard_Integer N) const
{
if ( (myTypeCurve == GeomAbs_BSplineCurve) &&
(U==myFirst || U==myLast) ) {
Standard_Integer Ideb, Ifin;
if (U==myFirst) {
myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (U==myLast) {
myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
return myBspl->LocalDN( U, Ideb, Ifin, N);
}
else {
return myCurve->DN( U, N);
}
}
//=======================================================================
//function : Resolution
//purpose :
//=======================================================================
Standard_Real Geom2dAdaptor_Curve::Resolution(const Standard_Real Ruv) const {
switch ( myTypeCurve) {
case GeomAbs_Line :
return Ruv;
case GeomAbs_Circle: {
Standard_Real R = (*((Handle(Geom2d_Circle)*)&myCurve))->Circ2d().Radius();
if ( R > Ruv/2.)
return 2*ASin(Ruv/(2*R));
else
return 2*PI;
}
case GeomAbs_Ellipse: {
return Ruv / (*((Handle(Geom2d_Ellipse)*)&myCurve))->MajorRadius();
}
case GeomAbs_BezierCurve: {
Standard_Real res;
(*((Handle(Geom2d_BezierCurve)*)&myCurve))->Resolution(Ruv,res);
return res;
}
case GeomAbs_BSplineCurve: {
Standard_Real res;
(*((Handle(Geom2d_BSplineCurve)*)&myCurve))->Resolution(Ruv,res);
return res;
}
default:
return Precision::Parametric(Ruv);
}
}
// --
// -- The following methods must be called when GetType returned
// -- the corresponding type.
// --
//=======================================================================
//function : Line
//purpose :
//=======================================================================
gp_Lin2d Geom2dAdaptor_Curve::Line() const
{
Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Line, "");
return (*((Handle(Geom2d_Line)*)&myCurve))->Lin2d();
}
//=======================================================================
//function : Circle
//purpose :
//=======================================================================
gp_Circ2d Geom2dAdaptor_Curve::Circle() const
{
Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Circle, "");
return (*((Handle(Geom2d_Circle)*)&myCurve))->Circ2d();
}
//=======================================================================
//function : Ellipse
//purpose :
//=======================================================================
gp_Elips2d Geom2dAdaptor_Curve::Ellipse() const
{
Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Ellipse, "");
return (*((Handle(Geom2d_Ellipse)*)&myCurve))->Elips2d();
}
//=======================================================================
//function : Hyperbola
//purpose :
//=======================================================================
gp_Hypr2d Geom2dAdaptor_Curve::Hyperbola() const
{
Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Hyperbola, "");
return (*((Handle(Geom2d_Hyperbola)*)&myCurve))->Hypr2d();
}
//=======================================================================
//function : Parabola
//purpose :
//=======================================================================
gp_Parab2d Geom2dAdaptor_Curve::Parabola() const
{
Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Parabola, "");
return (*((Handle(Geom2d_Parabola)*)&myCurve))->Parab2d();
}
//=======================================================================
//function : Degree
//purpose :
//=======================================================================
Standard_Integer Geom2dAdaptor_Curve::Degree() const
{
if (myTypeCurve == GeomAbs_BezierCurve)
return (*((Handle(Geom2d_BezierCurve)*)&myCurve))->Degree();
else if (myTypeCurve == GeomAbs_BSplineCurve)
return (*((Handle(Geom2d_BSplineCurve)*)&myCurve))->Degree();
else
Standard_NoSuchObject::Raise();
// portage WNT
return 0;
}
//=======================================================================
//function : IsRational
//purpose :
//=======================================================================
Standard_Boolean Geom2dAdaptor_Curve::IsRational() const {
switch( myTypeCurve) {
case GeomAbs_BSplineCurve:
return (*((Handle(Geom2d_BSplineCurve)*)&myCurve))->IsRational();
case GeomAbs_BezierCurve:
return (*((Handle(Geom2d_BezierCurve)*)&myCurve))->IsRational();
default:
return Standard_False;
}
}
//=======================================================================
//function : NbPoles
//purpose :
//=======================================================================
Standard_Integer Geom2dAdaptor_Curve::NbPoles() const
{
if (myTypeCurve == GeomAbs_BezierCurve)
return (*((Handle(Geom2d_BezierCurve)*)&myCurve))->NbPoles();
else if (myTypeCurve == GeomAbs_BSplineCurve)
return (*((Handle(Geom2d_BSplineCurve)*)&myCurve))->NbPoles();
else
Standard_NoSuchObject::Raise();
// portage WNT
return 0;
}
//=======================================================================
//function : NbKnots
//purpose :
//=======================================================================
Standard_Integer Geom2dAdaptor_Curve::NbKnots() const {
if ( myTypeCurve != GeomAbs_BSplineCurve)
Standard_NoSuchObject::Raise("Geom2dAdaptor_Curve::NbKnots");
return (*((Handle(Geom2d_BSplineCurve)*)&myCurve))->NbKnots();
}
//=======================================================================
//function : Bezier
//purpose :
//=======================================================================
Handle(Geom2d_BezierCurve) Geom2dAdaptor_Curve::Bezier() const
{
return *((Handle(Geom2d_BezierCurve)*)&myCurve);
}
//=======================================================================
//function : BSpline
//purpose :
//=======================================================================
Handle(Geom2d_BSplineCurve) Geom2dAdaptor_Curve::BSpline() const
{
return *((Handle(Geom2d_BSplineCurve)*)&myCurve);
}

View File

@@ -0,0 +1,49 @@
// File: Geom2dAdaptor_Curve.lxx
// Created: Fri Jun 4 11:03:44 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
#include <gp_Pnt2d.hxx>
#include <Geom2d_Curve.hxx>
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
inline Standard_Real Geom2dAdaptor_Curve::FirstParameter() const
{
return myFirst;
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
inline Standard_Real Geom2dAdaptor_Curve::LastParameter() const
{
return myLast;
}
//=======================================================================
//function : Curve
//purpose :
//=======================================================================
inline const Handle(Geom2d_Curve)& Geom2dAdaptor_Curve::Curve() const
{
return myCurve;
}
//=======================================================================
//function : GetType
//purpose :
//=======================================================================
inline GeomAbs_CurveType Geom2dAdaptor_Curve::GetType() const
{
return myTypeCurve;
}

View File

@@ -0,0 +1,35 @@
-- File: Geom2dAdaptor_HCurve.cdl
-- Created: Fri Aug 25 14:38:16 1995
-- Author: Remi LEQUETTE
-- <rle@mentox>
---Copyright: Matra Datavision 1995
class HCurve from Geom2dAdaptor inherits GHCurve from Geom2dAdaptor
---Purpose: Provides an interface between the services provided by any
-- curve from the package Geom2d and those required
-- of the curve by algorithms, which use it.
uses
Curve from Geom2d,
Curve from Geom2dAdaptor
raises
ConstructionError from Standard
is
Create returns mutable HCurve from Geom2dAdaptor;
Create( AS : Curve from Geom2dAdaptor) returns mutable HCurve from Geom2dAdaptor;
Create( S : Curve from Geom2d) returns mutable HCurve from Geom2dAdaptor;
Create( S : Curve from Geom2d; UFirst,ULast : Real)
returns mutable HCurve from Geom2dAdaptor
raises ConstructionError from Standard;
---Purpose: ConstructionError is raised if UFirst>ULast or VFirst>VLast
end HCurve;

View File

@@ -0,0 +1,49 @@
// File: Geom2dAdaptor_HCurve.cxx
// Created: Fri Aug 25 14:48:36 1995
// Author: Remi LEQUETTE
// <rle@mentox>
#include <Geom2dAdaptor_HCurve.ixx>
//=======================================================================
//function : Geom2dAdaptor_HCurve
//purpose :
//=======================================================================
Geom2dAdaptor_HCurve::Geom2dAdaptor_HCurve()
{
}
//=======================================================================
//function : Geom2dAdaptor_HCurve
//purpose :
//=======================================================================
Geom2dAdaptor_HCurve::Geom2dAdaptor_HCurve(const Geom2dAdaptor_Curve& AS) :
Geom2dAdaptor_GHCurve(AS)
{
}
//=======================================================================
//function : Geom2dAdaptor_HCurve
//purpose :
//=======================================================================
Geom2dAdaptor_HCurve::Geom2dAdaptor_HCurve(const Handle(Geom2d_Curve)& S)
{
ChangeCurve2d().Load(S);
}
//=======================================================================
//function : Geom2dAdaptor_HCurve
//purpose :
//=======================================================================
Geom2dAdaptor_HCurve::Geom2dAdaptor_HCurve(const Handle(Geom2d_Curve)& S,
const Standard_Real UFirst,
const Standard_Real ULast)
{
ChangeCurve2d().Load(S,UFirst,ULast);
}