1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +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

1
src/Geom2d/FILES Executable file
View File

@@ -0,0 +1 @@
Geom2d_BSplineCurve_1.cxx

84
src/Geom2d/Geom2d.cdl Executable file
View File

@@ -0,0 +1,84 @@
-- File: Geom2d.cdl
-- Created: Wed Mar 24 17:29:38 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
package Geom2d
--- Purpose :
-- This package contains the definition of the geometric objects
-- such as point, vector, axis placement, curves and the
-- description of the geometric transformations available
-- for these objects.
-- All these entities are defined in 2D space.
-- This package gives the possibility :
-- . to create geometric objects,
-- . to have information about them,
-- . to modify these objects.
-- This package uses the services of the package gp (Geometric
-- processor) which describes non-persistent objects for algebraic
-- calculus and basic analytic geometry. The purpose of this package
-- is to create persistent geometric objects and to read geometric
-- information about these objects. Complexes geometric algorithmes
-- are not described in this package. At construction time,
-- elementary verifications are done to verify that the objects
-- are coherents, but some verifications which require complex
-- algorithmes (for example to check that a curve has not null
-- length or does not self-intersect) must be done before the
-- construction of the geometric objects.
uses MMgt, GeomAbs, TColStd, gp, TColgp
is
exception UndefinedDerivative inherits DomainError from Standard;
exception UndefinedValue inherits DomainError from Standard ;
class Transformation;
deferred class Geometry;
deferred class Point;
class CartesianPoint;
deferred class Vector;
class Direction;
class VectorWithMagnitude;
class AxisPlacement;
deferred class Curve;
class Line;
deferred class Conic;
class Circle;
class Ellipse;
class Hyperbola;
class Parabola;
deferred class BoundedCurve;
class BezierCurve;
class BSplineCurve;
class TrimmedCurve;
class OffsetCurve;
end Geom2d;

View File

@@ -0,0 +1,103 @@
-- File: Geom2d_AxisPlacement.cdl
-- Created: Wed Mar 24 17:33:01 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
class AxisPlacement from Geom2d inherits Geometry from Geom2d
--- Purpose : Describes an axis in 2D space.
-- An axis is defined by:
-- - its origin, also termed the "Location point" of the axis,
-- - its unit vector, termed the "Direction" of the axis.
-- Note: Geom2d_AxisPlacement axes provide the
-- same kind of "geometric" services as gp_Ax2d axes
-- but have more complex data structures. The
-- geometric objects provided by the Geom2d package
-- use gp_Ax2d objects to include axes in their data
-- structures, or to define an axis of symmetry or axis of rotation.
-- Geom2d_AxisPlacement axes are used in a context
-- where they can be shared by several objects
-- contained inside a common data structure.
uses Ax2d from gp,
Dir2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp
is
Create (A : Ax2d) returns mutable AxisPlacement;
--- Purpose : Constructs an axis by conversion of the gp_Ax2d axis A.
Create (P : Pnt2d; V : Dir2d) returns mutable AxisPlacement;
--- Purpose : Constructs an axis from a given origin P and unit vector V.
Reverse (me : mutable);
Reversed (me) returns mutable AxisPlacement is static;
---Purpose: Reverses the unit vector of this axis.
-- Note:
-- - Reverse assigns the result to this axis, while
-- - Reversed creates a new one.
SetAxis (me : mutable; A : Ax2d);
--- Purpose : Changes the complete definition of the axis placement.
SetDirection (me : mutable; V : Dir2d);
--- Purpose :
-- Changes the "Direction" of the axis placement.
SetLocation (me : mutable; P : Pnt2d);
--- Purpose :
-- Changes the "Location" point (origin) of the axis placement.
Angle (me; Other : AxisPlacement) returns Real;
--- Purpose :
-- Computes the angle between the "Direction" of
-- two axis placement in radians.
-- The result is comprised between -Pi and Pi.
Ax2d (me) returns Ax2d;
--- Purpose : Converts this axis into a gp_Ax2d axis.
Direction (me) returns Dir2d;
--- Purpose : Returns the "Direction" of <me>.
-- -C++: return const&
Location (me) returns Pnt2d;
--- Purpose :
-- Returns the "Location" point (origin) of the axis placement.
-- -C++: return const&
Transform (me : mutable; T : Trsf2d);
---Purpose: Applies the transformation T to this axis.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this axis.
fields
axis : Ax2d;
end;

View File

@@ -0,0 +1,74 @@
// File: Geom2d_AxisPlacement.cxx
// Created: Wed Mar 24 19:18:35 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom_AxisPlacement.cxx, JCV 25/06/91
#include <Geom2d_AxisPlacement.ixx>
typedef Geom2d_AxisPlacement AxisPlacement;
typedef Handle(Geom2d_AxisPlacement) Handle(AxisPlacement);
typedef gp_Dir2d Dir2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Trsf2d Trsf2d;
typedef gp_Vec2d Vec2d;
Handle(Geom2d_Geometry) Geom2d_AxisPlacement::Copy() const {
Handle(AxisPlacement) A;
A = new AxisPlacement (axis);
return A;
}
Geom2d_AxisPlacement::Geom2d_AxisPlacement (const gp_Ax2d& A) { axis = A; }
Geom2d_AxisPlacement::Geom2d_AxisPlacement (const Pnt2d& P, const Dir2d& V) {
axis = gp_Ax2d (P, V);
}
gp_Ax2d Geom2d_AxisPlacement::Ax2d () const { return axis; }
Dir2d Geom2d_AxisPlacement::Direction () const { return axis.Direction(); }
Pnt2d Geom2d_AxisPlacement::Location () const { return axis.Location(); }
void Geom2d_AxisPlacement::Reverse() { axis.Reverse(); }
Handle(AxisPlacement) Geom2d_AxisPlacement::Reversed() const {
gp_Ax2d A = axis;
A.Reverse();
Handle(AxisPlacement) Temp = new AxisPlacement (A);
return Temp;
}
void Geom2d_AxisPlacement::Transform (const Trsf2d& T) { axis.Transform (T); }
void Geom2d_AxisPlacement::SetAxis (const gp_Ax2d& A) { axis = A; }
void Geom2d_AxisPlacement::SetLocation (const Pnt2d& P) {axis.SetLocation (P);}
void Geom2d_AxisPlacement::SetDirection (const Dir2d& V) {
axis.SetDirection(V);
}
Standard_Real Geom2d_AxisPlacement::Angle (const Handle(AxisPlacement)& Other) const {
return axis.Angle (Other->Ax2d());
}

1033
src/Geom2d/Geom2d_BSplineCurve.cdl Executable file

File diff suppressed because it is too large Load Diff

1441
src/Geom2d/Geom2d_BSplineCurve.cxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,806 @@
// File: Geom2d_BSplineCurve_1.cxx
// Created: Wed Mar 31 18:11:15 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
// File: Geom2d_BSplineCurve_1.cxx
// Created: Fri Jul 5 16:37:59 1991
// Author: JCV
// 03-02-97 : pmn ->LocateU sur Periodic (PRO6963),
// bon appel a LocateParameter (PRO6973) et mise en conformite avec
// le cdl de LocateU, lorsque U est un noeud (PRO6988)
#define No_Standard_OutOfRange
#define No_Standard_DimensionError
#include <Geom2d_BSplineCurve.jxx>
#include <BSplCLib.hxx>
#include <gp.hxx>
#include <Geom2d_UndefinedDerivative.hxx>
#include <Standard_DimensionError.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_RangeError.hxx>
#define POLES (poles->Array1())
#define KNOTS (knots->Array1())
#define FKNOTS (flatknots->Array1())
#define FMULTS (BSplCLib::NoMults())
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom2d_BSplineCurve::IsCN ( const Standard_Integer N) const
{
Standard_RangeError_Raise_if
(N < 0, "Geom2d_BSplineCurve::IsCN");
switch (smooth) {
case GeomAbs_CN : return Standard_True;
case GeomAbs_C0 : return N <= 0;
case GeomAbs_G1 : return N <= 0;
case GeomAbs_C1 : return N <= 1;
case GeomAbs_G2 : return N <= 1;
case GeomAbs_C2 : return N <= 2;
case GeomAbs_C3 :
return N <= 3 ? Standard_True :
N <= deg - BSplCLib::MaxKnotMult (mults->Array1(), mults->Lower() + 1, mults->Upper() - 1);
default:
return Standard_False;
}
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2d_BSplineCurve::IsClosed () const
{ return (StartPoint().Distance (EndPoint())) <= gp::Resolution (); }
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2d_BSplineCurve::IsPeriodic () const
{ return periodic; }
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom2d_BSplineCurve::Continuity () const
{ return smooth; }
//=======================================================================
//function : Degree
//purpose :
//=======================================================================
Standard_Integer Geom2d_BSplineCurve::Degree () const
{ return deg; }
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::D0 ( const Standard_Real U,
gp_Pnt2d& P) const
{
Standard_Real NewU = U ;
PeriodicNormalization(NewU) ;
if (!IsCacheValid(NewU)) {
Geom2d_BSplineCurve * MyCurve = (Geom2d_BSplineCurve *) this ;
MyCurve->ValidateCache(NewU) ;
}
if ( rational ) {
BSplCLib::CacheD0(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
cacheweights->Array1(),
P) ;
}
else {
BSplCLib::CacheD0(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
BSplCLib::NoWeights(),
P) ;
}
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::D1 (const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1) const
{
Standard_Real NewU = U ;
PeriodicNormalization(NewU) ;
if (!IsCacheValid(NewU)) {
Geom2d_BSplineCurve * MyCurve = (Geom2d_BSplineCurve *) this ;
MyCurve->ValidateCache(NewU) ;
}
if ( rational ) {
BSplCLib::CacheD1(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
cacheweights->Array1(),
P,
V1) ;
}
else {
BSplCLib::CacheD1(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
BSplCLib::NoWeights(),
P,
V1) ;
}
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::D2 (const Standard_Real U ,
gp_Pnt2d& P ,
gp_Vec2d& V1,
gp_Vec2d& V2 ) const
{
Standard_Real NewU = U ;
PeriodicNormalization(NewU) ;
if (!IsCacheValid(NewU)) {
Geom2d_BSplineCurve * MyCurve = (Geom2d_BSplineCurve *) this ;
MyCurve->ValidateCache(NewU) ;
}
if ( rational ) {
BSplCLib::CacheD2(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
cacheweights->Array1(),
P,
V1,
V2) ;
}
else {
BSplCLib::CacheD2(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
BSplCLib::NoWeights(),
P,
V1,
V2) ;
}
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::D3 (const Standard_Real U ,
gp_Pnt2d& P ,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3 ) const
{
Standard_Real NewU = U ;
PeriodicNormalization(NewU) ;
if (!IsCacheValid(NewU)) {
Geom2d_BSplineCurve * MyCurve = (Geom2d_BSplineCurve *) this ;
MyCurve->ValidateCache(NewU) ;
}
if ( rational ) {
BSplCLib::CacheD3(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
cacheweights->Array1(),
P,
V1,
V2,
V3) ;
}
else {
BSplCLib::CacheD3(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
BSplCLib::NoWeights(),
P,
V1,
V2,
V3) ;
}
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
gp_Vec2d Geom2d_BSplineCurve::DN (const Standard_Real U,
const Standard_Integer N ) const
{
gp_Vec2d V;
if ( rational ) {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
weights->Array1(),
FKNOTS,FMULTS,V);
}
else {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
FKNOTS,FMULTS,V);
}
return V;
}
//=======================================================================
//function : EndPoint
//purpose :
//=======================================================================
gp_Pnt2d Geom2d_BSplineCurve::EndPoint () const
{
if (mults->Value (knots->Upper ()) == deg + 1)
return poles->Value (poles->Upper());
else
return Value(LastParameter());
}
//=======================================================================
//function : FirstUKnotIndex
//purpose :
//=======================================================================
Standard_Integer Geom2d_BSplineCurve::FirstUKnotIndex () const
{
if (periodic) return 1;
else return BSplCLib::FirstUKnotIndex (deg, mults->Array1());
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_BSplineCurve::FirstParameter () const
{
return flatknots->Value (deg+1);
}
//=======================================================================
//function : Knot
//purpose :
//=======================================================================
Standard_Real Geom2d_BSplineCurve::Knot (const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if
(Index < 1 || Index > knots->Length(), "Geom2d_BSplineCurve::Knot");
return knots->Value (Index);
}
//=======================================================================
//function : KnotDistribution
//purpose :
//=======================================================================
GeomAbs_BSplKnotDistribution Geom2d_BSplineCurve::KnotDistribution () const
{
return knotSet;
}
//=======================================================================
//function : Knots
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::Knots (TColStd_Array1OfReal& K) const
{
Standard_DimensionError_Raise_if
(K.Length() != knots->Length(), "Geom2d_BSplineCurve::Knots");
K = knots->Array1();
}
//=======================================================================
//function : KnotSequence
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::KnotSequence (TColStd_Array1OfReal& K) const
{
Standard_DimensionError_Raise_if
(K.Length() != flatknots->Length(), "Geom2d_BSplineCurve::KnotSequence");
K = flatknots->Array1();
}
//=======================================================================
//function : LastUKnotIndex
//purpose :
//=======================================================================
Standard_Integer Geom2d_BSplineCurve::LastUKnotIndex() const
{
if (periodic) return knots->Length();
else return BSplCLib::LastUKnotIndex (deg, mults->Array1());
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_BSplineCurve::LastParameter () const
{
return flatknots->Value (flatknots->Upper()-deg);
}
//=======================================================================
//function : LocalValue
//purpose :
//=======================================================================
gp_Pnt2d Geom2d_BSplineCurve::LocalValue
(const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2) const
{
gp_Pnt2d P;
LocalD0(U,FromK1,ToK2,P);
return P;
}
//=======================================================================
//function : LocalD0
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::LocalD0
(const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
gp_Pnt2d& P) const
{
Standard_DomainError_Raise_if (FromK1 == ToK2,
"Geom2d_BSplineCurve::LocalValue");
Standard_Real u = U;
Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic,FromK1,ToK2, index,u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if ( rational ) {
BSplCLib::D0(u,index,deg,periodic,POLES,
weights->Array1(),
FKNOTS,FMULTS,P);
}
else {
BSplCLib::D0(u,index,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
FKNOTS,FMULTS,P);
}
}
//=======================================================================
//function : LocalD1
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::LocalD1 (const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
gp_Pnt2d& P,
gp_Vec2d& V1) const
{
Standard_DomainError_Raise_if (FromK1 == ToK2,
"Geom2d_BSplineCurve::LocalD1");
Standard_Real u = U;
Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) {
BSplCLib::D1(u,index,deg,periodic,POLES,
weights->Array1(),
FKNOTS,FMULTS,P,V1);
}
else {
BSplCLib::D1(u,index,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
FKNOTS,FMULTS,P,V1);
}
}
//=======================================================================
//function : LocalD2
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::LocalD2
(const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2) const
{
Standard_DomainError_Raise_if (FromK1 == ToK2,
"Geom2d_BSplineCurve::LocalD2");
Standard_Real u = U;
Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if ( rational ) {
BSplCLib::D2(u,index,deg,periodic,POLES,
weights->Array1(),
FKNOTS,FMULTS,P,V1,V2);
}
else {
BSplCLib::D2(u,index,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
FKNOTS,FMULTS,P,V1,V2);
}
}
//=======================================================================
//function : LocalD3
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::LocalD3
(const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
{
Standard_DomainError_Raise_if (FromK1 == ToK2,
"Geom2d_BSplineCurve::LocalD3");
Standard_Real u = U;
Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if ( rational ) {
BSplCLib::D3(u,index,deg,periodic,POLES,
weights->Array1(),
FKNOTS,FMULTS,P,V1,V2,V3);
}
else {
BSplCLib::D3(u,index,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
FKNOTS,FMULTS,P,V1,V2,V3);
}
}
//=======================================================================
//function : LocalDN
//purpose :
//=======================================================================
gp_Vec2d Geom2d_BSplineCurve::LocalDN
(const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
const Standard_Integer N ) const
{
Standard_DomainError_Raise_if (FromK1 == ToK2,
"Geom2d_BSplineCurve::LocalD3");
Standard_Real u = U;
Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
gp_Vec2d V;
if ( rational ) {
BSplCLib::DN(u,N,index,deg,periodic,POLES,
weights->Array1(),
FKNOTS,FMULTS,V);
}
else {
BSplCLib::DN(u,N,index,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
FKNOTS,FMULTS,V);
}
return V;
}
//=======================================================================
//function : Multiplicity
//purpose :
//=======================================================================
Standard_Integer Geom2d_BSplineCurve::Multiplicity
(const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if (Index < 1 || Index > mults->Length(),
"Geom2d_BSplineCurve::Multiplicity");
return mults->Value (Index);
}
//=======================================================================
//function : Multiplicities
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::Multiplicities (TColStd_Array1OfInteger& M) const
{
Standard_DimensionError_Raise_if (M.Length() != mults->Length(),
"Geom2d_BSplineCurve::Multiplicities");
M = mults->Array1();
}
//=======================================================================
//function : NbKnots
//purpose :
//=======================================================================
Standard_Integer Geom2d_BSplineCurve::NbKnots () const
{ return knots->Length(); }
//=======================================================================
//function : NbPoles
//purpose :
//=======================================================================
Standard_Integer Geom2d_BSplineCurve::NbPoles () const
{ return poles->Length(); }
//=======================================================================
//function : Pole
//purpose :
//=======================================================================
gp_Pnt2d Geom2d_BSplineCurve::Pole (const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if (Index < 1 || Index > poles->Length(),
"Geom2d_BSplineCurve::Pole");
return poles->Value (Index);
}
//=======================================================================
//function : Poles
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::Poles (TColgp_Array1OfPnt2d& P) const
{
Standard_DimensionError_Raise_if (P.Length() != poles->Length(),
"Geom2d_BSplineCurve::Poles");
P = poles->Array1();
}
//=======================================================================
//function : StartPoint
//purpose :
//=======================================================================
gp_Pnt2d Geom2d_BSplineCurve::StartPoint () const
{
if (mults->Value (1) == deg + 1)
return poles->Value (1);
else
return Value(FirstParameter());
}
//=======================================================================
//function : Weight
//purpose :
//=======================================================================
Standard_Real Geom2d_BSplineCurve::Weight
(const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if (Index < 1 || Index > poles->Length(),
"Geom2d_BSplineCurve::Weight");
if (IsRational())
return weights->Value (Index);
else
return 1.;
}
//=======================================================================
//function : Weights
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::Weights
(TColStd_Array1OfReal& W) const
{
Standard_DimensionError_Raise_if (W.Length() != poles->Length(),
"Geom2d_BSplineCurve::Weights");
if (IsRational())
W = weights->Array1();
else {
Standard_Integer i;
for (i = W.Lower(); i <= W.Upper(); i++)
W(i) = 1.;
}
}
//=======================================================================
//function : IsRational
//purpose :
//=======================================================================
Standard_Boolean Geom2d_BSplineCurve::IsRational () const
{
return !weights.IsNull();
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::Transform
(const gp_Trsf2d& T)
{
TColgp_Array1OfPnt2d & CPoles = poles->ChangeArray1();
for (Standard_Integer I = 1; I <= CPoles.Length(); I++)
CPoles (I).Transform (T);
InvalidateCache();
// maxderivinvok = 0;
}
//=======================================================================
//function : LocateU
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::LocateU
(const Standard_Real U,
const Standard_Real ParametricTolerance,
Standard_Integer& I1,
Standard_Integer& I2,
const Standard_Boolean WithKnotRepetition) const
{
Standard_Real NewU = U;
Handle(TColStd_HArray1OfReal) TheKnots;
if (WithKnotRepetition) TheKnots = flatknots;
else TheKnots = knots;
const TColStd_Array1OfReal & CKnots = TheKnots->Array1();
PeriodicNormalization(NewU); //Attention a la periode
Standard_Real UFirst = CKnots (1);
Standard_Real ULast = CKnots (CKnots.Length());
if (Abs (NewU - UFirst) <= Abs(ParametricTolerance)) { I1 = I2 = 1; }
else if (Abs (U - ULast) <= Abs(ParametricTolerance)) {
I1 = I2 = CKnots.Length();
}
else if (NewU < UFirst - Abs(ParametricTolerance)) {
I2 = 1;
I1 = 0;
}
else if (NewU > ULast + Abs(ParametricTolerance)) {
I1 = CKnots.Length();
I2 = I1 + 1;
}
else {
I1 = 1;
BSplCLib::Hunt (CKnots, NewU, I1);
while ( Abs( CKnots(I1+1) - NewU) <= Abs(ParametricTolerance)) I1++;
if ( Abs( CKnots(I1) - NewU) <= Abs(ParametricTolerance)) {
I2 = I1;
}
else {
I2 = I1 + 1;
}
}
}
//=======================================================================
//function : Resolution
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::Resolution(const Standard_Real ToleranceUV,
Standard_Real & UTolerance)
{
Standard_Integer ii ;
if(!maxderivinvok){
if ( periodic) {
Standard_Integer NbKnots, NbPoles;
BSplCLib::PrepareUnperiodize( deg,
mults->Array1(),
NbKnots,
NbPoles);
TColgp_Array1OfPnt2d new_poles(1,NbPoles) ;
TColStd_Array1OfReal new_weights(1,NbPoles) ;
for(ii = 1 ; ii <= NbPoles ; ii++) {
new_poles(ii) = poles->Array1()(((ii-1) % poles->Length()) + 1) ;
}
if (rational) {
for(ii = 1 ; ii <= NbPoles ; ii++) {
new_weights(ii) = weights->Array1()(((ii-1) % poles->Length()) + 1) ;
}
BSplCLib::Resolution(new_poles,
new_weights,
new_poles.Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
else {
BSplCLib::Resolution(new_poles,
*((TColStd_Array1OfReal*) NULL),
new_poles.Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
}
else {
if (rational) {
BSplCLib::Resolution(poles->Array1(),
weights->Array1(),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
else {
BSplCLib::Resolution(poles->Array1(),
*((TColStd_Array1OfReal*) NULL),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
}
maxderivinvok = 1;
}
UTolerance = ToleranceUV * maxderivinv;
}

412
src/Geom2d/Geom2d_BezierCurve.cdl Executable file
View File

@@ -0,0 +1,412 @@
-- File: Geom2d_BezierCurve.cdl
-- Created: Wed Mar 24 17:46:55 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991, 1992
class BezierCurve from Geom2d inherits BoundedCurve from Geom2d
--- Purpose : Describes a rational or non-rational Bezier curve
-- - a non-rational Bezier curve is defined by a table
-- of poles (also called control points),
-- - a rational Bezier curve is defined by a table of
-- poles with varying weights.
-- These data are manipulated by two parallel arrays:
-- - the poles table, which is an array of gp_Pnt2d points, and
-- - the weights table, which is an array of reals.
-- The bounds of these arrays are 1 and "the number of poles" of the curve.
-- The poles of the curve are "control points" used to deform the curve.
-- The first pole is the start point of the curve, and the
-- last pole is the end point of the curve. The segment
-- which joins the first pole to the second pole is the
-- tangent to the curve at its start point, and the
-- segment which joins the last pole to the
-- second-from-last pole is the tangent to the curve
-- at its end point.
-- It is more difficult to give a geometric signification
-- to the weights but they are useful for providing
-- exact representations of the arcs of a circle or
-- ellipse. Moreover, if the weights of all the poles are
-- equal, the curve is polynomial; it is therefore a
-- non-rational curve. The non-rational curve is a
-- special and frequently used case. The weights are
-- defined and used only in case of a rational curve.
-- The degree of a Bezier curve is equal to the
-- number of poles, minus 1. It must be greater than or
-- equal to 1. However, the degree of a
-- Geom2d_BezierCurve curve is limited to a value
-- (25) which is defined and controlled by the system.
-- This value is returned by the function MaxDegree.
-- The parameter range for a Bezier curve is [ 0, 1 ].
-- If the first and last control points of the Bezier
-- curve are the same point then the curve is closed.
-- For example, to create a closed Bezier curve with
-- four control points, you have to give a set of control
-- points P1, P2, P3 and P1.
-- The continuity of a Bezier curve is infinite.
-- It is not possible to build a Bezier curve with
-- negative weights. We consider that a weight value
-- is zero if it is less than or equal to
-- gp::Resolution(). We also consider that
-- two weight values W1 and W2 are equal if:
-- |W2 - W1| <= gp::Resolution().
-- Warning
-- - When considering the continuity of a closed
-- Bezier curve at the junction point, remember that
-- a curve of this type is never periodic. This means
-- that the derivatives for the parameter u = 0
-- have no reason to be the same as the
-- derivatives for the parameter u = 1 even if the curve is closed.
-- - The length of a Bezier curve can be null.
uses Array1OfReal from TColStd,
HArray1OfReal from TColStd,
Array1OfPnt2d from TColgp,
Ax2d from gp,
Pnt2d from gp,
HArray1OfPnt2d from TColgp,
Vec2d from gp,
Trsf2d from gp,
Geometry from Geom2d,
Shape from GeomAbs
raises ConstructionError from Standard,
DimensionError from Standard,
RangeError from Standard,
OutOfRange from Standard
is
Create (CurvePoles : Array1OfPnt2d from TColgp) returns mutable BezierCurve
--- Purpose :
-- Creates a non rational Bezier curve with a set of poles :
-- CurvePoles. The weights are defaulted to all being 1.
-- Raises ConstructionError if the number of poles is greater than MaxDegree + 1
-- or lower than 2.
raises ConstructionError;
Create (CurvePoles : Array1OfPnt2d from TColgp;
PoleWeights : Array1OfReal from TColStd)
returns mutable BezierCurve
--- Purpose :
-- Creates a rational Bezier curve with the set of poles
-- CurvePoles and the set of weights PoleWeights .
-- If all the weights are identical the curve is considered
-- as non rational. Raises ConstructionError if
-- the number of poles is greater than MaxDegree + 1 or lower
-- than 2 or CurvePoles and CurveWeights have not the same length
-- or one weight value is lower or equal to Resolution from
-- package gp.
raises ConstructionError;
Increase (me : mutable; Degree : Integer)
--- Purpose :
-- Increases the degree of a bezier curve. Degree is the new
-- degree of <me>.
-- raises ConstructionError if Degree is greater than MaxDegree or lower than 2
-- or lower than the initial degree of <me>.
raises ConstructionError;
InsertPoleAfter (me : mutable; Index : Integer; P : Pnt2d;
Weight : Real = 1.0)
--- Purpose :
-- Inserts a pole with its weight in the set of poles after the
-- pole of range Index. If the curve was non rational it can
-- become rational if all the weights are not identical.
raises OutOfRange,
--- Purpose : Raised if Index is not in the range [0, NbPoles]
ConstructionError;
--- Purpose :
-- Raised if the resulting number of poles is greater than
-- MaxDegree + 1.
InsertPoleBefore (me : mutable; Index : Integer; P : Pnt2d;
Weight : Real = 1.0)
--- Purpose :
-- Inserts a pole with its weight in the set of poles after
-- the pole of range Index. If the curve was non rational it
-- can become rational if all the weights are not identical.
raises OutOfRange,
--- Purpose : Raised if Index is not in the range [1, NbPoles+1]
ConstructionError;
--- Purpose :
-- Raised if the resulting number of poles is greater than
-- MaxDegree + 1.
RemovePole (me : mutable; Index : Integer)
--- Purpose : Removes the pole of range Index.
-- If the curve was rational it can become non rational.
raises OutOfRange,
--- Purpose : Raised if Index is not in the range [1, NbPoles]
ConstructionError;
-- Purpose : Raised if Degree is lower than 2.
Reverse (me : mutable);
--- Purpose :
-- Reverses the direction of parametrization of <me>
-- Value (NewU) = Value (1 - OldU)
ReversedParameter(me; U : Real) returns Real;
---Purpose: Returns the parameter on the reversed curve for
-- the point of parameter U on <me>.
--
-- returns 1-U
Segment (me : mutable; U1, U2 : Real);
--- Purpose :
-- Segments the curve between U1 and U2 which can be out
-- of the bounds of the curve. The curve is oriented from U1
-- to U2.
-- The control points are modified, the first and the last point
-- are not the same but the parametrization range is [0, 1]
-- else it could not be a Bezier curve.
-- Warnings :
-- Even if <me> is not closed it can become closed after the
-- segmentation for example if U1 or U2 are out of the bounds
-- of the curve <me> or if the curve makes loop.
-- After the segmentation the length of a curve can be null.
SetPole (me : mutable; Index : Integer; P : Pnt2d)
--- Purpose :
-- Substitutes the pole of range index with P.
-- If the curve <me> is rational the weight of range Index
-- is not modified.
raises OutOfRange;
--- Purpose : raiseD if Index is not in the range [1, NbPoles]
SetPole (me : mutable; Index : Integer; P : Pnt2d; Weight : Real)
--- Purpose :
-- Substitutes the pole and the weights of range Index.
-- If the curve <me> is not rational it can become rational
-- if all the weights are not identical.
-- If the curve was rational it can become non rational if
-- all the weights are identical.
raises OutOfRange,
--- Purpose : Raised if Index is not in the range [1, NbPoles]
ConstructionError;
--- Purpose : Raised if Weight <= Resolution from package gp
SetWeight (me : mutable; Index : Integer; Weight : Real)
--- Purpose :
-- Changes the weight of the pole of range Index.
-- If the curve <me> is not rational it can become rational
-- if all the weights are not identical.
-- If the curve was rational it can become non rational if
-- all the weights are identical.
raises OutOfRange,
--- Purpose : Raised if Index is not in the range [1, NbPoles]
ConstructionError;
--- Purpose : Raised if Weight <= Resolution from package gp
IsClosed (me) returns Boolean;
--- Purpose :
-- Returns True if the distance between the first point
-- and the last point of the curve is lower or equal to
-- the Resolution from package gp.
IsCN (me; N : Integer) returns Boolean;
--- Purpose : Continuity of the curve, returns True.
IsPeriodic (me) returns Boolean;
--- Purpose :
-- Returns False. A BezierCurve cannot be periodic in this
-- package
IsRational (me) returns Boolean;
--- Purpose :
-- Returns false if all the weights are identical. The tolerance
-- criterion is Resolution from package gp.
Continuity (me) returns Shape from GeomAbs;
--- Purpose : Returns GeomAbs_CN, which is the continuity of any Bezier curve.
Degree (me) returns Integer;
--- Purpose :
-- Returns the polynomial degree of the curve. It is the number
-- of poles less one. In this package the Degree of a Bezier
-- curve cannot be greater than "MaxDegree".
D0 (me; U : Real; P : out Pnt2d);
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d);
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d);
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d);
DN (me; U : Real; N : Integer) returns Vec2d
--- Purpose : For this Bezier curve, computes
-- - the point P of parameter U, or
-- - the point P and one or more of the following values:
-- - V1, the first derivative vector,
-- - V2, the second derivative vector,
-- - V3, the third derivative vector.
-- Note: the parameter U can be outside the bounds of the curve.
-- Raises RangeError if N < 1.
raises RangeError;
EndPoint (me) returns Pnt2d;
--- Purpose : Returns the end point or start point of this Bezier curve.
FirstParameter (me) returns Real;
--- Purpose : Returns the value of the first parameter of this
-- Bezier curve. This is 0.0, which gives the start point of this Bezier curve.
LastParameter (me) returns Real;
--- Purpose : Returns the value of the last parameter of this
-- Bezier curve. This is 1.0, which gives the end point of this Bezier curve.
NbPoles (me) returns Integer;
---Purpose: Returns the number of poles for this Bezier curve.
Pole (me; Index : Integer) returns Pnt2d
--- Purpose : Returns the pole of range Index.
raises OutOfRange;
--- Purpose : Raised if Index is not in the range [1, NbPoles]
Poles (me; P : out Array1OfPnt2d from TColgp)
--- Purpose : Returns all the poles of the curve.
raises DimensionError;
--- Purpose :
-- Raised if the length of P is not equal to the number of poles.
StartPoint (me) returns Pnt2d;
--- Purpose :
-- Returns Value (U=1), it is the first control point
-- of the curve.
Weight (me; Index : Integer) returns Real
--- Purpose : Returns the weight of range Index.
raises OutOfRange;
--- Purpose : Raised if Index is not in the range [1, NbPoles]
Weights (me; W : out Array1OfReal from TColStd)
--- Purpose : Returns all the weights of the curve.
raises DimensionError;
--- Purpose :
-- Raised if the length of W is not equal to the number of poles.
Transform (me : mutable; T : Trsf2d);
---Purpose: Applies the transformation T to this Bezier curve.
MaxDegree (myclass) returns Integer;
--- Purpose:
-- Returns the value of the maximum polynomial degree of a
-- BezierCurve. This value is 25.
Resolution(me : mutable;
ToleranceUV : Real;
UTolerance : out Real);
---Purpose: Computes for this Bezier curve the parametric
-- tolerance UTolerance for a given tolerance
-- Tolerance3D (relative to dimensions in the plane).
-- If f(t) is the equation of this Bezier curve,
-- UTolerance ensures that
-- | t1 - t0| < Utolerance ===>
-- |f(t1) - f(t0)| < ToleranceUV
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this Bezier curve.
Init (me : mutable; Poles : HArray1OfPnt2d from TColgp;
Weights : HArray1OfReal from TColStd)
---Purpose : Set poles to Poles, weights to Weights (not
-- copied). If Weights is null the curve is non
-- rational. Create the arrays of coefficients. Poles
-- and Weights are assumed to have the first
-- coefficient 1.
--
-- Update rational and closed.
--
raises ConstructionError -- if nbpoles < 2 or nbboles > MaDegree + 1
is static private;
CoefficientsOK(me; U : Real) returns Boolean
---Purpose : returns true if the coefficients have been
-- computed with the right value of cacheparameter
-- for the given U value.
--
is static private;
UpdateCoefficients(me : mutable; U : Real from Standard = 0.0)
---Purpose: Recompute the coeficients.
is static private;
fields
rational : Boolean;
closed : Boolean;
poles : HArray1OfPnt2d from TColgp;
weights : HArray1OfReal from TColStd;
coeffs : HArray1OfPnt2d from TColgp;
wcoeffs : HArray1OfReal from TColStd;
validcache : Integer;
-- = 1 the cache is valid
-- = 0 the cache is invalid
parametercache : Real;
-- Parameter at which the Taylor expension is stored in
-- the cache, often 0., sometimes 1..
spanlenghtcache : Real;
-- always 1. for the moment.
-- usefull to evaluate the parametric resolution
maxderivinv : Real from Standard;
maxderivinvok : Boolean from Standard;
end;

918
src/Geom2d/Geom2d_BezierCurve.cxx Executable file
View File

@@ -0,0 +1,918 @@
// File: Geom2d_BezierCurve.cxx
// Created: Thu Mar 25 10:24:39 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
// File Geom2d_BezierCurve.cxx Septembre 1990
// Passage en classe persistante - 23/01/91
// Modif suite a la deuxieme revue de projet toolkit Geometry -23/01/91
// Infos :
// Actuellement pour les champs de la courbe le tableau des poles est
// declare de 1 a NbPoles et le tableau des poids est declare de 1 a NbPoles
// Revised RLE Aug 19 1993
// Suppressed Swaps, added Init, removed typedefs
#define No_Standard_OutOfRange
#define No_Standard_DimensionError
#include <Geom2d_BezierCurve.ixx>
#include <PLib.hxx>
#include <BSplCLib.hxx>
#include <gp.hxx>
#include <gp_XY.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_DimensionError.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_RangeError.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
//=======================================================================
//function : Rational
//purpose : check rationality of an array of weights
//=======================================================================
static Standard_Boolean Rational(const TColStd_Array1OfReal& W)
{
Standard_Integer i, n = W.Length();
Standard_Boolean rat = Standard_False;
for (i = 1; i < n; i++) {
rat = Abs(W(i) - W(i+1)) > gp::Resolution();
if (rat) break;
}
return rat;
}
//=======================================================================
//function : Geom2d_BezierCurve
//purpose :
//=======================================================================
Geom2d_BezierCurve::Geom2d_BezierCurve
(const TColgp_Array1OfPnt2d& Poles):
validcache(0), parametercache(0.), spanlenghtcache(1.)
{
// copy the poles
Handle(TColgp_HArray1OfPnt2d) npoles =
new TColgp_HArray1OfPnt2d(1,Poles.Length());
npoles->ChangeArray1() = Poles;
// Init non rational
Init(npoles,
Handle(TColStd_HArray1OfReal)());
}
//=======================================================================
//function : Geom2d_BezierCurve
//purpose :
//=======================================================================
Geom2d_BezierCurve::Geom2d_BezierCurve
(const TColgp_Array1OfPnt2d& Poles,
const TColStd_Array1OfReal& Weights):
validcache(0), parametercache(0.), spanlenghtcache(1.)
{
// copy the poles
Handle(TColgp_HArray1OfPnt2d) npoles =
new TColgp_HArray1OfPnt2d(1,Poles.Length());
npoles->ChangeArray1() = Poles;
// check the weights
Standard_Integer nbpoles = Poles.Length();
if (Weights.Length() != nbpoles)
Standard_ConstructionError::Raise();
Standard_Integer i;
for (i = 1; i <= nbpoles; i++) {
if (Weights(i) <= gp::Resolution()) {
Standard_ConstructionError::Raise();
}
}
// check really rational
Standard_Boolean rat = Rational(Weights);
// copy the weights
Handle(TColStd_HArray1OfReal) nweights;
if (rat) {
nweights = new TColStd_HArray1OfReal(1,nbpoles);
nweights->ChangeArray1() = Weights;
}
// Init
Init(npoles,nweights);
}
//=======================================================================
//function : Increase
//purpose : increase degree
//=======================================================================
void Geom2d_BezierCurve::Increase (const Standard_Integer Deg)
{
if (Deg == Degree()) return;
Standard_ConstructionError_Raise_if
(Deg < Degree() ||
Deg > Geom2d_BezierCurve::MaxDegree(), "Geom2d_BezierCurve::Increase");
Handle(TColgp_HArray1OfPnt2d) npoles =
new TColgp_HArray1OfPnt2d(1,Deg+1);
Handle(TColStd_HArray1OfReal) nweights;
TColStd_Array1OfReal bidknots(1,2); bidknots(1) = 0.; bidknots(2) = 1.;
TColStd_Array1OfInteger bidmults(1,2); bidmults.Init(Degree() + 1);
if (IsRational()) {
nweights = new TColStd_HArray1OfReal(1,Deg+1);
BSplCLib::IncreaseDegree(Degree(), Deg, 0,
poles->Array1(),weights->Array1(),
bidknots, bidmults,
npoles->ChangeArray1(),nweights->ChangeArray1(),
bidknots, bidmults);
}
else {
BSplCLib::IncreaseDegree(Degree(), Deg, 0,
poles->Array1(),
*((TColStd_Array1OfReal*) NULL),
bidknots, bidmults,
npoles->ChangeArray1(),
*((TColStd_Array1OfReal*) NULL),
bidknots, bidmults);
}
Init(npoles,nweights);
}
//=======================================================================
//function : MaxDegree
//purpose :
//=======================================================================
Standard_Integer Geom2d_BezierCurve::MaxDegree ()
{
return BSplCLib::MaxDegree();
}
//=======================================================================
//function : InsertPoleAfter
//purpose :
//=======================================================================
void Geom2d_BezierCurve::InsertPoleAfter
(const Standard_Integer Index,
const gp_Pnt2d& P,
const Standard_Real Weight)
{
Standard_Integer nbpoles = NbPoles();
Standard_ConstructionError_Raise_if
(nbpoles >= Geom2d_BezierCurve::MaxDegree() ||
Weight <= gp::Resolution(),
"Geom2d_BezierCurve::InsertPoleAfter" );
Standard_OutOfRange_Raise_if
(Index < 0 || Index > nbpoles,
"Geom2d_BezierCurve::InsertPoleAfter");
Standard_Integer i;
// Insert the pole
Handle(TColgp_HArray1OfPnt2d) npoles =
new TColgp_HArray1OfPnt2d(1,nbpoles+1);
TColgp_Array1OfPnt2d& newpoles = npoles->ChangeArray1();
const TColgp_Array1OfPnt2d& oldpoles = poles->Array1();
for (i = 1; i <= Index; i++)
newpoles(i) = oldpoles(i);
newpoles(Index+1) = P;
for (i = Index+1; i <= nbpoles; i++)
newpoles(i+1) = oldpoles(i);
// Insert the weight
Handle(TColStd_HArray1OfReal) nweights;
Standard_Boolean rat = IsRational() || Abs(Weight-1.) > gp::Resolution();
if (rat) {
nweights = new TColStd_HArray1OfReal(1,nbpoles+1);
TColStd_Array1OfReal& newweights = nweights->ChangeArray1();
for (i = 1; i <= Index; i++)
if (IsRational())
newweights(i) = weights->Value(i);
else
newweights(i) = 1.;
newweights(Index+1) = Weight;
for (i = Index+1; i <= nbpoles; i++)
if (IsRational())
newweights(i+1) = weights->Value(i);
else
newweights(i+1) = 1.;
}
Init(npoles,nweights);
}
//=======================================================================
//function : InsertPoleBefore
//purpose :
//=======================================================================
void Geom2d_BezierCurve::InsertPoleBefore
(const Standard_Integer Index,
const gp_Pnt2d& P,
const Standard_Real Weight)
{
InsertPoleAfter(Index-1,P,Weight);
}
//=======================================================================
//function : RemovePole
//purpose :
//=======================================================================
void Geom2d_BezierCurve::RemovePole
(const Standard_Integer Index)
{
Standard_Integer nbpoles = NbPoles();
Standard_ConstructionError_Raise_if
(nbpoles <= 2 , "Geom2d_BezierCurve::RemovePole" );
Standard_OutOfRange_Raise_if
(Index < 1 || Index > nbpoles,
"Geom2d_BezierCurve::RemovePole");
Standard_Integer i;
// Remove the pole
Handle(TColgp_HArray1OfPnt2d) npoles =
new TColgp_HArray1OfPnt2d(1,nbpoles-1);
TColgp_Array1OfPnt2d& newpoles = npoles->ChangeArray1();
const TColgp_Array1OfPnt2d& oldpoles = poles->Array1();
for (i = 1; i < Index; i++)
newpoles(i) = oldpoles(i);
for (i = Index+1; i <= nbpoles; i++)
newpoles(i-1) = oldpoles(i);
// Remove the weight
Handle(TColStd_HArray1OfReal) nweights;
if (IsRational()) {
nweights = new TColStd_HArray1OfReal(1,nbpoles-1);
TColStd_Array1OfReal& newweights = nweights->ChangeArray1();
const TColStd_Array1OfReal& oldweights = weights->Array1();
for (i = 1; i < Index; i++)
newweights(i) = oldweights(i);
for (i = Index+1; i <= nbpoles; i++)
newweights(i-1) = oldweights(i);
}
Init(npoles,nweights);
}
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
void Geom2d_BezierCurve::Reverse ()
{
gp_Pnt2d P;
Standard_Integer i, nbpoles = NbPoles();
TColgp_Array1OfPnt2d & cpoles = poles->ChangeArray1();
// reverse poles
for (i = 1; i <= nbpoles / 2; i++) {
P = cpoles(i);
cpoles(i) = cpoles(nbpoles-i+1);
cpoles(nbpoles-i+1) = P;
}
// reverse weights
if (IsRational()) {
TColStd_Array1OfReal & cweights = weights->ChangeArray1();
Standard_Real w;
for (i = 1; i <= nbpoles / 2; i++) {
w = cweights(i);
cweights(i) = cweights(nbpoles-i+1);
cweights(nbpoles-i+1) = w;
}
}
UpdateCoefficients();
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_BezierCurve::ReversedParameter
( const Standard_Real U) const
{
return ( 1. - U);
}
//=======================================================================
//function : Segment
//purpose :
//=======================================================================
void Geom2d_BezierCurve::Segment
(const Standard_Real U1, const Standard_Real U2)
{
closed = (Abs(Value(U1).Distance (Value(U2))) <= gp::Resolution());
//
// WARNING : when calling trimming be carefull that the cache
// is computed regarding 0.0e0 and not 1.0e0
//
if (IsRational()) {
PLib::Trimming(U1,U2,coeffs->ChangeArray1(),wcoeffs->ChangeArray1());
PLib::CoefficientsPoles(coeffs->Array1(),wcoeffs->Array1(),
poles->ChangeArray1(),weights->ChangeArray1());
}
else {
PLib::Trimming(U1,U2,coeffs->ChangeArray1(),
*((TColStd_Array1OfReal*) NULL));
PLib::CoefficientsPoles(coeffs->Array1(),
*((TColStd_Array1OfReal*) NULL),
poles->ChangeArray1(),
*((TColStd_Array1OfReal*) NULL));
}
UpdateCoefficients();
}
//=======================================================================
//function : SetPole
//purpose :
//=======================================================================
void Geom2d_BezierCurve::SetPole
(const Standard_Integer Index,
const gp_Pnt2d& P)
{
Standard_OutOfRange_Raise_if (Index < 1 || Index > NbPoles(),
"Geom2d_BezierCurve::SetPole");
TColgp_Array1OfPnt2d& cpoles = poles->ChangeArray1();
cpoles(Index) = P;
if (Index == 1 || Index == cpoles.Length()) {
closed = (cpoles(1).Distance(cpoles(NbPoles())) <= gp::Resolution());
}
UpdateCoefficients();
}
//=======================================================================
//function : SetPole
//purpose :
//=======================================================================
void Geom2d_BezierCurve::SetPole
(const Standard_Integer Index,
const gp_Pnt2d& P,
const Standard_Real Weight)
{
SetPole(Index,P);
SetWeight(Index,Weight);
}
//=======================================================================
//function : SetWeight
//purpose :
//=======================================================================
void Geom2d_BezierCurve::SetWeight
(const Standard_Integer Index,
const Standard_Real Weight)
{
Standard_Integer nbpoles = NbPoles();
Standard_OutOfRange_Raise_if
(Index < 1 || Index > nbpoles,
"Geom2d_BezierCurve::SetWeight");
Standard_ConstructionError_Raise_if
(Weight <= gp::Resolution (),
"Geom2d_BezierCurve::SetWeight");
// compute new rationality
Standard_Boolean wasrat = IsRational();
if (!wasrat) {
// a weight of 1. does not turn to rational
if (Abs(Weight - 1.) <= gp::Resolution()) return;
// set weights of 1.
weights = new TColStd_HArray1OfReal(1,nbpoles);
wcoeffs = new TColStd_HArray1OfReal(1,nbpoles);
weights->Init(1.);
}
TColStd_Array1OfReal & cweights = weights->ChangeArray1();
cweights(Index) = Weight;
// is it turning into non rational
if (wasrat) {
if (!Rational(cweights)) {
weights.Nullify();
wcoeffs.Nullify();
}
}
UpdateCoefficients();
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2d_BezierCurve::IsClosed () const
{
return closed;
}
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom2d_BezierCurve::IsCN (const Standard_Integer ) const
{
return Standard_True;
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2d_BezierCurve::IsPeriodic () const
{
return Standard_False;
}
//=======================================================================
//function : IsRational
//purpose :
//=======================================================================
Standard_Boolean Geom2d_BezierCurve::IsRational () const
{
return !weights.IsNull();
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom2d_BezierCurve::Continuity () const
{
return GeomAbs_CN;
}
//=======================================================================
//function : Degree
//purpose :
//=======================================================================
Standard_Integer Geom2d_BezierCurve::Degree () const
{
return poles->Length()-1;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2d_BezierCurve::D0 (const Standard_Real U, gp_Pnt2d& P ) const
{
// Idee lumineuse sacrifiee sur l autel des performances.
//
// if(!CoefficientsOK(U))
// ((Geom2d_BezierCurve*)(void*)this)->UpdateCoefficients(U);
if (IsRational())
BSplCLib::CacheD0(U,Degree(),parametercache,spanlenghtcache,
coeffs->Array1(),wcoeffs->Array1(),P);
else
BSplCLib::CacheD0(U,Degree(),parametercache,spanlenghtcache,
coeffs->Array1(),
*((TColStd_Array1OfReal*) NULL),
P);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_BezierCurve::D1(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1) const
{
// Idee lumineuse sacrifiee sur l autel des performances.
//
// if(!CoefficientsOK(U))
// ((Geom2d_BezierCurve*)(void*)this)->UpdateCoefficients(U);
if (IsRational())
BSplCLib::CacheD1(U,Degree(),parametercache,spanlenghtcache,
coeffs->Array1(),wcoeffs->Array1(),P,V1);
else
BSplCLib::CacheD1(U,Degree(),parametercache,spanlenghtcache,
coeffs->Array1(),
*((TColStd_Array1OfReal*) NULL),
P,V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_BezierCurve::D2 (const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2) const
{
// Idee lumineuse sacrifiee sur l autel des performances.
//
// if(!CoefficientsOK(U))
// ((Geom2d_BezierCurve*)(void*)this)->UpdateCoefficients(U);
if (IsRational())
BSplCLib::CacheD2(U,Degree(),parametercache,spanlenghtcache,
coeffs->Array1(),wcoeffs->Array1(),P,V1,V2);
else
BSplCLib::CacheD2(U,Degree(),parametercache,spanlenghtcache,
coeffs->Array1(),
*((TColStd_Array1OfReal*) NULL),
P,V1,V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2d_BezierCurve::D3 (const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
{
// Idee lumineuse sacrifiee sur l autel des performances.
//
// if(!CoefficientsOK(U))
// ((Geom2d_BezierCurve*)(void*)this)->UpdateCoefficients(U);
if (IsRational())
BSplCLib::CacheD3(U,Degree(),parametercache,spanlenghtcache,
coeffs->Array1(),wcoeffs->Array1(),P,V1,V2,V3);
else
BSplCLib::CacheD3(U,Degree(),parametercache,spanlenghtcache,
coeffs->Array1(),
*((TColStd_Array1OfReal*) NULL),
P,V1,V2,V3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
gp_Vec2d Geom2d_BezierCurve::DN (const Standard_Real U,
const Standard_Integer N) const
{
Standard_RangeError_Raise_if (N < 1, "Geom2d_BezierCurve::DN");
gp_Vec2d V;
TColStd_Array1OfReal bidknots(1,2); bidknots(1) = 0.; bidknots(2) = 1.;
TColStd_Array1OfInteger bidmults(1,2); bidmults.Init(Degree() + 1);
if (IsRational())
BSplCLib::DN(U,N,0,Degree(),Standard_False,
poles->Array1(),weights->Array1(),
bidknots,bidmults,V);
else
BSplCLib::DN(U,N,0,Degree(),Standard_False,
poles->Array1(),
*((TColStd_Array1OfReal*) NULL),
bidknots,bidmults,V);
return V;
}
//=======================================================================
//function : EndPoint
//purpose :
//=======================================================================
gp_Pnt2d Geom2d_BezierCurve::EndPoint () const
{
return poles->Value (poles->Upper());
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_BezierCurve::FirstParameter () const
{
return 0.0;
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_BezierCurve::LastParameter () const
{
return 1.0;
}
//=======================================================================
//function : NbPoles
//purpose :
//=======================================================================
Standard_Integer Geom2d_BezierCurve::NbPoles () const
{
return poles->Length();
}
//=======================================================================
//function : Pole
//purpose :
//=======================================================================
gp_Pnt2d Geom2d_BezierCurve::Pole (const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if (Index < 1 || Index > poles->Length(),
"Geom2d_BezierCurve::Pole");
return poles->Value(Index);
}
//=======================================================================
//function : Poles
//purpose :
//=======================================================================
void Geom2d_BezierCurve::Poles (TColgp_Array1OfPnt2d& P) const
{
Standard_DimensionError_Raise_if (P.Length() != poles->Length(),
"Geom2d_BezierCurve::Poles");
P = poles->Array1();
}
//=======================================================================
//function : StartPoint
//purpose :
//=======================================================================
gp_Pnt2d Geom2d_BezierCurve::StartPoint () const
{
return poles->Value(1);
}
//=======================================================================
//function : Weight
//purpose :
//=======================================================================
Standard_Real Geom2d_BezierCurve::Weight
(const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if (Index < 1 || Index > weights->Length(),
"Geom2d_BezierCurve::Weight");
if (IsRational())
return weights->Value(Index);
else
return 1.;
}
//=======================================================================
//function : Weights
//purpose :
//=======================================================================
void Geom2d_BezierCurve::Weights
(TColStd_Array1OfReal& W) const
{
Standard_Integer nbpoles = NbPoles();
Standard_DimensionError_Raise_if (W.Length() != nbpoles,
"Geom2d_BezierCurve::Weights");
if (IsRational())
W = weights->Array1();
else {
Standard_Integer i;
for (i = 1; i <= nbpoles; i++)
W(i) = 1.;
}
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom2d_BezierCurve::Transform (const gp_Trsf2d& T)
{
Standard_Integer nbpoles = NbPoles();
TColgp_Array1OfPnt2d & cpoles = poles->ChangeArray1();
for (Standard_Integer i = 1; i <= nbpoles; i++)
cpoles (i).Transform(T);
UpdateCoefficients();
}
//=======================================================================
//function : Resolution
//purpose :
//=======================================================================
void Geom2d_BezierCurve::Resolution(const Standard_Real ToleranceUV,
Standard_Real & UTolerance)
{
if(!maxderivinvok){
TColStd_Array1OfReal bidflatknots(1, 2*(Degree()+1));
for(Standard_Integer i = 1; i <= Degree()+1; i++){
bidflatknots(i) = 0.;
bidflatknots(i + Degree() +1) = 1.;
}
if (IsRational()) {
BSplCLib::Resolution(poles->Array1(),
weights->Array1(),
poles->Length(),
bidflatknots,
Degree(),
1.,
maxderivinv) ;
}
else {
BSplCLib::Resolution(poles->Array1(),
*((TColStd_Array1OfReal*) NULL),
poles->Length(),
bidflatknots,
Degree(),
1.,
maxderivinv) ;
}
maxderivinvok = 1;
}
UTolerance = ToleranceUV * maxderivinv;
}
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom2d_Geometry) Geom2d_BezierCurve::Copy() const {
Handle(Geom2d_BezierCurve) C;
if (IsRational())
C = new Geom2d_BezierCurve (poles->Array1(),weights->Array1());
else
C = new Geom2d_BezierCurve (poles->Array1());
return C;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void Geom2d_BezierCurve::Init
(const Handle(TColgp_HArray1OfPnt2d)& Poles,
const Handle(TColStd_HArray1OfReal)& Weights)
{
Standard_Integer nbpoles = Poles->Length();
// closed ?
const TColgp_Array1OfPnt2d& cpoles = Poles->Array1();
closed = cpoles(1).Distance(cpoles(nbpoles)) <= gp::Resolution();
// rational
rational = !Weights.IsNull();
// set fields
poles = Poles;
coeffs = new TColgp_HArray1OfPnt2d (1,nbpoles);
if (rational) {
weights = Weights;
wcoeffs = new TColStd_HArray1OfReal (1, nbpoles, 0.0);
}
else {
weights.Nullify();
wcoeffs.Nullify();
}
UpdateCoefficients();
}
//=======================================================================
//function : CoefficientsOK
//purpose :
//=======================================================================
//Standard_Boolean Geom2d_BezierCurve::CoefficientsOK(const Standard_Real U)const
Standard_Boolean Geom2d_BezierCurve::CoefficientsOK(const Standard_Real )const
{
return (validcache) ;
}
//=======================================================================
//function : UpdateCoefficients
//purpose :
//=======================================================================
//void Geom2d_BezierCurve::UpdateCoefficients(const Standard_Real U)
void Geom2d_BezierCurve::UpdateCoefficients(const Standard_Real )
{
maxderivinvok = 0;
parametercache = 0.;
//
// Idee lumineuse sacrifiee sur l autel des performances.
// if (U >= 1.) parametercache = 1.;
TColStd_Array1OfReal bidflatknots(BSplCLib::FlatBezierKnots(Degree()),
1, 2*(Degree()+1));
if (IsRational())
BSplCLib::BuildCache(parametercache,spanlenghtcache,0,Degree(),
bidflatknots,poles->Array1(),weights->Array1(),
coeffs->ChangeArray1(),wcoeffs->ChangeArray1());
else
BSplCLib::BuildCache(parametercache,spanlenghtcache,0,Degree(),
bidflatknots,poles->Array1(),
*((TColStd_Array1OfReal*) NULL),
coeffs->ChangeArray1(),
*((TColStd_Array1OfReal*) NULL));
validcache = 1;
}

View File

@@ -0,0 +1,49 @@
-- File: Geom2d_BoundedCurve.cdl
-- Created: Wed Mar 24 17:54:32 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
deferred class BoundedCurve from Geom2d inherits Curve from Geom2d
--- Purpose : The abstract class BoundedCurve describes the
-- common behavior of bounded curves in 2D space. A
-- bounded curve is limited by two finite values of the
-- parameter, termed respectively "first parameter" and
-- "last parameter". The "first parameter" gives the "start
-- point" of the bounded curve, and the "last parameter"
-- gives the "end point" of the bounded curve.
-- The length of a bounded curve is finite.
-- The Geom2d package provides three concrete
-- classes of bounded curves:
-- - two frequently used mathematical formulations of complex curves:
-- - Geom2d_BezierCurve,
-- - Geom2d_BSplineCurve, and
-- - Geom2d_TrimmedCurve to trim a curve, i.e. to
-- only take part of the curve limited by two values of
-- the parameter of the basis curve.
uses Pnt2d from gp
is
EndPoint (me) returns Pnt2d is deferred;
--- Purpose :
-- Returns the end point of the curve.
-- The end point is the value of the curve for the
-- "LastParameter" of the curve.
StartPoint (me) returns Pnt2d is deferred;
--- Purpose :
-- Returns the start point of the curve.
-- The start point is the value of the curve for the
-- "FirstParameter" of the curve.
end;

View File

@@ -0,0 +1,11 @@
// File: Geom2d_BoundedCurve.cxx
// Created: Wed Mar 24 19:19:16 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_BoundedCurve.cxx, JCV 12/07/91
#include <Geom2d_BoundedCurve.ixx>

View File

@@ -0,0 +1,80 @@
-- File: Geom2d_CartesianPoint.cdl
-- Created: Wed Mar 24 17:56:19 1993
-- Author: Philippe DAUTRY
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
class CartesianPoint from Geom2d inherits Point from Geom2d
--- Purpose : Describes a point in 2D space. A
-- Geom2d_CartesianPoint is defined by a gp_Pnt2d
-- point, with its two Cartesian coordinates X and Y.
uses Ax2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp,
Geometry from Geom2d
is
Create (P : Pnt2d) returns mutable CartesianPoint;
--- Purpose : Returns a persistent copy of P.
Create (X, Y : Real) returns mutable CartesianPoint;
SetCoord (me : mutable; X, Y : Real);
--- Purpose : Set <me> to X, Y coordinates.
SetPnt2d (me : mutable; P : Pnt2d);
--- Purpose : Set <me> to P.X(), P.Y() coordinates.
SetX (me : mutable; X : Real);
--- Purpose : Changes the X coordinate of me.
SetY (me : mutable; Y : Real);
--- Purpose : Changes the Y coordinate of me.
Coord (me; X, Y : out Real);
--- Purpose : Returns the coordinates of <me>.
Pnt2d (me) returns Pnt2d;
--- Purpose :
-- Returns a non persistent cartesian point with
-- the same coordinates as <me>.
-- -C++: return const&
X (me) returns Real;
--- Purpose : Returns the X coordinate of <me>.
Y (me) returns Real;
--- Purpose : Returns the Y coordinate of <me>.
Transform (me : mutable; T : Trsf2d);
Copy (me) returns mutable like me;
fields
gpPnt2d : Pnt2d;
end;

View File

@@ -0,0 +1,60 @@
// File: Geom2d_CartesianPoint.cxx
// Created: Wed Mar 24 19:19:34 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_CartesianPoint.cxx, JCV 23/06/91
#include <Geom2d_CartesianPoint.ixx>
typedef Geom2d_CartesianPoint CartesianPoint;
typedef Handle(Geom2d_CartesianPoint) Handle(CartesianPoint);
typedef gp_Ax2d Ax2d;
typedef gp_Vec2d Vec2d;
typedef gp_Trsf2d Trsf2d;
Geom2d_CartesianPoint::Geom2d_CartesianPoint (const gp_Pnt2d& P) : gpPnt2d (P)
{}
Geom2d_CartesianPoint::Geom2d_CartesianPoint (const Standard_Real X, const Standard_Real Y)
: gpPnt2d (X , Y) { }
Handle(Geom2d_Geometry) Geom2d_CartesianPoint::Copy() const {
Handle(CartesianPoint) P;
P = new CartesianPoint (gpPnt2d);
return P;
}
void Geom2d_CartesianPoint::SetCoord (const Standard_Real X, const Standard_Real Y) {
gpPnt2d.SetCoord (X, Y);
}
void Geom2d_CartesianPoint::Coord (Standard_Real& X, Standard_Real& Y) const {
gpPnt2d.Coord (X, Y);
}
void Geom2d_CartesianPoint::SetPnt2d (const gp_Pnt2d& P) { gpPnt2d = P; }
void Geom2d_CartesianPoint::SetX (const Standard_Real X) { gpPnt2d.SetX (X); }
void Geom2d_CartesianPoint::SetY (const Standard_Real Y) { gpPnt2d.SetY (Y); }
gp_Pnt2d Geom2d_CartesianPoint::Pnt2d () const { return gpPnt2d; }
Standard_Real Geom2d_CartesianPoint::X () const { return gpPnt2d.X(); }
Standard_Real Geom2d_CartesianPoint::Y () const { return gpPnt2d.Y(); }
void Geom2d_CartesianPoint::Transform (const Trsf2d& T) {
gpPnt2d.Transform (T);
}

173
src/Geom2d/Geom2d_Circle.cdl Executable file
View File

@@ -0,0 +1,173 @@
-- File: Geom2d_Circle.cdl
-- Created: Wed Mar 24 17:56:51 1993
-- Author: Philippe DAUTRY
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991, 1992
class Circle from Geom2d inherits Conic from Geom2d
--- Purpose : Describes a circle in the plane (2D space).
-- A circle is defined by its radius and, as with any conic
-- curve, is positioned in the plane with a coordinate
-- system (gp_Ax22d object) where the origin is the
-- center of the circle.
-- The coordinate system is the local coordinate
-- system of the circle.
-- The orientation (direct or indirect) of the local
-- coordinate system gives an explicit orientation to the
-- circle, determining the direction in which the
-- parameter increases along the circle.
-- The Geom2d_Circle circle is parameterized by an angle:
-- P(U) = O + R*Cos(U)*XDir + R*Sin(U)*YDir
-- where:
-- - P is the point of parameter U,
-- - O, XDir and YDir are respectively the origin, "X
-- Direction" and "Y Direction" of its local coordinate system,
-- - R is the radius of the circle.
-- The "X Axis" of the local coordinate system therefore
-- defines the origin of the parameter of the circle. The
-- parameter is the angle with this "X Direction".
-- A circle is a closed and periodic curve. The period is
-- 2.*Pi and the parameter range is [ 0,2.*Pi [.
-- See Also
-- GCE2d_MakeCircle which provides functions for
-- more complex circle constructions
-- gp_Ax22d and gp_Circ2d for an equivalent, non-parameterized data structure.
uses Ax2d from gp,
Ax22d from gp,
Circ2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp,
Geometry from Geom2d
raises ConstructionError from Standard,
RangeError from Standard
is
Create (C : Circ2d) returns mutable Circle;
--- Purpose : Constructs a circle by conversion of the gp_Circ2d circle C.
Create (A : Ax2d; Radius : Real;
Sense: Boolean from Standard = Standard_True)
returns mutable Circle
--- Purpose : Constructs a circle of radius Radius, whose center is the origin of axis
-- A; A is the "X Axis" of the local coordinate system
-- of the circle; this coordinate system is direct if
-- Sense is true (default value) or indirect if Sense is false.
-- Note: It is possible to create a circle where Radius is equal to 0.0.
-- Exceptions Standard_ConstructionError if Radius is negative.
raises ConstructionError;
Create (A : Ax22d; Radius : Real) returns mutable Circle
--- Purpose : Constructs a circle
-- of radius Radius, where the coordinate system A
-- locates the circle and defines its orientation in the plane such that:
-- - the center of the circle is the origin of A,
-- - the orientation (direct or indirect) of A gives the
-- orientation of the circle.
raises ConstructionError;
SetCirc2d (me : mutable; C : Circ2d);
--- Purpose :
-- Converts the gp_Circ2d circle C into this circle.
SetRadius (me : mutable; R : Real)
--- Warnings : Assigns the value R to the radius of this circle.
-- Note: It is possible to have a circle with a radius equal to 0.0.
-- Exceptions Standard_ConstructionError if R is negative.
raises ConstructionError;
Circ2d (me) returns Circ2d;
--- Purpose :
-- Returns the non persistent circle from gp with the same
-- geometric properties as <me>.
Radius(me) returns Real
is static;
---Purpose: Returns the radius of this circle.
ReversedParameter(me; U : Real) returns Real is redefined static;
---Purpose: Computes the parameter on the reversed circle for
-- the point of parameter U on this circle.
-- For a circle, the returned value is: 2.*Pi - U.
Eccentricity (me) returns Real is redefined static;
--- Purpose : Returns 0., which is the eccentricity of any circle.
FirstParameter (me) returns Real is redefined static;
--- Purpose : Returns 0.0
LastParameter (me) returns Real is redefined static;
--- Purpose : Returns 2*PI.
IsClosed (me) returns Boolean is redefined static;
--- Purpose : returns True.
IsPeriodic (me) returns Boolean is redefined static;
--- Purpose : returns True. The period of a circle is 2.*Pi.
D0(me; U : Real; P : out Pnt2d) is redefined static;
---Purpose: Returns in P the point of parameter U.
-- P = C + R * Cos (U) * XDir + R * Sin (U) * YDir
-- where C is the center of the circle , XDir the XDirection and
-- YDir the YDirection of the circle's local coordinate system.
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U and the first derivative V1.
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2.
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter u, the first second and third
-- derivatives V1 V2 and V3.
DN (me; U : Real; N : Integer) returns Vec2d
--- Purpose : For the point of parameter U of this circle, computes
-- the vector corresponding to the Nth derivative.
-- Exceptions: Standard_RangeError if N is less than 1.
raises RangeError
is redefined static;
Transform (me : mutable; T : Trsf2d) is redefined static;
---Purpose: Applies the transformation T to this circle.
Copy (me) returns mutable like me
is redefined static;
---Purpose: Creates a new object which is a copy of this circle.
fields
radius : Real;
end;

256
src/Geom2d/Geom2d_Circle.cxx Executable file
View File

@@ -0,0 +1,256 @@
// File: Geom2d_Circle.cxx
// Created: Wed Mar 24 19:20:00 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Circle.cxx, JCV 12/07/91
#include <Geom2d_Circle.ixx>
#include <ElCLib.hxx>
#include <gp_XY.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_ConstructionError.hxx>
typedef Geom2d_Circle Circle;
typedef Handle(Geom2d_Circle) Handle(Circle);
typedef gp_Ax2d Ax2d;
typedef gp_Dir2d Dir2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Trsf2d Trsf2d;
typedef gp_Vec2d Vec2d;
typedef gp_XY XY;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom2d_Geometry) Geom2d_Circle::Copy() const
{
Handle(Circle) C;
C = new Circle (pos, radius);
return C;
}
//=======================================================================
//function : Geom2d_Circle
//purpose :
//=======================================================================
Geom2d_Circle::Geom2d_Circle (const gp_Circ2d& C) : radius (C.Radius()) {
pos = C.Axis();
}
//=======================================================================
//function : Geom2d_Circle
//purpose :
//=======================================================================
Geom2d_Circle::Geom2d_Circle (const Ax2d& A, const Standard_Real Radius,
const Standard_Boolean Sense)
: radius(Radius) {
if (Radius < 0.0) { Standard_ConstructionError::Raise(); }
pos = gp_Ax22d(A, Sense);
}
//=======================================================================
//function : Geom2d_Circle
//purpose :
//=======================================================================
Geom2d_Circle::Geom2d_Circle (const gp_Ax22d& A, const Standard_Real Radius)
: radius (Radius) {
if (Radius < 0.0) { Standard_ConstructionError::Raise(); }
pos = A;
}
//=======================================================================
//function : SetCirc2d
//purpose :
//=======================================================================
void Geom2d_Circle::SetCirc2d (const gp_Circ2d& C) {
radius = C.Radius();
pos = C.Axis();
}
//=======================================================================
//function : SetRadius
//purpose :
//=======================================================================
void Geom2d_Circle::SetRadius (const Standard_Real R)
{
if (R < 0.0) { Standard_ConstructionError::Raise(); }
radius = R;
}
//=======================================================================
//function : Radius
//purpose :
//=======================================================================
Standard_Real Geom2d_Circle::Radius () const
{
return radius;
}
//=======================================================================
//function : Circ2d
//purpose :
//=======================================================================
gp_Circ2d Geom2d_Circle::Circ2d () const
{
return gp_Circ2d (pos, radius);
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Circle::ReversedParameter( const Standard_Real U) const
{
return (2. * PI - U);
}
//=======================================================================
//function : Eccentricity
//purpose :
//=======================================================================
Standard_Real Geom2d_Circle::Eccentricity () const
{
return 0.0;
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Circle::FirstParameter () const
{
return 0.0;
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Circle::LastParameter () const
{
return 2.0 * PI;
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Circle::IsClosed () const
{
return Standard_True;
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Circle::IsPeriodic () const
{
return Standard_True;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2d_Circle::D0 (const Standard_Real U,
Pnt2d& P) const
{
P= ElCLib::CircleValue (U, pos, radius);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_Circle::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const
{
ElCLib::CircleD1 (U, pos, radius, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_Circle::D2 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2) const
{
ElCLib::CircleD2 (U, pos, radius, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2d_Circle::D3 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2, Vec2d& V3) const
{
ElCLib::CircleD3 (U, pos, radius, P, V1, V2, V3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec2d Geom2d_Circle::DN (const Standard_Real U, const Standard_Integer N) const
{
Standard_RangeError_Raise_if (N < 1," ");
return ElCLib::CircleDN (U, pos, radius, N);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom2d_Circle::Transform (const Trsf2d& T)
{
radius = radius * Abs(T.ScaleFactor());
pos.Transform (T);
}

134
src/Geom2d/Geom2d_Conic.cdl Executable file
View File

@@ -0,0 +1,134 @@
-- File: Geom2d_Conic.cdl
-- Created: Wed Mar 24 17:59:38 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
deferred class Conic from Geom2d inherits Curve from Geom2d
--- Purpose : The abstract class Conic describes the common
-- behavior of conic curves in 2D space and, in
-- particular, their general characteristics. The Geom2d
-- package provides four specific classes of conics:
-- Geom2d_Circle, Geom2d_Ellipse,
-- Geom2d_Hyperbola and Geom2d_Parabola.
-- A conic is positioned in the plane with a coordinate
-- system (gp_Ax22d object), where the origin is the
-- center of the conic (or the apex in case of a parabola).
-- This coordinate system is the local coordinate
-- system of the conic. It gives the conic an explicit
-- orientation, determining the direction in which the
-- parameter increases along the conic. The "X Axis" of
-- the local coordinate system also defines the origin of
-- the parameter of the conic.
uses Ax2d from gp,
Ax22d from gp,
Pnt2d from gp,
Vec2d from gp,
Shape from GeomAbs
raises ConstructionError from Standard,
DomainError from Standard
is
SetAxis (me: mutable; A: Ax22d);
---Purpose: Modifies this conic, redefining its local coordinate system
-- partially, by assigning P as its origin
SetXAxis (me : mutable; A : Ax2d);
SetYAxis (me : mutable; A : Ax2d);
---Purpose: Assigns the origin and unit vector of axis A to the
-- origin of the local coordinate system of this conic and either:
-- - its "X Direction", or
-- - its "Y Direction".
-- The other unit vector of the local coordinate system
-- of this conic is recomputed normal to A, without
-- changing the orientation of the local coordinate
-- system (right-handed or left-handed).
SetLocation (me : mutable; P : Pnt2d);
--- Purpose : Modifies this conic, redefining its local coordinate
-- system fully, by assigning A as this coordinate system.
XAxis (me) returns Ax2d;
--- Purpose :
-- Returns the "XAxis" of the conic.
-- This axis defines the origin of parametrization of the conic.
-- This axis and the "Yaxis" define the local coordinate system
-- of the conic.
-- -C++: return const&
YAxis (me) returns Ax2d;
--- Purpose :
-- Returns the "YAxis" of the conic.
-- The "YAxis" is perpendicular to the "Xaxis".
Eccentricity (me) returns Real
--- Purpose :
-- returns the eccentricity value of the conic e.
-- e = 0 for a circle
-- 0 < e < 1 for an ellipse (e = 0 if MajorRadius = MinorRadius)
-- e > 1 for a hyperbola
-- e = 1 for a parabola
raises DomainError
is deferred;
Location (me) returns Pnt2d;
--- Purpose :
-- Returns the location point of the conic.
-- For the circle, the ellipse and the hyperbola it is the center of
-- the conic. For the parabola it is the vertex of the parabola.
Position (me) returns Ax22d;
---Purpose :
-- Returns the local coordinates system of the conic.
---C++: return const&
Reverse (me : mutable);
--- Purpose :
-- Reverses the direction of parameterization of <me>.
-- The local coordinate system of the conic is modified.
ReversedParameter(me; U : Real) returns Real
---Purpose: Returns the parameter on the reversed curve for
-- the point of parameter U on <me>.
--
is deferred;
Continuity (me) returns Shape from GeomAbs;
--- Purpose : Returns GeomAbs_CN which is the global continuity of any conic.
IsCN (me; N : Integer) returns Boolean;
--- Purpose :
-- Returns True, the order of continuity of a conic is infinite.
fields
pos : Ax22d is protected;
end;

136
src/Geom2d/Geom2d_Conic.cxx Executable file
View File

@@ -0,0 +1,136 @@
// File: Geom2d_Conic.cxx
// Created: Wed Mar 24 19:20:16 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Conic.cx, JCV 12/07/91
#include <Geom2d_Conic.ixx>
#include <gp_Dir2d.hxx>
typedef Geom2d_Conic Conic;
typedef Handle(Geom2d_Conic) Handle(Conic);
typedef gp_Ax2d Ax2d;
typedef gp_Dir2d Dir2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Vec2d Vec2d;
//=======================================================================
//function : SetAxis
//purpose :
//=======================================================================
void Geom2d_Conic::SetAxis(const gp_Ax22d& A)
{
pos.SetAxis(A);
}
//=======================================================================
//function : SetXAxis
//purpose :
//=======================================================================
void Geom2d_Conic::SetXAxis (const Ax2d& A)
{
pos.SetXAxis(A);
}
//=======================================================================
//function : SetYAxis
//purpose :
//=======================================================================
void Geom2d_Conic::SetYAxis (const Ax2d& A)
{
pos.SetYAxis(A);
}
//=======================================================================
//function : SetLocation
//purpose :
//=======================================================================
void Geom2d_Conic::SetLocation (const Pnt2d& P)
{
pos.SetLocation (P);
}
//=======================================================================
//function : XAxis
//purpose :
//=======================================================================
Ax2d Geom2d_Conic::XAxis () const
{
return gp_Ax2d(pos.Location(), pos.XDirection());
}
//=======================================================================
//function : YAxis
//purpose :
//=======================================================================
Ax2d Geom2d_Conic::YAxis () const
{
return gp_Ax2d(pos.Location(), pos.YDirection());
}
//=======================================================================
//function : Location
//purpose :
//=======================================================================
Pnt2d Geom2d_Conic::Location () const
{
return pos.Location();
}
//=======================================================================
//function : Position
//purpose :
//=======================================================================
const gp_Ax22d& Geom2d_Conic::Position () const
{
return pos;
}
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
void Geom2d_Conic::Reverse () {
Dir2d Temp = pos.YDirection ();
Temp.Reverse ();
pos.SetAxis(gp_Ax22d(pos.Location(), pos.XDirection(), Temp));
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom2d_Conic::Continuity () const
{
return GeomAbs_CN;
}
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Conic::IsCN (const Standard_Integer ) const
{
return Standard_True;
}

255
src/Geom2d/Geom2d_Curve.cdl Executable file
View File

@@ -0,0 +1,255 @@
-- File: Geom2d_Curve.cdl
-- Created: Wed Mar 24 18:00:39 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991, 1992
deferred class Curve from Geom2d inherits Geometry from Geom2d
--- Purpose : The abstract class Curve describes the common
-- behavior of curves in 2D space. The Geom2d
-- package provides numerous concrete classes of
-- derived curves, including lines, circles, conics, Bezier
-- or BSpline curves, etc.
-- The main characteristic of these curves is that they
-- are parameterized. The Geom2d_Curve class shows:
-- - how to work with the parametric equation of a
-- curve in order to calculate the point of parameter
-- u, together with the vector tangent and the
-- derivative vectors of order 2, 3,..., N at this point;
-- - how to obtain general information about the curve
-- (for example, level of continuity, closed
-- characteristics, periodicity, bounds of the parameter field);
-- - how the parameter changes when a geometric
-- transformation is applied to the curve or when the
-- orientation of the curve is inverted.
-- All curves must have a geometric continuity: a curve is
-- at least "C0". Generally, this property is checked at
-- the time of construction or when the curve is edited.
-- Where this is not the case, the documentation
-- explicitly states so.
-- Warning
-- The Geom2d package does not prevent the
-- construction of curves with null length or curves which
-- self-intersect.
uses Pnt2d from gp,
Vec2d from gp,
Trsf2d from gp,
Shape from GeomAbs
raises RangeError from Standard,
NoSuchObject from Standard,
UndefinedDerivative from Geom2d,
UndefinedValue from Geom2d
is
Reverse (me : mutable)
--- Purpose :
-- Changes the direction of parametrization of <me>.
-- The "FirstParameter" and the "LastParameter" are not changed
-- but the orientation of the curve is modified. If the curve
-- is bounded the StartPoint of the initial curve becomes the
-- EndPoint of the reversed curve and the EndPoint of the initial
-- curve becomes the StartPoint of the reversed curve.
is deferred;
ReversedParameter(me; U : Real) returns Real
---Purpose: Computes the parameter on the reversed curve for
-- the point of parameter U on this curve.
-- Note: The point of parameter U on this curve is
-- identical to the point of parameter
-- ReversedParameter(U) on the reversed curve.
is deferred;
TransformedParameter(me; U : Real; T : Trsf2d from gp) returns Real
---Purpose: Computes the parameter on the curve transformed by
-- T for the point of parameter U on this curve.
-- Note: this function generally returns U but it can be
-- redefined (for example, on a line).
is virtual;
ParametricTransformation(me; T : Trsf2d from gp) returns Real
---Purpose: Returns the coefficient required to compute the
-- parametric transformation of this curve when
-- transformation T is applied. This coefficient is the
-- ratio between the parameter of a point on this curve
-- and the parameter of the transformed point on the
-- new curve transformed by T.
-- Note: this function generally returns 1. but it can be
-- redefined (for example, on a line).
is virtual;
Reversed (me) returns mutable like me
--- Purpose : Creates a reversed duplicate Changes the orientation of this curve. The first and
-- last parameters are not changed, but the parametric
-- direction of the curve is reversed.
-- If the curve is bounded:
-- - the start point of the initial curve becomes the end
-- point of the reversed curve, and
-- - the end point of the initial curve becomes the start
-- point of the reversed curve.
-- - Reversed creates a new curve.
is static;
FirstParameter (me) returns Real
--- Purpose : Returns the value of the first parameter.
-- Warnings :
-- It can be RealFirst or RealLast from package Standard
-- if the curve is infinite
is deferred;
LastParameter (me) returns Real
--- Purpose : Value of the last parameter.
-- Warnings :
-- It can be RealFirst or RealLast from package Standard
-- if the curve is infinite
is deferred;
IsClosed (me) returns Boolean
--- Purpose : Returns true if the curve is closed.
-- Examples :
-- Some curves such as circle are always closed, others such as line
-- are never closed (by definition).
-- Some Curves such as OffsetCurve can be closed or not. These curves
-- are considered as closed if the distance between the first point
-- and the last point of the curve is lower or equal to the Resolution
-- from package gp wich is a fixed criterion independant of the
-- application.
is deferred;
IsPeriodic (me) returns Boolean
--- Purpose :
-- Returns true if the parameter of the curve is periodic.
-- It is possible only if the curve is closed and if the
-- following relation is satisfied :
-- for each parametric value U the distance between the point
-- P(u) and the point P (u + T) is lower or equal to Resolution
-- from package gp, T is the period and must be a constant.
-- There are three possibilities :
-- . the curve is never periodic by definition (SegmentLine)
-- . the curve is always periodic by definition (Circle)
-- . the curve can be defined as periodic (BSpline). In this case
-- a function SetPeriodic allows you to give the shape of the
-- curve. The general rule for this case is : if a curve can be
-- periodic or not the default periodicity set is non periodic
-- and you have to turn (explicitly) the curve into a periodic
-- curve if you want the curve to be periodic.
is deferred;
Period (me) returns Real from Standard
---Purpose: Returns thne period of this curve.
raises
NoSuchObject from Standard
---Purpose: raises if the curve is not periodic
is virtual;
Continuity (me) returns Shape from GeomAbs
--- Purpose :
-- It is the global continuity of the curve :
-- C0 : only geometric continuity,
-- C1 : continuity of the first derivative all along the Curve,
-- C2 : continuity of the second derivative all along the Curve,
-- C3 : continuity of the third derivative all along the Curve,
-- G1 : tangency continuity all along the Curve,
-- G2 : curvature continuity all along the Curve,
-- CN : the order of continuity is infinite.
is deferred;
IsCN (me; N : Integer) returns Boolean
--- Purpose : Returns true if the degree of continuity of this curve is at least N.
-- Exceptions Standard_RangeError if N is less than 0.
raises RangeError
is deferred;
D0(me; U : Real; P : out Pnt2d)
---Purpose: Returns in P the point of parameter U.
-- If the curve is periodic then the returned point is P(U) with
-- U = Ustart + (U - Uend) where Ustart and Uend are the
-- parametric bounds of the curve.
raises UndefinedValue
---Purpose :
-- Raised only for the "OffsetCurve" if it is not possible to
-- compute the current point. For example when the first
-- derivative on the basis curve and the offset direction
-- are parallel.
is deferred;
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d)
--- Purpose :
-- Returns the point P of parameter U and the first derivative V1.
raises UndefinedDerivative
--- Purpose : Raised if the continuity of the curve is not C1.
is deferred;
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d)
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2.
raises UndefinedDerivative
--- Purpose : Raised if the continuity of the curve is not C2.
is deferred;
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d)
--- Purpose :
-- Returns the point P of parameter U, the first, the second
-- and the third derivative.
raises UndefinedDerivative
--- Purpose : Raised if the continuity of the curve is not C3.
is deferred;
DN (me; U : Real; N : Integer) returns Vec2d
--- Purpose : For the point of parameter U of this curve, computes
-- the vector corresponding to the Nth derivative.
-- Exceptions
-- StdFail_UndefinedDerivative if:
-- - the continuity of the curve is not "CN", or
-- - the derivative vector cannot be computed easily;
-- this is the case with specific types of curve (for
-- example, a rational BSpline curve where N is greater than 3).
-- Standard_RangeError if N is less than 1.
raises UndefinedDerivative,
RangeError
is deferred;
Value (me; U : Real) returns Pnt2d
--- Purpose : Computes the point of parameter U on <me>.
-- If the curve is periodic then the returned point is P(U) with
-- U = Ustart + (U - Uend) where Ustart and Uend are the
-- parametric bounds of the curve.
--
-- it is implemented with D0.
raises UndefinedValue
--- Purpose :
-- Raised only for the "OffsetCurve" if it is not possible to
-- compute the current point. For example when the first
-- derivative on the basis curve and the offset direction
-- are parallel.
is static;
end;

75
src/Geom2d/Geom2d_Curve.cxx Executable file
View File

@@ -0,0 +1,75 @@
// File: Geom2d_Curve.cxx
// Created: Wed Mar 24 19:20:49 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Curve.cxx, JCV 24/06/91
#include <Geom2d_Curve.ixx>
typedef Geom2d_Curve Curve;
typedef Handle(Geom2d_Curve) Handle(Curve);
//=======================================================================
//function : Reversed
//purpose :
//=======================================================================
Handle(Geom2d_Curve) Geom2d_Curve::Reversed () const
{
Handle(Curve) C = Handle(Curve)::DownCast(Copy());
C->Reverse();
return C;
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Curve::TransformedParameter(const Standard_Real U,
const gp_Trsf2d& ) const
{
return U;
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
Standard_Real Geom2d_Curve::ParametricTransformation(const gp_Trsf2d& ) const
{
return 1.;
}
//=======================================================================
//function : Period
//purpose :
//=======================================================================
Standard_Real Geom2d_Curve::Period() const
{
Standard_NoSuchObject_Raise_if
( !IsPeriodic(),"Geom2d_Curve::Period");
return ( LastParameter() - FirstParameter());
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
gp_Pnt2d Geom2d_Curve::Value(const Standard_Real U)const
{
gp_Pnt2d P;
D0(U,P);
return P;
}

95
src/Geom2d/Geom2d_Direction.cdl Executable file
View File

@@ -0,0 +1,95 @@
-- File: Geom2d_Direction.cdl
-- Created: Wed Mar 24 18:02:07 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
class Direction from Geom2d inherits Vector from Geom2d
--- Purpose :
-- The class Direction specifies a vector that is never null.
-- It is a unit vector.
uses Dir2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp,
Geometry from Geom2d
raises ConstructionError from Standard
is
Create (X, Y :Real) returns mutable Direction
--- Purpose : Creates a unit vector with it 2 cartesian coordinates.
raises ConstructionError;
--- Purpose :
-- Raised if Sqrt( X*X + Y*Y) <= Resolution from gp.
Create (V : Dir2d) returns mutable Direction;
--- Purpose : Creates a persistent copy of <me>.
SetCoord (me : mutable; X, Y : Real)
--- Purpose : Assigns the coordinates X and Y to this unit vector,
-- then normalizes it.
-- Exceptions
-- Standard_ConstructionError if Sqrt(X*X +
-- Y*Y) is less than or equal to gp::Resolution().
raises ConstructionError;
SetDir2d (me : mutable; V : Dir2d);
--- Purpose : Converts the gp_Dir2d unit vector V into this unit vector.
SetX (me : mutable; X : Real)
--- Purpose :
-- Assigns a value to the X coordinate of this unit vector, then normalizes it.
-- Exceptions
-- Standard_ConstructionError if the value assigned
-- causes the magnitude of the vector to become less
-- than or equal to gp::Resolution().
raises ConstructionError;
SetY (me : mutable; Y : Real)
--- Purpose : Assigns a value to the Y coordinate of this unit vector, then normalizes it.
-- Exceptions
-- Standard_ConstructionError if the value assigned
-- causes the magnitude of the vector to become less
-- than or equal to gp::Resolution().
raises ConstructionError;
Dir2d (me) returns Dir2d;
--- Purpose : Converts this unit vector into a gp_Dir2d unit vector.
Magnitude (me) returns Real;
--- Purpose : returns 1.0
SquareMagnitude (me) returns Real;
--- Purpose : returns 1.0
Crossed (me; Other : Vector) returns Real;
--- Purpose : Computes the cross product between <me> and <Other>.
---C++: alias operator ^
Transform (me : mutable; T : Trsf2d);
---Purpose: Applies the transformation T to this unit vector, then normalizes it.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this unit vector.
end;

94
src/Geom2d/Geom2d_Direction.cxx Executable file
View File

@@ -0,0 +1,94 @@
// File: Geom2d_Direction.cxx
// Created: Wed Mar 24 19:21:27 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Direction.cxx, JCV 25/06/91
#include <Geom2d_Direction.ixx>
#include <gp.hxx>
#include <Standard_ConstructionError.hxx>
typedef Geom2d_Direction Direction;
typedef Handle(Geom2d_Direction) Handle(Direction);
typedef Handle(Geom2d_Vector) Handle(Vector);
typedef gp_Ax2d Ax2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Trsf2d Trsf2d;
Handle(Geom2d_Geometry) Geom2d_Direction::Copy() const {
Handle(Direction) D;
D = new Direction (gpVec2d);
return D;
}
Geom2d_Direction::Geom2d_Direction (const Standard_Real X, const Standard_Real Y) {
Standard_Real D = Sqrt (X * X + Y * Y);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
gpVec2d = gp_Vec2d (X/D, Y/D);
}
Geom2d_Direction::Geom2d_Direction (const gp_Dir2d& V) { gpVec2d = V; }
void Geom2d_Direction::SetCoord (const Standard_Real X, const Standard_Real Y) {
Standard_Real D = Sqrt (X * X + Y * Y);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
gpVec2d = gp_Vec2d (X/D, Y/D);
}
void Geom2d_Direction::SetDir2d (const gp_Dir2d& V) { gpVec2d = V; }
void Geom2d_Direction::SetX (const Standard_Real X) {
Standard_Real D = Sqrt(X * X + gpVec2d.Y() * gpVec2d.Y());
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
gpVec2d = gp_Vec2d (X/D, gpVec2d.Y()/D);
}
void Geom2d_Direction::SetY (const Standard_Real Y) {
Standard_Real D = Sqrt (gpVec2d.X() * gpVec2d.X() + Y * Y);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
gpVec2d = gp_Vec2d (gpVec2d.X()/D, Y/D);
}
gp_Dir2d Geom2d_Direction::Dir2d () const { return gpVec2d; }
Standard_Real Geom2d_Direction::Magnitude () const { return 1.0; }
Standard_Real Geom2d_Direction::SquareMagnitude () const { return 1.0; }
Standard_Real Geom2d_Direction::Crossed (const Handle(Vector)& Other) const {
return gpVec2d.Crossed (Other->Vec2d());
}
void Geom2d_Direction::Transform (const gp_Trsf2d& T) {
gp_Dir2d dir = gpVec2d;
dir.Transform (T);
gpVec2d = dir;
}

275
src/Geom2d/Geom2d_Ellipse.cdl Executable file
View File

@@ -0,0 +1,275 @@
-- File: Geom2d_Ellipse.cdl
-- Created: Wed Mar 24 18:04:26 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991, 1992
class Ellipse from Geom2d inherits Conic from Geom2d
--- Purpose : Describes an ellipse in the plane (2D space).
-- An ellipse is defined by its major and minor radii and,
-- as with any conic curve, is positioned in the plane
-- with a coordinate system (gp_Ax22d object) where:
-- - the origin is the center of the ellipse,
-- - the "X Direction" defines the major axis, and
-- - the "Y Direction" defines the minor axis.
-- This coordinate system is the local coordinate system of the ellipse.
-- The orientation (direct or indirect) of the local
-- coordinate system gives an explicit orientation to the
-- ellipse, determining the direction in which the
-- parameter increases along the ellipse.
-- The Geom2d_Ellipse ellipse is parameterized by an angle:
-- P(U) = O + MajorRad*Cos(U)*XDir + MinorRad*Sin(U)*YDir
-- where:
-- - P is the point of parameter U,
-- - O, XDir and YDir are respectively the origin, "X
-- Direction" and "Y Direction" of its local coordinate system,
-- - MajorRad and MinorRad are the major and
-- minor radii of the ellipse.
-- The "X Axis" of the local coordinate system therefore
-- defines the origin of the parameter of the ellipse.
-- An ellipse is a closed and periodic curve. The period
-- is 2.*Pi and the parameter range is [ 0,2.*Pi [.
-- See Also
-- GCE2d_MakeEllipse which provides functions for
-- more complex ellipse constructions
-- gp_Ax22d
-- gp_Elips2d for an equivalent, non-parameterized data structure
uses Ax2d from gp,
Ax22d from gp,
Elips2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp,
Geometry from Geom2d
raises ConstructionError from Standard,
RangeError from Standard
is
Create (E : Elips2d) returns mutable Ellipse;
--- Purpose :
-- Creates an ellipse by conversion of the gp_Elips2d ellipse E.
Create (MajorAxis : Ax2d; MajorRadius, MinorRadius : Real;
Sense: Boolean from Standard = Standard_True)
returns mutable Ellipse
--- Purpose : Creates an ellipse defined by its major and minor radii,
-- MajorRadius and MinorRadius, and positioned
-- in the plane by its major axis MajorAxis; the
-- center of the ellipse is the origin of MajorAxis
-- and the unit vector of MajorAxis is the "X
-- Direction" of the local coordinate system of the
-- ellipse; this coordinate system is direct if Sense
-- is true (default value) or indirect if Sense is false.
-- Warnings :
-- It is not forbidden to create an ellipse with MajorRadius =
-- MinorRadius.
-- Exceptions
-- Standard_ConstructionError if:
-- - MajorRadius is less than MinorRadius, or
-- - MinorRadius is less than 0.
raises ConstructionError;
Create (Axis : Ax22d; MajorRadius, MinorRadius : Real)
returns mutable Ellipse
--- Purpose : Creates an ellipse defined by its major and minor radii,
-- MajorRadius and MinorRadius, where the
-- coordinate system Axis locates the ellipse and
-- defines its orientation in the plane such that:
-- - the center of the ellipse is the origin of Axis,
-- - the "X Direction" of Axis defines the major
-- axis of the ellipse,
-- - the "Y Direction" of Axis defines the minor
-- axis of the ellipse,
-- - the orientation of Axis (direct or indirect)
-- gives the orientation of the ellipse.
-- Warnings :
-- It is not forbidden to create an ellipse with MajorRadius =
-- MinorRadius.
-- Exceptions
-- Standard_ConstructionError if:
-- - MajorRadius is less than MinorRadius, or
-- - MinorRadius is less than 0.
raises ConstructionError;
SetElips2d (me : mutable; E : Elips2d);
--- Purpose: Converts the gp_Elips2d ellipse E into this ellipse.
SetMajorRadius (me : mutable; MajorRadius : Real)
raises ConstructionError;
--- Purpose : Assigns a value to the major radius of this ellipse.
-- Exceptions
-- Standard_ConstructionError if:
-- - the major radius of this ellipse becomes less than
-- the minor radius, or
-- - MinorRadius is less than 0.
SetMinorRadius (me : mutable; MinorRadius : Real)
raises ConstructionError;
--- Purpose : Assigns a value to the minor radius of this ellipse.
-- Exceptions
-- Standard_ConstructionError if:
-- - the major radius of this ellipse becomes less than
-- the minor radius, or
-- - MinorRadius is less than 0.
Elips2d (me) returns Elips2d;
--- Purpose : Converts this ellipse into a gp_Elips2d ellipse.
ReversedParameter(me; U : Real) returns Real is redefined static;
---Purpose: Computes the parameter on the reversed ellipse for
-- the point of parameter U on this ellipse.
-- For an ellipse, the returned value is: 2.*Pi - U.
Directrix1 (me) returns Ax2d
--- Purpose : Computes the directrices of this ellipse.
-- This directrix is the line normal to the XAxis of the ellipse
-- in the local plane (Z = 0) at a distance d = MajorRadius / e
-- from the center of the ellipse, where e is the eccentricity of
-- the ellipse.
-- This line is parallel to the "YAxis". The intersection point
-- between directrix1 and the "XAxis" is the "Location" point
-- of the directrix1. This point is on the positive side of
-- the "XAxis".
-- Raises ConstructionError if Eccentricity = 0.0. (The ellipse degenerates
-- into a circle)
raises ConstructionError;
Directrix2 (me) returns Ax2d
--- Purpose :
-- This line is obtained by the symmetrical transformation
-- of "Directrix1" with respect to the "YAxis" of the ellipse.
-- Raises ConstructionError if Eccentricity = 0.0. (The ellipse degenerates into a
-- circle).
raises ConstructionError;
Eccentricity (me) returns Real is redefined static;
--- Purpose :
-- Returns the eccentricity of the ellipse between 0.0 and 1.0
-- If f is the distance between the center of the ellipse and
-- the Focus1 then the eccentricity e = f / MajorRadius.
-- Returns 0 if MajorRadius = 0
Focal (me) returns Real;
--- Purpose :
-- Computes the focal distance. The focal distance is the distance between the center
-- and a focus of the ellipse.
Focus1 (me) returns Pnt2d;
--- Purpose :
-- Returns the first focus of the ellipse. This focus is on the
-- positive side of the "XAxis" of the ellipse.
Focus2 (me) returns Pnt2d;
--- Purpose :
-- Returns the second focus of the ellipse. This focus is on
-- the negative side of the "XAxis" of the ellipse.
MajorRadius (me) returns Real;
---Purpose: Returns the major radius of this ellipse.
MinorRadius (me) returns Real;
---Purpose: Returns the minor radius of this ellipse.
Parameter (me) returns Real;
--- Purpose :
-- Computes the parameter of this ellipse. This value is
-- given by the formula p = (1 - e * e) * MajorRadius where e is the eccentricity
-- of the ellipse.
-- Returns 0 if MajorRadius = 0
FirstParameter (me) returns Real is redefined static;
--- Purpose : Returns the value of the first parameter of this
-- ellipse. This is 0.0, which gives the start point of this ellipse.
-- The start point and end point of an ellipse are coincident.
LastParameter (me) returns Real is redefined static;
--- Purpose : Returns the value of the last parameter of this
-- ellipse. This is 2.*Pi, which gives the end point of this ellipse.
-- The start point and end point of an ellipse are coincident.
IsClosed (me) returns Boolean is redefined static;
--- Purpose : return True.
IsPeriodic (me) returns Boolean is redefined static;
--- Purpose : return True.
D0(me; U : Real; P : out Pnt2d) is redefined static;
---Purpose: Returns in P the point of parameter U.
-- P = C + MajorRadius * Cos (U) * XDir + MinorRadius * Sin (U) * YDir
-- where C is the center of the ellipse , XDir the direction of
-- the "XAxis" and "YDir" the "YAxis" of the ellipse.
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d) is redefined static;
-- Purpose :
-- Returns the point P of parameter U and the first derivative
-- at this point.
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U. The vectors V1 and V2
-- are the first and second derivatives at this point.
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U, the first second and
-- third derivatives V1 V2 and V3.
DN (me; U : Real; N : Integer) returns Vec2d
--- Purpose : For the point of parameter U of this ellipse,
-- computes the vector corresponding to the Nth derivative.
-- Exceptions Standard_RangeError if N is less than 1.
raises RangeError
is redefined static;
Transform (me : mutable; T : Trsf2d) is redefined static;
---Purpose: Applies the transformation T to this ellipse.
Copy (me) returns mutable like me
is redefined static;
---Purpose: Creates a new object which is a copy of this ellipse.
fields
majorRadius : Real;
minorRadius : Real;
end;

373
src/Geom2d/Geom2d_Ellipse.cxx Executable file
View File

@@ -0,0 +1,373 @@
// File: Geom2d_Ellipse.cxx
// Created: Wed Mar 24 19:22:03 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Ellipse.cxx, JCV 19/07/1991
#include <Geom2d_Ellipse.ixx>
#include <gp.hxx>
#include <gp_Dir2d.hxx>
#include <gp_XYZ.hxx>
#include <ElCLib.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_ConstructionError.hxx>
typedef Geom2d_Ellipse Ellipse;
typedef Handle(Geom2d_Ellipse) Handle(Ellipse);
typedef gp_Ax2d Ax2d;
typedef gp_Dir2d Dir2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Vec2d Vec2d;
typedef gp_Trsf2d Trsf2d;
typedef gp_XY XY;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom2d_Geometry) Geom2d_Ellipse::Copy() const
{
Handle(Ellipse) E;
E = new Ellipse (pos, majorRadius, minorRadius);
return E;
}
//=======================================================================
//function : Geom2d_Ellipse
//purpose :
//=======================================================================
Geom2d_Ellipse::Geom2d_Ellipse (const gp_Elips2d& E) {
majorRadius = E.MajorRadius();
minorRadius = E.MinorRadius();
pos = E.Axis();
}
//=======================================================================
//function : Geom2d_Ellipse
//purpose :
//=======================================================================
Geom2d_Ellipse::Geom2d_Ellipse (const Ax2d& MajorAxis,
const Standard_Real MajorRadius,
const Standard_Real MinorRadius,
const Standard_Boolean Sense)
:majorRadius (MajorRadius), minorRadius (MinorRadius){
if (MajorRadius < MinorRadius || MinorRadius < 0.0 ) {
Standard_ConstructionError::Raise();
}
pos = gp_Ax22d(MajorAxis, Sense);
}
//=======================================================================
//function : Geom2d_Ellipse
//purpose :
//=======================================================================
Geom2d_Ellipse::Geom2d_Ellipse (const gp_Ax22d& Axis,
const Standard_Real MajorRadius,
const Standard_Real MinorRadius)
: majorRadius (MajorRadius), minorRadius (MinorRadius)
{
if (MajorRadius < MinorRadius || MinorRadius < 0.0 ) {
Standard_ConstructionError::Raise();
}
pos = Axis;
}
//=======================================================================
//function : SetElips2d
//purpose :
//=======================================================================
void Geom2d_Ellipse::SetElips2d (const gp_Elips2d& E)
{
majorRadius = E.MajorRadius();
minorRadius = E.MinorRadius();
pos = E.Axis();
}
//=======================================================================
//function : SetMajorRadius
//purpose :
//=======================================================================
void Geom2d_Ellipse::SetMajorRadius (const Standard_Real MajorRadius)
{
if (MajorRadius < minorRadius)
Standard_ConstructionError::Raise();
else
majorRadius = MajorRadius;
}
//=======================================================================
//function : SetMinorRadius
//purpose :
//=======================================================================
void Geom2d_Ellipse::SetMinorRadius (const Standard_Real MinorRadius)
{
if (MinorRadius < 0 || majorRadius < MinorRadius)
{ Standard_ConstructionError::Raise(); }
else
{ minorRadius = MinorRadius; }
}
//=======================================================================
//function : Elips2d
//purpose :
//=======================================================================
gp_Elips2d Geom2d_Ellipse::Elips2d () const
{
return gp_Elips2d (pos, majorRadius, minorRadius);
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Ellipse::ReversedParameter( const Standard_Real U) const
{
return (2. * PI - U);
}
//=======================================================================
//function : Directrix1
//purpose :
//=======================================================================
Ax2d Geom2d_Ellipse::Directrix1 () const
{
gp_Elips2d Ev (pos, majorRadius, minorRadius);
return Ev.Directrix1();
}
//=======================================================================
//function : Directrix2
//purpose :
//=======================================================================
Ax2d Geom2d_Ellipse::Directrix2 () const
{
gp_Elips2d Ev (pos, majorRadius, minorRadius);
return Ev.Directrix2();
}
//=======================================================================
//function : Eccentricity
//purpose :
//=======================================================================
Standard_Real Geom2d_Ellipse::Eccentricity () const
{
if (majorRadius == 0.0)
{ return 0.0; }
else
{ return
(Sqrt(majorRadius*majorRadius-minorRadius*minorRadius))/majorRadius;
}
}
//=======================================================================
//function : Focal
//purpose :
//=======================================================================
Standard_Real Geom2d_Ellipse::Focal () const
{
return 2.0 * Sqrt(majorRadius * majorRadius - minorRadius * minorRadius);
}
//=======================================================================
//function : Focus1
//purpose :
//=======================================================================
Pnt2d Geom2d_Ellipse::Focus1 () const
{
Standard_Real C = Sqrt(majorRadius * majorRadius - minorRadius * minorRadius);
return Pnt2d (pos.Location().X() + C * pos.XDirection().X(),
pos.Location().Y() + C * pos.XDirection().Y());
}
//=======================================================================
//function : Focus2
//purpose :
//=======================================================================
Pnt2d Geom2d_Ellipse::Focus2 () const
{
Standard_Real C = Sqrt(majorRadius * majorRadius - minorRadius * minorRadius);
return Pnt2d (pos.Location().X() - C * pos.XDirection().X(),
pos.Location().Y() - C * pos.XDirection().Y());
}
//=======================================================================
//function : MajorRadius
//purpose :
//=======================================================================
Standard_Real Geom2d_Ellipse::MajorRadius () const
{
return majorRadius;
}
//=======================================================================
//function : MinorRadius
//purpose :
//=======================================================================
Standard_Real Geom2d_Ellipse::MinorRadius () const
{
return minorRadius;
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Ellipse::Parameter () const
{
if (majorRadius == 0.0)
return 0.0;
else
return (minorRadius * minorRadius)/majorRadius;
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Ellipse::FirstParameter () const
{
return 0.0;
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Ellipse::LastParameter () const
{
return 2.0 * PI;
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Ellipse::IsClosed () const
{
return Standard_True;
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Ellipse::IsPeriodic () const
{
return Standard_True;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2d_Ellipse::D0 (const Standard_Real U, Pnt2d& P) const
{
P = ElCLib::EllipseValue (U, pos, majorRadius, minorRadius);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_Ellipse::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const
{
ElCLib::EllipseD1 (U, pos, majorRadius, minorRadius, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_Ellipse::D2 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2) const
{
ElCLib::EllipseD2 (U, pos, majorRadius, minorRadius, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2d_Ellipse::D3 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2, Vec2d& V3) const
{
ElCLib::EllipseD3 (U, pos, majorRadius, minorRadius, P, V1, V2, V3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec2d Geom2d_Ellipse::DN (const Standard_Real U, const Standard_Integer N) const
{
Standard_RangeError_Raise_if (N < 1, " ");
return ElCLib::EllipseDN (U, pos, majorRadius, minorRadius, N);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom2d_Ellipse::Transform (const Trsf2d& T)
{
majorRadius = majorRadius * Abs(T.ScaleFactor());
minorRadius = minorRadius * Abs(T.ScaleFactor());
pos.Transform(T);
}

122
src/Geom2d/Geom2d_Geometry.cdl Executable file
View File

@@ -0,0 +1,122 @@
-- File: Geom2d_Geometry.cdl
-- Created: Wed Mar 24 18:05:00 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
deferred class Geometry from Geom2d inherits TShared from MMgt
--- Purpose :
-- The general abstract class Geometry in 2D space describes
-- the common behaviour of all the geometric entities.
--
-- All the objects derived from this class can be move with a
-- geometric transformation. Only the transformations which
-- doesn't modify the nature of the geometry are available in
-- this package.
-- The method Transform which defines a general transformation
-- is deferred. The other specifics transformations used the
-- method Transform.
-- All the following transformations modify the object itself.
-- Warning
-- Only transformations which do not modify the nature
-- of the geometry can be applied to Geom2d objects:
-- this is the case with translations, rotations,
-- symmetries and scales; this is also the case with
-- gp_Trsf2d composite transformations which are
-- used to define the geometric transformations applied
-- using the Transform or Transformed functions.
-- Note: Geometry defines the "prototype" of the
-- abstract method Transform which is defined for each
-- concrete type of derived object. All other
-- transformations are implemented using the Transform method.
uses Ax2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp
raises ConstructionError from Standard
is
Mirror (me : mutable; P : Pnt2d)
--- Purpose : Performs the symmetrical transformation of a Geometry
-- with respect to the point P which is the center of the
-- symmetry and assigns the result to this geometric object.
is static;
Mirror (me : mutable; A : Ax2d)
--- Purpose : Performs the symmetrical transformation of a Geometry
-- with respect to an axis placement which is the axis of the symmetry.
is static;
Rotate (me : mutable; P : Pnt2d; Ang : Real)
--- Purpose : Rotates a Geometry. P is the center of the rotation.
-- Ang is the angular value of the rotation in radians.
is static;
Scale (me : mutable; P : Pnt2d; S : Real)
--- Purpose : Scales a Geometry. S is the scaling value.
is static;
Translate (me : mutable; V : Vec2d)
--- Purpose : Translates a Geometry. V is the vector of the tanslation.
is static;
Translate (me : mutable; P1, P2 : Pnt2d)
--- Purpose : Translates a Geometry from the point P1 to the point P2.
is static;
Transform (me : mutable; T : Trsf2d)
--- Purpose : Transformation of a geometric object. This tansformation
-- can be a translation, a rotation, a symmetry, a scaling
-- or a complex transformation obtained by combination of
-- the previous elementaries transformations.
-- (see class Transformation of the package Geom2d).
is deferred;
--- Purpose : The following transformations have the same properties
-- as the previous ones but they don't modified the object
-- itself. A copy of the object is returned.
Mirrored (me; P : Pnt2d) returns mutable like me
is static;
Mirrored (me; A : Ax2d) returns mutable like me
is static;
Rotated (me; P : Pnt2d; Ang : Real) returns mutable like me
is static;
Scaled (me; P : Pnt2d; S : Real) returns mutable like me
is static;
Transformed (me; T : Trsf2d) returns mutable like me
is static;
Translated (me; V : Vec2d) returns mutable like me
is static;
Translated (me; P1, P2 : Pnt2d) returns mutable like me
is static;
Copy (me) returns mutable like me is deferred;
end;

132
src/Geom2d/Geom2d_Geometry.cxx Executable file
View File

@@ -0,0 +1,132 @@
// File: Geom2d_Geometry.cxx
// Created: Wed Mar 24 19:22:26 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Geometry.cxx, JCV 23/06/91
#include <Geom2d_Geometry.ixx>
#include <Standard_ConstructionError.hxx>
typedef Handle(Geom2d_Geometry) Handle(Geometry);
typedef Geom2d_Geometry Geometry;
typedef gp_Ax2d Ax2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Vec2d Vec2d;
typedef gp_Trsf2d Trsf2d;
void Geom2d_Geometry::Mirror (const gp_Pnt2d& P) {
Trsf2d T;
T.SetMirror (P);
Transform (T);
}
void Geom2d_Geometry::Mirror (const gp_Ax2d& A) {
Trsf2d T;
T.SetMirror (A);
Transform (T);
}
void Geom2d_Geometry::Rotate (const gp_Pnt2d& P, const Standard_Real Ang) {
Trsf2d T;
T.SetRotation (P, Ang);
Transform (T);
}
void Geom2d_Geometry::Scale (const gp_Pnt2d& P, const Standard_Real S) {
Trsf2d T;
T.SetScale (P, S);
Transform (T);
}
void Geom2d_Geometry::Translate (const gp_Vec2d& V) {
Trsf2d T;
T.SetTranslation (V);
Transform (T);
}
void Geom2d_Geometry::Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2) {
Vec2d V (P1, P2);
Translate (V);
}
Handle(Geometry) Geom2d_Geometry::Mirrored (const gp_Pnt2d& P) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Mirror (P);
return G;
}
Handle(Geometry) Geom2d_Geometry::Mirrored (const gp_Ax2d& A) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Mirror (A);
return G;
}
Handle(Geometry) Geom2d_Geometry::Rotated (
const gp_Pnt2d& P, const Standard_Real Ang) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Rotate (P, Ang);
return G;
}
Handle(Geometry) Geom2d_Geometry::Scaled (
const gp_Pnt2d& P, const Standard_Real S) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Scale (P, S);
return G;
}
Handle(Geometry) Geom2d_Geometry::Transformed (const gp_Trsf2d& T) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Transform (T);
return G;
}
Handle(Geometry) Geom2d_Geometry::Translated (const gp_Vec2d& V) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Translate (V);
return G;
}
Handle(Geometry) Geom2d_Geometry::Translated (
const gp_Pnt2d& P1, const gp_Pnt2d& P2) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Translate (P1, P2);
return G;
}

328
src/Geom2d/Geom2d_Hyperbola.cdl Executable file
View File

@@ -0,0 +1,328 @@
-- File: Geom2d_Hyperbola.cdl
-- Created: Wed Mar 24 18:06:32 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991, 1992
class Hyperbola from Geom2d inherits Conic from Geom2d
--- Purpose : Describes a branch of a hyperbola in the plane (2D space).
-- A hyperbola is defined by its major and minor radii
-- and, as with any conic curve, is positioned in the
-- plane with a coordinate system (gp_Ax22d object) where:
-- - the origin is the center of the hyperbola,
-- - the "X Direction" defines the major axis, and
-- - the "Y Direction" defines the minor axis.
-- This coordinate system is the local coordinate
-- system of the hyperbola.
-- The branch of the hyperbola described is the one
-- located on the positive side of the major axis.
-- The orientation (direct or indirect) of the local
-- coordinate system gives an explicit orientation to the
-- hyperbola, determining the direction in which the
-- parameter increases along the hyperbola.
-- The Geom2d_Hyperbola hyperbola is parameterized as follows:
-- P(U) = O + MajRad*Cosh(U)*XDir + MinRad*Sinh(U)*YDir
-- where:
-- - P is the point of parameter U,
-- - O, XDir and YDir are respectively the origin, "X
-- Direction" and "Y Direction" of its local coordinate system,
-- - MajRad and MinRad are the major and minor radii of the hyperbola.
-- The "X Axis" of the local coordinate system therefore
-- defines the origin of the parameter of the hyperbola.
-- The parameter range is ] -infinite,+infinite [.
-- The following diagram illustrates the respective
-- positions, in the plane of the hyperbola, of the three
-- branches of hyperbolas constructed using the
-- functions OtherBranch, ConjugateBranch1 and
-- ConjugateBranch2:
-- ^YAxis
-- |
-- FirstConjugateBranch
-- |
-- Other | Main
-- --------------------- C
-- --------------------->XAxis
-- Branch |
-- Branch
-- |
-- SecondConjugateBranch
-- |
-- Warning
-- The value of the major radius (on the major axis) can
-- be less than the value of the minor radius (on the minor axis).
-- See Also
-- GCE2d_MakeHyperbola which provides functions for
-- more complex hyperbola constructions
-- gp_Ax22d
-- gp_Hypr2d for an equivalent, non-parameterized data structure
uses Ax2d from gp,
Ax22d from gp,
Hypr2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp,
Geometry from Geom2d
raises ConstructionError from Standard,
DomainError from Standard,
RangeError from Standard
is
Create (H : Hypr2d) returns mutable Hyperbola;
--- Purpose : Creates an Hyperbola from a non persistent one from package gp
Create (MajorAxis : Ax2d; MajorRadius, MinorRadius : Real;
Sense: Boolean from Standard = Standard_True)
returns mutable Hyperbola
--- Purpose :
-- MajorAxis is the "XAxis" of the hyperbola.
-- The YAxis is in the direct sense if "Sense" is True;
-- The major radius of the hyperbola is on this "XAxis" and
-- the minor radius is on the "YAxis" of the hyperbola.
raises ConstructionError;
--- Purpose : Raised if MajorRadius < 0.0 or if MinorRadius < 0.0
Create (Axis : Ax22d; MajorRadius, MinorRadius : Real)
returns mutable Hyperbola
--- Purpose :
-- The XDirection of "Axis" is the "XAxis" of the hyperbola and
-- the YDirection of "Axis" is the "YAxis".
-- The major radius of the hyperbola is on this "XAxis" and
-- the minor radius is on the "YAxis" of the hyperbola.
raises ConstructionError;
--- Purpose : Raised if MajorRadius < 0.0 or if MinorRadius < 0.0
SetHypr2d (me : mutable; H : Hypr2d);
--- Purpose: Converts the gp_Hypr2d hyperbola H into this hyperbola.
SetMajorRadius (me : mutable; MajorRadius : Real)
raises ConstructionError;
---Purpose : Assigns a value to the major or minor radius of this hyperbola.
-- Exceptions
-- Standard_ConstructionError if:
-- - MajorRadius is less than 0.0,
-- - MinorRadius is less than 0.0.
SetMinorRadius (me : mutable; MinorRadius : Real)
raises ConstructionError;
--- Purpose : Assigns a value to the major or minor radius of this hyperbola.
-- Exceptions
-- Standard_ConstructionError if:
-- - MajorRadius is less than 0.0,
-- - MinorRadius is less than 0.0.
Hypr2d (me) returns Hypr2d;
--- Purpose : Converts this hyperbola into a gp_Hypr2d one.
ReversedParameter(me; U : Real) returns Real is redefined static;
---Purpose: Computes the parameter on the reversed hyperbola,
-- for the point of parameter U on this hyperbola.
-- For a hyperbola, the returned value is -U.
FirstParameter (me) returns Real is redefined static;
--- Purpose : Returns RealFirst from Standard.
LastParameter (me) returns Real is redefined static;
--- Purpose : returns RealLast from Standard.
IsClosed (me) returns Boolean is redefined static;
--- Purpose : Returns False.
IsPeriodic (me) returns Boolean is redefined static;
--- Purpose : return False for an hyperbola.
Asymptote1 (me) returns Ax2d
--- Purpose :
-- In the local coordinate system of the hyperbola the
-- equation of the hyperbola is (X*X)/(A*A) - (Y*Y)/(B*B) = 1.0
-- and the equation of the first asymptote is Y = (B/A)*X
-- where A is the major radius of the hyperbola and B is the
-- minor radius of the hyperbola.
raises ConstructionError;
--- Purpose : Raised if MajorRadius = 0.0
Asymptote2 (me) returns Ax2d
--- Purpose :
-- In the local coordinate system of the hyperbola the
-- equation of the hyperbola is (X*X)/(A*A) - (Y*Y)/(B*B) = 1.0
-- and the equation of the first asymptote is Y = -(B/A)*X.
-- where A is the major radius of the hyperbola and B is the
-- minor radius of the hyperbola.
raises ConstructionError;
--- Purpose : raised if MajorRadius = 0.0
ConjugateBranch1 (me) returns Hypr2d;
--- Purpose : Computes the first conjugate branch relative to this hyperbola.
-- Note: The diagram given under the class purpose
-- indicates where these two branches of hyperbola are
-- positioned in relation to this branch of hyperbola.
ConjugateBranch2 (me) returns Hypr2d;
--- Purpose : Computes the second conjugate branch relative to this hyperbola.
-- Note: The diagram given under the class purpose
-- indicates where these two branches of hyperbola are
-- positioned in relation to this branch of hyperbola.
Directrix1 (me) returns Ax2d;
--- Purpose :
-- This directrix is the line normal to the XAxis of the hyperbola
-- in the local plane (Z = 0) at a distance d = MajorRadius / e
-- from the center of the hyperbola, where e is the eccentricity of
-- the hyperbola.
-- This line is parallel to the "YAxis". The intersection point
-- between directrix1 and the "XAxis" is the location point of the
-- directrix1. This point is on the positive side of the "XAxis".
Directrix2 (me) returns Ax2d;
--- Purpose :
-- This line is obtained by the symmetrical transformation
-- of "Directrix1" with respect to the "YAxis" of the hyperbola.
Eccentricity (me) returns Real
--- Purpose :
-- Returns the excentricity of the hyperbola (e > 1).
-- If f is the distance between the location of the hyperbola
-- and the Focus1 then the eccentricity e = f / MajorRadius.
raises DomainError is redefined static;
--- Purpose : raised if MajorRadius = 0.0
Focal (me) returns Real;
--- Purpose :
-- Computes the focal distance. It is the distance between the
-- two focus of the hyperbola.
Focus1 (me) returns Pnt2d;
--- Purpose :
-- Returns the first focus of the hyperbola. This focus is on the
-- positive side of the "XAxis" of the hyperbola.
Focus2 (me) returns Pnt2d;
--- Purpose :
-- Returns the second focus of the hyperbola. This focus is on the
-- negative side of the "XAxis" of the hyperbola.
MajorRadius (me) returns Real;
---Purpose: Returns the major or minor radius of this hyperbola.
-- The major radius is also the distance between the
-- center of the hyperbola and the apex of the main
-- branch (located on the "X Axis" of the hyperbola).
MinorRadius (me) returns Real;
---Purpose: Returns the major or minor radius of this hyperbola.
-- The minor radius is also the distance between the
-- center of the hyperbola and the apex of a conjugate
-- branch (located on the "Y Axis" of the hyperbola).
OtherBranch (me) returns Hypr2d;
--- Purpose :
-- Computes the "other" branch of this hyperbola. This
-- is a symmetrical branch with respect to the center of this hyperbola.
-- Note: The diagram given under the class purpose
-- indicates where the "other" branch is positioned in
-- relation to this branch of the hyperbola.
-- ^ YAxis
-- |
-- FirstConjugateBranch
-- |
-- Other | Main
-- ---------------------------- C
-- ------------------------------------------&gtXAxis
-- Branch | Branch
-- |
-- |
-- SecondConjugateBranch
-- |
-- Warning
-- The major radius can be less than the minor radius.
Parameter (me) returns Real
--- Purpose : Computes the parameter of this hyperbola.
-- The parameter is:
-- p = (e*e - 1) * MajorRadius
-- where e is the eccentricity of this hyperbola and
-- MajorRadius its major radius.
-- Exceptions
-- Standard_DomainError if the major radius of this
-- hyperbola is null.
raises DomainError;
D0(me; U : Real; P : out Pnt2d) is redefined static;
---Purpose: Returns in P the point of parameter U.
-- P = C + MajorRadius * Cosh (U) * XDir +
-- MinorRadius * Sinh (U) * YDir
-- where C is the center of the hyperbola , XDir the XDirection and
-- YDir the YDirection of the hyperbola's local coordinate system.
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U and the first derivative V1.
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2.
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U, the first second and
-- third derivatives V1 V2 and V3.
DN (me; U : Real; N : Integer) returns Vec2d
--- Purpose : For the point of parameter U of this hyperbola,
-- computes the vector corresponding to the Nth derivative.
-- Exceptions Standard_RangeError if N is less than 1.
raises RangeError is redefined static;
Transform (me : mutable; T : Trsf2d) is redefined static;
---Purpose: Applies the transformation T to this hyperbola.
Copy (me) returns mutable like me is redefined static;
---Purpose: Creates a new object which is a copy of this hyperbola.
fields
majorRadius : Real;
minorRadius : Real;
end;

427
src/Geom2d/Geom2d_Hyperbola.cxx Executable file
View File

@@ -0,0 +1,427 @@
// File: Geom2d_Hyperbola.cxx
// Created: Wed Mar 24 19:22:55 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Hyperbola.cxx, JCV 17/01/91
#include <Geom2d_Hyperbola.ixx>
#include <Precision.hxx>
#include <ElCLib.hxx>
#include <gp_Dir2d.hxx>
#include <gp_XY.hxx>
#include <gp.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_RangeError.hxx>
typedef Geom2d_Hyperbola Hyperbola;
typedef Handle(Geom2d_Hyperbola) Handle(Hyperbola);
typedef gp_Ax2d Ax2d;
typedef gp_Dir2d Dir2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Vec2d Vec2d;
typedef gp_Trsf2d Trsf2d;
typedef gp_XY XY;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom2d_Geometry) Geom2d_Hyperbola::Copy() const
{
Handle(Hyperbola) H;
H = new Hyperbola (pos, majorRadius, minorRadius);
return H;
}
//=======================================================================
//function : Geom2d_Hyperbola
//purpose :
//=======================================================================
Geom2d_Hyperbola::Geom2d_Hyperbola (const gp_Hypr2d& H)
{
majorRadius = H.MajorRadius();
minorRadius = H.MinorRadius();
pos = H.Axis();
}
//=======================================================================
//function : Geom2d_Hyperbola
//purpose :
//=======================================================================
Geom2d_Hyperbola::Geom2d_Hyperbola (const Ax2d& A,
const Standard_Real MajorRadius,
const Standard_Real MinorRadius,
const Standard_Boolean Sense)
: majorRadius (MajorRadius), minorRadius (MinorRadius)
{
if( MajorRadius < 0.0|| MinorRadius < 0.0)
Standard_ConstructionError::Raise();
pos = gp_Ax22d(A, Sense);
}
//=======================================================================
//function : Geom2d_Hyperbola
//purpose :
//=======================================================================
Geom2d_Hyperbola::Geom2d_Hyperbola (const gp_Ax22d& Axis,
const Standard_Real MajorRadius,
const Standard_Real MinorRadius)
: majorRadius (MajorRadius), minorRadius (MinorRadius)
{
if( MajorRadius < 0.0|| MinorRadius < 0.0)
Standard_ConstructionError::Raise();
pos = Axis;
}
//=======================================================================
//function : SetHypr2d
//purpose :
//=======================================================================
void Geom2d_Hyperbola::SetHypr2d (const gp_Hypr2d& H)
{
majorRadius = H.MajorRadius();
minorRadius = H.MinorRadius();
pos = H.Axis();
}
//=======================================================================
//function : SetMajorRadius
//purpose :
//=======================================================================
void Geom2d_Hyperbola::SetMajorRadius (const Standard_Real MajorRadius)
{
if (MajorRadius < 0.0)
Standard_ConstructionError::Raise();
else
majorRadius = MajorRadius;
}
//=======================================================================
//function : SetMinorRadius
//purpose :
//=======================================================================
void Geom2d_Hyperbola::SetMinorRadius (const Standard_Real MinorRadius)
{
if (MinorRadius < 0.0 )
Standard_ConstructionError::Raise();
else
minorRadius = MinorRadius;
}
//=======================================================================
//function : Hypr2d
//purpose :
//=======================================================================
gp_Hypr2d Geom2d_Hyperbola::Hypr2d () const
{
return gp_Hypr2d (pos, majorRadius, minorRadius);
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Hyperbola::ReversedParameter( const Standard_Real U) const
{
return ( -U);
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Hyperbola::FirstParameter () const
{
return -Precision::Infinite();
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Hyperbola::LastParameter () const
{
return Precision::Infinite();
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Hyperbola::IsClosed () const
{
return Standard_False;
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Hyperbola::IsPeriodic () const
{
return Standard_False;
}
//=======================================================================
//function : Asymptote1
//purpose :
//=======================================================================
Ax2d Geom2d_Hyperbola::Asymptote1 () const
{
gp_Hypr2d Hv (pos, majorRadius, minorRadius);
return Hv.Asymptote1();
}
//=======================================================================
//function : Asymptote2
//purpose :
//=======================================================================
Ax2d Geom2d_Hyperbola::Asymptote2 () const
{
gp_Hypr2d Hv (pos, majorRadius, minorRadius);
return Hv.Asymptote2();
}
//=======================================================================
//function : ConjugateBranch1
//purpose :
//=======================================================================
gp_Hypr2d Geom2d_Hyperbola::ConjugateBranch1 () const
{
gp_Hypr2d Hv (pos, majorRadius, minorRadius);
return Hv.ConjugateBranch1 ();
}
//=======================================================================
//function : ConjugateBranch2
//purpose :
//=======================================================================
gp_Hypr2d Geom2d_Hyperbola::ConjugateBranch2 () const
{
gp_Hypr2d Hv (pos, majorRadius, minorRadius);
return Hv.ConjugateBranch2 ();
}
//=======================================================================
//function : Directrix1
//purpose :
//=======================================================================
Ax2d Geom2d_Hyperbola::Directrix1 () const
{
gp_Hypr2d Hv (pos, majorRadius, minorRadius);
return Hv.Directrix1 ();
}
//=======================================================================
//function : Directrix2
//purpose :
//=======================================================================
Ax2d Geom2d_Hyperbola::Directrix2 () const
{
gp_Hypr2d Hv (pos, majorRadius, minorRadius);
return Hv.Directrix2 ();
}
//=======================================================================
//function : Eccentricity
//purpose :
//=======================================================================
Standard_Real Geom2d_Hyperbola::Eccentricity () const
{
Standard_DomainError_Raise_if (majorRadius <= gp::Resolution(), " ");
return
(Sqrt(majorRadius*majorRadius+minorRadius*minorRadius))/majorRadius;
}
//=======================================================================
//function : Focal
//purpose :
//=======================================================================
Standard_Real Geom2d_Hyperbola::Focal () const
{
return 2.0 * Sqrt(majorRadius * majorRadius + minorRadius * minorRadius);
}
//=======================================================================
//function : Focus1
//purpose :
//=======================================================================
Pnt2d Geom2d_Hyperbola::Focus1 () const
{
Standard_Real C = Sqrt(majorRadius * majorRadius + minorRadius * minorRadius);
XY Pxy = pos.XDirection().XY();
Pxy.Multiply (C);
Pxy.Add (pos.Location().XY());
return Pnt2d (Pxy);
}
//=======================================================================
//function : Focus2
//purpose :
//=======================================================================
Pnt2d Geom2d_Hyperbola::Focus2 () const
{
Standard_Real C = Sqrt(majorRadius * majorRadius + minorRadius * minorRadius);
XY Pxy = pos.XDirection().XY();
Pxy.Multiply (-C);
Pxy.Add (pos.Location().XY());
return Pnt2d (Pxy);
}
//=======================================================================
//function : MajorRadius
//purpose :
//=======================================================================
Standard_Real Geom2d_Hyperbola::MajorRadius () const
{
return majorRadius;
}
//=======================================================================
//function : MinorRadius
//purpose :
//=======================================================================
Standard_Real Geom2d_Hyperbola::MinorRadius () const
{
return minorRadius;
}
//=======================================================================
//function : OtherBranch
//purpose :
//=======================================================================
gp_Hypr2d Geom2d_Hyperbola::OtherBranch () const
{
gp_Hypr2d Hv (pos, majorRadius, minorRadius);
return Hv.OtherBranch ();
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Hyperbola::Parameter () const
{
Standard_DomainError_Raise_if (majorRadius <= gp::Resolution(), " ");
return (minorRadius * minorRadius) / majorRadius;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2d_Hyperbola::D0 (const Standard_Real U,
Pnt2d& P ) const
{
P = ElCLib::HyperbolaValue (U, pos, majorRadius, minorRadius);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_Hyperbola::D1 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1) const
{
ElCLib::HyperbolaD1 (U, pos, majorRadius, minorRadius, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_Hyperbola::D2 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2) const
{
ElCLib::HyperbolaD2 (U, pos, majorRadius, minorRadius, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2d_Hyperbola::D3 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2, Vec2d& V3) const
{
ElCLib::HyperbolaD3 (U, pos, majorRadius, minorRadius, P, V1, V2, V3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec2d Geom2d_Hyperbola::DN (const Standard_Real U, const Standard_Integer N) const
{
Standard_RangeError_Raise_if (N < 1, " ");
return ElCLib::HyperbolaDN (U, pos, majorRadius, minorRadius, N);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom2d_Hyperbola::Transform (const Trsf2d& T)
{
majorRadius = majorRadius * Abs (T.ScaleFactor());
minorRadius = minorRadius * Abs (T.ScaleFactor());
pos.Transform(T);
}

198
src/Geom2d/Geom2d_Line.cdl Executable file
View File

@@ -0,0 +1,198 @@
-- File: Geom2d_Line.cdl
-- Created: Wed Mar 24 18:19:31 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
class Line from Geom2d inherits Curve from Geom2d
--- Purpose : Describes an infinite line in the plane (2D space).
-- A line is defined and positioned in the plane with an
-- axis (gp_Ax2d object) which gives it an origin and a unit vector.
-- The Geom2d_Line line is parameterized as follows:
-- P (U) = O + U*Dir
-- where:
-- - P is the point of parameter U,
-- - O is the origin and Dir the unit vector of its positioning axis.
-- The parameter range is ] -infinite, +infinite [.
-- The orientation of the line is given by the unit vector
-- of its positioning axis.
-- See Also
-- GCE2d_MakeLine which provides functions for more
-- complex line constructions
-- gp_Ax2d
-- gp_Lin2d for an equivalent, non-parameterized data structure.
uses Ax2d from gp,
Dir2d from gp,
Lin2d from gp,
Pnt2d from gp,
Vec2d from gp,
Trsf2d from gp,
Geometry from Geom2d,
Shape from GeomAbs
raises RangeError from Standard
is
Create (A : Ax2d) returns mutable Line;
--- Purpose :
-- Creates a line located in 2D space with the axis placement A.
-- The Location of A is the origin of the line.
Create (L : Lin2d) returns mutable Line;
--- Purpose :
-- Creates a line by conversion of the gp_Lin2d line L.
Create (P : Pnt2d; V : Dir2d) returns mutable Line;
--- Purpose : Constructs a line passing through point P and parallel to
-- vector V (P and V are, respectively, the origin
-- and the unit vector of the positioning axis of the line).
SetLin2d (me : mutable; L : Lin2d);
--- Purpose :
-- Set <me> so that <me> has the same geometric properties as L.
SetDirection (me : mutable; V : Dir2d);
--- Purpose : changes the direction of the line.
Direction (me) returns Dir2d from gp;
--- Purpose : changes the direction of the line.
---C++: return const &
SetLocation (me : mutable; P : Pnt2d);
--- Purpose :
-- Changes the "Location" point (origin) of the line.
Location (me) returns Pnt2d from gp;
--- Purpose :
-- Changes the "Location" point (origin) of the line.
---C++: return const &
SetPosition (me : mutable; A : Ax2d);
--- Purpose :
-- Changes the "Location" and a the "Direction" of <me>.
Position(me) returns Ax2d from gp
---C++: return const &
is static;
Lin2d (me) returns Lin2d;
--- Purpose :
-- Returns non persistent line from gp with the same geometric
-- properties as <me>
Reverse (me : mutable);
--- Purpose : Changes the orientation of this line. As a result, the
-- unit vector of the positioning axis of this line is reversed.
ReversedParameter(me; U : Real) returns Real;
---Purpose: Computes the parameter on the reversed line for the
-- point of parameter U on this line.
-- For a line, the returned value is -U.
FirstParameter (me) returns Real;
--- Purpose : Returns RealFirst from Standard.
LastParameter (me) returns Real;
--- Purpose : Returns RealLast from Standard
IsClosed (me) returns Boolean;
--- Purpose : Returns False
IsPeriodic (me) returns Boolean;
--- Purpose : Returns False
Continuity (me) returns Shape from GeomAbs;
--- Purpose : Returns GeomAbs_CN, which is the global continuity of any line.
Distance (me; P : Pnt2d) returns Real;
--- Purpose : Computes the distance between <me> and the point P.
IsCN (me; N : Integer) returns Boolean;
--- Purpose : Returns True.
D0(me; U : Real; P : out Pnt2d);
---Purpose: Returns in P the point of parameter U.
-- P (U) = O + U * Dir where O is the "Location" point of the
-- line and Dir the direction of the line.
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d);
--- Purpose :
-- Returns the point P of parameter u and the first derivative V1.
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d);
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2. V2 is a vector with null magnitude
-- for a line.
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d);
--- Purpose :
-- V2 and V3 are vectors with null magnitude for a line.
DN (me; U : Real; N : Integer) returns Vec2d
--- Purpose : For the point of parameter U of this line, computes
-- the vector corresponding to the Nth derivative.
-- Note: if N is greater than or equal to 2, the result is a
-- vector with null magnitude.
-- Exceptions Standard_RangeError if N is less than 1.
raises RangeError;
Transform (me : mutable; T : Trsf2d);
---Purpose: Applies the transformation T to this line.
TransformedParameter(me; U : Real; T : Trsf2d from gp) returns Real
---Purpose: Computes the parameter on the line transformed by
-- T for the point of parameter U on this line.
-- For a line, the returned value is equal to U multiplied
-- by the scale factor of transformation T.
is redefined;
ParametricTransformation(me; T : Trsf2d from gp) returns Real
---Purpose: Returns the coefficient required to compute the
-- parametric transformation of this line when
-- transformation T is applied. This coefficient is the
-- ratio between the parameter of a point on this line
-- and the parameter of the transformed point on the
-- new line transformed by T.
-- For a line, the returned value is the scale factor of the transformation T.
is redefined;
Copy (me) returns mutable like me;
---Purpose: Creates a new object, which is a copy of this line.
fields
pos : Ax2d;
end;

285
src/Geom2d/Geom2d_Line.cxx Executable file
View File

@@ -0,0 +1,285 @@
// File: Geom2d_Line.cxx
// Created: Wed Mar 24 19:23:23 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Line.cxx ,JCV 12/07/91
#include <Geom2d_Line.ixx>
#include <Precision.hxx>
#include <ElCLib.hxx>
#include <gp_XY.hxx>
#include <Standard_RangeError.hxx>
typedef Geom2d_Line Line;
typedef Handle(Geom2d_Line) Handle(Line);
typedef gp_Ax2d Ax2d;
typedef gp_Dir2d Dir2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Vec2d Vec2d;
typedef gp_Trsf2d Trsf2d;
typedef gp_XY XY;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom2d_Geometry) Geom2d_Line::Copy() const
{
Handle(Line) L;
L = new Line (pos);
return L;
}
//=======================================================================
//function : Geom2d_Line
//purpose :
//=======================================================================
Geom2d_Line::Geom2d_Line (const Ax2d& A) : pos (A) { }
//=======================================================================
//function : Geom2d_Line
//purpose :
//=======================================================================
Geom2d_Line::Geom2d_Line (const gp_Lin2d& L) : pos (L.Position()) { }
//=======================================================================
//function : Geom2d_Line
//purpose :
//=======================================================================
Geom2d_Line::Geom2d_Line (const Pnt2d& P, const Dir2d& V) : pos (P, V) { }
//=======================================================================
//function : SetDirection
//purpose :
//=======================================================================
void Geom2d_Line::SetDirection (const Dir2d& V) { pos.SetDirection (V); }
//=======================================================================
//function : Direction
//purpose :
//=======================================================================
const gp_Dir2d& Geom2d_Line::Direction () const { return pos.Direction (); }
//=======================================================================
//function : SetLin2d
//purpose :
//=======================================================================
void Geom2d_Line::SetLin2d (const gp_Lin2d& L) { pos = L.Position(); }
//=======================================================================
//function : SetLocation
//purpose :
//=======================================================================
void Geom2d_Line::SetLocation (const Pnt2d& P) { pos.SetLocation (P); }
//=======================================================================
//function : Location
//purpose :
//=======================================================================
const gp_Pnt2d& Geom2d_Line::Location () const { return pos.Location (); }
//=======================================================================
//function : SetPosition
//purpose :
//=======================================================================
void Geom2d_Line::SetPosition (const Ax2d& A) { pos = A; }
//=======================================================================
//function : Position
//purpose :
//=======================================================================
const gp_Ax2d& Geom2d_Line::Position () const { return pos; }
//=======================================================================
//function : Lin2d
//purpose :
//=======================================================================
gp_Lin2d Geom2d_Line::Lin2d () const { return gp_Lin2d (pos); }
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
void Geom2d_Line::Reverse () { pos.Reverse(); }
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Line::ReversedParameter( const Standard_Real U) const { return (-U); }
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Line::FirstParameter () const
{ return -Precision::Infinite(); }
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Line::LastParameter () const
{ return Precision::Infinite(); }
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Line::IsClosed () const { return Standard_False; }
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Line::IsPeriodic () const { return Standard_False; }
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom2d_Line::Continuity () const { return GeomAbs_CN; }
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Line::IsCN (const Standard_Integer ) const { return Standard_True; }
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2d_Line::D0 (const Standard_Real U, Pnt2d& P) const
{
P = ElCLib::LineValue (U, pos);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_Line::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const
{
ElCLib::LineD1 (U, pos, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_Line::D2 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2) const
{
ElCLib::LineD1 (U, pos, P, V1);
V2.SetCoord (0.0, 0.0);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2d_Line::D3 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2, Vec2d& V3) const
{
ElCLib::LineD1 (U, pos, P, V1);
V2.SetCoord (0.0, 0.0);
V3.SetCoord (0.0, 0.0);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec2d Geom2d_Line::DN
(const Standard_Real ,
const Standard_Integer N ) const
{
Standard_RangeError_Raise_if (N <= 0, " ");
if (N == 1)
return Vec2d (pos.Direction ());
else
return Vec2d (0.0, 0.0);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom2d_Line::Transform (const Trsf2d& T) { pos.Transform (T); }
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Line::TransformedParameter(const Standard_Real U,
const gp_Trsf2d& T) const
{
if (Precision::IsInfinite(U)) return U;
return U * Abs(T.ScaleFactor());
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
Standard_Real Geom2d_Line::ParametricTransformation(const gp_Trsf2d& T) const
{
return Abs(T.ScaleFactor());
}
//=======================================================================
//function : Distance
//purpose :
//=======================================================================
Standard_Real Geom2d_Line::Distance (const gp_Pnt2d& P) const {
gp_Lin2d L (pos);
return L.Distance (P);
}

331
src/Geom2d/Geom2d_OffsetCurve.cdl Executable file
View File

@@ -0,0 +1,331 @@
-- File: Geom2d_OffsetCurve.cdl
-- Created: Wed Mar 24 18:20:16 1993
-- Author: Philippe DAUTRY
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
class OffsetCurve from Geom2d inherits Curve from Geom2d
--- Purpose :
-- This class implements the basis services for the creation,
-- edition, modification and evaluation of planar offset curve.
-- The offset curve is obtained by offsetting by distance along
-- the normal to a basis curve defined in 2D space.
-- The offset curve in this package can be a self intersecting
-- curve even if the basis curve does not self-intersect.
-- The self intersecting portions are not deleted at the
-- construction time.
-- An offset curve is a curve at constant distance (Offset) from a
-- basis curve and the offset curve takes its parametrization from
-- the basis curve. The Offset curve is in the direction of the
-- normal to the basis curve N.
-- The distance offset may be positive or negative to indicate the
-- preferred side of the curve :
-- . distance offset >0 => the curve is in the direction of N
-- . distance offset >0 => the curve is in the direction of - N
-- On the Offset curve :
-- Value(u) = BasisCurve.Value(U) + (Offset * (T ^ Z)) / ||T ^ Z||
-- where T is the tangent vector to the basis curve and Z the
-- direction of the normal vector to the plane of the curve,
-- N = T ^ Z defines the offset direction and should not have
-- null length.
--
-- Warnings :
-- In this package we suppose that the continuity of the offset
-- curve is one degree less than the continuity of the
-- basis curve and we don't check that at any point ||T^Z|| != 0.0
--
-- So to evaluate the curve it is better to check that the offset
-- curve is well defined at any point because an exception could
-- be raised. The check is not done in this package at the creation
-- of the offset curve because the control needs the use of an
-- algorithm which cannot be implemented in this package.
-- The OffsetCurve is closed if the first point and the last point
-- are the same (The distance between these two points is lower or
-- equal to the Resolution sea package gp) . The OffsetCurve can be
-- closed even if the basis curve is not closed.
uses Dir2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp,
Curve from Geom2d,
Geometry from Geom2d,
Shape from GeomAbs
raises ConstructionError from Standard,
RangeError from Standard,
NoSuchObject from Standard,
UndefinedDerivative from Geom2d,
UndefinedValue from Geom2d,
NotImplemented from Standard
is
Create (C : Curve from Geom2d; Offset : Real) returns mutable OffsetCurve
--- Purpose : Constructs a curve offset from the basis curve C,
-- where Offset is the distance between the offset
-- curve and the basis curve at any point.
-- A point on the offset curve is built by measuring the
-- offset value along a normal vector at a point on C.
-- This normal vector is obtained by rotating the
-- vector tangential to C at 90 degrees in the
-- anti-trigonometric sense. The side of C on which
-- the offset value is measured is indicated by this
-- normal vector if Offset is positive, or in the inverse
-- sense if Offset is negative.
-- Warnings :
-- In this package the entities are not shared. The OffsetCurve is
-- built with a copy of the curve C. So when C is modified the
-- OffsetCurve is not modified
-- Warning! ConstructionError raised if the basis curve C is not at least C1.
-- No check is done to know if ||V^Z|| != 0.0 at any point.
raises ConstructionError;
Reverse (me : mutable);
--- Purpose : Changes the direction of parametrization of <me>.
-- As a result:
-- - the basis curve is reversed,
-- - the start point of the initial curve becomes the end
-- point of the reversed curve,
-- - the end point of the initial curve becomes the start
-- point of the reversed curve, and
-- - the first and last parameters are recomputed.
ReversedParameter(me; U : Real) returns Real;
---Purpose: Computes the parameter on the reversed curve for
-- the point of parameter U on this offset curve.
SetBasisCurve (me : mutable; C : Curve from Geom2d)
raises ConstructionError;
--- Purpose : Changes this offset curve by assigning C as the
-- basis curve from which it is built.
-- Exceptions
-- Standard_ConstructionError if the curve C is not at least "C1" continuous.
SetOffsetValue (me : mutable; D : Real);
--- Purpose : Changes this offset curve by assigning D as the offset value.
BasisCurve (me) returns Curve from Geom2d;
--- Purpose : Returns the basis curve of this offset curve. The basis curve can be an offset curve.
Continuity (me) returns Shape from GeomAbs;
--- Purpose :
-- Continuity of the Offset curve :
-- C0 : only geometric continuity,
-- C1 : continuity of the first derivative all along the Curve,
-- C2 : continuity of the second derivative all along the Curve,
-- C3 : continuity of the third derivative all along the Curve,
-- G1 : tangency continuity all along the Curve,
-- G2 : curvature continuity all along the Curve,
-- CN : the order of continuity is infinite.
-- Warnings :
-- Returns the continuity of the basis curve - 1.
-- The offset curve must have a unique normal direction defined
-- at any point.
--- Purpose : Value and derivatives
--
-- Warnings :
-- The exception UndefinedValue or UndefinedDerivative is
-- raised if it is not possible to compute a unique offset
-- direction.
-- If T is the first derivative with not null length and
-- Z the direction normal to the plane of the curve, the
-- relation ||T(U) ^ Z|| != 0 must be satisfied to evaluate
-- the offset curve.
-- No check is done at the creation time and we suppose
-- in this package that the offset curve is well defined.
D0 (me; U : Real; P : out Pnt2d)
raises UndefinedValue;
---Purpose: Warning! this should not be called
-- if the basis curve is not at least C1. Nevertheless
-- if used on portion where the curve is C1, it is OK
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d)
raises UndefinedDerivative;
---Purpose: Warning! this should not be called
-- if the continuity of the basis curve is not C2.
-- Nevertheless, it's OK to use it on portion
-- where the curve is C2
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d)
raises UndefinedDerivative;
---Purpose: Warning! This should not be called
-- if the continuity of the basis curve is not C3.
-- Nevertheless, it's OK to use it on portion
-- where the curve is C3
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d)
raises UndefinedDerivative;
---Purpose: Warning! This should not be called
-- if the continuity of the basis curve is not C4.
-- Nevertheless, it's OK to use it on portion
-- where the curve is C4
DN (me; U : Real; N : Integer) returns Vec2d
--- Purpose : The returned vector gives the value of the derivative
-- for the order of derivation N.
-- Warning! this should not be called
-- raises UndefunedDerivative if the continuity of the basis curve is not CN+1.
-- Nevertheless, it's OK to use it on portion
-- where the curve is CN+1
-- raises RangeError if N < 1.
-- raises NotImplemented if N > 3.
raises UndefinedDerivative,
RangeError,
NotImplemented;
--- Purpose : The following functions compute the value and derivatives
-- on the offset curve and returns the derivatives on the
-- basis curve too.
-- The computation of the value and derivatives on the basis
-- curve are used to evaluate the offset curve
-- Warnings :
-- The exception UndefinedValue or UndefinedDerivative is
-- raised if it is not possible to compute a unique offset direction.
Value (me; U : Real; P, Pbasis : out Pnt2d; V1basis : out Vec2d)
raises UndefinedValue;
---Purpose: Warning! this should not be called
-- if the basis curve is not at least C1. Nevertheless
-- if used on portion where the curve is C1, it is OK
D1 (me; U : Real; P, Pbasis : out Pnt2d;
V1, V1basis, V2basis : out Vec2d)
raises UndefinedDerivative;
---Purpose: Warning! this should not be called
-- if the continuity of the basis curve is not C1.
-- Nevertheless, it's OK to use it on portion
-- where the curve is C1
D2 (me; U : Real; P, Pbasis : out Pnt2d; V1, V2, V1basis, V2basis,
V3basis : out Vec2d)
raises UndefinedDerivative;
---Purpose: Warning! this should not be called
-- if the continuity of the basis curve is not C3.
-- Nevertheless, it's OK to use it on portion
-- where the curve is C3
FirstParameter (me) returns Real;
LastParameter (me) returns Real;
---Purpose: Returns the value of the first or last parameter of this
-- offset curve. The first parameter corresponds to the
-- start point of the curve. The last parameter
-- corresponds to the end point.
-- Note: the first and last parameters of this offset curve
-- are also the ones of its basis curve.
Offset (me) returns Real;
---Purpose: Returns the offset value of this offset curve.
IsClosed (me) returns Boolean;
--- Purpose :
-- Returns True if the distance between the start point
-- and the end point of the curve is lower or equal to
-- Resolution from package gp.
IsCN (me; N : Integer) returns Boolean
--- Purpose : Is the order of continuity of the curve N ?
-- Warnings :
-- This method answer True if the continuity of the basis curve
-- is N + 1. We suppose in this class that a normal direction
-- to the basis curve (used to compute the offset curve) is
-- defined at any point on the basis curve.
raises RangeError;
--- Purpose : Raised if N < 0.
IsPeriodic (me) returns Boolean;
--- Purpose : Is the parametrization of a curve is periodic ?
-- If the basis curve is a circle or an ellipse the corresponding
-- OffsetCurve is periodic. If the basis curve can't be periodic
-- (for example BezierCurve) the OffsetCurve can't be periodic.
Period (me) returns Real from Standard
---Purpose: Returns the period of this offset curve, i.e. the period
-- of the basis curve of this offset curve.
-- Exceptions
-- Standard_NoSuchObject if the basis curve is not periodic.
raises NoSuchObject from Standard
is redefined;
Transform (me : mutable; T : Trsf2d);
---Purpose : Applies the transformation T to this offset curve.
-- Note: the basis curve is also modified.
TransformedParameter(me; U : Real; T : Trsf2d from gp) returns Real
---Purpose: Returns the parameter on the transformed curve for
-- the transform of the point of parameter U on <me>.
--
-- me->Transformed(T)->Value(me->TransformedParameter(U,T))
--
-- is the same point as
--
-- me->Value(U).Transformed(T)
--
-- This methods calls the basis curve method.
is redefined;
ParametricTransformation(me; T : Trsf2d from gp) returns Real
---Purpose: Returns a coefficient to compute the parameter on
-- the transformed curve for the transform of the
-- point on <me>.
--
-- Transformed(T)->Value(U * ParametricTransformation(T))
--
-- is the same point as
--
-- Value(U).Transformed(T)
--
-- This methods calls the basis curve method.
is redefined;
Copy (me) returns mutable like me;
---Purpose: Creates a new object, which is a copy of this offset curve.
fields
basisCurve : Curve from Geom2d;
offsetValue : Real;
end;

719
src/Geom2d/Geom2d_OffsetCurve.cxx Executable file
View File

@@ -0,0 +1,719 @@
// File: Geom2d_OffsetCurve.cxx
// Created: Wed Mar 24 19:23:58 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
// File: Geom2d_OffsetCurve.cxx
// Created: Tue Jun 25 15:36:30 1991
// Author: JCV
// modified by Edward AGAPOV (eap) Jan 28 2002 --- DN(), occ143(BUC60654)
#include <Geom2d_OffsetCurve.ixx>
#include <gp.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_NotImplemented.hxx>
#include <Geom2d_UndefinedDerivative.hxx>
#include <Geom2d_UndefinedValue.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <gp_XY.hxx>
typedef Handle(Geom2d_OffsetCurve) Handle(OffsetCurve);
typedef Geom2d_OffsetCurve OffsetCurve;
typedef Handle(Geom2d_Geometry) Handle(Geometry);
typedef Handle(Geom2d_Curve) Handle(Curve);
typedef Geom2d_Curve Curve;
typedef gp_Dir2d Dir2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Vec2d Vec2d;
typedef gp_Trsf2d Trsf2d;
typedef gp_XY XY;
static const int MaxDegree = 9;
//ordre de derivation maximum pour la recherche de la premiere
//derivee non nulle
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom2d_Geometry) Geom2d_OffsetCurve::Copy () const
{
Handle(OffsetCurve) C;
C = new OffsetCurve (basisCurve, offsetValue);
return C;
}
//=======================================================================
//function : Geom2d_OffsetCurve
//purpose :
//=======================================================================
Geom2d_OffsetCurve::Geom2d_OffsetCurve (const Handle(Curve)& C,
const Standard_Real Offset)
: offsetValue (Offset)
{
if (C->DynamicType() == STANDARD_TYPE(Geom2d_OffsetCurve)) {
Handle(OffsetCurve) OC = Handle(OffsetCurve)::DownCast(C->Copy());
if ((OC->BasisCurve())->Continuity() == GeomAbs_C0)
Standard_ConstructionError::Raise();
basisCurve = Handle(Curve)::DownCast((OC->BasisCurve())->Copy());
offsetValue += OC->Offset();
} else {
if (C->Continuity() == GeomAbs_C0)
Standard_ConstructionError::Raise();
basisCurve = Handle(Curve)::DownCast(C->Copy());
}
}
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::Reverse ()
{
basisCurve->Reverse();
offsetValue = -offsetValue;
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_OffsetCurve::ReversedParameter( const Standard_Real U) const
{
return basisCurve->ReversedParameter( U);
}
//=======================================================================
//function : SetBasisCurve
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::SetBasisCurve (const Handle(Curve)& C)
{
if (C->Continuity() == GeomAbs_C0) Standard_ConstructionError::Raise();
basisCurve = Handle(Geom2d_Curve)::DownCast(C->Copy());
}
//=======================================================================
//function : SetOffsetValue
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::SetOffsetValue (const Standard_Real D) { offsetValue = D; }
//=======================================================================
//function : BasisCurve
//purpose :
//=======================================================================
Handle(Curve) Geom2d_OffsetCurve::BasisCurve () const
{
return basisCurve;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom2d_OffsetCurve::Continuity () const
{
GeomAbs_Shape OffsetShape=GeomAbs_C0;
switch (basisCurve->Continuity()) {
case GeomAbs_C0 : OffsetShape = GeomAbs_C0; break;
case GeomAbs_C1 : OffsetShape = GeomAbs_C0; break;
case GeomAbs_C2 : OffsetShape = GeomAbs_C1; break;
case GeomAbs_C3 : OffsetShape = GeomAbs_C2; break;
case GeomAbs_CN : OffsetShape = GeomAbs_CN; break;
case GeomAbs_G1 : OffsetShape = GeomAbs_G1; break;
case GeomAbs_G2 : OffsetShape = GeomAbs_G2; break;
}
return OffsetShape;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::D0 (const Standard_Real U,
Pnt2d& P ) const
{
Vec2d V1;
basisCurve->D1 (U, P, V1);
Standard_Integer Index = 2;
while (V1.Magnitude() <= gp::Resolution() && Index <= MaxDegree) {
V1 = basisCurve->DN (U, Index);
Index++;
}
Standard_Real A = V1.Y();
Standard_Real B = - V1.X();
Standard_Real R = Sqrt(A*A + B * B);
if (R <= gp::Resolution()) Geom2d_UndefinedValue::Raise();
A = A * offsetValue/R;
B = B * offsetValue/R;
P.SetCoord(P.X() + A, P.Y() + B);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const {
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ Z|| and Ndir = P' ^ Z
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
#ifdef DEB
GeomAbs_Shape Continuity = basisCurve->Continuity();
#else
basisCurve->Continuity();
#endif
Vec2d V2;
basisCurve->D2 (U, P, V1, V2);
Standard_Integer Index = 2;
while (V1.Magnitude() <= gp::Resolution() && Index <= MaxDegree) {
V1 = basisCurve->DN (U, Index);
Index++;
}
if (Index != 2) { V2 = basisCurve->DN (U, Index); }
XY Ndir (V1.Y(), -V1.X());
XY DNdir (V2.Y(), -V2.X());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R * R2;
Standard_Real Dr = Ndir.Dot (DNdir);
if (R3 <= gp::Resolution()) {
//We try another computation but the stability is not very good.
if (R2 <= gp::Resolution()) Geom2d_UndefinedDerivative::Raise();
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (offsetValue/R2);
V1.Add (Vec2d(DNdir));
}
else {
// Same computation as IICURV in EUCLID-IS because the stability is
// better
DNdir.Multiply (offsetValue/R);
DNdir.Subtract (Ndir.Multiplied (offsetValue*Dr/R3));
V1.Add (Vec2d(DNdir));
}
Ndir.Multiply (offsetValue/R);
Ndir.Add (P.XY());
P.SetXY (Ndir);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::D2 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2) const
{
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ Z|| and Ndir = P' ^ Z
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
// P"(u) = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
// Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
#ifdef DEB
GeomAbs_Shape Continuity = basisCurve->Continuity();
#else
basisCurve->Continuity();
#endif
Vec2d V3;
basisCurve->D3 (U, P, V1, V2, V3);
Standard_Integer Index = 2;
while (V1.Magnitude() <= gp::Resolution() && Index <= MaxDegree) {
V1 = basisCurve->DN (U, Index);
Index++;
}
if (Index != 2) {
V2 = basisCurve->DN (U, Index);
V3 = basisCurve->DN (U, Index + 1);
}
XY Ndir (V1.Y(), -V1.X());
XY DNdir (V2.Y(), -V2.X());
XY D2Ndir (V3.Y(), -V3.X());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R2 * R;
Standard_Real R4 = R2 * R2;
Standard_Real R5 = R3 * R2;
Standard_Real Dr = Ndir.Dot (DNdir);
Standard_Real D2r = Ndir.Dot (D2Ndir) + DNdir.Dot (DNdir);
if (R5 <= gp::Resolution()) {
//We try another computation but the stability is not very good
//dixit ISG.
if (R4 <= gp::Resolution()) { Geom2d_UndefinedDerivative::Raise(); }
// V2 = P" (U) :
Standard_Real R4 = R2 * R2;
D2Ndir.Subtract (DNdir.Multiplied (2.0 * Dr / R2));
D2Ndir.Add (Ndir.Multiplied (((3.0 * Dr * Dr)/R4) - (D2r/R2)));
D2Ndir.Multiply (offsetValue / R);
V2.Add (Vec2d(D2Ndir));
// V1 = P' (U) :
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (offsetValue/R2);
V1.Add (Vec2d(DNdir));
}
else {
// Same computation as IICURV in EUCLID-IS because the stability is
// better.
// V2 = P" (U) :
D2Ndir.Multiply (offsetValue/R);
D2Ndir.Subtract (DNdir.Multiplied (2.0 * offsetValue * Dr / R3));
D2Ndir.Add (Ndir.Multiplied
(offsetValue * (((3.0 * Dr * Dr) / R5) - (D2r / R3))));
V2.Add (Vec2d(D2Ndir));
// V1 = P' (U)
DNdir.Multiply (offsetValue/R);
DNdir.Subtract (Ndir.Multiplied (offsetValue*Dr/R3));
V1.Add (Vec2d(DNdir));
}
//P (U) :
Ndir.Multiply (offsetValue/R);
Ndir.Add (P.XY());
P.SetXY (Ndir);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::D3 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2, Vec2d& V3) const {
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ Z|| and Ndir = P' ^ Z
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
// P"(u) = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
// Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
//P"'(u) = p"'(u) + (Offset / R) * (D3Ndir - (3.0 * Dr/R**2 ) * D2Ndir -
// (3.0 * D2r / R2) * DNdir) + (3.0 * Dr * Dr / R4) * DNdir -
// (D3r/R2) * Ndir + (6.0 * Dr * Dr / R4) * Ndir +
// (6.0 * Dr * D2r / R4) * Ndir - (15.0 * Dr* Dr* Dr /R6) * Ndir
basisCurve->D3 (U, P, V1, V2, V3);
Vec2d V4 = basisCurve->DN (U, 4);
Standard_Integer Index = 2;
while (V1.Magnitude() <= gp::Resolution() && Index <= MaxDegree) {
V1 = basisCurve->DN (U, Index);
Index++;
}
if (Index != 2) {
V2 = basisCurve->DN (U, Index);
V3 = basisCurve->DN (U, Index + 1);
V4 = basisCurve->DN (U, Index + 2);
}
XY Ndir (V1.Y(), -V1.X());
XY DNdir (V2.Y(), -V2.X());
XY D2Ndir (V3.Y(), -V3.X());
XY D3Ndir (V4.Y(), -V4.X());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R2 * R;
Standard_Real R4 = R2 * R2;
Standard_Real R5 = R3 * R2;
Standard_Real R6 = R3 * R3;
Standard_Real R7 = R5 * R2;
Standard_Real Dr = Ndir.Dot (DNdir);
Standard_Real D2r = Ndir.Dot (D2Ndir) + DNdir.Dot (DNdir);
Standard_Real D3r = Ndir.Dot (D3Ndir) + 3.0 * DNdir.Dot (D2Ndir);
if (R7 <= gp::Resolution()) {
//We try another computation but the stability is not very good
//dixit ISG.
if (R6 <= gp::Resolution()) Geom2d_UndefinedDerivative::Raise();
// V3 = P"' (U) :
D3Ndir.Subtract (D2Ndir.Multiplied (3.0 * offsetValue * Dr / R2));
D3Ndir.Subtract (
(DNdir.Multiplied ((3.0 * offsetValue) * ((D2r/R2) + (Dr*Dr)/R4))));
D3Ndir.Add (Ndir.Multiplied (
(offsetValue * (6.0*Dr*Dr/R4 + 6.0*Dr*D2r/R4 - 15.0*Dr*Dr*Dr/R6 - D3r))
));
D3Ndir.Multiply (offsetValue/R);
V3.Add (Vec2d(D3Ndir));
// V2 = P" (U) :
Standard_Real R4 = R2 * R2;
D2Ndir.Subtract (DNdir.Multiplied (2.0 * Dr / R2));
D2Ndir.Subtract (Ndir.Multiplied (((3.0 * Dr * Dr)/R4) - (D2r/R2)));
D2Ndir.Multiply (offsetValue / R);
V2.Add (Vec2d(D2Ndir));
// V1 = P' (U) :
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (offsetValue/R2);
V1.Add (Vec2d(DNdir));
}
else {
// Same computation as IICURV in EUCLID-IS because the stability is
// better.
// V3 = P"' (U) :
D3Ndir.Multiply (offsetValue/R);
D3Ndir.Subtract (D2Ndir.Multiplied (3.0 * offsetValue * Dr / R3));
D3Ndir.Subtract (DNdir.Multiplied (
((3.0 * offsetValue) * ((D2r/R3) + (Dr*Dr)/R5))) );
D3Ndir.Add (Ndir.Multiplied (
(offsetValue * (6.0*Dr*Dr/R5 + 6.0*Dr*D2r/R5 - 15.0*Dr*Dr*Dr/R7 - D3r))
));
V3.Add (Vec2d(D3Ndir));
// V2 = P" (U) :
D2Ndir.Multiply (offsetValue/R);
D2Ndir.Subtract (DNdir.Multiplied (2.0 * offsetValue * Dr / R3));
D2Ndir.Subtract (Ndir.Multiplied (
offsetValue * (((3.0 * Dr * Dr) / R5) - (D2r / R3))
)
);
V2.Add (Vec2d(D2Ndir));
// V1 = P' (U) :
DNdir.Multiply (offsetValue/R);
DNdir.Subtract (Ndir.Multiplied (offsetValue*Dr/R3));
V1.Add (Vec2d(DNdir));
}
//P (U) :
Ndir.Multiply (offsetValue/R);
Ndir.Add (P.XY());
P.SetXY (Ndir);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec2d Geom2d_OffsetCurve::DN (const Standard_Real U,
const Standard_Integer N) const
{
Standard_RangeError_Raise_if (N < 1, "Geom2d_OffsetCurve::DN()");
gp_Vec2d VN, VBidon;
gp_Pnt2d PBidon;
switch (N) {
case 1: D1( U, PBidon, VN); break;
case 2: D2( U, PBidon, VBidon, VN); break;
case 3: D3( U, PBidon, VBidon, VBidon, VN); break;
default:
Standard_NotImplemented::Raise();
}
return VN;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::Value (const Standard_Real U,
Pnt2d& P, Pnt2d& Pbasis,
Vec2d& V1basis ) const
{
basisCurve->D1 (U, Pbasis, V1basis);
Standard_Integer Index = 2;
while (V1basis.Magnitude() <= gp::Resolution() && Index <= MaxDegree) {
V1basis = basisCurve->DN (U, Index);
Index++;
}
Standard_Real A = V1basis.Y();
Standard_Real B = - V1basis.X();
Standard_Real R = Sqrt(A*A + B * B);
if (R <= gp::Resolution()) Geom2d_UndefinedValue::Raise();
A = A * offsetValue/R;
B = B * offsetValue/R;
P.SetCoord (A + Pbasis.X(), B + Pbasis.Y());
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::D1 (const Standard_Real U,
Pnt2d& P, Pnt2d& Pbasis,
Vec2d& V1, Vec2d& V1basis,
Vec2d& V2basis ) const
{
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ Z|| and Ndir = P' ^ Z
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
#ifdef DEB
GeomAbs_Shape Continuity = basisCurve->Continuity();
#else
basisCurve->Continuity();
#endif
basisCurve->D2 (U, Pbasis, V1basis, V2basis);
V1 = V1basis;
Vec2d V2 = V2basis;
Standard_Integer Index = 2;
while (V1.Magnitude() <= gp::Resolution() && Index <= MaxDegree) {
V1 = basisCurve->DN (U, Index);
Index++;
}
if (Index != 2) {
V2 = basisCurve->DN (U, Index);
}
XY Ndir (V1.Y(), -V1.X());
XY DNdir (V2.Y(), -V2.X());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R * R2;
Standard_Real Dr = Ndir.Dot (DNdir);
if (R3 <= gp::Resolution()) {
//We try another computation but the stability is not very good.
if (R2 <= gp::Resolution()) { Geom2d_UndefinedDerivative::Raise(); }
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (offsetValue / R2);
V1.Add (Vec2d(DNdir));
}
else {
// Same computation as IICURV in EUCLID-IS because the stability is
// better
DNdir.Multiply (offsetValue/R);
DNdir.Subtract (Ndir.Multiplied (offsetValue*Dr/R3));
V1.Add (Vec2d(DNdir));
}
Ndir.Multiply (offsetValue/R);
Ndir.Add (Pbasis.XY());
P.SetXY (Ndir);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::D2 (const Standard_Real U,
Pnt2d& P, Pnt2d& Pbasis,
Vec2d& V1, Vec2d& V2,
Vec2d& V1basis, Vec2d& V2basis,
Vec2d& V3basis ) const
{
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ Z|| and Ndir = P' ^ Z
// P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R - Ndir * (DR/R))
// P"(u) = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
// Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
#ifdef DEB
GeomAbs_Shape Continuity = basisCurve->Continuity();
#else
basisCurve->Continuity();
#endif
basisCurve->D3 (U, Pbasis, V1basis, V2basis, V3basis);
Standard_Integer Index = 2;
V1 = V1basis;
V2 = V2basis;
Vec2d V3 = V3basis;
while (V1.Magnitude() <= gp::Resolution() && Index <= MaxDegree) {
V1 = basisCurve->DN (U, Index);
Index++;
}
if (Index != 2) {
V2 = basisCurve->DN (U, Index);
V3 = basisCurve->DN (U, Index + 1);
}
XY Ndir (V1.Y(), -V1.X());
XY DNdir (V2.Y(), -V2.X());
XY D2Ndir (V3.Y(), -V3.X());
Standard_Real R2 = Ndir.SquareModulus();
Standard_Real R = Sqrt (R2);
Standard_Real R3 = R2 * R;
Standard_Real R4 = R2 * R2;
Standard_Real R5 = R3 * R2;
Standard_Real Dr = Ndir.Dot (DNdir);
Standard_Real D2r = Ndir.Dot (D2Ndir) + DNdir.Dot (DNdir);
if (R5 <= gp::Resolution()) {
//We try another computation but the stability is not very good
//dixit ISG.
if (R4 <= gp::Resolution()) { Geom2d_UndefinedDerivative::Raise(); }
// V2 = P" (U) :
Standard_Real R4 = R2 * R2;
D2Ndir.Subtract (DNdir.Multiplied (2.0 * Dr / R2));
D2Ndir.Subtract (Ndir.Multiplied (((3.0 * Dr * Dr)/R4) - (D2r/R2)));
D2Ndir.Multiply (offsetValue / R);
V2.Add (Vec2d(D2Ndir));
// V1 = P' (U) :
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (offsetValue/R2);
V1.Add (Vec2d(DNdir));
}
else {
// Same computation as IICURV in EUCLID-IS because the stability is
// better.
// V2 = P" (U) :
D2Ndir.Multiply (offsetValue/R);
D2Ndir.Subtract (DNdir.Multiplied (2.0 * offsetValue * Dr / R3));
D2Ndir.Subtract (Ndir.Multiplied (
offsetValue * (((3.0 * Dr * Dr) / R5) - (D2r / R3))
)
);
V2.Add (Vec2d(D2Ndir));
// V1 = P' (U) :
DNdir.Multiply (offsetValue/R);
DNdir.Subtract (Ndir.Multiplied (offsetValue*Dr/R3));
V1.Add (Vec2d(DNdir));
}
//P (U) :
Ndir.Multiply (offsetValue/R);
Ndir.Add (Pbasis.XY());
P.SetXY (Ndir);
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_OffsetCurve::FirstParameter () const
{
return basisCurve->FirstParameter();
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_OffsetCurve::LastParameter () const
{
return basisCurve->LastParameter();
}
//=======================================================================
//function : Offset
//purpose :
//=======================================================================
Standard_Real Geom2d_OffsetCurve::Offset () const { return offsetValue; }
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2d_OffsetCurve::IsClosed () const
{
gp_Pnt2d PF, PL;
D0(FirstParameter(),PF);
D0(LastParameter(),PL);
return ( PF.Distance(PL) <= gp::Resolution());
}
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom2d_OffsetCurve::IsCN (const Standard_Integer N) const
{
Standard_RangeError_Raise_if (N < 0, " " );
return basisCurve->IsCN (N + 1);
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2d_OffsetCurve::IsPeriodic () const
{
return basisCurve->IsPeriodic();
}
//=======================================================================
//function : Period
//purpose :
//=======================================================================
Standard_Real Geom2d_OffsetCurve::Period() const
{
return basisCurve->Period();
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom2d_OffsetCurve::Transform (const Trsf2d& T)
{
basisCurve->Transform (T);
offsetValue *= Abs(T.ScaleFactor());
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_OffsetCurve::TransformedParameter(const Standard_Real U,
const gp_Trsf2d& T) const
{
return basisCurve->TransformedParameter(U,T);
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
Standard_Real Geom2d_OffsetCurve::ParametricTransformation(const gp_Trsf2d& T) const
{
return basisCurve->ParametricTransformation(T);
}

225
src/Geom2d/Geom2d_Parabola.cdl Executable file
View File

@@ -0,0 +1,225 @@
-- File: Geom2d_Parabola.cdl
-- Created: Wed Mar 24 18:22:05 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991, 1992
class Parabola from Geom2d inherits Conic from Geom2d
--- Purpose : Describes a parabola in the plane (2D space).
-- A parabola is defined by its focal length (i.e. the
-- distance between its focus and its apex) and is
-- positioned in the plane with a coordinate system
-- (gp_Ax22d object) where:
-- - the origin is the apex of the parabola, and
-- - the "X Axis" defines the axis of symmetry; the
-- parabola is on the positive side of this axis.
-- This coordinate system is the local coordinate
-- system of the parabola.
-- The orientation (direct or indirect) of the local
-- coordinate system gives an explicit orientation to the
-- parabola, determining the direction in which the
-- parameter increases along the parabola.
-- The Geom_Parabola parabola is parameterized as follows:
-- P(U) = O + U*U/(4.*F)*XDir + U*YDir, where:
-- - P is the point of parameter U,
-- - O, XDir and YDir are respectively the origin, "X
-- Direction" and "Y Direction" of its local coordinate system,
-- - F is the focal length of the parabola.
-- The parameter of the parabola is therefore its Y
-- coordinate in the local coordinate system, with the "X
-- Axis" of the local coordinate system defining the
-- origin of the parameter.
-- The parameter range is ] -infinite,+infinite [.
uses Ax2d from gp,
Ax22d from gp,
Parab2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp,
Geometry from Geom2d
raises ConstructionError from Standard,
RangeError from Standard
is
Create (Prb : Parab2d) returns mutable Parabola;
--- Purpose : Creates a parabola from a non persistent one.
Create (MirrorAxis : Ax2d; Focal : Real;
Sense: Boolean from Standard = Standard_True)
returns mutable Parabola
--- Purpose :
-- Creates a parabola with its "MirrorAxis" and it's focal
-- length "Focal".
-- MirrorAxis is the axis of symmetry of the curve, it is the
-- "XAxis". The "YAxis" is parallel to the directrix of the
-- parabola and is in the direct sense if Sense is True.
-- The "Location" point of "MirrorAxis" is the vertex of the parabola
raises ConstructionError;
--- Purpose : Raised if Focal < 0.0
Create (Axis : Ax22d; Focal : Real) returns mutable Parabola
--- Purpose :
-- Creates a parabola with its Axis and it's focal
-- length "Focal".
-- The XDirection of Axis is the axis of symmetry of the curve,
-- it is the "XAxis". The "YAxis" is parallel to the directrix of the
-- parabola. The "Location" point of "Axis" is the vertex
-- of the parabola.
raises ConstructionError;
--- Purpose : Raised if Focal < 0.0
Create (D : Ax2d; F : Pnt2d) returns mutable Parabola;
--- Purpose :
-- D is the directrix of the parabola and F the focus point.
-- The symmetry axis "XAxis" of the parabola is normal to the
-- directrix and pass through the focus point F, but its
-- "Location" point is the vertex of the parabola.
-- The "YAxis" of the parabola is parallel to D and its "Location"
-- point is the vertex of the parabola.
SetFocal (me : mutable; Focal : Real)
--- Purpose : Assigns the value Focal to the focal length of this parabola.
-- Exceptions Standard_ConstructionError if Focal is negative.
raises ConstructionError;
SetParab2d (me : mutable; Prb : Parab2d);
--- Purpose: Converts the gp_Parab2d parabola Prb into this parabola.
Parab2d (me) returns Parab2d;
--- Purpose :
-- Returns the non persistent parabola from gp with the same
-- geometric properties as <me>.
ReversedParameter(me; U : Real) returns Real is redefined static;
---Purpose: Computes the parameter on the reversed parabola
-- for the point of parameter U on this parabola.
-- For a parabola, the returned value is -U.
FirstParameter (me) returns Real is redefined static;
--- Purpose : Returns RealFirst from Standard.
LastParameter (me) returns Real is redefined static;
--- Purpose : Returns RealLast from Standard.
IsClosed (me) returns Boolean is redefined static;
--- Purpose : Returns False
IsPeriodic (me) returns Boolean is redefined static;
--- Purpose : Returns False
Directrix (me) returns Ax2d;
--- Purpose : The directrix is parallel to the "YAxis" of the parabola.
-- The "Location" point of the directrix is the intersection
-- point between the directrix and the symmetry axis ("XAxis") of the parabola.
Eccentricity (me) returns Real is redefined static;
--- Purpose : Returns the eccentricity e = 1.0
Focus (me) returns Pnt2d;
---Purpose: Computes the focus of this parabola The focus is on the
-- positive side of the "X Axis" of the local coordinate system of the parabola.
Focal (me) returns Real;
--- Purpose : Computes the focal length of this parabola.
-- The focal length is the distance between the apex and the focus of the parabola.
Parameter (me) returns Real;
--- Purpose : Computes the parameter of this parabola, which is
-- the distance between its focus and its directrix. This
-- distance is twice the focal length.
-- If P is the parameter of the parabola, the equation of
-- the parabola in its local coordinate system is: Y**2 = 2.*P*X.
D0(me; U : Real; P : out Pnt2d) is redefined static;
---Purpose: Returns in P the point of parameter U.
-- If U = 0 the returned point is the origin of the XAxis and
-- the YAxis of the parabola and it is the vertex of the parabola.
-- P = S + F * (U * U * XDir + * U * YDir)
-- where S is the vertex of the parabola, XDir the XDirection and
-- YDir the YDirection of the parabola's local coordinate system.
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U and the first derivative V1.
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2.
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d) is redefined static;
--- Purpose :
-- Returns the point P of parameter U, the first second and third
-- derivatives V1 V2 and V3.
DN (me; U : Real; N : Integer) returns Vec2d
--- Purpose : For the point of parameter U of this parabola,
-- computes the vector corresponding to the Nth derivative.
-- Exceptions Standard_RangeError if N is less than 1.
raises RangeError
is redefined static;
Transform (me : mutable; T : Trsf2d) is redefined static;
---Purpose: Applies the transformation T to this parabola.
TransformedParameter(me; U : Real; T : Trsf2d from gp) returns Real
---Purpose: Computes the parameter on the transformed
-- parabola, for the point of parameter U on this parabola.
-- For a parabola, the returned value is equal to U
-- multiplied by the scale factor of transformation T.
is redefined static;
ParametricTransformation(me; T : Trsf2d from gp) returns Real
---Purpose: Returns a coefficient to compute the parameter on
-- the transformed curve for the transform of the
-- point on <me>.
--
-- Transformed(T)->Value(U * ParametricTransformation(T))
--
-- is the same point as
--
-- Value(U).Transformed(T)
--
-- This methods returns T.ScaleFactor()
is redefined static;
Copy (me) returns mutable like me
is redefined static;
---Purpose: Creates a new object, which is a copy of this parabola.
fields
focalLength : Real;
end;

326
src/Geom2d/Geom2d_Parabola.cxx Executable file
View File

@@ -0,0 +1,326 @@
// File: Geom2d_Parabola.cxx
// Created: Wed Mar 24 19:27:19 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Parabola.cxx, JCV 17/01/91
#include <Geom2d_Parabola.ixx>
#include <Precision.hxx>
#include <gp_XY.hxx>
#include <ElCLib.hxx>
#include <gp_Dir2d.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
typedef Geom2d_Parabola Parabola;
typedef Handle(Geom2d_Parabola) Handle(Parabola);
typedef gp_Ax2d Ax2d;
typedef gp_Dir2d Dir2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Vec2d Vec2d;
typedef gp_Trsf2d Trsf2d;
typedef gp_XY XY;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom2d_Geometry) Geom2d_Parabola::Copy() const
{
Handle(Parabola) Prb;
Prb = new Parabola (pos, focalLength);
return Prb;
}
//=======================================================================
//function : Geom2d_Parabola
//purpose :
//=======================================================================
Geom2d_Parabola::Geom2d_Parabola (const gp_Parab2d& Prb)
{
focalLength = Prb.Focal ();
pos = Prb.Axis();
}
//=======================================================================
//function : Geom2d_Parabola
//purpose :
//=======================================================================
Geom2d_Parabola::Geom2d_Parabola (const Ax2d& MirrorAxis,
const Standard_Real Focal,
const Standard_Boolean Sense)
: focalLength (Focal)
{
if (Focal < 0.0) { Standard_ConstructionError::Raise(); }
pos = gp_Ax22d(MirrorAxis, Sense);
}
//=======================================================================
//function : Geom2d_Parabola
//purpose :
//=======================================================================
Geom2d_Parabola::Geom2d_Parabola (const gp_Ax22d& Axis, const Standard_Real Focal)
: focalLength (Focal)
{
if (Focal < 0.0) { Standard_ConstructionError::Raise(); }
pos = Axis;
}
//=======================================================================
//function : Geom2d_Parabola
//purpose :
//=======================================================================
Geom2d_Parabola::Geom2d_Parabola (const Ax2d& D, const Pnt2d& F) {
gp_Parab2d Prb (D, F);
pos = Prb.Axis();
focalLength = Prb.Focal();
}
//=======================================================================
//function : SetFocal
//purpose :
//=======================================================================
void Geom2d_Parabola::SetFocal (const Standard_Real Focal)
{
if (Focal < 0.0) Standard_ConstructionError::Raise();
focalLength = Focal;
}
//=======================================================================
//function : SetParab2d
//purpose :
//=======================================================================
void Geom2d_Parabola::SetParab2d (const gp_Parab2d& Prb)
{
focalLength = Prb.Focal ();
pos = Prb.Axis();
}
//=======================================================================
//function : Parab2d
//purpose :
//=======================================================================
gp_Parab2d Geom2d_Parabola::Parab2d () const
{
return gp_Parab2d (pos, focalLength);
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Parabola::ReversedParameter( const Standard_Real U) const
{
return ( -U);
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Parabola::FirstParameter () const
{
return -Precision::Infinite();
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Parabola::LastParameter () const
{
return Precision::Infinite();
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Parabola::IsClosed () const
{
return Standard_False;
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2d_Parabola::IsPeriodic () const
{
return Standard_False;
}
//=======================================================================
//function : Directrix
//purpose :
//=======================================================================
Ax2d Geom2d_Parabola::Directrix () const
{
gp_Parab2d Prb (pos, focalLength);
return Prb.Directrix();
}
//=======================================================================
//function : Eccentricity
//purpose :
//=======================================================================
Standard_Real Geom2d_Parabola::Eccentricity () const
{
return 1.0;
}
//=======================================================================
//function : Focus
//purpose :
//=======================================================================
Pnt2d Geom2d_Parabola::Focus () const
{
XY Pxy = pos.XDirection().XY();
Pxy.Multiply (focalLength);
Pxy.Add (pos.Location().XY());
return Pnt2d (Pxy);
}
//=======================================================================
//function : Focal
//purpose :
//=======================================================================
Standard_Real Geom2d_Parabola::Focal () const
{
return focalLength;
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Parabola::Parameter () const
{
return 2.0 * focalLength;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2d_Parabola::D0 (const Standard_Real U,
Pnt2d& P) const
{
P = ElCLib::ParabolaValue (U, pos, focalLength);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_Parabola::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const
{
ElCLib::ParabolaD1 (U, pos, focalLength, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_Parabola::D2 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2) const
{
ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2d_Parabola::D3 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2, Vec2d& V3) const
{
ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
V3.SetCoord (0.0, 0.0);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec2d Geom2d_Parabola::DN (const Standard_Real U, const Standard_Integer N) const
{
Standard_RangeError_Raise_if (N < 1, " ");
return ElCLib::ParabolaDN (U, pos, focalLength, N);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom2d_Parabola::Transform (const Trsf2d& T)
{
focalLength *= Abs(T.ScaleFactor());
pos.Transform (T);
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_Parabola::TransformedParameter(const Standard_Real U,
const gp_Trsf2d& T) const
{
if (Precision::IsInfinite(U)) return U;
return U * Abs(T.ScaleFactor());
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
Standard_Real Geom2d_Parabola::ParametricTransformation(const gp_Trsf2d& T) const
{
return Abs(T.ScaleFactor());
}

51
src/Geom2d/Geom2d_Point.cdl Executable file
View File

@@ -0,0 +1,51 @@
-- File: Geom2d_Point.cdl
-- Created: Wed Mar 24 18:22:36 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
deferred class Point from Geom2d inherits Geometry from Geom2d
--- Purpose : The abstract class Point describes the common
-- behavior of geometric points in 2D space.
-- The Geom2d package also provides the concrete
-- class Geom2d_CartesianPoint.
uses Pnt2d from gp
is
Coord (me; X, Y : out Real)
--- Purpose : returns the Coordinates of <me>.
is deferred;
Pnt2d (me) returns Pnt2d
--- Purpose : returns a non persistent copy of <me>
is deferred;
X (me) returns Real
--- Purpose : returns the X coordinate of <me>.
is deferred;
Y (me) returns Real
--- Purpose : returns the Y coordinate of <me>.
is deferred;
Distance (me; Other : Point) returns Real;
--- Purpose : computes the distance between <me> and <Other>.
SquareDistance (me; Other : Point) returns Real;
--- Purpose : computes the square distance between <me> and <Other>.
end;

28
src/Geom2d/Geom2d_Point.cxx Executable file
View File

@@ -0,0 +1,28 @@
// File: Geom2d_Point.cxx
// Created: Wed Mar 24 19:27:37 1993
// Author: Philippe DAUTRY
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Point.cxx, JCV 23/06/91
#include <Geom2d_Point.ixx>
typedef Geom2d_Point Point;
typedef Handle(Geom2d_Point) Handle(Point);
Standard_Real Geom2d_Point::Distance (const Handle(Point)& Other) const {
gp_Pnt2d P1 = this-> Pnt2d ();
gp_Pnt2d P2 = Other->Pnt2d ();
return P1.Distance (P2);
}
Standard_Real Geom2d_Point::SquareDistance (const Handle(Point)& Other) const {
gp_Pnt2d P1 = this-> Pnt2d ();
gp_Pnt2d P2 = Other->Pnt2d ();
return P1.SquareDistance (P2);
}

View File

@@ -0,0 +1,232 @@
-- File: Geom2d_Transformation.cdl
-- Created: Wed Mar 24 18:23:20 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
class Transformation from Geom2d inherits TShared from MMgt
--- Purpose :
-- The class Transformation allows to create Translation,
-- Rotation, Symmetry, Scaling and complex transformations
-- obtained by combination of the previous elementary
-- transformations.
-- The Transformation class can also be used to
-- construct complex transformations by combining
-- these elementary transformations.
-- However, these transformations can never change
-- the type of an object. For example, the projection
-- transformation can change a circle into an ellipse,
-- and therefore change the real type of the object.
-- Such a transformation is forbidden in this
-- environment and cannot be a Geom2d_Transformation.
-- The transformation can be represented as follow :
--
-- V1 V2 T
-- | a11 a12 a14 | | x | | x'|
-- | a21 a22 a24 | | y | | y'|
-- | 0 0 1 | | 1 | | 1 |
--
-- where {V1, V2} defines the vectorial part of the
-- transformation and T defines the translation part of
-- the transformation.
-- - Geom2d_Transformation transformations provide
-- the same kind of "geometric" services as
-- gp_Trsf2d ones but have more complex data
-- structures. The geometric objects provided by the
-- Geom2d package use gp_Trsf2d transformations
-- in the syntaxes Transform and Transformed.
-- - Geom2d_Transformation transformations are
-- used in a context where they can be shared by
-- several objects contained inside a common data structure.
uses Ax2d from gp,
Pnt2d from gp,
Trsf2d from gp,
TrsfForm from gp,
Vec2d from gp
raises ConstructionError from Standard,
OutOfRange from Standard
is
Create returns mutable Transformation;
--- Purpose : Creates an identity transformation.
Create (T : Trsf2d) returns mutable Transformation;
--- Purpose : Creates a persistent copy of T.
SetMirror (me : mutable; P : Pnt2d);
--- Purpose :
-- Makes the transformation into a symmetrical transformation
-- with respect to a point P.
-- P is the center of the symmetry.
SetMirror (me : mutable; A : Ax2d);
--- Purpose :
-- Makes the transformation into a symmetrical transformation
-- with respect to an axis A.
-- A is the center of the axial symmetry.
SetRotation (me : mutable; P : Pnt2d; Ang : Real);
--- Purpose : Assigns to this transformation the geometric
-- properties of a rotation at angle Ang (in radians) about point P.
SetScale (me : mutable; P : Pnt2d; S : Real);
--- Purpose :
-- Makes the transformation into a scale. P is the center of
-- the scale and S is the scaling value.
SetTransformation (me : mutable; FromSystem1, ToSystem2 : Ax2d);
--- Purpose :
-- Makes a transformation allowing passage from the coordinate
-- system "FromSystem1" to the coordinate system "ToSystem2".
SetTransformation (me : mutable; ToSystem : Ax2d);
--- Purpose :
-- Makes the transformation allowing passage from the basic
-- coordinate system
-- {P(0.,0.,0.), VX (1.,0.,0.), VY (0.,1.,0.)}
-- to the local coordinate system defined with the Ax2d ToSystem.
SetTranslation (me : mutable; V : Vec2d);
--- Purpose :
-- Makes the transformation into a translation.
-- V is the vector of the translation.
SetTranslation(me : mutable; P1, P2 : Pnt2d);
--- Purpose :
-- Makes the transformation into a translation from the point
-- P1 to the point P2.
SetTrsf2d (me : mutable; T : Trsf2d);
--- Purpose :
-- Makes the transformation into a transformation T from
-- package gp.
IsNegative (me) returns Boolean;
--- Purpose : Checks whether this transformation is an indirect
-- transformation: returns true if the determinant of the
-- matrix of the vectorial part of the transformation is less than 0.
Form (me) returns TrsfForm;
--- Purpose : Returns the nature of this transformation as a value
-- of the gp_TrsfForm enumeration.
-- Returns the nature of the transformation. It can be
-- Identity, Rotation, Translation, PntMirror, Ax1Mirror,
-- Scale, CompoundTrsf
ScaleFactor (me) returns Real;
--- Purpose : Returns the scale value of the transformation.
Trsf2d (me) returns Trsf2d;
--- Purpose : Converts this transformation into a gp_Trsf2d transformation.
-- Returns a non persistent copy of <me>.
-- -C++: return const&
Value (me; Row, Col : Integer) returns Real
--- Purpose :
-- Returns the coefficients of the global matrix of tranformation.
-- It is a 2 rows X 3 columns matrix.
raises OutOfRange;
--- Purpose :
-- Raised if Row < 1 or Row > 2 or Col < 1 or Col > 2
--- Purpose :
-- Computes the reverse transformation.
Invert (me : mutable)
---Purpose: Computes the inverse of this transformation.
-- and assigns the result to this transformatio
raises ConstructionError;
--- Purpose :
-- Raised if the the transformation is singular. This means that
-- the ScaleFactor is lower or equal to Resolution from
-- package gp.
Inverted (me) returns mutable Transformation
raises ConstructionError;
---Purpose: Computes the inverse of this transformation and creates a new one.
-- Raises ConstructionError if the the transformation is singular. This means that
-- the ScaleFactor is lower or equal to Resolution from package gp.
Multiplied (me; Other : Transformation) returns mutable Transformation;
--- Purpose :
-- Computes the transformation composed with Other and <me>.
-- <me> * Other.
-- Returns a new transformation
---C++: alias operator *
Multiply (me : mutable; Other : Transformation);
--- Purpose :
-- Computes the transformation composed with Other and <me> .
-- <me> = <me> * Other.
---C++: alias operator *=
--- Purpose :
-- Computes the following composition of transformations
-- if N > 0 <me> * <me> * .......* <me>.
-- if N = 0 Identity
-- if N < 0 <me>.Invert() * .........* <me>.Invert()
Power (me : mutable; N : Integer)
raises ConstructionError;
--- Purpose :
-- Raised if N < 0 and if the transformation is not inversible
Powered (me; N : Integer) returns Transformation
raises ConstructionError;
--- Purpose :
-- Raised if N < 0 and if the transformation is not inversible
PreMultiply (me : mutable; Other : Transformation);
--- Purpose :
-- Computes the matrix of the transformation composed with
-- <me> and Other. <me> = Other * <me>
Transforms (me; X, Y : in out Real);
--- Purpose :
-- Applies the transformation <me> to the triplet {X, Y}.
Copy (me) returns mutable Transformation;
--- Purpose: Creates a new object, which is a copy of this transformation.
fields
gpTrsf2d : Trsf2d;
end;

View File

@@ -0,0 +1,170 @@
// File: Geom2d_Transformation.cxx
// Created: Wed Mar 24 19:30:53 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Transformation.cxx, JCV 23/06/91
#include <Geom2d_Transformation.ixx>
typedef Geom2d_Transformation Transformation;
typedef Handle(Geom2d_Transformation) Handle(Transformation);
typedef gp_Ax2d Ax2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_TrsfForm TrsfForm;
typedef gp_Vec2d Vec2d;
Handle(Geom2d_Transformation) Geom2d_Transformation::Copy() const {
Handle(Transformation) T;
T = new Transformation (gpTrsf2d);
return T;
}
Geom2d_Transformation::Geom2d_Transformation () { }
Geom2d_Transformation::Geom2d_Transformation (const gp_Trsf2d& T)
: gpTrsf2d (T) { }
Handle(Transformation) Geom2d_Transformation::Inverted () const {
return new Transformation (gpTrsf2d.Inverted());
}
Handle(Transformation) Geom2d_Transformation::Multiplied (
const Handle(Transformation)& Other) const {
return new Transformation (gpTrsf2d.Multiplied (Other->Trsf2d()));
}
Handle(Transformation) Geom2d_Transformation::Powered (const Standard_Integer N) const{
gp_Trsf2d Temp = gpTrsf2d;
Temp.Power (N);
return new Transformation (Temp);
}
void Geom2d_Transformation::SetMirror (const gp_Pnt2d& P) {
gpTrsf2d.SetMirror (P);
}
void Geom2d_Transformation::SetMirror (const gp_Ax2d& A) {
gpTrsf2d.SetMirror (A);
}
void Geom2d_Transformation::SetRotation (const gp_Pnt2d& P, const Standard_Real Ang) {
gpTrsf2d.SetRotation (P, Ang);
}
void Geom2d_Transformation::SetScale (const gp_Pnt2d& P, const Standard_Real S) {
gpTrsf2d.SetScale (P, S);
}
void Geom2d_Transformation::SetTransformation (const gp_Ax2d& ToAxis) {
gpTrsf2d.SetTransformation (ToAxis);
}
void Geom2d_Transformation::SetTransformation (
const gp_Ax2d& FromAxis1, const gp_Ax2d& ToAxis2) {
gpTrsf2d.SetTransformation (FromAxis1, ToAxis2);
}
void Geom2d_Transformation::SetTranslation (const gp_Vec2d& V) {
gpTrsf2d.SetTranslation (V);
}
void Geom2d_Transformation::SetTranslation (const gp_Pnt2d& P1, const gp_Pnt2d& P2) {
gpTrsf2d.SetTranslation (P1, P2);
}
void Geom2d_Transformation::SetTrsf2d (const gp_Trsf2d& T) { gpTrsf2d = T; }
Standard_Boolean Geom2d_Transformation::IsNegative () const {
return gpTrsf2d.IsNegative();
}
TrsfForm Geom2d_Transformation::Form () const { return gpTrsf2d.Form(); }
Standard_Real Geom2d_Transformation::ScaleFactor () const {
return gpTrsf2d.ScaleFactor();
}
gp_Trsf2d Geom2d_Transformation::Trsf2d () const { return gpTrsf2d; }
Standard_Real Geom2d_Transformation::Value (const Standard_Integer Row, const Standard_Integer Col) const{
return gpTrsf2d.Value (Row, Col);
}
void Geom2d_Transformation::Invert () { gpTrsf2d.Invert(); }
void Geom2d_Transformation::Transforms (Standard_Real& X, Standard_Real& Y) const {
gpTrsf2d.Transforms (X, Y);
}
void Geom2d_Transformation::Multiply (const Handle(Geom2d_Transformation)& Other) {
gpTrsf2d.Multiply (Other->Trsf2d());
}
void Geom2d_Transformation::Power (const Standard_Integer N) { gpTrsf2d.Power (N); }
void Geom2d_Transformation::PreMultiply (
const Handle(Transformation)& Other) {
gpTrsf2d.PreMultiply (Other->Trsf2d());
}

View File

@@ -0,0 +1,289 @@
-- File: Geom2d_TrimmedCurve.cdl
-- Created: Wed Mar 24 18:24:24 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991, 1992
class TrimmedCurve from Geom2d inherits BoundedCurve from Geom2d
--- Purpose :
-- Defines a portion of a curve limited by two values of
-- parameters inside the parametric domain of the curve.
-- The trimmed curve is defined by:
-- - the basis curve, and
-- - the two parameter values which limit it.
-- The trimmed curve can either have the same
-- orientation as the basis curve or the opposite orientation.
uses Ax2d from gp,
Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp,
Curve from Geom2d,
Geometry from Geom2d,
Shape from GeomAbs
raises ConstructionError from Standard,
RangeError from Standard,
NoSuchObject from Standard,
UndefinedDerivative from Geom2d,
UndefinedValue from Geom2d
is
Create (C : Curve; U1, U2 : Real; Sense : Boolean = Standard_True)
returns mutable TrimmedCurve
--- Purpose :
-- Creates a trimmed curve from the basis curve C limited between
-- U1 and U2.
--
-- . U1 can be greater or lower than U2.
-- . The returned curve is oriented from U1 to U2.
-- . If the basis curve C is periodic there is an ambiguity
-- because two parts are available. In this case by default
-- the trimmed curve has the same orientation as the basis
-- curve (Sense = True). If Sense = False then the orientation
-- of the trimmed curve is opposite to the orientation of the
-- basis curve C.
-- If the curve is closed but not periodic it is not possible
-- to keep the part of the curve including the junction point
-- (except if the junction point is at the beginning or
-- at the end of the trimmed curve) because you could lose the
-- fundamental characteristics of the basis curve which are
-- used for example to compute the derivatives of the trimmed
-- curve. So for a closed curve the rules are the same as for
-- a open curve.
-- Warnings :
-- In this package the entities are not shared. The TrimmedCurve is
-- built with a copy of the curve C. So when C is modified the
-- TrimmedCurve is not modified
-- Warnings :
-- If <C> is periodic, parametrics bounds of the TrimmedCurve,
-- can be different to [<U1>;<U2>}, if <U1> or <U2> are not in the
-- principal period.
-- Include :
-- For more explanation see the scheme given with this class.
-- Raises ConstructionError the C is not periodic and U1 or U2 are out of
-- the bounds of C.
-- Raised if U1 = U2.
raises ConstructionError;
Reverse (me : mutable);
--- Purpose :
-- Changes the direction of parametrization of <me>. The first and
-- the last parametric values are modified. The "StartPoint"
-- of the initial curve becomes the "EndPoint" of the reversed
-- curve and the "EndPoint" of the initial curve becomes the
-- "StartPoint" of the reversed curve.
-- Example - If the trimmed curve is defined by:
-- - a basis curve whose parameter range is [ 0.,1. ], and
-- - the two trim values U1 (first parameter) and U2 (last parameter),
-- the reversed trimmed curve is defined by:
-- - the reversed basis curve, whose parameter range is still [ 0.,1. ], and
-- - the two trim values 1. - U2 (first parameter)
-- and 1. - U1 (last parameter).
ReversedParameter(me; U : Real) returns Real;
---Purpose: Returns the parameter on the reversed curve for
-- the point of parameter U on <me>.
--
-- returns UFirst + ULast - U
SetTrim (me : mutable; U1, U2 : Real; Sense : Boolean = Standard_True)
--- Purpose : Changes this trimmed curve, by redefining the
-- parameter values U1 and U2, which limit its basis curve.
-- Note: If the basis curve is periodic, the trimmed curve
-- has the same orientation as the basis curve if Sense
-- is true (default value) or the opposite orientation if Sense is false.
-- Warning
-- If the basis curve is periodic, the bounds of the
-- trimmed curve may be different from U1 and U2 if the
-- parametric origin of the basis curve is within the arc
-- of the trimmed curve. In this case, the modified
-- parameter will be equal to U1 or U2 plus or minus the period.
-- Exceptions
-- Standard_ConstructionError if:
-- - the basis curve is not periodic, and either U1 or U2
-- are outside the bounds of the basis curve, or
-- - U1 is equal to U2.
raises ConstructionError;
BasisCurve (me) returns Curve;
--- Purpose : Returns the basis curve.
-- Warning
-- This function does not return a constant reference.
-- Consequently, any modification of the returned value
-- directly modifies the trimmed curve.
Continuity (me) returns Shape from GeomAbs;
--- Purpose :
-- Returns the global continuity of the basis curve of this trimmed curve.
-- C0 : only geometric continuity,
-- C1 : continuity of the first derivative all along the Curve,
-- C2 : continuity of the second derivative all along the Curve,
-- C3 : continuity of the third derivative all along the Curve,
-- CN : the order of continuity is infinite.
IsCN (me; N : Integer) returns Boolean
--- Purpose
-- Returns True if the order of continuity of the
-- trimmed curve is N. A trimmed curve is at least "C0" continuous.
-- Warnings :
-- The continuity of the trimmed curve can be greater than
-- the continuity of the basis curve because you consider
-- only a part of the basis curve.
raises RangeError;
--- Purpose : Raised if N < 0.
EndPoint (me) returns Pnt2d;
--- Purpose :
-- Returns the end point of <me>. This point is the
-- evaluation of the curve for the "LastParameter".
FirstParameter (me) returns Real;
--- Purpose :
-- Returns the value of the first parameter of <me>.
-- The first parameter is the parameter of the "StartPoint"
-- of the trimmed curve.
IsClosed (me) returns Boolean;
--- Purpose :
-- Returns True if the distance between the StartPoint and
-- the EndPoint is lower or equal to Resolution from package
-- gp.
IsPeriodic (me) returns Boolean;
--- Purpose : Returns true if the basis curve of this trimmed curve is periodic.
Period (me) returns Real from Standard
---Purpose: Returns the period of the basis curve of this trimmed curve.
-- Exceptions
-- Standard_NoSuchObject if the basis curve is not periodic.
raises
NoSuchObject from Standard
is redefined;
LastParameter (me) returns Real;
--- Purpose :
-- Returns the value of the last parameter of <me>.
-- The last parameter is the parameter of the "EndPoint" of the
-- trimmed curve.
StartPoint (me) returns Pnt2d;
--- Purpose :
-- Returns the start point of <me>.
-- This point is the evaluation of the curve from the
-- "FirstParameter".
--- Purpose : value and derivatives
--- Warnings :
-- The returned derivatives have the same orientation as the
-- derivatives of the basis curve.
D0 (me; U : Real; P : out Pnt2d)
raises UndefinedValue;
--- Purpose:
-- If the basis curve is an OffsetCurve sometimes it is not
-- possible to do the evaluation of the curve at the parameter
-- U (see class OffsetCurve).
D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d)
raises UndefinedDerivative;
--- Purpose : Raised if the continuity of the curve is not C1.
D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d)
raises UndefinedDerivative;
--- Purpose : Raised if the continuity of the curve is not C2.
D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d)
raises UndefinedDerivative;
--- Purpose : Raised if the continuity of the curve is not C3.
DN (me; U : Real; N : Integer) returns Vec2d
--- Purpose : For the point of parameter U of this trimmed curve,
-- computes the vector corresponding to the Nth derivative.
-- Warning
-- The returned derivative vector has the same
-- orientation as the derivative vector of the basis curve,
-- even if the trimmed curve does not have the same
-- orientation as the basis curve.
-- Exceptions
-- Standard_RangeError if N is less than 1.
raises UndefinedDerivative,
RangeError;
--- Purpose : geometric transformations
Transform (me : mutable; T : Trsf2d);
--- Purpose : Applies the transformation T to this trimmed curve.
-- Warning The basis curve is also modified.
TransformedParameter(me; U : Real; T : Trsf2d from gp) returns Real
---Purpose: Returns the parameter on the transformed curve for
-- the transform of the point of parameter U on <me>.
--
-- me->Transformed(T)->Value(me->TransformedParameter(U,T))
--
-- is the same point as
--
-- me->Value(U).Transformed(T)
--
-- This methods calls the basis curve method.
is redefined;
ParametricTransformation(me; T : Trsf2d from gp) returns Real
---Purpose: Returns a coefficient to compute the parameter on
-- the transformed curve for the transform of the
-- point on <me>.
--
-- Transformed(T)->Value(U * ParametricTransformation(T))
--
-- is the same point as
--
-- Value(U).Transformed(T)
--
-- This methods calls the basis curve method.
is redefined;
Copy (me) returns mutable like me;
---Purpose:
-- Creates a new object, which is a copy of this trimmed curve.
fields
basisCurve : Curve from Geom2d;
uTrim1 : Real;
uTrim2 : Real;
end;

View File

@@ -0,0 +1,334 @@
// File: Geom2d_TrimmedCurve.cxx
// Created: Wed Mar 24 19:31:09 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_TrimmedCurve.cxx, JCV 17/01/91
#include <Geom2d_TrimmedCurve.ixx>
#include <gp.hxx>
#include <Geom2d_Geometry.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_OffsetCurve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_Parabola.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
#include <ElCLib.hxx>
#include <Precision.hxx>
typedef Handle(Geom2d_TrimmedCurve) Handle(TrimmedCurve);
typedef Geom2d_TrimmedCurve TrimmedCurve;
typedef Handle(Geom2d_Curve) Handle(Curve);
typedef Handle(Geom2d_Geometry) Handle(Geometry);
typedef gp_Ax2d Ax2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Trsf2d Trsf2d;
typedef gp_Vec2d Vec2d;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom2d_Geometry) Geom2d_TrimmedCurve::Copy () const
{
Handle(TrimmedCurve) Tc;
Tc = new TrimmedCurve (basisCurve, uTrim1, uTrim2);
return Tc;
}
//=======================================================================
//function : Geom2d_TrimmedCurve
//purpose :
//=======================================================================
Geom2d_TrimmedCurve::Geom2d_TrimmedCurve (const Handle(Geom2d_Curve)& C,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Boolean Sense) :
uTrim1 (U1),
uTrim2 (U2)
{
if(C.IsNull()) Standard_ConstructionError::Raise("Geom2d_TrimmedCurve:: C is null");
// kill trimmed basis curves
Handle(Geom2d_TrimmedCurve) T = Handle(Geom2d_TrimmedCurve)::DownCast(C);
if (!T.IsNull())
basisCurve = Handle(Curve)::DownCast(T->BasisCurve()->Copy());
else
basisCurve = Handle(Curve)::DownCast(C->Copy());
SetTrim(U1,U2,Sense);
}
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
void Geom2d_TrimmedCurve::Reverse ()
{
Standard_Real U1 = basisCurve->ReversedParameter(uTrim2);
Standard_Real U2 = basisCurve->ReversedParameter(uTrim1);
basisCurve->Reverse();
SetTrim(U1,U2);
}
//=======================================================================
//function : ReversedParamater
//purpose :
//=======================================================================
Standard_Real Geom2d_TrimmedCurve::ReversedParameter( const Standard_Real U) const
{
return basisCurve->ReversedParameter(U);
}
//=======================================================================
//function : SetTrim
//purpose :
//=======================================================================
void Geom2d_TrimmedCurve::SetTrim (const Standard_Real U1,
const Standard_Real U2,
const Standard_Boolean Sense)
{
Standard_Boolean sameSense = Standard_True;
if (U1 == U2)
Standard_ConstructionError::Raise("Geom2d_TrimmedCurve::U1 == U2");
Standard_Real Udeb = basisCurve->FirstParameter();
Standard_Real Ufin = basisCurve->LastParameter();
if (basisCurve->IsPeriodic()) {
sameSense = Sense;
// set uTrim1 in the range Udeb , Ufin
// set uTrim2 in the range uTrim1 , uTrim1 + Period()
uTrim1 = U1;
uTrim2 = U2;
ElCLib::AdjustPeriodic(Udeb, Ufin,
Min(Abs(uTrim2-uTrim1)/2,Precision::PConfusion()),
uTrim1, uTrim2);
}
else {
if (U1 < U2) {
sameSense = Sense;
uTrim1 = U1;
uTrim2 = U2;
}
else {
sameSense = !Sense;
uTrim1 = U2;
uTrim2 = U1;
}
if ((Udeb - uTrim1 > Precision::PConfusion()) ||
(uTrim2 - Ufin > Precision::PConfusion())) {
Standard_ConstructionError::Raise
("Geom_TrimmedCurve::parameters out of range");
}
}
if (!sameSense)
Reverse();
}
//=======================================================================
//function : BasisCurve
//purpose :
//=======================================================================
Handle(Curve) Geom2d_TrimmedCurve::BasisCurve () const
{
return basisCurve;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom2d_TrimmedCurve::Continuity () const
{
return basisCurve->Continuity();
}
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom2d_TrimmedCurve::IsCN (const Standard_Integer N) const
{
Standard_RangeError_Raise_if (N < 0, " ");
return basisCurve->IsCN (N);
}
//=======================================================================
//function : EndPoint
//purpose :
//=======================================================================
Pnt2d Geom2d_TrimmedCurve::EndPoint () const
{
return basisCurve->Value(uTrim2);
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_TrimmedCurve::FirstParameter () const { return uTrim1; }
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom2d_TrimmedCurve::IsClosed () const
{
Standard_Real Dist =
Value(FirstParameter()).Distance(Value(LastParameter()));
return ( Dist <= gp::Resolution());
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom2d_TrimmedCurve::IsPeriodic () const
{
//return basisCurve->IsPeriodic();
return Standard_False;
}
//=======================================================================
//function : Period
//purpose :
//=======================================================================
Standard_Real Geom2d_TrimmedCurve::Period () const
{
return basisCurve->Period();
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_TrimmedCurve::LastParameter () const { return uTrim2; }
//=======================================================================
//function : StartPoint
//purpose :
//=======================================================================
Pnt2d Geom2d_TrimmedCurve::StartPoint () const
{
gp_Pnt2d P;
P = basisCurve->Value(uTrim1);
return P;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom2d_TrimmedCurve::D0 (const Standard_Real U,
Pnt2d& P ) const {
basisCurve->D0(U, P);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom2d_TrimmedCurve::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const
{
basisCurve->D1 (U, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom2d_TrimmedCurve::D2 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2) const
{
basisCurve->D2 (U, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom2d_TrimmedCurve::D3 (const Standard_Real U,
Pnt2d& P,
Vec2d& V1, Vec2d& V2, Vec2d& V3) const
{
basisCurve->D3 (U, P, V1, V2, V3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec2d Geom2d_TrimmedCurve::DN (const Standard_Real U, const Standard_Integer N) const
{
return basisCurve->DN(U, N);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom2d_TrimmedCurve::Transform (const Trsf2d& T)
{
basisCurve->Transform (T);
Standard_Real U1 = basisCurve->TransformedParameter(uTrim1,T);
Standard_Real U2 = basisCurve->TransformedParameter(uTrim2,T);
SetTrim(U1,U2);
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom2d_TrimmedCurve::TransformedParameter(const Standard_Real U,
const gp_Trsf2d& T) const
{
return basisCurve->TransformedParameter(U,T);
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
Standard_Real Geom2d_TrimmedCurve::ParametricTransformation(const gp_Trsf2d& T) const
{
return basisCurve->ParametricTransformation(T);
}

86
src/Geom2d/Geom2d_Vector.cdl Executable file
View File

@@ -0,0 +1,86 @@
-- File: Geom2d_Vector.cdl
-- Created: Wed Mar 24 18:26:25 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
deferred class Vector from Geom2d inherits Geometry from Geom2d
--- Purpose : The abstract class Vector describes the common
-- behavior of vectors in 2D space.
-- The Geom2d package provides two concrete
-- classes of vectors: Geom2d_Direction (unit vector)
-- and Geom2d_VectorWithMagnitude.
uses Ax2d from gp,
Pnt2d from gp,
Vec2d from gp
raises DomainError from Standard,
VectorWithNullMagnitude from gp
is
Reverse (me : mutable);
--- Purpose : Reverses the vector <me>.
Reversed (me) returns mutable like me
--- Purpose : Returns a copy of <me> reversed.
is static;
Angle (me; Other : Vector) returns Real
--- Purpose : Computes the angular value, in radians, between this
-- vector and vector Other. The result is a value
-- between -Pi and Pi. The orientation is from this
-- vector to vector Other.
-- Raises VectorWithNullMagnitude if one of the two vectors is a vector with
-- null magnitude because the angular value is indefinite.
raises VectorWithNullMagnitude;
Coord (me; X, Y : out Real);
--- Purpose : Returns the coordinates of <me>.
Magnitude (me) returns Real
--- Purpose : Returns the Magnitude of <me>.
is deferred;
SquareMagnitude (me) returns Real
--- Purpose : Returns the square magnitude of <me>.
is deferred;
X (me) returns Real;
--- Purpose : Returns the X coordinate of <me>.
Y (me) returns Real;
--- Purpose : Returns the Y coordinate of <me>.
Crossed (me; Other : Vector) returns Real
--- Purpose : Cross product of <me> with the vector <Other>.
is deferred;
Dot (me; Other : Vector) returns Real;
--- Purpose : Returns the scalar product of 2 Vectors.
Vec2d (me) returns Vec2d;
--- Purpose : Returns a non persistent copy of <me>.
fields
gpVec2d : Vec2d is protected;
end;

51
src/Geom2d/Geom2d_Vector.cxx Executable file
View File

@@ -0,0 +1,51 @@
// File: Geom2d_Vector.cxx
// Created: Wed Mar 24 19:31:58 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_Vector.cxx, JCV 23/06/91
#include <Geom2d_Vector.ixx>
typedef Geom2d_Vector Vector;
typedef Handle(Geom2d_Vector) Handle(Vector);
typedef gp_Ax2d Ax2d;
typedef gp_Pnt2d Pnt2d;
Standard_Real Geom2d_Vector::Angle (
const Handle(Geom2d_Vector)& Other) const {
return gpVec2d.Angle (Other->Vec2d());
}
void Geom2d_Vector::Reverse () { gpVec2d.Reverse(); }
gp_Vec2d Geom2d_Vector::Vec2d () const { return gpVec2d; }
Standard_Real Geom2d_Vector::X () const { return gpVec2d.X(); }
Standard_Real Geom2d_Vector::Y () const { return gpVec2d.Y(); }
Handle(Vector) Geom2d_Vector::Reversed () const {
Handle(Vector) V = Handle(Vector)::DownCast(Copy());
V->Reverse();
return V;
}
void Geom2d_Vector::Coord (Standard_Real& X, Standard_Real& Y) const {
gpVec2d.Coord (X, Y);
}
Standard_Real Geom2d_Vector::Dot (const Handle(Vector)& Other) const {
return gpVec2d.Dot (Other->Vec2d());
}

View File

@@ -0,0 +1,152 @@
-- File: Geom2d_VectorWithMagnitude.cdl
-- Created: Wed Mar 24 18:36:20 1993
-- Author: JCV
-- <fid@sdsun2>
-- Copyright: Matra Datavision 1993
---Copyright: Matra Datavision 1991
class VectorWithMagnitude from Geom2d inherits Vector from Geom2d
--- Purpose :
-- Defines a vector with magnitude.
-- A vector with magnitude can have a zero length.
uses Pnt2d from gp,
Trsf2d from gp,
Vec2d from gp,
Geometry from Geom2d
raises ConstructionError from Standard
is
Create (V : Vec2d) returns mutable VectorWithMagnitude;
--- Purpose : Creates a persistent copy of V.
Create (X, Y : Real) returns mutable VectorWithMagnitude;
--- Purpose : Creates a vector with two cartesian coordinates.
Create (P1, P2 : Pnt2d) returns mutable VectorWithMagnitude;
--- Purpose :
-- Creates a vector from the point P1 to the point P2.
-- The magnitude of the vector is the distance between P1 and P2
SetCoord (me : mutable; X, Y : Real);
--- Purpose : Set <me> to X, Y coordinates.
SetVec2d (me : mutable; V : Vec2d);
-- Purpose : Set <me> to V.X(), V.Y() coordinates.
SetX (me : mutable; X : Real);
--- Purpose : Changes the X coordinate of <me>.
SetY (me : mutable; Y : Real);
--- Purpose : Changes the Y coordinate of <me>
Magnitude (me) returns Real;
--- Purpose : Returns the magnitude of <me>.
SquareMagnitude (me) returns Real;
--- Purpose : Returns the square magnitude of <me>.
Add (me : mutable; Other : Vector);
--- Purpose :
-- Adds the Vector Other to <me>.
---C++: alias operator +=
Added (me; Other : Vector) returns mutable VectorWithMagnitude
--- Purpose :
-- Adds the vector Other to <me>.
---C++: alias operator +
is static;
Crossed (me; Other : Vector) returns Real;
--- Purpose :
-- Computes the cross product between <me> and Other
-- <me> ^ Other. A new vector is returned.
---C++: alias operator ^
Divide (me : mutable; Scalar : Real);
--- Purpose : Divides <me> by a scalar.
---C++: alias operator /=
Divided (me; Scalar : Real) returns mutable VectorWithMagnitude
--- Purpose :
-- Divides <me> by a scalar. A new vector is returned.
---C++: alias operator /
is static;
Multiplied (me; Scalar : Real) returns mutable VectorWithMagnitude
--- Purpose :
-- Computes the product of the vector <me> by a scalar.
-- A new vector is returned.
--
-- -C++: alias operator *
-- Collision with same operator defined for the class Vector!
is static;
Multiply (me : mutable; Scalar : Real);
--- Purpose :
-- Computes the product of the vector <me> by a scalar.
---C++: alias operator *=
Normalize (me : mutable)
--- Purpose : Normalizes <me>.
raises ConstructionError;
--- Purpose :
-- Raised if the magnitude of the vector is lower or equal to
-- Resolution from package gp.
Normalized (me) returns mutable VectorWithMagnitude
--- Purpose : Returns a copy of <me> Normalized.
raises ConstructionError
--- Purpose :
-- Raised if the magnitude of the vector is lower or equal to
-- Resolution from package gp.
is static;
Subtract (me : mutable; Other : Vector);
--- Purpose : Subtracts the Vector Other to <me>.
---C++: alias operator -=
Subtracted (me; Other : Vector) returns mutable VectorWithMagnitude
--- Purpose :
-- Subtracts the vector Other to <me>. A new vector is returned.
---C++: alias operator -
is static;
Transform (me: mutable; T : Trsf2d);
---Purpose: Applies the transformation T to this vector.
Copy (me) returns mutable like me;
--- Purpose: Creates a new object which is a copy of this vector.
end;

View File

@@ -0,0 +1,151 @@
// File: Geom2d_VectorWithMagnitude.cxx
// Created: Wed Mar 24 19:32:14 1993
// Author: JCV
// <fid@sdsun2>
// Copyright: Matra Datavision 1993
//File Geom2d_VectorWithMagnitude.cxx, JCV 16/01/91
#include <Geom2d_VectorWithMagnitude.ixx>
typedef Geom2d_Vector Vector;
typedef Geom2d_VectorWithMagnitude VectorWithMagnitude;
typedef Handle(Geom2d_VectorWithMagnitude) Handle(VectorWithMagnitude);
typedef Handle(Geom2d_Vector) Handle(Vector);
typedef gp_Ax2d Ax2d;
typedef gp_Pnt2d Pnt2d;
typedef gp_Trsf2d Trsf2d;
Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (const gp_Vec2d& V)
{ gpVec2d = V; }
Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (
const Standard_Real X, const Standard_Real Y) { gpVec2d = gp_Vec2d (X, Y); }
Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (
const Pnt2d& P1, const Pnt2d& P2) { gpVec2d = gp_Vec2d (P1, P2); }
Handle(Geom2d_Geometry) Geom2d_VectorWithMagnitude::Copy() const {
Handle(VectorWithMagnitude) V;
V = new VectorWithMagnitude (gpVec2d);
return V;
}
void Geom2d_VectorWithMagnitude::SetCoord (const Standard_Real X, const Standard_Real Y) {
gpVec2d = gp_Vec2d (X, Y);
}
void Geom2d_VectorWithMagnitude::SetVec2d (const gp_Vec2d& V) { gpVec2d = V; }
void Geom2d_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec2d.SetX (X); }
void Geom2d_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec2d.SetY (Y); }
Standard_Real Geom2d_VectorWithMagnitude::Magnitude () const {
return gpVec2d.Magnitude ();
}
Standard_Real Geom2d_VectorWithMagnitude::SquareMagnitude () const {
return gpVec2d.SquareMagnitude ();
}
void Geom2d_VectorWithMagnitude::Add (const Handle(Vector)& Other) {
gpVec2d.Add (Other->Vec2d());
}
Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Added (
const Handle(Vector)& Other) const {
gp_Vec2d Temp = Other->Vec2d();
Temp.Add (gpVec2d);
return new VectorWithMagnitude (Temp);
}
Standard_Real Geom2d_VectorWithMagnitude::Crossed (const Handle(Vector)& Other) const{
return gpVec2d.Crossed (Other->Vec2d());
}
void Geom2d_VectorWithMagnitude::Divide (const Standard_Real Scalar) {
gpVec2d.Divide (Scalar);
}
Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Divided (
const Standard_Real Scalar) const {
gp_Vec2d V (gpVec2d);
V.Divide (Scalar);
return new VectorWithMagnitude (V);
}
Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Multiplied (
const Standard_Real Scalar) const {
gp_Vec2d V(gpVec2d);
V.Multiply (Scalar);
return new VectorWithMagnitude (V);
}
void Geom2d_VectorWithMagnitude::Multiply (const Standard_Real Scalar) {
gpVec2d.Multiply (Scalar);
}
void Geom2d_VectorWithMagnitude::Normalize () { gpVec2d.Normalize (); }
Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Normalized () const {
gp_Vec2d V = gpVec2d;
V.Normalized ();
return new VectorWithMagnitude (V);
}
void Geom2d_VectorWithMagnitude::Subtract (const Handle(Vector)& Other) {
gpVec2d.Subtract (Other->Vec2d());
}
Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Subtracted (
const Handle(Vector)& Other) const {
gp_Vec2d V = gpVec2d;
V.Subtract (Other->Vec2d());
return new VectorWithMagnitude (V);
}
void Geom2d_VectorWithMagnitude::Transform (const Trsf2d& T) {
gpVec2d.Transform (T);
}