OpenCascade.js
API ReferenceModelingDataTKGeomBase

Geom2dConvert

OCCT package Geom2dConvert: Geom2dConvert, Geom2dConvert_ApproxArcsSegments, Geom2dConvert_ApproxCurve, Geom2dConvert_BSplineCurveKnotSplitting, and 3…

Geom2dConvert

This package provides an implementation of algorithms to do the conversion between equivalent geometric entities from package Geom2d.
It gives the possibility : . to obtain the B-spline representation of bounded curves. . to split a B-spline curve into several B-spline curves with some constraints of continuity, . to convert a B-spline curve into several Bezier curves or surfaces. All the geometric entities used in this package are bounded. References : . Generating the Bezier Points of B-spline curves and surfaces (Wolfgang Bohm) CAGD volume 13 number 6 november 1981 . On NURBS: A Survey (Leslie Piegl) IEEE Computer Graphics and Application January 1991 .
Curve and surface construction using rational B-splines (Leslie Piegl and Wayne Tiller) CAD Volume 19 number 9 november 1987 . A survey of curve and surface methods in CAGD (Wolfgang BOHM) CAGD 1 1984.

Constructors(1)

Static methods(9)

  • SplitBSplineCurve(C: Geom2d_BSplineCurve, FromK1: number, ToK2: number, SameOrientation: boolean): Geom2d_BSplineCurve

    Convert a curve to BSpline by Approximation.
    This method computes the arc of B-spline curve between the two knots FromK1 and ToK2. If C is periodic the arc has the same orientation as C if SameOrientation = true.
    If C is not periodic SameOrientation is not used for the computation and C is oriented from the knot fromK1 to the knot toK2. We just keep the local definition of C between the knots FromK1 and ToK2.
    The returned B-spline curve has its first and last knots with a multiplicity equal to degree + 1, where degree is the polynomial degree of C. The indexes of the knots FromK1 and ToK2 doesn't include the repetition of multiple knots in their definition.
    Raised if FromK1 or ToK2 are out of the bounds [FirstUKnotIndex, LastUKnotIndex] Raised if FromK1 = ToK2

    Parameters (4)
    • C
    • FromK1
    • ToK2
    • SameOrientation
  • SplitBSplineCurve(C: Geom2d_BSplineCurve, FromU1: number, ToU2: number, ParametricTolerance: number, SameOrientation: boolean): Geom2d_BSplineCurve

    This function computes the segment of B-spline curve between the parametric values FromU1, ToU2. If C is periodic the arc has the same orientation as C if SameOrientation = True. If C is not periodic SameOrientation is not used for the computation and C is oriented fromU1 toU2. If U1 and U2 and two parametric values we consider that U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and ParametricTolerance must be greater or equal to Resolution from package gp.
    Raised if FromU1 or ToU2 are out of the parametric bounds of the curve (The tolerance criterion is ParametricTolerance). Raised if Abs (FromU1 - ToU2) <= ParametricTolerance Raised if ParametricTolerance < Resolution from gp.

    Parameters (5)
    • C
    • FromU1
    • ToU2
    • ParametricTolerance
    • SameOrientation
  • This function converts a non infinite curve from Geom into a B-spline curve. C must be an ellipse or a circle or a trimmed conic or a trimmed line or a Bezier curve or a trimmed Bezier curve or a BSpline curve or a trimmed BSpline curve or an Offset curve or a trimmed Offset curve. The returned B-spline is not periodic except if C is a Circle or an Ellipse.
    ParameterisationType applies only if the curve is a Circle or an ellipse : TgtThetaOver2, TgtThetaOver2_1, TgtThetaOver2_2, TgtThetaOver2_3, TgtThetaOver2_4, Purpose: this is the classical rational parameterisation 2 1 - t cos(theta) = ----- 2 1 + t.
    2t sin(theta) = ----- 2 1 + t
    t = tan (theta/2)
    with TgtThetaOver2 the routine will compute the number of spans using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1 with TgtThetaOver2_N, N spans will be forced: an error will be raized if (ULast - UFirst) >= PI and N = 1, ULast - UFirst >= 2 PI and N = 2
    QuasiAngular, here t is a rational function that approximates theta ----> tan(theta/2). Nevetheless the composing with above function yields exact functions whose square sum up to 1 RationalC1 ; t is replaced by a polynomial function of u so as to grant C1 contiuity across knots. Exceptions Standard_DomainError if the curve C is infinite. Standard_ConstructionError:

    • if C is a complete circle or ellipse, and if Parameterisation is not equal to Convert_TgtThetaOver2 or to Convert_RationalC1, or
    • if C is a trimmed circle or ellipse and if Parameterisation is equal to Convert_TgtThetaOver2_1 and if U2 - U1 > 0.9999 * Pi where U1 and U2 are respectively the first and the last parameters of the trimmed curve (this method of parameterization cannot be used to convert a half-circle or a half-ellipse, for example), or
    • if C is a trimmed circle or ellipse and Parameterisation is equal to Convert_TgtThetaOver2_2 and U2 - U1 > 1.9999 * Pi where U1 and U2 are respectively the first and the last parameters of the trimmed curve (this method of parameterization cannot be used to convert a quasi-complete circle or ellipse).
    Parameters (2)
    • C
    • Parameterisation
  • ConcatG1(ArrayOfCurves: NCollection_Array1_handle_Geom2d_BSplineCurve, ArrayOfToler: NCollection_Array1_double, ClosedFlag: boolean, ClosedTolerance: number): { ArrayOfConcatenated: NCollection_HArray1_handle_Geom2d_BSplineCurve; ClosedFlag: boolean; [Symbol.dispose](): void }

    This Method concatenates G1 the ArrayOfCurves as far as it is possible. ArrayOfCurves[0..N-1] ArrayOfToler contains the biggest tolerance of the two points shared by two consecutives curves. Its dimension: [0..N-2] ClosedFlag indicates if the ArrayOfCurves is closed. In this case ClosedTolerance contains the biggest tolerance of the two points which are at the closure. Otherwise its value is 0.0 ClosedFlag becomes False on the output if it is impossible to build closed curve.

    Parameters (4)
    • ArrayOfCurves
      Mutated in place; read the updated value from this argument after the call.
    • ArrayOfToler
    • ClosedFlag
    • ClosedTolerance
    Returns

    A result object with fields:

    • ArrayOfConcatenated: owned by the returned envelope.
    • ClosedFlag: updated value from the call.
      Dispose the returned envelope to release owned Handle fields.
  • ConcatC1(ArrayOfCurves: NCollection_Array1_handle_Geom2d_BSplineCurve, ArrayOfToler: NCollection_Array1_double, ClosedFlag: boolean, ClosedTolerance: number): { ArrayOfIndices: NCollection_HArray1_int; ArrayOfConcatenated: NCollection_HArray1_handle_Geom2d_BSplineCurve; ClosedFlag: boolean; [Symbol.dispose](): void }

    This Method concatenates C1 the ArrayOfCurves as far as it is possible. ArrayOfCurves[0..N-1] ArrayOfToler contains the biggest tolerance of the two points shared by two consecutives curves. Its dimension: [0..N-2] ClosedFlag indicates if the ArrayOfCurves is closed. In this case ClosedTolerance contains the biggest tolerance of the two points which are at the closure. Otherwise its value is 0.0 ClosedFlag becomes False on the output if it is impossible to build closed curve.

    Parameters (4)
    • ArrayOfCurves
      Mutated in place; read the updated value from this argument after the call.
    • ArrayOfToler
    • ClosedFlag
    • ClosedTolerance
    Returns

    A result object with fields:

    • ArrayOfIndices: owned by the returned envelope.
    • ArrayOfConcatenated: owned by the returned envelope.
    • ClosedFlag: updated value from the call.
      Dispose the returned envelope to release owned Handle fields.
  • ConcatC1(ArrayOfCurves: NCollection_Array1_handle_Geom2d_BSplineCurve, ArrayOfToler: NCollection_Array1_double, ClosedFlag: boolean, ClosedTolerance: number, AngularTolerance: number): { ArrayOfIndices: NCollection_HArray1_int; ArrayOfConcatenated: NCollection_HArray1_handle_Geom2d_BSplineCurve; ClosedFlag: boolean; [Symbol.dispose](): void }

    This Method concatenates C1 the ArrayOfCurves as far as it is possible. ArrayOfCurves[0..N-1] ArrayOfToler contains the biggest tolerance of the two points shared by two consecutives curves. Its dimension: [0..N-2] ClosedFlag indicates if the ArrayOfCurves is closed. In this case ClosedTolerance contains the biggest tolerance of the two points which are at the closure. Otherwise its value is 0.0 ClosedFlag becomes False on the output if it is impossible to build closed curve.

    Parameters (5)
    • ArrayOfCurves
      Mutated in place; read the updated value from this argument after the call.
    • ArrayOfToler
    • ClosedFlag
    • ClosedTolerance
    • AngularTolerance
    Returns

    A result object with fields:

    • ArrayOfIndices: owned by the returned envelope.
    • ArrayOfConcatenated: owned by the returned envelope.
    • ClosedFlag: updated value from the call.
      Dispose the returned envelope to release owned Handle fields.
  • C0BSplineToC1BSplineCurve(Tolerance: number): { BS: Geom2d_BSplineCurve; [Symbol.dispose](): void }

    This Method reduces as far as it is possible the multiplicities of the knots of the BSpline BS.(keeping the geometry). It returns a new BSpline which could still be C0. tolerance is a geometrical tolerance.

    Parameters (1)
    • Tolerance
    Returns

    A result object with fields:

    • BS: owned by the returned envelope.
      Dispose the returned envelope to release owned Handle fields.
  • This Method reduces as far as it is possible the multiplicities of the knots of the BSpline BS.(keeping the geometry). It returns an array of BSpline C1. Tolerance is a geometrical tolerance.

    Parameters (2)
    • BS
    • Tolerance
    Returns

    A result object with fields:

    • tabBS: owned by the returned envelope.
      Dispose the returned envelope to release owned Handle fields.
  • C0BSplineToArrayOfC1BSplineCurve(BS: Geom2d_BSplineCurve, AngularTolerance: number, Tolerance: number): { tabBS: NCollection_HArray1_handle_Geom2d_BSplineCurve; [Symbol.dispose](): void }

    This Method reduces as far as it is possible the multiplicities of the knots of the BSpline BS.(keeping the geometry). It returns an array of BSpline C1. tolerance is a geometrical tolerance.

    Parameters (3)
    • BS
    • AngularTolerance
    • Tolerance
    Returns

    A result object with fields:

    • tabBS: owned by the returned envelope.
      Dispose the returned envelope to release owned Handle fields.

Geom2dConvert_ApproxCurve

A framework to convert a 2D curve to a BSpline. This is done by approximation within a given tolerance.

Constructors(2)

  • constructor(Curve: Geom2d_Curve, Tol2d: number, Order: GeomAbs_Shape, MaxSegments: number, MaxDegree: number): Geom2dConvert_ApproxCurve

    Constructs an approximation framework defined by.

    • the 2D conic Curve
    • the tolerance value Tol2d
    • the degree of continuity Order
    • the maximum number of segments allowed MaxSegments
    • the highest degree MaxDegree which the polynomial defining the BSpline is allowed to have.
    Parameters (5)
    • Curve
    • Tol2d
    • Order
    • MaxSegments
    • MaxDegree
  • constructor(Curve: Adaptor2d_Curve2d, Tol2d: number, Order: GeomAbs_Shape, MaxSegments: number, MaxDegree: number): Geom2dConvert_ApproxCurve

    Constructs an approximation framework defined by.

    • the 2D conic Curve
    • the tolerance value Tol2d
    • the degree of continuity Order
    • the maximum number of segments allowed MaxSegments
    • the highest degree MaxDegree which the polynomial defining the BSpline is allowed to have.
    Parameters (5)
    • Curve
    • Tol2d
    • Order
    • MaxSegments
    • MaxDegree

