DHART
|
A collection of vertices and indices representing geometry. More...
#include <meshinfo.h>
Public Member Functions | |
MeshInfo () | |
Construct an empty instance of MeshInfo. More... | |
MeshInfo (const std::vector< std::array< numeric_type, 3 > > &vertices, int id, std::string name="") | |
Construct a new MeshInfo object from an unindexed vector of vertices, an ID, and a name. More... | |
MeshInfo (const std::vector< numeric_type > &in_vertices, const std::vector< int > &in_indexes, int id, std::string name="") | |
Construct a new MeshInfo object from an indexed vector of vertices. More... | |
void | AddVerts (const std::vector< std::array< numeric_type, 3 > > &verts) |
Add more vertices to this mesh. More... | |
int | NumVerts () const |
Determine how many vertices are in this mesh. More... | |
int | NumTris () const |
Calculate the total number of triangles in this mesh. More... | |
void | ConvertToRhinoCoordinates () |
Convert a mesh from Y-Up to Z-Up. More... | |
void | ConvertToOBJCoordinates () |
Convert a mesh from Z-Up to Y-Up. More... | |
void | PerformRotation (numeric_type rx, numeric_type ry, numeric_type rz) |
Rotate this mesh by x, y, z rotations in degrees (pitch, yaw, roll). More... | |
int | GetMeshID () const |
Get the ID of this mesh. More... | |
std::vector< numeric_type > | GetIndexedVertices () const |
| |
std::vector< int > | getRawIndices () const |
Retrieve a copy of this mesh's index buffer as a 1D array. More... | |
std::vector< std::array< numeric_type, 3 > > | GetUnindexedVertices () const |
Retrieve an unindexed array of this mesh's vertices. More... | |
void | SetMeshID (int new_id) |
Change the ID of this mesh. More... | |
bool | operator== (const MeshInfo &M2) const |
Compare the vertices of two MeshInfo objects. More... | |
std::array< numeric_type, 3 > | operator[] (int i) const |
Get vertex at a specific index in the mesh. More... | |
const array_and_size< numeric_type > | GetVertexPointer () const |
Get a pointer to the vertex array of this mesh. More... | |
const array_and_size< int > | GetIndexPointer () const |
Get a pointer to the index array of this mesh. More... | |
Public Attributes | |
int | meshid |
Identifier for this mesh. More... | |
std::string | name = "" |
A human-readable title. More... | |
Private Types | |
using | VertMatrix = Eigen::Matrix3X< numeric_type > |
Private Member Functions | |
void | SetVert (int index, numeric_type x, numeric_type y, numeric_type z) |
Change the position of the vertex at index. More... | |
void | VectorsToBuffers (const std::vector< std::array< numeric_type, 3 > > &vertices) |
Index vertices then insert them into verts and indices. More... | |
Private Attributes | |
VertMatrix | verts |
3 by X matrix of vertices More... | |
Eigen::Matrix3X< int > | indices |
3 by X matrix of indices for triangles. More... | |
A collection of vertices and indices representing geometry.
Internally stored as a 3 by X matrix of vertices and a 3 by X matrix for indices. Eigen is used to manage all matricies and perform quick transformations such as RotateMesh. More details on Eigen are available here: https://eigen.tuxfamily.org/dox/group__Geometry__Module.html
Definition at line 124 of file meshinfo.h.
|
private |
Definition at line 130 of file meshinfo.h.
|
inline |
Construct an empty instance of MeshInfo.
Definition at line 177 of file meshinfo.h.
References HF::Geometry::MeshInfo< numeric_type >::meshid, HF::Geometry::MeshInfo< numeric_type >::name, and HF::Geometry::MeshInfo< numeric_type >::verts.
HF::Geometry::MeshInfo< numeric_type >::MeshInfo | ( | const std::vector< std::array< numeric_type, 3 > > & | vertices, |
int | id, | ||
std::string | name = "" |
||
) |
Construct a new MeshInfo object from an unindexed vector of vertices, an ID, and a name.
vertices | An ordered list of vertices where every 3 vertices comprise single a triangle in the mesh. |
id | A unique identifier. |
name | A human-readable title. |
HF::Exceptions::InvalidOBJ | the input vertices don't represent a valid mesh. |
std::exception | the input array had one or more NAN values. |
Change the std::exception to also be an InvalidOBJ exception.
Check for a number of vertices that aren't a multiple of 3 like the other functions.
HF::Geometry::MeshInfo< numeric_type >::MeshInfo | ( | const std::vector< numeric_type > & | in_vertices, |
const std::vector< int > & | in_indexes, | ||
int | id, | ||
std::string | name = "" |
||
) |
Construct a new MeshInfo object from an indexed vector of vertices.
vertices | An ordered list of numeric_types with every 3 numeric_types representing the x,y, and z coordinates for a single vertex. |
indexes | A vector of indices with each index matching up with a vertex in vertices. |
id | A unique identifier. |
name | A human readable title. |
HF::Exceptions::InvalidOBJ | input indices and vertices don't represent a valid mesh. |
void HF::Geometry::MeshInfo< T >::AddVerts | ( | const std::vector< std::array< numeric_type, 3 > > & | verts | ) |
Add more vertices to this mesh.
verts | Vertices to add to this mesh, with each 3 belonging to a new triangle. |
Index the vertices in verts, then insert the new indices and vertices into their respective arrays.
HF::Exceptions::InvalidOBJ | in_vertices did not contain a valid set of triangles. |
Definition at line 162 of file meshinfo.cpp.
void HF::Geometry::MeshInfo< T >::ConvertToOBJCoordinates |
Convert a mesh from Z-Up to Y-Up.
Rename this to ConvertToYup.
Just use the RotateMesh function.
Definition at line 196 of file meshinfo.cpp.
void HF::Geometry::MeshInfo< T >::ConvertToRhinoCoordinates |
Convert a mesh from Y-Up to Z-Up.
Rename this to ConvertToZUp.
Just use the RotateMesh function.
Change exception to an assertion since it shouldn't happen in production code.
Definition at line 184 of file meshinfo.cpp.
vector< T > HF::Geometry::MeshInfo< T >::GetIndexedVertices |
Copy this mesh's vertices as a 1D array.
The vertices are copied directly from this mesh's underlying eigen matrix. The index of each vertex matches the index used for this mesh's index array. For Example the first element is the vertex at index 0, the second is the vertex for index 1, etc.
Definition at line 244 of file meshinfo.cpp.
Referenced by HF::RayTracer::EmbreeRayTracer::AddMesh().
const array_and_size< int > HF::Geometry::MeshInfo< T >::GetIndexPointer |
Get a pointer to the index array of this mesh.
Definition at line 326 of file meshinfo.cpp.
References HF::Geometry::array_and_size< ptr_type >::data, and HF::Geometry::array_and_size< ptr_type >::size.
Referenced by HF::RayTracer::NanoRTRayTracer::NanoRTRayTracer(), and GetVertsAndTris().
int HF::Geometry::MeshInfo< T >::GetMeshID |
Get the ID of this mesh.
Definition at line 241 of file meshinfo.cpp.
vector< int > HF::Geometry::MeshInfo< T >::getRawIndices |
Retrieve a copy of this mesh's index buffer as a 1D array.
Definition at line 256 of file meshinfo.cpp.
Referenced by HF::RayTracer::EmbreeRayTracer::AddMesh().
vector< std::array< T, 3 > > HF::Geometry::MeshInfo< T >::GetUnindexedVertices |
Retrieve an unindexed array of this mesh's vertices.
For every index in this mesh's indices array, copy the matching vertex into the return array. This will result in vertexes being repeated multiple times. For example, the first element is the vertex pointed to by the first index in indices, the second element is the vertex pointed to by the second index in indices etc.
Definition at line 264 of file meshinfo.cpp.
const array_and_size< T > HF::Geometry::MeshInfo< T >::GetVertexPointer |
Get a pointer to the vertex array of this mesh.
Definition at line 336 of file meshinfo.cpp.
References HF::Geometry::array_and_size< ptr_type >::data, and HF::Geometry::array_and_size< ptr_type >::size.
Referenced by HF::RayTracer::NanoRTRayTracer::NanoRTRayTracer(), and GetVertsAndTris().
int HF::Geometry::MeshInfo< T >::NumTris |
Calculate the total number of triangles in this mesh.
The number of triangles in the mesh is equal to the number of columns in the indices matrix.
Definition at line 181 of file meshinfo.cpp.
Referenced by HF::RayTracer::EmbreeRayTracer::AddMesh().
int HF::Geometry::MeshInfo< T >::NumVerts |
Determine how many vertices are in this mesh.
The number of vertices in the mesh is equal to the number of columns in the verts matrix.
Definition at line 178 of file meshinfo.cpp.
Referenced by HF::RayTracer::EmbreeRayTracer::AddMesh(), and HF::Geometry::MeshInfo< numeric_type >::operator==().
bool HF::Geometry::MeshInfo< T >::operator== | ( | const MeshInfo< numeric_type > & | M2 | ) | const |
Compare the vertices of two MeshInfo objects.
M2 | The desired MeshInfo to compare. |
First check that the size of both mesh's vertex arrays are the same size, then compare the distance between every vertex one by one.
Definition at line 310 of file meshinfo.cpp.
References HF::Geometry::arrayDist(), and HF::Geometry::MeshInfo< numeric_type >::NumVerts().
array< T, 3 > HF::Geometry::MeshInfo< T >::operator[] | ( | int | i | ) | const |
Get vertex at a specific index in the mesh.
i | Index of the vertex to retrieve. |
std::exception | i is out of the bounds of the vertex array. |
Definition at line 285 of file meshinfo.cpp.
void HF::Geometry::MeshInfo< T >::PerformRotation | ( | numeric_type | rx, |
numeric_type | ry, | ||
numeric_type | rz | ||
) |
Rotate this mesh by x, y, z rotations in degrees (pitch, yaw, roll).
rx | Pitch to rotate by in degrees. |
ry | Yaw to rotate by in degrees. |
rz | Roll to rotate by in degrees. |
[snippet_objloader_assert]
[snippet_objloader_assert]
Definition at line 209 of file meshinfo.cpp.
Referenced by RotateMesh().
void HF::Geometry::MeshInfo< T >::SetMeshID | ( | int | new_id | ) |
Change the ID of this mesh.
new_id | New ID to assign to this mesh. |
Definition at line 282 of file meshinfo.cpp.
|
inlineprivate |
Change the position of the vertex at index.
index | Index of the vertex to change, |
x | X coordinate |
y | Y coordinate |
z | Z coordinate |
Definition at line 40 of file meshinfo.cpp.
|
private |
Index vertices then insert them into verts and indices.
vertices | An ordered list of vertices; every 3 vertices form a triangle in the mesh. |
Calls IndexRawVertices to index the input vertices then fill verts and indices.
HF::Exceptions::InvalidOBJ | vertices did not contain the vertices of a valid mesh. |
Definition at line 122 of file meshinfo.cpp.
References HF::Geometry::IndexRawVertices().
|
private |
3 by X matrix of indices for triangles.
Definition at line 132 of file meshinfo.h.
int HF::Geometry::MeshInfo< numeric_type >::meshid |
Identifier for this mesh.
Definition at line 126 of file meshinfo.h.
Referenced by HF::Geometry::MeshInfo< numeric_type >::MeshInfo(), HF::RayTracer::EmbreeRayTracer::AddMesh(), GetMeshID(), and RotateMesh().
std::string HF::Geometry::MeshInfo< numeric_type >::name = "" |
A human-readable title.
Definition at line 127 of file meshinfo.h.
Referenced by HF::Geometry::MeshInfo< numeric_type >::MeshInfo(), and GetMeshName().
|
private |
3 by X matrix of vertices
Definition at line 131 of file meshinfo.h.
Referenced by HF::Geometry::MeshInfo< numeric_type >::MeshInfo().