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

6
src/Geom/FILES Executable file
View File

@@ -0,0 +1,6 @@
Geom_BSplineCurve_1.cxx
Geom_BSplineSurface_1.cxx

144
src/Geom/Geom.cdl Executable file
View File

@@ -0,0 +1,144 @@
-- File: Geom.cdl
-- Created: Tue Mar 9 18:50:59 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
package Geom
--- Purpose :
-- This package contains the definition of the geometric objects
-- such as point, vector, axis placement, curves, surfaces and the
-- description of the geometric transformations available for these
-- objects.
-- All these entities are defined in 3D 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,
Standard,
GeomAbs,
TCollection,
TColStd,
gp,
TColgp
--, Plate
is
---Group: Exceptions
exception UndefinedDerivative inherits DomainError from Standard;
exception UndefinedValue inherits DomainError from Standard;
class SequenceOfBSplineSurface
instantiates Sequence from TCollection (BSplineSurface from Geom);
class HSequenceOfBSplineSurface
instantiates HSequence from TCollection (BSplineSurface from Geom,
SequenceOfBSplineSurface from Geom);
-- class SequenceOfBoundedSurface
-- instantiates Sequence from TCollection (BoundedSurface from Geom);
class SequenceOfSurface
instantiates Sequence from TCollection (Surface from Geom);
class HSequenceOfSurface
instantiates HSequence from TCollection (Surface from Geom,
SequenceOfSurface from Geom);
-- class HSequenceOfBoundedSurface
-- instantiates HSequence from TCollection (BoundedSurface from Geom,
-- SequenceOfBoundedSurface from Geom);
-- class SequenceNodeOfSequenceOfSurface
-- instantiates SeqNode from TCollection (Surface from Geom);
-- class HSequenceOfSurface
-- instantiates HSequence from TCollection (Surface from Geom,
-- SequenceOfSurface from Geom);
---Group: Geometric entities
class Transformation;
deferred class Geometry;
deferred class Point;
class CartesianPoint;
deferred class Vector;
class Direction;
class VectorWithMagnitude;
deferred class AxisPlacement;
class Axis1Placement;
class Axis2Placement;
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;
deferred class Surface;
deferred class ElementarySurface;
class Plane;
class ConicalSurface;
class CylindricalSurface;
class SphericalSurface;
class ToroidalSurface;
deferred class SweptSurface;
class SurfaceOfLinearExtrusion;
class SurfaceOfRevolution;
deferred class BoundedSurface;
class BezierSurface;
class BSplineSurface;
class RectangularTrimmedSurface;
class OffsetSurface;
private class OsculatingSurface;
-- class PlateSurface ;
end Geom;

View File

@@ -0,0 +1,68 @@
-- File: Geom_Axis1Placement.cdl
-- Created: Tue Mar 9 19:24:06 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Axis1Placement from Geom inherits AxisPlacement from Geom
---Purpose : Describes an axis in 3D 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: Geom_Axis1Placement axes provide the
-- same kind of "geometric" services as gp_Ax1 axes
-- but have more complex data structures. The
-- geometric objects provided by the Geom package
-- use gp_Ax1 objects to include axes in their data
-- structures, or to define an axis of symmetry or axis of rotation.
-- Geom_Axis1Placement axes are used in a context
-- where they can be shared by several objects
-- contained inside a common data structure.
uses Ax1 from gp,
Ax2 from gp,
Dir from gp,
Pnt from gp,
Trsf from gp,
Geometry from Geom
is
Create (A1 : Ax1) returns mutable Axis1Placement;
---Purpose : Returns a transient copy of A1.
Create (P : Pnt; V : Dir) returns mutable Axis1Placement;
---Purpose :
-- P is the origin of the axis placement and V is the direction
-- of the axis placement.
Ax1 (me) returns Ax1;
---Purpose : Returns a non transient copy of <me>.
---C++: return const&
Reverse (me : mutable);
---Purpose : Reverses the direction of the axis placement.
Reversed (me) returns mutable Axis1Placement
---Purpose : Returns a copy of <me> reversed.
is static;
SetDirection (me : mutable; V : Dir);
---Purpose : Assigns V to the unit vector of this axis.
Transform (me : mutable; T : Trsf);
---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.
end;

View File

@@ -0,0 +1,69 @@
// File: Geom_Axis1Placement.cxx
// Created: Tue Mar 9 19:25:37 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Axis1Placement.cxx, JCV 17/01/91
#include <Geom_Axis1Placement.ixx>
typedef Geom_Axis1Placement Axis1Placement;
typedef Handle(Geom_Axis1Placement) Handle(Axis1Placement);
typedef gp_Ax2 Ax2;
typedef gp_Dir Dir;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_Axis1Placement::Copy() const {
Handle(Axis1Placement) A1;
A1 = new Axis1Placement (axis);
return A1;
}
//=======================================================================
//function : Geom_Axis1Placement
//purpose :
//=======================================================================
Geom_Axis1Placement::Geom_Axis1Placement (const gp_Ax1& A1)
{
axis = A1;
}
Geom_Axis1Placement::Geom_Axis1Placement (const Pnt& P, const Dir& V) {
axis = gp_Ax1 (P, V);
}
void Geom_Axis1Placement::SetDirection (const Dir& V) {axis.SetDirection (V);}
const gp_Ax1& Geom_Axis1Placement::Ax1 () const { return Axis(); }
void Geom_Axis1Placement::Reverse() { axis.Reverse(); }
void Geom_Axis1Placement::Transform (const Trsf& T) { axis.Transform (T); }
Handle(Axis1Placement) Geom_Axis1Placement::Reversed() const {
gp_Ax1 A1 = axis;
A1.Reverse();
Handle (Axis1Placement) Temp = new Axis1Placement (A1);
return Temp;
}

149
src/Geom/Geom_Axis2Placement.cdl Executable file
View File

@@ -0,0 +1,149 @@
-- File: Geom_Axis2Placement.cdl
-- Created: Tue Mar 9 19:26:23 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Axis2Placement from Geom inherits AxisPlacement from Geom
---Purpose : Describes a right-handed coordinate system in 3D space.
-- A coordinate system is defined by:
-- - its origin, also termed the "Location point" of the coordinate system,
-- - three orthogonal unit vectors, termed respectively
-- the "X Direction", "Y Direction" and "Direction" (or
-- "main Direction") of the coordinate system.
-- As a Geom_Axis2Placement coordinate system is
-- right-handed, its "Direction" is always equal to the
-- cross product of its "X Direction" and "Y Direction".
-- The "Direction" of a coordinate system is called the
-- "main Direction" because when this unit vector is
-- modified, the "X Direction" and "Y Direction" are
-- recomputed, whereas when the "X Direction" or "Y
-- Direction" is changed, the "main Direction" is
-- retained. The "main Direction" is also the "Z Direction".
-- Note: Geom_Axis2Placement coordinate systems
-- provide the same kind of "geometric" services as
-- gp_Ax2 coordinate systems but have more complex
-- data structures. The geometric objects provided by
-- the Geom package use gp_Ax2 objects to include
-- coordinate systems in their data structures, or to
-- define the geometric transformations, which are applied to them.
-- Geom_Axis2Placement coordinate systems are
-- used in a context where they can be shared by
-- several objects contained inside a common data structure.
uses Ax1 from gp,
Ax2 from gp,
Dir from gp,
Pnt from gp,
Trsf from gp,
Geometry from Geom
raises ConstructionError from Standard
is
Create (A2 : Ax2) returns mutable Axis2Placement;
---Purpose : Returns a transient copy of A2.
Create (P : Pnt; N, Vx : Dir) returns mutable Axis2Placement
---Purpose :
-- P is the origin of the axis placement, N is the main
-- direction of the axis placement and Vx is the "XDirection".
-- If the two directions N and Vx are not orthogonal the
-- "XDirection" is computed as follow :
-- XDirection = N ^ (Vx ^ N).
raises ConstructionError;
---Purpose : Raised if N and Vx are parallel.
SetAx2 (me : mutable; A2 : Ax2);
---Purpose : Assigns the origin and the three unit vectors of A2 to
-- this coordinate system.
SetDirection (me : mutable; V : Dir)
---Purpose :
-- Changes the main direction of the axis placement.
-- The "Xdirection" is modified :
-- New XDirection = V ^ (Previous_Xdirection ^ V).
raises ConstructionError;
---Purpose :
-- Raised if V and the previous "XDirection" are parallel
-- because it is impossible to calculate the new "XDirection"
-- and the new "YDirection".
SetXDirection (me : mutable; Vx : Dir)
---Purpose :
-- Changes the "XDirection" of the axis placement, Vx is the
-- new "XDirection". If Vx is not normal to the main direction
-- then "XDirection" is computed as follow :
-- XDirection = Direction ^ ( Vx ^ Direction).
-- The main direction is not modified.
raises ConstructionError;
---Purpose : Raised if Vx and "Direction" are parallel.
SetYDirection (me : mutable; Vy : Dir)
---Purpose :
-- Changes the "YDirection" of the axis placement, Vy is the
-- new "YDirection". If Vy is not normal to the main direction
-- then "YDirection" is computed as follow :
-- YDirection = Direction ^ ( Vy ^ Direction).
-- The main direction is not modified. The "XDirection" is
-- modified.
raises ConstructionError;
---Purpose : Raised if Vy and the main direction are parallel.
Ax2 (me) returns Ax2;
---Purpose : Returns a non transient copy of <me>.
XDirection (me) returns Dir;
---Purpose : Returns the "XDirection". This is a unit vector.
---C++: return const&
YDirection (me) returns Dir;
---Purpose : Returns the "YDirection". This is a unit vector.
---C++: return const&
Transform (me : mutable; T : Trsf);
---Purpose :
-- Transforms an axis placement with a Trsf.
-- The "Location" point, the "XDirection" and the
-- "YDirection" are transformed with T. The resulting
-- main "Direction" of <me> is the cross product between
-- the "XDirection" and the "YDirection" after transformation.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this coordinate system.
Create (P : Pnt; Vz, Vx, Vy : Dir) returns mutable Axis2Placement
is private;
fields
vxdir : Dir;
vydir : Dir;
end;

175
src/Geom/Geom_Axis2Placement.cxx Executable file
View File

@@ -0,0 +1,175 @@
// File: Geom_Axis2Placement.cxx
// Created: Tue Mar 9 19:27:59 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Axis2Placement.cxx, JCV 17/01/91
#include <Geom_Axis2Placement.ixx>
typedef Handle(Geom_Axis2Placement) Handle(Axis2Placement);
typedef Geom_Axis2Placement Axis2Placement;
typedef gp_Ax1 Ax1;
typedef gp_Dir Dir;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_Axis2Placement::Copy() const {
Handle(Axis2Placement) A2;
A2 = new Axis2Placement (axis.Location(), axis.Direction(), vxdir, vydir);
return A2;
}
//=======================================================================
//function : Geom_Axis2Placement
//purpose :
//=======================================================================
Geom_Axis2Placement::Geom_Axis2Placement (const gp_Ax2& A2) {
vxdir = A2. XDirection();
vydir = A2. YDirection();
axis = A2.Axis();
}
//=======================================================================
//function : Geom_Axis2Placement
//purpose :
//=======================================================================
Geom_Axis2Placement::Geom_Axis2Placement (
const gp_Pnt& P,
const gp_Dir& N,
const gp_Dir& Vx) {
axis = gp_Ax1 (P, N);
vxdir = N.CrossCrossed (Vx, N);
vydir = N.Crossed (vxdir);
}
//=======================================================================
//function : Geom_Axis2Placement
//purpose :
//=======================================================================
Geom_Axis2Placement::Geom_Axis2Placement (
const gp_Pnt& P,
const gp_Dir& Vz,
const gp_Dir& Vx,
const gp_Dir& Vy
) : vxdir (Vx), vydir (Vy) {
axis.SetLocation (P);
axis.SetDirection (Vz);
}
//=======================================================================
//function : XDirection
//purpose :
//=======================================================================
const gp_Dir& Geom_Axis2Placement::XDirection () const { return vxdir; }
//=======================================================================
//function : YDirection
//purpose :
//=======================================================================
const gp_Dir& Geom_Axis2Placement::YDirection () const { return vydir; }
//=======================================================================
//function : SetAx2
//purpose :
//=======================================================================
void Geom_Axis2Placement::SetAx2 (const gp_Ax2& A2) {
vxdir = A2.XDirection();
vydir = A2.YDirection();
axis = A2.Axis();
}
//=======================================================================
//function : SetDirection
//purpose :
//=======================================================================
void Geom_Axis2Placement::SetDirection (const gp_Dir& V) {
axis.SetDirection (V);
vxdir = V.CrossCrossed (vxdir, V);
vydir = V.Crossed (vxdir);
}
//=======================================================================
//function : SetXDirection
//purpose :
//=======================================================================
void Geom_Axis2Placement::SetXDirection (const gp_Dir& Vx) {
vxdir = axis.Direction().CrossCrossed (Vx, axis.Direction());
vydir = axis.Direction().Crossed (vxdir);
}
//=======================================================================
//function : SetYDirection
//purpose :
//=======================================================================
void Geom_Axis2Placement::SetYDirection (const gp_Dir& Vy) {
vxdir = Vy.Crossed (axis.Direction());
vydir = (axis.Direction()).Crossed (vxdir);
}
//=======================================================================
//function : Ax2
//purpose :
//=======================================================================
gp_Ax2 Geom_Axis2Placement::Ax2 () const {
return gp_Ax2 (axis.Location(), axis.Direction(), vxdir);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_Axis2Placement::Transform (const gp_Trsf& T) {
//axis.Location().Transform (T);
axis.SetLocation(axis.Location().Transformed(T)); // 10-03-93
vxdir.Transform (T);
vydir.Transform (T);
axis.SetDirection (vxdir.Crossed (vydir));
}

103
src/Geom/Geom_AxisPlacement.cdl Executable file
View File

@@ -0,0 +1,103 @@
-- File: Geom_AxisPlacement.cdl
-- Created: Tue Mar 9 19:28:24 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class AxisPlacement from Geom inherits Geometry from Geom
---Purpose : The abstract class AxisPlacement describes the
-- common behavior of positioning systems in 3D space,
-- such as axis or coordinate systems.
-- The Geom package provides two implementations of
-- 3D positioning systems:
-- - the axis (Geom_Axis1Placement class), which is defined by:
-- - its origin, also termed the "Location point" of the axis,
-- - its unit vector, termed the "Direction" or "main
-- Direction" of the axis;
-- - the right-handed coordinate system
-- (Geom_Axis2Placement class), which is defined by:
-- - its origin, also termed the "Location point" of the coordinate system,
-- - three orthogonal unit vectors, termed
-- respectively the "X Direction", the "Y Direction"
-- and the "Direction" of the coordinate system. As
-- the coordinate system is right-handed, these
-- unit vectors have the following relation:
-- "Direction" = "X Direction" ^
-- "Y Direction". The "Direction" is also
-- called the "main Direction" because, when the
-- unit vector is modified, the "X Direction" and "Y
-- Direction" are recomputed, whereas when the "X
-- Direction" or "Y Direction" is modified, the "main Direction" does not change.
-- The axis whose origin is the origin of the positioning
-- system and whose unit vector is its "main Direction" is
-- also called the "Axis" or "main Axis" of the positioning system.
uses Ax1 from gp,
Dir from gp,
Pnt from gp,
Vec from gp
raises ConstructionError from Standard
is
SetAxis (me : mutable; A1 : Ax1);
---Purpose : Assigns A1 as the "main Axis" of this positioning system. This modifies
-- - its origin, and
-- - its "main Direction".
-- If this positioning system is a
-- Geom_Axis2Placement, then its "X Direction" and
-- "Y Direction" are recomputed.
-- Exceptions
-- For a Geom_Axis2Placement:
-- Standard_ConstructionError if A1 and the
-- previous "X Direction" of the coordinate system are parallel.
SetDirection (me : mutable; V : Dir)
---Purpose :
-- Changes the direction of the axis placement.
-- If <me> is an axis placement two axis the main "Direction"
-- is modified and the "XDirection" and "YDirection" are
-- recomputed.
-- Raises ConstructionError only for an axis placement two axis if V and the
-- previous "XDirection" are parallel because it is not possible
-- to calculate the new "XDirection" and the new "YDirection".
raises ConstructionError
is deferred;
SetLocation (me : mutable; P : Pnt);
---Purpose :
-- Assigns the point P as the origin of this positioning system.
Angle (me; Other : AxisPlacement) returns Real;
---Purpose : Computes the angular value, in radians, between the
-- "main Direction" of this positioning system and that
-- of positioning system Other. The result is a value between 0 and Pi.
Axis (me) returns Ax1;
---Purpose : Returns the main axis of the axis placement.
-- For an "Axis2placement" it is the main axis (Location, Direction ).
-- For an "Axis1Placement" this method returns a copy of <me>.
---C++: return const&
Direction (me) returns Dir;
---Purpose :
-- Returns the main "Direction" of an axis placement.
Location (me) returns Pnt;
---Purpose :
-- Returns the Location point (origin) of the axis placement.
fields
axis : Ax1 is protected;
end;

33
src/Geom/Geom_AxisPlacement.cxx Executable file
View File

@@ -0,0 +1,33 @@
// File: Geom_AxisPlacement.cxx
// Created: Tue Mar 9 19:29:44 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_AxisPlacement.cxx, JCV 17/01/91
#include <Geom_AxisPlacement.ixx>
typedef Handle(Geom_AxisPlacement) Handle(AxisPlacement);
typedef gp_Ax1 Ax1;
typedef gp_Dir Dir;
typedef gp_Pnt Pnt;
typedef gp_Vec Vec;
const gp_Ax1& Geom_AxisPlacement::Axis () const { return axis; }
Dir Geom_AxisPlacement::Direction () const { return axis.Direction(); }
Pnt Geom_AxisPlacement::Location () const { return axis.Location(); }
void Geom_AxisPlacement::SetAxis (const Ax1& A1) { axis = A1; }
void Geom_AxisPlacement::SetLocation (const Pnt& P) {axis.SetLocation (P);}
Standard_Real Geom_AxisPlacement::Angle (const Handle(AxisPlacement)& Other) const {
return axis.Angle (Other->Axis());
}

1023
src/Geom/Geom_BSplineCurve.cdl Executable file

File diff suppressed because it is too large Load Diff

1327
src/Geom/Geom_BSplineCurve.cxx Executable file

File diff suppressed because it is too large Load Diff

804
src/Geom/Geom_BSplineCurve_1.cxx Executable file
View File

@@ -0,0 +1,804 @@
// File: Geom_BSplineCurve_1.cxx
// Created: Tue Mar 9 19:35:13 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
// 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 <Geom_BSplineCurve.jxx>
#include <BSplCLib.hxx>
#include <gp.hxx>
#include <Geom_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 Geom_BSplineCurve::IsCN ( const Standard_Integer N) const
{
Standard_RangeError_Raise_if
(N < 0, "Geom_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 Geom_BSplineCurve::IsClosed () const
//-- { return (StartPoint().Distance (EndPoint())) <= gp::Resolution (); }
{ return (StartPoint().SquareDistance(EndPoint())) <= 1e-16; }
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_BSplineCurve::IsPeriodic () const
{ return periodic; }
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom_BSplineCurve::Continuity () const
{ return smooth; }
//=======================================================================
//function : Degree
//purpose :
//=======================================================================
Standard_Integer Geom_BSplineCurve::Degree () const
{ return deg; }
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_BSplineCurve::D0 ( const Standard_Real U,
gp_Pnt& P) const
{
Standard_Real NewU = U ;
PeriodicNormalization(NewU) ;
if (!IsCacheValid(NewU))
{
Geom_BSplineCurve * MyCurve = (Geom_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()),
*((TColStd_Array1OfReal*) NULL),
P) ;
}
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_BSplineCurve::D1 (const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1) const
{
Standard_Real NewU = U ;
PeriodicNormalization(NewU) ;
if (!IsCacheValid(NewU))
{
Geom_BSplineCurve * MyCurve = (Geom_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()),
*((TColStd_Array1OfReal*) NULL),
P,
V1) ;
}
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_BSplineCurve::D2 (const Standard_Real U ,
gp_Pnt& P ,
gp_Vec& V1,
gp_Vec& V2 ) const
{
Standard_Real NewU = U ;
PeriodicNormalization(NewU) ;
if (!IsCacheValid(NewU))
{
Geom_BSplineCurve * MyCurve = (Geom_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()),
*((TColStd_Array1OfReal*) NULL),
P,
V1,
V2) ;
}
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_BSplineCurve::D3 (const Standard_Real U ,
gp_Pnt& P ,
gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3 ) const
{
Standard_Real NewU = U ;
PeriodicNormalization(NewU) ;
if (!IsCacheValid(NewU))
{
Geom_BSplineCurve * MyCurve = (Geom_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()),
*((TColStd_Array1OfReal*) NULL),
P,
V1,
V2,
V3) ;
}
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
gp_Vec Geom_BSplineCurve::DN (const Standard_Real U,
const Standard_Integer N ) const
{
gp_Vec 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_Pnt Geom_BSplineCurve::EndPoint () const
{
if (mults->Value (knots->Upper ()) == deg + 1)
return poles->Value (poles->Upper());
else
return Value(LastParameter());
}
//=======================================================================
//function : FirstUKnotIndex
//purpose :
//=======================================================================
Standard_Integer Geom_BSplineCurve::FirstUKnotIndex () const
{
if (periodic) return 1;
else return BSplCLib::FirstUKnotIndex (deg, mults->Array1());
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom_BSplineCurve::FirstParameter () const
{
return flatknots->Value (deg+1);
}
//=======================================================================
//function : Knot
//purpose :
//=======================================================================
Standard_Real Geom_BSplineCurve::Knot (const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if
(Index < 1 || Index > knots->Length(), "Geom_BSplineCurve::Knot");
return knots->Value (Index);
}
//=======================================================================
//function : KnotDistribution
//purpose :
//=======================================================================
GeomAbs_BSplKnotDistribution Geom_BSplineCurve::KnotDistribution () const
{
return knotSet;
}
//=======================================================================
//function : Knots
//purpose :
//=======================================================================
void Geom_BSplineCurve::Knots (TColStd_Array1OfReal& K) const
{
Standard_DimensionError_Raise_if
(K.Length() != knots->Length(), "Geom_BSplineCurve::Knots");
K = knots->Array1();
}
//=======================================================================
//function : KnotSequence
//purpose :
//=======================================================================
void Geom_BSplineCurve::KnotSequence (TColStd_Array1OfReal& K) const
{
Standard_DimensionError_Raise_if
(K.Length() != flatknots->Length(), "Geom_BSplineCurve::KnotSequence");
K = flatknots->Array1();
}
//=======================================================================
//function : LastUKnotIndex
//purpose :
//=======================================================================
Standard_Integer Geom_BSplineCurve::LastUKnotIndex() const
{
if (periodic) return knots->Length();
else return BSplCLib::LastUKnotIndex (deg, mults->Array1());
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom_BSplineCurve::LastParameter () const
{
return flatknots->Value (flatknots->Upper()-deg);
}
//=======================================================================
//function : LocalValue
//purpose :
//=======================================================================
gp_Pnt Geom_BSplineCurve::LocalValue
(const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2) const
{
gp_Pnt P;
LocalD0(U,FromK1,ToK2,P);
return P;
}
//=======================================================================
//function : LocalD0
//purpose :
//=======================================================================
void Geom_BSplineCurve::LocalD0
(const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
gp_Pnt& P) const
{
Standard_DomainError_Raise_if (FromK1 == ToK2,
"Geom_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 Geom_BSplineCurve::LocalD1 (const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
gp_Pnt& P,
gp_Vec& V1) const
{
Standard_DomainError_Raise_if (FromK1 == ToK2,
"Geom_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 Geom_BSplineCurve::LocalD2
(const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2) const
{
Standard_DomainError_Raise_if (FromK1 == ToK2,
"Geom_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 Geom_BSplineCurve::LocalD3
(const Standard_Real U,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3) const
{
Standard_DomainError_Raise_if (FromK1 == ToK2,
"Geom_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_Vec Geom_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,
"Geom_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_Vec 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 Geom_BSplineCurve::Multiplicity
(const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if (Index < 1 || Index > mults->Length(),
"Geom_BSplineCurve::Multiplicity");
return mults->Value (Index);
}
//=======================================================================
//function : Multiplicities
//purpose :
//=======================================================================
void Geom_BSplineCurve::Multiplicities (TColStd_Array1OfInteger& M) const
{
Standard_DimensionError_Raise_if (M.Length() != mults->Length(),
"Geom_BSplineCurve::Multiplicities");
M = mults->Array1();
}
//=======================================================================
//function : NbKnots
//purpose :
//=======================================================================
Standard_Integer Geom_BSplineCurve::NbKnots () const
{ return knots->Length(); }
//=======================================================================
//function : NbPoles
//purpose :
//=======================================================================
Standard_Integer Geom_BSplineCurve::NbPoles () const
{ return poles->Length(); }
//=======================================================================
//function : Pole
//purpose :
//=======================================================================
gp_Pnt Geom_BSplineCurve::Pole (const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if (Index < 1 || Index > poles->Length(),
"Geom_BSplineCurve::Pole");
return poles->Value (Index);
}
//=======================================================================
//function : Poles
//purpose :
//=======================================================================
void Geom_BSplineCurve::Poles (TColgp_Array1OfPnt& P) const
{
Standard_DimensionError_Raise_if (P.Length() != poles->Length(),
"Geom_BSplineCurve::Poles");
P = poles->Array1();
}
//=======================================================================
//function : StartPoint
//purpose :
//=======================================================================
gp_Pnt Geom_BSplineCurve::StartPoint () const
{
if (mults->Value (1) == deg + 1)
return poles->Value (1);
else
return Value(FirstParameter());
}
//=======================================================================
//function : Weight
//purpose :
//=======================================================================
Standard_Real Geom_BSplineCurve::Weight
(const Standard_Integer Index) const
{
Standard_OutOfRange_Raise_if (Index < 1 || Index > poles->Length(),
"Geom_BSplineCurve::Weight");
if (IsRational())
return weights->Value (Index);
else
return 1.;
}
//=======================================================================
//function : Weights
//purpose :
//=======================================================================
void Geom_BSplineCurve::Weights
(TColStd_Array1OfReal& W) const
{
Standard_DimensionError_Raise_if (W.Length() != poles->Length(),
"Geom_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 Geom_BSplineCurve::IsRational () const
{
return !weights.IsNull();
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_BSplineCurve::Transform
(const gp_Trsf& T)
{
TColgp_Array1OfPnt & CPoles = poles->ChangeArray1();
for (Standard_Integer I = 1; I <= CPoles.Length(); I++)
CPoles (I).Transform (T);
InvalidateCache() ;
maxderivinvok = 0;
}
//=======================================================================
//function : LocateU
//purpose :
// pmn : 30/01/97 mise en conformite avec le cdl, lorsque U est un noeud
// (PRO6988)
//=======================================================================
void Geom_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 (NewU - 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 Geom_BSplineCurve::Resolution(const Standard_Real Tolerance3D,
Standard_Real & UTolerance)
{
Standard_Integer ii;
if(!maxderivinvok){
if ( periodic) {
Standard_Integer NbKnots, NbPoles;
BSplCLib::PrepareUnperiodize( deg,
mults->Array1(),
NbKnots,
NbPoles);
TColgp_Array1OfPnt 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 = Tolerance3D * maxderivinv;
}

1475
src/Geom/Geom_BSplineSurface.cdl Executable file

File diff suppressed because it is too large Load Diff

1671
src/Geom/Geom_BSplineSurface.cxx Executable file

File diff suppressed because it is too large Load Diff

2194
src/Geom/Geom_BSplineSurface_1.cxx Executable file

File diff suppressed because it is too large Load Diff

428
src/Geom/Geom_BezierCurve.cdl Executable file
View File

@@ -0,0 +1,428 @@
-- File: Geom_BezierCurve.cdl
-- Created: Tue Mar 9 19:49:01 1993
-- Author: Philippe DAUTRY
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class BezierCurve from Geom inherits BoundedCurve from Geom
---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_Pnt 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
-- that joins the first pole to the second pole is the
-- tangent to the curve at its start point, and the
-- segment that 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 the exact
-- representations of arcs of a circle or ellipse.
-- Moreover, if the weights of all 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 the 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 Geom_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 the 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,
Array1OfPnt from TColgp,
Ax1 from gp,
Ax2 from gp,
Pnt from gp,
HArray1OfPnt from TColgp,
Vec from gp,
Trsf from gp,
Geometry from Geom,
Shape from GeomAbs
raises ConstructionError from Standard,
DimensionError from Standard,
RangeError from Standard,
OutOfRange from Standard
is
Create (CurvePoles : Array1OfPnt 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 : Array1OfPnt 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 : Pnt)
---Purpose : Inserts a pole P after the pole of range Index.
-- If the curve <me> is rational the weight value for the new
-- pole of range Index is 1.0.
raises OutOfRange,
---Purpose : raised if Index is not in the range [1, NbPoles]
ConstructionError;
---Purpose :
-- raised if the resulting number of poles is greater than
-- MaxDegree + 1.
InsertPoleAfter (me : mutable; Index : Integer; P : Pnt; Weight : Real)
---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]
ConstructionError;
---Purpose :
-- Raised if the resulting number of poles is greater than
-- MaxDegree + 1.
-- Raised if Weight is lower or equal to Resolution from package gp.
InsertPoleBefore (me : mutable; Index : Integer; P : Pnt)
---Purpose : Inserts a pole P before the pole of range Index.
-- If the curve <me> is rational the weight value for the new
-- pole of range Index is 1.0.
raises OutOfRange,
---Purpose : Raised if Index is not in the range [1, NbPoles]
ConstructionError;
---Purpose :
-- Raised if the resulting number of poles is greater than
-- MaxDegree + 1.
InsertPoleBefore (me : mutable; Index : Integer; P : Pnt; Weight : Real)
---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]
ConstructionError;
---Purpose :
-- Raised if the resulting number of poles is greater than
-- MaxDegree + 1.
-- Raised if Weight is lower or equal to Resolution from
-- package gp.
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 : Pnt)
---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 : Pnt; 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 True if the parametrization of a curve is periodic.
-- (P(u) = P(u + T) T = constante)
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 : a Bezier curve is CN
Degree (me) returns Integer;
---Purpose : Returns the polynomial degree of the curve.
-- it is the number of poles - 1
---Purpose : point P and derivatives (V1, V2, V3) computation
-- The Bezier Curve has a Polynomial representation so the
-- parameter U can be out of the bounds of the curve.
D0 (me; U : Real; P : out Pnt);
D1 (me; U : Real; P : out Pnt; V1 : out Vec);
D2 (me; U : Real; P : out Pnt; V1, V2 : out Vec);
D3 (me; U : Real; P : out Pnt; V1, V2, V3 : out Vec);
---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.
DN (me; U : Real; N : Integer) returns Vec
---Purpose : For the point of parameter U of this Bezier curve,
-- computes the vector corresponding to the Nth derivative.
-- Note: the parameter U can be outside the bounds of the curve.
-- Exceptions Standard_RangeError if N is less than 1.
raises RangeError;
StartPoint (me) returns Pnt;
---Purpose: Returns Value (U=0.), it is the first control point of the curve.
EndPoint (me) returns Pnt;
---Purpose: Returns Value (U=1.), it is the last control point of the 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 of this Bezier curve.
Pole (me; Index : Integer) returns Pnt
---Purpose : Returns the pole of range Index.
raises OutOfRange;
---Purpose : Raised if Index is not in the range [1, NbPoles]
Poles (me; P : out Array1OfPnt 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.
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 : Trsf);
---Purpose: Applies the transformation T to this Bezier curve.
MaxDegree (myclass) returns Integer;
---Purpose :
-- Returns the value of the maximum polynomial degree
-- of any Geom_BezierCurve curve. This value is 25.
Resolution(me : mutable;
Tolerance3D : Real;
UTolerance : out Real);
---Purpose: Computes for this Bezier curve the parametric
-- tolerance UTolerance for a given 3D tolerance Tolerance3D.
-- If f(t) is the equation of this Bezier curve,
-- UTolerance ensures that:
-- |t1-t0| < UTolerance ===> |f(t1)-f(t0)| < Tolerance3D
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this Bezier curve.
Init (me : mutable; Poles : HArray1OfPnt 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 : HArray1OfPnt from TColgp;
weights : HArray1OfReal from TColStd;
coeffs : HArray1OfPnt from TColgp;
wcoeffs : HArray1OfReal from TColStd;
-- computed at parametercache.
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;

902
src/Geom/Geom_BezierCurve.cxx Executable file
View File

@@ -0,0 +1,902 @@
// File: Geom_BezierCurve.cxx
// Created: Tue Mar 9 19:49:51 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
// File Geom_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 <Geom_BezierCurve.ixx>
#include <PLib.hxx>
#include <BSplCLib.hxx>
#include <gp.hxx>
#include <gp_XYZ.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_DimensionError.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_RangeError.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Precision.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 : Geom_BezierCurve
//purpose :
//=======================================================================
Geom_BezierCurve::Geom_BezierCurve(const TColgp_Array1OfPnt& Poles):
validcache(0), parametercache(0.), spanlenghtcache(1.)
{
Standard_Integer nbpoles = Poles.Length();
if(nbpoles < 2 || nbpoles > (Geom_BezierCurve::MaxDegree() + 1))
Standard_ConstructionError::Raise();
// copy the poles
Handle(TColgp_HArray1OfPnt) npoles =
new TColgp_HArray1OfPnt(1,nbpoles);
npoles->ChangeArray1() = Poles;
// Init non rational
Init(npoles,
Handle(TColStd_HArray1OfReal)());
}
//=======================================================================
//function : Geom_BezierCurve
//purpose :
//=======================================================================
Geom_BezierCurve::Geom_BezierCurve(const TColgp_Array1OfPnt& Poles,
const TColStd_Array1OfReal& Weights):
validcache(0), parametercache(0.), spanlenghtcache(1.)
{
// copy the poles
Standard_Integer nbpoles = Poles.Length();
if(nbpoles < 2 || nbpoles > (Geom_BezierCurve::MaxDegree() + 1))
Standard_ConstructionError::Raise();
Handle(TColgp_HArray1OfPnt) npoles =
new TColgp_HArray1OfPnt(1,nbpoles);
npoles->ChangeArray1() = Poles;
// check the weights
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 Geom_BezierCurve::Increase (const Standard_Integer Deg)
{
if (Deg == Degree()) return;
if(Deg < Degree() ||
Deg > Geom_BezierCurve::MaxDegree())
Standard_ConstructionError::Raise("Geom_BezierCurve::Increase");
Handle(TColgp_HArray1OfPnt) npoles =
new TColgp_HArray1OfPnt(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 Geom_BezierCurve::MaxDegree ()
{
return BSplCLib::MaxDegree();
}
//=======================================================================
//function : InsertPoleAfter
//purpose :
//=======================================================================
void Geom_BezierCurve::InsertPoleAfter
(const Standard_Integer Index,
const gp_Pnt& P)
{
InsertPoleAfter(Index,P,1.);
}
//=======================================================================
//function : InsertPoleAfter
//purpose :
//=======================================================================
void Geom_BezierCurve::InsertPoleAfter
(const Standard_Integer Index,
const gp_Pnt& P,
const Standard_Real Weight)
{
Standard_Integer nbpoles = NbPoles();
if(nbpoles >= Geom_BezierCurve::MaxDegree() ||
Weight <= gp::Resolution())
Standard_ConstructionError::Raise("Geom_BezierCurve::InsertPoleAfter");
if(Index < 0 || Index > nbpoles)
Standard_OutOfRange::Raise("Geom_BezierCurve::InsertPoleAfter");
Standard_Integer i;
// Insert the pole
Handle(TColgp_HArray1OfPnt) npoles =
new TColgp_HArray1OfPnt(1,nbpoles+1);
TColgp_Array1OfPnt& newpoles = npoles->ChangeArray1();
const TColgp_Array1OfPnt& 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 Geom_BezierCurve::InsertPoleBefore
(const Standard_Integer Index,
const gp_Pnt& P)
{
InsertPoleAfter(Index-1,P);
}
//=======================================================================
//function : InsertPoleBefore
//purpose :
//=======================================================================
void Geom_BezierCurve::InsertPoleBefore
(const Standard_Integer Index,
const gp_Pnt& P,
const Standard_Real Weight)
{
InsertPoleAfter(Index-1,P,Weight);
}
//=======================================================================
//function : RemovePole
//purpose :
//=======================================================================
void Geom_BezierCurve::RemovePole
(const Standard_Integer Index)
{
Standard_Integer nbpoles = NbPoles();
if(nbpoles <= 2)
Standard_ConstructionError::Raise("Geom_BezierCurve::RemovePole");
if(Index < 1 || Index > nbpoles)
Standard_OutOfRange::Raise("Geom_BezierCurve::RemovePole");
Standard_Integer i;
// Remove the pole
Handle(TColgp_HArray1OfPnt) npoles =
new TColgp_HArray1OfPnt(1,nbpoles-1);
TColgp_Array1OfPnt& newpoles = npoles->ChangeArray1();
const TColgp_Array1OfPnt& 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 Geom_BezierCurve::Reverse ()
{
gp_Pnt P;
Standard_Integer i, nbpoles = NbPoles();
TColgp_Array1OfPnt & 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 Geom_BezierCurve::ReversedParameter(const Standard_Real U) const
{
return ( 1. - U);
}
//=======================================================================
//function : Segment
//purpose :
//=======================================================================
void Geom_BezierCurve::Segment(const Standard_Real U1, const Standard_Real U2)
{
closed = (Abs(Value(U1).Distance (Value(U2))) <= Precision::Confusion());
if(!CoefficientsOK(0.)) UpdateCoefficients(0.);
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 Geom_BezierCurve::SetPole (const Standard_Integer Index,
const gp_Pnt& P)
{
if(Index < 1 || Index > NbPoles())
Standard_OutOfRange::Raise("Geom_BezierCurve::SetPole");
TColgp_Array1OfPnt& cpoles = poles->ChangeArray1();
cpoles(Index) = P;
if (Index == 1 || Index == cpoles.Length()) {
closed = (cpoles(1).Distance(cpoles(NbPoles())) <= Precision::Confusion());
}
UpdateCoefficients();
}
//=======================================================================
//function : SetPole
//purpose :
//=======================================================================
void Geom_BezierCurve::SetPole(const Standard_Integer Index,
const gp_Pnt& P,
const Standard_Real Weight)
{
SetPole(Index,P);
SetWeight(Index,Weight);
}
//=======================================================================
//function : SetWeight
//purpose :
//=======================================================================
void Geom_BezierCurve::SetWeight(const Standard_Integer Index,
const Standard_Real Weight)
{
Standard_Integer nbpoles = NbPoles();
if(Index < 1 || Index > nbpoles)
Standard_OutOfRange::Raise("Geom_BezierCurve::SetWeight");
if(Weight <= gp::Resolution ())
Standard_ConstructionError::Raise("Geom_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 Geom_BezierCurve::IsClosed () const
{
return closed;
}
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom_BezierCurve::IsCN (const Standard_Integer ) const
{
return Standard_True;
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_BezierCurve::IsPeriodic () const
{
return Standard_False;
}
//=======================================================================
//function : IsRational
//purpose :
//=======================================================================
Standard_Boolean Geom_BezierCurve::IsRational () const
{
return !weights.IsNull();
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom_BezierCurve::Continuity () const
{
return GeomAbs_CN;
}
//=======================================================================
//function : Degree
//purpose :
//=======================================================================
Standard_Integer Geom_BezierCurve::Degree () const
{
return poles->Length()-1;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_BezierCurve::D0 (const Standard_Real U, gp_Pnt& P ) const
{
// Idee lumineuse sacrifiee sur l autel des performances.
//
// if(!CoefficientsOK(U))
// ((Geom_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 Geom_BezierCurve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const
{
// Idee lumineuse sacrifiee sur l autel des performances.
//
// if(!CoefficientsOK(U))
// ((Geom_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 Geom_BezierCurve::D2 (const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2) const
{
// Idee lumineuse sacrifiee sur l autel des performances.
//
// if(!CoefficientsOK(U))
// ((Geom_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 Geom_BezierCurve::D3 (const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3) const
{
if(!CoefficientsOK(U))
((Geom_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_Vec Geom_BezierCurve::DN (const Standard_Real U,
const Standard_Integer N) const
{
if(N < 1)
Standard_RangeError::Raise("Geom_BezierCurve::DN");
gp_Vec 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(),0.,
BSplCLib::DN(U,N,0,Degree(),Standard_False,
poles->Array1(),
weights->Array1(),
bidknots,bidmults,V);
else
// BSplCLib::DN(U,N,0,Degree(),0.,
BSplCLib::DN(U,N,0,Degree(),Standard_False,
poles->Array1(),
*((TColStd_Array1OfReal*) NULL),
bidknots,bidmults,V);
return V;
}
//=======================================================================
//function : StartPoint
//purpose :
//=======================================================================
gp_Pnt Geom_BezierCurve::StartPoint () const
{
return poles->Value(1);
}
//=======================================================================
//function : EndPoint
//purpose :
//=======================================================================
gp_Pnt Geom_BezierCurve::EndPoint () const
{
return poles->Value (poles->Upper());
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom_BezierCurve::FirstParameter () const
{
return 0.0;
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom_BezierCurve::LastParameter () const
{
return 1.0;
}
//=======================================================================
//function : NbPoles
//purpose :
//=======================================================================
Standard_Integer Geom_BezierCurve::NbPoles () const
{
return poles->Length();
}
//=======================================================================
//function : Pole
//purpose :
//=======================================================================
gp_Pnt Geom_BezierCurve::Pole (const Standard_Integer Index) const
{
if(Index < 1 || Index > poles->Length())
Standard_OutOfRange::Raise("Geom_BezierCurve::Pole");
return poles->Value(Index);
}
//=======================================================================
//function : Poles
//purpose :
//=======================================================================
void Geom_BezierCurve::Poles (TColgp_Array1OfPnt& P) const
{
if(P.Length() != poles->Length())
Standard_DimensionError::Raise("Geom_BezierCurve::Poles");
P = poles->Array1();
}
//=======================================================================
//function : Weight
//purpose :
//=======================================================================
Standard_Real Geom_BezierCurve::Weight
(const Standard_Integer Index) const
{
if(Index < 1 || Index > poles->Length())
Standard_OutOfRange::Raise("Geom_BezierCurve::Weight");
if (IsRational())
return weights->Value(Index);
else
return 1.;
}
//=======================================================================
//function : Weights
//purpose :
//=======================================================================
void Geom_BezierCurve::Weights
(TColStd_Array1OfReal& W) const
{
Standard_Integer nbpoles = NbPoles();
if(W.Length() != nbpoles)
Standard_DimensionError::Raise("Geom_BezierCurve::Weights");
if (IsRational())
W = weights->Array1();
else {
Standard_Integer i;
for (i = 1; i <= nbpoles; i++)
W(i) = 1.;
}
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_BezierCurve::Transform (const gp_Trsf& T)
{
Standard_Integer nbpoles = NbPoles();
TColgp_Array1OfPnt & cpoles = poles->ChangeArray1();
for (Standard_Integer i = 1; i <= nbpoles; i++)
cpoles (i).Transform(T);
UpdateCoefficients();
}
//=======================================================================
//function : Resolution
//purpose :
//=======================================================================
void Geom_BezierCurve::Resolution(const Standard_Real Tolerance3D,
Standard_Real & UTolerance)
{
if(!maxderivinvok){
TColStd_Array1OfReal bidflatknots(BSplCLib::FlatBezierKnots(Degree()),
1, 2*(Degree()+1));
if (IsRational()) {
BSplCLib::Resolution(poles->Array1(),
weights->Array1(),
poles->Length(),
bidflatknots,
Degree(),
1.,
maxderivinv) ;
}
else {
BSplCLib::Resolution(poles->Array1(),
BSplCLib::NoWeights(),
poles->Length(),
bidflatknots,
Degree(),
1.,
maxderivinv) ;
}
maxderivinvok = 1;
}
UTolerance = Tolerance3D * maxderivinv;
}
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_BezierCurve::Copy() const {
Handle(Geom_BezierCurve) C;
if (IsRational())
C = new Geom_BezierCurve (poles->Array1(),weights->Array1());
else
C = new Geom_BezierCurve (poles->Array1());
return C;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void Geom_BezierCurve::Init
(const Handle(TColgp_HArray1OfPnt)& Poles,
const Handle(TColStd_HArray1OfReal)& Weights)
{
Standard_Integer nbpoles = Poles->Length();
// closed ?
const TColgp_Array1OfPnt& cpoles = Poles->Array1();
closed = cpoles(1).Distance(cpoles(nbpoles)) <= Precision::Confusion();
// rational
rational = !Weights.IsNull();
// set fields
poles = Poles;
coeffs = new TColgp_HArray1OfPnt (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 Geom_BezierCurve::CoefficientsOK(const Standard_Real U)const
{
return (validcache && ((parametercache == 0. && U < 1.) ||
(parametercache == 1. && U >= 1.)));
}
//=======================================================================
//function : UpdateCoefficients
//purpose :
//=======================================================================
//void Geom_BezierCurve::UpdateCoefficients(const Standard_Real U)
void Geom_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;
}

735
src/Geom/Geom_BezierSurface.cdl Executable file
View File

@@ -0,0 +1,735 @@
-- File: Geom_BezierSurface.cdl
-- Created: Tue Mar 9 19:51:22 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
--
-- RBD : 15/10/98 ; Suppression de la methode privee coefficientsOK
--
--
class BezierSurface from Geom inherits BoundedSurface from Geom
---Purpose : Describes a rational or non-rational Bezier surface.
-- - A non-rational Bezier surface is defined by a table
-- of poles (also known as control points).
-- - A rational Bezier surface is defined by a table of
-- poles with varying associated weights.
-- This data is manipulated using two associative 2D arrays:
-- - the poles table, which is a 2D array of gp_Pnt, and
-- - the weights table, which is a 2D array of reals.
-- The bounds of these arrays are:
-- - 1 and NbUPoles for the row bounds, where
-- NbUPoles is the number of poles of the surface
-- in the u parametric direction, and
-- - 1 and NbVPoles for the column bounds, where
-- NbVPoles is the number of poles of the surface
-- in the v parametric direction.
-- The poles of the surface, the "control points", are the
-- points used to shape and reshape the surface. They
-- comprise a rectangular network of points:
-- - The points (1, 1), (NbUPoles, 1), (1,
-- NbVPoles) and (NbUPoles, NbVPoles)
-- are the four parametric "corners" of the surface.
-- - The first column of poles and the last column of
-- poles define two Bezier curves which delimit the
-- surface in the v parametric direction. These are
-- the v isoparametric curves corresponding to
-- values 0 and 1 of the v parameter.
-- - The first row of poles and the last row of poles
-- define two Bezier curves which delimit the surface
-- in the u parametric direction. These are the u
-- isoparametric curves corresponding to values 0
-- and 1 of the u parameter.
-- It is more difficult to define a geometrical significance
-- for the weights. However they are useful for
-- representing a quadric surface precisely. Moreover, if
-- the weights of all the poles are equal, the surface has
-- a polynomial equation, and hence is a "non-rational surface".
-- The non-rational surface is a special, but frequently
-- used, case, where all poles have identical weights.
-- The weights are defined and used only in the case of
-- a rational surface. This rational characteristic is
-- defined in each parametric direction. Hence, a
-- surface can be rational in the u parametric direction,
-- and non-rational in the v parametric direction.
-- Likewise, the degree of a surface is defined in each
-- parametric direction. The degree of a Bezier surface
-- in a given parametric direction is equal to the number
-- of poles of the surface in that parametric direction,
-- minus 1. This must be greater than or equal to 1.
-- However, the degree for a Geom_BezierSurface is
-- limited to a value of (25) which is defined and
-- controlled by the system. This value is returned by the
-- function MaxDegree.
-- The parameter range for a Bezier surface is [ 0, 1 ]
-- in the two parametric directions.
-- A Bezier surface can also be closed, or open, in each
-- parametric direction. If the first row of poles is
-- identical to the last row of poles, the surface is closed
-- in the u parametric direction. If the first column of
-- poles is identical to the last column of poles, the
-- surface is closed in the v parametric direction.
-- The continuity of a Bezier surface is infinite in the u
-- parametric direction and the in v parametric direction.
-- Note: It is not possible to build a Bezier surface with
-- negative weights. Any weight value that is less than,
-- or equal to, gp::Resolution() is considered
-- to be zero. Two weight values, W1 and W2, are
-- considered equal if: |W2-W1| <= gp::Resolution()
uses Array1OfReal from TColStd,
Array2OfReal from TColStd,
HArray2OfReal from TColStd,
Array1OfPnt from TColgp,
Array2OfPnt from TColgp,
Ax1 from gp,
Ax2 from gp,
HArray2OfPnt from TColgp,
Pnt from gp,
Trsf from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom,
Shape from GeomAbs
raises ConstructionError from Standard,
DimensionError from Standard,
RangeError from Standard,
OutOfRange from Standard
is
Create (SurfacePoles : Array2OfPnt from TColgp)
returns mutable BezierSurface
---Purpose :
-- Creates a non-rational Bezier surface with a set of poles.
-- Control points representation :
-- SPoles(Uorigin,Vorigin) ...................SPoles(Uorigin,Vend)
-- . .
-- . .
-- SPoles(Uend, Vorigin) .....................SPoles(Uend, Vend)
-- For the double array the row indice corresponds to the parametric
-- U direction and the columns indice corresponds to the parametric
-- V direction.
-- The weights are defaulted to all being 1.
raises ConstructionError;
---Purpose :
-- Raised if the number of poles of the surface is lower than 2
-- or greater than MaxDegree + 1 in one of the two directions
-- U or V.
Create (SurfacePoles : Array2OfPnt from TColgp;
PoleWeights : Array2OfReal from TColStd)
returns mutable BezierSurface
---Purpose
-- Creates a rational Bezier surface with a set of poles and a
-- set of weights.
-- For the double array the row indice corresponds to the parametric
-- U direction and the columns indice corresponds to the parametric
-- V direction.
-- If all the weights are identical the surface is considered as
-- non-rational (the tolerance criterion is Resolution from package
-- gp).
raises ConstructionError;
---Purpose :
-- Raised if SurfacePoles and PoleWeights have not the same
-- Rowlength or have not the same ColLength.
-- Raised if PoleWeights (i, j) <= Resolution from gp;
-- Raised if the number of poles of the surface is lower than 2
-- or greater than MaxDegree + 1 in one of the two directions U or V.
ExchangeUV (me : mutable);
---Purpose : Exchanges the direction U and V on a Bezier surface
-- As a consequence:
-- - the poles and weights tables are transposed,
-- - degrees, rational characteristics and so on are
-- exchanged between the two parametric directions, and
-- - the orientation of the surface is reversed.
Increase (me : mutable; UDeg, VDeg : Integer)
---Purpose : Increases the degree of this Bezier surface in the two parametric directions.
raises ConstructionError;
---Purpose :
-- Raised if UDegree < UDegree <me> or VDegree < VDegree <me>
-- Raised if the degree of the surface is greater than MaxDegree
-- in one of the two directions U or V.
InsertPoleColAfter (me : mutable; VIndex : Integer;
CPoles : Array1OfPnt from TColgp)
---Purpose:
-- Inserts a column of poles. If the surface is rational the weights
-- values associated with CPoles are equal defaulted to 1.
raises OutOfRange,
---Purpose:
-- Raised if Vindex < 1 or VIndex > NbVPoles.
ConstructionError;
---Purpose:
-- raises if VDegree is greater than MaxDegree.
-- raises if the Length of CPoles is not equal to NbUPoles
InsertPoleColAfter (me : mutable; VIndex : Integer;
CPoles : Array1OfPnt from TColgp;
CPoleWeights : Array1OfReal from TColStd)
---Purpose :
-- Inserts a column of poles and weights.
-- If the surface was non-rational it can become rational.
raises OutOfRange,
---Purpose:
-- Raised if Vindex < 1 or VIndex > NbVPoles.
ConstructionError;
---Purpose : Raised if
-- . VDegree is greater than MaxDegree.
-- . the Length of CPoles is not equal to NbUPoles
-- . a weight value is lower or equal to Resolution from
-- package gp
InsertPoleColBefore (me : mutable; VIndex : Integer;
CPoles : Array1OfPnt from TColgp)
---Purpose:
-- Inserts a column of poles. If the surface is rational the weights
-- values associated with CPoles are equal defaulted to 1.
raises OutOfRange,
---Purpose:
-- Raised if Vindex < 1 or VIndex > NbVPoles.
ConstructionError;
---Purpose:
-- Raised if VDegree is greater than MaxDegree.
-- Raised if the Length of CPoles is not equal to NbUPoles
InsertPoleColBefore (me : mutable; VIndex : Integer;
CPoles : Array1OfPnt from TColgp;
CPoleWeights : Array1OfReal from TColStd)
---Purpose :
-- Inserts a column of poles and weights.
-- If the surface was non-rational it can become rational.
raises OutOfRange,
---Purpose:
-- Raised if Vindex < 1 or VIndex > NbVPoles.
ConstructionError;
---Purpose : Raised if :
-- . VDegree is greater than MaxDegree.
-- . the Length of CPoles is not equal to NbUPoles
-- . a weight value is lower or equal to Resolution from
-- package gp
InsertPoleRowAfter (me : mutable; UIndex : Integer;
CPoles : Array1OfPnt from TColgp)
---Purpose:
-- Inserts a row of poles. If the surface is rational the weights
-- values associated with CPoles are equal defaulted to 1.
raises OutOfRange,
---Purpose:
-- Raised if Uindex < 1 or UIndex > NbUPoles.
ConstructionError;
---Purpose:
-- Raised if UDegree is greater than MaxDegree.
-- Raised if the Length of CPoles is not equal to NbVPoles
InsertPoleRowAfter (me : mutable; UIndex : Integer;
CPoles : Array1OfPnt from TColgp;
CPoleWeights : Array1OfReal from TColStd)
---Purpose :
-- Inserts a row of poles and weights.
-- If the surface was non-rational it can become rational.
raises OutOfRange,
---Purpose:
-- Raised if Uindex < 1 or UIndex > NbUPoles.
ConstructionError;
---Purpose : Raised if :
-- . UDegree is greater than MaxDegree.
-- . the Length of CPoles is not equal to NbVPoles
-- . a weight value is lower or equal to Resolution from
-- package gp
InsertPoleRowBefore (me : mutable; UIndex : Integer;
CPoles : Array1OfPnt from TColgp)
---Purpose:
-- Inserts a row of poles. If the surface is rational the weights
-- values associated with CPoles are equal defaulted to 1.
raises OutOfRange,
---Purpose:
-- Raised if Uindex < 1 or UIndex > NbUPoles.
ConstructionError;
---Purpose:
-- Raised if UDegree is greater than MaxDegree.
-- Raised if the Length of CPoles is not equal to NbVPoles
InsertPoleRowBefore (me : mutable; UIndex : Integer;
CPoles : Array1OfPnt from TColgp;
CPoleWeights : Array1OfReal from TColStd)
---Purpose :
-- Inserts a row of poles and weights.
-- If the surface was non-rational it can become rational.
raises OutOfRange,
---Purpose:
-- Raised if Uindex < 1 or UIndex > NbUPoles.
ConstructionError;
---Purpose : Raised if :
-- . UDegree is greater than MaxDegree.
-- . the Length of CPoles is not equal to NbVPoles
-- . a weight value is lower or equal to Resolution from
-- pacakage gp
RemovePoleCol (me : mutable; VIndex : Integer)
---Purpose : Removes a column of poles.
-- If the surface was rational it can become non-rational.
raises ConstructionError,
---Purpose :
-- Raised if NbVPoles <= 2 after removing, a Bezier surface
-- must have at least two columns of poles.
OutOfRange;
---Purpose : Raised if Vindex < 1 or VIndex > NbVPoles
RemovePoleRow (me : mutable; UIndex : Integer)
---Purpose : Removes a row of poles.
-- If the surface was rational it can become non-rational.
raises ConstructionError,
---Purpose :
-- Raised if NbUPoles <= 2 after removing, a Bezier surface
-- must have at least two rows of poles.
OutOfRange;
---Purpose : Raised if Uindex < 1 or UIndex > NbUPoles
Segment (me : mutable; U1, U2, V1, V2 : Real);
---Purpose : Modifies this Bezier surface by segmenting it
-- between U1 and U2 in the u parametric direction,
-- and between V1 and V2 in the v parametric
-- direction. U1, U2, V1, and V2 can be outside the
-- bounds of this surface.
-- - U1 and U2 isoparametric Bezier curves,
-- segmented between V1 and V2, become the two
-- bounds of the surface in the v parametric
-- direction (0. and 1. u isoparametric curves).
-- - V1 and V2 isoparametric Bezier curves,
-- segmented between U1 and U2, become the two
-- bounds of the surface in the u parametric
-- direction (0. and 1. v isoparametric curves).
-- The poles and weights tables are modified, but the
-- degree of this surface in the u and v parametric
-- directions does not change.
-- U1 can be greater than U2, and V1 can be greater
-- than V2. In these cases, the corresponding
-- parametric direction is inverted. The orientation of
-- the surface is inverted if one (and only one)
-- parametric direction is inverted.
SetPole (me : mutable; UIndex, VIndex : Integer; P : Pnt)
---Purpose : Modifies a pole value.
-- If the surface is rational the weight of range (UIndex, VIndex)
-- is not modified.
raises OutOfRange;
---Purpose :
-- Raised if UIndex < 1 or UIndex > NbUPoles or VIndex < 1
-- or VIndex > NbVPoles.
SetPole (me : mutable; UIndex, VIndex : Integer; P : Pnt; Weight : Real)
---Purpose :
-- Substitutes the pole and the weight of range UIndex, VIndex.
-- If the surface <me> is not rational it can become rational.
-- if the surface was rational it can become non-rational.
raises OutOfRange,
---Purpose :
-- raises if UIndex < 1 or UIndex > NbUPoles or VIndex < 1
-- or VIndex > NbVPoles.
ConstructionError;
---Purpose : Raised if Weight <= Resolution from package gp.
SetPoleCol (me : mutable; VIndex : Integer;
CPoles : Array1OfPnt from TColgp)
---Purpose : Modifies a column of poles.
-- The length of CPoles can be lower but not greater than NbUPoles
-- so you can modify just a part of the column.
raises OutOfRange,
---Purpose : Raised if VIndex < 1 or VIndex > NbVPoles
ConstructionError;
---Purpose :
-- Raised if CPoles.Lower() < 1 or CPoles.Upper() > NbUPoles
SetPoleCol (me : mutable; VIndex : Integer;
CPoles : Array1OfPnt from TColgp;
CPoleWeights : Array1OfReal from TColStd)
---Purpose : Modifies a column of poles.
-- If the surface was rational it can become non-rational
-- If the surface was non-rational it can become rational.
-- The length of CPoles can be lower but not greater than NbUPoles
-- so you can modify just a part of the column.
raises OutOfRange,
---Purpose : Raised if VIndex < 1 or VIndex > NbVPoles
ConstructionError;
---Purpose :
-- Raised if CPoles.Lower() < 1 or CPoles.Upper() > NbUPoles
-- Raised if CPoleWeights and CPoles have not the same bounds.
-- Raised if one of the weight value CPoleWeights (i) is lower
-- or equal to Resolution from package gp.
SetPoleRow (me : mutable; UIndex : Integer;
CPoles : Array1OfPnt from TColgp)
---Purpose : Modifies a row of poles.
-- The length of CPoles can be lower but not greater than NbVPoles
-- so you can modify just a part of the row.
raises OutOfRange,
---Purpose : Raised if UIndex < 1 or UIndex > NbUPoles
ConstructionError;
---Purpose :
-- Raised if CPoles.Lower() < 1 or CPoles.Upper() > NbVPoles
SetPoleRow (me : mutable; UIndex : Integer;
CPoles : Array1OfPnt from TColgp;
CPoleWeights : Array1OfReal from TColStd)
---Purpose : Modifies a row of poles and weights.
-- If the surface was rational it can become non-rational.
-- If the surface was non-rational it can become rational.
-- The length of CPoles can be lower but not greater than NbVPoles
-- so you can modify just a part of the row.
raises OutOfRange,
---Purpose : Raised if UIndex < 1 or UIndex > NbUPoles
ConstructionError;
---Purpose :
-- Raised if CPoles.Lower() < 1 or CPoles.Upper() > NbVPoles
-- Raised if CPoleWeights and CPoles have not the same bounds.
-- Raised if one of the weight value CPoleWeights (i) is lower
-- or equal to Resolution from gp.
SetWeight (me : mutable; UIndex, VIndex : Integer; Weight : Real)
---Purpose :
-- Modifies the weight of the pole of range UIndex, VIndex.
-- If the surface was non-rational it can become rational.
-- If the surface was rational it can become non-rational.
raises OutOfRange,
---Purpose :
-- Raised if UIndex < 1 or UIndex > NbUPoles or VIndex < 1 or
-- VIndex > NbVPoles.
ConstructionError;
---Purpose : Raised if Weight <= Resolution from package gp.
SetWeightCol (me : mutable; VIndex : Integer;
CPoleWeights : Array1OfReal from TColStd)
---Purpose : Modifies a column of weights.
-- If the surface was rational it can become non-rational.
-- If the surface was non-rational it can become rational.
-- The length of CPoleWeights can be lower but not greater than
-- NbUPoles.
raises OutOfRange,
---Purpose : Raised if VIndex < 1 or VIndex > NbVPoles
ConstructionError;
---Purpose :
-- Raised if CPoleWeights.Lower() < 1 or CPoleWeights.Upper() >
-- NbUPoles
-- Raised if one of the weight value CPoleWeights (i) is lower
-- or equal to Resolution from package gp.
SetWeightRow (me : mutable; UIndex : Integer;
CPoleWeights : Array1OfReal from TColStd)
---Purpose : Modifies a row of weights.
-- If the surface was rational it can become non-rational.
-- If the surface was non-rational it can become rational.
-- The length of CPoleWeights can be lower but not greater than
-- NbVPoles.
raises OutOfRange,
---Purpose : Raised if UIndex < 1 or UIndex > NbUPoles
ConstructionError;
---Purpose :
-- Raised if CPoleWeights.Lower() < 1 or CPoleWeights.Upper() >
-- NbVPoles
-- Raised if one of the weight value CPoleWeights (i) is lower
-- or equal to Resolution from package gp.
UReverse (me : mutable);
---Purpose : Changes the orientation of this Bezier surface in the
-- u parametric direction. The bounds of the
-- surface are not changed, but the given parametric
-- direction is reversed. Hence, the orientation of the surface is reversed.
UReversedParameter (me; U : Real) returns Real;
---Purpose: Computes the u (or v) parameter on the modified
-- surface, produced by reversing its u (or v) parametric
-- direction, for any point of u parameter U (or of v
-- parameter V) on this Bezier surface.
-- In the case of a Bezier surface, these functions return respectively:
-- - 1.-U, or 1.-V.
VReverse (me : mutable);
---Purpose : Changes the orientation of this Bezier surface in the
-- v parametric direction. The bounds of the
-- surface are not changed, but the given parametric
-- direction is reversed. Hence, the orientation of the
-- surface is reversed.
VReversedParameter (me; V : Real) returns Real;
---Purpose: Computes the u (or v) parameter on the modified
-- surface, produced by reversing its u (or v) parametric
-- direction, for any point of u parameter U (or of v
-- parameter V) on this Bezier surface.
-- In the case of a Bezier surface, these functions return respectively:
-- - 1.-U, or 1.-V.
Bounds (me; U1, U2, V1, V2 : out Real);
---Purpose : Returns the parametric bounds U1, U2, V1 and V2 of
-- this Bezier surface.
-- In the case of a Bezier surface, this function returns
-- U1 = 0, V1 = 0, U2 = 1, V2 = 1.
Continuity (me) returns Shape from GeomAbs;
---Purpose :
-- Returns the continuity of the surface CN : the order of
-- continuity is infinite.
D0 (me; U, V : Real; P : out Pnt);
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec);
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec);
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV : out Vec);
---Purpose: Computes P, the point of parameters (U, V) of this Bezier surface, and
-- - one or more of the following sets of vectors:
-- - D1U and D1V, the first derivative vectors at this point,
-- - D2U, D2V and D2UV, the second derivative
-- vectors at this point,
-- - D3U, D3V, D3UUV and D3UVV, the third
-- derivative vectors at this point.
-- Note: The parameters U and V can be outside the bounds of the surface.
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
---Purpose : Computes the derivative of order Nu in the u
-- parametric direction, and Nv in the v parametric
-- direction, at the point of parameters (U, V) of this Bezier surface.
-- Note: The parameters U and V can be outside the bounds of the surface.
-- Exceptions
-- Standard_RangeError if:
-- - Nu + Nv is less than 1, or Nu or Nv is negative.
raises RangeError;
NbUPoles (me) returns Integer;
---Purpose : Returns the number of poles in the U direction.
NbVPoles (me) returns Integer;
---Purpose : Returns the number of poles in the V direction.
Pole (me; UIndex, VIndex : Integer) returns Pnt
---Purpose : Returns the pole of range UIndex, VIndex
raises OutOfRange;
---Purpose : Raised if UIndex < 1 or UIndex > NbUPoles, or
-- VIndex < 1 or VIndex > NbVPoles.
Poles (me; P : out Array2OfPnt from TColgp)
---Purpose : Returns the poles of the Bezier surface.
raises DimensionError;
---Purpose :
-- Raised if the length of P in the U an V direction is not equal to
-- NbUPoles and NbVPoles.
UDegree (me) returns Integer;
---Purpose :
-- Returns the degree of the surface in the U direction it is
-- NbUPoles - 1
UIso (me; U : Real) returns mutable Curve;
---Purpose :
-- Computes the U isoparametric curve. For a Bezier surface the
-- UIso curve is a Bezier curve.
VDegree (me) returns Integer;
---Purpose :
-- Returns the degree of the surface in the V direction it is
-- NbVPoles - 1
VIso (me; V : Real) returns mutable Curve;
---Purpose :
-- Computes the V isoparametric curve. For a Bezier surface the
-- VIso curve is a Bezier curve.
Weight (me; UIndex, VIndex : Integer) returns Real
---Purpose : Returns the weight of range UIndex, VIndex
raises OutOfRange;
---Purpose :
-- Raised if UIndex < 1 or UIndex > NbUPoles, or
-- VIndex < 1 or VIndex > NbVPoles.
Weights (me; W : out Array2OfReal from TColStd)
---Purpose : Returns the weights of the Bezier surface.
raises DimensionError;
---Purpose :
-- Raised if the length of W in the U an V direction is not
-- equal to NbUPoles and NbVPoles.
IsUClosed (me) returns Boolean;
---Purpose :
-- Returns True if the first control points row and the
-- last control points row are identical. The tolerance
-- criterion is Resolution from package gp.
IsVClosed (me) returns Boolean;
---Purpose :
-- Returns True if the first control points column
-- and the last control points column are identical.
-- The tolerance criterion is Resolution from package gp.
IsCNu (me; N : Integer) returns Boolean;
---Purpose : Returns True, a Bezier surface is always CN
IsCNv (me; N : Integer) returns Boolean;
---Purpose : Returns True, a BezierSurface is always CN
IsUPeriodic (me) returns Boolean;
---Purpose : Returns False.
IsVPeriodic (me) returns Boolean;
---Purpose : Returns False.
IsURational (me) returns Boolean;
---Purpose :
-- Returns False if the weights are identical in the U direction,
-- The tolerance criterion is Resolution from package gp.
--- Example :
-- |1.0, 1.0, 1.0|
-- if Weights = |0.5, 0.5, 0.5| returns False
-- |2.0, 2.0, 2.0|
IsVRational (me) returns Boolean;
---Purpose :
-- Returns False if the weights are identical in the V direction,
-- The tolerance criterion is Resolution from package gp.
--- Example :
-- |1.0, 2.0, 0.5|
-- if Weights = |1.0, 2.0, 0.5| returns False
-- |1.0, 2.0, 0.5|
Transform (me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this Bezier surface.
MaxDegree (myclass) returns Integer;
---Purpose:
-- Returns the value of the maximum polynomial degree of a
-- Bezier surface. This value is 25.
Create (SurfacePoles, SurfaceCoefficients : HArray2OfPnt from TColgp;
PoleWeights, CoefficientWeights : HArray2OfReal from TColStd;
IsURational, IsVRational : Boolean)
returns mutable BezierSurface
is private;
Resolution(me : mutable;
Tolerance3D : Real ;
UTolerance : out Real ;
VTolerance : out Real) ;
---Purpose: Computes two tolerance values for this Bezier
-- surface, based on the given tolerance in 3D space
-- Tolerance3D. The tolerances computed are:
-- - UTolerance in the u parametric direction, and
-- - VTolerance in the v parametric direction.
-- If f(u,v) is the equation of this Bezier surface,
-- UTolerance and VTolerance guarantee that:
-- | u1 - u0 | < UTolerance and
-- | v1 - v0 | < VTolerance
-- ====> |f (u1,v1) - f (u0,v0)| < Tolerance3D
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this Bezier surface.
Init (me : mutable; Poles : HArray2OfPnt from TColgp;
Weights : HArray2OfReal from TColStd)
---Purpose : Set poles to Poles, weights to Weights (not
-- copied).
-- Create the arrays of coefficients. Poles
-- and Weights are assumed to have the first
-- coefficient 1.
--
raises ConstructionError -- if nbpoles < 2 or nbpoles > MaDegree
is static private;
UpdateCoefficients(me : mutable;
U : Real from Standard = 0.0;
V : Real from Standard = 0.0)
---Purpose: Recompute the coeficients.
is static private;
fields
urational : Boolean;
vrational : Boolean;
poles : HArray2OfPnt from TColgp;
weights : HArray2OfReal from TColStd;
coeffs : HArray2OfPnt from TColgp;
wcoeffs : HArray2OfReal from TColStd;
ucacheparameter : Real ;
vcacheparameter : Real ;
-- Parameters at which the Taylor expension is stored in
-- the cache
ucachespanlenght : Real ;
vcachespanlenght : Real ;
-- Always 1. for the moment.
ucachespanindex : Integer ;
vcachespanindex : Integer ;
-- the span for which the cache is valid if
-- validcache is 1
validcache : Integer ;
-- usefull to evaluate the parametric resolutions
umaxderivinv : Real from Standard;
vmaxderivinv : Real from Standard;
maxderivinvok : Boolean from Standard;
end;

2145
src/Geom/Geom_BezierSurface.cxx Executable file

File diff suppressed because it is too large Load Diff

42
src/Geom/Geom_BoundedCurve.cdl Executable file
View File

@@ -0,0 +1,42 @@
-- File: Geom_BoundedCurve.cdl
-- Created: Wed Mar 10 09:24:17 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class BoundedCurve from Geom inherits Curve from Geom
---Purpose : The abstract class BoundedCurve describes the
-- common behavior of bounded curves in 3D 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 Geom package provides three concrete classes of bounded curves:
-- - two frequently used mathematical formulations of complex curves:
-- - Geom_BezierCurve,
-- - Geom_BSplineCurve, and
-- - Geom_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 Pnt from gp
is
EndPoint (me) returns Pnt
---Purpose : Returns the end point of the curve.
is deferred;
StartPoint (me) returns Pnt
---Purpose : Returns the start point of the curve.
is deferred;
end;

10
src/Geom/Geom_BoundedCurve.cxx Executable file
View File

@@ -0,0 +1,10 @@
// File: Geom_BoundedCurve.cxx
// Created: Wed Mar 10 09:25:56 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_BoundedCurve.cxx, JCV 17/01/91
#include <Geom_BoundedCurve.ixx>

View File

@@ -0,0 +1,43 @@
-- File: Geom_BoundedSurface.cdl
-- Created: Wed Mar 10 09:26:16 1993
-- Author: Philippe DAUTRY
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class BoundedSurface from Geom inherits Surface from Geom
---Purpose : The root class for bounded surfaces in 3D space. A
-- bounded surface is defined by a rectangle in its 2D parametric space, i.e.
-- - its u parameter, which ranges between two finite
-- values u0 and u1, referred to as "First u
-- parameter" and "Last u parameter" respectively, and
-- - its v parameter, which ranges between two finite
-- values v0 and v1, referred to as "First v
-- parameter" and the "Last v parameter" respectively.
-- The surface is limited by four curves which are the
-- boundaries of the surface:
-- - its u0 and u1 isoparametric curves in the u parametric direction, and
-- - its v0 and v1 isoparametric curves in the v parametric direction.
-- A bounded surface is finite.
-- The common behavior of all bounded surfaces is
-- described by the Geom_Surface class.
-- The Geom package provides three concrete
-- implementations of bounded surfaces:
-- - Geom_BezierSurface,
-- - Geom_BSplineSurface, and
-- - Geom_RectangularTrimmedSurface.
-- The first two of these implement well known
-- mathematical definitions of complex surfaces, the third
-- trims a surface using four isoparametric curves, i.e. it
-- limits the variation of its parameters to a rectangle in
-- 2D parametric space.
is
end;

View File

@@ -0,0 +1,10 @@
// File: Geom_BoundedSurface.cxx
// Created: Wed Mar 10 09:27:23 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_BoundedSurface.cxx, JCV 17/01/91
#include <Geom_BoundedSurface.ixx>

View File

@@ -0,0 +1,86 @@
-- File: Geom_CartesianPoint.cdl
-- Created: Wed Mar 10 09:27:52 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class CartesianPoint from Geom inherits Point from Geom
---Purpose : Describes a point in 3D space. A
-- Geom_CartesianPoint is defined by a gp_Pnt point,
-- with its three Cartesian coordinates X, Y and Z.
uses Ax1 from gp,
Ax2 from gp,
Pnt from gp,
Trsf from gp,
Vec from gp,
Geometry from Geom
is
Create (P : Pnt) returns mutable CartesianPoint;
---Purpose : Returns a transient copy of P.
Create (X, Y, Z : Real) returns mutable CartesianPoint;
---Purpose: Constructs a point defined by its three Cartesian coordinates X, Y and Z.
SetCoord (me : mutable; X, Y, Z : Real);
---Purpose : Assigns the coordinates X, Y and Z to this point.
SetPnt (me : mutable; P : Pnt);
---Purpose : Set <me> to P.X(), P.Y(), P.Z() 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.
SetZ (me : mutable; Z : Real);
---Purpose : Changes the Z coordinate of me.
Coord (me; X, Y, Z : out Real);
---Purpose : Returns the coordinates of <me>.
Pnt (me) returns Pnt;
---Purpose :
-- Returns a non transient cartesian point with
-- the same coordinates as <me>.
X (me) returns Real;
---Purpose : Returns the X coordinate of <me>.
Y (me) returns Real;
---Purpose : Returns the Y coordinate of <me>.
Z (me) returns Real;
---Purpose : Returns the Z coordinate of <me>.
Transform (me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this point.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this point.
fields
gpPnt : Pnt;
end;

140
src/Geom/Geom_CartesianPoint.cxx Executable file
View File

@@ -0,0 +1,140 @@
// File: Geom_CartesianPoint.cxx
// Created: Wed Mar 10 09:28:38 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_CartesianPoint.cxx, JCV 16/01/91
#include <Geom_CartesianPoint.ixx>
typedef Geom_CartesianPoint CartesianPoint;
typedef Handle(Geom_CartesianPoint) Handle(CartesianPoint);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Vec Vec;
typedef gp_Trsf Trsf;
//=======================================================================
//function : Geom_CartesianPoint
//purpose :
//=======================================================================
Geom_CartesianPoint::Geom_CartesianPoint (const gp_Pnt& P) : gpPnt(P) { }
//=======================================================================
//function : Geom_CartesianPoint
//purpose :
//=======================================================================
Geom_CartesianPoint::Geom_CartesianPoint (
const Standard_Real X, const Standard_Real Y, const Standard_Real Z) : gpPnt (X, Y ,Z) { }
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_CartesianPoint::Copy() const {
Handle(CartesianPoint) P;
P = new CartesianPoint (gpPnt);
return P;
}
//=======================================================================
//function : SetCoord
//purpose :
//=======================================================================
void Geom_CartesianPoint::SetCoord (const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
gpPnt.SetCoord (X, Y, Z);
}
//=======================================================================
//function : SetPnt
//purpose :
//=======================================================================
void Geom_CartesianPoint::SetPnt (const gp_Pnt& P) { gpPnt = P; }
//=======================================================================
//function : SetX
//purpose :
//=======================================================================
void Geom_CartesianPoint::SetX (const Standard_Real X) { gpPnt.SetX (X); }
//=======================================================================
//function : SetY
//purpose :
//=======================================================================
void Geom_CartesianPoint::SetY (const Standard_Real Y) { gpPnt.SetY (Y); }
//=======================================================================
//function : SetZ
//purpose :
//=======================================================================
void Geom_CartesianPoint::SetZ (const Standard_Real Z) { gpPnt.SetZ (Z); }
//=======================================================================
//function : Coord
//purpose :
//=======================================================================
void Geom_CartesianPoint::Coord (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const {
gpPnt.Coord (X, Y, Z);
}
//=======================================================================
//function : Pnt
//purpose :
//=======================================================================
gp_Pnt Geom_CartesianPoint::Pnt () const { return gpPnt; }
//=======================================================================
//function : X
//purpose :
//=======================================================================
Standard_Real Geom_CartesianPoint::X () const { return gpPnt.X(); }
//=======================================================================
//function : Y
//purpose :
//=======================================================================
Standard_Real Geom_CartesianPoint::Y () const { return gpPnt.Y(); }
//=======================================================================
//function : Z
//purpose :
//=======================================================================
Standard_Real Geom_CartesianPoint::Z () const { return gpPnt.Z(); }
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_CartesianPoint::Transform (const Trsf& T) { gpPnt.Transform (T); }

173
src/Geom/Geom_Circle.cdl Executable file
View File

@@ -0,0 +1,173 @@
-- File: Geom_Circle.cdl
-- Created: Wed Mar 10 09:29:19 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Circle from Geom inherits Conic from Geom
---Purpose : Describes a circle in 3D space.
-- A circle is defined by its radius and, as with any conic
-- curve, is positioned in space with a right-handed
-- coordinate system (gp_Ax2 object) where:
-- - the origin is the center of the circle, and
-- - the origin, "X Direction" and "Y Direction" define the
-- plane of the circle.
-- This coordinate system is the local coordinate
-- system of the circle.
-- The "main Direction" of this coordinate system is the
-- vector normal to the plane of the circle. The axis, of
-- which the origin and unit vector are respectively the
-- origin and "main Direction" of the local coordinate
-- system, is termed the "Axis" or "main Axis" of the circle.
-- The "main Direction" of the local coordinate system
-- gives an explicit orientation to the circle (definition of
-- the trigonometric sense), determining the direction in
-- which the parameter increases along the circle.
-- The Geom_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 [.
uses Ax2 from gp,
Circ from gp,
Pnt from gp,
Trsf from gp,
Vec from gp,
Geometry from Geom
raises ConstructionError from Standard,
RangeError from Standard
is
Create (C : Circ) returns mutable Circle;
---Purpose : Constructs a circle by conversion of the gp_Circ circle C.
Create (A2 : Ax2; Radius : Real) returns mutable Circle
---Purpose : Constructs a circle of radius Radius, where A2 locates the circle and
-- defines its orientation in 3D space such that:
-- - the center of the circle is the origin of A2,
-- - the origin, "X Direction" and "Y Direction" of A2
-- define the plane of the circle,
-- - A2 is the local coordinate system of the circle.
-- Note: It is possible to create a circle where Radius is equal to 0.0.
raises ConstructionError;
---Purpose : raised if Radius < 0.
SetCirc (me : mutable; C : Circ)
---Purpose :
-- Set <me> so that <me> has the same geometric properties as C.
is static;
SetRadius (me : mutable; R : Real)
---Purpose: 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
is static;
Circ (me) returns Circ
---Purpose :
-- returns the non transient circle from gp with the same
-- geometric properties as <me>.
is static;
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 the eccentricity e = 0 for a circle.
FirstParameter (me) returns Real is redefined static;
---Purpose : Returns the value of the first parameter of this
-- circle. This is 0.0, which gives the start point of this circle, or
-- The start point and end point of a circle are coincident.
LastParameter (me) returns Real is redefined static;
---Purpose : Returns the value of the last parameter of this
-- circle. This is 2.*Pi, which gives the end point of this circle.
-- The start point and end point of a circle are coincident.
IsClosed (me) returns Boolean is redefined static;
---Purpose : returns True.
IsPeriodic (me) returns Boolean is redefined static;
---Purpose : returns True.
D0(me; U : Real; P : out Pnt) 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 Pnt; V1 : out Vec) is redefined static;
---Purpose :
-- Returns the point P of parameter U and the first derivative V1.
D2 (me; U : Real; P : out Pnt; V1, V2 : out Vec) 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 Pnt; V1, V2, V3 : out Vec) 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 Vec
---Purpose :
-- The returned vector gives the value of the derivative for the
-- order of derivation N.
raises RangeError
is redefined static;
---Purpose : Raised if N < 1.
Transform (me : mutable; T : Trsf) 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;

219
src/Geom/Geom_Circle.cxx Executable file
View File

@@ -0,0 +1,219 @@
// File: Geom_Circle.cxx
// Created: Wed Mar 10 09:29:53 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Circle.cxx, JCV 17/01/91
#include <Geom_Circle.ixx>
#include <gp_XYZ.hxx>
#include <ElCLib.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_ConstructionError.hxx>
typedef Geom_Circle Circle;
typedef Handle(Geom_Circle) Handle(Circle);
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
typedef gp_XYZ XYZ;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_Circle::Copy() const {
Handle(Circle) C;
C = new Circle (pos, radius);
return C;
}
//=======================================================================
//function : Geom_Circle
//purpose :
//=======================================================================
Geom_Circle::Geom_Circle (const gp_Circ& C) : radius (C.Radius()) {
pos = C.Position();
}
//=======================================================================
//function : Geom_Circle
//purpose :
//=======================================================================
Geom_Circle::Geom_Circle (const Ax2& A2, const Standard_Real R) : radius (R) {
if (R < 0.0) Standard_ConstructionError::Raise();
pos = A2;
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_Circle::IsClosed () const { return Standard_True; }
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_Circle::IsPeriodic () const { return Standard_True; }
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Circle::ReversedParameter( const Standard_Real U) const
{
return ( 2. * PI - U);
}
//=======================================================================
//function : Eccentricity
//purpose :
//=======================================================================
Standard_Real Geom_Circle::Eccentricity () const { return 0.0; }
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom_Circle::FirstParameter () const { return 0.0; }
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom_Circle::LastParameter () const { return 2.0 * PI; }
//=======================================================================
//function : Circ
//purpose :
//=======================================================================
gp_Circ Geom_Circle::Circ () const { return gp_Circ (pos, radius); }
//=======================================================================
//function : SetCirc
//purpose :
//=======================================================================
void Geom_Circle::SetCirc (const gp_Circ& C) {
radius = C.Radius();
pos = C.Position();
}
//=======================================================================
//function : SetRadius
//purpose :
//=======================================================================
void Geom_Circle::SetRadius (const Standard_Real R) {
if (R < 0.0) Standard_ConstructionError::Raise();
radius = R;
}
//=======================================================================
//function : Radius
//purpose :
//=======================================================================
Standard_Real Geom_Circle::Radius() const
{
return radius;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_Circle::D0 (const Standard_Real U, Pnt& P) const {
P = ElCLib::CircleValue (U, pos, radius);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_Circle::D1 (const Standard_Real U, Pnt& P, Vec& V1) const {
ElCLib::CircleD1 (U, pos, radius, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_Circle::D2 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2) const {
ElCLib::CircleD2 (U, pos, radius, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_Circle::D3 (
const Standard_Real U, Pnt& P, Vec& V1, Vec& V2, Vec& V3) const {
ElCLib::CircleD3 (U, pos, radius, P, V1, V2, V3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_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 Geom_Circle::Transform (const Trsf& T) {
radius = radius * Abs(T.ScaleFactor());
pos.Transform (T);
}

141
src/Geom/Geom_Conic.cdl Executable file
View File

@@ -0,0 +1,141 @@
-- File: Geom_Conic.cdl
-- Created: Wed Mar 10 09:30:27 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class Conic from Geom inherits Curve from Geom
---Purpose : The abstract class Conic describes the common
-- behavior of conic curves in 3D space and, in
-- particular, their general characteristics. The Geom
-- package provides four concrete classes of conics:
-- Geom_Circle, Geom_Ellipse, Geom_Hyperbola and Geom_Parabola.
-- A conic is positioned in space with a right-handed
-- coordinate system (gp_Ax2 object), where:
-- - the origin is the center of the conic (or the apex in
-- the case of a parabola),
-- - the origin, "X Direction" and "Y Direction" define the
-- plane of the conic.
-- This coordinate system is the local coordinate
-- system of the conic.
-- The "main Direction" of this coordinate system is the
-- vector normal to the plane of the conic. The axis, of
-- which the origin and unit vector are respectively the
-- origin and "main Direction" of the local coordinate
-- system, is termed the "Axis" or "main Axis" of the conic.
-- The "main Direction" of the local coordinate system
-- gives an explicit orientation to the conic, 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 Ax1 from gp,
Ax2 from gp,
Pnt from gp,
Vec from gp,
Shape from GeomAbs
raises ConstructionError from Standard,
RangeError from Standard,
DomainError from Standard
is
SetAxis (me : mutable; A1 : Ax1)
---Purpose : Changes the orientation of the conic's plane. The normal
-- axis to the plane is A1. The XAxis and the YAxis are recomputed.
raises ConstructionError;
---Purpose :
-- raised if the A1 is parallel to the XAxis of the conic.
SetLocation (me : mutable; P : Pnt);
---Purpose : changes the location point of the conic.
SetPosition (me : mutable; A2 : Ax2);
---Purpose : changes the local coordinate system of the conic.
Axis (me) returns Ax1;
---Purpose : Returns the "main Axis" of this conic. This axis is
-- normal to the plane of the conic.
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
-- Exceptions
-- Standard_DomainError in the case of a hyperbola if
-- its major radius is null.
raises DomainError
is deferred;
Location (me) returns Pnt;
---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 Apex of the parabola.
Position (me) returns Ax2;
---Purpose :
-- Returns the local coordinates system of the conic.
-- The main direction of the Axis2Placement is normal to the
-- plane of the conic. The X direction of the Axis2placement
-- is in the plane of the conic and corresponds to the origin
-- for the conic's parametric value u.
---C++: return const&
XAxis (me) returns Ax1;
---Purpose :
-- Returns the XAxis of the conic.
-- This axis defines the origin of parametrization of the conic.
-- This axis is perpendicular to the Axis of the conic.
-- This axis and the Yaxis define the plane of the conic.
YAxis (me) returns Ax1;
---Purpose :
-- Returns the YAxis of the conic.
-- The YAxis is perpendicular to the Xaxis.
-- This axis and the Xaxis define the plane of the conic.
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 : The continuity of the conic is Cn.
IsCN (me; N : Integer) returns Boolean
---Purpose : Returns True.
raises RangeError;
---Purpose : Raised if N < 0.
fields
pos : Ax2 is protected;
end;

46
src/Geom/Geom_Conic.cxx Executable file
View File

@@ -0,0 +1,46 @@
// File: Geom_Conic.cxx
// Created: Wed Mar 10 09:31:40 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Conic.cx, JCV 17/01/91
#include <Geom_Conic.ixx>
typedef Geom_Conic Conic;
typedef Handle(Geom_Conic) Handle(Conic);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Vec Vec;
void Geom_Conic::Reverse () {
gp_Dir Vz = pos.Direction ();
Vz.Reverse();
pos.SetDirection (Vz);
}
void Geom_Conic::SetAxis (const Ax1& A1) { pos.SetAxis (A1); }
void Geom_Conic::SetLocation (const Pnt& O) { pos.SetLocation (O); }
void Geom_Conic::SetPosition (const Ax2& A2) { pos = A2; }
Ax1 Geom_Conic::Axis () const { return pos.Axis(); }
GeomAbs_Shape Geom_Conic::Continuity () const { return GeomAbs_CN; }
Pnt Geom_Conic::Location () const { return pos.Location(); }
const gp_Ax2& Geom_Conic::Position () const { return pos; }
Ax1 Geom_Conic::XAxis () const {return Ax1(pos.Location(), pos.XDirection());}
Ax1 Geom_Conic::YAxis () const {return Ax1(pos.Location(), pos.YDirection());}
Standard_Boolean Geom_Conic::IsCN (const Standard_Integer ) const { return Standard_True; }

299
src/Geom/Geom_ConicalSurface.cdl Executable file
View File

@@ -0,0 +1,299 @@
-- File: Geom_ConicalSurface.cdl
-- Created: Wed Mar 10 09:32:23 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class ConicalSurface from Geom inherits ElementarySurface from Geom
---Purpose : Describes a cone.
-- A cone is defined by the half-angle at its apex, and
-- is positioned in space by a coordinate system (a
-- gp_Ax3 object) and a reference radius as follows:
-- - The "main Axis" of the coordinate system is the
-- axis of revolution of the cone.
-- - The plane defined by the origin, the "X Direction"
-- and the "Y Direction" of the coordinate system is
-- the reference plane of the cone. The intersection
-- of the cone with this reference plane is a circle of
-- radius equal to the reference radius.
-- - The apex of the cone is on the negative side of
-- the "main Axis" of the coordinate system if the
-- half-angle is positive, and on the positive side if
-- the half-angle is negative.
-- This coordinate system is the "local coordinate
-- system" of the cone. The following apply:
-- - Rotation around its "main Axis", in the
-- trigonometric sense given by the "X Direction"
-- and the "Y Direction", defines the u parametric direction.
-- - Its "X Axis" gives the origin for the u parameter.
-- - Its "main Direction" is the v parametric direction of the cone.
-- - Its origin is the origin of the v parameter.
-- The parametric range of the two parameters is:
-- - [ 0, 2.*Pi ] for u, and - ] -infinity, +infinity [ for v
-- The parametric equation of the cone is: P(u, v) =
-- O + (R + v*sin(Ang)) * (cos(u)*XDir + sin(u)*YDir) + v*cos(Ang)*ZDir where:
-- - O, XDir, YDir and ZDir are respectively
-- the origin, the "X Direction", the "Y Direction" and
-- the "Z Direction" of the cone's local coordinate system,
-- - Ang is the half-angle at the apex of the cone, and
-- - R is the reference radius.
uses Ax3 from gp,
Cone from gp,
Pnt from gp,
Trsf from gp,
GTrsf2d from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom
raises ConstructionError from Standard,
RangeError from Standard
is
Create (A3 : Ax3; Ang : Real; Radius : Real)
returns mutable ConicalSurface
---Purpose :
-- A3 defines the local coordinate system of the conical surface.
-- Ang is the conical surface semi-angle ]0, PI/2[.
-- Radius is the radius of the circle Viso in the placement plane
-- of the conical surface defined with "XAxis" and "YAxis".
-- The "ZDirection" of A3 defines the direction of the surface's
-- axis of symmetry.
-- If the location point of A3 is the apex of the surface
-- Radius = 0 .
-- At the creation the parametrization of the surface is defined
-- such that the normal Vector (N = D1U ^ D1V) is oriented towards
-- the "outside region" of the surface.
raises ConstructionError;
---Purpose :
-- Raised if Radius < 0.0 or Ang < Resolution from gp or
-- Ang >= PI/2 - Resolution
Create (C : Cone) returns mutable ConicalSurface;
---Purpose :
-- Creates a ConicalSurface from a non transient Cone from
-- package gp.
SetCone (me : mutable; C : Cone);
---Purpose :
-- Set <me> so that <me> has the same geometric properties as C.
SetRadius (me : mutable; R : Real)
---Purpose :
-- Changes the radius of the conical surface in the placement
-- plane (Z = 0, V = 0). The local coordinate system is not
-- modified.
raises ConstructionError;
---Purpose : Raised if R < 0.0
SetSemiAngle (me : mutable; Ang : Real)
---Purpose :
-- Changes the semi angle of the conical surface.
raises ConstructionError;
---Purpose :
-- Raised if Ang < Resolution or Ang >= PI/2 - Resolution
Cone (me) returns Cone;
---Purpose :
-- returns a non transient cone with the same geometric properties
-- as <me>.
UReversedParameter (me; U : Real ) returns Real;
---Purpose: return 2.PI - U.
VReversedParameter (me; V : Real ) returns Real;
---Purpose: Computes the u (or v) parameter on the modified
-- surface, when reversing its u (or v) parametric
-- direction, for any point of u parameter U (or of v
-- parameter V) on this cone.
-- In the case of a cone, these functions return respectively:
-- - 2.*Pi - U, -V.
VReverse (me : mutable)
---Purpose : Changes the orientation of this cone in the v
-- parametric direction. The bounds of the surface are
-- not changed but the v parametric direction is reversed.
-- As a consequence, for a cone:
-- - the "main Direction" of the local coordinate system
-- is reversed, and
-- - the half-angle at the apex is inverted.
is redefined;
TransformParameters(me; U,V : in out Real; T : Trsf from gp)
---Purpose: Computes the parameters on the transformed surface for
-- the transform of the point of parameters U,V on <me>.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are the new values of U,V after calling
--
-- me->TranformParameters(U,V,T)
--
-- This methods multiplies V by T.ScaleFactor()
is redefined;
ParametricTransformation(me; T : Trsf from gp) returns GTrsf2d from gp
---Purpose: Returns a 2d transformation used to find the new
-- parameters of a point on the transformed surface.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are obtained by transforming U,V with
-- th 2d transformation returned by
--
-- me->ParametricTransformation(T)
--
-- This methods returns a scale centered on the
-- U axis with T.ScaleFactor
is redefined;
Apex (me) returns Pnt;
---Purpose : Computes the apex of this cone. It is on the negative
-- side of the axis of revolution of this cone if the
-- half-angle at the apex is positive, and on the positive
-- side of the "main Axis" if the half-angle is negative.
Bounds (me; U1, U2, V1, V2 : out Real);
---Purpose :
-- The conical surface is infinite in the V direction so
-- V1 = Realfirst from Standard and V2 = RealLast.
-- U1 = 0 and U2 = 2*PI.
Coefficients (me; A1, A2, A3, B1, B2, B3, C1, C2, C3, D : out Real);
---Purpose :
-- Returns the coefficients of the implicit equation of the
-- quadric in the absolute cartesian coordinate system :
-- These coefficients are normalized.
-- A1.X**2 + A2.Y**2 + A3.Z**2 + 2.(B1.X.Y + B2.X.Z + B3.Y.Z) +
-- 2.(C1.X + C2.Y + C3.Z) + D = 0.0
RefRadius (me) returns Real;
---Purpose : Returns the reference radius of this cone.
-- The reference radius is the radius of the circle formed
-- by the intersection of this cone and its reference
-- plane (i.e. the plane defined by the origin, "X
-- Direction" and "Y Direction" of the local coordinate
-- system of this cone).
-- If the apex of this cone is on the origin of the local
-- coordinate system of this cone, the returned value is 0.
SemiAngle (me) returns Real;
---Purpose :
-- returns the semi-angle of the conical surface ]0.0, PI/2[.
IsUClosed (me) returns Boolean;
---Purpose : returns True.
IsVClosed (me) returns Boolean;
---Purpose : returns False.
IsUPeriodic (me) returns Boolean;
---Purpose : Returns True.
IsVPeriodic (me) returns Boolean;
---Purpose : Returns False.
UIso (me; U : Real) returns mutable Curve;
---Purpose : Builds the U isoparametric line of this cone. The
-- origin of this line is on the reference plane of this
-- cone (i.e. the plane defined by the origin, "X Direction"
-- and "Y Direction" of the local coordinate system of this cone).
VIso (me; V : Real) returns mutable Curve;
---Purpose : Builds the V isoparametric circle of this cone. It is the
-- circle on this cone, located in the plane of Z
-- coordinate V*cos(Semi-Angle) in the local coordinate system of this
-- cone. The "Axis" of this circle is the axis of revolution
-- of this cone. Its starting point is defined by the "X
-- Direction" of this cone.
-- Warning
-- If the V isoparametric circle is close to the apex of
-- this cone, the radius of the circle becomes very small.
-- It is possible to have a circle with radius equal to 0.0.
D0 (me; U, V : Real; P : out Pnt);
---Purpose :
-- Computes the point P (U, V) on the surface.
-- P (U, V) = Loc +
-- (RefRadius + V * sin (Semi-Angle)) * (cos (U) * XDir + sin (U) * YDir) +
-- V * cos (Semi-Angle) * ZDir
-- where Loc is the origin of the placement plane (XAxis, YAxis)
-- XDir is the direction of the XAxis and YDir the direction of
-- the YAxis.
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec);
---Purpose :
-- Computes the current point and the first derivatives in the
-- directions U and V.
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec);
---Purpose :
-- Computes the current point, the first and the second derivatives
-- in the directions U and V.
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV :out Vec);
---Purpose :
-- Computes the current point, the first,the second and the third
-- derivatives in the directions U and V.
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
---Purpose: Computes the derivative of order Nu in the u
-- parametric direction, and Nv in the v parametric
-- direction at the point of parameters (U, V) of this cone.
-- Exceptions
-- Standard_RangeError if:
-- - Nu + Nv is less than 1,
-- - Nu or Nv is negative.
raises RangeError;
Transform (me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this cone.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this cone.
fields
radius : Real;
semiAngle : Real;
end;

422
src/Geom/Geom_ConicalSurface.cxx Executable file
View File

@@ -0,0 +1,422 @@
// File: Geom_ConicalSurface.cxx
// Created: Wed Mar 10 09:33:39 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_ConicalSurface.cxx, JCV 17/01/91
#include <Geom_ConicalSurface.ixx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
#include <Precision.hxx>
#include <gp.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_Ax2d.hxx>
#include <gp_XYZ.hxx>
#include <gp_Dir.hxx>
#include <ElSLib.hxx>
#include <GeomAbs_UVSense.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
typedef Geom_ConicalSurface ConicalSurface;
typedef Handle(Geom_ConicalSurface) Handle(ConicalSurface);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Ax3 Ax3;
typedef gp_Circ Circ;
typedef gp_Dir Dir;
typedef gp_Lin Lin;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
typedef gp_XYZ XYZ;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_ConicalSurface::Copy () const {
Handle(ConicalSurface) Cs;
Cs = new ConicalSurface (pos, semiAngle, radius);
return Cs;
}
//=======================================================================
//function : Geom_ConicalSurface
//purpose :
//=======================================================================
Geom_ConicalSurface::Geom_ConicalSurface ( const Ax3& A3 ,
const Standard_Real Ang,
const Standard_Real R) :
radius(R), semiAngle (Ang)
{
if (R < 0.0 || Abs(Ang) <= gp::Resolution() || Abs(Ang) >= PI/2.0 - gp::Resolution())
Standard_ConstructionError::Raise();
pos = A3;
}
//=======================================================================
//function : Geom_ConicalSurface
//purpose :
//=======================================================================
Geom_ConicalSurface::Geom_ConicalSurface ( const gp_Cone& C )
: radius (C.RefRadius()), semiAngle (C.SemiAngle())
{
pos = C.Position();
}
//=======================================================================
//function : UReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_ConicalSurface::UReversedParameter( const Standard_Real U) const
{
return ( 2.*PI - U);
}
//=======================================================================
//function : VReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_ConicalSurface::VReversedParameter( const Standard_Real V) const
{
return ( -V);
}
//=======================================================================
//function : VReverse
//purpose :
//=======================================================================
void Geom_ConicalSurface::VReverse()
{
semiAngle = -semiAngle;
pos.ZReverse();
}
//=======================================================================
//function : RefRadius
//purpose :
//=======================================================================
Standard_Real Geom_ConicalSurface::RefRadius () const
{ return radius; }
//=======================================================================
//function : SemiAngle
//purpose :
//=======================================================================
Standard_Real Geom_ConicalSurface::SemiAngle () const
{ return semiAngle;}
//=======================================================================
//function : IsUClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_ConicalSurface::IsUClosed () const
{ return Standard_True; }
//=======================================================================
//function : IsVClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_ConicalSurface::IsVClosed () const
{ return Standard_False; }
//=======================================================================
//function : IsUPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_ConicalSurface::IsUPeriodic () const
{ return Standard_True; }
//=======================================================================
//function : IsVPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_ConicalSurface::IsVPeriodic () const
{ return Standard_False; }
//=======================================================================
//function : Cone
//purpose :
//=======================================================================
gp_Cone Geom_ConicalSurface::Cone () const {
return gp_Cone (pos, semiAngle, radius);
}
//=======================================================================
//function : SetCone
//purpose :
//=======================================================================
void Geom_ConicalSurface::SetCone (const gp_Cone& C) {
radius = C.RefRadius ();
semiAngle = C.SemiAngle ();
pos = C.Position ();
}
//=======================================================================
//function : SetRadius
//purpose :
//=======================================================================
void Geom_ConicalSurface::SetRadius (const Standard_Real R) {
if (R < 0.0) Standard_ConstructionError::Raise();
radius = R;
}
//=======================================================================
//function : SetSemiAngle
//purpose :
//=======================================================================
void Geom_ConicalSurface::SetSemiAngle (const Standard_Real Ang) {
if (Abs(Ang) <= gp::Resolution() || Abs(Ang) >= PI/2.0 - gp::Resolution()) {
Standard_ConstructionError::Raise();
}
semiAngle = Ang;
}
//=======================================================================
//function : Apex
//purpose :
//=======================================================================
Pnt Geom_ConicalSurface::Apex () const
{
XYZ Coord = Position().Direction().XYZ();
Coord.Multiply (-radius / Tan (semiAngle));
Coord.Add (Position().Location().XYZ());
return Pnt (Coord);
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void Geom_ConicalSurface::Bounds (Standard_Real& U1, Standard_Real& U2,
Standard_Real& V1, Standard_Real& V2) const {
U1 = 0.0; U2 = 2.0 * PI;
V1 = -Precision::Infinite(); V2 = Precision::Infinite();
}
//=======================================================================
//function : Coefficients
//purpose :
//=======================================================================
void Geom_ConicalSurface::Coefficients (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3,
Standard_Real& B1, Standard_Real& B2, Standard_Real& B3,
Standard_Real& C1, Standard_Real& C2, Standard_Real& C3,
Standard_Real& D) const
{
// Dans le repere du cone :
// X**2 + Y**2 - (Myradius - Z * Tan(semiAngle))**2 = 0.0
Trsf T;
T.SetTransformation (pos);
Standard_Real KAng = Tan (semiAngle);
Standard_Real T11 = T.Value (1, 1);
Standard_Real T12 = T.Value (1, 2);
Standard_Real T13 = T.Value (1, 3);
Standard_Real T14 = T.Value (1, 4);
Standard_Real T21 = T.Value (2, 1);
Standard_Real T22 = T.Value (2, 2);
Standard_Real T23 = T.Value (2, 3);
Standard_Real T24 = T.Value (2, 4);
Standard_Real T31 = T.Value (3, 1) * KAng;
Standard_Real T32 = T.Value (3, 2) * KAng;
Standard_Real T33 = T.Value (3, 3) * KAng;
Standard_Real T34 = T.Value (3, 4) * KAng;
A1 = T11 * T11 + T21 * T21 - T31 * T31;
A2 = T12 * T12 + T22 * T22 - T32 * T32;
A3 = T13 * T13 + T23 * T23 - T33 * T33;
B1 = T11 * T12 + T21 * T22 - T31 * T32;
B2 = T11 * T13 + T21 * T23 - T31 * T33;
B3 = T12 * T13 + T22 * T23 - T32 * T33;
C1 = T11 * T14 + T21 * T24 + radius * T31;
C2 = T12 * T14 + T22 * T24 + radius * T32;
C3 = T13 * T14 + T23 * T24 + radius * T33;
D = T14 * T14 + T24 * T24 - radius * radius - T34 * T34 +
2.0 * radius * T34;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_ConicalSurface::D0 (const Standard_Real U, const Standard_Real V, Pnt& P) const
{
P = ElSLib::ConeValue (U, V, pos, radius, semiAngle);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_ConicalSurface::D1 (const Standard_Real U , const Standard_Real V,
Pnt& P ,
Vec& D1U, Vec& D1V ) const
{
ElSLib::ConeD1 (U, V, pos, radius, semiAngle, P, D1U, D1V);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_ConicalSurface::D2 ( const Standard_Real U , const Standard_Real V,
Pnt& P ,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV) const
{
ElSLib::ConeD2 (U, V, pos, radius, semiAngle, P, D1U, D1V,
D2U, D2V, D2UV);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_ConicalSurface::D3 (const Standard_Real U, const Standard_Real V,
Pnt& P ,
Vec& D1U , Vec& D1V,
Vec& D2U , Vec& D2V, Vec& D2UV,
Vec& D3U , Vec& D3V, Vec& D3UUV, Vec& D3UVV
) const
{
ElSLib::ConeD3 (U, V, pos, radius, semiAngle, P, D1U, D1V, D2U, D2V,
D2UV, D3U, D3V, D3UUV, D3UVV);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_ConicalSurface::DN (const Standard_Real U , const Standard_Real V,
const Standard_Integer Nu, const Standard_Integer Nv ) const
{
Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv < 0, " ");
if (Nv > 1) { return Vec (0.0, 0.0, 0.0); }
else {
return ElSLib::ConeDN (U, V, pos, radius, semiAngle, Nu, Nv);
}
}
//=======================================================================
//function : UIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_ConicalSurface::UIso (const Standard_Real U) const
{
Handle(Geom_Line)
GL = new Geom_Line(ElSLib::ConeUIso(pos,radius,semiAngle,U));
return GL;
}
//=======================================================================
//function : VIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_ConicalSurface::VIso (const Standard_Real V) const
{
Handle(Geom_Circle)
GC = new Geom_Circle(ElSLib::ConeVIso(pos,radius,semiAngle,V));
return GC;
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_ConicalSurface::Transform (const Trsf& T)
{
radius = radius * Abs(T.ScaleFactor());
pos.Transform (T);
}
//=======================================================================
//function : TransformParameters
//purpose :
//=======================================================================
void Geom_ConicalSurface::TransformParameters(Standard_Real& ,
Standard_Real& V,
const gp_Trsf& T)
const
{
if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
gp_GTrsf2d Geom_ConicalSurface::ParametricTransformation(const gp_Trsf& T)
const
{
gp_GTrsf2d T2;
gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
T2.SetAffinity(Axis, Abs(T.ScaleFactor()));
return T2;
}

258
src/Geom/Geom_Curve.cdl Executable file
View File

@@ -0,0 +1,258 @@
-- File: Geom_Curve.cdl
-- Created: Wed Mar 10 09:35:43 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class Curve from Geom inherits Geometry from Geom
---Purpose : The abstract class Curve describes the common
-- behavior of curves in 3D space. The Geom 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 Geom_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 states so explicitly.
-- Warning
-- The Geom package does not prevent the
-- construction of curves with null length or curves which
-- self-intersect.
uses Pnt from gp,
Vec from gp,
Trsf from gp,
Shape from GeomAbs
raises RangeError from Standard,
NoSuchObject from Standard,
UndefinedDerivative from Geom,
UndefinedValue from Geom
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: Returns the parameter on the reversed curve for
-- the point of parameter U on <me>.
--
-- me->Reversed()->Value(me->ReversedParameter(U))
--
-- is the same point as
--
-- me->Value(U)
is deferred;
TransformedParameter(me; U : Real; T : Trsf 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 returns <U>
--
-- It can be redefined. For example on the Line.
is virtual;
ParametricTransformation(me; T : Trsf 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 1.
--
-- It can be redefined. For example on the Line.
is virtual;
Reversed (me) returns mutable like me
---Purpose : Returns a copy of <me> reversed.
is static;
FirstParameter (me) returns Real
---Purpose : Returns the value of the first parameter.
-- Warnings :
-- It can be RealFirst from package Standard
-- if the curve is infinite
is deferred;
LastParameter (me) returns Real
---Purpose : Returns the value of the last parameter.
-- Warnings :
-- It can be RealLast from package Standard
-- if the curve is infinite
is deferred;
IsClosed (me) returns Boolean
---Purpose : Returns true if the curve is closed.
-- 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 : Is the parametrization of the curve 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 the period of this curve.
-- Exceptions Standard_NoSuchObject if this curve is not periodic.
raises
NoSuchObject from Standard
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 Pnt)
---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 Pnt; V1 : out Vec)
---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 Pnt; V1, V2 : out Vec)
---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 Pnt; V1, V2, V3 : out Vec)
---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 Vec
---Purpose :
-- The returned vector gives the value of the derivative for the
-- order of derivation N.
raises UndefinedDerivative,
---Purpose : Raised if the continuity of the curve is not CN.
--
---Purpose : Raised if the derivative cannot be computed
-- easily. e.g. rational bspline and n > 3.
RangeError
---Purpose : Raised if N < 1.
is deferred;
Value (me; U : Real) returns Pnt
---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/Geom/Geom_Curve.cxx Executable file
View File

@@ -0,0 +1,75 @@
// File: Geom_Curve.cxx
// Created: Wed Mar 10 09:36:27 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Curve.cxx, JCV 17/01/91
#include <Geom_Curve.ixx>
typedef Geom_Curve Curve;
typedef Handle(Geom_Curve) Handle(Curve);
//=======================================================================
//function : Reversed
//purpose :
//=======================================================================
Handle(Curve) Geom_Curve::Reversed () const
{
Handle(Curve) C = Handle(Curve)::DownCast(Copy());
C->Reverse();
return C;
}
//=======================================================================
//function : Period
//purpose :
//=======================================================================
Standard_Real Geom_Curve::Period() const
{
Standard_NoSuchObject_Raise_if
( !IsPeriodic(),"Geom_Curve::Period");
return ( LastParameter() - FirstParameter());
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
gp_Pnt Geom_Curve::Value( const Standard_Real U) const
{
gp_Pnt P;
D0( U, P);
return P;
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Curve::TransformedParameter(const Standard_Real U,
const gp_Trsf&) const
{
return U;
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Curve::ParametricTransformation(const gp_Trsf& ) const
{
return 1.;
}

View File

@@ -0,0 +1,222 @@
-- File: Geom_CylindricalSurface.cdl
-- Created: Wed Mar 10 09:36:50 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class CylindricalSurface from Geom inherits ElementarySurface from Geom
---Purpose : This class defines the infinite cylindrical surface.
--
-- The local coordinate system of the CylindricalSurface is defined
-- with an axis placement (see class ElementarySurface).
--
-- The "ZAxis" is the symmetry axis of the CylindricalSurface,
-- it gives the direction of increasing parametric value V.
--
-- The parametrization range is :
-- U [0, 2*PI], V ]- infinite, + infinite[
--
-- The "XAxis" and the "YAxis" define the placement plane of the
-- surface (Z = 0, and parametric value V = 0) perpendicular to
-- the symmetry axis. The "XAxis" defines the origin of the
-- parameter U = 0. The trigonometric sense gives the positive
-- orientation for the parameter U.
--
-- When you create a CylindricalSurface the U and V directions of
-- parametrization are such that at each point of the surface the
-- normal is oriented towards the "outside region".
--
-- The methods UReverse VReverse change the orientation of the
-- surface.
uses Ax3 from gp,
Cylinder from gp,
Pnt from gp,
Trsf from gp,
GTrsf2d from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom
raises ConstructionError from Standard,
RangeError from Standard
is
Create (A3 : Ax3; Radius : Real) returns mutable CylindricalSurface
---Purpose :
-- A3 defines the local coordinate system of the cylindrical surface.
-- The "ZDirection" of A3 defines the direction of the surface's
-- axis of symmetry.
-- At the creation the parametrization of the surface is defined
-- such that the normal Vector (N = D1U ^ D1V) is oriented towards
-- the "outside region" of the surface.
--- Warnings :
-- It is not forbidden to create a cylindrical surface with
-- Radius = 0.0
raises ConstructionError;
---Purpose : Raised if Radius < 0.0
Create (C : Cylinder) returns mutable CylindricalSurface;
---Purpose :
-- Creates a CylindricalSurface from a non transient Cylinder
-- from package gp.
SetCylinder (me : mutable; C : Cylinder);
---Purpose :
-- Set <me> so that <me> has the same geometric properties as C.
SetRadius (me : mutable; R : Real)
---Purpose : Changes the radius of the cylinder.
raises ConstructionError;
---Purpose : Raised if R < 0.0
Cylinder (me) returns Cylinder;
---Purpose :
-- returns a non transient cylinder with the same geometric
-- properties as <me>.
UReversedParameter (me; U : Real) returns Real;
---Purpose: Return the parameter on the Ureversed surface for
-- the point of parameter U on <me>.
-- Return 2.PI - U.
VReversedParameter (me; V : Real) returns Real;
---Purpose: Return the parameter on the Vreversed surface for
-- the point of parameter V on <me>.
-- Return -V
TransformParameters(me; U,V : in out Real; T : Trsf from gp)
---Purpose: Computes the parameters on the transformed surface for
-- the transform of the point of parameters U,V on <me>.
-- me->Transformed(T)->Value(U',V')
-- is the same point as
-- me->Value(U,V).Transformed(T)
-- Where U',V' are the new values of U,V after calling
-- me->TranformParameters(U,V,T)
-- This methods multiplies V by T.ScaleFactor()
is redefined;
ParametricTransformation(me; T : Trsf from gp) returns GTrsf2d from gp
---Purpose: Returns a 2d transformation used to find the new
-- parameters of a point on the transformed surface.
-- me->Transformed(T)->Value(U',V')
-- is the same point as
-- me->Value(U,V).Transformed(T)
-- Where U',V' are obtained by transforming U,V with
-- th 2d transformation returned by
-- me->ParametricTransformation(T)
-- This methods returns a scale centered on the
-- U axis with T.ScaleFactor
is redefined;
Bounds (me; U1, U2, V1, V2 : out Real);
---Purpose :
-- The CylindricalSurface is infinite in the V direction so
-- V1 = Realfirst, V2 = RealLast from package Standard.
-- U1 = 0 and U2 = 2*PI.
Coefficients (me; A1, A2, A3, B1, B2, B3, C1, C2, C3, D : out Real);
---Purpose :
-- Returns the coefficients of the implicit equation of the quadric
-- in the absolute cartesian coordinate system :
-- These coefficients are normalized.
-- A1.X**2 + A2.Y**2 + A3.Z**2 + 2.(B1.X.Y + B2.X.Z + B3.Y.Z) +
-- 2.(C1.X + C2.Y + C3.Z) + D = 0.0
Radius (me) returns Real;
---Purpose: Returns the radius of this cylinder.
IsUClosed (me) returns Boolean;
---Purpose : Returns True.
IsVClosed (me) returns Boolean;
---Purpose : Returns False.
IsUPeriodic (me) returns Boolean;
---Purpose : Returns True.
IsVPeriodic (me) returns Boolean;
---Purpose : Returns False.
UIso (me; U : Real) returns mutable Curve;
---Purpose :
-- The UIso curve is a Line. The location point of this line is
-- on the placement plane (XAxis, YAxis) of the surface.
-- This line is parallel to the axis of symmetry of the surface.
VIso (me; V : Real) returns mutable Curve;
---Purpose :
-- The VIso curve is a circle. The start point of this circle
-- (U = 0) is defined with the "XAxis" of the surface.
-- The center of the circle is on the symmetry axis.
D0 (me; U, V : Real; P : out Pnt);
---Purpose :
-- Computes the point P (U, V) on the surface.
-- P (U, V) = Loc + Radius * (cos (U) * XDir + sin (U) * YDir) +
-- V * ZDir
-- where Loc is the origin of the placement plane (XAxis, YAxis)
-- XDir is the direction of the XAxis and YDir the direction of
-- the YAxis.
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec);
---Purpose :
-- Computes the current point and the first derivatives in the
-- directions U and V.
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec);
---Purpose :
-- Computes the current point, the first and the second derivatives
-- in the directions U and V.
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV : out Vec);
---Purpose :
-- Computes the current point, the first, the second and the
-- third derivatives in the directions U and V.
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
---Purpose :
-- Computes the derivative of order Nu in the direction u and Nv
-- in the direction v.
raises RangeError;
---Purpose : Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
Transform (me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this cylinder.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this cylinder.
fields
radius : Real;
end;

View File

@@ -0,0 +1,370 @@
// File: Geom_CylindricalSurface.cxx
// Created: Wed Mar 10 09:38:21 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_CylindricalSurface.cxx, JCV 17/01/91
#include <Geom_CylindricalSurface.ixx>
#include <Precision.hxx>
#include <GeomAbs_UVSense.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_XYZ.hxx>
#include <gp_Ax2d.hxx>
#include <gp.hxx>
#include <ElSLib.hxx>
typedef Geom_CylindricalSurface CylindricalSurface;
typedef Handle(Geom_CylindricalSurface) Handle(CylindricalSurface);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Ax3 Ax3;
typedef gp_Circ Circ;
typedef gp_Dir Dir;
typedef gp_Lin Lin;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
typedef gp_XYZ XYZ;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_CylindricalSurface::Copy () const {
Handle(CylindricalSurface) Cs;
Cs = new CylindricalSurface (pos, radius);
return Cs;
}
//=======================================================================
//function : Geom_CylindricalSurface
//purpose :
//=======================================================================
Geom_CylindricalSurface::Geom_CylindricalSurface (const gp_Cylinder& C)
: radius (C.Radius()) {
pos = C.Position ();
}
//=======================================================================
//function : Geom_CylindricalSurface
//purpose :
//=======================================================================
Geom_CylindricalSurface::Geom_CylindricalSurface ( const Ax3& A3,
const Standard_Real R)
: radius (R) {
if (R < 0.0) Standard_ConstructionError::Raise();
pos = A3;
}
//=======================================================================
//function : UReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_CylindricalSurface::UReversedParameter( const Standard_Real U) const
{
return (2.*PI - U);
}
//=======================================================================
//function : VReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_CylindricalSurface::VReversedParameter( const Standard_Real V) const
{
return (-V);
}
//=======================================================================
//function : Radius
//purpose :
//=======================================================================
Standard_Real Geom_CylindricalSurface::Radius () const { return radius; }
//=======================================================================
//function : IsUClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_CylindricalSurface::IsUClosed () const { return Standard_True; }
//=======================================================================
//function : IsVClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_CylindricalSurface::IsVClosed () const { return Standard_False; }
//=======================================================================
//function : IsUPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_CylindricalSurface::IsUPeriodic () const { return Standard_True; }
//=======================================================================
//function : IsVPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_CylindricalSurface::IsVPeriodic () const { return Standard_False; }
//=======================================================================
//function : SetCylinder
//purpose :
//=======================================================================
void Geom_CylindricalSurface::SetCylinder (const gp_Cylinder& C) {
radius = C.Radius();
pos = C.Position();
}
//=======================================================================
//function : SetRadius
//purpose :
//=======================================================================
void Geom_CylindricalSurface::SetRadius (const Standard_Real R) {
if (R < 0.0) { Standard_ConstructionError::Raise(); }
radius = R;
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void Geom_CylindricalSurface::Bounds (Standard_Real& U1, Standard_Real& U2,
Standard_Real& V1, Standard_Real& V2) const {
U1 = 0.0; U2 = 2.0 * PI;
V1 = - Precision::Infinite(); V2 = Precision::Infinite();
}
//=======================================================================
//function : Coefficients
//purpose :
//=======================================================================
void Geom_CylindricalSurface::Coefficients (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3,
Standard_Real& B1, Standard_Real& B2, Standard_Real& B3,
Standard_Real& C1, Standard_Real& C2, Standard_Real& C3,
Standard_Real& D) const {
// Dans le repere local du cylindre :
// X**2 + Y**2 - radius = 0.0
Trsf T;
T.SetTransformation (pos);
Standard_Real T11 = T.Value (1, 1);
Standard_Real T12 = T.Value (1, 2);
Standard_Real T13 = T.Value (1, 3);
Standard_Real T14 = T.Value (1, 4);
Standard_Real T21 = T.Value (2, 1);
Standard_Real T22 = T.Value (2, 2);
Standard_Real T23 = T.Value (2, 3);
Standard_Real T24 = T.Value (2, 4);
#ifdef DEB
Standard_Real T31 = T.Value (3, 1);
Standard_Real T32 = T.Value (3, 2);
Standard_Real T33 = T.Value (3, 3);
Standard_Real T34 = T.Value (3, 4);
#else
T.Value (3, 1);
T.Value (3, 2);
T.Value (3, 3);
T.Value (3, 4);
#endif
A1 = T11 * T11 + T21 * T21;
A2 = T12 * T12 + T22 * T22;
A3 = T13 * T13 + T23 * T23;
B1 = T11 * T12 + T21 * T22;
B2 = T11 * T13 + T21 * T23;
B3 = T12 * T13 + T22 * T23;
C1 = T11 * T14 + T21 * T24;
C2 = T12 * T14 + T22 * T24;
C3 = T13 * T14 + T23 * T24;
D = T14 * T14 + T24 * T24 - radius * radius;
}
//=======================================================================
//function : Cylinder
//purpose :
//=======================================================================
gp_Cylinder Geom_CylindricalSurface::Cylinder () const {
return gp_Cylinder (pos, radius);
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_CylindricalSurface::D0 (const Standard_Real U,
const Standard_Real V,
Pnt& P ) const
{
ElSLib::CylinderD0 (U, V, pos, radius, P);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_CylindricalSurface::D1 (const Standard_Real U, const Standard_Real V ,
Pnt& P,
Vec& D1U, Vec& D1V) const
{
ElSLib::CylinderD1 (U, V, pos, radius, P, D1U, D1V);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_CylindricalSurface::D2 (const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV) const
{
ElSLib::CylinderD2 (U, V, pos, radius, P, D1U, D1V, D2U, D2V, D2UV);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_CylindricalSurface::D3 (const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV,
Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV)
const
{
ElSLib::CylinderD3 (U, V, pos, radius, P, D1U, D1V, D2U, D2V,
D2UV, D3U, D3V, D3UUV, D3UVV);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_CylindricalSurface::DN (const Standard_Real U , const Standard_Real V ,
const Standard_Integer Nu, const Standard_Integer Nv ) const
{
Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
if (Nv > 1) { return Vec (0.0, 0.0, 0.0); }
else {
return ElSLib::CylinderDN (U, V, pos, radius, Nu, Nv);
}
}
//=======================================================================
//function : UIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_CylindricalSurface::UIso (const Standard_Real U) const
{
Handle(Geom_Line) GL = new Geom_Line(ElSLib::CylinderUIso(pos,radius,U));
return GL;
}
//=======================================================================
//function : VIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_CylindricalSurface::VIso (const Standard_Real V) const
{
Handle(Geom_Circle) GC = new Geom_Circle(ElSLib::CylinderVIso(pos,radius,V));
return GC;
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_CylindricalSurface::Transform (const Trsf& T) {
radius = radius * Abs(T.ScaleFactor());
pos.Transform (T);
}
//=======================================================================
//function : TransformParameters
//purpose :
//=======================================================================
void Geom_CylindricalSurface::TransformParameters(Standard_Real& ,
Standard_Real& V,
const gp_Trsf& T)
const
{
if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
gp_GTrsf2d Geom_CylindricalSurface::ParametricTransformation(const gp_Trsf& T)
const
{
gp_GTrsf2d T2;
gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
T2.SetAffinity(Axis, Abs(T.ScaleFactor()));
return T2;
}

127
src/Geom/Geom_Direction.cdl Executable file
View File

@@ -0,0 +1,127 @@
-- File: Geom_Direction.cdl
-- Created: Wed Mar 10 09:40:08 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Direction from Geom inherits Vector from Geom
---Purpose :
-- The class Direction specifies a vector that is never null.
-- It is a unit vector.
uses Dir from gp,
Pnt from gp,
Trsf from gp,
Vec from gp,
Geometry from Geom
raises ConstructionError from Standard
is
Create (X, Y, Z :Real) returns mutable Direction
---Purpose : Creates a unit vector with it 3 cartesian coordinates.
raises ConstructionError;
---Purpose :
-- Raised if Sqrt( X*X + Y*Y + Z*Z) <= Resolution from gp.
Create (V : Dir) returns mutable Direction;
---Purpose : Creates a transient copy of <me>.
SetCoord (me : mutable; X, Y, Z : Real)
---Purpose : Sets <me> to X,Y,Z coordinates.
raises ConstructionError;
---Purpose :
-- Raised if Sqrt( X*X + Y*Y + Z*Z) <= Resolution from gp.
SetDir (me : mutable; V : Dir);
---Purpose : Converts the gp_Dir unit vector V into this unit vector.
SetX (me : mutable; X : Real)
---Purpose : Changes the X coordinate of <me>.
raises ConstructionError;
---Purpose :
-- Raised if Sqrt( X*X + Y*Y + Z*Z) <= Resolution from gp.
SetY (me : mutable; Y : Real)
---Purpose : Changes the Y coordinate of <me>.
raises ConstructionError;
---Purpose :
-- Raised if Sqrt( X*X + Y*Y + Z*Z) <= Resolution from gp.
SetZ (me : mutable; Z : Real)
---Purpose : Changes the Z coordinate of <me>.
raises ConstructionError;
---Purpose :
-- Raised if Sqrt( X*X + Y*Y + Z*Z) <= Resolution from gp.
Dir (me) returns Dir;
---Purpose :
-- Returns the non transient direction with the same
-- coordinates as <me>.
Magnitude (me) returns Real;
---Purpose : returns 1.0 which is the magnitude of any unit vector.
SquareMagnitude (me) returns Real;
---Purpose : returns 1.0 which is the square magnitude of any unit vector.
Cross (me : mutable; Other : Vector)
---Purpose :
-- Computes the cross product between <me> and <Other>.
raises ConstructionError;
---Purpose :
-- Raised if the two vectors are parallel because it is
-- not possible to have a direction with null length.
CrossCross (me : mutable; V1, V2 : Vector)
---Purpose :
-- Computes the triple vector product <me> ^(V1 ^ V2).
raises ConstructionError;
---Purpose :
-- Raised if V1 and V2 are parallel or <me> and (V1 ^ V2) are
-- parallel
Crossed (me; Other : Vector) returns mutable like me
---Purpose :
-- Computes the cross product between <me> and <Other>.
-- A new direction is returned.
raises ConstructionError
---Purpose :
-- Raised if the two vectors are parallel because it is
-- not possible to have a direction with null length.
is static;
CrossCrossed (me; V1, V2 : Vector) returns mutable like me
---Purpose :
-- Computes the triple vector product <me> ^(V1 ^ V2).
raises ConstructionError
---Purpose :
-- Raised if V1 and V2 are parallel or <me> and (V1 ^ V2) are
-- parallel
is static;
Transform (me : mutable; T : Trsf);
---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;

126
src/Geom/Geom_Direction.cxx Executable file
View File

@@ -0,0 +1,126 @@
// File: Geom_Direction.cxx
// Created: Wed Mar 10 09:40:32 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Direction.cxx, JCV 16/01/91
#include <Geom_Direction.ixx>
#include <gp.hxx>
#include <Standard_ConstructionError.hxx>
typedef Geom_Direction Direction;
typedef Handle(Geom_Direction) Handle(Direction);
typedef Geom_Vector Vector;
typedef Handle(Geom_Vector) Handle(Vector);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_Direction::Copy() const {
Handle(Direction) D;
D = new Direction (gpVec);
return D;
}
//=======================================================================
//function : Geom_Direction
//purpose :
//=======================================================================
Geom_Direction::Geom_Direction (const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
Standard_Real D = sqrt (X * X + Y * Y + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
gpVec = gp_Vec (X/D, Y/D, Z/D);
}
Geom_Direction::Geom_Direction (const gp_Dir& V) { gpVec = V; }
void Geom_Direction::SetDir (const gp_Dir& V) { gpVec = V; }
gp_Dir Geom_Direction::Dir () const { return gpVec; }
Standard_Real Geom_Direction::Magnitude () const { return 1.0; }
Standard_Real Geom_Direction::SquareMagnitude () const { return 1.0; }
void Geom_Direction::SetCoord (const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
Standard_Real D = Sqrt (X * X + Y * Y + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
gpVec = gp_Vec(X/D, Y/D, Z/D);
}
void Geom_Direction::SetX (const Standard_Real X) {
Standard_Real D = Sqrt (X * X + gpVec.Y() * gpVec.Y() + gpVec.Z() * gpVec.Z());
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
gpVec = gp_Vec (X/D, gpVec.Y()/D, gpVec.Z()/D);
}
void Geom_Direction::SetY (const Standard_Real Y) {
Standard_Real D = Sqrt (gpVec.X() * gpVec.X() + Y * Y + gpVec.Z() * gpVec.Z());
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
gpVec = gp_Vec (gpVec.X()/D, Y/D, gpVec.Z()/D);
}
void Geom_Direction::SetZ (const Standard_Real Z) {
Standard_Real D = Sqrt (gpVec.X() * gpVec.X() + gpVec.Y() * gpVec.Y() + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
gpVec = gp_Vec (gpVec.X()/D, gpVec.Y()/D, Z/D);
}
void Geom_Direction::Cross (const Handle(Vector)& Other) {
gp_Dir V (gpVec.Crossed(Other->Vec()));
gpVec = V;
}
void Geom_Direction::CrossCross (
const Handle(Vector)& V1, const Handle(Vector)& V2) {
gp_Dir V (gpVec.CrossCrossed (V1->Vec(), V2->Vec()));
gpVec = V;
}
Handle(Vector) Geom_Direction::Crossed (const Handle(Vector)& Other)
const {
gp_Dir V (gpVec.Crossed (Other->Vec()));
return new Direction (V);
}
Handle(Vector) Geom_Direction::CrossCrossed (
const Handle(Vector)& V1, const Handle(Vector)& V2) const {
gp_Dir V (gpVec.CrossCrossed (V1->Vec(), V2->Vec()));
return new Direction (V);
}
void Geom_Direction::Transform (const gp_Trsf& T) {
gp_Dir V (gpVec);
V.Transform (T);
gpVec = V;
}

View File

@@ -0,0 +1,143 @@
-- File: Geom_ElementarySurface.cdl
-- Created: Wed Mar 10 09:41:01 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class ElementarySurface from Geom inherits Surface from Geom
---Purpose : Describes the common behavior of surfaces which
-- have a simple parametric equation in a local
-- coordinate system. The Geom package provides
-- several implementations of concrete elementary surfaces:
-- - the plane, and
-- - four simple surfaces of revolution: the cylinder, the
-- cone, the sphere and the torus.
-- An elementary surface inherits the common behavior
-- of Geom_Surface surfaces. Furthermore, it is located
-- in 3D space by a coordinate system (a gp_Ax3
-- object) which is also its local coordinate system.
-- Any elementary surface is oriented, i.e. the normal
-- vector is always defined, and gives the same
-- orientation to the surface, at any point on the surface.
-- In topology this property is referred to as the "outside
-- region of the surface". This orientation is related to
-- the two parametric directions of the surface.
-- Rotation of a surface around the "main Axis" of its
-- coordinate system, in the trigonometric sense given
-- by the "X Direction" and the "Y Direction" of the
-- coordinate system, defines the u parametric direction
-- of that elementary surface of revolution. This is the
-- default construction mode.
-- It is also possible, however, to change the orientation
-- of a surface by reversing one of the two parametric
-- directions: use the UReverse or VReverse functions
-- to change the orientation of the normal at any point on the surface.
-- Warning
-- The local coordinate system of an elementary surface
-- is not necessarily direct:
-- - if it is direct, the trigonometric sense defined by its
-- "main Direction" is the same as the trigonometric
-- sense defined by its two vectors "X Direction" and "Y Direction":
-- "main Direction" = "X Direction" ^ "Y Direction"
-- - if it is indirect, the two definitions of trigonometric
-- sense are opposite:
-- "main Direction" = - "X Direction" ^ "Y Direction"
uses Ax1 from gp,
Ax2 from gp,
Ax3 from gp,
Pnt from gp,
Vec from gp,
Shape from GeomAbs
raises ConstructionError from Standard
is
SetAxis (me : mutable; A1 : Ax1)
---Purpose :
-- Changes the main axis (ZAxis) of the elementary surface.
raises ConstructionError;
---Purpose :
-- Raised if the direction of A1 is parallel to the XAxis of the
-- coordinate system of the surface.
SetLocation (me : mutable; Loc : Pnt);
---Purpose :
-- Changes the location of the local coordinates system of the
-- surface.
SetPosition (me : mutable; A3 : Ax3);
---Purpose :
-- Changes the local coordinates system of the surface.
Axis (me) returns Ax1;
---Purpose :
-- Returns the main axis of the surface (ZAxis).
Location (me) returns Pnt;
---Purpose :
-- Returns the location point of the local coordinate system of the
-- surface.
Position (me) returns Ax3;
---Purpose : Returns the local coordinates system of the surface.
---C++: return const&
UReverse (me : mutable)
---Purpose :
-- Reverses the U parametric direction of the surface.
is virtual;
UReversedParameter (me; U : Real) returns Real
---Purpose: Return the parameter on the Ureversed surface for
-- the point of parameter U on <me>.
--
-- me->UReversed()->Value(me->UReversedParameter(U),V)
-- is the same point as
-- me->Value(U,V)
is deferred;
VReverse (me : mutable)
---Purpose :
-- Reverses the V parametric direction of the surface.
is virtual;
VReversedParameter (me; V : Real) returns Real
---Purpose: Return the parameter on the Vreversed surface for
-- the point of parameter V on <me>.
--
-- me->VReversed()->Value(U,me->VReversedParameter(V))
-- is the same point as
-- me->Value(U,V)
is deferred;
Continuity (me) returns Shape from GeomAbs;
---Purpose : Returns GeomAbs_CN, the global continuity of any elementary surface.
IsCNu (me; N : Integer) returns Boolean;
---Purpose : Returns True.
IsCNv (me; N : Integer) returns Boolean;
---Purpose : Returns True.
fields
pos : Ax3 is protected;
end;

View File

@@ -0,0 +1,140 @@
// File: Geom_ElementarySurface.cxx
// Created: Wed Mar 10 09:42:08 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_ElementarySurface.cxx, JCV 17/01/91
#include <Geom_ElementarySurface.ixx>
typedef Geom_ElementarySurface ElementarySurface;
typedef Handle(Geom_ElementarySurface) Handle(ElementarySurface);
typedef Handle(Geom_Surface) Handle(Surface);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Ax3 Ax3;
typedef gp_Dir Dir;
typedef gp_Pnt Pnt;
typedef gp_Vec Vec;
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom_ElementarySurface::Continuity () const {
return GeomAbs_CN;
}
//=======================================================================
//function : IsCNu
//purpose :
//=======================================================================
Standard_Boolean Geom_ElementarySurface::IsCNu (const Standard_Integer ) const {
return Standard_True;
}
//=======================================================================
//function : IsCNv
//purpose :
//=======================================================================
Standard_Boolean Geom_ElementarySurface::IsCNv (const Standard_Integer ) const {
return Standard_True;
}
//=======================================================================
//function : Axis
//purpose :
//=======================================================================
Ax1 Geom_ElementarySurface::Axis () const {
return pos.Axis();
}
//=======================================================================
//function : SetAxis
//purpose :
//=======================================================================
void Geom_ElementarySurface::SetAxis (const Ax1& A1) {
pos.SetAxis (A1);
}
//=======================================================================
//function : Location
//purpose :
//=======================================================================
Pnt Geom_ElementarySurface::Location () const {
return pos.Location();
}
//=======================================================================
//function : Position
//purpose :
//=======================================================================
const gp_Ax3& Geom_ElementarySurface::Position () const {
return pos;
}
//=======================================================================
//function : SetPosition
//purpose :
//=======================================================================
void Geom_ElementarySurface::SetPosition (const Ax3& A3) {
pos = A3;
}
//=======================================================================
//function : SetLocation
//purpose :
//=======================================================================
void Geom_ElementarySurface::SetLocation (const Pnt& Loc) {
pos.SetLocation (Loc);
}
//=======================================================================
//function : UReverse
//purpose :
//=======================================================================
void Geom_ElementarySurface::UReverse () {
pos.YReverse();
}
//=======================================================================
//function : VReverse
//purpose :
//=======================================================================
void Geom_ElementarySurface::VReverse () {
pos.ZReverse();
}

251
src/Geom/Geom_Ellipse.cdl Executable file
View File

@@ -0,0 +1,251 @@
-- File: Geom_Ellipse.cdl
-- Created: Wed Mar 10 09:43:26 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Ellipse from Geom inherits Conic from Geom
---Purpose : Describes an ellipse in 3D space.
-- An ellipse is defined by its major and minor radii and,
-- as with any conic curve, is positioned in space with a
-- right-handed coordinate system (gp_Ax2 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.
-- The origin, "X Direction" and "Y Direction" of this
-- coordinate system define the plane of the ellipse. The
-- coordinate system is the local coordinate system of the ellipse.
-- The "main Direction" of this coordinate system is the
-- vector normal to the plane of the ellipse. The axis, of
-- which the origin and unit vector are respectively the
-- origin and "main Direction" of the local coordinate
-- system, is termed the "Axis" or "main Axis" of the ellipse.
-- The "main Direction" of the local coordinate system
-- gives an explicit orientation to the ellipse (definition of
-- the trigonometric sense), determining the direction in
-- which the parameter increases along the ellipse.
-- The Geom_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 [.
uses Ax1 from gp,
Ax2 from gp,
Elips from gp,
Pnt from gp,
Trsf from gp,
Vec from gp,
Geometry from Geom
raises ConstructionError from Standard,
RangeError from Standard
is
Create (E : Elips) returns mutable Ellipse;
---Purpose : Constructs an ellipse by conversion of the gp_Elips ellipse E.
Create (A2 : Ax2; MajorRadius, MinorRadius : Real)
returns mutable Ellipse
---Purpose : Constructs an ellipse
-- defined by its major and minor radii, MajorRadius
-- and MinorRadius, where A2 locates the ellipse
-- and defines its orientation in 3D space such that:
-- - the center of the ellipse is the origin of A2,
-- - the "X Direction" of A2 defines the major axis
-- of the ellipse, i.e. the major radius
-- MajorRadius is measured along this axis,
-- - the "Y Direction" of A2 defines the minor axis
-- of the ellipse, i.e. the minor radius
-- MinorRadius is measured along this axis,
-- - A2 is the local coordinate system of the ellipse.
-- Exceptions
-- Standard_ConstructionError if:
-- - MajorRadius is less than MinorRadius, or
-- - MinorRadius is less than 0.
-- Warning The Geom package does not prevent the
-- construction of an ellipse where MajorRadius and
-- MinorRadius are equal.
raises ConstructionError;
SetElips (me : mutable; E : Elips)
---Purpose: Converts the gp_Elips ellipse E into this ellipse.
is static;
SetMajorRadius (me : mutable; MajorRadius : Real)
raises ConstructionError
---Purpose : Assigns a value to the major radius of this ellipse.
-- ConstructionError raised if MajorRadius < MinorRadius.
is static;
SetMinorRadius (me : mutable; MinorRadius : Real)
raises ConstructionError
---Purpose : Assigns a value to the minor radius of this ellipse.
-- ConstructionError raised if MajorRadius < MinorRadius or if MinorRadius < 0.
is static;
Elips (me) returns Elips
---Purpose :
-- returns the non transient ellipse from gp with the same
is static;
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 Ax1
---Purpose :
-- 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;
---Purpose : Raised if Eccentricity = 0.0. (The ellipse degenerates
-- into a circle)
Directrix2 (me) returns Ax1
---Purpose :
-- This line is obtained by the symmetrical transformation
-- of "Directrix1" with respect to the "YAxis" of the ellipse.
raises ConstructionError;
---Purpose :
-- Raised if Eccentricity = 0.0. (The ellipse degenerates into a
-- circle).
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. It is the distance between the
-- the two focus of the ellipse.
Focus1 (me) returns Pnt;
---Purpose :
-- Returns the first focus of the ellipse. This focus is on the
-- positive side of the "XAxis" of the ellipse.
Focus2 (me) returns Pnt;
---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 :
-- Returns 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 respectively:
-- - 0.0, which gives the start point of this ellipse, or
-- 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 respectively:
-- - 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 Pnt) 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 Pnt; V1 : out Vec) is redefined static;
-- Purpose :
-- Returns the point P of parameter U and the first derivative
-- at this point.
D2 (me; U : Real; P : out Pnt; V1, V2 : out Vec) 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 Pnt; V1, V2, V3 : out Vec) 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 Vec
---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 : Trsf) 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;

332
src/Geom/Geom_Ellipse.cxx Executable file
View File

@@ -0,0 +1,332 @@
// File: Geom_Ellipse.cxx
// Created: Wed Mar 10 09:43:49 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Ellipse.cxx, JCV 17/01/91
#include <Geom_Ellipse.ixx>
#include <gp_XYZ.hxx>
#include <ElCLib.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
typedef Geom_Ellipse Ellipse;
typedef Handle(Geom_Ellipse) Handle(Ellipse);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Vec Vec;
typedef gp_Trsf Trsf;
typedef gp_XYZ XYZ;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_Ellipse::Copy() const
{
Handle(Ellipse) E;
E = new Ellipse (pos, majorRadius, minorRadius);
return E;
}
//=======================================================================
//function : Geom_Ellipse
//purpose :
//=======================================================================
Geom_Ellipse::Geom_Ellipse (const gp_Elips& E)
: majorRadius (E.MajorRadius()), minorRadius (E.MinorRadius())
{
pos = E.Position ();
}
//=======================================================================
//function : Geom_Ellipse
//purpose :
//=======================================================================
Geom_Ellipse::Geom_Ellipse ( const Ax2& A,
const Standard_Real MajorRadius,
const Standard_Real MinorRadius)
: majorRadius (MajorRadius), minorRadius (MinorRadius) {
if (MajorRadius < MinorRadius || MinorRadius < 0.0 ) {
Standard_ConstructionError::Raise();
}
pos = A;
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_Ellipse::IsClosed () const { return Standard_True; }
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_Ellipse::IsPeriodic () const { return Standard_True; }
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom_Ellipse::FirstParameter () const { return 0.0; }
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom_Ellipse::LastParameter () const { return 2.0 * PI; }
//=======================================================================
//function : MajorRadius
//purpose :
//=======================================================================
Standard_Real Geom_Ellipse::MajorRadius () const { return majorRadius; }
//=======================================================================
//function : MinorRadius
//purpose :
//=======================================================================
Standard_Real Geom_Ellipse::MinorRadius () const { return minorRadius; }
//=======================================================================
//function : SetElips
//purpose :
//=======================================================================
void Geom_Ellipse::SetElips (const gp_Elips& E) {
majorRadius = E.MajorRadius();
minorRadius = E.MinorRadius();
pos = E.Position();
}
//=======================================================================
//function : SetMajorRadius
//purpose :
//=======================================================================
void Geom_Ellipse::SetMajorRadius (const Standard_Real MajorRadius) {
if (MajorRadius < minorRadius) Standard_ConstructionError::Raise ();
else majorRadius = MajorRadius;
}
//=======================================================================
//function : SetMinorRadius
//purpose :
//=======================================================================
void Geom_Ellipse::SetMinorRadius (const Standard_Real MinorRadius) {
if (MinorRadius < 0 || majorRadius < MinorRadius) {
Standard_ConstructionError::Raise();
}
else { minorRadius = MinorRadius; }
}
//=======================================================================
//function : Elips
//purpose :
//=======================================================================
gp_Elips Geom_Ellipse::Elips () const {
return gp_Elips (pos, majorRadius, minorRadius);
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Ellipse::ReversedParameter( const Standard_Real U) const
{
return ( 2. * PI - U);
}
//=======================================================================
//function : Directrix1
//purpose :
//=======================================================================
Ax1 Geom_Ellipse::Directrix1 () const {
gp_Elips Ev (pos, majorRadius, minorRadius);
return Ev.Directrix1();
}
//=======================================================================
//function : Directrix2
//purpose :
//=======================================================================
Ax1 Geom_Ellipse::Directrix2 () const {
gp_Elips Ev (pos, majorRadius, minorRadius);
return Ev.Directrix2();
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_Ellipse::D0 (const Standard_Real U, gp_Pnt& P) const {
P = ElCLib::EllipseValue (U, pos, majorRadius, minorRadius);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_Ellipse::D1 (const Standard_Real U, Pnt& P, Vec& V1) const {
ElCLib::EllipseD1 (U, pos, majorRadius, minorRadius, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_Ellipse::D2 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2) const {
ElCLib::EllipseD2 (U, pos, majorRadius, minorRadius, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_Ellipse::D3 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2, Vec& V3) const {
ElCLib::EllipseD3 (U, pos, majorRadius, minorRadius, P, V1, V2, V3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_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 : Eccentricity
//purpose :
//=======================================================================
Standard_Real Geom_Ellipse::Eccentricity () const {
if (majorRadius == 0.0) { return 0.0; }
else {
return (Sqrt(majorRadius*majorRadius-minorRadius*minorRadius))/majorRadius;
}
}
//=======================================================================
//function : Focal
//purpose :
//=======================================================================
Standard_Real Geom_Ellipse::Focal () const {
return 2.0 * Sqrt(majorRadius * majorRadius - minorRadius * minorRadius);
}
//=======================================================================
//function : Focus1
//purpose :
//=======================================================================
Pnt Geom_Ellipse::Focus1 () const {
Standard_Real C = Sqrt (majorRadius * majorRadius - minorRadius * minorRadius);
Standard_Real Xp, Yp, Zp, Xd, Yd, Zd;
pos.Location().Coord (Xp, Yp, Zp);
pos.XDirection().Coord (Xd, Yd, Zd);
return Pnt (Xp + C * Xd, Yp + C * Yd, Zp + C * Zd);
}
//=======================================================================
//function : Focus2
//purpose :
//=======================================================================
Pnt Geom_Ellipse::Focus2 () const {
Standard_Real C = Sqrt (majorRadius * majorRadius - minorRadius * minorRadius);
Standard_Real Xp, Yp, Zp, Xd, Yd, Zd;
pos.Location().Coord (Xp, Yp, Zp);
pos.XDirection().Coord (Xd, Yd, Zd);
return Pnt (Xp - C * Xd, Yp - C * Yd, Zp - C * Zd);
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real Geom_Ellipse::Parameter () const {
if (majorRadius == 0.0) return 0.0;
else return (minorRadius * minorRadius) / majorRadius;
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_Ellipse::Transform (const Trsf& T) {
majorRadius = majorRadius * Abs(T.ScaleFactor());
minorRadius = minorRadius * Abs(T.ScaleFactor());
pos.Transform(T);
}

144
src/Geom/Geom_Geometry.cdl Executable file
View File

@@ -0,0 +1,144 @@
-- File: Geom_Geometry.cdl
-- Created: Tue Mar 9 19:17:40 1993
-- Author: JVC
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class Geometry from Geom inherits TShared from MMgt
---Purpose : The abstract class Geometry for 3D space is the root
-- class of all geometric objects from the Geom
-- package. It describes the common behavior of these objects when:
-- - applying geometric transformations to objects, and
-- - constructing objects by geometric transformation (including copying).
-- Warning
-- Only transformations which do not modify the nature
-- of the geometry can be applied to Geom objects: this
-- is the case with translations, rotations, symmetries
-- and scales; this is also the case with gp_Trsf
-- 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 Ax1 from gp,
Ax2 from gp,
Pnt from gp,
Trsf from gp,
Vec from gp
raises ConstructionError from Standard
is
---Group:
-- All the following transformations modify the object itself.
Mirror (me : mutable; P : Pnt)
---Purpose :
-- Performs the symmetrical transformation of a Geometry
-- with respect to the point P which is the center of the
-- symmetry.
is static;
Mirror (me : mutable; A1 : Ax1)
---Purpose :
-- Performs the symmetrical transformation of a Geometry
-- with respect to an axis placement which is the axis of the
-- symmetry.
is static;
Mirror (me : mutable; A2 : Ax2)
---Purpose :
-- Performs the symmetrical transformation of a Geometry
-- with respect to a plane. The axis placement A2 locates
-- the plane of the symmetry : (Location, XDirection, YDirection).
is static;
Rotate (me : mutable; A1 : Ax1; Ang : Real)
---Purpose :
-- Rotates a Geometry. A1 is the axis of the rotation.
-- Ang is the angular value of the rotation in radians.
is static;
Scale (me : mutable; P : Pnt; S : Real)
---Purpose :
-- Scales a Geometry. S is the scaling value.
is static;
Translate (me : mutable; V : Vec)
---Purpose :
-- Translates a Geometry. V is the vector of the tanslation.
is static;
Translate (me : mutable; P1, P2 : Pnt)
---Purpose :
-- Translates a Geometry from the point P1 to the point P2.
is static;
Transform (me : mutable; T : Trsf)
---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 Geom).
is deferred;
---Group:
-- 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 : Pnt) returns mutable like me
is static;
Mirrored (me; A1 : Ax1) returns mutable like me
is static;
Mirrored (me; A2 : Ax2) returns mutable like me
is static;
Rotated (me; A1 : Ax1; Ang : Real) returns mutable like me
is static;
Scaled (me; P : Pnt; S : Real) returns mutable like me
is static;
Transformed (me; T : Trsf) returns mutable like me
is static;
Translated (me; V : Vec) returns mutable like me
is static;
Translated (me; P1, P2 : Pnt) returns mutable like me
is static;
Copy (me) returns mutable like me is deferred;
---Purpose: Creates a new object which is a copy of this geometric object.
end;

172
src/Geom/Geom_Geometry.cxx Executable file
View File

@@ -0,0 +1,172 @@
// File: Geom_Geometry.cxx
// Created: Wed Mar 10 09:45:02 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Geometry.cxx, JCV 15/01/91
//JCV 09/07/92 portage sur C1
#include <Geom_Geometry.ixx>
#include <Standard_ConstructionError.hxx>
typedef Handle(Geom_Geometry) Handle(Geometry);
typedef Geom_Geometry Geometry;
typedef gp_Pnt Pnt;
typedef gp_Vec Vec;
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Trsf Trsf;
Handle(Geom_Geometry) Geom_Geometry::Copy() const {
Handle(Geom_Geometry) G;
Standard_ConstructionError::Raise();
return G;
}
void Geom_Geometry::Mirror (const gp_Pnt& P) {
Trsf T;
T.SetMirror (P);
Transform (T);
}
void Geom_Geometry::Mirror (const gp_Ax1& A1) {
Trsf T;
T.SetMirror (A1);
Transform (T);
}
void Geom_Geometry::Mirror (const gp_Ax2& A2) {
Trsf T;
T.SetMirror (A2);
Transform (T);
}
void Geom_Geometry::Rotate (const gp_Ax1& A1, const Standard_Real Ang) {
Trsf T;
T.SetRotation (A1, Ang);
Transform (T);
}
void Geom_Geometry::Scale (const gp_Pnt& P, const Standard_Real S) {
Trsf T;
T.SetScale (P, S);
Transform (T);
}
void Geom_Geometry::Translate (const gp_Vec& V) {
Trsf T;
T.SetTranslation (V);
Transform (T);
}
void Geom_Geometry::Translate (const gp_Pnt& P1, const gp_Pnt& P2) {
Vec V (P1, P2);
Translate (V);
}
Handle(Geometry) Geom_Geometry::Mirrored (const gp_Pnt& P) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Mirror (P);
return G;
}
Handle(Geometry) Geom_Geometry::Mirrored (const gp_Ax1& A1) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Mirror (A1);
return G;
}
Handle(Geometry) Geom_Geometry::Mirrored (const gp_Ax2& A2) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Mirror (A2);
return G;
}
Handle(Geometry) Geom_Geometry::Rotated (
const gp_Ax1& A1,
const Standard_Real Ang
) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Rotate (A1, Ang);
return G;
}
Handle(Geometry) Geom_Geometry::Scaled (const gp_Pnt& P, const Standard_Real S) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Scale (P, S);
return G;
}
Handle(Geometry) Geom_Geometry::Transformed (const gp_Trsf& T) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Transform (T);
return G;
}
Handle(Geometry) Geom_Geometry::Translated (const gp_Vec& V) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Translate (V);
return G;
}
Handle(Geometry) Geom_Geometry::Translated (
const gp_Pnt& P1,
const gp_Pnt& P2
) const {
Handle(Geometry) me = this;
Handle(Geometry) G = me->Copy();
G->Translate (P1, P2);
return G;
}

309
src/Geom/Geom_Hyperbola.cdl Executable file
View File

@@ -0,0 +1,309 @@
-- File: Geom_Hyperbola.cdl
-- Created: Wed Mar 10 09:45:33 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Hyperbola from Geom inherits Conic from Geom
---Purpose : Describes a branch of a hyperbola in 3D space.
-- A hyperbola is defined by its major and minor radii
-- and, as with any conic curve, is positioned in space
-- with a right-handed coordinate system (gp_Ax2 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.
-- The origin, "X Direction" and "Y Direction" of this
-- coordinate system define the plane of the hyperbola.
-- The 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 "main Direction" of the local coordinate system is
-- a vector normal to the plane of the hyperbola. The
-- axis, of which the origin and unit vector are
-- respectively the origin and "main Direction" of the
-- local coordinate system, is termed the "Axis" or "main
-- Axis" of the hyperbola.
-- The "main Direction" of the local coordinate system
-- gives an explicit orientation to the hyperbola,
-- determining the direction in which the parameter
-- increases along the hyperbola.
-- The Geom_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: Defines the main branch of an hyperbola.
-- ^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).
uses Ax1 from gp,
Ax2 from gp,
Hypr from gp,
Pnt from gp,
Trsf from gp,
Vec from gp,
Geometry from Geom
raises ConstructionError from Standard,
DomainError from Standard,
RangeError from Standard
is
Create (H : Hypr) returns mutable Hyperbola;
---Purpose : Constructs a hyperbola by conversion of the gp_Hypr hyperbola H.
Create (A2 : Ax2; MajorRadius, MinorRadius : Real)
returns mutable Hyperbola
---Purpose : Constructs a hyperbola defined by its major and
-- minor radii, MajorRadius and MinorRadius, where A2 locates the
-- hyperbola and defines its orientation in 3D space such that:
-- - the center of the hyperbola is the origin of A2,
-- - the "X Direction" of A2 defines the major axis
-- of the hyperbola, i.e. the major radius
-- MajorRadius is measured along this axis,
-- - the "Y Direction" of A2 defines the minor axis
-- of the hyperbola, i.e. the minor radius
-- MinorRadius is measured along this axis,
-- - A2 is the local coordinate system of the hyperbola.
-- Exceptions
-- Standard_ConstructionError if:
-- - MajorRadius is less than 0.0,
-- - MinorRadius is less than 0.0.
raises ConstructionError;
SetHypr (me : mutable; H : Hypr)
---Purpose: Converts the gp_Hypr hyperbola H into this hyperbola.
is static;
SetMajorRadius (me : mutable; MajorRadius : Real)
raises ConstructionError
---Purpose : Assigns a value to the major radius of this hyperbola.
-- Exceptions
-- Standard_ConstructionError if:
-- - MajorRadius is less than 0.0, or
-- - MinorRadius is less than 0.0.Raised if MajorRadius < 0.0
is static;
SetMinorRadius (me : mutable; MinorRadius : Real)
raises ConstructionError
---Purpose : Assigns a value to the minor radius of this hyperbola.
-- Exceptions
-- Standard_ConstructionError if:
-- - MajorRadius is less than 0.0, or
-- - MinorRadius is less than 0.0.Raised if MajorRadius < 0.0
is static;
Hypr (me) returns Hypr
---Purpose :
-- returns the non transient parabola from gp with the same
-- geometric properties as <me>.
is static;
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 Ax1
---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.
-- Raises ConstructionError if MajorRadius = 0.0
raises ConstructionError;
Asymptote2 (me) returns Ax1
---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.
-- Raises ConstructionError if MajorRadius = 0.0
raises ConstructionError;
ConjugateBranch1 (me) returns Hypr;
---Purpose :
-- This branch of hyperbola is on the positive side of the
-- YAxis of <me>.
ConjugateBranch2 (me) returns Hypr;
---Purpose :
-- This branch of hyperbola is on the negative side of the
-- YAxis of <me>.
-- 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 Ax1;
---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 Ax1;
---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 ConstructionError 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 Pnt;
---Purpose :
-- Returns the first focus of the hyperbola. This focus is on the
-- positive side of the XAxis of the hyperbola.
Focus2 (me) returns Pnt;
---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 Hypr;
---Purpose : Computes the "other" branch of this hyperbola. This
-- is the 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.
Parameter (me) returns Real
---Purpose :
-- Returns p = (e * e - 1) * MajorRadius where e is the
-- eccentricity of the hyperbola.
raises DomainError;
---Purpose : raised if MajorRadius = 0.0
D0(me; U : Real; P : out Pnt) 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 Pnt; V1 : out Vec) is redefined static;
---Purpose :
-- Returns the point P of parameter U and the first derivative V1.
D2 (me; U : Real; P : out Pnt; V1, V2 : out Vec) 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 Pnt; V1, V2, V3 : out Vec) 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 Vec
---Purpose :
-- The returned vector gives the value of the derivative for the
-- order of derivation N.
raises RangeError
is redefined static;
---Purpose : Raised if N < 1.
Transform (me : mutable; T : Trsf) 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;

377
src/Geom/Geom_Hyperbola.cxx Executable file
View File

@@ -0,0 +1,377 @@
// File: Geom_Hyperbola.cxx
// Created: Wed Mar 10 09:45:54 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Hyperbola.cxx, JCV 17/01/91
#include <Geom_Hyperbola.ixx>
#include <Precision.hxx>
#include <gp_XYZ.hxx>
#include <ElCLib.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_ConstructionError.hxx>
typedef Geom_Hyperbola Hyperbola;
typedef Handle(Geom_Hyperbola) Handle(Hyperbola);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Vec Vec;
typedef gp_Trsf Trsf;
typedef gp_XYZ XYZ;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_Hyperbola::Copy() const {
Handle(Hyperbola) H;
H = new Hyperbola (pos, majorRadius, minorRadius);
return H;
}
//=======================================================================
//function : Geom_Hyperbola
//purpose :
//=======================================================================
Geom_Hyperbola::Geom_Hyperbola (const gp_Hypr& H)
: majorRadius (H.MajorRadius()), minorRadius (H.MinorRadius()) {
pos = H.Position();
}
//=======================================================================
//function : Geom_Hyperbola
//purpose :
//=======================================================================
Geom_Hyperbola::Geom_Hyperbola ( const Ax2& A,
const Standard_Real MajorRadius,
const Standard_Real MinorRadius)
: majorRadius (MajorRadius), minorRadius (MinorRadius) {
if (MajorRadius < 0.0 || MinorRadius < 0.0) {
Standard_ConstructionError::Raise();
}
pos = A;
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_Hyperbola::IsClosed () const { return Standard_False; }
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_Hyperbola::IsPeriodic () const { return Standard_False; }
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom_Hyperbola::FirstParameter () const
{ return -Precision::Infinite(); }
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom_Hyperbola::LastParameter () const
{ return Precision::Infinite(); }
//=======================================================================
//function : MajorRadius
//purpose :
//=======================================================================
Standard_Real Geom_Hyperbola::MajorRadius () const { return majorRadius; }
//=======================================================================
//function : MinorRadius
//purpose :
//=======================================================================
Standard_Real Geom_Hyperbola::MinorRadius () const { return minorRadius; }
//=======================================================================
//function : SetHypr
//purpose :
//=======================================================================
void Geom_Hyperbola::SetHypr (const gp_Hypr& H) {
majorRadius = H.MajorRadius();
minorRadius = H.MinorRadius();
pos = H.Position();
}
//=======================================================================
//function : SetMajorRadius
//purpose :
//=======================================================================
void Geom_Hyperbola::SetMajorRadius (const Standard_Real MajorRadius) {
if (MajorRadius < 0.0) Standard_ConstructionError::Raise();
else majorRadius = MajorRadius;
}
//=======================================================================
//function : SetMinorRadius
//purpose :
//=======================================================================
void Geom_Hyperbola::SetMinorRadius (const Standard_Real MinorRadius) {
if (MinorRadius < 0.0) Standard_ConstructionError::Raise();
else minorRadius = MinorRadius;
}
//=======================================================================
//function : Hypr
//purpose :
//=======================================================================
gp_Hypr Geom_Hyperbola::Hypr () const
{
return gp_Hypr (pos, majorRadius, minorRadius);
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Hyperbola::ReversedParameter( const Standard_Real U) const
{
return ( -U);
}
//=======================================================================
//function : Asymptote1
//purpose :
//=======================================================================
Ax1 Geom_Hyperbola::Asymptote1 () const {
gp_Hypr Hv (pos, majorRadius, minorRadius);
return Hv.Asymptote1();
}
//=======================================================================
//function : Asymptote2
//purpose :
//=======================================================================
Ax1 Geom_Hyperbola::Asymptote2 () const {
gp_Hypr Hv (pos, majorRadius, minorRadius);
return Hv.Asymptote2();
}
//=======================================================================
//function : ConjugateBranch1
//purpose :
//=======================================================================
gp_Hypr Geom_Hyperbola::ConjugateBranch1 () const {
gp_Hypr Hv (pos, majorRadius, minorRadius);
return Hv.ConjugateBranch1();
}
//=======================================================================
//function : ConjugateBranch2
//purpose :
//=======================================================================
gp_Hypr Geom_Hyperbola::ConjugateBranch2 () const {
gp_Hypr Hv (pos, majorRadius, minorRadius);
return Hv.ConjugateBranch2();
}
//=======================================================================
//function : Directrix1
//purpose :
//=======================================================================
Ax1 Geom_Hyperbola::Directrix1 () const {
gp_Hypr Hv (pos, majorRadius, minorRadius);
return Hv.Directrix1();
}
//=======================================================================
//function : Directrix2
//purpose :
//=======================================================================
Ax1 Geom_Hyperbola::Directrix2 () const {
gp_Hypr Hv (pos, majorRadius, minorRadius);
return Hv.Directrix2();
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_Hyperbola::D0 (const Standard_Real U, Pnt& P) const {
P = ElCLib::HyperbolaValue (U, pos, majorRadius, minorRadius);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_Hyperbola::D1 (const Standard_Real U, Pnt& P, Vec& V1) const {
ElCLib::HyperbolaD1 (U, pos, majorRadius, minorRadius, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_Hyperbola::D2 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2) const {
ElCLib::HyperbolaD2 (U, pos, majorRadius, minorRadius, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_Hyperbola::D3 (
const Standard_Real U, Pnt& P, Vec& V1, Vec& V2, Vec& V3) const {
ElCLib::HyperbolaD3 (U, pos, majorRadius, minorRadius, P, V1, V2, V3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_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 : Eccentricity
//purpose :
//=======================================================================
Standard_Real Geom_Hyperbola::Eccentricity () const {
Standard_ConstructionError_Raise_if (majorRadius == 0.0, " ")
return (Sqrt(majorRadius*majorRadius + minorRadius*minorRadius))/majorRadius;
}
//=======================================================================
//function : Focal
//purpose :
//=======================================================================
Standard_Real Geom_Hyperbola::Focal () const {
return 2.0 * Sqrt(majorRadius * majorRadius + minorRadius * minorRadius);
}
//=======================================================================
//function : Focus1
//purpose :
//=======================================================================
Pnt Geom_Hyperbola::Focus1 () const {
Standard_Real C = Sqrt(majorRadius * majorRadius + minorRadius * minorRadius);
Standard_Real Xp, Yp, Zp, Xd, Yd, Zd;
pos.Location().Coord (Xp, Yp, Zp);
pos.XDirection().Coord (Xd, Yd, Zd);
return Pnt (Xp + C * Xd, Yp + C * Yd, Zp + C * Zd);
}
//=======================================================================
//function : Focus2
//purpose :
//=======================================================================
Pnt Geom_Hyperbola::Focus2 () const {
Standard_Real C = Sqrt(majorRadius * majorRadius + minorRadius * minorRadius);
Standard_Real Xp, Yp, Zp, Xd, Yd, Zd;
pos.Location().Coord (Xp, Yp, Zp);
pos.XDirection().Coord (Xd, Yd, Zd);
return Pnt (Xp - C * Xd, Yp - C * Yd, Zp - C * Zd);
}
//=======================================================================
//function : OtherBranch
//purpose :
//=======================================================================
gp_Hypr Geom_Hyperbola::OtherBranch () const {
gp_Hypr Hv (pos, majorRadius, minorRadius);
return Hv.OtherBranch ();
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real Geom_Hyperbola::Parameter () const {
Standard_ConstructionError_Raise_if (majorRadius == 0.0, " ");
return (minorRadius * minorRadius)/majorRadius;
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_Hyperbola::Transform (const Trsf& T) {
majorRadius = majorRadius * Abs(T.ScaleFactor());
minorRadius = minorRadius * Abs(T.ScaleFactor());
pos.Transform(T);
}

201
src/Geom/Geom_Line.cdl Executable file
View File

@@ -0,0 +1,201 @@
-- File: Geom_Line.cdl
-- Created: Wed Mar 10 09:46:21 1993
-- Author: Philippe DAUTRY
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Line from Geom inherits Curve from Geom
---Purpose : Describes an infinite line.
-- A line is defined and positioned in space with an axis
-- (gp_Ax1 object) which gives it an origin and a unit vector.
-- The Geom_Line line is parameterized:
-- 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.
uses Ax1 from gp,
Ax2 from gp,
Dir from gp,
Lin from gp,
Pnt from gp,
Vec from gp,
Trsf from gp,
Geometry from Geom,
Shape from GeomAbs
raises RangeError from Standard
is
Create (A1 : Ax1) returns mutable Line;
---Purpose :
-- Creates a line located in 3D space with the axis placement A1.
-- The Location of A1 is the origin of the line.
Create (L : Lin) returns mutable Line;
---Purpose :
-- Creates a line from a non transient line from package gp.
Create (P : Pnt; V : Dir) 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).
SetLin (me : mutable; L : Lin)
---Purpose :
-- Set <me> so that <me> has the same geometric properties as L.
is static;
SetDirection (me : mutable; V : Dir)
---Purpose : changes the direction of the line.
is static;
SetLocation (me : mutable; P : Pnt)
---Purpose :
-- changes the "Location" point (origin) of the line.
is static;
SetPosition (me : mutable; A1 : Ax1)
---Purpose :
-- changes the "Location" and a the "Direction" of <me>.
is static;
Lin (me) returns Lin from gp
---Purpose :
-- Returns non transient line from gp with the same geometric
-- properties as <me>
is static;
Position(me) returns Ax1 from gp
---C++: return const &
---Purpose: Returns the positioning axis of this line; this is also its local coordinate system.
is static;
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 the value of the first parameter of this
-- line. This is Standard_Real::RealFirst().
LastParameter (me) returns Real;
---Purpose : Returns the value of the last parameter of this
-- line. This is Standard_Real::RealLast().
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.
IsCN (me; N : Integer) returns Boolean
---Purpose: returns True.
raises RangeError;
---Purpose: Raised if N < 0.
D0(me; U : Real; P : out Pnt);
---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 Pnt; V1 : out Vec);
---Purpose :
-- Returns the point P of parameter u and the first derivative V1.
D2 (me; U : Real; P : out Pnt; V1, V2 : out Vec);
---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 Pnt; V1, V2, V3 : out Vec);
---Purpose :
-- V2 and V3 are vectors with null magnitude for a line.
DN (me; U : Real; N : Integer) returns Vec
---Purpose :
-- The returned vector gives the value of the derivative for the
-- order of derivation N.
raises RangeError;
---Purpose : Raised if N < 1.
Transform (me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this line.
TransformedParameter(me; U : Real; T : Trsf 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 returns <U> * T.ScaleFactor()
is redefined;
ParametricTransformation(me; T : Trsf 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;
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this line.
fields
pos : Ax1;
end;

240
src/Geom/Geom_Line.cxx Executable file
View File

@@ -0,0 +1,240 @@
// File: Geom_Line.cxx
// Created: Wed Mar 10 09:47:01 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Line.cxx ,JCV 17/01/91
#include <Geom_Line.ixx>
#include <Precision.hxx>
#include <gp_XYZ.hxx>
#include <ElCLib.hxx>
#include <Standard_RangeError.hxx>
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_Line::Copy() const {
Handle(Geom_Line) L;
L = new Geom_Line (pos);
return L;
}
//=======================================================================
//function : Geom_Line
//purpose :
//=======================================================================
Geom_Line::Geom_Line (const gp_Ax1& A) : pos (A) { }
//=======================================================================
//function : Geom_Line
//purpose :
//=======================================================================
Geom_Line::Geom_Line (const gp_Lin& L) : pos (L.Position()) { }
//=======================================================================
//function : Geom_Line
//purpose :
//=======================================================================
Geom_Line::Geom_Line (const gp_Pnt& P, const gp_Dir& V) : pos (P, V) { }
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
void Geom_Line::Reverse () { pos.Reverse(); }
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Line::ReversedParameter( const Standard_Real U) const
{ return (-U);}
//=======================================================================
//function : SetDirection
//purpose :
//=======================================================================
void Geom_Line::SetDirection (const gp_Dir& V) { pos.SetDirection (V); }
//=======================================================================
//function : SetLin
//purpose :
//=======================================================================
void Geom_Line::SetLin (const gp_Lin& L) { pos = L.Position(); }
//=======================================================================
//function : SetLocation
//purpose :
//=======================================================================
void Geom_Line::SetLocation (const gp_Pnt& P) { pos.SetLocation (P); }
//=======================================================================
//function : SetPosition
//purpose :
//=======================================================================
void Geom_Line::SetPosition (const gp_Ax1& A1) { pos = A1; }
//=======================================================================
//function : Position
//purpose :
//=======================================================================
const gp_Ax1& Geom_Line::Position () const { return pos; }
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_Line::IsClosed () const { return Standard_False; }
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_Line::IsPeriodic () const { return Standard_False; }
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom_Line::Continuity () const { return GeomAbs_CN; }
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom_Line::FirstParameter () const
{ return -Precision::Infinite(); }
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom_Line::LastParameter () const
{ return Precision::Infinite(); }
//=======================================================================
//function : Lin
//purpose :
//=======================================================================
gp_Lin Geom_Line::Lin () const { return gp_Lin (pos); }
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom_Line::IsCN (const Standard_Integer ) const
{ return Standard_True; }
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_Line::Transform (const gp_Trsf& T) { pos.Transform (T); }
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_Line::D0 (const Standard_Real U, gp_Pnt& P) const
{
P = ElCLib::LineValue (U, pos);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_Line::D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const {
ElCLib::LineD1 (U, pos, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_Line::D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const {
ElCLib::LineD1 (U, pos, P, V1);
V2.SetCoord (0.0, 0.0, 0.0);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_Line::D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const{
ElCLib::LineD1 (U, pos, P, V1);
V2.SetCoord (0.0, 0.0, 0.0);
V3.SetCoord (0.0, 0.0, 0.0);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
gp_Vec Geom_Line::DN (const Standard_Real , const Standard_Integer N) const {
Standard_RangeError_Raise_if (N <= 0, " ");
if (N == 1) return gp_Vec (pos.Direction ());
else return gp_Vec (0.0, 0.0, 0.0);
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Line::TransformedParameter(const Standard_Real U,
const gp_Trsf& T) const
{
if (Precision::IsInfinite(U)) return U;
return U * Abs(T.ScaleFactor());
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Line::ParametricTransformation(const gp_Trsf& T) const
{
return Abs(T.ScaleFactor());
}

348
src/Geom/Geom_OffsetCurve.cdl Executable file
View File

@@ -0,0 +1,348 @@
-- File: Geom_OffsetCurve.cdl
-- Created: Wed Mar 10 09:48:36 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class OffsetCurve from Geom inherits Curve from Geom
---Purpose :
-- This class implements the basis services for an offset curve
-- in 3D 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 in a reference direction V. The offset curve
-- takes its parametrization from the basis curve.
-- The Offset curve is in the direction of of the normal N
-- defined with the cross product V^T where the vector T
-- is given by the first derivative on the basis curve with
-- non zero length.
-- 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 ^ V)) / ||T ^ V||
--
-- At any point the Offset direction V must not be parallel to the
-- vector T and the vector T must not have null length else the
-- offset curve is not defined. So the offset curve has not the
-- same continuity as the basis curve.
--
-- 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^V|| != 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 Dir from gp,
Pnt from gp,
Trsf from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom,
Shape from GeomAbs
raises ConstructionError from Standard,
RangeError from Standard,
NoSuchObject from Standard,
UndefinedDerivative from Geom,
UndefinedValue from Geom
is
Create (C : Curve from Geom; Offset : Real; V : Dir)
returns mutable OffsetCurve
---Purpose :
-- C is the basis curve, Offset is the distance between <me> and
-- the basis curve at any point. V defines the fixed reference
-- direction (offset direction). If P is a point on the basis
-- curve and T the first derivative with non zero length
-- at this point, the corresponding point on the offset curve is
-- in the direction of the vector-product N = V ^ T where
-- N is a unitary vector.
-- 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
raises ConstructionError;
---Purpose :
-- Raised if the basis curve C is not at least C1.
-- Warnings :
-- No check is done to know if ||V^T|| != 0.0 at any point.
Reverse (me : mutable);
---Purpose : Changes the orientation of this offset curve.
-- 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 Geom)
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.
SetDirection (me : mutable; V : Dir);
---Purpose : Changes this offset curve by assigning V as the
-- reference vector used to compute the offset direction.
SetOffsetValue (me : mutable; D : Real);
---Purpose : Changes this offset curve by assigning D as the offset value.
BasisCurve (me) returns Curve from Geom;
---Purpose : Returns the basis curve of this offset curve.
-- Note: The basis curve can be an offset curve.
Continuity (me) returns Shape from GeomAbs;
---Purpose : Returns the global continuity of this offset curve as a
-- value of the GeomAbs_Shape enumeration.
-- The degree of continuity of this offset curve is equal
-- to the degree of continuity of the basis curve minus 1.
-- 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 offset direction defined
-- at any point.
Direction (me) returns Dir;
---Purpose : Returns the reference vector of this offset curve.
---C++: return const&
---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
-- V the offset direction the relation ||T(U) ^ V|| != 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 Pnt);
---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 Pnt; V1 : out Vec)
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 Pnt; V1, V2 : out Vec)
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 Pnt; V1, V2, V3 : out Vec)
raises UndefinedDerivative;
---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 Vec
---Purpose :
-- The returned vector gives the value of the derivative
-- for the order of derivation N.
--Warning!
-- this should not be called
-- 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 UndefinedDerivative,
---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
--
-- Warning:
-- The exception UndefinedValue or UndefinedDerivative is
-- raised if it is not possible to compute a unique offset
-- direction.
RangeError;
---Purpose : Raised if N < 1.
--
Value (me; U : Real; P, Pbasis : out Pnt; V1basis : out Vec)
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
D0 (me; U : Real; P, Pbasis : out Pnt; V1basis : out Vec)
raises UndefinedValue;
---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
D1 (me; U : Real; P, Pbasis : out Pnt; V1, V1basis, V2basis : out Vec)
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 Pnt; V1, V2, V1basis, V2basis,
V3basis : out Vec)
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 : Returns true if the degree of continuity of the basis
-- curve of this offset curve is at least N + 1.
-- 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 : Returns true if this offset curve is periodic, i.e. if the
-- basis curve of this offset curve is 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 : Trsf);
--- Purpose: Applies the transformation T to this offset curve.
-- Note: the basis curve is also modified.
TransformedParameter(me; U : Real; T : Trsf 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 : Trsf 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 Geom;
direction : Dir;
offsetValue : Real;
end;

774
src/Geom/Geom_OffsetCurve.cxx Executable file
View File

@@ -0,0 +1,774 @@
// File: Geom_OffsetCurve.cxx
// Created: Wed Mar 10 09:49:18 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
// Created: Tue Jun 25 15:36:30 1991
// Author: JCV
// 24-Aug-95 : xab removed C1 and C2 test : appeller D1 et D2
// avec discernement !
// 19-09-97 : JPI correction derivee seconde
//
#include <Geom_OffsetCurve.ixx>
#include <gp.hxx>
#include <gp_XYZ.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_Parabola.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Geometry.hxx>
#include <Geom_UndefinedDerivative.hxx>
#include <Geom_UndefinedValue.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_NotImplemented.hxx>
typedef Geom_OffsetCurve OffsetCurve;
typedef Handle(Geom_OffsetCurve) Handle(OffsetCurve);
typedef Geom_Curve Curve;
typedef Handle(Geom_Curve) Handle(Curve);
typedef Handle(Geom_Geometry) Handle(Geometry);
typedef gp_Dir Dir;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
typedef gp_XYZ XYZ;
static const int MaxDegree = 9;
//ordre de derivation maximum pour la recherche de la premiere
//derivee non nulle
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_OffsetCurve::Copy () const {
Handle(OffsetCurve) C;
C = new OffsetCurve (basisCurve, offsetValue, direction);
return C;
}
//=======================================================================
//function : Geom_OffsetCurve
//purpose :
//=======================================================================
Geom_OffsetCurve::Geom_OffsetCurve (const Handle(Curve)& C,
const Standard_Real Offset,
const Dir& V )
: direction(V), offsetValue(Offset) {
if (C->DynamicType() == STANDARD_TYPE(Geom_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());
Standard_Real PrevOff = OC->Offset();
gp_Vec V1(OC->Direction());
gp_Vec V2(direction);
gp_Vec Vdir(PrevOff*V1 + offsetValue*V2);
if (Offset >= 0.) {
offsetValue = Vdir.Magnitude();
direction.SetXYZ(Vdir.XYZ());
} else {
offsetValue = -Vdir.Magnitude();
direction.SetXYZ((-Vdir).XYZ());
}
} else {
if (C->Continuity() == GeomAbs_C0) Standard_ConstructionError::Raise();
basisCurve = Handle(Curve)::DownCast(C->Copy()); // DownCast: 10-03-93
}
}
//=======================================================================
//function : Reverse
//purpose :
//=======================================================================
void Geom_OffsetCurve::Reverse ()
{
basisCurve->Reverse();
offsetValue = -offsetValue;
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_OffsetCurve::ReversedParameter( const Standard_Real U) const
{
return basisCurve->ReversedParameter( U);
}
//=======================================================================
//function : Direction
//purpose :
//=======================================================================
const gp_Dir& Geom_OffsetCurve::Direction () const
{ return direction; }
//=======================================================================
//function : SetDirection
//purpose :
//=======================================================================
void Geom_OffsetCurve::SetDirection (const Dir& V)
{ direction = V; }
//=======================================================================
//function : SetOffsetValue
//purpose :
//=======================================================================
void Geom_OffsetCurve::SetOffsetValue (const Standard_Real D)
{ offsetValue = D; }
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_OffsetCurve::IsPeriodic () const
{
return basisCurve->IsPeriodic();
}
//=======================================================================
//function : Period
//purpose :
//=======================================================================
Standard_Real Geom_OffsetCurve::Period () const
{
return basisCurve->Period();
}
//=======================================================================
//function : SetBasisCurve
//purpose :
//=======================================================================
void Geom_OffsetCurve::SetBasisCurve (const Handle(Curve)& C) {
if (C->Continuity() == GeomAbs_C0) Standard_ConstructionError::Raise();
basisCurve = Handle(Curve)::DownCast(C->Copy()); // DownCast: 10-03-93
}
//=======================================================================
//function : BasisCurve
//purpose :
//=======================================================================
Handle(Curve) Geom_OffsetCurve::BasisCurve () const
{
return basisCurve;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom_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 Geom_OffsetCurve::D0 (const Standard_Real U, Pnt& P) const
{
gp_Pnt PBasis;
gp_Vec VBasis;
D0(U,P,PBasis,VBasis);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_OffsetCurve::D1 (const Standard_Real U, Pnt& P, Vec& V1) const
{
gp_Pnt PBasis;
gp_Vec V1Basis,V2Basis;
D1(U,P,PBasis,V1,V1Basis,V2Basis);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_OffsetCurve::D2 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2) const
{
gp_Pnt PBasis;
gp_Vec V1Basis,V2Basis,V3Basis;
D2(U,P,PBasis,V1,V2,V1Basis,V2Basis,V3Basis);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_OffsetCurve::D3 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2, Vec& V3)
const {
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ V|| and Ndir = P' ^ direction (local normal direction)
// 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);
Vec 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);
}
XYZ OffsetDir = direction.XYZ();
XYZ Ndir = (V1.XYZ()).Crossed (OffsetDir);
XYZ DNdir = (V2.XYZ()).Crossed (OffsetDir);
XYZ D2Ndir = (V3.XYZ()).Crossed (OffsetDir);
XYZ D3Ndir = (V4.XYZ()).Crossed (OffsetDir);
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()) {
if (R6 <= gp::Resolution()) Geom_UndefinedDerivative::Raise();
// V3 = P"' (U) :
D3Ndir.Subtract (D2Ndir.Multiplied (3.0 * Dr / R2));
D3Ndir.Subtract (DNdir.Multiplied (3.0 * ((D2r/R2) + (Dr*Dr/R4))));
D3Ndir.Add (Ndir.Multiplied (6.0*Dr*Dr/R4 + 6.0*Dr*D2r/R4 -
15.0*Dr*Dr*Dr/R6 - D3r));
D3Ndir.Multiply (offsetValue/R);
V3.Add (Vec(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 (Vec(D2Ndir));
// V1 = P' (U) :
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (offsetValue/R2);
V1.Add (Vec(DNdir));
}
else {
// V3 = P"' (U) :
D3Ndir.Divide (R);
D3Ndir.Subtract (D2Ndir.Multiplied (3.0 * Dr / R3));
D3Ndir.Subtract (DNdir.Multiplied ((3.0 * ((D2r/R3) + (Dr*Dr)/R5))));
D3Ndir.Add (Ndir.Multiplied (6.0*Dr*Dr/R5 + 6.0*Dr*D2r/R5 -
15.0*Dr*Dr*Dr/R7 - D3r));
D3Ndir.Multiply (offsetValue);
V3.Add (Vec(D3Ndir));
// V2 = P" (U) :
D2Ndir.Divide (R);
D2Ndir.Subtract (DNdir.Multiplied (2.0 * Dr / R3));
D2Ndir.Subtract (Ndir.Multiplied ((3.0 * Dr * Dr / R5) - (D2r / R3)));
D2Ndir.Multiply (offsetValue);
V2.Add (Vec(D2Ndir));
// V1 = P' (U) :
DNdir.Multiply (offsetValue/R);
DNdir.Subtract (Ndir.Multiplied (offsetValue*Dr/R3));
V1.Add (Vec(DNdir));
}
//P (U) :
Ndir.Multiply (offsetValue/R);
Ndir.Add (P.XYZ());
P.SetXYZ (Ndir);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_OffsetCurve::DN (const Standard_Real U, const Standard_Integer N) const {
if (N < 1) Standard_RangeError::Raise();
XYZ OffsetDir = direction.XYZ();
Pnt P;
Vec V1, V2, dummy;
if (N == 1) {
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);
XYZ Ndir = (V1.XYZ()).Crossed (OffsetDir);
XYZ DNdir = (V2.XYZ()).Crossed (OffsetDir);
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()) {
if (R2 <= gp::Resolution()) Geom_UndefinedDerivative::Raise();
Ndir.Multiply (Dr/R);
DNdir.Multiply(R);
DNdir.Subtract (Ndir);
DNdir.Multiply (offsetValue/R2);
V1.Add (Vec(DNdir));
}
else {
Ndir.Multiply (offsetValue * Dr / R3);
DNdir.Multiply (offsetValue/R);
DNdir.Subtract (Ndir);
V1.Add (Vec(DNdir));
}
dummy = V1;
}
else if (N == 2) {
Vec 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);
}
XYZ Ndir = (V1.XYZ()).Crossed (OffsetDir);
XYZ DNdir = (V2.XYZ()).Crossed (OffsetDir);
XYZ D2Ndir = (V3.XYZ()).Crossed (OffsetDir);
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()) {
if (R4 <= gp::Resolution()) Geom_UndefinedDerivative::Raise();
Ndir.Multiply ((3.0 * Dr * Dr / R4) - (D2r/R2));
DNdir.Multiply (2.0 * Dr / R2);
D2Ndir.Subtract (DNdir);
D2Ndir.Subtract (Ndir);
D2Ndir.Multiply (offsetValue / R);
V2.Add (Vec(D2Ndir));
}
else {
Ndir.Multiply ((3.0 * Dr * Dr / R4) - (D2r / R2));
DNdir.Multiply (2.0 * Dr / R2);
D2Ndir.Divide (R);
D2Ndir.Subtract (DNdir);
D2Ndir.Subtract (Ndir);
D2Ndir.Multiply (offsetValue);
V2.Add (Vec(D2Ndir));
}
dummy = V2;
}
else if (N == 3) {
Vec V3;
basisCurve->D3 (U, P, V1, V2, V3);
Vec 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);
}
XYZ Ndir = (V1.XYZ()).Crossed (OffsetDir);
XYZ DNdir = (V2.XYZ()).Crossed (OffsetDir);
XYZ D2Ndir = (V3.XYZ()).Crossed (OffsetDir);
XYZ D3Ndir = (V4.XYZ()).Crossed (OffsetDir);
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()) {
if (R6 <= gp::Resolution()) Geom_UndefinedDerivative::Raise();
D2Ndir.Multiply (3.0 * Dr / R2);
DNdir.Multiply (3.0 * ((D2r/R2) + (Dr*Dr)/R4));
Ndir.Multiply (6.0*Dr*Dr/R4 + 6.0*Dr*D2r/R4 - 15.0*Dr*Dr*Dr/R6 - D3r);
D3Ndir.Subtract (D2Ndir);
D3Ndir.Subtract (DNdir);
D3Ndir.Add (Ndir);
D3Ndir.Multiply (offsetValue/R);
V3.Add (Vec(D3Ndir));
}
else {
D2Ndir.Multiply (3.0 * Dr / R3);
DNdir.Multiplied (3.0 * ((D2r/R3) + (Dr*Dr/R5)));
Ndir.Multiply (6.0*Dr*Dr/R5 + 6.0*Dr*D2r/R5 - 15.0*Dr*Dr*Dr/R7 - D3r);
D3Ndir.Divide (R);
D3Ndir.Subtract (D2Ndir);
D3Ndir.Subtract (DNdir);
D3Ndir.Add (Ndir);
D3Ndir.Multiply (offsetValue);
V3.Add (Vec(D3Ndir));
}
dummy = V3;
}
else { Standard_NotImplemented::Raise(); }
return dummy;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_OffsetCurve::D0(const Standard_Real U,
gp_Pnt& P,
gp_Pnt& Pbasis,
gp_Vec& V1basis)const
{
basisCurve->D1 (U, Pbasis, V1basis);
Standard_Integer Index = 2;
while (V1basis.Magnitude() <= gp::Resolution() && Index <= MaxDegree) {
V1basis = basisCurve->DN (U, Index);
Index++;
}
XYZ Ndir = (V1basis.XYZ()).Crossed (direction.XYZ());
Standard_Real R = Ndir.Modulus();
if (R <= gp::Resolution()) Geom_UndefinedValue::Raise();
Ndir.Multiply (offsetValue/R);
Ndir.Add (Pbasis.XYZ());
P.SetXYZ(Ndir);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_OffsetCurve::D1 ( const Standard_Real U,
Pnt& P , Pnt& PBasis ,
Vec& V1, Vec& V1basis, Vec& V2basis) const {
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ V|| and Ndir = P' ^ direction (local normal direction)
// 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;
Vec 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);
XYZ OffsetDir = direction.XYZ();
XYZ Ndir = (V1.XYZ()).Crossed (OffsetDir);
XYZ DNdir = (V2.XYZ()).Crossed (OffsetDir);
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()) Geom_UndefinedDerivative::Raise();
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (offsetValue/R2);
V1.Add (Vec(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 (Vec(DNdir));
}
Ndir.Multiply (offsetValue/R);
Ndir.Add (PBasis.XYZ());
P.SetXYZ (Ndir);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_OffsetCurve::D2 (const Standard_Real U,
Pnt& P , Pnt& PBasis ,
Vec& V1 , Vec& V2 ,
Vec& V1basis, Vec& V2basis, Vec& V3basis) const {
// P(u) = p(u) + Offset * Ndir / R
// with R = || p' ^ V|| and Ndir = P' ^ direction (local normal direction)
// 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;
Vec 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);
}
XYZ OffsetDir = direction.XYZ();
XYZ Ndir = (V1.XYZ()).Crossed (OffsetDir);
XYZ DNdir = (V2.XYZ()).Crossed (OffsetDir);
XYZ D2Ndir = (V3.XYZ()).Crossed (OffsetDir);
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()) Geom_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 (Vec(D2Ndir));
// V1 = P' (U) :
DNdir.Multiply(R);
DNdir.Subtract (Ndir.Multiplied (Dr/R));
DNdir.Multiply (offsetValue/R2);
V1.Add (Vec(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 (Vec(D2Ndir));
// V1 = P' (U) :
DNdir.Multiply (offsetValue/R);
DNdir.Subtract (Ndir.Multiplied (offsetValue*Dr/R3));
V1.Add (Vec(DNdir));
}
//P (U) :
Ndir.Multiply (offsetValue/R);
Ndir.Add (PBasis.XYZ());
P.SetXYZ (Ndir);
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom_OffsetCurve::FirstParameter () const {
return basisCurve->FirstParameter();
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom_OffsetCurve::LastParameter () const {
return basisCurve->LastParameter();
}
//=======================================================================
//function : Offset
//purpose :
//=======================================================================
Standard_Real Geom_OffsetCurve::Offset () const { return offsetValue; }
//=======================================================================
//function : Value
//purpose :
//=======================================================================
void Geom_OffsetCurve::Value (
const Standard_Real U, Pnt& P, Pnt& PBasis, Vec& V1basis) const {
if (basisCurve->Continuity() == GeomAbs_C0) Geom_UndefinedValue::Raise();
basisCurve->D1 (U, PBasis, V1basis);
Standard_Integer Index = 2;
while (V1basis.Magnitude() <= gp::Resolution() && Index <= MaxDegree) {
V1basis = basisCurve->DN (U, Index);
Index++;
}
XYZ Ndir = (V1basis.XYZ()).Crossed (direction.XYZ());
Standard_Real R = Ndir.Modulus();
if (R <= gp::Resolution()) Geom_UndefinedValue::Raise();
Ndir.Multiply (offsetValue/R);
Ndir.Add (PBasis.XYZ());
P.SetXYZ (Ndir);
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_OffsetCurve::IsClosed () const
{
gp_Pnt PF,PL;
D0(FirstParameter(),PF);
D0(LastParameter(),PL);
return ( PF.Distance(PL) <= gp::Resolution());
}
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom_OffsetCurve::IsCN (const Standard_Integer N) const {
Standard_RangeError_Raise_if (N < 0, " ");
return basisCurve->IsCN (N + 1);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_OffsetCurve::Transform (const Trsf& T) {
basisCurve->Transform (T);
direction.Transform(T);
offsetValue *= T.ScaleFactor();
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom_OffsetCurve::TransformedParameter(const Standard_Real U,
const gp_Trsf& T) const
{
return basisCurve->TransformedParameter(U,T);
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
Standard_Real Geom_OffsetCurve::ParametricTransformation(const gp_Trsf& T)
const
{
return basisCurve->ParametricTransformation(T);
}

483
src/Geom/Geom_OffsetSurface.cdl Executable file
View File

@@ -0,0 +1,483 @@
-- File: Geom_OffsetSurface.cdl
-- Created: Wed Mar 10 09:53:39 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
-- Modified: 18/11/96 : JPI : ajout methode Surface
class OffsetSurface from Geom inherits Surface from Geom
---Purpose : Describes an offset surface in 3D space.
-- An offset surface is defined by:
-- - the basis surface to which it is parallel, and
-- - the distance between the offset surface and its basis surface.
-- A point on the offset surface is built by measuring the
-- offset value along the normal vector at a point on the
-- basis surface. This normal vector is given by the cross
-- product D1u^D1v, where D1u and D1v are the
-- vectors tangential to the basis surface in the u and v
-- parametric directions at this point. The side of the
-- basis surface on which the offset is measured
-- depends on the sign of the offset value.
-- A Geom_OffsetSurface surface can be
-- self-intersecting, even if the basis surface does not
-- self-intersect. The self-intersecting portions are not
-- deleted at the time of construction.
-- Warning
-- There must be only one normal vector defined at any
-- point on the basis surface. This must be verified by the
-- user as no check is made at the time of construction
-- to detect points with multiple possible normal
-- directions (for example, the top of a conical surface).
uses Pnt from gp,
Trsf from gp,
GTrsf2d from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom,
BSplineSurface from Geom,
Shape from GeomAbs,
Surface from Geom,
SequenceOfBSplineSurface from Geom,
OsculatingSurface from Geom
-- Array1OfBoolean from TColStd
raises ConstructionError from Standard,
RangeError from Standard,
NoSuchObject from Standard,
UndefinedDerivative from Geom,
UndefinedValue from Geom
is
Create (S : Surface from Geom; Offset : Real) returns mutable OffsetSurface
---Purpose : Constructs a surface offset from the basis surface
-- S, where Offset is the distance between the offset
-- surface and the basis surface at any point.
-- A point on the offset surface is built by measuring
-- the offset value along a normal vector at a point on
-- S. This normal vector is given by the cross product
-- D1u^D1v, where D1u and D1v are the vectors
-- tangential to the basis surface in the u and v
-- parametric directions at this point. The side of S on
-- which the offset value is measured is indicated by
-- this normal vector if Offset is positive, or is the
-- inverse sense if Offset is negative.
-- Warnings :
-- - The offset surface is built with a copy of the
-- surface S. Therefore, when S is modified the
-- offset surface is not modified.
-- - No check is made at the time of construction to
-- detect points on S with multiple possible normal directions.
raises ConstructionError;
---Purpose : Raised if S is not at least C1.
-- Warnings :
-- No check is done to verify that a unique normal direction is
-- defined at any point of the basis surface S.
SetBasisSurface (me : mutable; S : Surface from Geom)
raises ConstructionError;
---Purpose : Raised if S is not at least C1.
-- Warnings :
-- No check is done to verify that a unique normal direction is
-- defined at any point of the basis surface S.
-- Exceptions
-- Standard_ConstructionError if the surface S is not
-- at least "C1" continuous.
SetOffsetValue (me : mutable; D : Real);
---Purpose: Changes this offset surface by assigning D as the offset value.
Offset (me) returns Real;
---Purpose: Returns the offset value of this offset surface.
BasisSurface (me) returns Surface from Geom;
--- Purpose: Returns the basis surface of this offset surface.
-- Note: The basis surface can be an offset surface.
UReverse (me : mutable);
---Purpose : Changes the orientation of this offset surface in the u
-- parametric direction. The bounds of the surface
-- are not changed but the given parametric direction is reversed.
UReversedParameter (me; U : Real) returns Real;
---Purpose: Computes the u parameter on the modified
-- surface, produced by reversing the u
-- parametric direction of this offset surface, for any
-- point of u parameter U on this offset surface.
VReverse (me : mutable);
---Purpose : Changes the orientation of this offset surface in the v parametric direction. The bounds of the surface
-- are not changed but the given parametric direction is reversed.
VReversedParameter (me; V : Real) returns Real;
---Purpose: Computes the v parameter on the modified
-- surface, produced by reversing the or v
-- parametric direction of this offset surface, for any
-- point of v parameter V on this offset surface.
Bounds (me; U1, U2, V1, V2 : out Real);
---Purpose : Returns the parametric bounds U1, U2, V1 and V2 of
-- this offset surface.
-- If the surface is infinite, this function can return:
-- - Standard_Real::RealFirst(), or
-- - Standard_Real::RealLast().
Continuity (me) returns Shape from GeomAbs;
---Purpose :
-- This method returns the continuity of the basis surface - 1.
-- Continuity of the Offset surface :
-- C0 : only geometric continuity,
-- C1 : continuity of the first derivative all along the Surface,
-- C2 : continuity of the second derivative all along the Surface,
-- C3 : continuity of the third derivative all along the Surface,
-- CN : the order of continuity is infinite.
-- Example :
-- If the basis surface is C2 in the V direction and C3 in the U
-- direction Shape = C1.
-- Warnings :
-- If the basis surface has a unique normal direction defined at
-- any point this method gives the continuity of the offset
-- surface otherwise the effective continuity can be lower than
-- the continuity of the basis surface - 1.
IsCNu(me; N : Integer) returns Boolean
---Purpose :
-- This method answer True if the continuity of the basis surface
-- is N + 1 in the U parametric direction. We suppose in this
-- class that a unique normal is defined at any point on the basis
-- surface.
raises RangeError;
---Purpose : Raised if N <0.
IsCNv (me; N : Integer) returns Boolean
---Purpose :
-- This method answer True if the continuity of the basis surface
-- is N + 1 in the V parametric direction. We suppose in this
-- class that a unique normal is defined at any point on the basis
-- surface.
raises RangeError;
---Purpose : Raised if N <0.
IsUClosed (me) returns Boolean;
---Purpose: Checks whether this offset surface is closed in the u
-- parametric direction.
-- Returns true if, taking uFirst and uLast as
-- the parametric bounds in the u parametric direction,
-- the distance between the points P(uFirst,v)
-- and P(uLast,v) is less than or equal to
-- gp::Resolution() for each value of the parameter v.
IsVClosed (me) returns Boolean;
---Purpose: Checks whether this offset surface is closed in the u
-- or v parametric direction. Returns true if taking vFirst and vLast as the
-- parametric bounds in the v parametric direction, the
-- distance between the points P(u,vFirst) and
-- P(u,vLast) is less than or equal to
-- gp::Resolution() for each value of the parameter u.
IsUPeriodic (me) returns Boolean;
---Purpose:
-- Returns true if this offset surface is periodic in the u
-- parametric direction, i.e. if the basis
-- surface of this offset surface is periodic in this direction.
UPeriod (me) returns Real from Standard
---Purpose: Returns the period of this offset surface in the u
-- parametric direction respectively, i.e. the period of the
-- basis surface of this offset surface in this parametric direction.
raises
NoSuchObject from Standard
---Purpose: raises if the surface is not uperiodic.
is redefined;
IsVPeriodic (me) returns Boolean;
---Purpose:
-- Returns true if this offset surface is periodic in the v
-- parametric direction, i.e. if the basis
-- surface of this offset surface is periodic in this direction.
VPeriod (me) returns Real from Standard
---Purpose: Returns the period of this offset surface in the v
-- parametric direction respectively, i.e. the period of the
-- basis surface of this offset surface in this parametric direction.
raises
NoSuchObject from Standard
---Purpose: raises if the surface is not vperiodic.
is redefined;
UIso (me; U : Real) returns mutable Curve;
---Purpose : Computes the U isoparametric curve.
VIso (me; V : Real) returns mutable Curve;
---Purpose : Computes the V isoparametric curve.
---Purpose :
-- Te followings methods compute value and derivatives.
--
--- Warnings
-- An exception is raised if a unique normal vector is
-- not defined on the basis surface for the parametric
-- value (U,V).
-- No check is done at the creation time and we suppose
-- in this package that the offset surface can be defined
-- at any point.
D0 (me; U, V : Real; P : out Pnt)
---Purpose :
-- P (U, V) = Pbasis + Offset * Ndir where
-- Ndir = D1Ubasis ^ D1Vbasis / ||D1Ubasis ^ D1Vbasis|| is the
-- normal direction of the basis surface. Pbasis, D1Ubasis,
-- D1Vbasis are the point and the first derivatives on the basis
-- surface.
-- If Ndir is undefined this method computes an approched normal
-- direction using the following limited development :
-- Ndir = N0 + DNdir/DU + DNdir/DV + Eps with Eps->0 which
-- requires to compute the second derivatives on the basis surface.
-- If the normal direction cannot be approximate for this order
-- of derivation the exception UndefinedValue is raised.
raises UndefinedValue;
---Purpose :
-- Raised if the continuity of the basis surface is not C1.
-- Raised if the order of derivation required to compute the
-- normal direction is greater than the second order.
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec)
raises UndefinedDerivative;
---Purpose :
-- Raised if the continuity of the basis surface is not C2.
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec)
raises UndefinedDerivative;
---Purpose ;
-- Raised if the continuity of the basis surface is not C3.
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV : out Vec)
raises UndefinedDerivative;
---Purpose :
-- Raised if the continuity of the basis surface is not C4.
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
---Purpose :
-- Computes the derivative of order Nu in the direction u and Nv
-- in the direction v.
raises UndefinedDerivative,
---Purpose ;
-- Raised if the continuity of the basis surface is not CNu + 1
-- in the U direction and CNv + 1 in the V direction.
RangeError;
---Purpose : Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
---Purpose :
-- The following methods compute the value and derivatives
-- on the offset surface and returns the derivatives on the
-- basis surface too.
-- The computation of the value and derivatives on the basis
-- surface are used to evaluate the offset surface.
--
-- Warnings :
-- The exception UndefinedValue or UndefinedDerivative is
-- raised if it is not possible to compute a unique offset
-- direction.
Value(me; U, V : Real; P, Pbasis : out Pnt; D1Ubasis, D1Vbasis : out Vec)
---Purpose :
-- P (U, V) = Pbasis + Offset * Ndir where
-- Ndir = D1Ubasis ^ D1Vbasis / ||D1Ubasis ^ D1Vbasis|| is
-- the normal direction of the surface.
-- If Ndir is undefined this method computes an approched normal
-- direction using the following limited development :
-- Ndir = N0 + DNdir/DU + DNdir/DV + Eps with Eps->0 which
-- requires to compute the second derivatives on the basis surface.
-- If the normal direction cannot be approximate for this order
-- of derivation the exception UndefinedValue is raised.
raises UndefinedValue;
---Purpose :
-- Raised if the continuity of the basis surface is not C1.
-- Raised if the order of derivation required to compute the normal
-- direction is greater than the second order.
D1 (me; U, V : Real; P, Pbasis : out Pnt; D1U, D1V, D1Ubasis, D1Vbasis,
D2Ubasis, D2Vbasis, D2UVbasis : out Vec)
raises UndefinedDerivative;
---Purpose :
-- Raised if the continuity of the basis surface is not C2.
D2 (me; U, V : Real; P, Pbasis : out Pnt; D1U, D1V, D2U, D2V, D2UV,
D1Ubasis, D1Vbasis, D2Ubasis, D2Vbasis, D2UVbasis, D3Ubasis, D3Vbasis,
D3UUVbasis, D3UVVbasis : out Vec)
raises UndefinedDerivative;
---Purpose :
-- Raised if the continuity of the basis surface is not C3.
---Purpose : The following private methods
-- includes common part of local and global methods
-- of derivative evaluations.
SetD0 (me; U, V : Real; P : out Pnt; D1U, D1V : Vec)
raises UndefinedDerivative
is private;
SetD1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec;
d2u,d2v,d2uv : Vec)
raises UndefinedDerivative
is private;
SetD2 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV : out Vec;
d3u,d3v,d3uuv,d3uvv : Vec )
raises UndefinedDerivative
is private;
SetD3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV : out Vec)
raises UndefinedDerivative
is private;
SetDN(me; U, V : Real; Nu, Nv : Integer;
D1U, D1V : Vec)
returns Vec
is private;
---Purpose : The following functions evaluates the local
-- derivatives on surface. Useful to manage discontinuities
-- on the surface.
-- if Side = 1 -> P = S( U+,V )
-- if Side = -1 -> P = S( U-,V )
-- else P is betveen discontinuities
-- can be evaluated using methods of
-- global evaluations P = S( U ,V )
LocalD0 (me; U, V : Real; USide, VSide : Integer;
P : out Pnt);
LocalD1 (me; U, V : Real; USide, VSide : Integer;
P : out Pnt; D1U, D1V : out Vec);
LocalD2 (me; U, V : Real; USide, VSide : Integer;
P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec);
LocalD3 (me; U, V : Real; USide, VSide : Integer;
P : out Pnt; D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV :
out Vec);
LocalDN (me; U, V : Real; USide, VSide : Integer;
Nu, Nv : Integer)
returns Vec;
LocateSides(me ; U,V : Real; USide, VSide : Integer ;
BSplS : BSplineSurface from Geom;
NDir : Integer ; P : out Pnt ;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV : out Vec )
---Purpose: This method locates U,V parameters on basis BSpline surface
-- and calls LocalDi or Di methods corresponding an order
-- of derivative and position
-- of UV-point relatively the surface discontinuities.
is private ;
Transform (me : mutable; T : Trsf);
--- Purpose:
-- Applies the transformation T to this offset surface.
-- Note: the basis surface is also modified.
TransformParameters(me; U,V : in out Real; T : Trsf from gp)
---Purpose: Computes the parameters on the transformed surface for
-- the transform of the point of parameters U,V on <me>.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are the new values of U,V after calling
--
-- me->TranformParameters(U,V,T)
-- This methods calls the basis surface method.
is redefined;
ParametricTransformation(me; T : Trsf from gp) returns GTrsf2d from gp
---Purpose: Returns a 2d transformation used to find the new
-- parameters of a point on the transformed surface.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are obtained by transforming U,V with
-- th 2d transformation returned by
--
-- me->ParametricTransformation(T)
--
-- This methods calls the basis surface method.
is redefined;
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this offset surface.
Surface (me) returns mutable Surface from Geom;
---Purpose: returns an equivalent surface of the offset surface
-- when the basis surface is a canonic surface or a
-- rectangular limited surface on canonic surface or if
-- the offset is null.
UOsculatingSurface (me ; U,V : Real ; IsOpposite : out Boolean from Standard
; UOsculSurf : out BSplineSurface from Geom)
---Purpose: if Standard_True, L is the local osculating surface
-- along U at the point U,V. It means that DL/DU is
-- collinear to DS/DU . If IsOpposite == Standard_True
-- these vectors have opposite direction.
--
returns Boolean from Standard;
VOsculatingSurface (me ; U,V : Real ; IsOpposite : out Boolean from Standard
; VOsculSurf : out BSplineSurface from Geom)
---Purpose: if Standard_True, L is the local osculating surface
-- along V at the point U,V.
-- It means that DL/DV is
-- collinear to DS/DV . If IsOpposite == Standard_True
-- these vectors have opposite direction.
returns Boolean from Standard;
fields
basisSurf : Surface from Geom;
equivSurf : Surface from Geom;
offsetValue : Real;
myOscSurf : OsculatingSurface from Geom;
end;

1885
src/Geom/Geom_OffsetSurface.cxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,106 @@
-- File: Geom_OsculatingSurface.cdl
-- Created: Tue May 5 09:20:47 1998
-- Author: Stepan MISHIN
-- <smn@sgi30>
---Copyright: Matra Datavision 1998
private class OsculatingSurface from Geom
---Purpose:
uses Surface from Geom,
SequenceOfReal from TColStd,
SequenceOfBSplineSurface from Geom,
HSequenceOfBSplineSurface from Geom,
Array1OfBoolean from TColStd,
IsoType from GeomAbs,
BSplineSurface from Geom,
HSequenceOfInteger from TColStd
is
Create returns OsculatingSurface from Geom;
Create (BS : Surface from Geom; Tol: Real from Standard)
returns OsculatingSurface from Geom;
--- Purpose : detects if the surface has punctual U or V
-- isoparametric curve along on the bounds of the surface
-- relativly to the tolerance Tol and Builds the corresponding
-- osculating surfaces.
Init(me: in out; BS : Surface from Geom; Tol: Real from Standard)
is static;
BasisSurface (me) returns Surface from Geom
is static;
Tolerance (me) returns Real from Standard
is static;
UOscSurf (me ; U,V : Real ; t : out Boolean from Standard;
L : out BSplineSurface from Geom)
---Purpose: if Standard_True, L is the local osculating surface
-- along U at the point U,V.
returns Boolean from Standard
is static;
VOscSurf (me ; U,V : Real ; t : out Boolean from Standard;
L : out BSplineSurface from Geom)
---Purpose: if Standard_True, L is the local osculating surface
-- along V at the point U,V.
returns Boolean from Standard
is static;
BuildOsculatingSurface (me ; Param : Real;
UKnot,VKnot : Integer;
BS : BSplineSurface from Geom ;
L : out mutable BSplineSurface from Geom)
---Purpose: returns False if the osculating surface can't be built
--
returns Boolean from Standard
is private;
IsQPunctual(me ; S : Surface from Geom;
Param : Real from Standard;
IT : IsoType from GeomAbs;
TolMin,TolMax: Real from Standard)
---Purpose: returns True if the isoparametric is
-- quasi-punctual
returns Boolean from Standard
is private;
HasOscSurf (me) returns Boolean from Standard
is private;
IsAlongU (me) returns Boolean from Standard is private;
IsAlongV (me) returns Boolean from Standard is private;
ClearOsculFlags (me: in out)
is private ;
GetSeqOfL1 (me) returns SequenceOfBSplineSurface from Geom
is private;
---C++: return const&
GetSeqOfL2 (me) returns SequenceOfBSplineSurface from Geom
is private;
---C++: return const&
fields
myBasisSurf : Surface from Geom;
myTol : Real from Standard;
myOsculSurf1 : HSequenceOfBSplineSurface from Geom;
myOsculSurf2 : HSequenceOfBSplineSurface from Geom;
myKdeg : HSequenceOfInteger from TColStd;
-- myKdeg2 : SequenceOfInteger from TColStd;
myAlong : Array1OfBoolean from TColStd;
end OsculatingSurface;

View File

@@ -0,0 +1,762 @@
#include <Geom_OsculatingSurface.ixx>
#include <Geom_BezierSurface.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColgp_HArray2OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_HArray2OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array2OfVec.hxx>
#include <BSplSLib.hxx>
#include <Convert_GridPolynomialToPoles.hxx>
#include <Precision.hxx>
#include <PLib.hxx>
//=======================================================================
//function : Geom_OffsetOsculatingSurface
//purpose :
//=======================================================================
Geom_OsculatingSurface::Geom_OsculatingSurface()
: myAlong(1,4)
{
}
//=======================================================================
//function : Geom_OffsetOsculatingSurface
//purpose :
//=======================================================================
Geom_OsculatingSurface::Geom_OsculatingSurface(const Handle(Geom_Surface)& BS,
const Standard_Real Tol)
: myAlong(1,4)
{
Init(BS,Tol);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
const Standard_Real Tol)
{
ClearOsculFlags();
myTol=Tol;
Standard_Real TolMin=1.e-12;
Standard_Boolean OsculSurf = Standard_True;
myBasisSurf = Handle(Geom_Surface)::DownCast(BS->Copy());
myOsculSurf1 = new Geom_HSequenceOfBSplineSurface();
myOsculSurf2 = new Geom_HSequenceOfBSplineSurface();
if ((BS->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) ||
(BS->IsKind(STANDARD_TYPE(Geom_BezierSurface))))
{
Standard_Real U1=0,U2=0,V1=0,V2=0;
Standard_Integer i = 1;
BS->Bounds(U1,U2,V1,V2);
myAlong.SetValue(1,IsQPunctual(BS,V1,GeomAbs_IsoV,TolMin,Tol));
myAlong.SetValue(2,IsQPunctual(BS,V2,GeomAbs_IsoV,TolMin,Tol));
myAlong.SetValue(3,IsQPunctual(BS,U1,GeomAbs_IsoU,TolMin,Tol));
myAlong.SetValue(4,IsQPunctual(BS,U2,GeomAbs_IsoU,TolMin,Tol));
#ifdef DEB
cout<<myAlong(1)<<endl<<myAlong(2)<<endl<<myAlong(3)<<endl<<myAlong(4)<<endl;
#endif
if (myAlong(1) || myAlong(2) || myAlong(3) || myAlong(4))
{
Handle(Geom_BSplineSurface) InitSurf, L,S;
if (BS->IsKind(STANDARD_TYPE(Geom_BezierSurface)))
{
Handle(Geom_BezierSurface) BzS = Handle(Geom_BezierSurface)::DownCast(BS);
TColgp_Array2OfPnt P(1,BzS->NbUPoles(),1,BzS->NbVPoles());
TColStd_Array1OfReal UKnots(1,2);
TColStd_Array1OfReal VKnots(1,2);
TColStd_Array1OfInteger UMults(1,2);
TColStd_Array1OfInteger VMults(1,2);
for (i=1;i<=2;i++)
{
UKnots.SetValue(i,(i-1));
VKnots.SetValue(i,(i-1));
UMults.SetValue(i,BzS->UDegree()+1);
VMults.SetValue(i,BzS->VDegree()+1);
}
BzS->Poles(P);
InitSurf = new Geom_BSplineSurface(P,UKnots,VKnots,
UMults,VMults,
BzS->UDegree(),
BzS->VDegree(),
BzS->IsUPeriodic(),
BzS->IsVPeriodic());
}
else
{
InitSurf = Handle(Geom_BSplineSurface)::DownCast(myBasisSurf);
}
#ifdef DEB
cout<<"UDEG: "<<InitSurf->UDegree()<<endl;
cout<<"VDEG: "<<InitSurf->VDegree()<<endl;
#endif
if(IsAlongU() && IsAlongV()) ClearOsculFlags();
// Standard_ConstructionError_Raise_if((IsAlongU() && IsAlongV()),"Geom_OsculatingSurface");
if ((IsAlongU() && InitSurf->VDegree()>1) ||
(IsAlongV() && InitSurf->UDegree()>1))
{
myKdeg = new TColStd_HSequenceOfInteger();
Standard_Integer k=0;
Standard_Boolean IsQPunc;
Standard_Integer UKnot,VKnot;
if (myAlong(1) || myAlong(2))
{
for (i=1;i<InitSurf->NbUKnots();i++)
{
if (myAlong(1))
{
S = InitSurf; k=0; IsQPunc=Standard_True;
UKnot=i;
VKnot=1;
while(IsQPunc)
{
OsculSurf = BuildOsculatingSurface(V1,UKnot,VKnot,S,L);
if(!OsculSurf) break;
k++;
#ifdef DEB
cout<<"1.k = "<<k<<endl;
#endif
IsQPunc=IsQPunctual(L,V1,GeomAbs_IsoV,0.,Tol);
UKnot=1;
VKnot=1;
S=L;
}
if (OsculSurf)
myOsculSurf1->Append(L);
else
ClearOsculFlags(); //myAlong.SetValue(1,Standard_False);
if (myAlong(2) && OsculSurf)
{
S = InitSurf; k=0; IsQPunc=Standard_True;
UKnot=i;
VKnot=InitSurf->NbVKnots()-1;
while(IsQPunc)
{
OsculSurf = BuildOsculatingSurface(V2,UKnot,VKnot,S,L);
if(!OsculSurf) break;
k++;
#ifdef DEB
cout<<"2.k = "<<k<<endl;
#endif
IsQPunc=IsQPunctual(L,V2,GeomAbs_IsoV,0.,Tol);
UKnot=1;
VKnot=1;
S=L;
}
if(OsculSurf)
{
myOsculSurf2->Append(L);
myKdeg->Append(k);
}
}
}
else
//if (myAlong(2))
{
S = InitSurf; k=0; IsQPunc=Standard_True;
UKnot=i;
VKnot=InitSurf->NbVKnots()-1;
while(IsQPunc)
{
OsculSurf = BuildOsculatingSurface(V2,UKnot,VKnot,S,L);
if(!OsculSurf) break;
k++;
#ifdef DEB
cout<<"2.k = "<<k<<endl;
#endif
IsQPunc=IsQPunctual(L,V2,GeomAbs_IsoV,0.,Tol);
UKnot=1;
VKnot=1;
S=L;
}
if(OsculSurf)
{
myOsculSurf2->Append(L);
myKdeg->Append(k);
}
else
ClearOsculFlags(); //myAlong.SetValue(2,Standard_False);
}
}
}
if (myAlong(3) || myAlong(4))
{
for (i=1;i<InitSurf->NbVKnots();i++)
{
if (myAlong(3))
{
S = InitSurf; k=0; IsQPunc=Standard_True;
UKnot=1;
VKnot=i;
while(IsQPunc)
{
OsculSurf = BuildOsculatingSurface(U1,UKnot,VKnot,S,L);
if(!OsculSurf) break;
k++;
#ifdef DEB
cout<<"1.k = "<<k<<endl;
#endif
IsQPunc=IsQPunctual(L,U1,GeomAbs_IsoU,0.,Tol);
UKnot=1;
VKnot=1;
S=L;
}
if(OsculSurf)
myOsculSurf1->Append(L);
else
ClearOsculFlags(); //myAlong.SetValue(3,Standard_False);
if (myAlong(4) && OsculSurf )
{
S = InitSurf; k=0; IsQPunc=Standard_True;
UKnot=InitSurf->NbUKnots()-1;
VKnot=i;
while(IsQPunc)
{
OsculSurf = BuildOsculatingSurface(U2,UKnot,VKnot,S,L);
if(!OsculSurf) break;
k++;
#ifdef DEB
cout<<"2.k = "<<k<<endl;
#endif
IsQPunc=IsQPunctual(L,U2,GeomAbs_IsoU,0.,Tol);
UKnot=1;
VKnot=1;
S=L;
}
if(OsculSurf)
{
myOsculSurf2->Append(L);
myKdeg->Append(k);
}
}
}
else
{
S = InitSurf; k=0; IsQPunc=Standard_True;
UKnot=InitSurf->NbUKnots()-1;
VKnot=i;
while(IsQPunc)
{
OsculSurf = BuildOsculatingSurface(U2,UKnot,VKnot,S,L);
if(!OsculSurf) break;
k++;
#ifdef DEB
cout<<"2.k = "<<k<<endl;
#endif
IsQPunc=IsQPunctual(L,U2,GeomAbs_IsoU,0.,Tol);
UKnot=1;
VKnot=1;
S=L;
}
if(OsculSurf)
{
myOsculSurf2->Append(L);
myKdeg->Append(k);
}
else
ClearOsculFlags(); //myAlong.SetValue(4,Standard_False);
}
}
}
}
else
{
ClearOsculFlags();
}
}
}
else
ClearOsculFlags();
}
//=======================================================================
//function : BasisSurface
//purpose :
//=======================================================================
Handle(Geom_Surface) Geom_OsculatingSurface::BasisSurface() const
{
return myBasisSurf;
}
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
Standard_Real Geom_OsculatingSurface::Tolerance() const
{
return myTol;
}
//=======================================================================
//function : UOscSurf
//purpose :
//=======================================================================
Standard_Boolean Geom_OsculatingSurface::UOscSurf
(const Standard_Real U,
const Standard_Real V,
Standard_Boolean& t,
Handle(Geom_BSplineSurface)& L) const
{
Standard_Boolean along = Standard_False;
if (myAlong(1) || myAlong(2))
{
Standard_Integer NU = 1, NV = 1;
Standard_Real u1,u2,v1,v2;
t = Standard_False;
myBasisSurf->Bounds(u1,u2,v1,v2);
Standard_Integer NbUK,NbVK;
Standard_Boolean isToSkipSecond = Standard_False;
if (myBasisSurf->IsKind(STANDARD_TYPE(Geom_BSplineSurface)))
{
Handle(Geom_BSplineSurface) BSur =
*((Handle(Geom_BSplineSurface)*)& myBasisSurf);
NbUK = BSur->NbUKnots();
NbVK = BSur->NbVKnots();
TColStd_Array1OfReal UKnots(1,NbUK);
TColStd_Array1OfReal VKnots(1,NbVK);
BSur->UKnots(UKnots);
BSur->VKnots(VKnots);
BSplCLib::Hunt(UKnots,U,NU);
BSplCLib::Hunt(VKnots,V,NV);
if (NU < 1) NU=1;
if (NU >= NbUK) NU=NbUK-1;
if (NbVK==2 && NV==1)
// Need to find the closest end
if (VKnots(NbVK)-V > V-VKnots(1))
isToSkipSecond = Standard_True;
}
else {NU = 1; NV = 1 ; NbVK = 2 ;}
if (myAlong(1) && NV == 1)
{
L = *((Handle(Geom_BSplineSurface)*)& myOsculSurf1->Value(NU));
along = Standard_True;
}
if (myAlong(2) && (NV == NbVK-1) && !isToSkipSecond)
{
// t means that derivative vector of osculating surface is opposite
// to the original. This happens when (v-t)^k is negative, i.e.
// difference between degrees (k) is odd and t is the last parameter
if (myKdeg->Value(NU)%2) t = Standard_True;
L = *((Handle(Geom_BSplineSurface)*)& myOsculSurf2->Value(NU));
along = Standard_True;
}
}
return along;
}
//=======================================================================
//function : VOscSurf
//purpose :
//=======================================================================
Standard_Boolean Geom_OsculatingSurface::VOscSurf
(const Standard_Real U,
const Standard_Real V,
Standard_Boolean& t,
Handle(Geom_BSplineSurface)& L) const
{
Standard_Boolean along = Standard_False;
if (myAlong(3) || myAlong(4))
{
Standard_Integer NU = 1, NV = 1;
Standard_Real u1,u2,v1,v2;
t = Standard_False;
myBasisSurf->Bounds(u1,u2,v1,v2);
Standard_Integer NbUK,NbVK;
Standard_Boolean isToSkipSecond = Standard_False;
if (myBasisSurf->IsKind(STANDARD_TYPE(Geom_BSplineSurface)))
{
Handle(Geom_BSplineSurface) BSur =
*((Handle(Geom_BSplineSurface)*)& myBasisSurf);
NbUK = BSur->NbUKnots();
NbVK = BSur->NbVKnots();
TColStd_Array1OfReal UKnots(1,NbUK);
TColStd_Array1OfReal VKnots(1,NbVK);
BSur->UKnots(UKnots);
BSur->VKnots(VKnots);
BSplCLib::Hunt(UKnots,U,NU);
BSplCLib::Hunt(VKnots,V,NV);
if (NV < 1) NV=1;
if (NV >= NbVK) NV=NbVK-1;
if (NbUK==2 && NU==1)
// Need to find the closest end
if (UKnots(NbUK)-U > U-UKnots(1))
isToSkipSecond = Standard_True;
}
else {NU = 1; NV = 1 ; NbUK = 2;}
if (myAlong(3) && NU == 1)
{
L = *((Handle(Geom_BSplineSurface)*)& myOsculSurf1->Value(NV));
along = Standard_True;
}
if (myAlong(4) && (NU == NbUK-1) && !isToSkipSecond)
{
if (myKdeg->Value(NV)%2) t = Standard_True;
L = *((Handle(Geom_BSplineSurface)*)& myOsculSurf2->Value(NV));
along = Standard_True;
}
}
return along;
}
//=======================================================================
//function : BuildOsculatingSurface
//purpose :
//=======================================================================
Standard_Boolean Geom_OsculatingSurface::BuildOsculatingSurface
(const Standard_Real Param,
const Standard_Integer SUKnot,
const Standard_Integer SVKnot,
const Handle(Geom_BSplineSurface)& BS,
Handle(Geom_BSplineSurface)& BSpl) const
{
Standard_Integer i, j;
Standard_Boolean OsculSurf=Standard_True;
#ifdef DEB
cout<<"t = "<<Param<<endl;
cout<<"======================================"<<endl<<endl;
#endif
// for cache
Standard_Integer MinDegree,
MaxDegree ;
Standard_Real udeg, vdeg;
udeg = BS->UDegree();
vdeg = BS->VDegree();
if( (IsAlongU() && vdeg <=1) || (IsAlongV() && udeg <=1))
{
#ifdef DEB
cout<<" surface osculatrice nulle "<<endl;
#endif
//Standard_ConstructionError::Raise("Geom_OsculatingSurface");
OsculSurf=Standard_False;
}
else
{
MinDegree = (Standard_Integer ) Min(udeg,vdeg) ;
MaxDegree = (Standard_Integer ) Max(udeg,vdeg) ;
TColgp_Array2OfPnt cachepoles(1, MaxDegree + 1, 1, MinDegree + 1);
// end for cache
// for polynomial grid
Standard_Integer MaxUDegree, MaxVDegree;
Standard_Integer UContinuity, VContinuity;
Handle(TColStd_HArray2OfInteger) NumCoeffPerSurface =
new TColStd_HArray2OfInteger(1, 1, 1, 2);
Handle(TColStd_HArray1OfReal) PolynomialUIntervals =
new TColStd_HArray1OfReal(1, 2);
Handle(TColStd_HArray1OfReal) PolynomialVIntervals =
new TColStd_HArray1OfReal(1, 2);
Handle(TColStd_HArray1OfReal) TrueUIntervals =
new TColStd_HArray1OfReal(1, 2);
Handle(TColStd_HArray1OfReal) TrueVIntervals =
new TColStd_HArray1OfReal(1, 2);
MaxUDegree = (Standard_Integer ) udeg;
MaxVDegree = (Standard_Integer ) vdeg;
for (i=1;i<=2;i++)
{
PolynomialUIntervals->ChangeValue(i) = i-1;
PolynomialVIntervals->ChangeValue(i) = i-1;
TrueUIntervals->ChangeValue(i) = BS->UKnot(SUKnot+i-1);
TrueVIntervals->ChangeValue(i) = BS->VKnot(SVKnot+i-1);
}
Standard_Integer OscUNumCoeff=0, OscVNumCoeff=0;
if (IsAlongU())
{
#ifdef DEB
cout<<">>>>>>>>>>> AlongU"<<endl;
#endif
OscUNumCoeff = (Standard_Integer ) udeg + 1;
OscVNumCoeff = (Standard_Integer ) vdeg;
}
if (IsAlongV())
{
#ifdef DEB
cout<<">>>>>>>>>>> AlongV"<<endl;
#endif
OscUNumCoeff = (Standard_Integer ) udeg;
OscVNumCoeff = (Standard_Integer ) vdeg + 1;
}
NumCoeffPerSurface->ChangeValue(1,1) = OscUNumCoeff;
NumCoeffPerSurface->ChangeValue(1,2) = OscVNumCoeff;
Handle(TColStd_HArray1OfReal) Coefficients = new TColStd_HArray1OfReal(1,
NumCoeffPerSurface->Value(1,1)*NumCoeffPerSurface->Value(1,2)*3);
// end for polynomial grid
// building the cache
Standard_Integer ULocalIndex, VLocalIndex;
Standard_Real ucacheparameter, vcacheparameter,uspanlength, vspanlength;
TColgp_Array2OfPnt NewPoles(1, BS->NbUPoles(), 1, BS->NbVPoles());
TColStd_Array1OfReal UFlatKnots(1, BS->NbUPoles() + BS->UDegree() + 1);
TColStd_Array1OfReal VFlatKnots(1, BS->NbVPoles() + BS->VDegree() + 1);
BS->Poles(NewPoles);
BS->UKnotSequence(UFlatKnots);
BS->VKnotSequence(VFlatKnots);
VLocalIndex = 0;
ULocalIndex = 0;
for(j = 1; j <= SVKnot; j++) VLocalIndex += BS->VMultiplicity(j);
for(i = 1; i <= SUKnot; i++) ULocalIndex += BS->UMultiplicity(i);
ucacheparameter = BS->UKnot(SUKnot);
vcacheparameter = BS->VKnot(SVKnot);
vspanlength = BS->VKnot(SVKnot + 1) - BS->VKnot(SVKnot);
uspanlength = BS->UKnot(SUKnot + 1) - BS->UKnot(SUKnot);
// On se ramene toujours a un parametrage tel que localement ce soit l'iso
// u=0 ou v=0 qui soit degeneree
Standard_Boolean IsVNegative = Param > vcacheparameter + vspanlength/2;
Standard_Boolean IsUNegative = Param > ucacheparameter + uspanlength/2;
if (IsAlongU() && (Param > vcacheparameter + vspanlength/2))
vcacheparameter = vcacheparameter + vspanlength;
if (IsAlongV() && (Param > ucacheparameter + uspanlength/2))
ucacheparameter = ucacheparameter + uspanlength;
BSplSLib::BuildCache(ucacheparameter,
vcacheparameter,
uspanlength,
vspanlength,
BS->IsUPeriodic(),
BS->IsVPeriodic(),
BS->UDegree(),
BS->VDegree(),
ULocalIndex,
VLocalIndex,
UFlatKnots,
VFlatKnots,
NewPoles,
BSplSLib::NoWeights(),
cachepoles,
BSplSLib::NoWeights());
Standard_Integer m, n, index;
TColgp_Array2OfPnt OscCoeff(1,OscUNumCoeff , 1, OscVNumCoeff);
if (IsAlongU())
{
if (udeg > vdeg)
{
for(n = 1; n <= udeg + 1; n++)
for(m = 1; m <= vdeg; m++)
OscCoeff(n,m) = cachepoles(n,m+1) ;
}
else
{
for(n = 1; n <= udeg + 1; n++)
for(m = 1; m <= vdeg; m++)
OscCoeff(n,m) = cachepoles(m+1,n) ;
}
if (IsVNegative) PLib::VTrimming(-1,0,OscCoeff,PLib::NoWeights2());
index=1;
for(n = 1; n <= udeg + 1; n++)
for(m = 1; m <= vdeg; m++)
{
Coefficients->ChangeValue(index++) = OscCoeff(n,m).X();
Coefficients->ChangeValue(index++) = OscCoeff(n,m).Y();
Coefficients->ChangeValue(index++) = OscCoeff(n,m).Z();
}
}
if (IsAlongV())
{
if (udeg > vdeg)
{
for(n = 1; n <= udeg; n++)
for(m = 1; m <= vdeg + 1; m++)
OscCoeff(n,m) = cachepoles(n+1,m);
}
else
{
for(n = 1; n <= udeg; n++)
for(m = 1; m <= vdeg + 1; m++)
OscCoeff(n,m) = cachepoles(m,n+1);
}
if (IsUNegative) PLib::UTrimming(-1,0,OscCoeff,PLib::NoWeights2());
index=1;
for(n = 1; n <= udeg; n++)
for(m = 1; m <= vdeg + 1; m++)
{
Coefficients->ChangeValue(index++) = OscCoeff(n,m).X();
Coefficients->ChangeValue(index++) = OscCoeff(n,m).Y();
Coefficients->ChangeValue(index++) = OscCoeff(n,m).Z();
}
}
if (IsAlongU()) MaxVDegree--;
if (IsAlongV()) MaxUDegree--;
UContinuity = - 1;
VContinuity = - 1;
Convert_GridPolynomialToPoles Data(1,1,
UContinuity,
VContinuity,
MaxUDegree,
MaxVDegree,
NumCoeffPerSurface,
Coefficients,
PolynomialUIntervals,
PolynomialVIntervals,
TrueUIntervals,
TrueVIntervals);
// Handle(Geom_BSplineSurface) BSpl =
BSpl =new Geom_BSplineSurface(Data.Poles()->Array2(),
Data.UKnots()->Array1(),
Data.VKnots()->Array1(),
Data.UMultiplicities()->Array1(),
Data.VMultiplicities()->Array1(),
Data.UDegree(),
Data.VDegree(),
0, 0);
#ifdef DEB
cout<<"^====================================^"<<endl<<endl;
#endif
// L=BSpl;
}
return OsculSurf;
}
//=======================================================================
//function : IsQPunctual
//purpose :
//=======================================================================
Standard_Boolean Geom_OsculatingSurface::IsQPunctual
(const Handle(Geom_Surface)& S,
const Standard_Real Param,
const GeomAbs_IsoType IT,
const Standard_Real TolMin,
const Standard_Real TolMax) const
{
Standard_Real U1=0,U2=0,V1=0,V2=0,T;
Standard_Boolean Along = Standard_True;
S->Bounds(U1,U2,V1,V2);
gp_Vec D1U,D1V;
gp_Pnt P;
Standard_Real Step,D1NormMax;
if (IT == GeomAbs_IsoV)
{
Step = (U2 - U1)/10;
D1NormMax=0.;
for (T=U1;T<=U2;T=T+Step)
{
S->D1(T,Param,P,D1U,D1V);
D1NormMax=Max(D1NormMax,D1U.Magnitude());
}
#ifdef DEB
cout << " D1NormMax = " << D1NormMax << endl;
#endif
if (D1NormMax >TolMax || D1NormMax < TolMin )
Along = Standard_False;
}
else
{
Step = (V2 - V1)/10;
D1NormMax=0.;
for (T=V1;T<=V2;T=T+Step)
{
S->D1(Param,T,P,D1U,D1V);
D1NormMax=Max(D1NormMax,D1V.Magnitude());
}
#ifdef DEB
cout << " D1NormMax = " << D1NormMax << endl;
#endif
if (D1NormMax >TolMax || D1NormMax < TolMin )
Along = Standard_False;
}
return Along;
}
//=======================================================================
//function : HasOscSurf
//purpose :
//=======================================================================
Standard_Boolean Geom_OsculatingSurface::HasOscSurf() const
{
return (myAlong(1) || myAlong(2) || myAlong(3) || myAlong(4));
}
//=======================================================================
//function : IsAlongU
//purpose :
//=======================================================================
Standard_Boolean Geom_OsculatingSurface::IsAlongU() const
{
return (myAlong(1) || myAlong(2));
}
//=======================================================================
//function : IsAlongV
//purpose :
//=======================================================================
Standard_Boolean Geom_OsculatingSurface::IsAlongV() const
{
return (myAlong(3) || myAlong(4));
}
//=======================================================================
//function : IsGetSeqOfL1
//purpose :
//=======================================================================
const Geom_SequenceOfBSplineSurface& Geom_OsculatingSurface::GetSeqOfL1() const
{
return myOsculSurf1->Sequence();
}
//=======================================================================
//function : IsGetSeqOfL2
//purpose :
//=======================================================================
const Geom_SequenceOfBSplineSurface& Geom_OsculatingSurface::GetSeqOfL2() const
{
return myOsculSurf2->Sequence();
}
//=======================================================================
//function : ClearOsculFlags
//purpose :
//=======================================================================
void Geom_OsculatingSurface::ClearOsculFlags()
{
myAlong.SetValue(1,Standard_False);
myAlong.SetValue(2,Standard_False);
myAlong.SetValue(3,Standard_False);
myAlong.SetValue(4,Standard_False);
}

241
src/Geom/Geom_Parabola.cdl Executable file
View File

@@ -0,0 +1,241 @@
-- File: Geom_Parabola.cdl
-- Created: Wed Mar 10 09:57:52 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Parabola from Geom inherits Conic from Geom
---Purpose : Describes a parabola in 3D space.
-- A parabola is defined by its focal length (i.e. the
-- distance between its focus and its apex) and is
-- positioned in space with a coordinate system
-- (gp_Ax2 object) where:
-- - the origin is the apex of the parabola,
-- - the "X Axis" defines the axis of symmetry; the
-- parabola is on the positive side of this axis,
-- - the origin, "X Direction" and "Y Direction" define the
-- plane of the parabola.
-- This coordinate system is the local coordinate
-- system of the parabola.
-- The "main Direction" of this coordinate system is a
-- vector normal to the plane of the parabola. The axis,
-- of which the origin and unit vector are respectively the
-- origin and "main Direction" of the local coordinate
-- system, is termed the "Axis" or "main Axis" of the parabola.
-- The "main Direction" 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 Ax1 from gp,
Ax2 from gp,
Parab from gp,
Pnt from gp,
Trsf from gp,
Vec from gp,
Geometry from Geom
raises ConstructionError from Standard,
RangeError from Standard
is
Create (Prb : Parab) returns mutable Parabola;
---Purpose : Creates a parabola from a non transient one.
Create (A2 : Ax2; Focal : Real) returns mutable Parabola
---Purpose :
-- Creates a parabola with its local coordinate system "A2"
-- and it's focal length "Focal".
-- The XDirection of A2 defines the axis of symmetry of the
-- parabola. The YDirection of A2 is parallel to the directrix
-- of the parabola. The Location point of A2 is the vertex of
-- the parabola
raises ConstructionError;
---Purpose : Raised if Focal < 0.0
Create (D : Ax1; F : Pnt) 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. The normal to the plane
-- of the parabola is the cross product between the XAxis and the
-- YAxis.
SetFocal (me : mutable; Focal : Real)
---Purpose : Assigns the value Focal to the focal distance of this parabola.
-- Exceptions Standard_ConstructionError if Focal is negative.
raises ConstructionError
is static;
SetParab (me : mutable; Prb : Parab)
---Purpose: Converts the gp_Parab parabola Prb into this parabola.
is static;
Parab (me) returns Parab
---Purpose :
-- Returns the non transient parabola from gp with the same
-- geometric properties as <me>.
is static;
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 the value of the first or last parameter of this
-- parabola. This is, respectively:
-- - Standard_Real::RealFirst(), or
-- - Standard_Real::RealLast().
LastParameter (me) returns Real is redefined static;
---Purpose : Returns the value of the first or last parameter of this
-- parabola. This is, respectively:
-- - Standard_Real::RealFirst(), or
-- - Standard_Real::RealLast().
IsClosed (me) returns Boolean is redefined static;
---Purpose : Returns False
IsPeriodic (me) returns Boolean is redefined static;
---Purpose : Returns False
Directrix (me) returns Ax1;
---Purpose : Computes the directrix of this parabola.
-- This is a line normal to the axis of symmetry, in the
-- plane of this parabola, located on the negative side
-- of its axis of symmetry, at a distance from the apex
-- equal to the focal length.
-- The directrix is returned as an axis (gp_Ax1 object),
-- where the origin is located on the "X Axis" of this parabola.
Eccentricity (me) returns Real is redefined static;
---Purpose : Returns 1. (which is the eccentricity of any parabola).
Focus (me) returns Pnt;
---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 distance of this parabola
-- The focal distance 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 Pnt) 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 Pnt; V1 : out Vec) is redefined static;
---Purpose :
-- Returns the point P of parameter U and the first derivative V1.
D2 (me; U : Real; P : out Pnt; V1, V2 : out Vec) 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 Pnt; V1, V2, V3 : out Vec) 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 Vec
---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 : Trsf) is redefined static;
---Purpose: Applies the transformation T to this parabola.
TransformedParameter(me; U : Real; T : Trsf 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 returns <U> * T.ScaleFactor()
is redefined static;
ParametricTransformation(me; T : Trsf 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;

297
src/Geom/Geom_Parabola.cxx Executable file
View File

@@ -0,0 +1,297 @@
// File: Geom_Parabola.cxx
// Created: Wed Mar 10 09:58:12 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Parabola.cxx, JCV 17/01/91
#include <Geom_Parabola.ixx>
#include <Precision.hxx>
#include <ElCLib.hxx>
#include <gp_XYZ.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
typedef Geom_Parabola Parabola;
typedef Handle(Geom_Parabola) Handle(Parabola);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
typedef gp_XYZ XYZ;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_Parabola::Copy() const {
Handle(Parabola) Prb;
Prb = new Parabola (pos, focalLength);
return Prb;
}
//=======================================================================
//function : Geom_Parabola
//purpose :
//=======================================================================
Geom_Parabola::Geom_Parabola (const gp_Parab& Prb)
: focalLength (Prb.Focal())
{ pos = Prb.Position(); }
//=======================================================================
//function : Geom_Parabola
//purpose :
//=======================================================================
Geom_Parabola::Geom_Parabola (const Ax2& A2, const Standard_Real Focal)
: focalLength (Focal) {
if(Focal < 0.0) Standard_ConstructionError::Raise();
pos = A2;
}
//=======================================================================
//function : Geom_Parabola
//purpose :
//=======================================================================
Geom_Parabola::Geom_Parabola (const Ax1& D, const Pnt& F) {
gp_Parab Prb (D, F);
pos = Prb.Position();
focalLength = Prb.Focal();
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Parabola::ReversedParameter( const Standard_Real U) const
{
return (-U);
}
//=======================================================================
//function : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_Parabola::IsClosed () const { return Standard_False; }
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_Parabola::IsPeriodic () const { return Standard_False; }
//=======================================================================
//function : Eccentricity
//purpose :
//=======================================================================
Standard_Real Geom_Parabola::Eccentricity () const { return 1.0; }
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom_Parabola::FirstParameter () const
{ return -Precision::Infinite(); }
//=======================================================================
//function : Focal
//purpose :
//=======================================================================
Standard_Real Geom_Parabola::Focal () const { return focalLength; }
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom_Parabola::LastParameter () const
{ return Precision::Infinite(); }
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real Geom_Parabola::Parameter () const { return 2.0 * focalLength; }
//=======================================================================
//function : SetFocal
//purpose :
//=======================================================================
void Geom_Parabola::SetFocal (const Standard_Real Focal) {
if (Focal < 0.0) Standard_ConstructionError::Raise();
focalLength = Focal;
}
//=======================================================================
//function : SetParab
//purpose :
//=======================================================================
void Geom_Parabola::SetParab (const gp_Parab& Prb) {
focalLength = Prb.Focal ();
pos = Prb.Position ();
}
//=======================================================================
//function : Directrix
//purpose :
//=======================================================================
Ax1 Geom_Parabola::Directrix () const {
gp_Parab Prb (pos, focalLength);
return Prb.Directrix();
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_Parabola::D0 (const Standard_Real U, Pnt& P) const {
P = ElCLib::ParabolaValue (U, pos, focalLength);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_Parabola::D1 (const Standard_Real U, Pnt& P, Vec& V1) const {
ElCLib::ParabolaD1 (U, pos, focalLength, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_Parabola::D2 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2) const {
ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_Parabola::D3 (const Standard_Real U,
Pnt& P, Vec& V1, Vec& V2, Vec& V3) const {
ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
V3.SetCoord (0.0, 0.0, 0.0);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_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 : Focus
//purpose :
//=======================================================================
Pnt Geom_Parabola::Focus () const {
Standard_Real Xp, Yp, Zp, Xd, Yd, Zd;
pos.Location().Coord (Xp, Yp, Zp);
pos.XDirection().Coord (Xd, Yd, Zd);
return Pnt (Xp + focalLength*Xd, Yp + focalLength*Yd, Zp + focalLength*Zd);
}
//=======================================================================
//function : Parab
//purpose :
//=======================================================================
gp_Parab Geom_Parabola::Parab () const {
return gp_Parab (pos, focalLength);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_Parabola::Transform (const Trsf& T) {
focalLength *= Abs(T.ScaleFactor());
pos.Transform (T);
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Parabola::TransformedParameter(const Standard_Real U,
const gp_Trsf& T) const
{
if (Precision::IsInfinite(U)) return U;
return U * Abs(T.ScaleFactor());
}
//=======================================================================
//function : TransformedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Parabola::ParametricTransformation(const gp_Trsf& T) const
{
return Abs(T.ScaleFactor());
}

236
src/Geom/Geom_Plane.cdl Executable file
View File

@@ -0,0 +1,236 @@
-- File: Geom_Plane.cdl
-- Created: Wed Mar 10 09:58:36 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Plane from Geom inherits ElementarySurface from Geom
---Purpose : Describes a plane in 3D space.
-- A plane is positioned in space by a coordinate system
-- (a gp_Ax3 object) such that the plane is defined by
-- the origin, "X Direction" and "Y Direction" of this
-- coordinate system.
-- This coordinate system is the "local coordinate
-- system" of the plane. The following apply:
-- - Its "X Direction" and "Y Direction" are respectively
-- the u and v parametric directions of the plane.
-- - Its origin is the origin of the u and v parameters
-- (also called the "origin" of the plane).
-- - Its "main Direction" is a vector normal to the plane.
-- This normal vector gives the orientation of the
-- plane only if the local coordinate system is "direct".
-- (The orientation of the plane is always defined by
-- the "X Direction" and the "Y Direction" of its local
-- coordinate system.)
-- The parametric equation of the plane is:
-- P(u, v) = O + u*XDir + v*YDir
-- where O, XDir and YDir are respectively the
-- origin, the "X Direction" and the "Y Direction" of the
-- local coordinate system of the plane.
-- The parametric range of the two parameters u and v
-- is ] -infinity, +infinity [.
uses Ax1 from gp,
Ax3 from gp,
Dir from gp,
Lin from gp,
Pln from gp,
Pnt from gp,
Trsf from gp,
Vec from gp,
GTrsf2d from gp,
Curve from Geom,
Geometry from Geom
raises ConstructionError from Standard,
RangeError from Standard
is
Create (A3 : Ax3) returns mutable Plane;
---Purpose :
-- Creates a plane located in 3D space with an axis placement
-- three axis. The "ZDirection" of "A3" is the direction normal
-- to the plane. The "Location" point of "A3" is the origin of
-- the plane. The "XDirection" and "YDirection" of "A3" define
-- the directions of the U isoparametric and V isoparametric
-- curves.
Create (Pl : Pln) returns mutable Plane;
---Purpose :
-- Creates a plane from a non transient plane from package gp.
Create (P : Pnt; V : Dir) returns mutable Plane;
---Purpose :
-- P is the "Location" point or origin of the plane.
-- V is the direction normal to the plane.
Create (A, B, C ,D : Real) returns mutable Plane
---Purpose :
-- Creates a plane from its cartesian equation :
-- Ax + By + Cz + D = 0.0
raises ConstructionError;
---Purpose :
-- Raised if Sqrt (A*A + B*B + C*C) <= Resolution from gp
SetPln (me : mutable; Pl : Pln);
---Purpose :
-- Set <me> so that <me> has the same geometric properties as Pl.
Pln (me) returns Pln
---Purpose : Converts this plane into a gp_Pln plane.
is static;
UReverse (me : mutable)
---Purpose :
-- Changes the orientation of this plane in the u (or v)
-- parametric direction. The bounds of the plane are not
-- changed but the given parametric direction is
-- reversed. Hence the orientation of the surface is reversed.
is redefined;
UReversedParameter (me; U : Real ) returns Real;
---Purpose: Computes the u parameter on the modified
-- plane, produced when reversing the u
-- parametric of this plane, for any point of u parameter U on this plane.
-- In the case of a plane, these methods return - -U.
VReverse (me : mutable)
---Purpose :
-- Changes the orientation of this plane in the u (or v)
-- parametric direction. The bounds of the plane are not
-- changed but the given parametric direction is
-- reversed. Hence the orientation of the surface is reversed.
is redefined;
VReversedParameter (me; V : Real ) returns Real;
---Purpose: Computes the v parameter on the modified
-- plane, produced when reversing the v
-- parametric of this plane, for any point of v parameter V on this plane.
-- In the case of a plane, these methods return -V.
TransformParameters(me; U,V : in out Real; T : Trsf from gp)
---Purpose: Computes the parameters on the transformed surface for
-- the transform of the point of parameters U,V on <me>.
-- me->Transformed(T)->Value(U',V')
-- is the same point as
-- me->Value(U,V).Transformed(T)
-- Where U',V' are the new values of U,V after calling
-- me->TranformParameters(U,V,T)
-- This methods multiplies U and V by T.ScaleFactor()
is redefined;
ParametricTransformation(me; T : Trsf from gp) returns GTrsf2d from gp
---Purpose: Returns a 2d transformation used to find the new
-- parameters of a point on the transformed surface.
-- me->Transformed(T)->Value(U',V')
-- is the same point as
-- me->Value(U,V).Transformed(T)
-- Where U',V' are obtained by transforming U,V with
-- th 2d transformation returned by
-- me->ParametricTransformation(T)
-- This methods returns a scale centered on the
-- origin with T.ScaleFactor
is redefined;
Bounds (me; U1, U2, V1, V2 : out Real);
---Purpose : Returns the parametric bounds U1, U2, V1 and V2 of this plane.
-- Because a plane is an infinite surface, the following is always true:
-- - U1 = V1 = Standard_Real::RealFirst()
-- - U2 = V2 = Standard_Real::RealLast().
Coefficients (me; A, B, C, D : out Real);
---Purpose :
-- Computes the normalized coefficients of the plane's
-- cartesian equation : Ax + By + Cz + D = 0.0
IsUClosed (me) returns Boolean;
---Purpose : return False
IsVClosed (me) returns Boolean;
---Purpose : return False
IsUPeriodic (me) returns Boolean;
---Purpose : return False.
IsVPeriodic (me) returns Boolean;
---Purpose : return False.
UIso (me; U : Real) returns mutable Curve;
---Purpose :
-- Computes the U isoparametric curve.
-- This is a Line parallel to the YAxis of the plane.
VIso (me; V : Real) returns mutable Curve;
---Purpose :
-- Computes the V isoparametric curve.
-- This is a Line parallel to the XAxis of the plane.
D0 (me; U, V : Real; P : out Pnt);
---Purpose :
-- Computes the point P (U, V) on <me>.
-- P = O + U * XDir + V * YDir.
-- where O is the "Location" point of the plane, XDir the
-- "XDirection" and YDir the "YDirection" of the plane's local
-- coordinate system.
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec);
---Purpose :
-- Computes the current point and the first derivatives in the
-- directions U and V.
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec);
---Purpose :
-- Computes the current point, the first and the second
-- derivatives in the directions U and V.
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV :out Vec);
---Purpose :
-- Computes the current point, the first,the second and the
-- third derivatives in the directions U and V.
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
---Purpose :
-- Computes the derivative of order Nu in the direction u
-- and Nv in the direction v.
raises RangeError;
---Purpose : Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
Transform (me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this plane.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this plane.
end;

368
src/Geom/Geom_Plane.cxx Executable file
View File

@@ -0,0 +1,368 @@
// File: Geom_Plane.cxx
// Created: Wed Mar 10 09:59:41 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Plane.cxx, JCV 17/01/91
#include <Geom_Plane.ixx>
#include <Precision.hxx>
#include <Standard_RangeError.hxx>
#include <gp_XYZ.hxx>
#include <gp.hxx>
#include <gp_Lin.hxx>
#include <gp_Trsf2d.hxx>
#include <ElSLib.hxx>
#include <Geom_Line.hxx>
#include <GeomAbs_UVSense.hxx>
typedef Geom_Plane Plane;
typedef Handle(Geom_Plane) Handle(Plane);
typedef Handle(Geom_Line) Handle(Line);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Ax3 Ax3;
typedef gp_Dir Dir;
typedef gp_Lin Lin;
typedef gp_Pln Pln;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
typedef gp_XYZ XYZ;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_Plane::Copy () const {
Handle(Plane) Pl = new Plane ( pos);
return Pl;
}
//=======================================================================
//function : Geom_Plane
//purpose :
//=======================================================================
Geom_Plane::Geom_Plane (const gp_Ax3& A3) {
pos = A3;
}
//=======================================================================
//function : Geom_Plane
//purpose :
//=======================================================================
Geom_Plane::Geom_Plane (const gp_Pln& Pl) {
pos = Pl.Position();
}
//=======================================================================
//function : Geom_Plane
//purpose :
//=======================================================================
Geom_Plane::Geom_Plane (const Pnt& P, const Dir& V) {
gp_Pln Pl (P, V);
pos = Pl.Position();
}
//=======================================================================
//function : Geom_Plane
//purpose :
//=======================================================================
Geom_Plane::Geom_Plane ( const Standard_Real A,
const Standard_Real B,
const Standard_Real C,
const Standard_Real D) {
gp_Pln Pl (A, B, C, D);
pos = Pl.Position ();
}
//=======================================================================
//function : SetPln
//purpose :
//=======================================================================
void Geom_Plane::SetPln (const gp_Pln& Pl)
{ pos = Pl.Position(); }
//=======================================================================
//function : Pln
//purpose :
//=======================================================================
gp_Pln Geom_Plane::Pln () const {
return gp_Pln (Position());
}
//=======================================================================
//function : UReverse
//purpose :
//=======================================================================
void Geom_Plane::UReverse() {
pos.XReverse();
}
//=======================================================================
//function : UReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Plane::UReversedParameter( const Standard_Real U) const {
return (-U);
}
//=======================================================================
//function : VReverse
//purpose :
//=======================================================================
void Geom_Plane::VReverse() {
pos.YReverse();
}
//=======================================================================
//function : VReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_Plane::VReversedParameter( const Standard_Real V) const {
return (-V);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_Plane::Transform (const Trsf& T)
{ pos.Transform (T); }
//=======================================================================
//function : IsUClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_Plane::IsUClosed () const {
return Standard_False;
}
//=======================================================================
//function : IsVClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_Plane::IsVClosed () const {
return Standard_False;
}
//=======================================================================
//function : IsUPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_Plane::IsUPeriodic () const {
return Standard_False;
}
//=======================================================================
//function : IsVPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_Plane::IsVPeriodic () const {
return Standard_False;
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void Geom_Plane::Bounds (Standard_Real& U1, Standard_Real& U2, Standard_Real& V1, Standard_Real& V2) const {
U1 = -Precision::Infinite();
U2 = Precision::Infinite();
V1 = -Precision::Infinite();
V2 = Precision::Infinite();
}
//=======================================================================
//function : Coefficients
//purpose :
//=======================================================================
void Geom_Plane::Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D) const {
gp_Pln Pl (Position());
Pl.Coefficients (A, B, C, D);
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_Plane::D0 (const Standard_Real U, const Standard_Real V, Pnt& P) const {
P = ElSLib::PlaneValue (U, V, pos);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_Plane::D1 ( const Standard_Real U, const Standard_Real V,
Pnt& P, Vec& D1U, Vec& D1V) const
{
ElSLib::PlaneD1 (U, V, pos, P, D1U, D1V);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_Plane::D2 ( const Standard_Real U , const Standard_Real V,
Pnt& P ,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV) const
{
ElSLib::PlaneD1 (U, V, pos, P, D1U, D1V);
D2U.SetCoord (0.0, 0.0, 0.0);
D2V.SetCoord (0.0, 0.0, 0.0);
D2UV.SetCoord (0.0, 0.0, 0.0);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_Plane::D3 ( const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV,
Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV) const
{
ElSLib::PlaneD1 (U, V, pos, P, D1U, D1V);
D2U.SetCoord (0.0, 0.0, 0.0);
D2V.SetCoord (0.0, 0.0, 0.0);
D2UV.SetCoord (0.0, 0.0, 0.0);
D3U.SetCoord (0.0, 0.0, 0.0);
D3V.SetCoord (0.0, 0.0, 0.0);
D3UUV.SetCoord (0.0, 0.0, 0.0);
D3UVV.SetCoord (0.0, 0.0, 0.0);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_Plane::DN ( const Standard_Real , const Standard_Real ,
const Standard_Integer Nu, const Standard_Integer Nv ) const {
Standard_RangeError_Raise_if (Nu < 0 || Nv < 0 || Nu + Nv < 1, " ");
if (Nu == 0 && Nv == 1) {
return Vec (pos.YDirection());
}
else if (Nu == 1 && Nv == 0) {
return Vec (pos.XDirection());
}
return Vec (0.0, 0.0, 0.0);
}
//=======================================================================
//function : UIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_Plane::UIso (const Standard_Real U) const
{
Handle(Geom_Line) GL = new Geom_Line (ElSLib::PlaneUIso(pos,U));
return GL;
}
//=======================================================================
//function : VIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_Plane::VIso (const Standard_Real V) const
{
Handle(Geom_Line) GL = new Geom_Line (ElSLib::PlaneVIso(pos,V));
return GL;
}
//=======================================================================
//function : TransformParameters
//purpose :
//=======================================================================
void Geom_Plane::TransformParameters(Standard_Real& U,
Standard_Real& V,
const gp_Trsf& T)
const
{
if (!Precision::IsInfinite(U)) U *= Abs(T.ScaleFactor());
if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
gp_GTrsf2d Geom_Plane::ParametricTransformation(const gp_Trsf& T) const
{
gp_Trsf2d T2;
T2.SetScale(gp::Origin2d(), Abs(T.ScaleFactor()));
return gp_GTrsf2d(T2);
}

55
src/Geom/Geom_Point.cdl Executable file
View File

@@ -0,0 +1,55 @@
-- File: Geom_Point.cdl
-- Created: Wed Mar 10 10:01:33 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class Point from Geom inherits Geometry from Geom
---Purpose : The abstract class Point describes the common
-- behavior of geometric points in 3D space.
-- The Geom package also provides the concrete class
-- Geom_CartesianPoint.
uses Pnt from gp
is
Coord (me; X, Y, Z : out Real)
---Purpose : returns the Coordinates of <me>.
is deferred;
Pnt (me) returns Pnt
---Purpose : returns a non transient 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;
Z (me) returns Real
---Purpose : returns the Z 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;

29
src/Geom/Geom_Point.cxx Executable file
View File

@@ -0,0 +1,29 @@
// File: Geom_Point.cxx
// Created: Wed Mar 10 10:02:09 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Point.cxx, JCV 15/01/91
#include <Geom_Point.ixx>
typedef Handle(Geom_Point) Handle(Point);
typedef Geom_Point Point;
Standard_Real Geom_Point::Distance (const Handle(Point)& Other) const {
gp_Pnt P1 = this->Pnt ();
gp_Pnt P2 = Other->Pnt ();
return P1.Distance (P2);
}
Standard_Real Geom_Point::SquareDistance (const Handle(Point)& Other) const {
gp_Pnt P1 = this->Pnt ();
gp_Pnt P2 = Other->Pnt ();
return P1.SquareDistance (P2);
}

View File

@@ -0,0 +1,366 @@
-- File: Geom_RectangularTrimmedSurface.cdl
-- Created: Wed Mar 10 10:02:30 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class RectangularTrimmedSurface from Geom inherits BoundedSurface from Geom
---Purpose : Describes a portion of a surface (a patch) limited
-- by two values of the u parameter in the u
-- parametric direction, and two values of the v
-- parameter in the v parametric direction. The
-- domain of the trimmed surface must be within the
-- domain of the surface being trimmed.
-- The trimmed surface is defined by:
-- - the basis surface, and
-- - the values (umin, umax) and (vmin, vmax)
-- which limit it in the u and v parametric directions.
-- The trimmed surface is built from a copy of the basis
-- surface. Therefore, when the basis surface is
-- modified the trimmed surface is not changed.
-- Consequently, the trimmed surface does not
-- necessarily have the same orientation as the basis surface.
-- Warning: The case of surface being trimmed is periodic and
-- parametrics values are outside the domain is possible.
-- But, domain of the trimmed surface can be translated
-- by (n X) the period.
uses Ax1 from gp,
Ax2 from gp,
Pnt from gp,
Trsf from gp,
GTrsf2d from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom,
Shape from GeomAbs,
Surface from Geom
raises ConstructionError from Standard,
RangeError from Standard,
NoSuchObject from Standard,
UndefinedDerivative from Geom,
UndefinedValue from Geom
is
Create (S : Surface from Geom;
U1, U2, V1, V2 : Real;
USense, VSense : Boolean = Standard_True)
returns mutable RectangularTrimmedSurface
---Purpose :
-- The U parametric direction of the surface is oriented from U1
-- to U2. The V parametric direction of the surface is oriented
-- from V1 to V2.
-- These two directions define the orientation of the surface
-- (normal). If the surface is not periodic USense and VSense are
-- not used for the construction. If the surface S is periodic in
-- one direction USense and VSense give the available part of the
-- surface. By default in this case the surface has the same
-- orientation as the basis surface S.
-- The returned surface is not closed and not periodic.
-- ConstructionError Raised if
-- S is not periodic in the UDirection and U1 or U2 are out of the
-- bounds of S.
-- S is not periodic in the VDirection and V1 or V2 are out of the
-- bounds of S.
-- U1 = U2 or V1 = V2
raises ConstructionError;
Create (S : Surface from Geom;
Param1, Param2 : Real;
UTrim : Boolean;
Sense : Boolean = Standard_True)
returns mutable RectangularTrimmedSurface
---Purpose :
-- The basis surface S is only trim in one parametric direction.
-- If UTrim = True the surface is trimmed in the U parametric
-- direction else the surface is trimmed in the V parametric
-- direction.
-- In the considered parametric direction the resulting surface is
-- oriented from Param1 to Param2. If S is periodic Sense gives the
-- available part of the surface. By default the trimmed surface has
-- the same orientation as the basis surface S in the considered
-- parametric direction (Sense = True).
-- If the basis surface S is closed or periodic in the parametric
-- direction opposite to the trimming direction the trimmed surface
-- has the same characteristics as the surface S in this direction.
-- Warnings :
-- In this package the entities are not shared.
-- The RectangularTrimmedSurface is built with a copy of the
-- surface S. So when S is modified the RectangularTrimmedSurface
-- is not modified
raises ConstructionError;
---Purpose : Raised if
-- S is not periodic in the considered parametric direction and
-- Param1 or Param2 are out of the bounds of S.
-- Param1 = Param2
SetTrim (me : mutable;
U1, U2, V1, V2 : Real;
USense, VSense : Boolean = Standard_True)
---Purpose : Modifies this patch by changing the trim values
-- applied to the original surface
-- The u parametric direction of
-- this patch is oriented from U1 to U2. The v
-- parametric direction of this patch is oriented
-- from V1 to V2. USense and VSense are used
-- for the construction only if the surface is periodic
-- in the corresponding parametric direction, and
-- define the available part of the surface; by default
-- in this case, this patch has the same orientation
-- as the basis surface.
raises ConstructionError;
---Purpose : Raised if
-- The BasisSurface is not periodic in the UDirection and U1 or U2
-- are out of the bounds of the BasisSurface.
-- The BasisSurface is not periodic in the VDirection and V1 or V2
-- are out of the bounds of the BasisSurface.
-- U1 = U2 or V1 = V2
SetTrim (me : mutable;
Param1, Param2 : Real;
UTrim : Boolean;
Sense : Boolean = Standard_True)
---Purpose : Modifies this patch by changing the trim values
-- applied to the original surface
-- The basis surface is trimmed only in one parametric direction: if UTrim
-- is true, the surface is trimmed in the u parametric
-- direction; if it is false, it is trimmed in the v
-- parametric direction. In the "trimmed" direction,
-- this patch is oriented from Param1 to Param2. If
-- the basis surface is periodic in the "trimmed"
-- direction, Sense defines its available part. By
-- default in this case, this patch has the same
-- orientation as the basis surface in this parametric
-- direction. If the basis surface is closed or periodic
-- in the other parametric direction (i.e. not the
-- "trimmed" direction), this patch has the same
-- characteristics as the basis surface in that parametric direction.
raises ConstructionError;
---Purpose : Raised if
-- The BasisSurface is not periodic in the considered direction and
-- Param1 or Param2 are out of the bounds of the BasisSurface.
-- Param1 = Param2
SetTrim (me : mutable;
U1, U2, V1, V2 : Real;
UTrim, VTrim : Boolean;
USense, VSense : Boolean)
---Purpose : General set trim, to implement constructors and
-- others set trim.
raises ConstructionError
is private;
BasisSurface (me) returns Surface from Geom;
---Purpose : Returns the Basis surface of <me>.
UReverse (me : mutable);
---Purpose : Changes the orientation of this patch in the u
-- parametric direction. The bounds of the surface are
-- not changed, but the given parametric direction is
-- reversed. Hence the orientation of the surface is reversed.
UReversedParameter (me; U : Real) returns Real;
---Purpose: Computes the u parameter on the modified
-- surface, produced by when reversing its u
-- parametric direction, for any point of u parameter U on this patch.
VReverse (me : mutable);
---Purpose : Changes the orientation of this patch in the v
-- parametric direction. The bounds of the surface are
-- not changed, but the given parametric direction is
-- reversed. Hence the orientation of the surface is reversed.
VReversedParameter (me; V : Real) returns Real;
---Purpose: Computes the v parameter on the modified
-- surface, produced by when reversing its v
-- parametric direction, for any point of v parameter V on this patch.
Bounds (me; U1, U2, V1, V2 : out Real);
---Purpose : Returns the parametric bounds U1, U2, V1 and V2 of this patch.
Continuity (me) returns Shape from GeomAbs;
---Purpose :
-- Returns the continuity of the surface :
-- C0 : only geometric continuity,
-- C1 : continuity of the first derivative all along the Surface,
-- C2 : continuity of the second derivative all along the Surface,
-- C3 : continuity of the third derivative all along the Surface,
-- CN : the order of continuity is infinite.
IsUClosed (me) returns Boolean;
---Purpose: Returns true if this patch is closed in the given parametric direction.
IsVClosed (me) returns Boolean;
---Purpose: Returns true if this patch is closed in the given parametric direction.
IsCNu (me; N : Integer) returns Boolean
---Purpose :
-- Returns true if the order of derivation in the U parametric
-- direction is N.
raises RangeError;
---Purpose : Raised if N < 0.
IsCNv (me; N : Integer) returns Boolean
---Purpose :
-- Returns true if the order of derivation in the V parametric
-- direction is N.
raises RangeError;
---Purpose : Raised if N < 0.
IsUPeriodic (me) returns Boolean;
---Purpose: Returns true if this patch is periodic in the given
-- parametric direction.
UPeriod (me) returns Real from Standard
---Purpose: Returns the period of this patch in the u
-- parametric direction.
raises
NoSuchObject from Standard
---Purpose: raises if the surface is not uperiodic.
is redefined;
IsVPeriodic (me) returns Boolean;
---Purpose:
-- Returns true if this patch is periodic in the given
-- parametric direction.
VPeriod (me) returns Real from Standard
---Purpose: Returns the period of this patch in the v
-- parametric direction.
raises
NoSuchObject from Standard
---Purpose: raises if the surface is not vperiodic.
is redefined;
---Purpose : value and derivatives
UIso (me; U : Real) returns mutable Curve;
---Purpose : computes the U isoparametric curve.
VIso (me; V : Real) returns mutable Curve;
---Purpose : Computes the V isoparametric curve.
D0 (me; U, V : Real; P : out Pnt)
raises UndefinedValue;
---Purpose :
-- Can be raised if the basis surface is an OffsetSurface.
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec)
---Purpose :
-- The returned derivatives have the same orientation as the
-- derivatives of the basis surface even if the trimmed surface
-- has not the same parametric orientation.
-- Warning! UndefinedDerivative raised if the continuity of the surface is not C1.
raises UndefinedDerivative;
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec)
--- Purpose :
-- The returned derivatives have the same orientation as the
-- derivatives of the basis surface even if the trimmed surface
-- has not the same parametric orientation.
-- Warning! UndefinedDerivative raised if the continuity of the surface is not C2.
raises UndefinedDerivative;
D3 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV,
D3U, D3V, D3UUV, D3UVV : out Vec)
--- Purposes : The returned derivatives have the same orientation as the
-- derivatives of the basis surface even if the trimmed surface
-- has not the same parametric orientation.
-- Warning UndefinedDerivative raised if the continuity of the surface is not C3.
raises UndefinedDerivative;
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
---Purpose : The returned derivative has the same orientation as the
-- derivative of the basis surface even if the trimmed surface
-- has not the same parametric orientation.
-- Warning! UndefinedDerivative raised if the continuity of the surface is not CNu in the U
-- parametric direction and CNv in the V parametric direction.
-- RangeError Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
raises UndefinedDerivative,
RangeError;
Transform (me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this patch.
-- Warning
-- As a consequence, the basis surface included in the
-- data structure of this patch is also modified.
TransformParameters(me; U,V : in out Real; T : Trsf from gp)
---Purpose: Computes the parameters on the transformed surface for
-- the transform of the point of parameters U,V on <me>.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are the new values of U,V after calling
--
-- me->TranformParameters(U,V,T)
--
-- This methods calls the basis surface method.
is redefined;
ParametricTransformation(me; T : Trsf from gp) returns GTrsf2d from gp
---Purpose: Returns a 2d transformation used to find the new
-- parameters of a point on the transformed surface.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are obtained by transforming U,V with
-- th 2d transformation returned by
--
-- me->ParametricTransformation(T)
--
-- This methods calls the basis surface method.
is redefined;
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this patch.
fields
basisSurf : Surface from Geom;
utrim1 : Real;
vtrim1 : Real;
utrim2 : Real;
vtrim2 : Real;
isutrimmed : Boolean;
isvtrimmed : Boolean;
end;

View File

@@ -0,0 +1,654 @@
// File: Geom_RectangularTrimmedSurface.cxx
// *******************************************************************
// Created: Wed Mar 10 10:03:35 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
// *******************************************************************
//File Geom_RectangularTrimmedSurface.cxx, JCV 01/02/91
#include <Geom_RectangularTrimmedSurface.ixx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Geometry.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_OffsetSurface.hxx>
#include <Precision.hxx>
#include <ElCLib.hxx>
typedef Handle(Geom_Surface) Handle(Surface);
typedef Handle(Geom_Geometry) Handle(Geometry);
typedef Geom_RectangularTrimmedSurface RectangularTrimmedSurface;
typedef Handle(Geom_RectangularTrimmedSurface) Handle(RectangularTrimmedSurface);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_RectangularTrimmedSurface::Copy () const {
Handle(RectangularTrimmedSurface) S;
if ( isutrimmed && isvtrimmed )
S = new RectangularTrimmedSurface (basisSurf,
utrim1 , utrim2,
vtrim1 , vtrim2,
Standard_True , Standard_True );
else if ( isutrimmed)
S = new RectangularTrimmedSurface (basisSurf,
utrim1 , utrim2,
Standard_True, Standard_True );
else if (isvtrimmed)
S = new RectangularTrimmedSurface (basisSurf,
vtrim1 , vtrim2,
Standard_False , Standard_True );
return S;
}
//=======================================================================
//function : Geom_RectangularTrimmedSurface
//purpose :
//=======================================================================
Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface (
const Handle(Surface)& S,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Real V1,
const Standard_Real V2,
const Standard_Boolean USense,
const Standard_Boolean VSense)
: utrim1 (U1),
vtrim1(V1),
utrim2 (U2),
vtrim2 (V2),
isutrimmed (Standard_True),
isvtrimmed (Standard_True)
{
// kill trimmed basis surfaces
Handle(Geom_RectangularTrimmedSurface) T =
Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
if (!T.IsNull())
basisSurf = Handle(Surface)::DownCast(T->BasisSurface()->Copy());
else
basisSurf = Handle(Surface)::DownCast(S->Copy());
Handle(Geom_OffsetSurface) O =
Handle(Geom_OffsetSurface)::DownCast(basisSurf);
if (!O.IsNull())
{
Handle(Geom_RectangularTrimmedSurface) S2 =
new Geom_RectangularTrimmedSurface( O->BasisSurface(),U1,U2, V1, V2, USense, VSense);
Handle(Geom_OffsetSurface) OS = new Geom_OffsetSurface(S2, O->Offset());
basisSurf = Handle(Surface)::DownCast(OS);
}
SetTrim( U1, U2, V1, V2, USense, VSense);
}
//=======================================================================
//function : Geom_RectangularTrimmedSurface
//purpose :
//=======================================================================
Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface (
const Handle(Geom_Surface)& S,
const Standard_Real Param1,
const Standard_Real Param2,
const Standard_Boolean UTrim,
const Standard_Boolean Sense
) {
// kill trimmed basis surfaces
Handle(Geom_RectangularTrimmedSurface) T =
Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
if (!T.IsNull())
basisSurf = Handle(Surface)::DownCast(T->BasisSurface()->Copy());
else
basisSurf = Handle(Surface)::DownCast(S->Copy());
Handle(Geom_OffsetSurface) O =
Handle(Geom_OffsetSurface)::DownCast(basisSurf);
if (!O.IsNull())
{
Handle(Geom_RectangularTrimmedSurface) S2 =
new Geom_RectangularTrimmedSurface( O->BasisSurface(),Param1,Param2, UTrim, Sense);
Handle(Geom_OffsetSurface) OS = new Geom_OffsetSurface(S2, O->Offset());
basisSurf = Handle(Surface)::DownCast(OS);
}
SetTrim(Param1, Param2, UTrim, Sense);
}
//=======================================================================
//function : SetTrim
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::SetTrim (const Standard_Real U1,
const Standard_Real U2,
const Standard_Real V1,
const Standard_Real V2,
const Standard_Boolean USense,
const Standard_Boolean VSense ) {
SetTrim( U1, U2, V1, V2, Standard_True, Standard_True, USense, VSense);
}
//=======================================================================
//function : SetTrim
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::SetTrim (const Standard_Real Param1,
const Standard_Real Param2,
const Standard_Boolean UTrim,
const Standard_Boolean Sense ) {
// dummy arguments to call general SetTrim
Standard_Real dummy_a = 0.;
Standard_Real dummy_b = 0.;
Standard_Boolean dummy_Sense = Standard_True;
if ( UTrim) {
SetTrim( Param1 , Param2 ,
dummy_a , dummy_b ,
Standard_True , Standard_False,
Sense , dummy_Sense );
}
else {
SetTrim( dummy_a , dummy_b ,
Param1 , Param2 ,
Standard_False, Standard_True,
dummy_Sense , Sense );
}
}
//=======================================================================
//function : SetTrim
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::SetTrim(const Standard_Real U1,
const Standard_Real U2,
const Standard_Real V1,
const Standard_Real V2,
const Standard_Boolean UTrim,
const Standard_Boolean VTrim,
const Standard_Boolean USense,
const Standard_Boolean VSense) {
Standard_Boolean UsameSense = Standard_True;
Standard_Boolean VsameSense = Standard_True;
Standard_Real Udeb, Ufin, Vdeb, Vfin;
basisSurf->Bounds(Udeb, Ufin, Vdeb, Vfin);
// Trimming the U-Direction
isutrimmed = UTrim;
if (!UTrim) {
utrim1 = Udeb;
utrim2 = Ufin;
}
else {
if ( U1 == U2)
Standard_ConstructionError::Raise
("Geom_RectangularTrimmedSurface::U1==U2");
if (basisSurf->IsUPeriodic()) {
UsameSense = USense;
// 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) {
UsameSense = USense;
utrim1 = U1;
utrim2 = U2;
}
else {
UsameSense = !USense;
utrim1 = U2;
utrim2 = U1;
}
if ((Udeb-utrim1 > Precision::PConfusion()) ||
(utrim2-Ufin > Precision::PConfusion()))
Standard_ConstructionError::Raise
("Geom_RectangularTrimmedSurface::U parameters out of range");
}
}
// Trimming the V-Direction
isvtrimmed = VTrim;
if (!VTrim) {
vtrim1 = Vdeb;
vtrim2 = Vfin;
}
else {
if ( V1 == V2)
Standard_ConstructionError::Raise
("Geom_RectangularTrimmedSurface::V1==V2");
if (basisSurf->IsVPeriodic()) {
VsameSense = VSense;
// set vTrim1 in the range Vdeb , Vfin
// set vTrim2 in the range vTrim1 , vTrim1 + Period()
vtrim1 = V1;
vtrim2 = V2;
ElCLib::AdjustPeriodic(Vdeb, Vfin,
Min(Abs(vtrim2-vtrim1)/2,Precision::PConfusion()),
vtrim1, vtrim2);
}
else {
if (V1 < V2) {
VsameSense = VSense;
vtrim1 = V1;
vtrim2 = V2;
}
else {
VsameSense = !VSense;
vtrim1 = V2;
vtrim2 = V1;
}
if ((Vdeb-vtrim1 > Precision::PConfusion()) ||
(vtrim2-Vfin > Precision::PConfusion()))
Standard_ConstructionError::Raise
("Geom_RectangularTrimmedSurface::V parameters out of range");
}
}
if (!UsameSense) UReverse();
if (!VsameSense) VReverse();
}
//=======================================================================
//function : UReverse
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::UReverse ()
{
Standard_Real U1 = basisSurf->UReversedParameter(utrim2);
Standard_Real U2 = basisSurf->UReversedParameter(utrim1);
basisSurf->UReverse();
SetTrim(U1,U2,vtrim1,vtrim2,
isutrimmed,isvtrimmed,
Standard_True,Standard_True);
}
//=======================================================================
//function : UReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_RectangularTrimmedSurface::UReversedParameter( const Standard_Real U) const {
return basisSurf->UReversedParameter(U);
}
//=======================================================================
//function : VReverse
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::VReverse ()
{
Standard_Real V1 = basisSurf->VReversedParameter(vtrim2);
Standard_Real V2 = basisSurf->VReversedParameter(vtrim1);
basisSurf->VReverse();
SetTrim(utrim1,utrim2,V1,V2,
isutrimmed,isvtrimmed,
Standard_True,Standard_True);
}
//=======================================================================
//function : VReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_RectangularTrimmedSurface::VReversedParameter( const Standard_Real V) const {
return basisSurf->VReversedParameter( V);
}
//=======================================================================
//function : BasisSurface
//purpose :
//=======================================================================
Handle(Surface) Geom_RectangularTrimmedSurface::BasisSurface () const
{
return basisSurf;
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom_RectangularTrimmedSurface::Continuity () const {
return basisSurf->Continuity();
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::D0
(const Standard_Real U, const Standard_Real V,
Pnt& P ) const {
basisSurf->D0 (U, V, P);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::D1
(const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V) const {
basisSurf->D1 (U, V, P, D1U, D1V);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::D2
(const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV) const {
basisSurf->D2 (U, V, P, D1U, D1V, D2U, D2V, D2UV);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::D3
(const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV,
Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV) const {
basisSurf->D3 (U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_RectangularTrimmedSurface::DN
(const Standard_Real U , const Standard_Real V,
const Standard_Integer Nu, const Standard_Integer Nv) const {
return basisSurf->DN (U, V, Nu, Nv);
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::Bounds (Standard_Real& U1,
Standard_Real& U2,
Standard_Real& V1,
Standard_Real& V2) const {
U1 = utrim1;
U2 = utrim2;
V1 = vtrim1;
V2 = vtrim2;
}
//=======================================================================
//function : UIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_RectangularTrimmedSurface::UIso (const Standard_Real U) const {
Handle(Geom_Curve) C = basisSurf->UIso (U);
if ( isvtrimmed) {
Handle(Geom_TrimmedCurve) Ct;
Ct = new Geom_TrimmedCurve (C, vtrim1, vtrim2, Standard_True);
return Ct;
}
else {
return C;
}
}
//=======================================================================
//function : VIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_RectangularTrimmedSurface::VIso (const Standard_Real V) const {
Handle(Geom_Curve) C = basisSurf->VIso (V);
if ( isutrimmed) {
Handle(Geom_TrimmedCurve) Ct;
Ct = new Geom_TrimmedCurve (C, utrim1, utrim2, Standard_True);
return Ct;
}
else {
return C;
}
}
//=======================================================================
//function : IsCNu
//purpose :
//=======================================================================
Standard_Boolean Geom_RectangularTrimmedSurface::IsCNu (const Standard_Integer N) const {
Standard_RangeError_Raise_if (N < 0," ");
return basisSurf->IsCNu (N);
}
//=======================================================================
//function : IsCNv
//purpose :
//=======================================================================
Standard_Boolean Geom_RectangularTrimmedSurface::IsCNv (const Standard_Integer N) const {
Standard_RangeError_Raise_if (N < 0," ");
return basisSurf->IsCNv (N);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::Transform (const Trsf& T)
{
basisSurf->Transform (T);
basisSurf->TransformParameters(utrim1,vtrim1,T);
basisSurf->TransformParameters(utrim2,vtrim2,T);
}
//=======================================================================
//function : IsUPeriodic
//purpose :
// 24/11/98: pmn : Compare la periode a la longeur de l'intervalle
//=======================================================================
Standard_Boolean Geom_RectangularTrimmedSurface::IsUPeriodic () const
{
if (basisSurf->IsUPeriodic() && !isutrimmed)
return Standard_True;
return Standard_False;
}
//=======================================================================
//function : UPeriod
//purpose :
//=======================================================================
Standard_Real Geom_RectangularTrimmedSurface::UPeriod() const
{
return basisSurf->UPeriod();
}
//=======================================================================
//function : IsVPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_RectangularTrimmedSurface::IsVPeriodic () const
{
if (basisSurf->IsVPeriodic() && !isvtrimmed)
return Standard_True;
return Standard_False;
}
//=======================================================================
//function : VPeriod
//purpose :
//=======================================================================
Standard_Real Geom_RectangularTrimmedSurface::VPeriod() const
{
return basisSurf->VPeriod();
}
//=======================================================================
//function : IsUClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_RectangularTrimmedSurface::IsUClosed () const {
if (isutrimmed)
return Standard_False;
else
return basisSurf->IsUClosed();
}
//=======================================================================
//function : IsVClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_RectangularTrimmedSurface::IsVClosed () const {
if (isvtrimmed)
return Standard_False;
else
return basisSurf->IsVClosed();
}
//=======================================================================
//function : TransformParameters
//purpose :
//=======================================================================
void Geom_RectangularTrimmedSurface::TransformParameters(Standard_Real& U,
Standard_Real& V,
const gp_Trsf& T)
const
{
basisSurf->TransformParameters(U,V,T);
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
gp_GTrsf2d Geom_RectangularTrimmedSurface::ParametricTransformation
(const gp_Trsf& T) const
{
return basisSurf->ParametricTransformation(T);
}

View File

@@ -0,0 +1,231 @@
-- File: Geom_SphericalSurface.cdl
-- Created: Wed Mar 10 10:22:03 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class SphericalSurface from Geom inherits ElementarySurface from Geom
--- Purpose : Describes a sphere.
-- A sphere is defined by its radius, and is positioned in
-- space by a coordinate system (a gp_Ax3 object), the
-- origin of which is the center of the sphere.
-- This coordinate system is the "local coordinate
-- system" of the sphere. The following apply:
-- - Rotation around its "main Axis", in the trigonometric
-- sense given by the "X Direction" and the "Y
-- Direction", defines the u parametric direction.
-- - Its "X Axis" gives the origin for the u parameter.
-- - The "reference meridian" of the sphere is a
-- half-circle, of radius equal to the radius of the
-- sphere. It is located in the plane defined by the
-- origin, "X Direction" and "main Direction", centered
-- on the origin, and positioned on the positive side of the "X Axis".
-- - Rotation around the "Y Axis" gives the v parameter
-- on the reference meridian.
-- - The "X Axis" gives the origin of the v parameter on
-- the reference meridian.
-- - The v parametric direction is oriented by the "main
-- Direction", i.e. when v increases, the Z coordinate
-- increases. (This implies that the "Y Direction"
-- orients the reference meridian only when the local
-- coordinate system is indirect.)
-- - The u isoparametric curve is a half-circle obtained
-- by rotating the reference meridian of the sphere
-- through an angle u around the "main Axis", in the
-- trigonometric sense defined by the "X Direction"
-- and the "Y Direction".
-- The parametric equation of the sphere is:
-- P(u,v) = O + R*cos(v)*(cos(u)*XDir + sin(u)*YDir)+R*sin(v)*ZDir
-- where:
-- - O, XDir, YDir and ZDir are respectively the
-- origin, the "X Direction", the "Y Direction" and the "Z
-- Direction" of its local coordinate system, and
-- - R is the radius of the sphere.
-- The parametric range of the two parameters is:
-- - [ 0, 2.*Pi ] for u, and
-- - [ - Pi/2., + Pi/2. ] for v.
uses Ax3 from gp,
Pnt from gp,
Sphere from gp,
Trsf from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom
raises ConstructionError from Standard,
RangeError from Standard
is
Create (A3 : Ax3; Radius : Real) returns mutable SphericalSurface
--- Purpose :
-- A3 is the local coordinate system of the surface.
-- At the creation the parametrization of the surface is defined
-- such as the normal Vector (N = D1U ^ D1V) is directed away from
-- the center of the sphere.
-- The direction of increasing parametric value V is defined by the
-- rotation around the "YDirection" of A2 in the trigonometric sense
-- and the orientation of increasing parametric value U is defined
-- by the rotation around the main direction of A2 in the
-- trigonometric sense.
-- Warnings :
-- It is not forbidden to create a spherical surface with
-- Radius = 0.0
raises ConstructionError;
--- Purpose : Raised if Radius < 0.0.
Create (S : Sphere) returns mutable SphericalSurface;
--- Purpose :
-- Creates a SphericalSurface from a non persistent Sphere from
-- package gp.
SetRadius (me : mutable; R : Real)
raises ConstructionError;
--- Purpose : Assigns the value R to the radius of this sphere.
-- Exceptions Standard_ConstructionError if R is less than 0.0.
SetSphere (me : mutable; S : Sphere);
--- Purpose : Converts the gp_Sphere S into this sphere.
Sphere (me) returns Sphere;
--- Purpose : Returns a non persistent sphere with the same geometric
-- properties as <me>.
UReversedParameter(me; U : Real) returns Real;
---Purpose: Computes the u parameter on the modified
-- surface, when reversing its u parametric
-- direction, for any point of u parameter U on this sphere.
-- In the case of a sphere, these functions returns 2.PI - U.
VReversedParameter(me; V : Real) returns Real;
---Purpose: Computes the v parameter on the modified
-- surface, when reversing its v parametric
-- direction, for any point of v parameter V on this sphere.
-- In the case of a sphere, these functions returns -U.
Area (me) returns Real;
--- Purpose : Computes the aera of the spherical surface.
Bounds (me; U1, U2, V1, V2 : out Real);
--- Purpose : Returns the parametric bounds U1, U2, V1 and V2 of this sphere.
-- For a sphere: U1 = 0, U2 = 2*PI, V1 = -PI/2, V2 = PI/2.
Coefficients (me; A1, A2, A3, B1, B2, B3, C1, C2, C3, D : out Real);
--- Purpose : Returns the coefficients of the implicit equation of the
-- quadric in the absolute cartesian coordinates system :
-- These coefficients are normalized.
-- A1.X**2 + A2.Y**2 + A3.Z**2 + 2.(B1.X.Y + B2.X.Z + B3.Y.Z) +
-- 2.(C1.X + C2.Y + C3.Z) + D = 0.0
Radius (me) returns Real;
---Purpose: Computes the coefficients of the implicit equation of
-- this quadric in the absolute Cartesian coordinate system:
-- A1.X**2 + A2.Y**2 + A3.Z**2 + 2.(B1.X.Y + B2.X.Z + B3.Y.Z) +
-- 2.(C1.X + C2.Y + C3.Z) + D = 0.0
-- An implicit normalization is applied (i.e. A1 = A2 = 1.
-- in the local coordinate system of this sphere).
Volume (me) returns Real;
--- Purpose : Computes the volume of the spherical surface.
IsUClosed (me) returns Boolean;
--- Purpose : Returns True.
IsVClosed (me) returns Boolean;
--- Purpose : Returns False.
IsUPeriodic (me) returns Boolean;
--- Purpose : Returns True.
IsVPeriodic (me) returns Boolean;
--- Purpose : Returns False.
UIso (me; U : Real) returns mutable Curve;
--- Purpose : Computes the U isoparametric curve.
-- The U isoparametric curves of the surface are defined by the
-- section of the spherical surface with plane obtained by rotation
-- of the plane (Location, XAxis, ZAxis) around ZAxis. This plane
-- defines the origin of parametrization u.
-- For a SphericalSurface the UIso curve is a Circle.
-- Warnings : The radius of this circle can be zero.
VIso (me; V : Real) returns mutable Curve;
--- Purpose : Computes the V isoparametric curve.
-- The V isoparametric curves of the surface are defined by
-- the section of the spherical surface with plane parallel to the
-- plane (Location, XAxis, YAxis). This plane defines the origin of
-- parametrization V.
-- Be careful if V is close to PI/2 or 3*PI/2 the radius of the
-- circle becomes tiny. It is not forbidden in this toolkit to
-- create circle with radius = 0.0
-- For a SphericalSurface the VIso curve is a Circle.
-- Warnings : The radius of this circle can be zero.
D0 (me; U, V : Real; P : out Pnt);
--- Purpose :
-- Computes the point P (U, V) on the surface.
-- P (U, V) = Loc + Radius * Sin (V) * Zdir +
-- Radius * Cos (V) * (cos (U) * XDir + sin (U) * YDir)
-- where Loc is the origin of the placement plane (XAxis, YAxis)
-- XDir is the direction of the XAxis and YDir the direction of
-- the YAxis and ZDir the direction of the ZAxis.
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec);
--- Purpose :
-- Computes the current point and the first derivatives in the
-- directions U and V.
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec);
--- Purpose :
-- Computes the current point, the first and the second derivatives
-- in the directions U and V.
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV : out Vec);
--- Purpose :
-- Computes the current point, the first,the second and the third
-- derivatives in the directions U and V.
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
--- Purpose :
-- Computes the derivative of order Nu in the direction u
-- and Nv in the direction v.
raises RangeError;
--- Purpose : Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
Transform (me : mutable; T : Trsf) ;
---Purpose: Applies the transformation T to this sphere.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this sphere.
fields
radius : Real;
end;

View File

@@ -0,0 +1,350 @@
// File: Geom_SphericalSurface.cxx
// Created: Wed Mar 10 10:23:09 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_SphericalSurface.cxx, JCV 17/01/91
#include <Geom_SphericalSurface.ixx>
#include <gp_Circ.hxx>
#include <gp_XYZ.hxx>
#include <ElSLib.hxx>
#include <Geom_Circle.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
typedef Geom_Circle Circle;
typedef Geom_SphericalSurface SphericalSurface;
typedef Handle(Geom_SphericalSurface) Handle(SphericalSurface);
typedef Handle(Geom_Curve) Handle(Curve);
typedef Handle(Geom_Circle) Handle(Circle);
typedef gp_Ax2 Ax2;
typedef gp_Ax3 Ax3;
typedef gp_Circ Circ;
typedef gp_Dir Dir;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_XYZ XYZ;
typedef gp_Vec Vec;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_SphericalSurface::Copy () const {
Handle(SphericalSurface) Cs;
Cs = new SphericalSurface (pos, radius);
return Cs;
}
//=======================================================================
//function : Geom_SphericalSurface
//purpose :
//=======================================================================
Geom_SphericalSurface::Geom_SphericalSurface (const Ax3& A, const Standard_Real R)
: radius (R) {
if (R < 0.0) Standard_ConstructionError::Raise();
pos = A;
}
//=======================================================================
//function : Geom_SphericalSurface
//purpose :
//=======================================================================
Geom_SphericalSurface::Geom_SphericalSurface (const gp_Sphere& S)
:radius (S.Radius()) {
pos = S.Position();
}
//=======================================================================
//function : UReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_SphericalSurface::UReversedParameter( const Standard_Real U) const
{
return (2.*PI - U);
}
//=======================================================================
//function : VReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_SphericalSurface::VReversedParameter( const Standard_Real V) const
{
return (-V);
}
//=======================================================================
//function : Area
//purpose :
//=======================================================================
Standard_Real Geom_SphericalSurface::Area () const
{return 4.0 * PI * radius * radius;}
//=======================================================================
//function : Radius
//purpose :
//=======================================================================
Standard_Real Geom_SphericalSurface::Radius () const
{ return radius; }
//=======================================================================
//function : IsUClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_SphericalSurface::IsUClosed () const
{ return Standard_True; }
//=======================================================================
//function : IsVClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_SphericalSurface::IsVClosed () const
{ return Standard_False; }
//=======================================================================
//function : IsUPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_SphericalSurface::IsUPeriodic () const
{ return Standard_True; }
//=======================================================================
//function : IsVPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_SphericalSurface::IsVPeriodic () const
{ return Standard_False; }
//=======================================================================
//function : SetRadius
//purpose :
//=======================================================================
void Geom_SphericalSurface::SetRadius (const Standard_Real R) {
if (R < 0.0) { Standard_ConstructionError::Raise(); }
radius = R;
}
//=======================================================================
//function : SetSphere
//purpose :
//=======================================================================
void Geom_SphericalSurface::SetSphere (const gp_Sphere& S) {
radius = S.Radius();
pos = S.Position();
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void Geom_SphericalSurface::Bounds (Standard_Real& U1, Standard_Real& U2,
Standard_Real& V1, Standard_Real& V2) const {
U1 = 0.0;
U2 = PI * 2.0;
V1 = -PI / 2.0;
V2 = PI / 2.0;
}
//=======================================================================
//function : Coefficients
//purpose :
//=======================================================================
void Geom_SphericalSurface::Coefficients (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3,
Standard_Real& B1, Standard_Real& B2, Standard_Real& B3,
Standard_Real& C1, Standard_Real& C2, Standard_Real& C3,
Standard_Real& D ) const {
// Dans le repere local de la sphere :
// X*X + Y*Y + Z*Z - radius * radius = 0
Trsf T;
T.SetTransformation (pos);
Standard_Real T11 = T.Value (1, 1);
Standard_Real T12 = T.Value (1, 2);
Standard_Real T13 = T.Value (1, 3);
Standard_Real T14 = T.Value (1, 4);
Standard_Real T21 = T.Value (2, 1);
Standard_Real T22 = T.Value (2, 2);
Standard_Real T23 = T.Value (2, 3);
Standard_Real T24 = T.Value (2, 4);
Standard_Real T31 = T.Value (3, 1);
Standard_Real T32 = T.Value (3, 2);
Standard_Real T33 = T.Value (3, 3);
Standard_Real T34 = T.Value (3, 4);
A1 = T11 * T11 + T21 * T21 + T31 * T31;
A2 = T12 * T12 + T22 * T22 + T32 * T32;
A3 = T13 * T13 + T23 * T23 + T33 * T33;
B1 = T11 * T12 + T21 * T22 + T31 * T32;
B2 = T11 * T13 + T21 * T23 + T31 * T33;
B3 = T12 * T13 + T22 * T23 + T32 * T33;
C1 = T11 * T14 + T21 * T24 + T31 * T34;
C2 = T12 * T14 + T22 * T24 + T32 * T34;
C3 = T13 * T14 + T23 * T24 + T33 * T34;
D = T14 * T14 + T24 * T24 + T34 * T34 - radius * radius;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_SphericalSurface::D0 (const Standard_Real U, const Standard_Real V, Pnt& P) const
{
ElSLib::SphereD0(U,V,pos,radius,P);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_SphericalSurface::D1 (const Standard_Real U, const Standard_Real V ,
Pnt& P, Vec& D1U, Vec& D1V
) const
{
ElSLib::SphereD1 (U, V, pos, radius, P ,D1U, D1V);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_SphericalSurface::D2 (const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV ) const
{
ElSLib::SphereD2 (U, V, pos, radius, P, D1U, D1V, D2U, D2V, D2UV);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_SphericalSurface::D3 (const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV,
Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV
) const
{
ElSLib::SphereD3 (U, V, pos, radius, P, D1U, D1V, D2U, D2V,
D2UV, D3U, D3V, D3UUV, D3UVV);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_SphericalSurface::DN (const Standard_Real U, const Standard_Real V,
const Standard_Integer Nu, const Standard_Integer Nv) const {
Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
return ElSLib::SphereDN (U, V, pos, radius, Nu, Nv);
}
//=======================================================================
//function : Sphere
//purpose :
//=======================================================================
gp_Sphere Geom_SphericalSurface::Sphere () const {
return gp_Sphere (pos, radius);
}
//=======================================================================
//function : UIso
//purpose :
//=======================================================================
Handle(Curve) Geom_SphericalSurface::UIso (const Standard_Real U) const
{
Handle(Geom_Circle) GC = new Geom_Circle(ElSLib::SphereUIso(pos,radius,U));
Handle(Geom_TrimmedCurve) iso = new Geom_TrimmedCurve(GC,-PI/2.,PI/2);
return iso;
}
//=======================================================================
//function : VIso
//purpose :
//=======================================================================
Handle(Curve) Geom_SphericalSurface::VIso (const Standard_Real V) const
{
Handle(Geom_Circle)
GC = new Geom_Circle(ElSLib::SphereVIso(pos,radius,V));
return GC;
}
//=======================================================================
//function : Volume
//purpose :
//=======================================================================
Standard_Real Geom_SphericalSurface::Volume () const {
return (4.0 * PI * radius * radius * radius)/3.0;
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_SphericalSurface::Transform (const Trsf& T) {
radius = radius * Abs(T.ScaleFactor());
pos.Transform (T);
}

320
src/Geom/Geom_Surface.cdl Executable file
View File

@@ -0,0 +1,320 @@
-- File: Geom_Surface.cdl
-- Created: Wed Mar 10 10:24:50 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class Surface from Geom inherits Geometry from Geom
---Purpose : Describes the common behavior of surfaces in 3D
-- space. The Geom package provides many
-- implementations of concrete derived surfaces, such as
-- planes, cylinders, cones, spheres and tori, surfaces of
-- linear extrusion, surfaces of revolution, Bezier and
-- BSpline surfaces, and so on.
-- The key characteristic of these surfaces is that they
-- are parameterized. Geom_Surface demonstrates:
-- - how to work with the parametric equation of a
-- surface to compute the point of parameters (u,
-- v), and, at this point, the 1st, 2nd ... Nth derivative,
-- - how to find global information about a surface in
-- each parametric direction (for example, level of
-- continuity, whether the surface is closed, its
-- periodicity, the bounds of the parameters and so on), and
-- - how the parameters change when geometric
-- transformations are applied to the surface, or the
-- orientation is modified.
-- Note that all surfaces must have a geometric
-- continuity, and any surface is at least "C0". Generally,
-- continuity is checked at construction time or when the
-- curve is edited. Where this is not the case, the
-- documentation makes this explicit.
-- Warning
-- The Geom package does not prevent the construction of
-- surfaces with null areas, or surfaces which self-intersect.
uses Pnt from gp,
Vec from gp,
Trsf from gp,
GTrsf2d from gp,
Shape from GeomAbs,
Curve from Geom
raises RangeError from Standard,
NoSuchObject from Standard,
UndefinedDerivative from Geom,
UndefinedValue from Geom
is
UReverse (me : mutable)
---Purpose :
-- Reverses the U direction of parametrization of <me>.
-- The bounds of the surface are not modified.
is deferred;
UReversed (me) returns mutable like me
---Purpose :
-- Reverses the U direction of parametrization of <me>.
-- The bounds of the surface are not modified.
-- A copy of <me> is returned.
is static;
UReversedParameter (me; U : Real) returns Real
---Purpose: Returns the parameter on the Ureversed surface for
-- the point of parameter U on <me>.
--
-- me->UReversed()->Value(me->UReversedParameter(U),V)
--
-- is the same point as
--
-- me->Value(U,V)
is deferred;
VReverse (me : mutable)
---Purpose :
-- Reverses the V direction of parametrization of <me>.
-- The bounds of the surface are not modified.
is deferred;
VReversed (me) returns mutable like me
---Purpose :
-- Reverses the V direction of parametrization of <me>.
-- The bounds of the surface are not modified.
-- A copy of <me> is returned.
is static;
VReversedParameter (me; V : Real) returns Real
---Purpose: Returns the parameter on the Vreversed surface for
-- the point of parameter V on <me>.
--
-- me->VReversed()->Value(U,me->VReversedParameter(V))
--
-- is the same point as
--
-- me->Value(U,V)
is deferred;
TransformParameters(me; U,V : in out Real; T : Trsf from gp)
---Purpose: Computes the parameters on the transformed surface for
-- the transform of the point of parameters U,V on <me>.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are the new values of U,V after calling
--
-- me->TranformParameters(U,V,T)
--
-- This methods does not change <U> and <V>
--
-- It can be redefined. For example on the Plane,
-- Cylinder, Cone, Revolved and Extruded surfaces.
is virtual;
ParametricTransformation(me; T : Trsf from gp) returns GTrsf2d from gp
---Purpose: Returns a 2d transformation used to find the new
-- parameters of a point on the transformed surface.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are obtained by transforming U,V with
-- th 2d transformation returned by
--
-- me->ParametricTransformation(T)
--
-- This methods returns an identity transformation
--
-- It can be redefined. For example on the Plane,
-- Cylinder, Cone, Revolved and Extruded surfaces.
--
is virtual;
Bounds(me; U1, U2, V1, V2 : out Real)
---Purpose: Returns the parametric bounds U1, U2, V1 and V2 of this surface.
-- If the surface is infinite, this function can return a value
-- equal to Precision::Infinite: instead of Standard_Real::LastReal.
is deferred;
IsUClosed (me) returns Boolean
---Purpose : Checks whether this surface is closed in the u
-- parametric direction.
-- Returns true if, in the u parametric direction: taking
-- uFirst and uLast as the parametric bounds in
-- the u parametric direction, for each parameter v, the
-- distance between the points P(uFirst, v) and
-- P(uLast, v) is less than or equal to gp::Resolution().
is deferred;
IsVClosed (me) returns Boolean
---Purpose : Checks whether this surface is closed in the u
-- parametric direction.
-- Returns true if, in the v parametric
-- direction: taking vFirst and vLast as the
-- parametric bounds in the v parametric direction, for
-- each parameter u, the distance between the points
-- P(u, vFirst) and P(u, vLast) is less than
-- or equal to gp::Resolution().
is deferred;
IsUPeriodic (me) returns Boolean
---Purpose : Checks if this surface is periodic in the u
-- parametric direction. Returns true if:
-- - this surface is closed in the u parametric direction, and
-- - there is a constant T such that the distance
-- between the points P (u, v) and P (u + T,
-- v) (or the points P (u, v) and P (u, v +
-- T)) is less than or equal to gp::Resolution().
-- Note: T is the parametric period in the u parametric direction.
is deferred;
UPeriod (me) returns Real from Standard
---Purpose: Returns the period of this surface in the u
-- parametric direction.
raises
NoSuchObject from Standard
---Purpose: raises if the surface is not uperiodic.
is virtual;
IsVPeriodic (me) returns Boolean
---Purpose : Checks if this surface is periodic in the v
-- parametric direction. Returns true if:
-- - this surface is closed in the v parametric direction, and
-- - there is a constant T such that the distance
-- between the points P (u, v) and P (u + T,
-- v) (or the points P (u, v) and P (u, v +
-- T)) is less than or equal to gp::Resolution().
-- Note: T is the parametric period in the v parametric direction.
is deferred;
VPeriod (me) returns Real from Standard
---Purpose: Returns the period of this surface in the v parametric direction.
raises
NoSuchObject from Standard
---Purpose: raises if the surface is not vperiodic.
is virtual;
UIso (me; U : Real) returns mutable Curve
---Purpose : Computes the U isoparametric curve.
is deferred;
VIso (me; V : Real) returns mutable Curve
---Purpose : Computes the V isoparametric curve.
is deferred;
Continuity (me) returns Shape from GeomAbs
---Purpose :
-- Returns the Global Continuity of the surface in direction U and V :
-- C0 : only geometric continuity,
-- C1 : continuity of the first derivative all along the surface,
-- C2 : continuity of the second derivative all along the surface,
-- C3 : continuity of the third derivative all along the surface,
-- G1 : tangency continuity all along the surface,
-- G2 : curvature continuity all along the surface,
-- CN : the order of continuity is infinite.
-- Example :
-- If the surface is C1 in the V parametric direction and C2
-- in the U parametric direction Shape = C1.
is deferred;
IsCNu (me; N : Integer) returns Boolean
---Purpose : Returns the order of continuity of the surface in the
-- U parametric direction.
raises RangeError
---Purpose : Raised if N < 0.
is deferred;
IsCNv (me; N : Integer) returns Boolean
---Purpose : Returns the order of continuity of the surface in the
-- V parametric direction.
raises RangeError
---Purpose : Raised if N < 0.
is deferred;
D0 (me; U, V : Real; P : out Pnt)
---Purpose : Computes the point of parameter U,V on the surface.
raises UndefinedValue
---Purpose :
-- Raised only for an "OffsetSurface" if it is not possible to
-- compute the current point.
is deferred;
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec)
---Purpose :
-- Computes the point P and the first derivatives in the
-- directions U and V at this point.
raises UndefinedDerivative
---Purpose : Raised if the continuity of the surface is not C1.
is deferred;
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec)
---Purpose :
-- Computes the point P, the first and the second derivatives in
-- the directions U and V at this point.
raises UndefinedDerivative
---Purpose : Raised if the continuity of the surface is not C2.
is deferred;
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV :out Vec)
---Purpose :
-- Computes the point P, the first,the second and the third
-- derivatives in the directions U and V at this point.
raises UndefinedDerivative
---Purpose : Raised if the continuity of the surface is not C2.
is deferred;
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
---Purpose ;
-- Computes the derivative of order Nu in the direction U and Nv
-- in the direction V at the point P(U, V).
raises UndefinedDerivative,
---Purpose :
-- Raised if the continuity of the surface is not CNu in the U
-- direction or not CNv in the V direction.
RangeError
---Purpose : Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
is deferred;
Value (me; U, V : Real) returns Pnt
---Purpose :
-- Computes the point of parameter U on the surface.
--
-- It is implemented with D0
raises UndefinedValue
---Purpose :
-- Raised only for an "OffsetSurface" if it is not possible to
-- compute the current point.
is static;
end;

105
src/Geom/Geom_Surface.cxx Executable file
View File

@@ -0,0 +1,105 @@
// File: Geom_Surface.cxx
// Created: Wed Mar 10 10:27:16 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Surface.cxx, JCV 17/01/91
#include <Geom_Surface.ixx>
typedef Geom_Surface Surface;
typedef Handle(Geom_Surface) Handle(Surface);
//=======================================================================
//function : UReversed
//purpose :
//=======================================================================
Handle(Surface) Geom_Surface::UReversed () const
{
Handle(Surface) S = Handle(Surface)::DownCast(Copy());
S->UReverse();
return S;
}
//=======================================================================
//function : VReversed
//purpose :
//=======================================================================
Handle(Surface) Geom_Surface::VReversed () const
{
Handle(Surface) S = Handle(Surface)::DownCast(Copy());
S->VReverse();
return S;
}
//=======================================================================
//function : TransformParameters
//purpose :
//=======================================================================
void Geom_Surface::TransformParameters(Standard_Real& ,
Standard_Real& ,
const gp_Trsf& ) const
{
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
gp_GTrsf2d Geom_Surface::ParametricTransformation(const gp_Trsf&) const
{
gp_GTrsf2d dummy;
return dummy;
}
//=======================================================================
//function : UPeriod
//purpose :
//=======================================================================
Standard_Real Geom_Surface::UPeriod() const
{
Standard_NoSuchObject_Raise_if
( !IsUPeriodic(),"Geom_Surface::UPeriod");
Standard_Real U1, U2, V1, V2;
Bounds(U1,U2,V1,V2);
return ( U2 - U1);
}
//=======================================================================
//function : VPeriod
//purpose :
//=======================================================================
Standard_Real Geom_Surface::VPeriod() const
{
Standard_NoSuchObject_Raise_if
( !IsVPeriodic(),"Geom_Surface::VPeriod");
Standard_Real U1, U2, V1, V2;
Bounds(U1,U2,V1,V2);
return ( V2 - V1);
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
gp_Pnt Geom_Surface::Value(const Standard_Real U,
const Standard_Real V)const
{
gp_Pnt P;
D0(U,V,P);
return P;
}

View File

@@ -0,0 +1,293 @@
-- File: Geom_SurfaceOfLinearExtrusion.cdl
-- Created: Wed Mar 10 10:27:29 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class SurfaceOfLinearExtrusion from Geom inherits SweptSurface from Geom
--- Purpose : Describes a surface of linear extrusion ("extruded
-- surface"), e.g. a generalized cylinder. Such a surface
-- is obtained by sweeping a curve (called the "extruded
-- curve" or "basis") in a given direction (referred to as
-- the "direction of extrusion" and defined by a unit vector).
-- The u parameter is along the extruded curve. The v
-- parameter is along the direction of extrusion.
-- The parameter range for the u parameter is defined
-- by the reference curve.
-- The parameter range for the v parameter is ] -
-- infinity, + infinity [.
-- The position of the curve gives the origin of the v parameter.
-- The surface is "CN" in the v parametric direction.
-- The form of a surface of linear extrusion is generally a
-- ruled surface (GeomAbs_RuledForm). It can be:
-- - a cylindrical surface, if the extruded curve is a circle,
-- or a trimmed circle, with an axis parallel to the
-- direction of extrusion (GeomAbs_CylindricalForm), or
-- - a planar surface, if the extruded curve is a line
-- (GeomAbs_PlanarForm).
-- Note: The surface of extrusion is built from a copy of
-- the original basis curve, so the original curve is not
-- modified when the surface is modified.
-- Warning
-- Degenerate surfaces are not detected. A degenerate
-- surface is obtained, for example, when the extruded
-- curve is a line and the direction of extrusion is parallel
-- to that line.
uses Ax1 from gp,
Ax2 from gp,
Dir from gp,
Pnt from gp,
Trsf from gp,
GTrsf2d from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom,
BSplineCurve from Geom,
Shape from GeomAbs,
CurveType from GeomAbs
raises RangeError from Standard,
UndefinedDerivative from Geom
is
Create (C : Curve; V : Dir) returns mutable SurfaceOfLinearExtrusion;
--- Purpose :
-- V is the direction of extrusion.
-- C is the extruded curve.
-- The form of a SurfaceOfLinearExtrusion can be :
-- . ruled surface (RuledForm),
-- . a cylindrical surface if the extruded curve is a circle or
-- a trimmed circle (CylindricalForm),
-- . a plane surface if the extruded curve is a Line (PlanarForm).
-- Warnings :
-- Degenerated surface cases are not detected. For example if the
-- curve C is a line and V is parallel to the direction of this
-- line.
SetDirection (me : mutable; V : Dir);
--- Purpose : Assigns V as the "direction of extrusion" for this
-- surface of linear extrusion.
SetBasisCurve (me : mutable; C : Curve);
--- Purpose : Modifies this surface of linear extrusion by redefining
-- its "basis curve" (the "extruded curve").
UReverse (me : mutable);
--- Purpose : Changes the orientation of this surface of linear
-- extrusion in the u parametric direction. The
-- bounds of the surface are not changed, but the given
-- parametric direction is reversed. Hence the
-- orientation of the surface is reversed.
-- In the case of a surface of linear extrusion:
-- - UReverse reverses the basis curve, and
-- - VReverse reverses the direction of linear extrusion.
UReversedParameter (me; U : Real) returns Real;
---Purpose: Computes the u parameter on the modified
-- surface, produced by reversing its u parametric
-- direction, for any point of u parameter U on this surface of linear extrusion.
-- In the case of an extruded surface:
-- - UReverseParameter returns the reversed
-- parameter given by the function
-- ReversedParameter called with U on the basis curve,
VReverse (me : mutable);
--- Purpose : Changes the orientation of this surface of linear
-- extrusion in the v parametric direction. The
-- bounds of the surface are not changed, but the given
-- parametric direction is reversed. Hence the
-- orientation of the surface is reversed.
-- In the case of a surface of linear extrusion:
-- - UReverse reverses the basis curve, and
-- - VReverse reverses the direction of linear extrusion.
VReversedParameter (me; V : Real) returns Real;
---Purpose: Computes the v parameter on the modified
-- surface, produced by reversing its u v parametric
-- direction, for any point of v parameter V on this surface of linear extrusion.
-- In the case of an extruded surface VReverse returns -V.
Bounds (me; U1, U2, V1, V2 : out Real);
--- Purpose : Returns the parametric bounds U1, U2, V1 and V2 of
-- this surface of linear extrusion.
-- A surface of linear extrusion is infinite in the v
-- parametric direction, so:
-- - V1 = Standard_Real::RealFirst()
-- - V2 = Standard_Real::RealLast().
IsUClosed (me) returns Boolean;
--- Purpose: IsUClosed returns true if the "basis curve" of this
-- surface of linear extrusion is closed.
IsVClosed (me) returns Boolean;
--- Purpose : IsVClosed always returns false.
IsCNu (me; N : Integer) returns Boolean
--- Purpose : IsCNu returns true if the degree of continuity for the
-- "basis curve" of this surface of linear extrusion is at least N.
-- Raises RangeError if N < 0.
raises RangeError;
IsCNv (me; N : Integer) returns Boolean;
--- Purpose : IsCNv always returns true.
IsUPeriodic (me) returns Boolean;
--- Purpose : IsUPeriodic returns true if the "basis curve" of this
-- surface of linear extrusion is periodic.
IsVPeriodic (me) returns Boolean;
--- Purpose : IsVPeriodic always returns false.
UIso (me; U : Real) returns mutable Curve;
--- Purpose : Computes the U isoparametric curve of this surface
-- of linear extrusion. This is the line parallel to the
-- direction of extrusion, passing through the point of
-- parameter U of the basis curve.
VIso (me; V : Real) returns mutable Curve;
--- Purpose : Computes the V isoparametric curve of this surface
-- of linear extrusion. This curve is obtained by
-- translating the extruded curve in the direction of
-- extrusion, with the magnitude V.
D0 (me; U, V : Real; P : out Pnt);
--- Purpose :
-- Computes the point P (U, V) on the surface.
-- The parameter U is the parameter on the extruded curve.
-- The parametrization V is a linear parametrization, and
-- the direction of parametrization is the direction of
-- extrusion. If the point is on the extruded curve, V = 0.0
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec)
--- Purpose :
-- Computes the current point and the first derivatives in the
-- directions U and V.
-- Raises UndefinedDerivative if the continuity of the surface is not C1.
raises UndefinedDerivative;
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec)
--- Purpose ;
-- Computes the current point, the first and the second derivatives
-- in the directions U and V.
-- Raises UndefinedDerivative if the continuity of the surface is not C2.
raises UndefinedDerivative;
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV : out Vec)
--- Purpose :
-- Computes the current point, the first,the second and the third
-- derivatives in the directions U and V.
-- Raises UndefinedDerivative if the continuity of the surface is not C3.
raises UndefinedDerivative;
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
--- Purpose :
-- Computes the derivative of order Nu in the direction u
-- and Nv in the direction v.
-- Raises UndefinedDerivative if the continuity of the surface is not CNu in the u
-- direction and CNv in the v direction.
--- Raises RangeError if Nu + Nv < 1 or Nu < 0 or Nv < 0.
raises UndefinedDerivative,
RangeError;
LocalD0 (me; U, V : Real; USide : Integer;
P : out Pnt);
---Purpose : The following functions evaluates the local
-- derivatives on surface. Useful to manage discontinuities
-- on the surface.
-- if Side = 1 -> P = S( U+,V )
-- if Side = -1 -> P = S( U-,V )
-- else P is betveen discontinuities
-- can be evaluated using methods of
-- global evaluations P = S( U ,V )
LocalD1 (me; U, V : Real; USide : Integer;
P : out Pnt; D1U, D1V : out Vec);
LocalD2 (me; U, V : Real; USide : Integer;
P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec);
LocalD3 (me; U, V : Real; USide : Integer;
P : out Pnt; D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV :
out Vec);
LocalDN (me; U, V : Real; USide : Integer;
Nu, Nv : Integer)
returns Vec;
Transform(me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this surface of linear extrusion.
TransformParameters(me; U,V : in out Real; T : Trsf from gp)
---Purpose: Computes the parameters on the transformed surface for
-- the transform of the point of parameters U,V on <me>.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are the new values of U,V after calling
--
-- me->TranformParameters(U,V,T)
--
-- This methods multiplies :
-- U by BasisCurve()->ParametricTransformation(T)
-- V by T.ScaleFactor()
is redefined;
ParametricTransformation(me; T : Trsf from gp) returns GTrsf2d from gp
---Purpose: Returns a 2d transformation used to find the new
-- parameters of a point on the transformed surface.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are obtained by transforming U,V with
-- th 2d transformation returned by
--
-- me->ParametricTransformation(T)
--
-- This methods returns a scale
-- U by BasisCurve()->ParametricTransformation(T)
-- V by T.ScaleFactor()
is redefined;
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this surface of linear extrusion.
end;

View File

@@ -0,0 +1,604 @@
// File: Geom_SurfaceOfLinearExtrusion.cxx
// Created: Wed Mar 10 10:28:33 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_SurfaceOfLinearExtrusion.cxx, JCV 4/03/91
#include <GeomAbs_CurveType.hxx>
#include <Geom_SurfaceOfLinearExtrusion.ixx>
#include <Precision.hxx>
#include <gp.hxx>
#include <gp_Ax2d.hxx>
#include <gp_XYZ.hxx>
#include <gp_Lin.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_Parabola.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_OffsetCurve.hxx>
#include <BSplSLib.hxx>
#include <BSplCLib.hxx>
#include <Standard_RangeError.hxx>
#define POLES (poles->Array2())
#define WEIGHTS (weights->Array2())
#define UKNOTS (uknots->Array1())
#define VKNOTS (vknots->Array1())
#define UFKNOTS (ufknots->Array1())
#define VFKNOTS (vfknots->Array1())
#define FMULTS (BSplCLib::NoMults())
typedef Geom_SurfaceOfLinearExtrusion SurfaceOfLinearExtrusion;
typedef Handle(Geom_SurfaceOfLinearExtrusion) Handle(SurfaceOfLinearExtrusion);
typedef Geom_Curve Curve;
typedef Handle(Geom_Curve) Handle(Curve);
typedef gp_Dir Dir;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
typedef gp_XYZ XYZ;
static void LocateSide(const Standard_Real U,
const Standard_Integer Side,
const Handle(Geom_BSplineCurve)& BSplC,
const Standard_Integer NDir,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D2U,
gp_Vec& D3U)
{
Standard_Integer Ideb, Ifin;
Standard_Real ParTol=Precision::PConfusion()/2;
BSplC->Geom_BSplineCurve::LocateU(U,ParTol,Ideb,Ifin,Standard_False);
if(Side == 1)
{
if(Ideb<1) Ideb=1;
if ((Ideb>=Ifin)) Ifin = Ideb+1;
}else
if(Side ==-1)
{
if(Ifin > BSplC -> NbKnots()) Ifin=BSplC->NbKnots();
if ((Ideb>=Ifin)) Ideb = Ifin-1;
}
switch(NDir)
{
case 0 : BSplC->Geom_BSplineCurve::LocalD0(U,Ideb,Ifin,P); break;
case 1 : BSplC->Geom_BSplineCurve::LocalD1(U,Ideb,Ifin,P,D1U); break;
case 2 : BSplC->Geom_BSplineCurve::LocalD2(U,Ideb,Ifin,P,D1U,D2U); break;
case 3 : BSplC->Geom_BSplineCurve::LocalD3(U,Ideb,Ifin,P,D1U,D2U,D3U);break;
}
}
static gp_Vec LocateSideN(const Standard_Real U,
const Standard_Integer Side,
const Handle(Geom_BSplineCurve)& BSplC,
const Standard_Integer Nu,
// const Standard_Integer Nv )
const Standard_Integer )
{
Standard_Integer Ideb, Ifin;
Standard_Real ParTol=Precision::PConfusion()/2;
BSplC->Geom_BSplineCurve::LocateU(U,ParTol,Ideb,Ifin,Standard_False);
if(Side == 1)
{
if(Ideb<1) Ideb=1;
if ((Ideb>=Ifin)) Ifin = Ideb+1;
}else
if(Side ==-1)
{
if(Ifin > BSplC -> NbKnots()) Ifin=BSplC->NbKnots();
if ((Ideb>=Ifin)) Ideb = Ifin-1;
}
return BSplC->Geom_BSplineCurve::LocalDN(U,Ideb,Ifin,Nu);
}
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_SurfaceOfLinearExtrusion::Copy () const
{
Handle(Geom_SurfaceOfLinearExtrusion) Sr;
Sr = new SurfaceOfLinearExtrusion (basisCurve, direction);
return Sr;
}
//=======================================================================
//function : Geom_SurfaceOfLinearExtrusion
//purpose :
//=======================================================================
Geom_SurfaceOfLinearExtrusion::Geom_SurfaceOfLinearExtrusion
( const Handle(Curve)& C,
const Dir& V) {
basisCurve = Handle(Curve)::DownCast(C->Copy()); // Copy 10-03-93
direction = V;
smooth = C->Continuity();
}
//=======================================================================
//function : UReverse
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::UReverse () {
basisCurve->Reverse();
}
//=======================================================================
//function : UReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_SurfaceOfLinearExtrusion::UReversedParameter(const Standard_Real U) const {
return basisCurve->ReversedParameter(U);
}
//=======================================================================
//function : VReverse
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::VReverse () {
direction.Reverse();
}
//=======================================================================
//function : VReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_SurfaceOfLinearExtrusion::VReversedParameter( const Standard_Real V) const {
return (-V);
}
//=======================================================================
//function : SetDirection
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::SetDirection (const Dir& V) {
Handle(Geom_Curve) C;
direction = V;
C = basisCurve;
}
//=======================================================================
//function : SetBasisCurve
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::SetBasisCurve (const Handle(Curve)& C) {
smooth = C->Continuity();
basisCurve = Handle(Curve)::DownCast(C->Copy()); // Copy 10-03-93
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::Bounds ( Standard_Real& U1,
Standard_Real& U2,
Standard_Real& V1,
Standard_Real& V2 ) const {
V1 = -Precision::Infinite(); V2 = Precision::Infinite();
U1 = basisCurve->FirstParameter(); U2 = basisCurve->LastParameter();
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::D0 (const Standard_Real U, const Standard_Real V,
Pnt& P ) const {
XYZ Pxyz = direction.XYZ();
Pxyz.Multiply (V);
Pxyz.Add (basisCurve->Value (U).XYZ());
P.SetXYZ(Pxyz);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::D1 ( const Standard_Real U ,
const Standard_Real V ,
Pnt& P ,
Vec& D1U, Vec& D1V) const {
basisCurve->D1 (U, P, D1U);
D1V = direction;
XYZ Pxyz = direction.XYZ();
Pxyz.Multiply (V);
Pxyz.Add (P.XYZ());
P.SetXYZ (Pxyz);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::D2 ( const Standard_Real U ,
const Standard_Real V ,
Pnt& P ,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV)
const {
basisCurve->D2 (U, P, D1U, D2U);
D1V = direction;
D2V.SetCoord (0.0, 0.0, 0.0);
D2UV.SetCoord (0.0, 0.0, 0.0);
XYZ Pxyz = direction.XYZ();
Pxyz.Multiply (V);
Pxyz.Add (P.XYZ());
P.SetXYZ (Pxyz);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::D3
( const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV,
Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV ) const {
basisCurve->D3 (U, P, D1U, D2U, D3U);
D1V = direction;
D2V.SetCoord (0.0, 0.0, 0.0);
D3V.SetCoord (0.0, 0.0, 0.0);
D3UUV.SetCoord (0.0, 0.0, 0.0);
D3UVV.SetCoord (0.0, 0.0, 0.0);
D2UV.SetCoord (0.0, 0.0, 0.0);
XYZ Pxyz = direction.XYZ();
Pxyz.Multiply (V);
Pxyz.Add (P.XYZ());
P.SetXYZ (Pxyz);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_SurfaceOfLinearExtrusion::DN
( const Standard_Real U, const Standard_Real ,
const Standard_Integer Nu, const Standard_Integer Nv) const {
Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
if (Nu == 0 && Nv == 1) return Vec (direction);
else if (Nv == 0) return basisCurve->DN (U, Nu);
else return Vec (0.0, 0.0, 0.0);
}
//=======================================================================
//function : LocalD0
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::LocalD0 (const Standard_Real U,
const Standard_Real V,
const Standard_Integer USide,
gp_Pnt& P ) const
{
if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve)))
{
Vec D1U,D2U,D3U;
Handle( Geom_BSplineCurve) BSplC;
BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve);
LocateSide(U,USide,BSplC,0,P,D1U,D2U,D3U);
XYZ Pxyz = direction.XYZ();
Pxyz.Multiply (V);
Pxyz.Add (P.XYZ());
P.SetXYZ (Pxyz);
}
else D0(U,V,P);
}
//=======================================================================
//function : LocalD1
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::LocalD1 (const Standard_Real U,
const Standard_Real V,
const Standard_Integer USide,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V) const
{
if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve)))
{
Vec D2U,D3U;
Handle( Geom_BSplineCurve) BSplC;
BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve);
LocateSide(U,USide,BSplC,1,P,D1U,D2U,D3U);
D1V = direction;
XYZ Pxyz = direction.XYZ();
Pxyz.Multiply (V);
Pxyz.Add (P.XYZ());
P.SetXYZ (Pxyz);
}
else D1(U,V,P,D1U,D1V);
}
//=======================================================================
//function : LocalD2
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::LocalD2 (const Standard_Real U,
const Standard_Real V,
const Standard_Integer USide,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V,
gp_Vec& D2U,
gp_Vec& D2V,
gp_Vec& D2UV) const
{
if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve)))
{
Vec D3U;
Handle( Geom_BSplineCurve) BSplC;
BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve);
LocateSide(U,USide,BSplC,2,P,D1U,D2U,D3U);
D1V = direction;
D2V.SetCoord (0.0, 0.0, 0.0);
D2UV.SetCoord (0.0, 0.0, 0.0);
XYZ Pxyz = direction.XYZ();
Pxyz.Multiply (V);
Pxyz.Add (P.XYZ());
P.SetXYZ (Pxyz);
}
else D2(U,V,P,D1U,D1V,D2U,D2V,D2UV);
}
//=======================================================================
//function : LocalD3
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::LocalD3 (const Standard_Real U,
const Standard_Real V,
const Standard_Integer USide,
gp_Pnt& P,
gp_Vec& D1U,
gp_Vec& D1V,
gp_Vec& D2U,
gp_Vec& D2V,
gp_Vec& D2UV,
gp_Vec& D3U,
gp_Vec& D3V,
gp_Vec& D3UUV,
gp_Vec& D3UVV) const
{
if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve)))
{
Handle( Geom_BSplineCurve) BSplC;
BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve);
LocateSide(U,USide,BSplC,3,P,D1U,D2U,D3U);
D1V = direction;
D2V.SetCoord (0.0, 0.0, 0.0);
D3V.SetCoord (0.0, 0.0, 0.0);
D3UUV.SetCoord (0.0, 0.0, 0.0);
D3UVV.SetCoord (0.0, 0.0, 0.0);
D2UV.SetCoord (0.0, 0.0, 0.0);
XYZ Pxyz = direction.XYZ();
Pxyz.Multiply (V);
Pxyz.Add (P.XYZ());
P.SetXYZ (Pxyz);
}
else D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV);
}
//=======================================================================
//function : LocalDN
//purpose :
//=======================================================================
gp_Vec Geom_SurfaceOfLinearExtrusion::LocalDN (const Standard_Real U,
const Standard_Real V,
const Standard_Integer USide,
const Standard_Integer Nu,
const Standard_Integer Nv) const
{
Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
if (Nu == 0 && Nv == 1) return Vec (direction);
else if (Nv == 0) {
if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
Handle( Geom_BSplineCurve) BSplC;
BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve);
return LocateSideN(U,USide,BSplC,Nu,Nv);
}
else
return DN(U,V,Nu,Nv);
}
return Vec (0.0, 0.0, 0.0);
}
//=======================================================================
//function : UIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_SurfaceOfLinearExtrusion::UIso (const Standard_Real U) const {
Handle(Geom_Line) L;
L = new Geom_Line (basisCurve->Value (U), direction);
return L;
}
//=======================================================================
//function : VIso
//purpose :
//=======================================================================
Handle(Curve) Geom_SurfaceOfLinearExtrusion::VIso (const Standard_Real V) const {
Vec Vdir (direction);
Vdir.Multiply (V);
Handle(Curve) C;
C = Handle(Geom_Curve)::DownCast(basisCurve->Translated(Vdir));
return C;
}
//=======================================================================
//function : IsCNu
//purpose :
//=======================================================================
Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsCNu (const Standard_Integer N) const {
Standard_RangeError_Raise_if (N < 0, " ");
return basisCurve->IsCN (N);
}
//=======================================================================
//function : IsCNv
//purpose :
//=======================================================================
Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsCNv (const Standard_Integer ) const {
return Standard_True;
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::Transform (const Trsf& T) {
direction.Transform (T);
basisCurve->Transform (T);
}
//=======================================================================
//function : IsUClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsUClosed () const {
return basisCurve->IsClosed ();
}
//=======================================================================
//function : IsUPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsUPeriodic () const {
return basisCurve->IsPeriodic ();
}
//=======================================================================
//function : IsVClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsVClosed () const {
return Standard_False;
}
//=======================================================================
//function : IsVPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_SurfaceOfLinearExtrusion::IsVPeriodic () const {
return Standard_False;
}
//=======================================================================
//function : TransformParameters
//purpose :
//=======================================================================
void Geom_SurfaceOfLinearExtrusion::TransformParameters(Standard_Real& U,
Standard_Real& V,
const gp_Trsf& T)
const
{
U = basisCurve->TransformedParameter(U,T);
if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
gp_GTrsf2d Geom_SurfaceOfLinearExtrusion::ParametricTransformation
(const gp_Trsf& T) const
{
// transformation in the V Direction
gp_GTrsf2d TV;
gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
TV.SetAffinity(Axis, Abs(T.ScaleFactor()));
// transformation in the U Direction
gp_GTrsf2d TU;
Axis = gp_Ax2d(gp::Origin2d(),gp::DY2d());
TU.SetAffinity(Axis, basisCurve->ParametricTransformation(T));
return TU * TV;
}

View File

@@ -0,0 +1,349 @@
-- File: Geom_SurfaceOfRevolution.cdl
-- Created: Wed Mar 10 10:30:24 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class SurfaceOfRevolution from Geom inherits SweptSurface from Geom
---Purpose : Describes a surface of revolution (revolved surface).
-- Such a surface is obtained by rotating a curve (called
-- the "meridian") through a complete revolution about
-- an axis (referred to as the "axis of revolution"). The
-- curve and the axis must be in the same plane (the
-- "reference plane" of the surface).
-- Rotation around the axis of revolution in the
-- trigonometric sense defines the u parametric
-- direction. So the u parameter is an angle, and its
-- origin is given by the position of the meridian on the surface.
-- The parametric range for the u parameter is: [ 0, 2.*Pi ]
-- The v parameter is that of the meridian.
-- Note: A surface of revolution is built from a copy of the
-- original meridian. As a result the original meridian is
-- not modified when the surface is modified.
-- The form of a surface of revolution is typically a
-- general revolution surface
-- (GeomAbs_RevolutionForm). It can be:
-- - a conical surface, if the meridian is a line or a
-- trimmed line (GeomAbs_ConicalForm),
-- - a cylindrical surface, if the meridian is a line or a
-- trimmed line parallel to the axis of revolution
-- (GeomAbs_CylindricalForm),
-- - a planar surface if the meridian is a line or a
-- trimmed line perpendicular to the axis of revolution
-- of the surface (GeomAbs_PlanarForm),
-- - a toroidal surface, if the meridian is a circle or a
-- trimmed circle (GeomAbs_ToroidalForm), or
-- - a spherical surface, if the meridian is a circle, the
-- center of which is located on the axis of the
-- revolved surface (GeomAbs_SphericalForm).
-- Warning
-- Be careful not to construct a surface of revolution
-- where the curve and the axis or revolution are not
-- defined in the same plane. If you do not have a
-- correct configuration, you can correct your initial
-- curve, using a cylindrical projection in the reference plane.
uses Ax1 from gp,
Ax2 from gp,
Dir from gp,
Pnt from gp,
Trsf from gp,
GTrsf2d from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom,
Shape from GeomAbs,
BSplineCurve from Geom
raises ConstructionError from Standard,
RangeError from Standard,
UndefinedDerivative from Geom
is
Create (C : Curve; A1 : Ax1) returns mutable SurfaceOfRevolution;
---Purpose :
-- C : is the meridian or the referenced curve.
-- A1 is the axis of revolution.
-- The form of a SurfaceOfRevolution can be :
-- . a general revolution surface (RevolutionForm),
-- . a conical surface if the meridian is a line or a trimmed line
-- (ConicalForm),
-- . a cylindrical surface if the meridian is a line or a trimmed
-- line parallel to the revolution axis (CylindricalForm),
-- . a planar surface if the meridian is a line perpendicular to
-- the revolution axis of the surface (PlanarForm).
-- . a spherical surface,
-- . a toroidal surface,
-- . a quadric surface.
-- Warnings :
-- It is not checked that the curve C is planar and that the
-- surface axis is in the plane of the curve.
-- It is not checked that the revolved curve C doesn't
-- self-intersects.
SetAxis (me : mutable; A1 : Ax1);
---Purpose : Changes the axis of revolution.
-- Warnings :
-- It is not checked that the axis is in the plane of the
-- revolved curve.
SetDirection (me : mutable; V : Dir);
---Purpose : Changes the direction of the revolution axis.
-- Warnings :
-- It is not checked that the axis is in the plane of the
-- revolved curve.
SetBasisCurve (me : mutable; C : Curve);
---Purpose : Changes the revolved curve of the surface.
-- Warnings :
-- It is not checked that the curve C is planar and that the
-- surface axis is in the plane of the curve.
-- It is not checked that the revolved curve C doesn't
-- self-intersects.
SetLocation (me : mutable; P : Pnt);
---Purpose : Changes the location point of the revolution axis.
-- Warnings :
-- It is not checked that the axis is in the plane of the
-- revolved curve.
Axis (me) returns Ax1;
---Purpose : Returns the revolution axis of the surface.
Location (me) returns Pnt;
---Purpose :
-- Returns the location point of the axis of revolution.
---C++: return const&
ReferencePlane (me) returns Ax2
---Purpose :
-- Computes the position of the reference plane of the surface
-- defined by the basis curve and the symmetry axis.
-- The location point is the location point of the revolution's
-- axis, the XDirection of the plane is given by the revolution's
-- axis and the orientation of the normal to the plane is given
-- by the sense of revolution.
raises ConstructionError;
---Purpose :
-- Raised if the revolved curve is not planar or if the revolved
-- curve and the symmetry axis are not in the same plane or if
-- the maximum of distance between the axis and the revolved
-- curve is lower or equal to Resolution from gp.
UReverse (me : mutable);
---Purpose : Changes the orientation of this surface of revolution
-- in the u parametric direction. The bounds of the
-- surface are not changed but the given parametric
-- direction is reversed. Hence the orientation of the
-- surface is reversed.
-- As a consequence:
-- - UReverse reverses the direction of the axis of
-- revolution of this surface,
UReversedParameter ( me; U : Real) returns Real;
---Purpose: Computes the u parameter on the modified
-- surface, when reversing its u parametric
-- direction, for any point of u parameter U on this surface of revolution.
-- In the case of a revolved surface:
-- - UReversedParameter returns 2.*Pi - U
VReverse (me : mutable);
---Purpose : Changes the orientation of this surface of revolution
-- in the v parametric direction. The bounds of the
-- surface are not changed but the given parametric
-- direction is reversed. Hence the orientation of the
-- surface is reversed.
-- As a consequence:
-- - VReverse reverses the meridian of this surface of revolution.
VReversedParameter (me; V : Real) returns Real;
---Purpose: Computes the v parameter on the modified
-- surface, when reversing its v parametric
-- direction, for any point of v parameter V on this surface of revolution.
-- In the case of a revolved surface:
-- - VReversedParameter returns the reversed
-- parameter given by the function
-- ReversedParameter called with V on the meridian.
TransformParameters(me; U,V : in out Real; T : Trsf from gp)
---Purpose: Computes the parameters on the transformed surface for
-- the transform of the point of parameters U,V on <me>.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are the new values of U,V after calling
--
-- me->TranformParameters(U,V,T)
--
-- This methods multiplies V by
-- BasisCurve()->ParametricTransformation(T)
is redefined;
ParametricTransformation(me; T : Trsf from gp) returns GTrsf2d from gp
---Purpose: Returns a 2d transformation used to find the new
-- parameters of a point on the transformed surface.
--
-- me->Transformed(T)->Value(U',V')
--
-- is the same point as
--
-- me->Value(U,V).Transformed(T)
--
-- Where U',V' are obtained by transforming U,V with
-- th 2d transformation returned by
--
-- me->ParametricTransformation(T)
--
-- This methods returns a scale centered on the
-- U axis with BasisCurve()->ParametricTransformation(T)
is redefined;
Bounds (me; U1, U2, V1, V2 : out Real);
---Purpose : Returns the parametric bounds U1, U2 , V1 and V2 of this surface.
-- A surface of revolution is always complete, so U1 = 0, U2 = 2*PI.
IsUClosed (me) returns Boolean;
---Purpose : IsUClosed always returns true.
IsVClosed (me) returns Boolean;
---Purpose : IsVClosed returns true if the meridian of this
-- surface of revolution is closed.
IsCNu (me; N : Integer) returns Boolean;
---Purpose : IsCNu always returns true.
IsCNv (me; N : Integer) returns Boolean
---Purpose : IsCNv returns true if the degree of continuity of the
-- meridian of this surface of revolution is at least N.
raises RangeError;
---Purpose : Raised if N < 0.
IsUPeriodic (me) returns Boolean;
---Purpose : Returns True.
IsVPeriodic (me) returns Boolean;
---Purpose : IsVPeriodic returns true if the meridian of this
-- surface of revolution is periodic.
UIso (me; U : Real) returns mutable Curve;
---Purpose : Computes the U isoparametric curve of this surface
-- of revolution. It is the curve obtained by rotating the
-- meridian through an angle U about the axis of revolution.
VIso (me; V : Real) returns mutable Curve;
---Purpose : Computes the U isoparametric curve of this surface
-- of revolution. It is the curve obtained by rotating the
-- meridian through an angle U about the axis of revolution.
D0 (me; U, V : Real; P : out Pnt);
---Purpose : Computes the point P (U, V) on the surface.
-- U is the angle of the rotation around the revolution axis.
-- The direction of this axis gives the sense of rotation.
-- V is the parameter of the revolved curve.
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec)
---Purpose :
-- Computes the current point and the first derivatives
-- in the directions U and V.
raises UndefinedDerivative;
---Purpose : Raised if the continuity of the surface is not C1.
D2 (me; U, V : Real; P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec)
---Purpose :
-- Computes the current point, the first and the second derivatives
-- in the directions U and V.
raises UndefinedDerivative;
---Purpose : Raised if the continuity of the surface is not C2.
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV : out Vec)
---Purpose :
-- Computes the current point, the first,the second and the third
-- derivatives in the directions U and V.
raises UndefinedDerivative;
---Purpose : Raised if the continuity of the surface is not C3.
DN (me; U, V : Real; Nu, Nv : Integer)
---Purpose :
-- Computes the derivative of order Nu in the direction u and
-- Nv in the direction v.
returns Vec
raises UndefinedDerivative,
---Purpose :
-- Raised if the continuity of the surface is not CNu in the u
-- direction and CNv in the v direction.
RangeError;
---Purpose : Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
---Purpose : The following functions evaluates the local
-- derivatives on surface. Useful to manage discontinuities
-- on the surface.
-- if Side = 1 -> P = S( U+,V )
-- if Side = -1 -> P = S( U-,V )
-- else P is betveen discontinuities
-- can be evaluated using methods of
-- global evaluations P = S( U ,V )
LocalD0 (me; U, V : Real; USide : Integer;
P : out Pnt);
LocalD1 (me; U, V : Real; USide : Integer;
P : out Pnt; D1U, D1V : out Vec);
LocalD2 (me; U, V : Real; USide : Integer;
P : out Pnt; D1U, D1V, D2U, D2V, D2UV : out Vec);
LocalD3 (me; U, V : Real; USide : Integer;
P : out Pnt; D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV :
out Vec);
LocalDN (me; U, V : Real; USide : Integer;
Nu, Nv : Integer)
returns Vec;
Transform (me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this surface of revolution.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this surface of revolution.
fields
loc : Pnt;
end;

File diff suppressed because it is too large Load Diff

59
src/Geom/Geom_SweptSurface.cdl Executable file
View File

@@ -0,0 +1,59 @@
-- File: Geom_SweptSurface.cdl
-- Created: Wed Mar 10 10:54:18 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class SweptSurface from Geom inherits Surface from Geom
---Purpose : Describes the common behavior for surfaces
-- constructed by sweeping a curve with another curve.
-- The Geom package provides two concrete derived
-- surfaces: surface of revolution (a revolved surface),
-- and surface of linear extrusion (an extruded surface).
uses Dir from gp,
Curve from Geom,
Shape from GeomAbs
is
Continuity (me) returns Shape from GeomAbs;
---Purpose :
-- returns the continuity of the surface :
-- C0 : only geometric continuity,
-- C1 : continuity of the first derivative all along the surface,
-- C2 : continuity of the second derivative all along the surface,
-- C3 : continuity of the third derivative all along the surface,
-- G1 : tangency continuity all along the surface,
-- G2 : curvature continuity all along the surface,
-- CN : the order of continuity is infinite.
Direction (me) returns Dir;
---Purpose :
-- Returns the reference direction of the swept surface.
-- For a surface of revolution it is the direction of the
-- revolution axis, for a surface of linear extrusion it is
-- the direction of extrusion.
---C++: return const&
BasisCurve (me) returns Curve from Geom;
---Purpose :
-- Returns the referenced curve of the surface.
-- For a surface of revolution it is the revolution curve,
-- for a surface of linear extrusion it is the extruded curve.
fields
basisCurve : Curve from Geom is protected;
direction : Dir from gp is protected;
smooth : Shape from GeomAbs is protected;
end;

33
src/Geom/Geom_SweptSurface.cxx Executable file
View File

@@ -0,0 +1,33 @@
// File: Geom_SweptSurface.cxx
// Created: Wed Mar 10 10:55:23 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_SweptSurface.cxx, JCV 17/02/91
#include <Geom_SweptSurface.ixx>
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom_SweptSurface::Continuity () const { return smooth; }
//=======================================================================
//function : Direction
//purpose :
//=======================================================================
const gp_Dir& Geom_SweptSurface::Direction () const { return direction; }
//=======================================================================
//function : BasisCurve
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_SweptSurface::BasisCurve () const
{
return basisCurve;
}

267
src/Geom/Geom_ToroidalSurface.cdl Executable file
View File

@@ -0,0 +1,267 @@
-- File: Geom_ToroidalSurface.cdl
-- Created: Wed Mar 10 10:56:00 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class ToroidalSurface from Geom inherits ElementarySurface from Geom
---Purpose : Describes a torus.
-- A torus is defined by its major and minor radii, and
-- positioned in space with a coordinate system (a
-- gp_Ax3 object) as follows:
-- - The origin is the center of the torus.
-- - The surface is obtained by rotating a circle around
-- the "main Direction". This circle has a radius equal
-- to the minor radius, and is located in the plane
-- defined by the origin, "X Direction" and "main
-- Direction". It is centered on the "X Axis", on its
-- positive side, and positioned at a distance from the
-- origin equal to the major radius. This circle is the
-- "reference circle" of the torus.
-- - The plane defined by the origin, the "X Direction"
-- and the "Y Direction" is called the "reference plane" of the torus.
-- This coordinate system is the "local coordinate
-- system" of the torus. The following apply:
-- - Rotation around its "main Axis", in the trigonometric
-- sense given by "X Direction" and "Y Direction",
-- defines the u parametric direction.
-- - The "X Axis" gives the origin for the u parameter.
-- - Rotation around an axis parallel to the "Y Axis" and
-- passing through the center of the "reference circle"
-- gives the v parameter on the "reference circle".
-- - The "X Axis" gives the origin of the v parameter on
-- the "reference circle".
-- - The v parametric direction is oriented by the
-- inverse of the "main Direction", i.e. near 0, as v
-- increases, the Z coordinate decreases. (This
-- implies that the "Y Direction" orients the reference
-- circle only when the local coordinate system is direct.)
-- - The u isoparametric curve is a circle obtained by
-- rotating the "reference circle" of the torus through
-- an angle u about the "main Axis".
-- The parametric equation of the torus is :
-- P(u, v) = O + (R + r*cos(v)) * (cos(u)*XDir +
-- sin(u)*YDir ) + r*sin(v)*ZDir, where:
-- - O, XDir, YDir and ZDir are respectively the
-- origin, the "X Direction", the "Y Direction" and the "Z
-- Direction" of the local coordinate system,
-- - r and R are, respectively, the minor and major radius.
-- The parametric range of the two parameters is:
-- - [ 0, 2.*Pi ] for u
-- - [ 0, 2.*Pi ] for v
uses Array1OfReal from TColStd,
Ax3 from gp,
Pnt from gp,
Torus from gp,
Trsf from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom
raises ConstructionError from Standard,
DimensionError from Standard,
RangeError from Standard
is
Create (A3 : Ax3; MajorRadius, MinorRadius : Real)
returns mutable ToroidalSurface
---Purpose :
-- A3 is the local coordinate system of the surface.
-- The orientation of increasing V parametric value is defined
-- by the rotation around the main axis (ZAxis) in the
-- trigonometric sense. The parametrization of the surface in the
-- U direction is defined such as the normal Vector (N = D1U ^ D1V)
-- is oriented towards the "outside region" of the surface.
-- Warnings :
-- It is not forbidden to create a toroidal surface with
-- MajorRadius = MinorRadius = 0.0
raises ConstructionError;
---Purpose :
-- Raised if MinorRadius < 0.0 or if MajorRadius < 0.0
Create (T : Torus) returns mutable ToroidalSurface;
---Purpose :
-- Creates a ToroidalSurface from a non transient Torus from
-- package gp.
SetMajorRadius (me : mutable; MajorRadius : Real)
raises ConstructionError;
---Purpose : Modifies this torus by changing its major radius.
-- Exceptions
-- Standard_ConstructionError if:
-- - MajorRadius is negative, or
-- - MajorRadius - r is less than or equal to
-- gp::Resolution(), where r is the minor radius of this torus.
SetMinorRadius (me : mutable; MinorRadius : Real)
raises ConstructionError;
---Purpose : Modifies this torus by changing its minor radius.
-- Exceptions
-- Standard_ConstructionError if:
-- - MinorRadius is negative, or
-- - R - MinorRadius is less than or equal to
-- gp::Resolution(), where R is the major radius of this torus.
SetTorus(me : mutable; T : Torus);
---Purpose : Converts the gp_Torus torus T into this torus.
Torus (me) returns Torus;
---Purpose :
-- Returns the non transient torus with the same geometric
-- properties as <me>.
UReversedParameter(me; U : Real) returns Real;
---Purpose: Return the parameter on the Ureversed surface for
-- the point of parameter U on <me>.
-- Return 2.PI - U.
VReversedParameter(me; U : Real) returns Real;
---Purpose: Return the parameter on the Ureversed surface for
-- the point of parameter U on <me>.
-- Return 2.PI - U.
Area (me) returns Real;
---Purpose : Computes the aera of the surface.
Bounds (me; U1, U2, V1, V2 : out Real);
---Purpose : Returns the parametric bounds U1, U2, V1 and V2 of this torus.
-- For a torus: U1 = V1 = 0 and V1 = V2 = 2*PI .
Coefficients (me; Coef : out Array1OfReal from TColStd)
---Purpose :
-- Returns the coefficients of the implicit equation of the surface
-- in the absolute cartesian coordinate system :
-- Coef(1) * X**4 + Coef(2) * Y**4 + Coef(3) * Z**4 +
-- Coef(4) * X**3 * Y + Coef(5) * X**3 * Z + Coef(6) * Y**3 * X +
-- Coef(7) * Y**3 * Z + Coef(8) * Z**3 * X + Coef(9) * Z**3 * Y +
-- Coef(10) * X**2 * Y**2 + Coef(11) * X**2 * Z**2 +
-- Coef(12) * Y**2 * Z**2 + Coef(13) * X**3 + Coef(14) * Y**3 +
-- Coef(15) * Z**3 + Coef(16) * X**2 * Y + Coef(17) * X**2 * Z +
-- Coef(18) * Y**2 * X + Coef(19) * Y**2 * Z + Coef(20) * Z**2 * X +
-- Coef(21) * Z**2 * Y + Coef(22) * X**2 + Coef(23) * Y**2 +
-- Coef(24) * Z**2 + Coef(25) * X * Y + Coef(26) * X * Z +
-- Coef(27) * Y * Z + Coef(28) * X + Coef(29) * Y + Coef(30) * Z +
-- Coef(31) = 0.0
raises DimensionError;
---Purpose : Raised if the length of Coef is lower than 31.
MajorRadius (me) returns Real;
--- Purpose: Returns the major radius, or the minor radius, of this torus.
MinorRadius (me) returns Real;
--- Purpose: Returns the major radius, or the minor radius, of this torus.
Volume (me) returns Real;
---Purpose : Computes the volume.
IsUClosed (me) returns Boolean;
---Purpose : Returns True.
IsVClosed (me) returns Boolean;
---Purpose : Returns True.
IsUPeriodic (me) returns Boolean;
---Purpose : Returns True.
IsVPeriodic (me) returns Boolean;
---Purpose : Returns True.
UIso (me; U : Real) returns mutable Curve;
---Purpose : Computes the U isoparametric curve.
--
-- For a toroidal surface the UIso curve is a circle.
-- The center of the Uiso circle is at the distance MajorRadius
-- from the location point of the toroidal surface.
-- Warnings :
-- The radius of the circle can be zero if for the surface
-- MinorRadius = 0.0
VIso (me; V : Real) returns mutable Curve;
---Purpose : Computes the V isoparametric curve.
--
-- For a ToroidalSurface the VIso curve is a circle.
-- The axis of the circle is the main axis (ZAxis) of the
-- toroidal surface.
-- Warnings :
-- The radius of the circle can be zero if for the surface
-- MajorRadius = MinorRadius
D0 (me; U, V : Real; P : out Pnt);
---Purpose :
-- Computes the point P (U, V) on the surface.
-- P (U, V) = Loc + MinorRadius * Sin (V) * Zdir +
-- (MajorRadius + MinorRadius * Cos(V)) *
-- (cos (U) * XDir + sin (U) * YDir)
-- where Loc is the origin of the placement plane (XAxis, YAxis)
-- XDir is the direction of the XAxis and YDir the direction of
-- the YAxis and ZDir the direction of the ZAxis.
D1 (me; U, V : Real; P : out Pnt; D1U, D1V : out Vec);
---Purpose :
-- Computes the current point and the first derivatives in
-- the directions U and V.
D2 (me; U, V : Real; P : out Pnt; D1U,D1V, D2U, D2V, D2UV : out Vec);
---Purpose :
-- Computes the current point, the first and the second derivatives
-- in the directions U and V.
D3 (me; U, V : Real; P : out Pnt;
D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV : out Vec);
---Purpose :
-- Computes the current point, the first,the second and the
-- third derivatives in the directions U and V.
DN (me; U, V : Real; Nu, Nv : Integer) returns Vec
---Purpose :
-- Computes the derivative of order Nu in the direction u and
-- Nv in the direction v.
raises RangeError;
---Purpose : Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
Transform (me : mutable; T : Trsf);
---Purpose: Applies the transformation T to this torus.
Copy (me) returns mutable like me;
---Purpose: Creates a new object which is a copy of this torus.
fields
majorRadius : Real;
minorRadius : Real;
end;

383
src/Geom/Geom_ToroidalSurface.cxx Executable file
View File

@@ -0,0 +1,383 @@
// File: Geom_ToroidalSurface.cxx
// Created: Wed Mar 10 10:57:46 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_ToroidalSurface.cxx, JCV 17/01/91
#include <Geom_ToroidalSurface.ixx>
#include <GeomAbs_UVSense.hxx>
#include <Geom_Circle.hxx>
#include <gp.hxx>
#include <gp_Circ.hxx>
#include <gp_Dir.hxx>
#include <gp_XYZ.hxx>
#include <ElSLib.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
typedef Geom_ToroidalSurface ToroidalSurface;
typedef Handle(Geom_ToroidalSurface) Handle(ToroidalSurface);
typedef TColStd_Array1OfReal Array1OfReal;
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Ax3 Ax3;
typedef gp_Circ Circ;
typedef gp_Dir Dir;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
typedef gp_XYZ XYZ;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_ToroidalSurface::Copy () const {
Handle(ToroidalSurface) Cs;
Cs = new ToroidalSurface (pos, majorRadius, minorRadius);
return Cs;
}
//=======================================================================
//function : Geom_ToroidalSurface
//purpose :
//=======================================================================
Geom_ToroidalSurface::Geom_ToroidalSurface
( const Ax3& A3,
const Standard_Real MajorRadius,
const Standard_Real MinorRadius )
: majorRadius (MajorRadius), minorRadius (MinorRadius) {
if (MinorRadius < 0.0 || MajorRadius < 0.0) {
Standard_ConstructionError::Raise();
}
else {
pos = A3;
}
}
//=======================================================================
//function : Geom_ToroidalSurface
//purpose :
//=======================================================================
Geom_ToroidalSurface::Geom_ToroidalSurface (const gp_Torus& T)
: majorRadius (T.MajorRadius()), minorRadius (T.MinorRadius()) {
pos = T.Position();
}
//=======================================================================
//function : MajorRadius
//purpose :
//=======================================================================
Standard_Real Geom_ToroidalSurface::MajorRadius () const {
return majorRadius;
}
//=======================================================================
//function : MinorRadius
//purpose :
//=======================================================================
Standard_Real Geom_ToroidalSurface::MinorRadius () const {
return minorRadius;
}
//=======================================================================
//function : UReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_ToroidalSurface::UReversedParameter( const Standard_Real U) const {
return (2.*PI - U);
}
//=======================================================================
//function : VReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_ToroidalSurface::VReversedParameter( const Standard_Real V) const {
return (2.*PI - V);
}
//=======================================================================
//function : IsUClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_ToroidalSurface::IsUClosed () const {
return Standard_True;
}
//=======================================================================
//function : IsVClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_ToroidalSurface::IsVClosed () const {
return Standard_True;
}
//=======================================================================
//function : IsUPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_ToroidalSurface::IsUPeriodic () const {
return Standard_True;
}
//=======================================================================
//function : IsVPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_ToroidalSurface::IsVPeriodic () const {
return Standard_True;
}
//=======================================================================
//function : SetMajorRadius
//purpose :
//=======================================================================
void Geom_ToroidalSurface::SetMajorRadius (const Standard_Real MajorRadius) {
if (MajorRadius - minorRadius <= gp::Resolution())
Standard_ConstructionError::Raise();
else
majorRadius = MajorRadius;
}
//=======================================================================
//function : SetMinorRadius
//purpose :
//=======================================================================
void Geom_ToroidalSurface::SetMinorRadius (const Standard_Real MinorRadius) {
if (MinorRadius < 0.0 || majorRadius - MinorRadius <= gp::Resolution())
Standard_ConstructionError::Raise();
else
minorRadius = MinorRadius;
}
//=======================================================================
//function : SetTorus
//purpose :
//=======================================================================
void Geom_ToroidalSurface::SetTorus (const gp_Torus& T) {
minorRadius = T.MinorRadius();
majorRadius = T.MajorRadius();
pos = T.Position();
}
//=======================================================================
//function : Area
//purpose :
//=======================================================================
Standard_Real Geom_ToroidalSurface::Area () const {
return 4.0 * PI * PI * minorRadius * majorRadius;
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void Geom_ToroidalSurface::Bounds (Standard_Real& U1,
Standard_Real& U2,
Standard_Real& V1,
Standard_Real& V2 ) const {
U1 = 0.0;
V1 = 0.0;
U2 = 2*PI;
V2 = 2*PI;
}
//=======================================================================
//function : Coefficients
//purpose :
//=======================================================================
void Geom_ToroidalSurface::Coefficients (Array1OfReal& Coef) const {
gp_Torus Tor (pos, majorRadius, minorRadius);
Tor.Coefficients (Coef);
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_ToroidalSurface::D0 (const Standard_Real U, const Standard_Real V, Pnt& P) const
{
ElSLib::TorusD0 (U, V, pos, majorRadius, minorRadius,P);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_ToroidalSurface::D1
(const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V) const
{
ElSLib::TorusD1 (U, V, pos, majorRadius, minorRadius, P, D1U, D1V);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_ToroidalSurface::D2
(const Standard_Real U , const Standard_Real V,
Pnt& P ,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV ) const
{
ElSLib::TorusD2 (U, V, pos, majorRadius, minorRadius, P, D1U, D1V,
D2U, D2V, D2UV);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_ToroidalSurface::D3
(const Standard_Real U, const Standard_Real V,
Pnt& P,
Vec& D1U, Vec& D1V,
Vec& D2U, Vec& D2V, Vec& D2UV,
Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV ) const
{
ElSLib::TorusD3 (U, V, pos, majorRadius, minorRadius, P, D1U, D1V,
D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_ToroidalSurface::DN
(const Standard_Real U , const Standard_Real V,
const Standard_Integer Nu, const Standard_Integer Nv ) const {
Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
return ElSLib::TorusDN (U, V, pos, majorRadius, minorRadius, Nu, Nv);
}
//=======================================================================
//function : Torus
//purpose :
//=======================================================================
gp_Torus Geom_ToroidalSurface::Torus () const {
return gp_Torus (pos, majorRadius, minorRadius);
}
//=======================================================================
//function : UIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_ToroidalSurface::UIso (const Standard_Real U) const
{
Handle(Geom_Circle)
GC = new Geom_Circle(ElSLib::TorusUIso(pos,majorRadius,minorRadius,U));
return GC;
}
//=======================================================================
//function : VIso
//purpose :
//=======================================================================
Handle(Geom_Curve) Geom_ToroidalSurface::VIso (const Standard_Real V) const
{
Handle(Geom_Circle) GC =
new Geom_Circle(ElSLib::TorusVIso(pos,majorRadius,minorRadius,V));
return GC;
}
//=======================================================================
//function : Volume
//purpose :
//=======================================================================
Standard_Real Geom_ToroidalSurface::Volume () const {
return (PI * minorRadius * minorRadius) * (2.0 * PI * majorRadius);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_ToroidalSurface::Transform (const Trsf& T) {
majorRadius = majorRadius * Abs(T.ScaleFactor());
minorRadius = minorRadius * Abs(T.ScaleFactor());
pos.Transform (T);
}

251
src/Geom/Geom_Transformation.cdl Executable file
View File

@@ -0,0 +1,251 @@
-- File: Geom_Transformation.cdl
-- Created: Wed Mar 10 10:59:19 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class Transformation from Geom inherits TShared from MMgt
---Purpose : Describes how to construct the following elementary transformations
-- - translations,
-- - rotations,
-- - symmetries,
-- - scales.
-- 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 Geom_Transformation.
-- The transformation can be represented as follow :
--
-- V1 V2 V3 T
-- | a11 a12 a13 a14 | | x | | x'|
-- | a21 a22 a23 a24 | | y | | y'|
-- | a31 a32 a33 a34 | | z | = | z'|
-- | 0 0 0 1 | | 1 | | 1 |
--
-- where {V1, V2, V3} defines the vectorial part of the
-- transformation and T defines the translation part of
-- the transformation.
-- Note: Geom_Transformation transformations
-- provide the same kind of "geometric" services as
-- gp_Trsf ones but have more complex data structures.
-- The geometric objects provided by the Geom
-- package use gp_Trsf transformations in the syntaxes
-- Transform and Transformed.
-- Geom_Transformation transformations are used in
-- a context where they can be shared by several
-- objects contained inside a common data structure.
uses Ax1 from gp,
Ax2 from gp,
Ax3 from gp,
Pnt from gp,
Trsf from gp,
TrsfForm from gp,
Vec from gp
raises ConstructionError from Standard,
OutOfRange from Standard
is
Create returns mutable Transformation;
---Purpose : Creates an identity transformation.
Create (T : Trsf) returns mutable Transformation;
---Purpose : Creates a transient copy of T.
SetMirror (me : mutable; P : Pnt);
---Purpose :
-- Makes the transformation into a symmetrical transformation
-- with respect to a point P.
-- P is the center of the symmetry.
SetMirror (me : mutable; A1 : Ax1);
---Purpose :
-- Makes the transformation into a symmetrical transformation
-- with respect to an axis A1.
-- A1 is the center of the axial symmetry.
SetMirror (me : mutable; A2 : Ax2);
---Purpose :
-- Makes the transformation into a symmetrical transformation
-- with respect to a plane. The plane of the symmetry is
-- defined with the axis placement A2. It is the plane
-- (Location, XDirection, YDirection).
SetRotation (me : mutable; A1 : Ax1; Ang : Real);
---Purpose :
-- Makes the transformation into a rotation.
-- A1 is the axis rotation and Ang is the angular value
-- of the rotation in radians.
SetScale (me : mutable; P : Pnt; 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 : Ax3);
---Purpose :
-- Makes a transformation allowing passage from the coordinate
-- system "FromSystem1" to the coordinate system "ToSystem2".
--- Example :
-- In a C++ implementation :
-- Real x1, y1, z1; // are the coordinates of a point in the
-- // local system FromSystem1
-- Real x2, y2, z2; // are the coordinates of a point in the
-- // local system ToSystem2
-- gp_Pnt P1 (x1, y1, z1)
-- Geom_Transformation T;
-- T.SetTransformation (FromSystem1, ToSystem2);
-- gp_Pnt P2 = P1.Transformed (T);
-- P2.Coord (x2, y2, z2);
SetTransformation (me : mutable; ToSystem : Ax3);
---Purpose :
-- Makes the transformation allowing passage from the basic
-- coordinate system
-- {P(0.,0.,0.), VX (1.,0.,0.), VY (0.,1.,0.), VZ (0., 0. ,1.) }
-- to the local coordinate system defined with the Ax2 ToSystem.
-- Same utilisation as the previous method. FromSystem1 is
-- defaulted to the absolute coordinate system.
SetTranslation (me : mutable; V : Vec);
---Purpose :
-- Makes the transformation into a translation.
-- V is the vector of the translation.
SetTranslation(me : mutable; P1, P2 : Pnt);
---Purpose :
-- Makes the transformation into a translation from the point
-- P1 to the point P2.
SetTrsf (me : mutable; T : Trsf);
---Purpose : Converts the gp_Trsf transformation T into this transformation.
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.
ScaleFactor (me) returns Real;
---Purpose : Returns the scale value of the transformation.
Trsf (me) returns Trsf;
---Purpose :
-- Returns a non transient 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 3 rows X 4 columns matrix.
raises OutOfRange;
---Purpose :
-- Raised if Row < 1 or Row > 3 or Col < 1 or Col > 4
---Purpose :
-- Computes the reverse transformation.
Invert (me : mutable)
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 :
-- Raised 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
Multiply (me : mutable; Other : Transformation);
---Purpose :
-- Computes the transformation composed with Other and <me> .
-- <me> = <me> * Other.
Power (me : mutable; N : Integer)
---Purpose :
-- Computes the following composition of transformations
-- if N > 0 <me> * <me> * .......* <me>.
-- if N = 0 Identity
-- if N < 0 <me>.Invert() * .........* <me>.Invert()
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, Z : in out Real);
---Purpose :
-- Applies the transformation <me> to the triplet {X, Y, Z}.
Copy (me) returns mutable Transformation;
---Purpose: Creates a new object which is a copy of this transformation.
fields
gpTrsf : Trsf;
end;

138
src/Geom/Geom_Transformation.cxx Executable file
View File

@@ -0,0 +1,138 @@
// File: Geom_Transformation.cxx
// Created: Wed Mar 10 10:59:58 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Transformation.cxx, JCV 14/01/91
#include <Geom_Transformation.ixx>
typedef Handle(Geom_Transformation) Handle(Transformation);
typedef Geom_Transformation Transformation;
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Ax3 Ax3;
typedef gp_Pnt Pnt;
typedef gp_TrsfForm TrsfForm;
typedef gp_Vec Vec;
Geom_Transformation::Geom_Transformation () { }
Geom_Transformation::Geom_Transformation (const gp_Trsf& T)
: gpTrsf (T) { }
Handle(Geom_Transformation) Geom_Transformation::Copy() const {
Handle(Transformation) T;
T = new Transformation (gpTrsf);
return T;
}
void Geom_Transformation::SetMirror (const gp_Pnt& P) { gpTrsf.SetMirror (P); }
void Geom_Transformation::SetMirror (const gp_Ax1& A1) { gpTrsf.SetMirror (A1); }
void Geom_Transformation::SetMirror (const gp_Ax2& A2) { gpTrsf.SetMirror (A2);}
void Geom_Transformation::SetRotation (const gp_Ax1& A1, const Standard_Real Ang) {
gpTrsf.SetRotation (A1, Ang);
}
void Geom_Transformation::SetScale (const gp_Pnt& P, const Standard_Real S) {
gpTrsf.SetScale (P, S);
}
void Geom_Transformation::SetTransformation (const gp_Ax3& ToAxis) {
gpTrsf.SetTransformation (ToAxis);
}
void Geom_Transformation::SetTransformation (
const gp_Ax3& FromAxis1, const gp_Ax3& ToAxis2) {
gpTrsf.SetTransformation (FromAxis1, ToAxis2);
}
void Geom_Transformation::SetTranslation (const gp_Vec& V) {
gpTrsf.SetTranslation (V);
}
void Geom_Transformation::SetTranslation (const gp_Pnt& P1, const gp_Pnt& P2) {
gpTrsf.SetTranslation (P1, P2);
}
void Geom_Transformation::SetTrsf (const gp_Trsf& T) { gpTrsf = T; }
Standard_Boolean Geom_Transformation::IsNegative () const {return gpTrsf.IsNegative();}
TrsfForm Geom_Transformation::Form () const { return gpTrsf.Form(); }
Standard_Real Geom_Transformation::ScaleFactor () const { return gpTrsf.ScaleFactor(); }
const gp_Trsf& Geom_Transformation::Trsf () const { return gpTrsf; }
Standard_Real Geom_Transformation::Value (const Standard_Integer Row, const Standard_Integer Col) const {
return gpTrsf.Value (Row, Col);
}
void Geom_Transformation::Invert () { gpTrsf.Invert(); }
Handle(Transformation) Geom_Transformation::Inverted () const {
return new Transformation (gpTrsf.Inverted());
}
Handle(Transformation) Geom_Transformation::Multiplied (
const Handle(Geom_Transformation)& Other) const {
return new Transformation (gpTrsf.Multiplied (Other->Trsf()));
}
void Geom_Transformation::Multiply (const Handle(Geom_Transformation)& Other) {
gpTrsf.Multiply (Other->Trsf());
}
void Geom_Transformation::Power (const Standard_Integer N) { gpTrsf.Power (N); }
Handle(Transformation) Geom_Transformation::Powered (const Standard_Integer N) const {
gp_Trsf T = gpTrsf;
T.Power (N);
return new Transformation (T);
}
void Geom_Transformation::PreMultiply (const Handle(Geom_Transformation)& Other){
gpTrsf.PreMultiply (Other->Trsf());
}
void Geom_Transformation::Transforms (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const {
gpTrsf.Transforms (X, Y, Z);
}

292
src/Geom/Geom_TrimmedCurve.cdl Executable file
View File

@@ -0,0 +1,292 @@
-- File: Geom_TrimmedCurve.cdl
-- Created: Wed Mar 10 11:00:17 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class TrimmedCurve from Geom inherits BoundedCurve from Geom
---Purpose : Describes a portion of a curve (termed the "basis
-- curve") limited by two parameter values inside the
-- parametric domain of the basis 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 Ax1 from gp,
Ax2 from gp,
Pnt from gp,
Trsf from gp,
Vec from gp,
Curve from Geom,
Geometry from Geom,
Shape from GeomAbs
raises ConstructionError from Standard,
RangeError from Standard,
NoSuchObject from Standard,
UndefinedDerivative from Geom,
UndefinedValue from Geom
is
Create (C : Curve; U1, U2 : Real; Sense : Boolean = Standard_True)
returns mutable TrimmedCurve
---Purpose : Constructs a trimmed curve from the basis curve C
-- which is limited between parameter values U1 and U2.
-- Note: - U1 can be greater or less than U2; in both cases,
-- 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, 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.
-- - If the curve is closed but not periodic, it is not
-- possible to keep the part of the curve which
-- includes the junction point (except if the junction
-- point is at the beginning or at the end of the
-- trimmed curve). If you tried to do this, you could
-- alter the fundamental characteristics of the basis
-- curve, which are used, for example, to compute
-- the derivatives of the trimmed curve. The rules
-- for a closed curve are therefore the same as
-- those for an open curve.
-- Warning: The trimmed curve is built from a copy of curve C.
-- Therefore, when C is modified, the trimmed curve
-- is not modified.
-- - 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:
-- - C is not periodic and U1 or U2 is outside the
-- bounds of C, or
-- - U1 is equal to U2.
raises ConstructionError;
Reverse (me : mutable);
---Purpose : Changes the orientation of this trimmed curve.
-- 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,
-- - the first and last parameters are recomputed.
-- If the trimmed curve was defined by:
-- - a basis curve whose parameter range is [ 0., 1. ],
-- - 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. ],
-- - the two trim values 1. - U2 (first parameter) and 1. - U1 (last parameter).
ReversedParameter(me; U : Real) returns Real;
---Purpose: Computes the parameter on the reversed curve for
-- the point of parameter U on this trimmed curve.
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 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,
-- CN : the order of continuity is infinite.
IsCN (me; N : Integer) returns Boolean
---Purpose : Returns true if the degree of continuity of the basis
-- curve of this trimmed curve is at least 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 Pnt;
---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 Pnt;
---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 even if the trimmed curve
-- has not the same orientation as the basis curve.
D0(me; U : Real; P : out Pnt);
---Purpose: Returns in P the point of parameter U.
--
-- 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 Pnt; V1 : out Vec)
raises UndefinedDerivative;
---Purpose : Raised if the continuity of the curve is not C1.
D2 (me; U : Real; P : out Pnt; V1, V2 : out Vec)
raises UndefinedDerivative;
---Purpose : Raised if the continuity of the curve is not C2.
D3 (me; U : Real; P : out Pnt; V1, V2, V3 : out Vec)
raises UndefinedDerivative;
---Purpose : Raised if the continuity of the curve is not C3.
DN (me; U : Real; N : Integer) returns Vec
---Purpose : N is the order of derivation.
raises UndefinedDerivative,
---Purpose : Raised if the continuity of the curve is not CN.
RangeError;
---Purpose : Raised if N < 1.
---Purpose : geometric transformations
Transform (me : mutable; T : Trsf);
--- Purpose: Applies the transformation T to this trimmed curve.
-- Warning The basis curve is also modified.
TransformedParameter(me; U : Real; T : Trsf 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 : Trsf 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;
uTrim1 : Real;
uTrim2 : Real;
end;

354
src/Geom/Geom_TrimmedCurve.cxx Executable file
View File

@@ -0,0 +1,354 @@
// File: Geom_TrimmedCurve.cxx
// Created: Wed Mar 10 11:01:02 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_TrimmedCurve.cxx, JCV 17/01/91
#include <Geom_TrimmedCurve.ixx>
#include <gp.hxx>
#include <Geom_Geometry.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_OffsetCurve.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_Parabola.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>
#include <Precision.hxx>
#include <ElCLib.hxx>
typedef Handle(Geom_TrimmedCurve) Handle(TrimmedCurve);
typedef Geom_TrimmedCurve TrimmedCurve;
typedef Handle(Geom_Curve) Handle(Curve);
typedef Handle(Geom_Geometry) Handle(Geometry);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
typedef gp_Vec Vec;
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_TrimmedCurve::Copy () const {
Handle(TrimmedCurve) Tc = new TrimmedCurve (basisCurve, uTrim1, uTrim2);
return Tc;
}
//=======================================================================
//function : Geom_TrimmedCurve
//purpose :
//=======================================================================
Geom_TrimmedCurve::Geom_TrimmedCurve (const Handle(Geom_Curve)& C,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Boolean Sense) :
uTrim1 (U1),
uTrim2 (U2)
{
// kill trimmed basis curves
Handle(Geom_TrimmedCurve) T = Handle(Geom_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 Geom_TrimmedCurve::Reverse ()
{
Standard_Real U1 = basisCurve->ReversedParameter(uTrim2);
Standard_Real U2 = basisCurve->ReversedParameter(uTrim1);
basisCurve->Reverse();
SetTrim(U1,U2);
}
//=======================================================================
//function : ReversedParameter
//purpose :
//=======================================================================
Standard_Real Geom_TrimmedCurve::ReversedParameter
(const Standard_Real U) const
{
return basisCurve->ReversedParameter(U);
}
//=======================================================================
//function : SetTrim
//purpose :
//=======================================================================
void Geom_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("Geom_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 : IsClosed
//purpose :
//=======================================================================
Standard_Boolean Geom_TrimmedCurve::IsClosed () const
{
return ( StartPoint().Distance(EndPoint()) <= gp::Resolution());
}
//=======================================================================
//function : IsPeriodic
//purpose :
//=======================================================================
Standard_Boolean Geom_TrimmedCurve::IsPeriodic () const
{
//return basisCurve->IsPeriodic();
return Standard_False;
}
//=======================================================================
//function : Period
//purpose :
//=======================================================================
Standard_Real Geom_TrimmedCurve::Period() const
{
return basisCurve->Period();
}
//=======================================================================
//function : Continuity
//purpose :
//=======================================================================
GeomAbs_Shape Geom_TrimmedCurve::Continuity () const {
return basisCurve->Continuity ();
}
//=======================================================================
//function : BasisCurve
//purpose :
//=======================================================================
Handle(Curve) Geom_TrimmedCurve::BasisCurve () const {
return basisCurve;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
void Geom_TrimmedCurve::D0 (const Standard_Real U, Pnt& P) const {
basisCurve->D0( U, P);
}
//=======================================================================
//function : D1
//purpose :
//=======================================================================
void Geom_TrimmedCurve::D1 (const Standard_Real U, Pnt& P, Vec& V1) const {
basisCurve->D1 (U, P, V1);
}
//=======================================================================
//function : D2
//purpose :
//=======================================================================
void Geom_TrimmedCurve::D2 ( const Standard_Real U,
Pnt& P,
Vec& V1, Vec& V2) const {
basisCurve->D2 (U, P, V1, V2);
}
//=======================================================================
//function : D3
//purpose :
//=======================================================================
void Geom_TrimmedCurve::D3 (const Standard_Real U,
Pnt& P,
Vec& V1, Vec& V2, Vec& V3) const {
basisCurve->D3 (U, P, V1, V2, V3);
}
//=======================================================================
//function : DN
//purpose :
//=======================================================================
Vec Geom_TrimmedCurve::DN (const Standard_Real U,
const Standard_Integer N) const
{
return basisCurve->DN (U, N);
}
//=======================================================================
//function : EndPoint
//purpose :
//=======================================================================
Pnt Geom_TrimmedCurve::EndPoint () const {
return basisCurve->Value (uTrim2);
}
//=======================================================================
//function : FirstParameter
//purpose :
//=======================================================================
Standard_Real Geom_TrimmedCurve::FirstParameter () const {
return uTrim1;
}
//=======================================================================
//function : LastParameter
//purpose :
//=======================================================================
Standard_Real Geom_TrimmedCurve::LastParameter () const {
return uTrim2;
}
//=======================================================================
//function : StartPoint
//purpose :
//=======================================================================
Pnt Geom_TrimmedCurve::StartPoint () const {
return basisCurve->Value (uTrim1);
}
//=======================================================================
//function : IsCN
//purpose :
//=======================================================================
Standard_Boolean Geom_TrimmedCurve::IsCN (const Standard_Integer N) const {
Standard_RangeError_Raise_if (N < 0, " ");
return basisCurve->IsCN (N);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_TrimmedCurve::Transform (const Trsf& 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 Geom_TrimmedCurve::TransformedParameter(const Standard_Real U,
const gp_Trsf& T) const
{
return basisCurve->TransformedParameter(U,T);
}
//=======================================================================
//function : ParametricTransformation
//purpose :
//=======================================================================
Standard_Real Geom_TrimmedCurve::ParametricTransformation(const gp_Trsf& T)
const
{
return basisCurve->ParametricTransformation(T);
}

156
src/Geom/Geom_Vector.cdl Executable file
View File

@@ -0,0 +1,156 @@
-- File: Geom_Vector.cdl
-- Created: Wed Mar 10 11:02:36 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
deferred class Vector from Geom inherits Geometry from Geom
---Purpose : The abstract class Vector describes the common
-- behavior of vectors in 3D space.
-- The Geom package provides two concrete classes of
-- vectors: Geom_Direction (unit vector) and Geom_VectorWithMagnitude.
uses Ax1 from gp,
Ax2 from gp,
Pnt from gp,
Vec from gp
raises ConstructionError from Standard,
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 0 and Pi.
-- Exceptions
-- gp_VectorWithNullMagnitude if:
-- - the magnitude of this vector is less than or equal to
-- gp::Resolution(), or
-- - the magnitude of vector Other is less than or equal
-- to gp::Resolution().
raises VectorWithNullMagnitude;
AngleWithRef (me; Other , VRef : 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 vector VRef defines the
-- positive sense of rotation: the angular value is positive
-- if the cross product this ^ Other has the same
-- orientation as VRef (in relation to the plane defined
-- by this vector and vector Other). Otherwise, it is negative.
-- Exceptions
-- Standard_DomainError if this vector, vector Other
-- and vector VRef are coplanar, except if this vector
-- and vector Other are parallel.
-- gp_VectorWithNullMagnitude if the magnitude of
-- this vector, vector Other or vector VRef is less than
-- or equal to gp::Resolution().
raises DomainError,
VectorWithNullMagnitude;
Coord (me; X, Y, Z : out Real);
---Purpose : Returns the coordinates X, Y and Z of this vector.
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>.
Z (me) returns Real;
---Purpose : Returns the Z coordinate of <me>.
Cross (me : mutable; Other : Vector)
---Purpose :
-- Computes the cross product between <me> and <Other>.
raises ConstructionError
---Purpose :
-- Raised if <me> is a "Direction" and if <me> and <Other>
-- are parallel because it is not possible to build a
-- "Direction" with null length.
is deferred;
Crossed (me; Other : Vector) returns mutable like me
---Purpose :
-- Computes the cross product between <me> and <Other>.
-- A new direction is returned.
raises ConstructionError
---Purpose :
-- Raised if <me> is a "Direction" and if the two vectors
-- are parallel because it is not possible to create a
-- "Direction" with null length.
is deferred;
CrossCross (me : mutable; V1, V2 : Vector)
---Purpose :
-- Computes the triple vector product <me> ^(V1 ^ V2).
raises ConstructionError
---Purpose :
-- Raised if <me> is a "Direction" and if V1 and V2 are parallel
-- or <me> and (V1 ^ V2) are parallel
is deferred;
CrossCrossed (me; V1, V2 : Vector) returns mutable like me
---Purpose :
-- Computes the triple vector product <me> ^(V1 ^ V2).
raises ConstructionError
---Purpose :
-- Raised if <me> is a direction and if V1 and V2 are
-- parallel or <me> and (V1 ^ V2) are parallel
is deferred;
Dot (me; Other : Vector) returns Real;
---Purpose : Computes the scalar product of this vector and vector Other.
DotCross (me; V1, V2 : Vector) returns Real;
---Purpose :
-- Computes the triple scalar product. Returns me . (V1 ^ V2)
Vec (me) returns Vec;
---Purpose : Converts this vector into a gp_Vec vector.
---C++: return const&
fields
gpVec : Vec is protected;
end;

70
src/Geom/Geom_Vector.cxx Executable file
View File

@@ -0,0 +1,70 @@
// File: Geom_Vector.cxx
// Created: Wed Mar 10 11:03:05 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_Vector.cxx, JCV 16/01/91
#include <Geom_Vector.ixx>
typedef Geom_Vector Vector;
typedef Handle(Geom_Vector) Handle(Vector);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
void Geom_Vector::Reverse () { gpVec.Reverse(); }
Standard_Real Geom_Vector::X () const { return gpVec.X(); }
Standard_Real Geom_Vector::Y () const { return gpVec.Y(); }
Standard_Real Geom_Vector::Z () const { return gpVec.Z(); }
const gp_Vec& Geom_Vector::Vec () const { return gpVec; }
Handle(Vector) Geom_Vector::Reversed () const
{
Handle(Vector) V = Handle(Vector)::DownCast(Copy());
V->Reverse();
return V;
}
Standard_Real Geom_Vector::Angle (const Handle(Vector)& Other) const {
return gpVec.Angle (Other->Vec());
}
Standard_Real Geom_Vector::AngleWithRef (
const Handle(Vector)& Other, const Handle(Vector)& VRef) const {
return gpVec.AngleWithRef (Other->Vec(), VRef->Vec());
}
void Geom_Vector::Coord (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const {
gpVec.Coord (X, Y, Z);
}
Standard_Real Geom_Vector::Dot (const Handle(Vector)& Other) const {
return gpVec.Dot (Other->Vec());
}
Standard_Real Geom_Vector::DotCross (
const Handle(Vector)& V1, const Handle(Vector)& V2) const {
return gpVec.DotCross (V1->Vec(), V2->Vec());
}

View File

@@ -0,0 +1,162 @@
-- File: Geom_VectorWithMagnitude.cdl
-- Created: Wed Mar 10 11:03:19 1993
-- Author: JCV
-- <fid@phylox>
-- Copyright: Matra Datavision 1993
class VectorWithMagnitude from Geom inherits Vector from Geom
---Purpose :
-- Defines a vector with magnitude.
-- A vector with magnitude can have a zero length.
uses Pnt from gp,
Trsf from gp,
Vec from gp,
Geometry from Geom
raises ConstructionError from Standard
is
Create (V : Vec) returns mutable VectorWithMagnitude;
---Purpose : Creates a transient copy of V.
Create (X, Y, Z : Real) returns mutable VectorWithMagnitude;
---Purpose : Creates a vector with three cartesian coordinates.
Create (P1, P2 : Pnt) 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, Z : Real);
---Purpose : Assigns the values X, Y and Z to the coordinates of this vector.
SetVec (me : mutable; V : Vec);
--- Purpose : Converts the gp_Vec vector V into this vector.
SetX (me : mutable; X : Real);
---Purpose : Changes the X coordinate of <me>.
SetY (me : mutable; Y : Real);
---Purpose : Changes the Y coordinate of <me>
SetZ (me : mutable; Z : Real);
---Purpose : Changes the Z 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>.
Added (me; Other : Vector) returns mutable VectorWithMagnitude
---Purpose :
-- Adds the vector Other to <me>.
is static;
Cross (me : mutable; Other : Vector);
---Purpose :
-- Computes the cross product between <me> and Other
-- <me> ^ Other.
Crossed (me; Other : Vector) returns mutable like me
---Purpose :
-- Computes the cross product between <me> and Other
-- <me> ^ Other. A new vector is returned.
is static;
CrossCross (me : mutable; V1, V2 : Vector);
---Purpose :
-- Computes the triple vector product <me> ^ (V1 ^ V2).
CrossCrossed (me; V1, V2 : Vector) returns mutable like me
---Purpose :
-- Computes the triple vector product <me> ^ (V1 ^ V2).
-- A new vector is returned.
is static;
Divide (me : mutable; Scalar : Real);
---Purpose : Divides <me> by a scalar.
Divided (me; Scalar : Real) returns mutable VectorWithMagnitude
---Purpose :
-- Divides <me> by a scalar. A new vector is returned.
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.
is static;
Multiply (me : mutable; Scalar : Real);
---Purpose :
-- Computes the product of the vector <me> by a scalar.
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>.
Subtracted (me; Other : Vector) returns mutable VectorWithMagnitude
---Purpose :
-- Subtracts the vector Other to <me>. A new vector is returned.
is static;
Transform (me: mutable; T : Trsf);
---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,300 @@
// File: Geom_VectorWithMagnitude.cxx
// Created: Wed Mar 10 11:03:38 1993
// Author: JCV
// <fid@phylox>
// Copyright: Matra Datavision 1993
//File Geom_VectorWithMagnitude.cxx, JCV 16/01/91
#include <Geom_VectorWithMagnitude.ixx>
typedef Geom_VectorWithMagnitude VectorWithMagnitude;
typedef Handle(Geom_VectorWithMagnitude) Handle(VectorWithMagnitude);
typedef Geom_Vector Vector;
typedef Handle(Geom_Vector) Handle(Vector);
typedef Handle(Geom_Geometry) Handle(Geometry);
typedef gp_Ax1 Ax1;
typedef gp_Ax2 Ax2;
typedef gp_Pnt Pnt;
typedef gp_Trsf Trsf;
//=======================================================================
//function : Geom_VectorWithMagnitude
//purpose :
//=======================================================================
Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (const gp_Vec& V)
{ gpVec = V; }
//=======================================================================
//function : Geom_VectorWithMagnitude
//purpose :
//=======================================================================
Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (
const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { gpVec = gp_Vec (X, Y, Z); }
//=======================================================================
//function : Geom_VectorWithMagnitude
//purpose :
//=======================================================================
Geom_VectorWithMagnitude::Geom_VectorWithMagnitude (
const Pnt& P1, const Pnt& P2) { gpVec = gp_Vec (P1, P2); }
//=======================================================================
//function : Copy
//purpose :
//=======================================================================
Handle(Geom_Geometry) Geom_VectorWithMagnitude::Copy() const {
Handle(VectorWithMagnitude) V;
V = new VectorWithMagnitude (gpVec);
return V;
}
//=======================================================================
//function : SetCoord
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::SetCoord (
const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { gpVec = gp_Vec (X, Y ,Z); }
//=======================================================================
//function : SetVec
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::SetVec (const gp_Vec& V) { gpVec = V; }
//=======================================================================
//function : SetX
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec.SetX (X); }
//=======================================================================
//function : SetY
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec.SetY (Y); }
//=======================================================================
//function : SetZ
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::SetZ (const Standard_Real Z) { gpVec.SetZ (Z); }
//=======================================================================
//function : Magnitude
//purpose :
//=======================================================================
Standard_Real Geom_VectorWithMagnitude::Magnitude () const {return gpVec.Magnitude ();}
//=======================================================================
//function : SquareMagnitude
//purpose :
//=======================================================================
Standard_Real Geom_VectorWithMagnitude::SquareMagnitude () const {
return gpVec.SquareMagnitude ();
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::Add (const Handle(Vector)& Other) {
gpVec.Add (Other->Vec());
}
//=======================================================================
//function : Added
//purpose :
//=======================================================================
Handle(VectorWithMagnitude) Geom_VectorWithMagnitude::Added (
const Handle(Vector)& Other) const {
gp_Vec V1 = gpVec;
V1.Add (Other->Vec());
return new VectorWithMagnitude (V1);
}
//=======================================================================
//function : Cross
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::Cross (const Handle(Vector)& Other) {
gpVec.Cross (Other->Vec());
}
//=======================================================================
//function : Crossed
//purpose :
//=======================================================================
Handle(Vector) Geom_VectorWithMagnitude::Crossed (
const Handle(Vector)& Other) const {
gp_Vec V (gpVec);
V.Cross (Other->Vec());
return new VectorWithMagnitude (V);
}
//=======================================================================
//function : CrossCross
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::CrossCross (
const Handle(Vector)& V1, const Handle(Vector)& V2) {
gpVec.CrossCross (V1->Vec(), V2->Vec());
}
//=======================================================================
//function : CrossCrossed
//purpose :
//=======================================================================
Handle(Vector) Geom_VectorWithMagnitude::CrossCrossed (
const Handle(Vector)& V1, const Handle(Vector)& V2) const {
gp_Vec V (gpVec);
V.CrossCross (V1->Vec(), V2->Vec());
return new VectorWithMagnitude (V);
}
//=======================================================================
//function : Divide
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::Divide (const Standard_Real Scalar) {
gpVec.Divide (Scalar);
}
//=======================================================================
//function : Divided
//purpose :
//=======================================================================
Handle(VectorWithMagnitude) Geom_VectorWithMagnitude::Divided (
const Standard_Real Scalar) const {
gp_Vec V (gpVec);
V.Divide (Scalar);
return new VectorWithMagnitude (V);
}
//=======================================================================
//function : Multiplied
//purpose :
//=======================================================================
Handle(VectorWithMagnitude) Geom_VectorWithMagnitude::Multiplied (
const Standard_Real Scalar) const {
gp_Vec V (gpVec);
V.Multiply (Scalar);
return new VectorWithMagnitude (V);
}
//=======================================================================
//function : Multiply
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::Multiply (const Standard_Real Scalar) {
gpVec.Multiply (Scalar);
}
//=======================================================================
//function : Normalize
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::Normalize () { gpVec.Normalize (); }
//=======================================================================
//function : Normalized
//purpose :
//=======================================================================
Handle(VectorWithMagnitude) Geom_VectorWithMagnitude::Normalized () const {
gp_Vec V (gpVec);
V.Normalize ();
return new VectorWithMagnitude (V);
}
//=======================================================================
//function : Subtract
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::Subtract (const Handle(Vector)& Other) {
gpVec.Subtract (Other->Vec());
}
//=======================================================================
//function : Subtracted
//purpose :
//=======================================================================
Handle(VectorWithMagnitude) Geom_VectorWithMagnitude::Subtracted (
const Handle(Vector)& Other) const {
gp_Vec V (gpVec);
V.Subtract (Other->Vec());
return new VectorWithMagnitude (V);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
void Geom_VectorWithMagnitude::Transform (const Trsf& T) {
gpVec.Transform (T);
}