Visual Computing Library  devel
Loading...
Searching...
No Matches
vcl::MeshInfo Class Reference

A simple class that allows to store which elements and their components have been imported/loaded or are going to be exported/saved on a mesh file or some other data structure. More...

#include <vclib/space/complex/mesh_info.h>

Classes

struct  CustomComponent
 The CustomComponent struct is a simple structure that describes a custom component of an Element (or of the Mesh) More...
 

Public Types

enum  Component {
  POSITION , VREFS , NORMAL , COLOR ,
  QUALITY , TEXCOORD , WEDGE_TEXCOORDS , CUSTOM_COMPONENTS ,
  TEXTURES , NUM_COMPONENTS
}
 Enum used to describe the type of Components that each Element can have.
 
using DataType = PrimitiveType
 Enum used to describe the type of Data stored in a component.
 
enum  Element {
  VERTEX , FACE , EDGE , MESH ,
  NUM_ELEMENTS
}
 Enum used to describe the type of Elements that can be found in a file. More...
 
enum class  MeshType { TRIANGLE_MESH , QUAD_MESH , POLYGON_MESH , UNKNOWN }
 Enum used to describe the type of the Mesh - by default, the value is set to UNKNOWN.
 

Public Member Functions

void addPerEdgeCustomComponent (const std::string &name, DataType t)
 
void addPerElementCustomComponent (Element el, const std::string &name, DataType t)
 
void addPerFaceCustomComponent (const std::string &name, DataType t)
 
void addPerVertexCustomComponent (const std::string &name, DataType t)
 
void clear ()
 Clears the MeshInfo object.
 
void clearPerEdgeCustomComponents ()
 
void clearPerElementCustomComponents (Element el)
 
void clearPerFaceCustomComponents ()
 
void clearPerVertexCustomComponents ()
 
bool hasEdges () const
 Returns true if the current object has Edge Elements.
 
bool hasElement (Element el) const
 
bool hasFaces () const
 Returns true if the current object has Face Elements.
 
bool hasPerEdgeColor () const
 
bool hasPerEdgeCustomComponents () const
 
bool hasPerEdgeNormal () const
 
bool hasPerEdgeQuality () const
 
bool hasPerEdgeVertexReferences () const
 
bool hasPerElementComponent (Element el, Component comp) const
 
bool hasPerFaceColor () const
 
bool hasPerFaceCustomComponents () const
 
bool hasPerFaceNormal () const
 
bool hasPerFaceQuality () const
 
bool hasPerFaceVertexReferences () const
 Returns true if the current object has per Face Vertex References.
 
bool hasPerFaceWedgeTexCoords () const
 
bool hasPerVertexColor () const
 Returns true if the current object has Vertex Colors.
 
bool hasPerVertexCustomComponents () const
 Returns true if the current object has Vertex Custom Components.
 
bool hasPerVertexNormal () const
 Returns true if the current object has Vertex Normals.
 
bool hasPerVertexPosition () const
 Returns true if the current object has Vertex Positions.
 
bool hasPerVertexQuality () const
 Returns true if the current object has Vertex Quality.
 
bool hasPerVertexTexCoord () const
 Returns true if the current object has Vertex Texture Coordinates.
 
bool hasTextures () const
 
bool hasVertices () const
 Returns true if the current object has Vertex Elements.
 
MeshInfo intersect (const MeshInfo &info) const
 Returns a MeshInfo object that is the intersection between this and info.
 
bool isEmpty () const
 Returns whether the current MeshInfo object is empty, i.e., it has no Elements set.
 
bool isPolygonMesh () const
 Returns true if the current object has Mesh type set to MeshType::POLYGON_MESH.
 
bool isQuadMesh () const
 Returns true if the current object has Mesh type set to MeshType::QUAD_MESH.
 
bool isTriangleMesh () const
 Returns true if the current object has Mesh type set to MeshType::TRIANGLE_MESH.
 
bool isUnkownMesh () const
 
 MeshInfo ()
 Default constructor.
 
template<MeshConcept Mesh>
 MeshInfo (const Mesh &m)
 Sets the current status of the MeshInfo object from the input mesh.
 
MeshType meshType () const
 
DataType perEdgeColorType () const
 
const std::vector< CustomComponent > & perEdgeCustomComponents () const
 
DataType perEdgeNormalType () const
 
DataType perEdgeQualityType () const
 
DataType perElementComponentType (Element el, Component comp) const
 
