OpenCascade.js
API ReferenceModelingAlgorithmsTKGeomAlgo

Geom2dAPI

OCCT package Geom2dAPI: Geom2dAPI_ExtremaCurveCurve, Geom2dAPI_InterCurveCurve, Geom2dAPI_Interpolate, Geom2dAPI_PointsToBSpline, and 1 more bound classes.

Geom2dAPI_ExtremaCurveCurve

Describes functions for computing all the extrema between two 2D curves. An ExtremaCurveCurve algorithm minimizes or maximizes the distance between a point on the first curve and a point on the second curve. Thus, it computes the start point and end point of perpendiculars common to the two curves (an intersection point is not an extremum except where the two curves are tangential at this point). Solutions consist of pairs of points, and an extremum is considered to be a segment joining the two points of a solution. An ExtremaCurveCurve object provides a framework for:

  • defining the construction of the extrema,
  • implementing the construction algorithm, and
  • consulting the results. Warning In some cases, the nearest points between two curves do not correspond to one of the computed extrema. Instead, they may be given by:
  • a limit point of one curve and one of the following:
  • its orthogonal projection on the other curve,
  • a limit point of the other curve; or
  • an intersection point between the two curves.

Constructors(1)

  • constructor(C1: Geom2d_Curve, C2: Geom2d_Curve, U1min: number, U1max: number, U2min: number, U2max: number): Geom2dAPI_ExtremaCurveCurve

    Computes the extrema between.

    • the portion of the curve C1 limited by the two points of parameter (U1min,U1max), and
    • the portion of the curve C2 limited by the two points of parameter (U2min,U2max). Warning Use the function NbExtrema to obtain the number of solutions. If this algorithm fails, NbExtrema returns 0.
    Parameters (6)
    • C1
    • C2
    • U1min
    • U1max
    • U2min
    • U2max

Instance methods(8)

  • NbExtrema(): number

    Returns the number of extrema computed by this algorithm. Note: if this algorithm fails, NbExtrema returns 0.

  • Points(Index: number, P1: gp_Pnt2d, P2: gp_Pnt2d): void

    Returns the points P1 on the first curve and P2 on the second curve, which are the ends of the extremum of index Index computed by this algorithm. Exceptions Standard_OutOfRange if Index is not in the range [ 1,NbExtrema ], where NbExtrema is the number of extrema computed by this algorithm.

    Parameters (3)
    • Index
    • P1
      Mutated in place; read the updated value from this argument after the call.
    • P2
      Mutated in place; read the updated value from this argument after the call.
  • Parameters(Index: number, U1: number, U2: number): { U1: number; U2: number }

    Returns the parameters U1 of the point on the first curve and U2 of the point on the second curve, which are the ends of the extremum of index Index computed by this algorithm. Exceptions Standard_OutOfRange if Index is not in the range [ 1,NbExtrema ], where NbExtrema is the number of extrema computed by this algorithm.

    Parameters (3)
    • Index
    • U1
    • U2
    Returns

    A result object with fields:

    • U1: updated value from the call.
    • U2: updated value from the call.
  • Distance(Index: number): number

    Computes the distance between the end points of the extremum of index Index computed by this algorithm. Exceptions Standard_OutOfRange if Index is not in the range [ 1,NbExtrema ], where NbExtrema is the number of extrema computed by this algorithm.

    Parameters (1)
    • Index
  • Returns the points P1 on the first curve and P2 on the second curve, which are the ends of the shortest extremum computed by this algorithm. Exceptions StdFail_NotDone if this algorithm fails.

    Parameters (2)
    • P1
      Mutated in place; read the updated value from this argument after the call.
    • P2
      Mutated in place; read the updated value from this argument after the call.
  • LowerDistanceParameters(U1: number, U2: number): { U1: number; U2: number }

    Returns the parameters U1 of the point on the first curve and U2 of the point on the second curve, which are the ends of the shortest extremum computed by this algorithm. Exceptions StdFail_NotDone if this algorithm fails.

    Parameters (2)
    • U1
    • U2
    Returns

    A result object with fields:

    • U1: updated value from the call.
    • U2: updated value from the call.
  • LowerDistance(): number

    Computes the distance between the end points of the shortest extremum computed by this algorithm. Exceptions - StdFail_NotDone if this algorithm fails.

