CSLib
OCCT package CSLib: CSLib, CSLib_Class2d, CSLib_DerivativeStatus, CSLib_NormalPolyDef, and 1 more bound classes.
CSLib
Provides functions for basic geometric computation on curves and surfaces.
This package implements functions for computing surface normals and their derivatives at parametric points. The tolerance criteria used are Resolution from gp and RealEpsilon from double.
Key functionality:
- Normal computation from surface first derivatives (D1U, D1V)
- Approximate normal in singular cases using second derivatives
- Derivatives of the non-normalized and normalized normal vectors
Constructors(1)
- constructor(): CSLib
Static methods(2)
- DNNUV(theNu: number, theNv: number, theDerSurf: NCollection_Array2_gp_Vec): gp_Vec
Computes the derivative of order (theNu, theNv) of the non-normalized normal vector.
The non-normalized normal is N = dS/du ^ dS/dv. This function computes d^(Nu+Nv)N / (du^Nu * dv^Nv).Parameters (3)theNu—Derivative order in U directiontheNv—Derivative order in V directiontheDerSurf—Surface derivatives array where theDerSurf(i,j) = d^(i+j)S/(du^i * dv^j) for i = 0..theNu+1, j = 0..theNv+1
ReturnsThe derivative vector d^(Nu+Nv)N / (du^Nu * dv^Nv)
- DNNUV(theNu: number, theNv: number, theDerSurf1: NCollection_Array2_gp_Vec, theDerSurf2: NCollection_Array2_gp_Vec): gp_Vec
Computes the derivative of the non-normalized vector N = dS1/du ^ dS2/dv.
This variant is used for osculating surfaces where the normal is computed from derivatives of two different surfaces.Parameters (4)theNu—Derivative order in U directiontheNv—Derivative order in V directiontheDerSurf1—Derivatives of the first surface S1theDerSurf2—Derivatives of the second surface S2
ReturnsThe derivative vector
CSLib_Class2d
Low-level algorithm for 2D point-in-polygon classification.
This class determines whether a 2D point lies inside, outside, or on the boundary of a closed polygon. It uses a ray-casting algorithm where a horizontal ray from the test point is extended to infinity, and the number of polygon edge crossings determines the classification.
The polygon is internally normalized to [0,1] x [0,1] domain for numerical stability.
Constructors(4)
Default constructor. Creates an empty classifier.
- constructor(thePnts2d: NCollection_Array1_gp_Pnt2d, theTolU: number, theTolV: number, theUMin: number, theVMin: number, theUMax: number, theVMax: number): CSLib_Class2d
Constructs a 2D classifier from an array of polygon vertices.
The polygon is automatically closed (no need to repeat the first point at the end). Points are normalized internally to the UV bounds for numerical stability.Parameters (7)thePnts2d—Array of polygon vertices (minimum 3 points required)theTolU—Tolerance in U direction for boundary detectiontheTolV—Tolerance in V direction for boundary detectiontheUMin—Minimum U bound of the polygon domaintheVMin—Minimum V bound of the polygon domaintheUMax—Maximum U bound of the polygon domaintheVMax—Maximum V bound of the polygon domain
- constructor(thePnts2d: NCollection_Sequence_gp_Pnt2d, theTolU: number, theTolV: number, theUMin: number, theVMin: number, theUMax: number, theVMax: number): CSLib_Class2d
Constructs a 2D classifier from a sequence of polygon vertices.
Same as the array constructor but accepts a sequence for convenience.Parameters (7)thePnts2d—Sequence of polygon vertices (minimum 3 points required)theTolU—Tolerance in U direction for boundary detectiontheTolV—Tolerance in V direction for boundary detectiontheUMin—Minimum U bound of the polygon domaintheVMin—Minimum V bound of the polygon domaintheUMax—Maximum U bound of the polygon domaintheVMax—Maximum V bound of the polygon domain
- constructor(thePnts2d: NCollection_DynamicArray_gp_Pnt2d, theTolU: number, theTolV: number, theUMin: number, theVMin: number, theUMax: number, theVMax: number): CSLib_Class2d
Constructs a 2D classifier from a vector of polygon vertices.
Same as the array constructor but accepts a vector for convenience.Parameters (7)thePnts2d—Vector of polygon vertices (minimum 3 points required)theTolU—Tolerance in U direction for boundary detectiontheTolV—Tolerance in V direction for boundary detectiontheUMin—Minimum U bound of the polygon domaintheVMin—Minimum V bound of the polygon domaintheUMax—Maximum U bound of the polygon domaintheVMax—Maximum V bound of the polygon domain
Instance methods(2)
Classifies a point relative to the polygon.
Parameters (1)thePoint—The 2D point to classify
ReturnsClassification result
- SiDans_OnMode(thePoint: gp_Pnt2d, theTol: number): CSLib_Class2d_Result
Classifies a point with explicit ON tolerance.
Similar toSiDans()but uses the specified tolerance for boundary detection instead of the tolerances specified at construction.Parameters (2)thePoint—The 2D point to classifytheTol—Tolerance for boundary detection
ReturnsClassification result
CSLib_DerivativeStatus
Properties(7)
CSLib_NormalPolyDef
Polynomial definition for surface normal computation at singular points.
This class defines a polynomial function F(X) and its derivative for use with numerical root-finding algorithms. The function represents a trigonometric polynomial in terms of cos(X) and sin(X) with binomial coefficients.
The polynomial has the form: F(X) = Sum_{i=0}^{k0} C(k0,i) * cos^i(X) * sin^(k0-i)(X) * li(i)
where C(k0,i) is the binomial coefficient and li(i) are user-provided coefficients.
This is used internally by CSLib::Normal() to find the normal direction at singular surface points by solving for zeros of this polynomial.
Constructors(1)
- constructor(theK0: number, theLi: NCollection_Array1_double): CSLib_NormalPolyDef
Constructs a polynomial definition for normal computation.
Parameters (2)theK0—Polynomial degree (must be >= 0)theLi—Array of coefficients with indices 0 to theK0
Instance methods(3)
- Value(X: number, F: number): { returnValue: boolean; F: number }
Computes the value of the function for the given variable.
Evaluates F(X) = Sum_{i=0}^{k0} C(k0,i) * cos^i(X) * sin^(k0-i)(X) * li(i)Parameters (2)X—Input variable (angle in radians)F—Computed function value
ReturnsA result object with fields:
returnValue: true if calculation was successful, false otherwiseF: updated value from the call.
- Derivative(X: number, D: number): { returnValue: boolean; D: number }
Computes the derivative of the function for the given variable.
Evaluates dF/dX using the chain rule on the trigonometric polynomial.Parameters (2)X—Input variable (angle in radians)D—Computed derivative value
ReturnsA result object with fields:
returnValue: true if calculation was successful, false otherwiseD: updated value from the call.
- Values(X: number, F: number, D: number): { returnValue: boolean; F: number; D: number }
Computes both the value and derivative of the function.
More efficient than callingValue()andDerivative()separately as common subexpressions are computed only once.Parameters (3)X—Input variable (angle in radians)F—Computed function valueD—Computed derivative value
ReturnsA result object with fields:
returnValue: true if calculation was successful, false otherwiseF: updated value from the call.D: updated value from the call.