Skip to content

Mesh Module

Triangulation and polygon mesh handling.

LightOcct::LPolygon2d

Light OCCT wrapper for OCCT Poly_Polygon2D class.

Provides a polygon in 2D space (parametric space), typically as an approximate representation of a curve. A Polygon2D is defined by a table of 2D nodes (points). If the polygon is closed, the point of closure is repeated at the end of the table. Follows Light OCCT architecture: Enum + Handle pattern for type-safe OCCT object storage POD structures for cross-language data exchange Wrapper methods hide OCCT implementation details No OCCT types exposed in public interface

cpp
#include <light-occt/mesh/LPolygon2d.hxx>

Quick Reference

Fields: myType

Factory Methods: CreateEmpty(), CreateFromNodes()

Methods: LPolygon2d(), LPolygon2d(), operator=(), ~LPolygon2d(), GetType(), IsValid(), GetNbNodes(), GetDeflection(), SetDeflection(), GetNode(), SetNode(), GetAllNodes(), SetAllNodes(), Copy(), GetPolygonData(), SetPolygonData()

Enums: PolygonType

Types: TypeEnum


Fields

myType

cpp
PolygonType myType;

Polygon type.

Methods

Factory Methods

CreateEmpty

Create empty polygon with specified capacity.

cpp
static LPolygon2d CreateEmpty(int nbNodes);

nbNodes Number of nodes to allocate New polygon instance

Parameters:

  • nbNodes - Number of nodes to allocate New polygon instance
CreateFromNodes

Create polygon from node array.

cpp
static LPolygon2d CreateFromNodes(const std::vector<  > & Point2d nodes);

nodes Array of 2D node positions New polygon instance

Parameters:

  • nodes - Array of 2D node positions New polygon instance

Instance Methods

LPolygon2d

Default constructor - creates undefined polygon.

cpp
 LPolygon2d() const;
LPolygon2d

Copy constructor.

cpp
 LPolygon2d(const  & LPolygon2d other) const;

other Polygon to copy from

Parameters:

  • other - Polygon to copy from
operator=

Assignment operator.

cpp
& LPolygon2d operator=(const  & LPolygon2d other) const;

other Polygon to copy from Reference to this polygon

Parameters:

  • other - Polygon to copy from Reference to this polygon
~LPolygon2d

Destructor.

cpp
 ~LPolygon2d() const;
GetType

Get polygon type.

cpp
PolygonType GetType() const;

Polygon type enumeration

IsValid

Check if polygon is valid (not undefined).

cpp
bool IsValid() const;

True if polygon is valid

GetNbNodes

Get number of nodes in polygon.

cpp
int GetNbNodes() const;

Number of nodes

GetDeflection

Get deflection value.

cpp
double GetDeflection() const;

Maximum deflection from original curve

SetDeflection

Set deflection value.

cpp
void SetDeflection(double deflection) const;

deflection Maximum deflection from original curve

Parameters:

  • deflection - Maximum deflection from original curve
GetNode

Get 2D node position.

cpp
Point2d GetNode(int index) const;

index Node index (1-based) 2D point coordinates

Parameters:

  • index - Node index (1-based) 2D point coordinates
SetNode

Set 2D node position.

cpp
void SetNode(int index, const  & Point2d point) const;

index Node index (1-based) point 2D point coordinates

Parameters:

  • index - Node index (1-based) point 2D point coordinates
  • point - 2D point coordinates
GetAllNodes

Get all node positions efficiently.

cpp
std::vector<  > Point2d GetAllNodes() const;

of all 2D node positions Vector

SetAllNodes

Set all node positions efficiently.

cpp
void SetAllNodes(const std::vector<  > & Point2d nodes) const;

nodes of 2D node positions Vector

Parameters:

  • nodes - of 2D node positions Vector
Copy

Create copy of this polygon.

cpp
LPolygon2d Copy() const;

New polygon instance

GetPolygonData

Get complete polygon data as POD structure.

cpp
Polygon2DData GetPolygonData() const;

Structure with all polygon data

SetPolygonData

Set polygon data from POD structure.

cpp
void SetPolygonData(const  & Polygon2DData data) const;

data Structure with polygon data

Parameters:

  • data - Structure with polygon data

Enumerations

PolygonType

Polygon type enumeration.

cpp
enum PolygonType {
    POLYGON2D_STANDARD, // Standard polygon with Handle(Poly_Polygon2D)
    POLYGON2D_UNDEFINED, // Invalid/undefined polygon.
};

Type Definitions

TypeEnum

cpp
PolygonType TypeEnum;

LightOcct::LPolygon3d

Light OCCT wrapper for OCCT Poly_Polygon3D class.

Provides a polygon in 3D space, typically as an approximate representation of a curve. A Polygon3D is defined by a table of 3D nodes (points) and optional curve parameters. If the polygon is closed, the point of closure is repeated at the end of the table. Follows Light OCCT architecture: Enum + Handle pattern for type-safe OCCT object storage POD structures for cross-language data exchange Wrapper methods hide OCCT implementation details No OCCT types exposed in public interface

cpp
#include <light-occt/mesh/LPolygon3d.hxx>

Quick Reference

Fields: myType

Factory Methods: CreateEmpty(), CreateFromNodes(), CreateWithParameters()

Methods: LPolygon3d(), LPolygon3d(), operator=(), ~LPolygon3d(), GetType(), IsValid(), GetNbNodes(), HasParameters(), GetDeflection(), SetDeflection(), GetNode(), SetNode(), GetParameter(), SetParameter(), GetAllNodes(), GetAllParameters(), SetAllNodes(), SetAllParameters(), Copy(), GetPolygonData(), SetPolygonData()

Enums: PolygonType

Types: TypeEnum


Fields

myType

cpp
PolygonType myType;

Polygon type.

Methods

Factory Methods

CreateEmpty

Create empty polygon with specified capacity.

cpp
static LPolygon3d CreateEmpty(int nbNodes, bool hasParameters);

nbNodes Number of nodes to allocate hasParameters Whether to allocate parameter storage New polygon instance

Parameters:

  • nbNodes - Number of nodes to allocate hasParameters Whether to allocate parameter storage New polygon instance
  • hasParameters - Whether to allocate parameter storage New polygon instance
CreateFromNodes

Create polygon from node array.

cpp
static LPolygon3d CreateFromNodes(const std::vector<  > & Point nodes);

nodes Array of 3D node positions New polygon instance

Parameters:

  • nodes - Array of 3D node positions New polygon instance
CreateWithParameters

Create polygon from nodes and parameters.

cpp
static LPolygon3d CreateWithParameters(const std::vector<  > & Point nodes, const std::vector< double > & parameters);

nodes Array of 3D node positions parameters Array of curve parameters for each node New polygon instance

Parameters:

  • nodes - Array of 3D node positions parameters Array of curve parameters for each node New polygon instance
  • parameters - Array of curve parameters for each node New polygon instance

Instance Methods

LPolygon3d

Default constructor - creates undefined polygon.

cpp
 LPolygon3d() const;
LPolygon3d

Copy constructor.

cpp
 LPolygon3d(const  & LPolygon3d other) const;

other Polygon to copy from

Parameters:

  • other - Polygon to copy from
operator=

Assignment operator.

cpp
& LPolygon3d operator=(const  & LPolygon3d other) const;

other Polygon to copy from Reference to this polygon

Parameters:

  • other - Polygon to copy from Reference to this polygon
~LPolygon3d

Destructor.

cpp
 ~LPolygon3d() const;
GetType

Get polygon type.

cpp
PolygonType GetType() const;

Polygon type enumeration

IsValid

Check if polygon is valid (not undefined).

cpp
bool IsValid() const;

True if polygon is valid

GetNbNodes

Get number of nodes in polygon.

cpp
int GetNbNodes() const;

Number of nodes

HasParameters

Check if polygon has curve parameters.

cpp
bool HasParameters() const;

True if parameters are available

GetDeflection

Get deflection value.

cpp
double GetDeflection() const;