Instance methods(4)

  • Returns the 2D BSpline curve resulting from the approximation algorithm.

  • IsDone(): boolean

    returns true if the approximation has been done with within required tolerance

  • HasResult(): boolean

    returns true if the approximation did come out with a result that is not NECESSARELY within the required tolerance

  • MaxError(): number

    Returns the greatest distance between a point on the source conic and the BSpline curve resulting from the approximation. (>0 when an approximation has been done, 0 if no approximation).

Geom2dConvert_BSplineCurveKnotSplitting

An algorithm to determine points at which a BSpline curve should be split in order to obtain arcs of the same continuity.
If you require curves with a minimum continuity for your computation, it is useful to know the points between which an arc has a continuity of a given order. The continuity order is given at the construction time. For a BSpline curve, the discontinuities are localized at the knot values. Between two knot values the BSpline is infinitely and continuously differentiable.
At a given knot, the continuity is equal to: Degree - Mult, where Degree is the degree of the BSpline curve and Mult is the multiplicity of the knot.
It is possible to compute the arcs which correspond to this splitting using the global function SplitBSplineCurve provided by the package Geom2dConvert. A BSplineCurveKnotSplitting object provides a framework for:

  • defining the curve to be analysed and the required degree of continuity,
  • implementing the computation algorithm, and
  • consulting the results.

