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

Write an ITKMesh to an OBJ file. More...

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

Public Member Functions

 OBJWriter ()=default
 Default constructor.
 
 OBJWriter (filesystem::path outputPath, ITKMesh::Pointer mesh)
 Constructor with output path and input mesh.
 
 OBJWriter (filesystem::path outputPath, ITKMesh::Pointer mesh, UVMap::Pointer uvMap, cv::Mat uvImg)
 Constructor with output path and textured mesh information.
 
void setPath (const filesystem::path &path)
 Set the output path. More...
 
void setMesh (ITKMesh::Pointer mesh)
 Set the input mesh.
 
void setUVMap (UVMap::Pointer uvMap)
 Set the input UV Map.
 
void setTexture (cv::Mat uvImg)
 Set the input texture image.
 
void setTextureFormat (std::string fmt)
 Set the texture image format. More...
 
void write ()
 Write the OBJ to disk. More...
 

Private Member Functions

void write_obj_ ()
 
void write_mtl_ ()
 
void write_texture_ ()
 
void write_header_ ()
 
void write_vertices_ ()
 
void write_texture_coordinates_ ()
 
void write_faces_ ()
 

Private Attributes

filesystem::path outputPath_
 
std::string textureFmt_ {"tif"}
 
std::ofstream outputMesh_
 
std::ofstream outputMTL_
 
std::map< std::uint32_t, cv::Vec3i > pointLinks_
 
ITKMesh::Pointer mesh_
 
UVMap::Pointer uvMap_
 
cv::Mat texture_
 

Detailed Description

Write an ITKMesh to an OBJ file.

Author
Seth Parker
Date
6/24/15

Writes both textured and untextured meshes in ASCII OBJ format. Texture information is automatically written if a UV map is set and is not empty.

Definition at line 29 of file OBJWriter.hpp.

Member Function Documentation

◆ setPath()

void volcart::io::OBJWriter::setPath ( const filesystem::path &  path)

Set the output path.

write() and validate() will fail if path does not have an expected file extension (.obj/.OBJ).

◆ setTextureFormat()

void volcart::io::OBJWriter::setTextureFormat ( std::string  fmt)

Set the texture image format.

Passed value will be used as the file extension when writing the texture image. Example values: tif, jpg, png.

◆ write()

void volcart::io::OBJWriter::write ( )

Write the OBJ to disk.

If UV Map is not empty, automatically writes MTL and texture image.

Exceptions
volcart::IOException

◆ write_faces_()

void volcart::io::OBJWriter::write_faces_ ( )
private

Write the OBJ faces

◆ write_header_()

void volcart::io::OBJWriter::write_header_ ( )
private

Write the OBJ header

◆ write_mtl_()

void volcart::io::OBJWriter::write_mtl_ ( )
private

Write the MTL file

◆ write_obj_()

void volcart::io::OBJWriter::write_obj_ ( )
private

Write the OBJ file

◆ write_texture_()

void volcart::io::OBJWriter::write_texture_ ( )
private

Write the texture file

◆ write_texture_coordinates_()

void volcart::io::OBJWriter::write_texture_coordinates_ ( )
private

Write the OBJ texture coordinates

◆ write_vertices_()

void volcart::io::OBJWriter::write_vertices_ ( )
private

Write the OBJ vertices

Member Data Documentation

◆ mesh_

ITKMesh::Pointer volcart::io::OBJWriter::mesh_
private

Input mesh

Definition at line 107 of file OBJWriter.hpp.

◆ outputMesh_

std::ofstream volcart::io::OBJWriter::outputMesh_
private

Output OBJ filestream

Definition at line 90 of file OBJWriter.hpp.

◆ outputMTL_

std::ofstream volcart::io::OBJWriter::outputMTL_
private

Output MTL filestream

Definition at line 92 of file OBJWriter.hpp.

◆ outputPath_

filesystem::path volcart::io::OBJWriter::outputPath_
private

Output file path

Definition at line 86 of file OBJWriter.hpp.

◆ pointLinks_

std::map<std::uint32_t, cv::Vec3i> volcart::io::OBJWriter::pointLinks_
private

Keeps track of what info we have about each point in the mesh. Used for building OBJ faces.

[ Point Index, {v, vt, vn} ]

v = vertex index number
vt = UV coordinate index number
vn = vertex normal index number

Definition at line 104 of file OBJWriter.hpp.

◆ texture_

cv::Mat volcart::io::OBJWriter::texture_
private

Input texture image

Definition at line 111 of file OBJWriter.hpp.

◆ textureFmt_

std::string volcart::io::OBJWriter::textureFmt_ {"tif"}
private

Output texture image file extension

Definition at line 88 of file OBJWriter.hpp.

◆ uvMap_

UVMap::Pointer volcart::io::OBJWriter::uvMap_
private

Input UV map

Definition at line 109 of file OBJWriter.hpp.


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