Geom2dAPI_InterCurveCurve

This class implements methods for computing.

  • the intersections between two 2D curves,
  • the self-intersections of a 2D curve. Using the InterCurveCurve algorithm allows to get the following results:
  • intersection points in the case of cross intersections,
  • intersection segments in the case of tangential intersections,
  • nothing in the case of no intersections.

Constructors(3)

  • Create an empty intersector. Use the function Init for further initialization of the intersection algorithm by curves or curve.

  • Creates an object and computes self-intersections of the curve C1. Tolerance value Tol, defaulted to 1.0e-6, defines the precision of computing the intersection points. In case of a tangential intersection, Tol also defines the size of intersection segments (limited portions of the curves) where the distance between all points from two curves (or a curve in case of self-intersection) is less than Tol. Warning Use functions NbPoints and NbSegments to obtain the number of solutions. If the algorithm finds no intersections NbPoints and NbSegments return 0.

    Parameters (2)
    • C1
    • Tol
  • Creates an object and computes the intersections between the curves C1 and C2.

    Parameters (3)
    • C1
    • C2
    • Tol

Instance methods(7)

  • Init(C1: Geom2d_Curve, C2: Geom2d_Curve, Tol: number): void

    Initializes an algorithm with the given arguments and computes the intersections between the curves C1. and C2.

    Parameters (3)
    • C1
    • C2
    • Tol
  • Init(C1: Geom2d_Curve, Tol: number): void

    Initializes an algorithm with the given arguments and computes the self-intersections of the curve C1. Tolerance value Tol, defaulted to 1.0e-6, defines the precision of computing the intersection points. In case of a tangential intersection, Tol also defines the size of intersection segments (limited portions of the curves) where the distance between all points from two curves (or a curve in case of self-intersection) is less than Tol. Warning Use functions NbPoints and NbSegments to obtain the number of solutions. If the algorithm finds no intersections NbPoints and NbSegments return 0.

    Parameters (2)
    • C1
    • Tol
  • NbPoints(): number

    Returns the number of intersection-points in case of cross intersections. NbPoints returns 0 if no intersections were found.

  • Point(Index: number): gp_Pnt2d

    Returns the intersection point of index Index. Intersection points are computed in case of cross intersections with a precision equal to the tolerance value assigned at the time of construction or in the function Init (this value is defaulted to 1.0e-6). Exceptions Standard_OutOfRange if index is not in the range [ 1,NbPoints ], where NbPoints is the number of computed intersection points.

    Parameters (1)
    • Index
  • NbSegments(): number

    Returns the number of tangential intersections. NbSegments returns 0 if no intersections were found.

  • Segment(Index: number): { Curve1: Geom2d_Curve; Curve2: Geom2d_Curve; [Symbol.dispose](): void }

    Use this syntax only to get solutions of tangential intersection between two curves. Output values Curve1 and Curve2 are the intersection segments on the first curve and on the second curve accordingly. Parameter Index defines a number of computed solution. An intersection segment is a portion of an initial curve limited by two points.
    The distance from each point of this segment to the other curve is less or equal to the tolerance value assigned at the time of construction or in function Init (this value is defaulted to 1.0e-6).
    Exceptions Standard_OutOfRange if Index is not in the range [ 1,NbSegments ], where NbSegments is the number of computed tangential intersections. Standard_NullObject if the algorithm is initialized for the computing of self-intersections on a curve.

    Parameters (1)
    • Index
    Returns

    A result object with fields:

    • Curve1: owned by the returned envelope.
    • Curve2: owned by the returned envelope.
      Dispose the returned envelope to release owned Handle fields.
  • return the algorithmic object from Intersection.

Geom2dAPI_Interpolate

