OCC Main Page | ModelingData | Toolkits | Packages | Class Hierarchy | Data Structures | File List | Data Fields | Globals

ModelingData
TKG3d
Geom


Geom_BezierCurve Class Reference

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.
.

#include <Geom_BezierCurve.hxx>

Inheritance diagram for Geom_BezierCurve:

Inheritance graph
[legend]

Public Member Functions

Standard_EXPORT Geom_BezierCurve (const TColgp_Array1OfPnt &CurvePoles)
 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.
.
Standard_EXPORT Geom_BezierCurve (const TColgp_Array1OfPnt &CurvePoles, const TColStd_Array1OfReal &PoleWeights)
 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.
.
Standard_EXPORT void Increase (const Standard_Integer Degree)
 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>.
.
Standard_EXPORT void InsertPoleAfter (const Standard_Integer Index, const gp_Pnt &P)
 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.
//! raised if Index is not in the range [1, NbPoles]
raised if the resulting number of poles is greater than
MaxDegree + 1.
.
Standard_EXPORT void InsertPoleAfter (const Standard_Integer Index, const gp_Pnt &P, const Standard_Real Weight)
 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.
//! Raised if Index is not in the range [1, NbPoles]
Raised if the resulting number of poles is greater than
MaxDegree + 1.
Raised if Weight is lower or equal to Resolution from package gp.
.
Standard_EXPORT void InsertPoleBefore (const Standard_Integer Index, const gp_Pnt &P)
 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.
//! Raised if Index is not in the range [1, NbPoles]
Raised if the resulting number of poles is greater than
MaxDegree + 1.
.
Standard_EXPORT void InsertPoleBefore (const Standard_Integer Index, const gp_Pnt &P, const Standard_Real Weight)
 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.
//! Raised if Index is not in the range [1, NbPoles]
Raised if the resulting number of poles is greater than
MaxDegree + 1.
Raised if Weight is lower or equal to Resolution from
package gp.
.
Standard_EXPORT void RemovePole (const Standard_Integer Index)
 Removes the pole of range Index.
If the curve was rational it can become non rational.
//! Raised if Index is not in the range [1, NbPoles]
//! Raised if Degree is lower than 2.
.
Standard_EXPORT void Reverse ()
 Reverses the direction of parametrization of <me>
Value (NewU) = Value (1 - OldU)
.
Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const
 Returns the parameter on the reversed curve for
the point of parameter U on <me>.

returns 1-U
.
Standard_EXPORT void Segment (const Standard_Real U1, const Standard_Real U2)
 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.
.
Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt &P)
 Substitutes the pole of range index with P.
If the curve <me> is rational the weight of range Index
is not modified.
//! raiseD if Index is not in the range [1, NbPoles]
.
Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt &P, const Standard_Real Weight)
 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.
//! Raised if Index is not in the range [1, NbPoles]
//! Raised if Weight <= Resolution from package gp
.
Standard_EXPORT void SetWeight (const Standard_Integer Index, const Standard_Real Weight)
 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.
//! Raised if Index is not in the range [1, NbPoles]
//! Raised if Weight <= Resolution from package gp
.
Standard_EXPORT Standard_Boolean IsClosed () const
 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.
.
Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const
 Continuity of the curve, returns True.
.
Standard_EXPORT Standard_Boolean IsPeriodic () const
 Returns True if the parametrization of a curve is periodic.
(P(u) = P(u + T) T = constante)
.
Standard_EXPORT Standard_Boolean IsRational () const
 Returns false if all the weights are identical. The tolerance
criterion is Resolution from package gp.
.
Standard_EXPORT GeomAbs_Shape Continuity () const
 a Bezier curve is CN

Standard_EXPORT Standard_Integer Degree () const
 Returns the polynomial degree of the curve.
it is the number of poles - 1
//! 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.
.
Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt &P) const
 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.
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.
.
Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt &P, gp_Vec &V1) const
 Returns the point P of parameter U and the first derivative V1.
//! Raised if the continuity of the curve is not C1.
.
Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt &P, gp_Vec &V1, gp_Vec &V2) const
 Returns the point P of parameter U, the first and second
derivatives V1 and V2.
//! Raised if the continuity of the curve is not C2.
.
Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt &P, gp_Vec &V1, gp_Vec &V2, gp_Vec &V3) const
 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.
.
Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const
 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.
.
Standard_EXPORT gp_Pnt StartPoint () const
 Returns Value (U=0.), it is the first control point of the curve.
.
Standard_EXPORT gp_Pnt EndPoint () const
 Returns Value (U=1.), it is the last control point of the Bezier curve.
.
Standard_EXPORT Standard_Real FirstParameter () const
 Returns the value of the first parameter of this
Bezier curve. This is 0.0, which gives the start point of this Bezier curve
.
Standard_EXPORT Standard_Real LastParameter () const
 Returns the value of the last parameter of this
Bezier curve. This is 1.0, which gives the end point of this Bezier curve.
.
Standard_EXPORT Standard_Integer NbPoles () const
 Returns the number of poles of this Bezier curve.
.
Standard_EXPORT gp_Pnt Pole (const Standard_Integer Index) const
 Returns the pole of range Index.
//! Raised if Index is not in the range [1, NbPoles]
.
Standard_EXPORT void Poles (TColgp_Array1OfPnt &P) const
 Returns all the poles of the curve.
Raised if the length of P is not equal to the number of poles.
.
Standard_EXPORT Standard_Real Weight (const Standard_Integer Index) const
 Returns the weight of range Index.
//! Raised if Index is not in the range [1, NbPoles]
.
Standard_EXPORT void Weights (TColStd_Array1OfReal &W) const
 Returns all the weights of the curve.
Raised if the length of W is not equal to the number of poles.
.
Standard_EXPORT void Transform (const gp_Trsf &T)
 Applies the transformation T to this Bezier curve.
.
Standard_EXPORT void Resolution (const Standard_Real Tolerance3D, Standard_Real &UTolerance)
 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
.
Standard_EXPORT Handle_Geom_Geometry Copy () const
 Creates a new object which is a copy of this Bezier curve.
.
Standard_EXPORT const Handle (Standard_Type)&DynamicType() const

Static Public Member Functions

static Standard_EXPORT Standard_Integer MaxDegree ()
 Returns the value of the maximum polynomial degree
of any Geom_BezierCurve curve. This value is 25.
.

Private Member Functions

Standard_EXPORT void Init (const Handle(TColgp_HArray1OfPnt)&Poles, const Handle(TColStd_HArray1OfReal)&Weights)
 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.

if nbpoles < 2 or nbboles > MaDegree + 1
.
Standard_EXPORT Standard_Boolean CoefficientsOK (const Standard_Real U) const
 returns true if the coefficients have been
computed with the right value of cacheparameter
for the given U value.


Standard_EXPORT void UpdateCoefficients (const Standard_Real U=0.0)
 Recompute the coeficients.
.

Private Attributes

Standard_Boolean rational
Standard_Boolean closed
Handle_TColgp_HArray1OfPnt poles
Handle_TColStd_HArray1OfReal weights
Handle_TColgp_HArray1OfPnt coeffs
Handle_TColStd_HArray1OfReal wcoeffs
Standard_Integer validcache
Standard_Real parametercache
Standard_Real spanlenghtcache
Standard_Real maxderivinv
Standard_Boolean maxderivinvok

Constructor & Destructor Documentation

Standard_EXPORT Geom_BezierCurve::Geom_BezierCurve const TColgp_Array1OfPnt &  CurvePoles  ) 
 

Standard_EXPORT Geom_BezierCurve::Geom_BezierCurve const TColgp_Array1OfPnt &  CurvePoles,
const TColStd_Array1OfReal &  PoleWeights
 


Member Function Documentation

Standard_EXPORT Standard_Boolean Geom_BezierCurve::CoefficientsOK const Standard_Real  U  )  const [private]
 

Standard_EXPORT GeomAbs_Shape Geom_BezierCurve::Continuity  )  const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT Handle_Geom_Geometry Geom_BezierCurve::Copy  )  const [virtual]
 

Implements Geom_Geometry.

Standard_EXPORT void Geom_BezierCurve::D0 const Standard_Real  U,
gp_Pnt &  P
const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT void Geom_BezierCurve::D1 const Standard_Real  U,
gp_Pnt &  P,
gp_Vec &  V1
const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT void Geom_BezierCurve::D2 const Standard_Real  U,
gp_Pnt &  P,
gp_Vec &  V1,
gp_Vec &  V2
const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT void Geom_BezierCurve::D3 const Standard_Real  U,
gp_Pnt &  P,
gp_Vec &  V1,
gp_Vec &  V2,
gp_Vec &  V3
const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT Standard_Integer Geom_BezierCurve::Degree  )  const
 

Standard_EXPORT gp_Vec Geom_BezierCurve::DN const Standard_Real  U,
const Standard_Integer  N
const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT gp_Pnt Geom_BezierCurve::EndPoint  )  const [virtual]
 

Implements Geom_BoundedCurve.

Standard_EXPORT Standard_Real Geom_BezierCurve::FirstParameter  )  const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT const Geom_BezierCurve::Handle Standard_Type   )  const
 

Reimplemented from Geom_BoundedCurve.

