cgv
Loading...
Searching...
No Matches
cgv::media::mesh::obj_reader_generic< T > Class Template Reference

implements the pure reading of an obj file and calls virtual callback functions to allow a derived class to handle the read information. More...

#include <obj_reader.h>

Inheritance diagram for cgv::media::mesh::obj_reader_generic< T >:
cgv::media::mesh::obj_reader_base cgv::media::mesh::obj_loader_generic< T > cgv::media::mesh::simple_mesh_obj_reader< T >

Public Types

typedef T coord_type
 type of coordinates
 
typedef cgv::math::fvec< T, 2 > vec2_type
 type used to store texture coordinates
 
typedef cgv::math::fvec< T, 3 > vec3_type
 type used to store positions and normal vectors
 
- Public Types inherited from cgv::media::mesh::obj_reader_base
typedef illum::obj_material::color_type color_type
 type used for rgba colors
 

Static Public Member Functions

static bool is_double (const char *begin, const char *end, coord_type &value)
 

Protected Member Functions

template type dependent helpers for reading
vec2_type parse_vec2 (const std::vector< cgv::utils::token > &t) const
 parse 2d vector
 
vec3_type parse_vec3 (const std::vector< cgv::utils::token > &t) const
 parse 3d vector
 
void parse_and_process_vertex (const std::vector< cgv::utils::token > &tokens)
 
void parse_and_process_normal (const std::vector< cgv::utils::token > &tokens)
 
void parse_and_process_texcoord (const std::vector< cgv::utils::token > &tokens)
 
- Protected Member Functions inherited from cgv::media::mesh::obj_reader_base
color_type parse_color (const std::vector< cgv::utils::token > &t, unsigned off=0) const
 parse a color, if alpha not given it defaults to 1
 
void parse_face (const std::vector< cgv::utils::token > &tokens, bool is_line=false)
 
void parse_material (const std::vector< cgv::utils::token > &tokens)
 
unsigned get_current_group () const
 return the index of the currently selected group or -1 if no group is defined
 
unsigned get_current_material () const
 return the index of the currently selected material or -1 if no material is defined
 
virtual void process_comment (const std::string &comment)
 overide this function to process a comment
 
virtual void process_color (const color_type &c)
 overide this function to process a color (this called for vc prefixes which is is not in the standard but for example used in pobj-files)
 
void convert_to_positive (unsigned vcount, int *vertices, int *texcoords, int *normals, unsigned v, unsigned n, unsigned t)
 convert negative indices to positive ones by adding the number of elements
 
virtual void process_line (unsigned vcount, int *vertices, int *texcoords=0, int *normals=0)
 overide this function to process a line strip, the indices start with 0
 
virtual void process_face (unsigned vcount, int *vertices, int *texcoords=0, int *normals=0)
 overide this function to process a face, the indices start with 0
 
virtual void process_group (const std::string &name, const std::string &parameters)
 overide this function to process a group given by name and parameter string
 
virtual void process_material (const cgv::media::illum::obj_material &mtl, unsigned idx)
 process a material definition. If a material with a certain name is overwritten, it will receive the same index
 

virtual interface

virtual void process_vertex (const vec3_type &p)
 overide this function to process a vertex
 
virtual void process_texcoord (const vec2_type &t)
 overide this function to process a texcoord
 
virtual void process_normal (const vec3_type &n)
 overide this function to process a normal
 
 obj_reader_generic ()
 default constructor
 

Additional Inherited Members

- Public Member Functions inherited from cgv::media::mesh::obj_reader_base
virtual bool parse_obj (const std::string &content, const std::string path_name="")
 parse the content of an obj file already read to memory, where path_name is used to find material files
 
virtual bool read_obj (const std::string &file_name)
 read an obj file
 
virtual bool read_mtl (const std::string &file_name)
 read a material file
 
virtual void clear ()
 clear the reader such that a new file can be read
 
- Protected Attributes inherited from cgv::media::mesh::obj_reader_base
unsigned group_index
 keep track of the current group
 
unsigned nr_groups
 number of groups
 
unsigned material_index
 keep track of current material index
 
unsigned nr_materials
 number of materials
 
std::map< std::string, unsigned > material_index_lut
 mapping from material names to material indices
 
int minus
 
unsigned nr_normals
 
unsigned nr_texcoords
 
bool have_default_material
 
