Hide menu
Loading...
Searching...
No Matches
cadex.ModelData.IndexedTriangleSet Class Reference

Defines a polygonal shape consisting of triangles. More...

Inheritance diagram for cadex.ModelData.IndexedTriangleSet:
cadex.ModelData.MeshShape cadex.BaseObject

Public Member Functions

 IndexedTriangleSet (global::System.IntPtr cPtr, bool cMemoryOwn)
 
 IndexedTriangleSet (cadex.BaseObject.Initialized arg0)
 
bool AddTriangles (cadex.Collections.PointList theVertices, cadex.Collections.IntList theVertexIndices)
 The number of values ​​in theVertexIndices must be a multiple of three, since each triplet defines a triangle.
 
bool AddTriangles (cadex.Collections.PointList theVertices, cadex.Collections.IntList theVertexIndices, cadex.Collections.VectorList theNormals, cadex.Collections.IntList theNormalIndices)
 The number of values ​​in theVertexIndices and theNormalIndices must be the same and a multiple of three, since each triple defines a vertex and vertex normal of a triangle, respectively.
 
bool AddTriangles (cadex.Collections.PointList theVertices, cadex.Collections.IntList theVertexIndices, cadex.Collections.VectorList theNormals, cadex.Collections.IntList theNormalIndices, cadex.Collections.ColorList theColors, cadex.Collections.IntList theColorIndices)
 The number of values ​​in theVertexIndices, theNormalIndices and theColorIndices should be the same and a multiple of three, since each triple defines a vertex, vertex normal and vertex color of a triangle, respectively.
 
bool AddTriangles (cadex.ModelData.IndexedTriangleSet theTriangleSet)
 Adds triangles from theTriangleSet.
 
cadex.ModelData.IndexedTriangleSet WithColors (cadex.Collections.ColorList theColors, cadex.Collections.IntList theColorIndices)
 The size of theColorIndices must be equal to the size of theVertexIndices (NumberOfTriangles() * 3).
 
cadex.Geom.Point Vertex (int theIndex)
 theIndex must be in the range [0, NumberOfVertices()-1].
 
uint NumberOfVertices ()
 Returns a number of vertices.
 
bool HasNormals ()
 Returns true if the triangle set has explicitly defined normals.
 
cadex.Geom.Vector Normal (int theIndex)
 theIndex must be in the range [0, NumberOfNormals()-1].
 
uint NumberOfNormals ()
 Returns a number of normals.
 
bool HasColors ()
 Returns true if the triangle set has explicitly defined colors.
 
cadex.Materials.Color Color (int theIndex)
 theIndex must be in the range [0, NumberOfColors()-1].
 
uint NumberOfColors ()
 Returns a number of colors.
 
cadex.Geom.Point TriangleVertex (uint theTriangleIndex, uint theVertexSlot)
 theTriangleIndex must be in the range [0, NumberOfTriangles()-1].
 
int TriangleVertexIndex (uint theTriangleIndex, uint theVertexSlot)
 theTriangleIndex must be in the range [0, NumberOfTriangles()-1].
 
cadex.Geom.Vector TriangleVertexNormal (uint theTriangleIndex, uint theVertexSlot)
 theTriangleIndex must be in the range [0, NumberOfTriangles()-1].
 
int TriangleVertexNormalIndex (uint theTriangleIndex, uint theVertexSlot)
 theTriangleIndex must be in the range [0, NumberOfTriangles()-1].
 
cadex.Geom.Vector TriangleNormal (uint theTriangleIndex)
 theTriangleIndex must be in the range [0, NumberOfTriangles()-1].
 
cadex.Materials.Color TriangleVertexColor (uint theTriangleIndex, uint theVertexSlot)
 theTriangleIndex must be in the range [0, NumberOfTriangles()-1].
 
int TriangleVertexColorIndex (uint theTriangleIndex, uint theVertexSlot)
 theTriangleIndex must be in the range [0, NumberOfTriangles()-1].
 
uint NumberOfTriangles ()
 Returns a number of triangles.
 