Maximum deflection from original curve

SetDeflection

Set deflection value.

cpp
void SetDeflection(double deflection) const;

deflection Maximum deflection from original curve

Parameters:

  • deflection - Maximum deflection from original curve
GetNode

Get 3D node position.

cpp
Point GetNode(int index) const;

index Node index (1-based) 3D point coordinates

Parameters:

  • index - Node index (1-based) 3D point coordinates
SetNode

Set 3D node position.

cpp
void SetNode(int index, const  & Point point) const;

index Node index (1-based) point 3D point coordinates

Parameters:

  • index - Node index (1-based) point 3D point coordinates
  • point - 3D point coordinates
GetParameter

Get curve parameter at node.

cpp
double GetParameter(int index) const;

index Node index (1-based) Curve parameter value

Parameters:

  • index - Node index (1-based) Curve parameter value
SetParameter

Set curve parameter at node.

cpp
void SetParameter(int index, double parameter) const;

index Node index (1-based) parameter Curve parameter value

Parameters:

  • index - Node index (1-based) parameter Curve parameter value
  • parameter - Curve parameter value
GetAllNodes

Get all node positions efficiently.

cpp
std::vector<  > Point GetAllNodes() const;

of all 3D node positions Vector

GetAllParameters

Get all curve parameters efficiently.

cpp
std::vector< double > GetAllParameters() const;

of all curve parameters (empty if no parameters) Vector

SetAllNodes

Set all node positions efficiently.

cpp
void SetAllNodes(const std::vector<  > & Point nodes) const;

nodes of 3D node positions Vector

Parameters:

  • nodes - of 3D node positions Vector
SetAllParameters

Set all curve parameters efficiently.

cpp
void SetAllParameters(const std::vector< double > & parameters) const;

parameters of curve parameters Vector

Parameters:

  • parameters - of curve parameters Vector
Copy

Create copy of this polygon.

cpp
LPolygon3d Copy() const;

New polygon instance

GetPolygonData

Get complete polygon data as POD structure.

cpp
Polygon3DData GetPolygonData() const;

Structure with all polygon data

SetPolygonData

Set polygon data from POD structure.

cpp
void SetPolygonData(const  & Polygon3DData data) const;

data Structure with polygon data

Parameters:

  • data - Structure with polygon data

Enumerations

PolygonType

Polygon type enumeration.

cpp
enum PolygonType {
    POLYGON_STANDARD, // Standard polygon with Handle(Poly_Polygon3D)
    POLYGON_UNDEFINED, // Invalid/undefined polygon.
};

Type Definitions

TypeEnum

cpp
PolygonType TypeEnum;

LightOcct::LTriangulation

Light OCCT wrapper for OCCT Poly_Triangulation class.

Provides a triangulation for surfaces or shapes using the enum + Handle pattern. A triangulation consists of: A table of 3D nodes (points on the surface) A table of triangles (each triangle has three node indices) Optional 2D nodes (UV parameters on the surface) Optional surface normals at nodes Deflection value (maximum distance from surface to triangulation) Follows Light OCCT architecture: Enum + Handle pattern for type-safe OCCT object storage POD structures for cross-language data exchange Wrapper methods hide OCCT implementation details No OCCT types exposed in public interface

cpp
#include <light-occt/mesh/LTriangulation.hxx>

Quick Reference

Fields: myType

Factory Methods: CreateEmpty(), CreateFromArrays(), CreateWithUV()

Methods: LTriangulation(), LTriangulation(), operator=(), ~LTriangulation(), GetType(), IsValid(), GetNbNodes(), GetNbTriangles(), HasUVNodes(), HasNormals(), GetDeflection(), SetDeflection(), GetNode(), SetNode(), GetUVNode(), SetUVNode(), GetNormal(), SetNormal(), GetTriangle(), SetTriangle(), GetAllNodes(), GetAllTriangles(), SetAllNodes(), SetAllTriangles(), AddUVNodes(), RemoveUVNodes(), AddNormals(), RemoveNormals(), ComputeNormals(), Clear(), GetBoundingBox(), Copy(), GetTriangulationData(), GetNodeData()