const std::vector< CustomComponent > & perElementCustomComponents (Element el) const
 
DataType perFaceColorType () const
 
const std::vector< CustomComponent > & perFaceCustomComponents () const
 
DataType perFaceNormalType () const
 
DataType perFaceQualityType () const
 
DataType perFaceWedgeTexCoordsType () const
 
DataType perVertexColorType () const
 
const std::vector< CustomComponent > & perVertexCustomComponents () const
 
DataType perVertexNormalType () const
 
DataType perVertexPositionType () const
 
DataType perVertexQualityType () const
 
DataType perVertexTexCoordType () const
 
void setEdges (bool b=true)
 
void setElement (Element el, bool b=true)
 
void setFaces (bool b=true)
 
void setMeshType (MeshType t)
 
void setPerEdgeColor (bool b=true, DataType t=PrimitiveType::UCHAR)
 
void setPerEdgeCustomComponents (bool b=true)
 
void setPerEdgeNormal (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setPerEdgeQuality (bool b=true, DataType t=PrimitiveType::DOUBLE)
 
void setPerEdgeVertexReferences (bool b=true)
 
void setPerElementComponent (Element el, Component c, bool b, DataType t)
 
void setPerFaceColor (bool b=true, DataType t=PrimitiveType::UCHAR)
 
void setPerFaceCustomComponents (bool b=true)
 
void setPerFaceNormal (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setPerFaceQuality (bool b=true, DataType t=PrimitiveType::DOUBLE)
 
void setPerFaceVertexReferences (bool b=true)
 
void setPerFaceWedgeTexCoords (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setPerVertexColor (bool b=true, DataType t=PrimitiveType::UCHAR)
 
void setPerVertexCustomComponents (bool b=true)
 
void setPerVertexNormal (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setPerVertexPosition (bool b=true, DataType t=PrimitiveType::DOUBLE)
 
void setPerVertexQuality (bool b=true, DataType t=PrimitiveType::DOUBLE)
 
void setPerVertexTexCoord (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setPolygonMesh ()
 
void setQuadMesh ()
 
void setTextures (bool b=true)
 
void setTriangleMesh ()
 
void setUnknownMesh ()
 
void setVertices (bool b=true)
 
void updateMeshType (uint faceSize)
 

Static Private Member Functions

template<typename T >
static DataType getType ()
 Given the template T, returns the corresponding enum DataType value of T.
 
static DataType getType (std::type_index ti)
 

Private Attributes

std::bitset< NUM_ELEMENTS > mElements = {false}
 
std::array< std::bitset< NUM_COMPONENTS >, NUM_ELEMENTS > mPerElemComponents
 
Eigen::Matrix< DataType, NUM_ELEMENTS, NUM_COMPONENTS > mPerElemComponentsType
 
std::array< std::vector< CustomComponent >, NUM_ELEMENTS > mPerElemCustomComponents
 
MeshType mType = MeshType::UNKNOWN
 

Detailed Description

A simple class that allows to store which elements and their components have been imported/loaded or are going to be exported/saved on a mesh file or some other data structure.

For example, when loading a Mesh from a file, an object of this type is used to know which Elements/Components have been loaded from the file, using the getter functions:

MeshInfo info;
AMeshType m = vcl::load<AMeshType>("meshfile.ply", info);
if (info.hasFaces()) { // the file had faces
(info.hasFaceColors()) { // the file had face colors
// ...
}
}
A class representing a box in N-dimensional space.
Definition box.h:46
A simple class that allows to store which elements and their components have been imported/loaded or ...
Definition mesh_info.h:76
bool hasFaces() const
Returns true if the current object has Face Elements.
Definition mesh_info.h:400

When saving a Mesh to a file, an object of this type is used to tell which Elements/Components save on the file and, when the file format supports it, to choose the type used to store a specific component:

MeshInfo info(m); // compute the default MeshInfo object from the Mesh
info.setPerVertexPosition(true, MeshInfo::FLOAT); // force to store vertex
// positions using floats
info.setVertexColors(false); // do not store vertex colors
vcl::save(m, "meshfile.ply", info);

Member Enumeration Documentation

◆ Element

Enum used to describe the type of Elements that can be found in a file.

Note
: MESH is not an element, but it is used since some components can be stored per mesh.

Constructor & Destructor Documentation

◆ MeshInfo() [1/2]

vcl::MeshInfo::MeshInfo ( )
inline

Default constructor.

All the Elements/Components are disabled, their type is set to DataType::NONE and the Mesh Type is set to MeshType::POLYGON_MESH.

◆ MeshInfo() [2/2]

template<MeshConcept Mesh>
vcl::MeshInfo::MeshInfo ( const Mesh m)
inline

Sets the current status of the MeshInfo object from the input mesh.

Template Parameters
MeshThe type of the input mesh, it must satisfy the MeshConcept.
Parameters
[in]mthe mesh from which construct the MeshInfo object

Member Function Documentation

◆ clear()

void vcl::MeshInfo::clear ( )
inline

Clears the MeshInfo object.

All the Elements/Components are disabled, their type is set to DataType::NONE and the Mesh Type is set to MeshType::UNKNOWN.

◆ getType()

template<typename T >
static DataType vcl::MeshInfo::getType ( )
inlinestaticprivate

Given the template T, returns the corresponding enum DataType value of T.

Returns DataType::NONE if the type T was not part of the type supported by the DataType enum.

Returns

◆ hasEdges()

bool vcl::MeshInfo::hasEdges ( ) const
inline

Returns true if the current object has Edge Elements.

Returns
true if the current object has Edge Elements.

◆ hasFaces()

bool vcl::MeshInfo::hasFaces ( ) const
inline

Returns true if the current object has Face Elements.

Returns
true if the current object has Face Elements.

◆ hasPerFaceVertexReferences()

bool vcl::MeshInfo::hasPerFaceVertexReferences ( ) const
inline

Returns true if the current object has per Face Vertex References.

Returns
true if the current object has per Face Vertex References.

◆ hasPerVertexColor()

bool vcl::MeshInfo::hasPerVertexColor ( ) const
inline

Returns true if the current object has Vertex Colors.

Returns
true if the current object has Vertex Colors.

◆ hasPerVertexCustomComponents()

bool vcl::MeshInfo::hasPerVertexCustomComponents ( ) const
inline

Returns true if the current object has Vertex Custom Components.

Returns
true if the current object has Vertex Custom Components.

◆ hasPerVertexNormal()

bool vcl::MeshInfo::hasPerVertexNormal ( ) const
inline

Returns true if the current object has Vertex Normals.

Returns
true if the current object has Vertex Normals.

◆ hasPerVertexPosition()

bool vcl::MeshInfo::hasPerVertexPosition ( ) const
inline

Returns true if the current object has Vertex Positions.

Returns
true if the current object has Vertex Positions.

◆ hasPerVertexQuality()

bool vcl::MeshInfo::hasPerVertexQuality ( ) const
inline

Returns true if the current object has Vertex Quality.

Returns
true if the current object has Vertex Quality.

◆ hasPerVertexTexCoord()

bool vcl::MeshInfo::hasPerVertexTexCoord ( ) const
inline

Returns true if the current object has Vertex Texture Coordinates.

Returns
true if the current object has Vertex Texture Coordinates.

◆ hasVertices()

bool vcl::MeshInfo::hasVertices ( ) const
inline

Returns true if the current object has Vertex Elements.

Returns
true if the current object has Vertex Elements.

◆ intersect()

MeshInfo vcl::MeshInfo::intersect ( const MeshInfo info) const
inline

Returns a MeshInfo object that is the intersection between this and info.

The intersection is a MeshInfo object that has Elements/Components enabled only if they are enabled both in this object and in info. Types are imported from this MeshInfo.

Parameters
[in]infoThe info object to compute the intersection with.
Returns
The intersection between this and info.

◆ isPolygonMesh()

bool vcl::MeshInfo::isPolygonMesh ( ) const
inline

Returns true if the current object has Mesh type set to MeshType::POLYGON_MESH.

Returns
true if the current Mesh type is set to MeshType::POLYGON_MESH.

◆ isQuadMesh()

bool vcl::MeshInfo::isQuadMesh ( ) const
inline

Returns true if the current object has Mesh type set to MeshType::QUAD_MESH.

Returns
true if the current Mesh type is set to MeshType::QUAD_MESH.

◆ isTriangleMesh()

bool vcl::MeshInfo::isTriangleMesh ( ) const
inline

Returns true if the current object has Mesh type set to MeshType::TRIANGLE_MESH.

Returns
true if the current Mesh type is set to MeshType::TRIANGLE_MESH.

Member Data Documentation

◆ mPerElemComponents

std::array<std::bitset<NUM_COMPONENTS>, NUM_ELEMENTS> vcl::MeshInfo::mPerElemComponents
private
Initial value:
= {
false}

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