- Public Member Functions inherited from cadex.ModelData.MeshShape
 MeshShape (global::System.IntPtr cPtr, bool cMemoryOwn)
 
- Public Member Functions inherited from cadex.BaseObject
 BaseObject (global::System.IntPtr cPtr, bool cMemoryOwn)
 
void Dispose ()
 
bool IsNull ()
 
ulong Id ()
 Return unique identifier of public object.
 
bool IsEqual (cadex.BaseObject theObj)
 
override int GetHashCode ()
 
override bool Equals (System.Object o)
 

Static Public Member Functions

static new bool CompareType (cadex.BaseObject theObject)
 
static cadex.ModelData.IndexedTriangleSet Cast (cadex.ModelData.MeshShape theBase)
 
- Static Public Member Functions inherited from cadex.ModelData.MeshShape
static bool CompareType (cadex.BaseObject theObject)
 Check the type of object. Returns true if the specified object is this class type.
 
static cadex.ModelData.MeshShape Cast (cadex.BaseObject theBase)
 

Protected Member Functions

override void Dispose (bool disposing)
 
- Protected Member Functions inherited from cadex.ModelData.MeshShape
override void Dispose (bool disposing)
 

Detailed Description

Defines a polygonal shape consisting of triangles.

Triangles are defined via array of unique vertices and triplets of indices in this array. This is to describe connectivity and to reduce data required to describe a triangle set.

The triangle set can optionally contain normals and/or colors which are defined per each vertex. Normals and colors also use indexing in the same manner as vertices.

A triangle set can be constructed using AddTriangles(), supplying unique vertices and indices describing triangles, for instance:

//vertices
IndexedTriangleSet::VertexVecType aVertices = {
{ 0., 0., 0. },
{ 1., 0., 0. },
{ 1., 1., 0. },
{ 0., 1., 1. }
};
//triangles (vertex indices)
IndexedTriangleSet::IndexVecType aVertexIndices = {
0, 1, 2,
0, 2, 3
};
//normals
IndexedTriangleSet::NormalVecType aNormals = {
{ 0., 0., 1. }, //to triangle #0: {0, 1, 2}
{ 1., -1., 1. }, //to triangle #1: {0, 2, 3}
};
//normal indices
IndexedTriangleSet::IndexVecType aNormalIndices = {
0, 0, 0,
1, 1, 1
};
ModelData::IndexedTriangleSet aTriangleSet;
aTriangleSet.AddTriangles (aVertices, aVertexIndices, aNormals, aNormalIndices);

The user must ensure data consistency so that the number of added normals and/or colors is equal to number of added vertices. Otherwise, triangles won't be added.

Data can be queried using the rank number of triangle and a vertex slot (0 to 2), for instance:

size_t n = aTriangleSet.NumberOfTriangles();
for (size_t i = 0; i < n; ++i) {
cout << "Triangle " << i << ":" << endl;
for (int j = 0; j < 3; ++j) {
const auto& aVertex = aTriangleSet.TriangleVertex (i, j);
if (aTriangleSet.HasNormals()) {
const auto& aNormal = aTriangleSet.TriangleVertexNormal (i, j);
}
if (aTriangleSet.HasColors()) {
const auto& aColor = aTriangleSet.TriangleVertexColor (i, j);
}
}
}

Coordinate and normal indices into respective arrays of unique values can be queried using TriangleVertexIndex() and TriangleVertexNormalIndex() respectively.

Examples
MTKConverter/Program.cs, MTKConverter/main.cxx, exploring/mesh/Program.cs, exploring/mesh/main.cxx, helpers/shape_processor.cs, helpers/shape_processor.hxx, machining/dfm_analyzer/Program.cs, machining/dfm_analyzer/main.cxx, machining/feature_recognizer/Program.cs, machining/feature_recognizer/main.cxx, meshing/mesh_generation/Program.cs, meshing/mesh_generation/main.cxx, molding/dfm_analyzer/Program.cs, molding/dfm_analyzer/main.cxx, molding/feature_recognizer/Program.cs, molding/feature_recognizer/main.cxx, sheet_metal/dfm_analyzer/Program.cs, sheet_metal/dfm_analyzer/main.cxx, sheet_metal/feature_recognizer/Program.cs, and sheet_metal/feature_recognizer/main.cxx.