Standard_EXPORT void Geom_BezierCurve::Increase const Standard_Integer  Degree  ) 
 

Standard_EXPORT void Geom_BezierCurve::Init const Handle(TColgp_HArray1OfPnt)&  Poles,
const Handle(TColStd_HArray1OfReal)&  Weights
[private]
 

Standard_EXPORT void Geom_BezierCurve::InsertPoleAfter const Standard_Integer  Index,
const gp_Pnt &  P,
const Standard_Real  Weight
 

Standard_EXPORT void Geom_BezierCurve::InsertPoleAfter const Standard_Integer  Index,
const gp_Pnt &  P
 

Standard_EXPORT void Geom_BezierCurve::InsertPoleBefore const Standard_Integer  Index,
const gp_Pnt &  P,
const Standard_Real  Weight
 

Standard_EXPORT void Geom_BezierCurve::InsertPoleBefore const Standard_Integer  Index,
const gp_Pnt &  P
 

Standard_EXPORT Standard_Boolean Geom_BezierCurve::IsClosed  )  const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT Standard_Boolean Geom_BezierCurve::IsCN const Standard_Integer  N  )  const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT Standard_Boolean Geom_BezierCurve::IsPeriodic  )  const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT Standard_Boolean Geom_BezierCurve::IsRational  )  const
 

Standard_EXPORT Standard_Real Geom_BezierCurve::LastParameter  )  const [virtual]
 

Implements Geom_Curve.

static Standard_EXPORT Standard_Integer Geom_BezierCurve::MaxDegree  )  [static]
 

Standard_EXPORT Standard_Integer Geom_BezierCurve::NbPoles  )  const
 

Standard_EXPORT gp_Pnt Geom_BezierCurve::Pole const Standard_Integer  Index  )  const
 

Standard_EXPORT void Geom_BezierCurve::Poles TColgp_Array1OfPnt &  P  )  const
 

Standard_EXPORT void Geom_BezierCurve::RemovePole const Standard_Integer  Index  ) 
 

Standard_EXPORT void Geom_BezierCurve::Resolution const Standard_Real  Tolerance3D,
Standard_Real &  UTolerance
 

Standard_EXPORT void Geom_BezierCurve::Reverse  )  [virtual]
 

Implements Geom_Curve.

Standard_EXPORT Standard_Real Geom_BezierCurve::ReversedParameter const Standard_Real  U  )  const [virtual]
 

Implements Geom_Curve.

Standard_EXPORT void Geom_BezierCurve::Segment const Standard_Real  U1,
const Standard_Real  U2
 

Standard_EXPORT void Geom_BezierCurve::SetPole const Standard_Integer  Index,
const gp_Pnt &  P,
const Standard_Real  Weight
 

Standard_EXPORT void Geom_BezierCurve::SetPole const Standard_Integer  Index,
const gp_Pnt &  P
 

Standard_EXPORT void Geom_BezierCurve::SetWeight const Standard_Integer  Index,
const Standard_Real  Weight
 

Standard_EXPORT gp_Pnt Geom_BezierCurve::StartPoint  )  const [virtual]
 

Implements Geom_BoundedCurve.

Standard_EXPORT void Geom_BezierCurve::Transform const gp_Trsf &  T  )  [virtual]
 

Implements Geom_Geometry.

Standard_EXPORT void Geom_BezierCurve::UpdateCoefficients const Standard_Real  U = 0.0  )  [private]
 

Standard_EXPORT Standard_Real Geom_BezierCurve::Weight const Standard_Integer  Index  )  const
 

Standard_EXPORT void Geom_BezierCurve::Weights TColStd_Array1OfReal &  W  )  const
 


Field Documentation

Standard_Boolean Geom_BezierCurve::closed [private]
 

Handle_TColgp_HArray1OfPnt Geom_BezierCurve::coeffs [private]
 

Standard_Real Geom_BezierCurve::maxderivinv [private]
 

Standard_Boolean Geom_BezierCurve::maxderivinvok [private]
 

Standard_Real Geom_BezierCurve::parametercache [private]
 

Handle_TColgp_HArray1OfPnt Geom_BezierCurve::poles [private]
 

Standard_Boolean Geom_BezierCurve::rational [private]
 

Standard_Real Geom_BezierCurve::spanlenghtcache [private]
 

Standard_Integer Geom_BezierCurve::validcache [private]
 

Handle_TColStd_HArray1OfReal Geom_BezierCurve::wcoeffs [private]
 

Handle_TColStd_HArray1OfReal Geom_BezierCurve::weights [private]
 


The documentation for this class was generated from the following file:
Generated on Mon Aug 25 13:22:51 2008 for OpenCASCADE by  doxygen 1.4.1