DHART
|
Manipulate and load geometry from disk. More...
Classes | |
struct | array_and_size |
A simple type to hold the size and data pointer of an array. More... | |
class | MeshInfo |
A collection of vertices and indices representing geometry. More... | |
struct | tinyobj_attr |
struct | tinyobj_geometry |
struct | tinyobj_material |
struct | tinyobj_shape |
Enumerations | |
enum | GROUP_METHOD { ONLY_FILE = 0 , BY_GROUP = 1 , BY_MATERIAL = 2 , MATERIAL_AND_FILE = 3 } |
Method of grouping submeshes in OBJ files. More... | |
Functions | |
template<typename T > | |
void | IndexRawVertices (const vector< array< T, 3 > > &vertices, vector< int > &mapped_indexes, vector< T > &mapped_vertices) |
Index an array of vertices. More... | |
template<typename T > | |
T | arrayDist (const array< T, 3 > from, const array< T, 3 > &to) |
Calculate the distance between from and to. More... | |
template<typename T > | |
MeshInfo () -> MeshInfo< float > | |
tinyobj::ObjReader | CreateReader (const std::string &path) |
template<typename T > | |
tinyobj_shape< T > | MakeShape (const tinyobj::shape_t &shape) |
template<typename T > | |
vector< tinyobj_shape< T > > | MakeShapes (const vector< tinyobj::shape_t > &shapes) |
vector< tinyobj_material > | MakeMaterials (const vector< tinyobj::material_t > &materials) |
tinyobj_geometry< double > | LoadMeshesFromTinyOBJ (std::string path) |
vector< MeshInfo< float > > | LoadMeshObjects (std::string path, GROUP_METHOD gm=ONLY_FILE, bool change_coords=false, int scale=1) |
Create MeshInfo instances from the OBJ at path. More... | |
vector< array< float, 3 > > | LoadRawVertices (std::string path) |
Load a list of vertices directly from an OBJ file. More... | |
std::string | GetTestOBJPath (std::string key) |
Get the path to the OBJ with the given key. More... | |
vector< MeshInfo< float > > | LoadMeshObjects (std::vector< std::string > &path, GROUP_METHOD gm=ONLY_FILE, bool change_coords=false, int scale=1) |
Create MeshInfo instances from the OBJ files in path. More... | |
template<typename T > | |
HF::Geometry::MeshInfo< T > | LoadTMPMeshObjects (const std::string &path) |
Variables | |
static robin_hood::unordered_map< string, string > | test_model_paths |
Manipulate and load geometry from disk.
HF::Geometry contains all functionality in DHARTAPI for dealing with mesh Geometry. The fundamental datatype of HF::Geometry is MeshInfo, which stores the vertices and indices of meshes as matricies in Eigen.
struct HF::Geometry::tinyobj_attr |
Definition at line 72 of file objloader.h.
Class Members | ||
---|---|---|
vector< T > | vertices |
struct HF::Geometry::tinyobj_geometry |
Definition at line 89 of file objloader.h.
Class Members | ||
---|---|---|
tinyobj_attr< T > | attributes | |
vector< tinyobj_material > | materials | |
vector< tinyobj_shape< T > > | shapes |
struct HF::Geometry::tinyobj_material |
Definition at line 84 of file objloader.h.
Class Members | ||
---|---|---|
string | name |
struct HF::Geometry::tinyobj_shape |
Definition at line 78 of file objloader.h.
Class Members | ||
---|---|---|
vector< int > | indices | |
vector< int > | mat_ids | |
string | name |
Method of grouping submeshes in OBJ files.
Enumerator | |
---|---|
ONLY_FILE | Treat all the geometry in the file as a single mesh. |
BY_GROUP | Create a new MeshInfo instance for every OBJ group in the file. |
BY_MATERIAL | Create a new MeshInfo instance for every different material in the file. |
MATERIAL_AND_FILE | UNIMPLEMENTED. |
Definition at line 64 of file objloader.h.
T HF::Geometry::arrayDist | ( | const array< T, 3 > | from, |
const array< T, 3 > & | to | ||
) |
Calculate the distance between from and to.
from | x,y,z position to calculate distance from. |
to | x,y,z position to calculate distance to. |
Definition at line 306 of file meshinfo.cpp.
Referenced by HF::Geometry::MeshInfo< numeric_type >::operator==().
tinyobj::ObjReader HF::Geometry::CreateReader | ( | const std::string & | path | ) |
Definition at line 120 of file objloader.cpp.
Referenced by LoadMeshesFromTinyOBJ().
std::string HF::Geometry::GetTestOBJPath | ( | std::string | key | ) |
Get the path to the OBJ with the given key.
key | The name of the obj to get the path of |
std::out_of_range | if the given key couldn't be found |
Definition at line 407 of file objloader.cpp.
References test_model_paths.
void HF::Geometry::IndexRawVertices | ( | const vector< array< T, 3 > > & | vertices, |
vector< int > & | mapped_indexes, | ||
vector< T > & | mapped_vertices | ||
) |
Index an array of vertices.
vertices | An array of vertices for a mesh organized so every 3 vertices represents a triangle on the mesh. |
mapped_indexes | Output parameter for array of indicies |
mapped_vertices | Output parameter for vertex array. |
Iterate through every array in vertices. If the x,y,z location in the array hasn't been seen yet, add its coordinates to mapped_vertices, assign it a unique ID in a an index hashmap, then add its id to mapped_indexes. IF it has been seen add the existing ID in the index hashmap to mapped_indexes.
Definition at line 73 of file meshinfo.cpp.
Referenced by HF::Geometry::MeshInfo< numeric_type >::VectorsToBuffers().
tinyobj_geometry< double > HF::Geometry::LoadMeshesFromTinyOBJ | ( | std::string | path | ) |
Definition at line 177 of file objloader.cpp.
References HF::Geometry::tinyobj_geometry< T >::attributes, CreateReader(), MakeMaterials(), HF::Geometry::tinyobj_geometry< T >::materials, and HF::Geometry::tinyobj_geometry< T >::shapes.
Referenced by LoadTMPMeshObjects().
std::vector< MeshInfo< float > > HF::Geometry::LoadMeshObjects | ( | std::string | path, |
GROUP_METHOD | gm = ONLY_FILE , |
||
bool | change_coords = false , |
||
int | scale = 1 |
||
) |
Create MeshInfo instances from the OBJ at path.
path | Path to the OBJ to load. |
gm | Method for dividing the mesh into subobjects. |
change_coords | Rotate the mesh from Y-up to Z-up. |
scale | Scaling factor to use for the imported mesh |
HF::Exceptions::InvalidOBJ | The file at path was not a valid OBJ file. |
HF::Exceptions::FileNotFound | No file could be found at path. |
std::exception | gm did not match any valid GROUP_METHOD. |
the name of the mesh should probably just be the filename if the group type is ONLY_FILE.
Definitely some areas for minor speed gains by using indexing instead of .push_bcaks
Change std::exception to std::out_of_range.
Refactor this to break out whatever code can be repeated or reused. This has a McCabe complexity of 25!!!!
Definition at line 195 of file objloader.cpp.
References BY_GROUP, BY_MATERIAL, LoadMeshObjects(), and ONLY_FILE.
Referenced by LoadMeshObjects(), and LoadOBJ().
std::vector< MeshInfo< float > > HF::Geometry::LoadMeshObjects | ( | std::vector< std::string > & | path, |
GROUP_METHOD | gm = ONLY_FILE , |
||
bool | change_coords = false , |
||
int | scale = 1 |
||
) |
Create MeshInfo instances from the OBJ files in path.
path | Path to the OBJ to load. |
gm | Method for dividing the mesh into subobjects. |
change_coords | Rotate the mesh from Y-up to Z-up. |
scale | Scaling factor to use for the imported mesh |
HF::Exceptions::InvalidOBJ | One or more of the files in paths was not a valid OBJ file. |
HF::Exceptions::FileNotFound | Could not find one or more of the files at path. |
std::exception | gm did not match any valid GROUP_METHOD. |
Definition at line 412 of file objloader.cpp.
References LoadMeshObjects().
std::vector< std::array< float, 3 > > HF::Geometry::LoadRawVertices | ( | std::string | path | ) |
Load a list of vertices directly from an OBJ file.
path | Location of the OBJ to load on disk. |
HF::Exceptions::InvalidOBJ | path did not lead to a valid OBJ file. |
Definition at line 371 of file objloader.cpp.
HF::Geometry::MeshInfo< T > HF::Geometry::LoadTMPMeshObjects | ( | const std::string & | path | ) |
Definition at line 98 of file objloader.h.
References HF::Geometry::tinyobj_geometry< T >::attributes, LoadMeshesFromTinyOBJ(), and HF::Geometry::tinyobj_geometry< T >::shapes.
vector< tinyobj_material > HF::Geometry::MakeMaterials | ( | const vector< tinyobj::material_t > & | materials | ) |
Definition at line 168 of file objloader.cpp.
Referenced by LoadMeshesFromTinyOBJ().
tinyobj_shape< T > HF::Geometry::MakeShape | ( | const tinyobj::shape_t & | shape | ) |
Definition at line 146 of file objloader.cpp.
References HF::Geometry::tinyobj_shape< T >::indices, and HF::Geometry::tinyobj_shape< T >::mat_ids.
vector< tinyobj_shape< T > > HF::Geometry::MakeShapes | ( | const vector< tinyobj::shape_t > & | shapes | ) |
Definition at line 159 of file objloader.cpp.
HF::Geometry::MeshInfo | ( | ) | -> MeshInfo< float > |
|
static |
Definition at line 112 of file objloader.cpp.
Referenced by GetTestOBJPath().