std::set< std::string > mtl_lib_files
 
std::string path_name
 store the path name
 

Detailed Description

template<typename T>
class cgv::media::mesh::obj_reader_generic< T >

implements the pure reading of an obj file and calls virtual callback functions to allow a derived class to handle the read information.

The default implementations of the processing methods are implemented to simply ignore the read information.

Definition at line 97 of file obj_reader.h.

Member Typedef Documentation

◆ coord_type

template<typename T >
typedef T cgv::media::mesh::obj_reader_generic< T >::coord_type

type of coordinates

Definition at line 101 of file obj_reader.h.

◆ vec2_type

template<typename T >
typedef cgv::math::fvec<T,2> cgv::media::mesh::obj_reader_generic< T >::vec2_type

type used to store texture coordinates

Definition at line 103 of file obj_reader.h.

◆ vec3_type

template<typename T >
typedef cgv::math::fvec<T,3> cgv::media::mesh::obj_reader_generic< T >::vec3_type

type used to store positions and normal vectors

Definition at line 105 of file obj_reader.h.

Constructor & Destructor Documentation

◆ obj_reader_generic()

template<typename T >
cgv::media::mesh::obj_reader_generic< T >::obj_reader_generic ( )

default constructor

Definition at line 105 of file obj_reader.cxx.

Member Function Documentation

◆ is_double()

template<typename T >
bool cgv::media::mesh::obj_reader_generic< T >::is_double ( const char *  begin,
const char *  end,
coord_type value 
)
static

Definition at line 37 of file obj_reader.cxx.

◆ parse_and_process_normal()

template<typename T >
void cgv::media::mesh::obj_reader_generic< T >::parse_and_process_normal ( const std::vector< cgv::utils::token > &  tokens)
protectedvirtual

Implements cgv::media::mesh::obj_reader_base.

Definition at line 184 of file obj_reader.cxx.

◆ parse_and_process_texcoord()

template<typename T >
void cgv::media::mesh::obj_reader_generic< T >::parse_and_process_texcoord ( const std::vector< cgv::utils::token > &  tokens)
protectedvirtual

Implements cgv::media::mesh::obj_reader_base.

Definition at line 190 of file obj_reader.cxx.

◆ parse_and_process_vertex()

template<typename T >
void cgv::media::mesh::obj_reader_generic< T >::parse_and_process_vertex ( const std::vector< cgv::utils::token > &  tokens)
protectedvirtual

Implements cgv::media::mesh::obj_reader_base.

Definition at line 178 of file obj_reader.cxx.

◆ parse_vec2()

template<typename T >
obj_reader_generic< T >::vec2_type cgv::media::mesh::obj_reader_generic< T >::parse_vec2 ( const std::vector< cgv::utils::token > &  t) const
protected

parse 2d vector

Definition at line 43 of file obj_reader.cxx.

References cgv::utils::is_double().

◆ parse_vec3()

template<typename T >
obj_reader_generic< T >::vec3_type cgv::media::mesh::obj_reader_generic< T >::parse_vec3 ( const std::vector< cgv::utils::token > &  t) const
protected

parse 3d vector

Definition at line 53 of file obj_reader.cxx.

References cgv::utils::is_double().

◆ process_normal()

template<typename T >
void cgv::media::mesh::obj_reader_generic< T >::process_normal ( const vec3_type n)
protectedvirtual

overide this function to process a normal

Reimplemented in cgv::media::mesh::obj_loader_generic< T >, and cgv::media::mesh::simple_mesh_obj_reader< T >.

Definition at line 128 of file obj_reader.cxx.

◆ process_texcoord()

template<typename T >
void cgv::media::mesh::obj_reader_generic< T >::process_texcoord ( const vec2_type t)
protectedvirtual

overide this function to process a texcoord

Reimplemented in cgv::media::mesh::obj_loader_generic< T >, and cgv::media::mesh::simple_mesh_obj_reader< T >.

Definition at line 122 of file obj_reader.cxx.

◆ process_vertex()

template<typename T >
void cgv::media::mesh::obj_reader_generic< T >::process_vertex ( const vec3_type p)
protectedvirtual

overide this function to process a vertex

Reimplemented in cgv::media::mesh::obj_loader_generic< T >, and cgv::media::mesh::simple_mesh_obj_reader< T >.

Definition at line 116 of file obj_reader.cxx.


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