Member Function Documentation

◆ AddTriangles() [1/4]

bool cadex.ModelData.IndexedTriangleSet.AddTriangles ( cadex.Collections.PointList theVertices,
cadex.Collections.IntList theVertexIndices )
inline

The number of values ​​in theVertexIndices must be a multiple of three, since each triplet defines a triangle.

Returns true if the triangles were successfully added and false otherwise. Adds triangles.

◆ AddTriangles() [2/4]

bool cadex.ModelData.IndexedTriangleSet.AddTriangles ( cadex.Collections.PointList theVertices,
cadex.Collections.IntList theVertexIndices,
cadex.Collections.VectorList theNormals,
cadex.Collections.IntList theNormalIndices )
inline

The number of values ​​in theVertexIndices and theNormalIndices must be the same and a multiple of three, since each triple defines a vertex and vertex normal of a triangle, respectively.

Returns true if the triangles were successfully added and false otherwise. Adds triangles.

◆ AddTriangles() [3/4]

bool cadex.ModelData.IndexedTriangleSet.AddTriangles ( cadex.Collections.PointList theVertices,
cadex.Collections.IntList theVertexIndices,
cadex.Collections.VectorList theNormals,
cadex.Collections.IntList theNormalIndices,
cadex.Collections.ColorList theColors,
cadex.Collections.IntList theColorIndices )
inline

The number of values ​​in theVertexIndices, theNormalIndices and theColorIndices should be the same and a multiple of three, since each triple defines a vertex, vertex normal and vertex color of a triangle, respectively.

However, if there is no need to add normals, then theNormals and theNormalIndices can be empty.

Returns true if the triangles were successfully added and false otherwise. Adds triangles.

◆ AddTriangles() [4/4]

bool cadex.ModelData.IndexedTriangleSet.AddTriangles ( cadex.ModelData.IndexedTriangleSet theTriangleSet)
inline

Adds triangles from theTriangleSet.

◆ Color()

cadex.Materials.Color cadex.ModelData.IndexedTriangleSet.Color ( int theIndex)
inline

theIndex must be in the range [0, NumberOfColors()-1].

Otherwise the result is undefined. Returns a color.

◆ Dispose()

override void cadex.ModelData.IndexedTriangleSet.Dispose ( bool disposing)
inlineprotectedvirtual

Reimplemented from cadex.BaseObject.

◆ HasColors()

bool cadex.ModelData.IndexedTriangleSet.HasColors ( )
inline

Returns true if the triangle set has explicitly defined colors.

See also
NumberOfColors().

◆ HasNormals()

bool cadex.ModelData.IndexedTriangleSet.HasNormals ( )
inline

Returns true if the triangle set has explicitly defined normals.

See also
NumberOfNormals().
Examples
exploring/mesh/Program.cs, and exploring/mesh/main.cxx.

◆ Normal()

cadex.Geom.Vector cadex.ModelData.IndexedTriangleSet.Normal ( int theIndex)
inline

theIndex must be in the range [0, NumberOfNormals()-1].

Otherwise the result is undefined. Returns a normal.

◆ NumberOfColors()

uint cadex.ModelData.IndexedTriangleSet.NumberOfColors ( )
inline

Returns a number of colors.

◆ NumberOfNormals()

uint cadex.ModelData.IndexedTriangleSet.NumberOfNormals ( )
inline

Returns a number of normals.

◆ NumberOfTriangles()

uint cadex.ModelData.IndexedTriangleSet.NumberOfTriangles ( )
inline

◆ NumberOfVertices()

uint cadex.ModelData.IndexedTriangleSet.NumberOfVertices ( )
inline

Returns a number of vertices.

◆ TriangleNormal()

cadex.Geom.Vector cadex.ModelData.IndexedTriangleSet.TriangleNormal ( uint theTriangleIndex)
inline

theTriangleIndex must be in the range [0, NumberOfTriangles()-1].