Constructors(1)

  • Determines points at which the BSpline curve BasisCurve should be split in order to obtain arcs with a degree of continuity equal to ContinuityRange. These points are knot values of BasisCurve. They are identified by indices in the knots table of BasisCurve. Use the available interrogation functions to access computed values, followed by the global function SplitBSplineCurve (provided by the package Geom2dConvert) to split the curve. Exceptions Standard_RangeError if ContinuityRange is less than zero.

    Parameters (2)
    • BasisCurve
    • ContinuityRange

Instance methods(3)

  • NbSplits(): number

    Returns the number of points at which the analysed BSpline curve should be split, in order to obtain arcs with the continuity required by this framework. All these points correspond to knot values. Note that the first and last points of the curve, which bound the first and last arcs, are counted among these splitting points.

  • Splitting(SplitValues: NCollection_Array1_int): void

    Loads the SplitValues table with the split knots values computed in this framework. Each value in the table is an index in the knots table of the BSpline curve analysed by this algorithm.
    The values in SplitValues are given in ascending order and comprise the indices of the knots which give the first and last points of the curve.
    Use two consecutive values from the table as arguments of the global function SplitBSplineCurve (provided by the package Geom2dConvert) to split the curve. Exceptions Standard_DimensionError if the array SplitValues was not created with the following bounds:

    • 1, and
    • the number of split points computed in this framework (as given by the function NbSplits).
    Parameters (1)
    • SplitValues
      Mutated in place; read the updated value from this argument after the call.
  • SplitValue(Index: number): number

    Returns the split knot of index Index to the split knots table computed in this framework. The returned value is an index in the knots table of the BSpline curve analysed by this algorithm. Notes:

    • If Index is equal to 1, the corresponding knot gives the first point of the curve.
    • If Index is equal to the number of split knots computed in this framework, the corresponding point is the last point of the curve. Exceptions Standard_RangeError if Index is less than 1 or greater than the number of split knots computed in this framework.
    Parameters (1)
    • Index

Geom2dConvert_BSplineCurveToBezierCurve

An algorithm to convert a BSpline curve into a series of adjacent Bezier curves. A BSplineCurveToBezierCurve object provides a framework for:

  • defining the BSpline curve to be converted
  • implementing the construction algorithm, and
  • consulting the results. References : Generating the Bezier points of B-spline curves and surfaces (Wolfgang Bohm) CAD volume 13 number 6 november 1981

Constructors(2)

  • Computes all the data needed to convert.

    • the BSpline curve BasisCurve, into a series of adjacent Bezier arcs. The result consists of a series of BasisCurve arcs limited by points corresponding to knot values of the curve. Use the available interrogation functions to ascertain the number of computed Bezier arcs, and then to construct each individual Bezier curve (or all Bezier curves). Note: ParametricTolerance is not used.
    Parameters (1)
    • BasisCurve
  • constructor(BasisCurve: Geom2d_BSplineCurve, U1: number, U2: number, ParametricTolerance: number): Geom2dConvert_BSplineCurveToBezierCurve

    Computes all the data needed to convert the portion of the BSpline curve BasisCurve limited by the two parameter values U1 and U2 for Example if there is a Knot Uk and Uk < U < Uk + ParametricTolerance/2 the last curve corresponds to the span [Uk-1, Uk] and not to [Uk, Uk+1] The result consists of a series of BasisCurve arcs limited by points corresponding to knot values of the curve.
    Use the available interrogation functions to ascertain the number of computed Bezier arcs, and then to construct each individual Bezier curve (or all Bezier curves). Note: ParametricTolerance is not used. Raises DomainError if U1 or U2 are out of the parametric bounds of the basis curve [FirstParameter, LastParameter]. The Tolerance criterion is ParametricTolerance. Raised if Abs (U2 - U1) <= ParametricTolerance.

    Parameters (4)
    • BasisCurve
    • U1
    • U2
    • ParametricTolerance

Instance methods(4)

  • Arc(Index: number): Geom2d_BezierCurve

    Constructs and returns the Bezier curve of index Index to the table of adjacent Bezier arcs computed by this algorithm. This Bezier curve has the same orientation as the BSpline curve analyzed in this framework. Exceptions Standard_OutOfRange if Index is less than 1 or greater than the number of adjacent Bezier arcs computed by this algorithm.

    Parameters (1)
    • Index
  • Constructs all the Bezier curves whose data is computed by this algorithm and loads these curves into the Curves table. The Bezier curves have the same orientation as the BSpline curve analyzed in this framework. Exceptions Standard_DimensionError if the Curves array was not created with the following bounds:

    • 1 , and
    • the number of adjacent Bezier arcs computed by this algorithm (as given by the function NbArcs).
    Parameters (1)
    • Curves
      Mutated in place; read the updated value from this argument after the call.
  • This methode returns the bspline's knots associated to the converted arcs Raises DimensionError if the length of Curves is not equal to NbArcs + 1.

    Parameters (1)
    • TKnots
      Mutated in place; read the updated value from this argument after the call.
  • NbArcs(): number

    Returns the number of BezierCurve arcs. If at the creation time you have decomposed the basis curve between the parametric values UFirst, ULast the number of BezierCurve arcs depends on the number of knots included inside the interval [UFirst, ULast]. If you have decomposed the whole basis B-spline curve the number of BezierCurve arcs NbArcs is equal to the number of knots less one.

Geom2dConvert_CompCurveToBSplineCurve

This algorithm converts and concat several curve in an BSplineCurve.

Constructors(2)

Instance methods(3)

  • Add(NewCurve: Geom2d_BoundedCurve, Tolerance: number, After: boolean): boolean

    Append a curve in the BSpline Return False if the curve is not G0 with the BSplineCurve. Tolerance is used to check continuity and decrease Multiplicity at the common Knot After is useful if BasisCurve is a closed curve .

    Parameters (3)
    • NewCurve
    • Tolerance
    • After
  • Clear(): void

    Clear result curve.

Geom2dConvert_PPoint

Class representing a point on curve, with 2D coordinate and the tangent.

Constructors(3)

Instance methods(5)

  • Dist(theOth: Geom2dConvert_PPoint): number

    Compute the distance between two 2d points.

    Parameters (1)
    • theOth
  • Parameter(): number

    Query the parameter value.

  • Query the point location.

  • Query the first derivatives.

  • SetD1(theD1: gp_XY): void

    Change the value of the derivative at the point.

    Parameters (1)
    • theD1