Visual Computing Library
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 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.
 
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  Component {
  COORD , 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.
 

Public Member Functions

 MeshInfo ()
 Default constructor.
 
template<MeshConcept Mesh>
 MeshInfo (const Mesh &m)
 Sets the current status of the MeshInfo object from the input mesh.
 
void clear ()
 Clears the MeshInfo object.
 
bool isEmpty () const
 Returns whether the current MeshInfo object is empty, i.e., it has no Elements set.
 
bool isUnkownMesh () const
 
bool isTriangleMesh () const
 Returns true if the current object has Mesh type set to MeshType::TRIANGLE_MESH.
 
bool isQuadMesh () const
 Returns true if the current object has Mesh type set to MeshType::QUAD_MESH.
 
bool isPolygonMesh () const
 Returns true if the current object has Mesh type set to MeshType::POLYGON_MESH.
 
bool hasElement (Element el) const
 
bool hasPerElementComponent (Element el, Component comp) const
 
bool hasVertices () const
 Returns true if the current object has Vertex Elements.
 
bool hasVertexCoords () const
 Returns true if the current object has Vertex Coordinates.
 
bool hasVertexNormals () const
 Returns true if the current object has Vertex Normals.
 
bool hasVertexColors () const
 Returns true if the current object has Vertex Colors.
 
bool hasVertexQuality () const
 Returns true if the current object has Vertex Quality.
 
bool hasVertexTexCoords () const
 Returns true if the current object has Vertex Texture Coordinates.
 
bool hasVertexCustomComponents () const
 Returns true if the current object has Vertex Custom Components.
 
bool hasFaces () const
 Returns true if the current object has Face Elements.
 
bool hasFaceVRefs () const
 Returns true if the current object has per Face Vertex References.
 
bool hasFaceNormals () const
 
bool hasFaceColors () const
 
bool hasFaceQuality () const
 
bool hasFaceWedgeTexCoords () const
 
bool hasFaceCustomComponents () const
 
bool hasEdges () const
 Returns true if the current object has Edge Elements.
 
bool hasEdgeVRefs () const
 
bool hasEdgeColors () const
 
bool hasEdgeNormals () const
 
bool hasEdgeQuality () const
 
bool hasEdgeCustomComponents () const
 
bool hasTextures () const
 
void updateMeshType (uint faceSize)
 
void setUnknownMesh ()
 
void setTriangleMesh ()
 
void setQuadMesh ()
 
void setPolygonMesh ()
 
void setMeshType (MeshType t)
 
void setElement (Element el, bool b=true)
 
void setElementComponents (Element el, Component c, bool b, DataType t)
 
void setVertices (bool b=true)
 
void setVertexCoords (bool b=true, DataType t=PrimitiveType::DOUBLE)
 
void setVertexNormals (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setVertexColors (bool b=true, DataType t=PrimitiveType::UCHAR)
 
void setVertexQuality (bool b=true, DataType t=PrimitiveType::DOUBLE)
 
void setVertexTexCoords (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setVertexCustomComponents (bool b=true)
 
void setFaces (bool b=true)
 
void setFaceVRefs (bool b=true)
 
void setFaceNormals (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setFaceColors (bool b=true, DataType t=PrimitiveType::UCHAR)
 
void setFaceQuality (bool b=true, DataType t=PrimitiveType::DOUBLE)
 
void setFaceWedgeTexCoords (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setFaceCustomComponents (bool b=true)
 
void setEdges (bool b=true)
 
void setEdgeVRefs (bool b=true)
 
void setEdgeColors (bool b=true, DataType t=PrimitiveType::UCHAR)
 
void setEdgeNormals (bool b=true, DataType t=PrimitiveType::FLOAT)
 
void setEdgeQuality (bool b=true, DataType t=PrimitiveType::DOUBLE)
 
void setEdgeCustomComponents (bool b=true)
 
void setTextures (bool b=true)
 
void addElementCustomComponent (Element el, const std::string &name, DataType t)
 
void clearElementCustomComponents (Element el)
 
void addVertexCustomComponent (const std::string &name, DataType t)
 
void clearVertexCustomComponents ()
 
void addFaceCustomComponent (const std::string &name, DataType t)
 
void clearFaceCustomComponents ()
 
void addEdgeCustomComponent (const std::string &name, DataType t)
 
void clearEdgeCustomComponents ()
 
DataType elementComponentType (Element el, Component comp) const
 
DataType vertexCoordsType () const
 
DataType vertexNormalsType () const
 
DataType vertexColorsType () const
 
DataType vertexQualityType () const
 
DataType vertexTexCoordsType () const
 
DataType faceNormalsType () const
 
DataType faceColorsType () const
 
DataType faceQualityType () const
 
DataType faceWedgeTexCoordsType () const
 
DataType edgeColorsType () const
 
DataType edgeNormalsType () const
 
DataType edgeQualityType () const
 
const std::vector< CustomComponent > & vertexCustomComponents () const
 
const std::vector< CustomComponent > & faceCustomComponents () const
 
const std::vector< CustomComponent > & edgeCustomComponents () const
 
MeshInfo intersect (const MeshInfo &info) const
 Returns a MeshInfo object that is the intersection between this and info.
 

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 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:397
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43

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.setVertexCoords(true, MeshInfo::FLOAT); // force to store vertex
// coords using floats
info.setVertexColors(false); // do not store vertex colors
vcl::save(m, "meshfile.ply", info);
void save(const MeshType &m, const std::string &filename, LogType &log=nullLogger, const SaveSettings &settings=SaveSettings())
Saves a mesh to a file with the given filename. Checks automatically the file format to save from the...
Definition save.h:59

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.

◆ hasFaceVRefs()

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

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

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

◆ hasVertexColors()

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

Returns true if the current object has Vertex Colors.

Returns
true if the current object has Vertex Colors.

◆ hasVertexCoords()

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

Returns true if the current object has Vertex Coordinates.

Returns
true if the current object has Vertex Coordinates.

◆ hasVertexCustomComponents()

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

Returns true if the current object has Vertex Custom Components.

Returns
true if the current object has Vertex Custom Components.

◆ hasVertexNormals()

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

Returns true if the current object has Vertex Normals.

Returns
true if the current object has Vertex Normals.

◆ hasVertexQuality()

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

Returns true if the current object has Vertex Quality.

Returns
true if the current object has Vertex Quality.

◆ hasVertexTexCoords()

bool vcl::MeshInfo::hasVertexTexCoords ( ) 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: