Volume Cartographer 2.27.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
volcart::io::OBJReader Class Reference
Core » IO

Read an OBJ file into a volcart::ITKMesh. More...

#include <vc/core/io/OBJReader.hpp>

Public Member Functions

void setPath (const filesystem::path &p)
 Set the OBJ file path.
 
auto read () -> ITKMesh::Pointer
 Read the mesh from file.
 
auto getMesh () -> ITKMesh::Pointer
 Return the parsed mesh.
 
auto getUVMap () -> UVMap::Pointer
 Return parsed UV information. More...
 
auto getTextureMat () -> cv::Mat
 Return texture image as cv::Mat. More...
 

Private Types

enum class  RefType {
  Invalid , Vertex , VertexWithTexture , VertexWithNormal ,
  VertexWithTextureAndNormal
}
 Validation enumeration to ensure proper parsing of OBJReader::VertexRefs. More...
 
using VertexRefs = cv::Vec3i
 3-Tuple linking a vertex to its position, UV, and normal elements More...
 
using Face = std::vector< VertexRefs >
 A list of at least three OBJReader::VertexRefs comprise a face. More...
 

Private Member Functions

void reset_ ()
 
void parse_ ()
 
void parse_vertex_ (const std::vector< std::string > &strs)
 
void parse_normal_ (const std::vector< std::string > &strs)
 
void parse_tcoord_ (const std::vector< std::string > &strs)
 
void parse_face_ (const std::vector< std::string > &strs)
 
void parse_mtllib_ (const std::vector< std::string > &strs)
 
auto classify_vertref_ (const std::string &ref) -> RefType
 
void build_mesh_ ()
 

Private Attributes

filesystem::path path_
 
filesystem::path texturePath_
 
ITKMesh::Pointer mesh_
 
UVMap::Pointer uvMap_
 
cv::Mat textureMat_
 
std::vector< cv::Vec3d > vertices_
 
std::vector< cv::Vec3d > normals_
 
std::vector< cv::Vec2d > uvs_
 
std::vector< OBJReader::Facefaces_
 

Detailed Description

Read an OBJ file into a volcart::ITKMesh.

Author
Zack Anderson, Seth Parker
Date
02/09/2017

Supports image mapped meshes. Image path is parsed from the OBJ's mtl include. Other material properties are currently ignored. Throws volcart::IOException on error.

Definition at line 29 of file OBJReader.hpp.

Member Typedef Documentation

◆ Face

using volcart::io::OBJReader::Face = std::vector<VertexRefs>
private

A list of at least three OBJReader::VertexRefs comprise a face.

Definition at line 69 of file OBJReader.hpp.

◆ VertexRefs

using volcart::io::OBJReader::VertexRefs = cv::Vec3i
private

3-Tuple linking a vertex to its position, UV, and normal elements

The return value for each element is the [index + 1] of a vertex's position, UV coordinate, or surface normal inside the OBJReader::vertices_, OBJReader::uvs_, or OBJReader::normals_ lists.

VertexRefs { v, vt, vn }

Definition at line 67 of file OBJReader.hpp.

Member Enumeration Documentation

◆ RefType

enum class volcart::io::OBJReader::RefType
strongprivate

Validation enumeration to ensure proper parsing of OBJReader::VertexRefs.

Definition at line 73 of file OBJReader.hpp.

Member Function Documentation

◆ build_mesh_()

void volcart::io::OBJReader::build_mesh_ ( )
private

Construct a mesh from the parsed information

◆ classify_vertref_()

auto volcart::io::OBJReader::classify_vertref_ ( const std::string &  ref) -> RefType
private

◆ getTextureMat()

auto volcart::io::OBJReader::getTextureMat ( ) -> cv::Mat

Return texture image as cv::Mat.

If no texture image was read from MTL file or if the file does not exist, throws a volcart::IOException.

◆ getUVMap()

auto volcart::io::OBJReader::getUVMap ( ) -> UVMap::Pointer

Return parsed UV information.

If no UV information is read, returns an empty volcart::UVMap.

◆ parse_()

void volcart::io::OBJReader::parse_ ( )
private

Parse the mesh

◆ parse_face_()

void volcart::io::OBJReader::parse_face_ ( const std::vector< std::string > &  strs)
private

Handle parsed face lines

◆ parse_mtllib_()

void volcart::io::OBJReader::parse_mtllib_ ( const std::vector< std::string > &  strs)
private

Handle parsed mtllib lines

◆ parse_normal_()

void volcart::io::OBJReader::parse_normal_ ( const std::vector< std::string > &  strs)
private

Handle parsed vertex normal lines

◆ parse_tcoord_()

void volcart::io::OBJReader::parse_tcoord_ ( const std::vector< std::string > &  strs)
private

Handle parsed vertex UV coordinate lines

◆ parse_vertex_()

void volcart::io::OBJReader::parse_vertex_ ( const std::vector< std::string > &  strs)
private

Handle parsed vertex lines

◆ reset_()

void volcart::io::OBJReader::reset_ ( )
private

Clear all temporary data structures

Member Data Documentation

◆ faces_

std::vector<OBJReader::Face> volcart::io::OBJReader::faces_
private

List of parsed faces

Definition at line 120 of file OBJReader.hpp.

◆ mesh_

ITKMesh::Pointer volcart::io::OBJReader::mesh_
private

Internal representation of mesh structure

Definition at line 107 of file OBJReader.hpp.

◆ normals_

std::vector<cv::Vec3d> volcart::io::OBJReader::normals_
private

List of parsed vertex normals

Definition at line 116 of file OBJReader.hpp.

◆ path_

filesystem::path volcart::io::OBJReader::path_
private

Path to the OBJ file

Definition at line 103 of file OBJReader.hpp.

◆ textureMat_

cv::Mat volcart::io::OBJReader::textureMat_
private

Internal representation of texture image

Definition at line 111 of file OBJReader.hpp.

◆ texturePath_

filesystem::path volcart::io::OBJReader::texturePath_
private

Path to the parsed texture image

Definition at line 105 of file OBJReader.hpp.

◆ uvMap_

UVMap::Pointer volcart::io::OBJReader::uvMap_
private

Internal representation of UV Map

Definition at line 109 of file OBJReader.hpp.

◆ uvs_

std::vector<cv::Vec2d> volcart::io::OBJReader::uvs_
private

List of parsed vertex UV coordinates

Definition at line 118 of file OBJReader.hpp.

◆ vertices_

std::vector<cv::Vec3d> volcart::io::OBJReader::vertices_
private

List of parsed vertex positions

Definition at line 114 of file OBJReader.hpp.


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