ParserNS::Parser< V, F, C > Class Template Reference

Load a file in .xml.bz2 format. More...

#include <parser.h>

Inheritance diagram for ParserNS::Parser< V, F, C >:

Inheritance graph
[legend]
Collaboration diagram for ParserNS::Parser< V, F, C >:

Collaboration graph
[legend]

Public Types

enum  Mode { Immediate, Callback, Progressive }
 Indicate the mode to use while parsing. More...

Public Member Functions

 Parser (std::string path, Parser::Mode mode)
 Create a parser loading the file 'path' and using the mode 'mode'.
void parse ()
 parse the input file
Exceptions:
ParserException 

void write (const MeshSequenceType &type, const int &frame, const C< C< V > > &verts, const C< C< F > > &faces)
int getNbFrame () const
MeshSequenceType getMSType () const
const C< C< V > > & getVerticesInTime () const
const C< C< F > > & getFacesInTime () const
C
< SegmentationNS::SegmentationPtr > 
getSegmentation ()
void setSegmentation (const C< SegmentationNS::SegmentationPtr > &seg)
void setMeshSequence (MeshNS::MeshSequencePtr ms)
MeshNS::PolyhedronPtr getNext ()

Detailed Description

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
class ParserNS::Parser< V, F, C >

Load a file in .xml.bz2 format.

Template Parameters:
V the type of vertex : should have the &operator[] method, and &x(), &y(), &z() methods.
F the type of face : should have push_back method.
C container used to store F and V and the segmentation. should have a push_back method default is std::vector.
This class loads a file in xml.bz2 format. The parser can work in immediate mode or with callback (not done).

The class is used in normal mode like that: Parser<V,F> parser(path); parser.parse() vector<vector<V> > verts= parser.getVertices(); vector<vector<F> > faces= parser.getVertices(); vector<Segmentation*> segmentations=parser.getSegmentations(); do everything you wants with verts, faces and segmentations.

The parser can also write file. Writing can only be done in immediate mode for now.

Warning:
callback mode is not implemented now.

segmentation are always loaded in immediate mode

Todo:
add progressive loading Parser<V,F> parser(path); // file will be written in path // if segementation has to be written, setSegmentation has to called before write parser.setSegmentation(segmentations); parser.write(meshsequencetype, numberofframe, verts,faces);

Member Enumeration Documentation

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
enum ParserNS::Parser::Mode

Indicate the mode to use while parsing.

Possible values :

  • Immediate (load all the mesh on a vector) : easier to handle
  • Callback (add verts and face into the mesh ad they are read): more efficient (both speed and memory) but harder to handle
  • Progressive : return a Mesh::Mesh as it read


Constructor & Destructor Documentation

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
ParserNS::Parser< V, F, C >::Parser ( std::string  path,
Parser< V, F, C >::Mode  mode 
) [inline]

Create a parser loading the file 'path' and using the mode 'mode'.

Parameters:
path,: the file to load
mode,: the mode to use either Parser::Immediate or Parser::Progressive and Parser::Callback, please note that only Immediate is done and Callback


Member Function Documentation

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
void Parser::write ( const MeshSequenceType type,
const int &  frame,
const C< C< V > > &  verts,
const C< C< F > > &  faces 
) [inline]

Parameters:
type : mesh sequence type
See also:
MeshSequenceType
Parameters:
frame : number of frames
verts : contains the verts of all the mesh in the sequence
faces : contains the faces of all the mesh in the sequence
Exceptions:
ParserException 
Todo:
add details !!

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
int ParserNS::Parser< V, F, C >::getNbFrame (  )  const [inline]

Returns:
the number of frame in the sequence
Precondition:
parse should have been called !

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
MeshSequenceType ParserNS::Parser< V, F, C >::getMSType (  )  const [inline]

Returns:
the type of mesh sequence loaded
Precondition:
parse should have been called !

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
const C<C<V> >& ParserNS::Parser< V, F, C >::getVerticesInTime (  )  const [inline]

Returns:
the vertices loaded
Precondition:
parse should have been called !

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
const C<C<F> >& ParserNS::Parser< V, F, C >::getFacesInTime (  )  const [inline]

Returns:
the faces loaded
Precondition:
parse should have been called !

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
C<SegmentationNS::SegmentationPtr> ParserNS::Parser< V, F, C >::getSegmentation (  )  [inline]

Returns:
all the segmentation loaded
Precondition:
parse should have been called !

template<class V, class F, template< class U, class V=std::allocator< U > > class C>
void ParserNS::Parser< V, F, C >::setSegmentation ( const C< SegmentationNS::SegmentationPtr > &  seg  )  [inline]

Parameters:
seg : all the segmentation which have to be written
Warning:
should be valled before write if user wants to write segmentations in the file


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

Generated on Fri Jan 16 13:05:55 2009 by  doxygen 1.5.5