Defines a polygonal shape consisting of triangles. More...
#include <cadex/ModelData_IndexedTriangleSet.hxx>
Public Types | |
typedef ModelData_Vectorf | NormalType |
Defines a type of the normal vector. | |
typedef ModelData_Point2d | UVCoordinateType |
Defines a type of the UV coordinate. | |
![]() | |
typedef int | IndexType |
Type of indices. | |
typedef cadex::internal::cadex_vector< IndexType >::type | IndexVecType |
typedef ModelData_Point | CoordType |
typedef ModelData_Color | ColorType |
![]() | |
typedef int | IdType |
Defines a type identifier. | |
Public Member Functions | |
ModelData_IndexedTriangleSet () | |
Constructor. | |
ModelData_IndexedTriangleSet (initialized) | |
Constructor. | |
ModelData_IndexedTriangleSet (internal::ModelData_IndexedTriangleSetImpl *theImpl) | |
Constructor (reserved for internal use). | |
IndexType | NumberOfFaces () const |
Returns a number of faces (triangles). | |
IndexType | NumberOfNormals () const |
Returns a number of (unique) normals. | |
IndexType | NumberOfUVCoordinates () const |
Returns a number of UV coordinates. | |
const CoordType & | Coordinate (IndexType theFace, IndexType theVertexSlot) const |
Returns a vertex coordinate. | |
IndexType | CoordinateIndex (IndexType theFace, IndexType theVertexSlot) const |
Returns a coordinate index for a vertex in a face. | |
NormalType | FaceNormal (IndexType theFace) const |
Returns a normal of a face. | |
bool | HasNormals () const |
Returns true if the triangle set has explicitly defined normals. | |
const NormalType & | VertexNormal (IndexType theFace, IndexType theVertexSlot) const |
Returns a normal at a vertex in a face. | |
const NormalType & | Normal (IndexType theIndex) const |
Returns a normal per its index. | |
IndexType | NormalIndex (IndexType theFace, IndexType theVertexSlot) const |
Returns a normal index for a vertex in a face. | |
const ColorType & | VertexColor (IndexType theFace, IndexType theVertexSlot) const |
Returns a color at a vertex in a face. | |
IndexType | ColorIndex (IndexType theFace, IndexType theVertexSlot) const |
Returns a color index for a vertex in a face. | |
bool | HasUVCoordinates () const |
Returns true if the triangle set has UV coordinates associated with vertices. | |
const ModelData_Point2d & | UVCoordinate (IndexType theFace, IndexType theVertexSlot) const |
Returns a UV coordinate associated with a vertex. | |
const ModelData_Point2d & | UVCoordinate (IndexType theIndex) const |
//! Returns a UV coordinate per its index. | |
IndexType | UVCoordinateIndex (IndexType theFace, IndexType theVertexSlot) const |
Returns a UV coordinate index for a vertex in a face. | |
void | AddCoordinates (const CoordType theVertices[], size_t theVertexNb) |
Adds vertex coordinates. | |
void | AddCoordinates (const CoordType theVertices[], size_t theVertexNb, const IndexType theIndices[], size_t theIndexNb) |
Adds vertex coordinates and triangles. | |
void | AddCoordinates (const CoordType theVertices[], size_t theVertexNb, const IndexType theIndices[], const IndexType theCounts[], size_t theCountNb) |
Adds vertex coordinates and their indices. | |
void | AddNormals (const NormalType theNormals[], size_t theNormalNb, const IndexType theIndices[], size_t theIndexNb) |
Adds vertex normals. | |
void | AddNormals (const NormalType theNormals[], size_t theNormalNb, const IndexType theIndices[], const IndexType theCounts[], size_t theCountNb) |
Adds vertex normals. | |
void | AddColors (const ColorType theColors[], size_t theColorNb, const IndexType theIndices[], size_t theIndexNb) |
Adds vertex colors. | |
void | AddColors (const ColorType theColors[], size_t theColorNb, const IndexType theIndices[], const IndexType theCounts[], size_t theCountNb) |
Adds vertex colors. | |
void | AddUVCoordinates (const UVCoordinateType theUVCoordinates[], size_t theUVCoordinateNb, const IndexType theIndices[], size_t theIndexNb) |
Adds UV coordinates. | |
void | AddUVCoordinates (const UVCoordinateType theUVCoordinates[], size_t theUVCoordinateNb, const IndexType theIndices[], const IndexType theCounts[], size_t theCountNb) |
Adds UV coordinates. | |
void | Merge () |
const CoordType & | Coordinate (IndexType theVertexIndex) const |
Returns a vertex coordinate. | |
![]() | |
void | SetAppearance (const ModelData_Appearance &theAppearance) |
ModelData_Appearance | Appearance () const |
const CoordType & | Coordinate (IndexType theVertexIndex) const |
Returns a vertex coordinate. | |
bool | HasColors () const |
const ColorType & | Color (IndexType theIndex) const |
IndexType | NumberOfVertices () const |
IndexType | NumberOfColors () const |
Returns a number of unique colors. | |
bool | IsEmpty () const |
![]() | |
ModelData_PolyShape () | |
Constructor. | |
![]() | |
ModelData_BaseObject () | |
Constructor. | |
IdType | TypeId () const |
Returns an object type id. | |
template<typename T > | |
bool | IsOfType () const |
Returns true if the object has a type T. | |
void | SetName (const Base_UTF16String &theName) |
Sets an object name. | |
Base_UTF16String | Name () const |
void | SetUuid (const Base_Uuid &theUuid) |
Base_Uuid | Uuid () const |
void | Nullify () |
Resets reference to implementation object. | |
bool | IsNull () const |
Returns true if the object is nullified. | |
operator bool () const | |
Casts the object to the bool type. | |
internal::ModelData_BaseObjectImpl * | Impl () const |
Return a handle to backend (reserved for internal use). | |
Static Public Member Functions | |
static IdType | GetTypeId () |
Additional Inherited Members | |
![]() | |
ModelData_PolyVertexSet (internal::ModelData_BaseObjectImpl *theImpl) | |
Constructor (reserved for internal use). | |
![]() | |
ModelData_PolyShape (const internal::ModelData_BaseObjectImpl *theImpl) | |
Constructor (reserved for internal use). | |
![]() | |
ModelData_BaseObject (const internal::ModelData_BaseObjectImpl *theImpl) | |
Constructor (reserved for internal use). | |
ModelData_BaseObject (const internal::ModelData_BaseObjectImpl *theImpl, const Base_UTF16String &theName) | |
Constructor (reserved for internal use). | |
template<typename T > | |
T * | GetOrCreateImpl () |
Reserved for internal use. | |
Defines a polygonal shape consisting of triangles.
Triangles are defined via array of unique vertex coordinates 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 vertex coordinates. Colors are used very rarely, instead Appearance() attached to entire triangle set is used, as a rule.
A triangle set can be constructed at once or step-by-step using AddCoordinates(), supplying unique coordinates and indices describing triangles, for instance:
Normals and/or colors can be optionally added with the help of AddNormals() and AddColors():
The user must ensure data consistency so that the number of added normals and/or colors is equal to number of added coordinates. Otherwise, behavior is undefined.
Data can be queried using the rank number of triangle and a vertex slot (0 to 2), for instance:
Coordinate, normal and color indices into respective arrays of unique values can be queried using CoordinateIndex(), NormalIndex() and ColorIndex() respectively.
The triangle set can optionally contain UV coordinates of mesh vertices in parametric domain of original B-Rep surface. HasUVCoordinates() returns whether UV coordinates are available, UVCoordinate() returns coordinate of a specified vertex.
typedef ModelData_Vectorf cadex::ModelData_IndexedTriangleSet::NormalType |
Defines a type of the normal vector.
The vector can be not-normalized and even have a zero-length (in the case of incorrect input data or degenerated triangle).
cadex::ModelData_IndexedTriangleSet::ModelData_IndexedTriangleSet | ( | ) |
Constructor.
Creates a null triangle set. IsNull() will return true.
cadex::ModelData_IndexedTriangleSet::ModelData_IndexedTriangleSet | ( | initialized | ) |
Constructor.
Creates an initialized empty triangle set. IsNull() will return false.
void cadex::ModelData_IndexedTriangleSet::AddColors | ( | const ColorType | theColors[], |
size_t | theColorNb, | ||
const IndexType | theIndices[], | ||
const IndexType | theCounts[], | ||
size_t | theCountNb | ||
) |
Adds vertex colors.
Sets colors.
void cadex::ModelData_IndexedTriangleSet::AddCoordinates | ( | const CoordType | theVertices[], |
size_t | theVertexNb | ||
) |
Adds vertex coordinates.
theVertices must contain multiple of three vertices, where each triplet defines a triangle.
void cadex::ModelData_IndexedTriangleSet::AddCoordinates | ( | const CoordType | theVertices[], |
size_t | theVertexNb, | ||
const IndexType | theIndices[], | ||
size_t | theIndexNb | ||
) |
Adds vertex coordinates and triangles.
Defines a face set via vertex coordinates and their indices.
const ModelData_IndexedTriangleSet::CoordType & cadex::ModelData_IndexedTriangleSet::Coordinate | ( | IndexType | theFace, |
IndexType | theVertexSlot | ||
) | const |
Returns a vertex coordinate.
Returns Coordinate (CoordinateIndex (theFace, theVertexSlot));
bool cadex::ModelData_IndexedTriangleSet::HasNormals | ( | ) | const |
Returns true if the triangle set has explicitly defined normals.
bool cadex::ModelData_IndexedTriangleSet::HasUVCoordinates | ( | ) | const |
Returns true if the triangle set has UV coordinates associated with vertices.
const ModelData_Point2d & cadex::ModelData_IndexedTriangleSet::UVCoordinate | ( | IndexType | theFace, |
IndexType | theVertexSlot | ||
) | const |
Returns a UV coordinate associated with a vertex.
This method may only be used if HasUVCoordinates() returns true, otherwise behavior is undefined.
const ModelData_Point2d & cadex::ModelData_IndexedTriangleSet::UVCoordinate | ( | IndexType | theIndex | ) | const |
//! Returns a UV coordinate per its index.
This method may only be used if HasUVCoordinates() returns true, otherwise behavior is undefined.
ModelData_IndexedTriangleSet::IndexType cadex::ModelData_IndexedTriangleSet::UVCoordinateIndex | ( | IndexType | theFace, |
IndexType | theVertexSlot | ||
) | const |
Returns a UV coordinate index for a vertex in a face.
This method may only be used if HasUVCoordinates() returns true, otherwise behavior is undefined.
const ModelData_IndexedTriangleSet::NormalType & cadex::ModelData_IndexedTriangleSet::VertexNormal | ( | IndexType | theFace, |
IndexType | theVertexSlot | ||
) | const |
Returns a normal at a vertex in a face.
theFace must be a valid face index, from 0 to NumberOfFaces() - 1. theVertexSlot must be a vertex slot index, from 0 to NumberOfVertices(theFace) - 1. Returns Normal (NormalIndex (theFace, theVertexSlot));