Enums: TriangulationType

Types: TypeEnum


Fields

myType

cpp
TriangulationType myType;

Triangulation type.

Methods

Factory Methods

CreateEmpty

Create empty triangulation with specified capacity.

cpp
static LTriangulation CreateEmpty(int nbNodes, int nbTriangles, bool hasUVNodes, bool hasNormals);

nbNodes Number of nodes to allocate nbTriangles Number of triangles to allocate hasUVNodes Whether to allocate UV node storage hasNormals Whether to allocate normal storage New triangulation instance

Parameters:

  • nbNodes - Number of nodes to allocate nbTriangles Number of triangles to allocate hasUVNodes Whether to allocate UV node storage hasNormals Whether to allocate normal storage New triangulation instance
  • nbTriangles - Number of triangles to allocate hasUVNodes Whether to allocate UV node storage hasNormals Whether to allocate normal storage New triangulation instance
  • hasUVNodes - Whether to allocate UV node storage hasNormals Whether to allocate normal storage New triangulation instance
  • hasNormals - Whether to allocate normal storage New triangulation instance
CreateFromArrays

Create triangulation from node and triangle arrays.

cpp
static LTriangulation CreateFromArrays(const std::vector<  > & Point nodes, const std::vector<  > & TriangleData triangles);

nodes Array of 3D node positions triangles Array of triangle data (node indices) New triangulation instance

Parameters:

  • nodes - Array of 3D node positions triangles Array of triangle data (node indices) New triangulation instance
  • triangles - Array of triangle data (node indices) New triangulation instance
CreateWithUV

Create triangulation with UV nodes.

cpp
static LTriangulation CreateWithUV(const std::vector<  > & Point nodes, const std::vector<  > & Point2d uvNodes, const std::vector<  > & TriangleData triangles);

nodes Array of 3D node positions uvNodes Array of 2D UV positions triangles Array of triangle data (node indices) New triangulation instance

Parameters:

  • nodes - Array of 3D node positions uvNodes Array of 2D UV positions triangles Array of triangle data (node indices) New triangulation instance
  • uvNodes - Array of 2D UV positions triangles Array of triangle data (node indices) New triangulation instance
  • triangles - Array of triangle data (node indices) New triangulation instance

Instance Methods

LTriangulation

Default constructor - creates undefined triangulation.

cpp
 LTriangulation() const;
LTriangulation

Copy constructor.

cpp
 LTriangulation(const  & LTriangulation other) const;

other Triangulation to copy from

Parameters:

  • other - Triangulation to copy from
operator=

Assignment operator.

cpp
& LTriangulation operator=(const  & LTriangulation other) const;

other Triangulation to copy from Reference to this triangulation

Parameters:

  • other - Triangulation to copy from Reference to this triangulation
~LTriangulation

Destructor.

cpp
 ~LTriangulation() const;
GetType

Get triangulation type.

cpp
TriangulationType GetType() const;

Triangulation type enumeration

IsValid

Check if triangulation is valid (not undefined).

cpp
bool IsValid() const;

True if triangulation is valid

GetNbNodes

Get number of nodes in triangulation.

cpp
int GetNbNodes() const;

Number of nodes

GetNbTriangles

Get number of triangles in triangulation.

cpp
int GetNbTriangles() const;

Number of triangles

HasUVNodes

Check if triangulation has UV nodes.

cpp
bool HasUVNodes() const;

True if UV nodes are available

HasNormals

Check if triangulation has surface normals.

cpp
bool HasNormals() const;

True if normals are available

GetDeflection

Get deflection value.

cpp
double GetDeflection() const;

Maximum deflection from surface

SetDeflection

Set deflection value.

cpp
void SetDeflection(double deflection) const;

deflection Maximum deflection from surface

Parameters:

  • deflection - Maximum deflection from surface
GetNode

Get 3D node position.

cpp
Point GetNode(int index) const;

index Node index (1-based) 3D point coordinates

Parameters:

  • index - Node index (1-based) 3D point coordinates
SetNode

