37 #ifndef AIMS_SURFACE_SURFACE_H 38 #define AIMS_SURFACE_SURFACE_H 59 std::ostream& operator << ( std::ostream& out, const AimsSurface<D,T>& thing);
67 template <
int D,
class T>
78 typedef std::vector< AimsVector< uint, D > >
Polygons;
93 const std::vector<Point3df>&
vertex()
const {
return _vertex; }
95 std::vector<Point3df>&
vertex() {
return _vertex; }
98 const std::vector<Point3df>&
normal()
const {
return _normal; }
100 std::vector<Point3df>&
normal() {
return _normal; }
103 const std::vector<T>&
texture()
const {
return _texture; }
105 std::vector<T>&
texture() {
return _texture; }
108 const std::vector< AimsVector<uint,D> >&
polygon()
const 111 std::vector< AimsVector<uint,D> >&
polygon() {
return _polygon; }
119 inline void setMini();
121 inline void setMaxi();
127 inline void updateNormals();
131 std::ostream& operator << <>( std::ostream& out,
136 template <
int D,
class T>
inline 139 float xmini=1e38,ymini=1e38,zmini=1e38;
141 std::vector<Point3df>::const_iterator it;
142 for (it=_vertex.begin();it!=_vertex.end();it++)
143 {
if (it->item(0) < xmini) xmini = it->item(0);
144 if (it->item(1) < ymini) ymini = it->item(1);
145 if (it->item(2) < zmini) zmini = it->item(2);
147 _mini =
Point3df(xmini,ymini,zmini);
151 template <
int D,
class T>
inline 154 float xmaxi=-1e38,ymaxi=-1e38,zmaxi=-1e38;
156 std::vector<Point3df>::const_iterator it;
157 for (it=_vertex.begin();it!=_vertex.end();it++)
158 {
if (it->item(0) > xmaxi) xmaxi = it->item(0);
159 if (it->item(1) > ymaxi) ymaxi = it->item(1);
160 if (it->item(2) > zmaxi) zmaxi = it->item(2);
162 _maxi =
Point3df(xmaxi,ymaxi,zmaxi);
166 template <
int D,
class T>
inline 169 _vertex.erase( _vertex.begin() , _vertex.end() );
170 _normal.erase( _normal.begin() , _normal.end() );
171 _texture.erase( _texture.begin() , _texture.end() );
172 _polygon.erase( _polygon.begin() , _polygon.end() );
176 template <
int D,
class T>
inline 188 std::vector< Point3df >::size_type nVert=_vertex.size();
189 Polygons::size_type nPoly=_polygon.size();
190 std::vector<std::set<uint> > polyVert(_vertex.size());
193 if (_normal.size() != nVert)
194 _normal.resize(nVert);
197 for (i=0; i<nPoly; ++i)
198 for (Polygons::size_type j=0; j<3; j++)
199 polyVert[_polygon[i][j]].insert(i);
202 for (i=0; i<nVert; ++i)
205 std::set<uint>::const_iterator it;
206 for (it= polyVert[i].begin(); it != polyVert[i].end(); it++)
211 (_vertex[_polygon[(*it)][1]]-_vertex[_polygon[(*it)][0]]),
212 (_vertex[_polygon[(*it)][2]]-_vertex[_polygon[(*it)][0]]) ) * 0.5F;
224 std::vector< Point3df >::size_type nVert=_vertex.size();
225 Polygons::size_type nPoly=_polygon.size();
226 std::vector<std::pair<std::set<uint>, std::set<uint> > >
227 polyVert(_vertex.size());
230 if( _normal.size() != nVert )
231 _normal.resize( nVert );
234 for( i=0; i<nPoly; ++i )
236 polyVert[_polygon[i][0]].first.insert(i);
237 polyVert[_polygon[i][1]].first.insert(i);
238 polyVert[_polygon[i][2]].first.insert(i);
239 polyVert[_polygon[i][0]].second.insert(i);
240 polyVert[_polygon[i][2]].second.insert(i);
241 polyVert[_polygon[i][3]].second.insert(i);
245 for( i=0; i<nVert; ++i )
249 std::set<uint>::const_iterator it;
250 const std::pair<std::set<uint>, std::set<uint> > & polySet = polyVert[i];
251 for( it=polySet.first.begin(); it != polySet.first.end(); ++it )
256 (_vertex[_polygon[(*it)][1]]-_vertex[_polygon[(*it)][0]]),
257 (_vertex[_polygon[(*it)][2]]-_vertex[_polygon[(*it)][0]]) ) * 0.5F;
259 for( it=polySet.second.begin(); it != polySet.second.end(); ++it )
264 (_vertex[_polygon[(*it)][2]]-_vertex[_polygon[(*it)][0]]),
265 (_vertex[_polygon[(*it)][3]]-_vertex[_polygon[(*it)][0]]) ) * 0.5F;
273 template <
int D,
class T>
inline 274 std::ostream& operator << (std::ostream& out,const AimsSurface<D,T>& thing)
276 out <<
"{D=" << D <<
"," 277 <<
"vertex=" << thing.vertex().size() <<
"," 278 <<
"normal=" << thing.normal().size() <<
"," 279 <<
"texture=" << thing.texture().size() <<
"," 280 <<
"polygon=" << thing.polygon().size() <<
"}";
303 template <
int D,
class T>
305 :
public virtual carto::RCObject,
public std::map< int, AimsSurface<D,T> >
335 const std::vector<Point3df>&
vertex()
const 338 std::vector<Point3df>&
vertex() {
return (*
this)[0].vertex(); }
341 const std::vector<Point3df>&
normal()
const 344 std::vector<Point3df>&
normal() {
return (*
this)[0].normal(); }
350 std::vector<T>&
texture() {
return (*
this)[0].texture(); }
353 const std::vector< AimsVector<uint,D> >&
polygon()
const 357 {
return (*
this)[0].polygon(); }
365 inline void setMini();
367 inline void setMaxi();
373 inline void updateNormals();
377 std::ostream& operator << <>( std::ostream& out,
394 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES 418 {
return "Segments"; }
451 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES 454 template <
int D,
class T>
inline 458 float xmini=1e38,ymini=1e38,zmini=1e38;
461 for (it=this->begin();it!=this->end();it++)
462 { ((*it).second).setMini();
463 tmp = ((*it).second).minimum();
464 if (tmp.
item(0) < xmini) xmini = tmp.
item(0);
465 if (tmp.
item(1) < ymini) ymini = tmp.
item(1);
466 if (tmp.
item(2) < zmini) zmini = tmp.
item(2);
468 _mini =
Point3df(xmini,ymini,zmini);
472 template <
int D,
class T>
inline 476 float xmaxi=-1e38,ymaxi=-1e38,zmaxi=-1e38;
479 for (it=this->begin();it!=this->end();it++)
480 { ((*it).second).setMaxi();
481 tmp = ((*it).second).maximum();
482 if (tmp.
item(0) > xmaxi) xmaxi = tmp.
item(0);
483 if (tmp.
item(1) > ymaxi) ymaxi = tmp.
item(1);
484 if (tmp.
item(2) > zmaxi) zmaxi = tmp.
item(2);
486 _maxi =
Point3df(xmaxi,ymaxi,zmaxi);
490 template <
int D,
class T>
inline 494 for (it=this->begin();it!=this->end();it++)
495 ((*it).second).erase();
496 std::map< int, AimsSurface<D,T> >::erase( this->begin(), this->end() );
499 template <
int D,
class T>
inline 511 for (it=this->begin();it!=this->end();it++)
512 ((*it).second).updateNormals();
520 for (it=this->begin();it!=this->end();it++)
521 ((*it).second).updateNormals();
525 template <
int D,
class T>
inline 533 for (it=thing.begin();it!=thing.end();it++)
535 out <<
"t=" << (*it).first <<
",";
536 out << (*it).second <<
"},";
539 return out <<
"NULL}" << std::flush;
560 #define _mesh_type AimsTimeSurface<2, float> 564 #define _mesh_type AimsTimeSurface<3, float> 568 #define _mesh_type AimsTimeSurface<4, float> 572 #define _mesh_type AimsTimeSurface<2, Point2df> 576 #define _mesh_type AimsTimeSurface<3, Point2df> 580 #define _mesh_type AimsTimeSurface<4, Point2df> #define DECLARE_GENERIC_OBJECT_TYPE(T)
Point3df maximum() const
Get the superior point of the box containing the mesh.
void setMini()
Calculates the inferior point of the box containing all the meshes.
static std::string dataType()
static std::string dataType()
void setMaxi()
Calculates the superior point of the box containing all the meshes.
void setMaxi()
Calculate the superior point of the box containing the mesh.
static std::string objectType()
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle
AIMSDATA_API AimsTimeSurface< 4, Void > AimsSurfaceFacet
void erase()
Clear the mesh.
static std::string objectType()
Point3df minimum() const
Get the inferior point of the box containing all the meshes.
AIMSDATA_API AimsTimeSurface< 2, Void > AimsSegments
const std::vector< Point3df > & vertex() const
Get a const reference to the vector of vertices.
static std::string name()
AimsVector< T, 3 > crossed(const AimsVector< T, D > &v1, const AimsVector< T, D > &v2)
std::vector< AimsVector< uint, D > > & polygon()
Get a non const reference to the vector of polygons of the 0 surface.
std::map< int, AimsSurface< D, Void > >::iterator iterator
The template class to manage a mesh with time if needed.
AimsSurface()
Constructor does nothing special.
static std::string dataType()
std::vector< T > _texture
Vector of textures.
const std::vector< T > & texture() const
Get a const reference to the vector of textures of the 0 surface.
std::vector< AimsVector< uint, D > > & polygon()
Get a non const reference to the vector of polygons.
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< AimsVector< uint, D > > & polygon() const
Get a const reference to the vector of polygons.
static std::string objectType()
std::vector< Point3df > & normal()
Get a non const reference to the vector of normals of the 0 surface.
std::vector< Point3df > _normal
Vector of normals.
std::vector< Point3df > & vertex()
Get a non const reference to the vector of verteces.
static std::string name()
Point3df _maxi
Inferior point of the box containing all the meshes.
Point3df maximum() const
Get the superior point of the box containing all the meshes.
std::vector< T > & texture()
Get a non const reference to the vector of textures of the 0 surface.
const std::vector< T > & texture() const
Get a const reference to the vector of textures.
std::vector< Point3df > & vertex()
Get a non const reference to the vector of verteces of the 0 surface.
void updateNormals()
Update/Compute the normals.
The template class to manage a mesh.
virtual ~AimsSurface()
Destructor does nothing.
AIMSDATA_API std::ostream & operator<<(std::ostream &out, const AimsSurface< D, T > &thing)
aims::PythonHeader & header()
Point3df _mini
Inferior point of a box containing the whole mesh in the 3D space.
Point3df _maxi
Superior point of a box containing the whole mesh in the 3D space.
std::vector< T > & texture()
Get a non const reference to the vector of textures.
Point3df minimum() const
Get the inferior point of the box containing the mesh.
const std::vector< Point3df > & vertex() const
Get a const reference to the vector of verteces of the surface of index 0.
static std::string name()
virtual ~AimsTimeSurface()
Destructor does nothing.
AIMSDATA_API float norm(const Tensor &thing)
Point3df _mini
Inferior point of the box containing all the meshes.
std::vector< Point3df > & normal()
Get a non const reference to the vector of normals.
std::map< int, AimsSurface< D, Void > >::const_iterator const_iterator
AimsTimeSurface()
Constructor does nothing special.
void setMini()
Calculate the inferior point of the box containing the mesh.
void setHeader(const aims::PythonHeader &hdr)
Set the header.
std::vector< AimsVector< uint, D > > Polygons
Vector of polygons.
const T & item(int d) const
void erase()
Clear all the meshes.
std::vector< Point3df > _vertex
Vector of vertices.
const aims::PythonHeader & header() const
Get the header.
const std::vector< Point3df > & normal() const
Get a const reference to the vector of normals.