34 #ifndef AIMS_IO_PLYR_H
35 #define AIMS_IO_PLYR_H
53 template<
long D,
typename T>
57 PlyReader(
const std::string& name ) : _name( name ) {}
61 const carto::AllocatorContext & context,
73 template <
long D,
typename T>
74 inline PlyReader<D,T> &
77 reader.
read( thing, thing.allocator(),
83 template <
long D,
typename T>
96 mesh->begin()->second.
vertex().back()[n] = (float) x;
101 template <
long D,
typename T>
114 mesh->begin()->second.
normal().back()[n] = (float) x;
119 template <
long D,
typename T>
128 (*tex)[n].push_back( (
float) x );
133 template <
long D,
typename T>
136 long length, value_index;
142 if( value_index == 0 )
146 mesh->begin()->second.
polygon().push_back( v );
148 else if( value_index > 0 && value_index < D )
149 mesh->begin()->second.
polygon().back()[ value_index ]
151 else if( value_index > 0 )
152 std::cerr <<
"polygon with too many items: " << value_index <<
"\n";
157 template <
long D,
typename T>
160 const carto::AllocatorContext & ,
168 long nvertices, ntriangles;
175 nvertices =
ply_set_read_cb(ply,
"vertex",
"x", ply_vertex_cb, &thing, 0);
176 thing.
vertex().reserve( nvertices );
177 thing.
normal().reserve( nvertices );
194 tex->reserve( ntex );
197 for( i=0; i<ntex; ++i )
206 ntriangles =
ply_set_read_cb(ply,
"face",
"vertex_indices", ply_face_cb,
208 thing.
polygon().reserve( ntriangles );
215 std::vector<AimsVector<uint,D> > & poly = thing.
polygon();
216 typename std::vector<AimsVector<uint,D> >::iterator ip;
218 for ( ip=poly.begin(); ip!=poly.end(); ++ip )
221 for (
int j=0; j<D; ++j )
222 if ( pol[j] >= (
unsigned) nvertices )
227 std::cerr <<
"Broken mesh: polygon pointing to a "
228 <<
"vertex out of range" << std::endl;
229 std::cerr << pol[j] <<
" >= " << nvertices << std::endl;
The template class to manage a mesh with time if needed.
void setHeader(const aims::PythonHeader &hdr)
Set the header.
const std::vector< AimsVector< uint, D > > & polygon() const
Get a const reference to the vector of polygons of the 0 surface.
void updateNormals()
Update/Compute the normals.
const std::vector< Point3df > & normal() const
Get a const reference to the vector of normals of the 0 surface.
const std::vector< Point3df > & vertex() const
Get a const reference to the vector of verteces of the surface of index 0.
void read(AimsTimeSurface< D, T > &thing, const carto::AllocatorContext &context, carto::Object options)
PlyReader(const std::string &name)
virtual bool getProperty(const std::string &, Object &) const
virtual bool removeProperty(const std::string &)
virtual void setProperty(const std::string &, Object)
virtual bool hasProperty(const std::string &) const
The class for EcatSino data write operation.
GenesisReader< T > & operator>>(GenesisReader< T > &reader, AimsData< T > &thing)
std::vector< Object > ObjectVector
int ply_get_argument_user_data(p_ply_argument argument, void **pdata, long *idata)
long ply_set_read_cb(p_ply ply, const char *element_name, const char *property_name, p_ply_read_cb read_cb, void *pdata, long idata)
struct t_ply_argument_ * p_ply_argument
int ply_read_header(p_ply ply)
p_ply ply_open(const char *name, p_ply_error_cb error_cb, long idata, void *pdata)
int ply_get_argument_property(p_ply_argument argument, p_ply_property *property, long *length, long *value_index)
double ply_get_argument_value(p_ply_argument argument)