Set 3D node position.

cpp
void SetNode(int index, const  & Point point) const;

index Node index (1-based) point 3D point coordinates

Parameters:

  • index - Node index (1-based) point 3D point coordinates
  • point - 3D point coordinates
GetUVNode

Get UV node position.

cpp
Point2d GetUVNode(int index) const;

index Node index (1-based) 2D UV coordinates

Parameters:

  • index - Node index (1-based) 2D UV coordinates
SetUVNode

Set UV node position.

cpp
void SetUVNode(int index, const  & Point2d point) const;

index Node index (1-based) point 2D UV coordinates

Parameters:

  • index - Node index (1-based) point 2D UV coordinates
  • point - 2D UV coordinates
GetNormal

Get surface normal at node.

cpp
Vector GetNormal(int index) const;

index Node index (1-based) Surface normal vector

Parameters:

  • index - Node index (1-based) Surface normal vector
SetNormal

Set surface normal at node.

cpp
void SetNormal(int index, const  & Vector normal) const;

index Node index (1-based) normal Surface normal vector (should be normalized)

Parameters:

  • index - Node index (1-based) normal Surface normal vector (should be normalized)
  • normal - Surface normal vector (should be normalized)
GetTriangle

Get triangle data.

cpp
TriangleData GetTriangle(int index) const;

index Triangle index (1-based) Triangle with three node indices

Parameters:

  • index - Triangle index (1-based) Triangle with three node indices
SetTriangle

Set triangle data.

cpp
void SetTriangle(int index, const  & TriangleData triangle) const;

index Triangle index (1-based) triangle Triangle with three node indices

Parameters:

  • index - Triangle index (1-based) triangle Triangle with three node indices
  • triangle - index (1-based) triangle Triangle with three node indices
GetAllNodes

Get all node data efficiently.

cpp
TriangulationNodesData GetAllNodes() const;

Structure with all node arrays

GetAllTriangles

Get all triangle data efficiently.

cpp
TriangulationTrianglesData GetAllTriangles() const;

Structure with all triangle data

SetAllNodes

Set all node data efficiently.

cpp
void SetAllNodes(const  & TriangulationNodesData nodesData) const;

nodesData Structure with all node arrays

Parameters:

  • nodesData - Structure with all node arrays
SetAllTriangles

Set all triangle data efficiently.

cpp
void SetAllTriangles(const  & TriangulationTrianglesData trianglesData) const;

trianglesData Structure with all triangle data

Parameters:

  • trianglesData - Structure with all triangle data
AddUVNodes

Add UV node storage if not already present.

cpp
void AddUVNodes() const;
RemoveUVNodes

Remove UV node storage.

cpp
void RemoveUVNodes() const;
AddNormals

Add normal storage if not already present.

cpp
void AddNormals() const;
RemoveNormals

Remove normal storage.

cpp
void RemoveNormals() const;
ComputeNormals

Compute smooth normals by averaging triangle normals.

cpp
void ComputeNormals() const;
Clear

Clear all mesh data.

cpp
void Clear() const;
GetBoundingBox

Get bounding box of triangulation.

cpp
BoundingBox GetBoundingBox() const;

Axis-aligned bounding box

Copy

Create copy of this triangulation.

cpp
LTriangulation Copy() const;

New triangulation instance

GetTriangulationData

Get triangulation metadata.

cpp
TriangulationData GetTriangulationData() const;

Structure with triangulation properties

GetNodeData

Get specific node data.

cpp
MeshNodeData GetNodeData(int index) const;

index Node index (1-based) Node data with position, UV, and normal

Parameters:

  • index - Node index (1-based) Node data with position, UV, and normal

Enumerations

TriangulationType

Triangulation type enumeration.

cpp
enum TriangulationType {
    TRIANGULATION_STANDARD, // Standard triangulation with Handle(Poly_Triangulation)
    TRIANGULATION_UNDEFINED, // Invalid/undefined triangulation.
};

Type Definitions

TypeEnum

cpp
TriangulationType TypeEnum;

Released under the LGPL-2.1 License