This class is used to interpolate a BsplineCurve passing through an array of points, with a C2 Continuity if tangency is not requested at the point. If tangency is requested at the point the continuity will be C1. If Perodicity is requested the curve will be closed and the junction will be the first point given.
The curve will than be only C1 The curve is defined by a table of points through which it passes, and if required by a parallel table of reals which gives the value of the parameter of each point through which the resulting BSpline curve passes, and by vectors tangential to these points. An Interpolate object provides a framework for: defining the constraints of the BSpline curve,.

  • implementing the interpolation algorithm, and consulting the results.

Constructors(2)

  • constructor(Points: NCollection_HArray1_gp_Pnt2d, PeriodicFlag: boolean, Tolerance: number): Geom2dAPI_Interpolate

    Tolerance is to check if the points are not too close to one an other It is also used to check if the tangent vector is not too small. There should be at least 2 points if PeriodicFlag is True then the curve will be periodic.

    Parameters (3)
    • Points
    • PeriodicFlag
    • Tolerance
  • constructor(Points: NCollection_HArray1_gp_Pnt2d, Parameters: NCollection_HArray1_double, PeriodicFlag: boolean, Tolerance: number): Geom2dAPI_Interpolate

    if PeriodicFlag is True then the curve will be periodic Warning: There should be as many parameters as there are points except if PeriodicFlag is True : then there should be one more parameter to close the curve

    Parameters (4)
    • Points
    • Parameters
    • PeriodicFlag
    • Tolerance

Instance methods(5)

  • Load(InitialTangent: gp_Vec2d, FinalTangent: gp_Vec2d, Scale: boolean): void

    Assigns this constrained BSpline curve to be tangential to vectors InitialTangent and FinalTangent at its first and last points respectively (i.e. the first and last points of the table of points through which the curve passes, as defined at the time of initialization). <Scale> - boolean flag defining whether tangent vectors are to be scaled according to derivatives of lagrange interpolation.

    Parameters (3)
    • InitialTangent
    • FinalTangent
    • Scale
  • Load(Tangents: NCollection_Array1_gp_Vec2d, TangentFlags: NCollection_HArray1_bool, Scale: boolean): void

    Assigns this constrained BSpline curve to be tangential to vectors defined in the table Tangents, which is parallel to the table of points through which the curve passes, as defined at the time of initialization. Vectors in the table Tangents are defined only if the flag given in the parallel table TangentFlags is true: only these vectors are set as tangency constraints. <Scale> - boolean flag defining whether tangent vectors are to be scaled according to derivatives of lagrange interpolation.

    Parameters (3)
    • Tangents
    • TangentFlags
    • Scale
  • Perform(): void

    Computes the constrained BSpline curve. Use the function IsDone to verify that the computation is successful, and then the function Curve to obtain the result.

  • Returns the computed BSpline curve. Raises StdFail_NotDone if the interpolation fails.

  • IsDone(): boolean

    Returns true if the constrained BSpline curve is successfully constructed. Note: in this case, the result is given by the function Curve.

Geom2dAPI_PointsToBSpline

This class is used to approximate a BsplineCurve passing through an array of points, with a given Continuity. Describes functions for building a 2D BSpline curve which approximates a set of points. A PointsToBSpline object provides a framework for:

  • defining the data of the BSpline curve to be built,
  • implementing the approximation algorithm, and
  • consulting the results

Constructors(6)

  • Constructs an empty approximation algorithm. Use an Init function to define and build the BSpline curve.

  • constructor(Points: NCollection_Array1_gp_Pnt2d, DegMin?: number, DegMax?: number, Continuity?: GeomAbs_Shape, Tol2D?: number): Geom2dAPI_PointsToBSpline

    Approximate a BSpline Curve passing through an array of Point. The resulting BSpline will have the following properties: 1- his degree will be in the range [Degmin,Degmax] 2- his continuity will be at least <Continuity> 3- the distance from the point <Points> to the BSpline will be lower to Tol2D.

    Parameters (5)
    • Points
    • DegMin
    • DegMax
    • Continuity
    • Tol2D
  • constructor(Points: NCollection_Array1_gp_Pnt2d, ParType: Approx_ParametrizationType, DegMin?: number, DegMax?: number, Continuity?: GeomAbs_Shape, Tol2D?: number): Geom2dAPI_PointsToBSpline

    Approximate a BSpline Curve passing through an array of Point. The resulting BSpline will have the following properties: 1- his degree will be in the range [Degmin,Degmax] 2- his continuity will be at least <Continuity> 3- the distance from the point <Points> to the BSpline will be lower to Tol2D.

    Parameters (6)
    • Points
    • ParType
    • DegMin
    • DegMax
    • Continuity
    • Tol2D
  • constructor(Points: NCollection_Array1_gp_Pnt2d, Parameters: NCollection_Array1_double, DegMin?: number, DegMax?: number, Continuity?: GeomAbs_Shape, Tol2D?: number): Geom2dAPI_PointsToBSpline

    Approximate a BSpline Curve passing through an array of Point, which parameters are given by the array <Parameters>. The resulting BSpline will have the following properties: 1- his degree will be in the range [Degmin,Degmax] 2- his continuity will be at least <Continuity> 3- the distance from the point <Points> to the BSpline will be lower to Tol2D.

    Parameters (6)
    • Points
    • Parameters
    • DegMin
    • DegMax
    • Continuity
    • Tol2D
  • constructor(YValues: NCollection_Array1_double, X0: number, DX: number, DegMin?: number, DegMax?: number, Continuity?: GeomAbs_Shape, Tol2D?: number): Geom2dAPI_PointsToBSpline

    Approximate a BSpline Curve passing through an array of Point. Of coordinates :
    X = X0 + DX * (i-YValues.Lower()) Y = YValues(i)
    With i in the range YValues.Lower(), YValues.Upper()
    The BSpline will be parametrized from t = X0 to X0 + DX * (YValues.Upper() - YValues.Lower())
    And will satisfy X(t) = t
    The resulting BSpline will have the following properties: 1- his degree will be in the range [Degmin,Degmax] 2- his continuity will be at least <Continuity> 3- the distance from the point <Points> to the BSpline will be lower to Tol2D

    Parameters (7)
    • YValues
    • X0
    • DX
    • DegMin
    • DegMax
    • Continuity
    • Tol2D
  • constructor(Points: NCollection_Array1_gp_Pnt2d, Weight1: number, Weight2: number, Weight3: number, DegMax?: number, Continuity?: GeomAbs_Shape, Tol3D?: number): Geom2dAPI_PointsToBSpline

    Approximate a BSpline Curve passing through an array of Point using variational smoothing algorithm, which tries to minimize additional criterium: Weight1CurveLength + Weight2Curvature + Weight3*Torsion.

    Parameters (7)
    • Points
    • Weight1
    • Weight2
    • Weight3
    • DegMax
    • Continuity
    • Tol3D

