37 #ifndef AIMS_IO_MESHR_H 
   38 #define AIMS_IO_MESHR_H 
   57   template<
int D, 
class T=Vo
id>
 
   62       : _name( name ), _itemr( ir ) { }
 
   70       { 
delete _itemr; _itemr = ir; }
 
   78   template <
int D, 
class T>
 
   88   template <
int D, 
class T> 
inline  
   91     std::string res = name;
 
   93     if ( res.length() > 5 )
 
   94       ext = res.substr( 
int(res.length() - 5), 5 );
 
   96       res = res.substr( 0, res.length() - 5 );
 
  101   template <
int D, 
class T> 
inline 
  106       std::cerr << 
"Warning : .mesh single frame reading not implemented yet "  
  107                 << 
"-\nreading whole mesh\n";
 
  111     if ( !hdr.
read( &buf ) )
 
  117       std::stringstream msg;
 
  118       msg << 
"Wrong polygon dimension, " << polydim << 
", should be " << D 
 
  122     std::ifstream::off_type offset = buf; 
 
  124     std::ios::openmode  omd = std::ios::in;
 
  126       omd |= std::ios::binary;
 
  127     std::ifstream       is( hdr.
filename().c_str(), omd );
 
  128     is.unsetf( std::ios::skipws );
 
  136       is.setf( std::ios::skipws );
 
  155     typename std::vector<AimsVector<uint,D> >::iterator ip;
 
  159     uint32_t time, nvertex, nnormal, ntexture, npolygon;
 
  160     for ( 
int t=0; t<size; ++t )
 
  163         sr->
read( is, time );
 
  166         sr->
read( is, nvertex );
 
  170         std::vector<Point3df>   & vert = surf.
vertex();
 
  171         vert.insert( vert.end(), nvertex, 
Point3df() );
 
  172         pr->
read( is, &vert[0], nvertex );
 
  175         sr->
read( is, nnormal );
 
  181         sr->
read( is, ntexture );
 
  182         std::vector<T>  & tex = surf.
texture();
 
  183         tex.insert( tex.end(), ntexture, T() );
 
  184         ir->
read( is, &tex[0], ntexture );
 
  187         sr->
read( is, npolygon );
 
  188         std::vector<AimsVector<uint,D> >  & poly = surf.
polygon();
 
  190         plr->
read( is, &poly[0], npolygon );
 
  193         for ( ip=poly.begin(); ip!=poly.end(); ++ip )
 
  196             for ( 
int j=0; j<D; ++j )
 
  197               if ( pol[j] >= nvertex )
 
  202                       std::cerr << 
"Broken mesh: polygon pointing to a "  
  203                                 << 
"vertex out of range" << std::endl;
 
  211         if ( 
norm.size() != vert.size() )
 
The template class to manage a mesh.
const std::vector< Point3df > & normal() const
Get a const reference to the vector of normals.
const std::vector< Point3df > & vertex() const
Get a const reference to the vector of vertices.
void updateNormals()
Update/Compute the normals.
const std::vector< T > & texture() const
Get a const reference to the vector of textures.
const std::vector< AimsVector< uint, D > > & polygon() const
Get a const reference to the vector of polygons.
The template class to manage a mesh with time if needed.
void erase()
Clear all the meshes.
void setHeader(const aims::PythonHeader &hdr)
Set the header.
Default low-levels readers.
virtual ItemReader< T > * reader(const std::string &openmode="binar", bool bswap=false) const
Low-level "small item" reader, used by higher-level file readers.
virtual void read(std::istream &is, T &item) const
virtual ItemReader< T > * reader(const std::string &openmode="binar", bool bswap=false) const =0
Mesh format readers for mesh objects.
void setItemReader(ItemReader< T > *ir)
void read(AimsTimeSurface< D, T > &thing, int frame=-1)
MeshReader(const std::string &name, ItemReader< T > *ir=0)
std::string removeExtension(const std::string &name)
Return a name without .mesh extension.
virtual bool getProperty(const std::string &, Object &) const
static void launchErrnoExcept(const std::string &filename="")
The class for EcatSino data write operation.
GenesisReader< T > & operator>>(GenesisReader< T > &reader, AimsData< T > &thing)
AIMSDATA_API float norm(const Tensor &thing)