Otherwise the result is undefined.

The normal is calculated on the fly based on the vertices of the triangle.

In case of a degenerate triangle the zero vector will be returned. Returns a normal of a triangle.

◆ TriangleVertex()

cadex.Geom.Point cadex.ModelData.IndexedTriangleSet.TriangleVertex ( uint theTriangleIndex,
uint theVertexSlot )
inline

theTriangleIndex must be in the range [0, NumberOfTriangles()-1].

Otherwise the result is undefined. theVertexSlot must be in the range [0, 2]. Otherwise the result is undefined.

See also
TriangleVertexIndex(). Returns a vertex of a triangle.
Examples
exploring/mesh/Program.cs, exploring/mesh/main.cxx, meshing/mesh_generation/Program.cs, and meshing/mesh_generation/main.cxx.

◆ TriangleVertexColor()

cadex.Materials.Color cadex.ModelData.IndexedTriangleSet.TriangleVertexColor ( uint theTriangleIndex,
uint theVertexSlot )
inline

theTriangleIndex must be in the range [0, NumberOfTriangles()-1].

Otherwise the result is undefined. theVertexSlot must be in the range [0, 2]. Otherwise the result is undefined.

See also
TriangleVertexColorIndex(). Returns a color at vertex in a triangle.

◆ TriangleVertexColorIndex()

int cadex.ModelData.IndexedTriangleSet.TriangleVertexColorIndex ( uint theTriangleIndex,
uint theVertexSlot )
inline

theTriangleIndex must be in the range [0, NumberOfTriangles()-1].

theVertexSlot must be in the range [0, 2].

If the color index was not found -1 will be returned.

See also
TriangleVertexColor(). Returns a color index for vertex in a triangle.

◆ TriangleVertexIndex()

int cadex.ModelData.IndexedTriangleSet.TriangleVertexIndex ( uint theTriangleIndex,
uint theVertexSlot )
inline

theTriangleIndex must be in the range [0, NumberOfTriangles()-1].

theVertexSlot must be in the range [0, 2].

If the vertex index was not found -1 will be returned.

See also
TriangleVertex(). Returns a vertex index in a triangle.
Examples
exploring/mesh/Program.cs, exploring/mesh/main.cxx, meshing/mesh_generation/Program.cs, and meshing/mesh_generation/main.cxx.

◆ TriangleVertexNormal()

cadex.Geom.Vector cadex.ModelData.IndexedTriangleSet.TriangleVertexNormal ( uint theTriangleIndex,
uint theVertexSlot )
inline

theTriangleIndex must be in the range [0, NumberOfTriangles()-1].

Otherwise the result is undefined. theVertexSlot must be in the range [0, 2]. Otherwise the result is undefined.

See also
TriangleVertexNormalIndex(). Returns a normal at vertex in a triangle.
Examples
exploring/mesh/Program.cs, and exploring/mesh/main.cxx.

◆ TriangleVertexNormalIndex()

int cadex.ModelData.IndexedTriangleSet.TriangleVertexNormalIndex ( uint theTriangleIndex,
uint theVertexSlot )
inline

theTriangleIndex must be in the range [0, NumberOfTriangles()-1].

theVertexSlot must be in the range [0, 2].

If the normal index was not found -1 will be returned.

See also
TriangleVertexNormal(). Returns a normal index for vertex in a triangle.

◆ Vertex()

cadex.Geom.Point cadex.ModelData.IndexedTriangleSet.Vertex ( int theIndex)
inline

theIndex must be in the range [0, NumberOfVertices()-1].

Otherwise the result is undefined. Returns a vertex.

◆ WithColors()

cadex.ModelData.IndexedTriangleSet cadex.ModelData.IndexedTriangleSet.WithColors ( cadex.Collections.ColorList theColors,
cadex.Collections.IntList theColorIndices )
inline

The size of theColorIndices must be equal to the size of theVertexIndices (NumberOfTriangles() * 3).

Otherwise an empty IndexedTriangleSet will be returned. Returns a new IndexedTriangleSet. Vertices and Normals copies from the caller.