Instance methods(7)

  • Init(Points: NCollection_Array1_gp_Pnt2d, DegMin: number, DegMax: number, Continuity: GeomAbs_Shape, Tol2D: number): void

    Approximate a BSpline Curve passing through an array of Point. The resulting BSpline will have the following properties: 1- his degree will be in the range [Degmin,Degmax] 2- his continuity will be at least <Continuity> 3- the distance from the point <Points> to the BSpline will be lower to Tol2D.

    Parameters (5)
    • Points
    • DegMin
    • DegMax
    • Continuity
    • Tol2D
  • Init(Points: NCollection_Array1_gp_Pnt2d, ParType: Approx_ParametrizationType, DegMin: number, DegMax: number, Continuity: GeomAbs_Shape, Tol2D: number): void

    Approximate a BSpline Curve passing through an array of Point. The resulting BSpline will have the following properties: 1- his degree will be in the range [Degmin,Degmax] 2- his continuity will be at least <Continuity> 3- the distance from the point <Points> to the BSpline will be lower to Tol2D.

    Parameters (6)
    • Points
    • ParType
    • DegMin
    • DegMax
    • Continuity
    • Tol2D
  • Init(Points: NCollection_Array1_gp_Pnt2d, Parameters: NCollection_Array1_double, DegMin: number, DegMax: number, Continuity: GeomAbs_Shape, Tol2D: number): void

    Approximate a BSpline Curve passing through an array of Point, which parameters are given by the array <Parameters>. The resulting BSpline will have the following properties: 1- his degree will be in the range [Degmin,Degmax] 2- his continuity will be at least <Continuity> 3- the distance from the point <Points> to the BSpline will be lower to Tol2D.

    Parameters (6)
    • Points
    • Parameters
    • DegMin
    • DegMax
    • Continuity
    • Tol2D
  • Init(YValues: NCollection_Array1_double, X0: number, DX: number, DegMin: number, DegMax: number, Continuity: GeomAbs_Shape, Tol2D: number): void

    Approximate a BSpline Curve passing through an array of Point. Of coordinates :
    X = X0 + DX * (i-YValues.Lower()) Y = YValues(i)
    With i in the range YValues.Lower(), YValues.Upper()
    The BSpline will be parametrized from t = X0 to X0 + DX * (YValues.Upper() - YValues.Lower())
    And will satisfy X(t) = t
    The resulting BSpline will have the following properties: 1- his degree will be in the range [Degmin,Degmax] 2- his continuity will be at least <Continuity> 3- the distance from the point <Points> to the BSpline will be lower to Tol2D

    Parameters (7)
    • YValues
    • X0
    • DX
    • DegMin
    • DegMax
    • Continuity
    • Tol2D
  • Init(Points: NCollection_Array1_gp_Pnt2d, Weight1: number, Weight2: number, Weight3: number, DegMax: number, Continuity: GeomAbs_Shape, Tol2D: number): void

    Approximate a BSpline Curve passing through an array of Point using variational smoothing algorithm, which tries to minimize additional criterium: Weight1CurveLength + Weight2Curvature + Weight3*Torsion.

    Parameters (7)
    • Points
    • Weight1
    • Weight2
    • Weight3
    • DegMax
    • Continuity
    • Tol2D
  • Returns the approximate BSpline Curve.

  • IsDone(): boolean

Geom2dAPI_ProjectPointOnCurve

This class implements methods for computing all the orthogonal projections of a 2D point onto a 2D curve.

Constructors(3)

Instance methods(11)

  • Init(P: gp_Pnt2d, Curve: Geom2d_Curve): void

    Initializes this algorithm with the given arguments, and computes the orthogonal projections of a point.
    on a curve <Curve>

    Parameters (2)
    • P
    • Curve
  • Init(P: gp_Pnt2d, Curve: Geom2d_Curve, Umin: number, Usup: number): void

    Initializes this algorithm with the given arguments, and computes the orthogonal projections of the point P onto the portion of the curve Curve limited by the two points of parameter Umin and Usup.

    Parameters (4)
    • P
    • Curve
    • Umin
    • Usup
  • NbPoints(): number

    return the number of of computed orthogonal projectionn points.

  • Point(Index: number): gp_Pnt2d

    Returns the orthogonal projection on the curve. Index is a number of a computed point. Exceptions Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where NbPoints is the number of solution points.

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

    Returns the parameter on the curve of a point which is the orthogonal projection. Index is a number of a computed projected point. Exceptions Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where NbPoints is the number of solution points.

    Parameters (1)
    • Index
  • Parameter(Index: number, U: number): { U: number }

    Returns the parameter on the curve of a point which is the orthogonal projection. Index is a number of a computed projected point. Exceptions Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where NbPoints is the number of solution points.

    Parameters (2)
    • Index
    • U
    Returns

    A result object with fields:

    • U: updated value from the call.
  • Distance(Index: number): number

    Computes the distance between the point and its computed orthogonal projection on the curve. Index is a number of computed projected point. Exceptions Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where NbPoints is the number of solution points.

    Parameters (1)
    • Index
  • Returns the nearest orthogonal projection of the point on the curve. Exceptions StdFail_NotDone if this algorithm fails.

  • Returns the parameter on the curve of the nearest orthogonal projection of the point. Exceptions StdFail_NotDone if this algorithm fails.

  • LowerDistance(): number

    Computes the distance between the point and its nearest orthogonal projection on the curve. Exceptions StdFail_NotDone if this algorithm fails.

  • Extrema(): any

    return the algorithmic object from Extrema