Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions
CSLib_Class2d Class Reference

Low-level algorithm for 2D point-in-polygon classification. More...

#include <CSLib_Class2d.hxx>

Public Types

enum  Result { Result_Inside = 1 , Result_Outside = -1 , Result_Uncertain = 0 }
 Classification result for point-in-polygon tests. More...
 

Public Member Functions

 CSLib_Class2d ()=default
 Default constructor. Creates an empty classifier.
 
 CSLib_Class2d (const NCollection_Array1< gp_Pnt2d > &thePnts2d, double theTolU, double theTolV, double theUMin, double theVMin, double theUMax, double theVMax)
 Constructs a 2D classifier from an array of polygon vertices.
 
 CSLib_Class2d (const NCollection_Sequence< gp_Pnt2d > &thePnts2d, double theTolU, double theTolV, double theUMin, double theVMin, double theUMax, double theVMax)
 Constructs a 2D classifier from a sequence of polygon vertices.
 
 CSLib_Class2d (const NCollection_DynamicArray< gp_Pnt2d > &thePnts2d, double theTolU, double theTolV, double theUMin, double theVMin, double theUMax, double theVMax)
 Constructs a 2D classifier from a vector of polygon vertices.
 
 CSLib_Class2d (CSLib_Class2d &&theOther) noexcept
 Move constructor.
 
CSLib_Class2doperator= (CSLib_Class2d &&theOther) noexcept
 Move assignment operator.
 
Result SiDans (const gp_Pnt2d &thePoint) const
 Classifies a point relative to the polygon.
 
Result SiDans_OnMode (const gp_Pnt2d &thePoint, double theTol) const
 Classifies a point with explicit ON tolerance.
 

Detailed Description

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.

Note
This class was moved from package BRepTopAdaptor.

Member Enumeration Documentation

◆ Result

Classification result for point-in-polygon tests.

Enumerator
Result_Inside 

Point is strictly inside the polygon.

Result_Outside 

Point is strictly outside the polygon.

Result_Uncertain 

Point is on boundary or classification is uncertain.

Constructor & Destructor Documentation

◆ CSLib_Class2d() [1/5]

CSLib_Class2d::CSLib_Class2d ( )
default

Default constructor. Creates an empty classifier.

◆ CSLib_Class2d() [2/5]

CSLib_Class2d::CSLib_Class2d ( const NCollection_Array1< gp_Pnt2d > & thePnts2d,
double theTolU,
double theTolV,
double theUMin,
double theVMin,
double theUMax,
double theVMax )

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
[in]thePnts2dArray of polygon vertices (minimum 3 points required)
[in]theTolUTolerance in U direction for boundary detection
[in]theTolVTolerance in V direction for boundary detection
[in]theUMinMinimum U bound of the polygon domain
[in]theVMinMinimum V bound of the polygon domain
[in]theUMaxMaximum U bound of the polygon domain
[in]theVMaxMaximum V bound of the polygon domain

◆ CSLib_Class2d() [3/5]

CSLib_Class2d::CSLib_Class2d ( const NCollection_Sequence< gp_Pnt2d > & thePnts2d,
double theTolU,
double theTolV,
double theUMin,
double theVMin,
double theUMax,
double theVMax )

Constructs a 2D classifier from a sequence of polygon vertices.

Same as the array constructor but accepts a sequence for convenience.

Parameters
[in]thePnts2dSequence of polygon vertices (minimum 3 points required)
[in]theTolUTolerance in U direction for boundary detection
[in]theTolVTolerance in V direction for boundary detection
[in]theUMinMinimum U bound of the polygon domain
[in]theVMinMinimum V bound of the polygon domain
[in]theUMaxMaximum U bound of the polygon domain
[in]theVMaxMaximum V bound of the polygon domain

◆ CSLib_Class2d() [4/5]

CSLib_Class2d::CSLib_Class2d ( const NCollection_DynamicArray< gp_Pnt2d > & thePnts2d,
double theTolU,
double theTolV,
double theUMin,
double theVMin,
double theUMax,
double theVMax )

Constructs a 2D classifier from a vector of polygon vertices.

Same as the array constructor but accepts a vector for convenience.

Parameters
[in]thePnts2dVector of polygon vertices (minimum 3 points required)
[in]theTolUTolerance in U direction for boundary detection
[in]theTolVTolerance in V direction for boundary detection
[in]theUMinMinimum U bound of the polygon domain
[in]theVMinMinimum V bound of the polygon domain
[in]theUMaxMaximum U bound of the polygon domain
[in]theVMaxMaximum V bound of the polygon domain

◆ CSLib_Class2d() [5/5]

CSLib_Class2d::CSLib_Class2d ( CSLib_Class2d && theOther)
inlinenoexcept

Move constructor.

Member Function Documentation

◆ operator=()

CSLib_Class2d & CSLib_Class2d::operator= ( CSLib_Class2d && theOther)
inlinenoexcept

Move assignment operator.

◆ SiDans()

Result CSLib_Class2d::SiDans ( const gp_Pnt2d & thePoint) const

Classifies a point relative to the polygon.

Parameters
[in]thePointThe 2D point to classify
Returns
Classification result

◆ SiDans_OnMode()

Result CSLib_Class2d::SiDans_OnMode ( const gp_Pnt2d & thePoint,
double theTol ) const

Classifies a point with explicit ON tolerance.

Similar to SiDans() but uses the specified tolerance for boundary detection instead of the tolerances specified at construction.

Parameters
[in]thePointThe 2D point to classify
[in]theTolTolerance for boundary detection
Returns
Classification result

The documentation for this class was generated from the following file: