37 #ifndef AIMS_SURFACE_SURFACE_H
38 #define AIMS_SURFACE_SURFACE_H
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; }
136 return !( *
this == s );
141 std::ostream& operator << <>( std::ostream& out,
147 template <
int D,
class T>
inline
150 float xmini=1e38,ymini=1e38,zmini=1e38;
152 std::vector<Point3df>::const_iterator it;
153 for (it=_vertex.begin();it!=_vertex.end();it++)
154 {
if (it->item(0) < xmini) xmini = it->item(0);
155 if (it->item(1) < ymini) ymini = it->item(1);
156 if (it->item(2) < zmini) zmini = it->item(2);
158 _mini =
Point3df(xmini,ymini,zmini);
162 template <
int D,
class T>
inline
165 float xmaxi=-1e38,ymaxi=-1e38,zmaxi=-1e38;
167 std::vector<Point3df>::const_iterator it;
168 for (it=_vertex.begin();it!=_vertex.end();it++)
169 {
if (it->item(0) > xmaxi) xmaxi = it->item(0);
170 if (it->item(1) > ymaxi) ymaxi = it->item(1);
171 if (it->item(2) > zmaxi) zmaxi = it->item(2);
173 _maxi =
Point3df(xmaxi,ymaxi,zmaxi);
177 template <
int D,
class T>
inline
180 _vertex.erase( _vertex.begin() , _vertex.end() );
181 _normal.erase( _normal.begin() , _normal.end() );
182 _texture.erase( _texture.begin() , _texture.end() );
183 _polygon.erase( _polygon.begin() , _polygon.end() );
187 template <
int D,
class T>
inline
199 std::vector< Point3df >::size_type nVert=_vertex.size();
200 Polygons::size_type nPoly=_polygon.size();
201 std::vector<std::set<uint> > polyVert(_vertex.size());
204 if (_normal.size() != nVert)
205 _normal.resize(nVert);
208 for (i=0; i<nPoly; ++i)
209 for (Polygons::size_type j=0; j<3; j++)
210 polyVert[_polygon[i][j]].insert(i);
213 for (i=0; i<nVert; ++i)
216 std::set<uint>::const_iterator it;
217 for (it= polyVert[i].begin(); it != polyVert[i].end(); it++)
222 (_vertex[_polygon[(*it)][1]]-_vertex[_polygon[(*it)][0]]),
223 (_vertex[_polygon[(*it)][2]]-_vertex[_polygon[(*it)][0]]) ) * 0.5F;
235 std::vector< Point3df >::size_type nVert=_vertex.size();
236 Polygons::size_type nPoly=_polygon.size();
237 std::vector<std::pair<std::set<uint>, std::set<uint> > >
238 polyVert(_vertex.size());
241 if( _normal.size() != nVert )
242 _normal.resize( nVert );
245 for( i=0; i<nPoly; ++i )
247 polyVert[_polygon[i][0]].first.insert(i);
248 polyVert[_polygon[i][1]].first.insert(i);
249 polyVert[_polygon[i][2]].first.insert(i);
250 polyVert[_polygon[i][0]].second.insert(i);
251 polyVert[_polygon[i][2]].second.insert(i);
252 polyVert[_polygon[i][3]].second.insert(i);
256 for( i=0; i<nVert; ++i )
260 std::set<uint>::const_iterator it;
261 const std::pair<std::set<uint>, std::set<uint> > & polySet = polyVert[i];
262 for( it=polySet.first.begin(); it != polySet.first.end(); ++it )
267 (_vertex[_polygon[(*it)][1]]-_vertex[_polygon[(*it)][0]]),
268 (_vertex[_polygon[(*it)][2]]-_vertex[_polygon[(*it)][0]]) ) * 0.5F;
270 for( it=polySet.second.begin(); it != polySet.second.end(); ++it )
275 (_vertex[_polygon[(*it)][2]]-_vertex[_polygon[(*it)][0]]),
276 (_vertex[_polygon[(*it)][3]]-_vertex[_polygon[(*it)][0]]) ) * 0.5F;
284 template <
int D,
class T>
inline
287 out <<
"{D=" << D <<
","
288 <<
"vertex=" << thing.
vertex().size() <<
","
289 <<
"normal=" << thing.
normal().size() <<
","
290 <<
"texture=" << thing.
texture().size() <<
","
291 <<
"polygon=" << thing.
polygon().size() <<
"}";
314 template <
int D,
class T>
316 :
public virtual carto::RCObject,
public std::map< int, AimsSurface<D,T> >
344 const std::vector<Point3df>&
vertex()
const
347 std::vector<Point3df>&
vertex() {
return (*
this)[0].vertex(); }
350 const std::vector<Point3df>&
normal()
const
353 std::vector<Point3df>&
normal() {
return (*
this)[0].normal(); }
359 std::vector<T>&
texture() {
return (*
this)[0].texture(); }
362 const std::vector< AimsVector<uint,D> >&
polygon()
const
366 {
return (*
this)[0].polygon(); }
387 return !( *
this == other );
392 std::ostream& operator << <>( std::ostream& out,
408 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
432 {
return "Segments"; }
468 template <
int D,
class T>
inline
472 float xmini=1e38,ymini=1e38,zmini=1e38;
475 for (it=this->begin();it!=this->end();it++)
476 { ((*it).second).setMini();
477 tmp = ((*it).second).minimum();
478 if (tmp.
item(0) < xmini) xmini = tmp.
item(0);
479 if (tmp.
item(1) < ymini) ymini = tmp.
item(1);
480 if (tmp.
item(2) < zmini) zmini = tmp.
item(2);
482 _mini =
Point3df(xmini,ymini,zmini);
486 template <
int D,
class T>
inline
490 float xmaxi=-1e38,ymaxi=-1e38,zmaxi=-1e38;
493 for (it=this->begin();it!=this->end();it++)
494 { ((*it).second).setMaxi();
495 tmp = ((*it).second).maximum();
496 if (tmp.
item(0) > xmaxi) xmaxi = tmp.
item(0);
497 if (tmp.
item(1) > ymaxi) ymaxi = tmp.
item(1);
498 if (tmp.
item(2) > zmaxi) zmaxi = tmp.
item(2);
500 _maxi =
Point3df(xmaxi,ymaxi,zmaxi);
504 template <
int D,
class T>
inline
508 for (it=this->begin();it!=this->end();it++)
509 ((*it).second).erase();
510 std::map< int, AimsSurface<D,T> >::erase( this->begin(), this->end() );
513 template <
int D,
class T>
inline
525 for (it=this->begin();it!=this->end();it++)
526 ((*it).second).updateNormals();
534 for (it=this->begin();it!=this->end();it++)
535 ((*it).second).updateNormals();
539 template <
int D,
typename T>
inline
543 if( this->size() != other.size() )
545 if( header() != other.
header() )
548 for( i=this->begin(), j=other.begin(); i!=e; ++i, ++j )
550 if( i->first != j->first )
552 if( i->second != j->second )
559 template <
int D,
class T>
inline
567 for (it=thing.begin();it!=thing.end();it++)
569 out <<
"t=" << (*it).first <<
",";
570 out << (*it).second <<
"},";
573 return out <<
"NULL}" << std::flush;
594 #define _mesh_type AimsTimeSurface<2, float>
598 #define _mesh_type AimsTimeSurface<3, float>
602 #define _mesh_type AimsTimeSurface<4, float>
606 #define _mesh_type AimsTimeSurface<2, Point2df>
610 #define _mesh_type AimsTimeSurface<3, Point2df>
614 #define _mesh_type AimsTimeSurface<4, Point2df>
The template class to manage a mesh.
Point3df maximum() const
Get the superior point of the box containing the mesh.
AimsSurface()
Constructor does nothing special.
std::vector< AimsVector< uint, D > > & polygon()
Get a non const reference to the vector of polygons.
void erase()
Clear the mesh.
const std::vector< Point3df > & normal() const
Get a const reference to the vector of normals.
std::vector< Point3df > _normal
Vector of normals.
std::vector< Point3df > & normal()
Get a non const reference to the vector of normals.
virtual ~AimsSurface()
Destructor does nothing.
void setMaxi()
Calculate the superior point of the box containing the mesh.
Point3df _mini
Inferior point of a box containing the whole mesh in the 3D space.
std::vector< Point3df > _vertex
Vector of vertices.
const std::vector< Point3df > & vertex() const
Get a const reference to the vector of vertices.
void updateNormals()
Update/Compute the normals.
Point3df minimum() const
Get the inferior point of the box containing the mesh.
Point3df _maxi
Superior point of a box containing the whole mesh in the 3D space.
std::vector< Point3df > & vertex()
Get a non const reference to the vector of verteces.
void setMini()
Calculate the inferior point of the box containing the mesh.
std::vector< T > _texture
Vector of textures.
const std::vector< T > & texture() const
Get a const reference to the vector of textures.
std::vector< T > & texture()
Get a non const reference to the vector of textures.
const std::vector< AimsVector< uint, D > > & polygon() const
Get a const reference to the vector of polygons.
std::vector< AimsVector< uint, D > > Polygons
Vector of polygons.
The template class to manage a mesh with time if needed.
Point3df minimum() const
Get the inferior point of the box containing all the meshes.
void erase()
Clear all the meshes.
Point3df maximum() const
Get the superior point of the box containing all the meshes.
bool operator==(const AimsTimeSurface< D, T > &) const
void setHeader(const aims::PythonHeader &hdr)
Set the header.
aims::PythonHeader _header
Header.
const std::vector< AimsVector< uint, D > > & polygon() const
Get a const reference to the vector of polygons of the 0 surface.
std::vector< T > & texture()
Get a non const reference to the vector of textures of the 0 surface.
std::vector< Point3df > & normal()
Get a non const reference to the vector of normals of the 0 surface.
const std::vector< T > & texture() const
Get a const reference to the vector of textures of the 0 surface.
std::map< int, AimsSurface< D, T > >::iterator iterator
virtual ~AimsTimeSurface()
Destructor does nothing.
const aims::PythonHeader & header() const
Get the header.
std::map< int, AimsSurface< D, T > >::const_iterator const_iterator
std::vector< Point3df > & vertex()
Get a non const reference to the vector of verteces of the 0 surface.
aims::PythonHeader & header()
void setMini()
Calculates the inferior point of the box containing all the meshes.
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.
Point3df _maxi
Inferior point of the box containing all the meshes.
std::vector< AimsVector< uint, D > > & polygon()
Get a non const reference to the vector of polygons of the 0 surface.
void setMaxi()
Calculates the superior point of the box containing all the meshes.
AimsTimeSurface()
Constructor does nothing special.
const std::vector< Point3df > & vertex() const
Get a const reference to the vector of verteces of the surface of index 0.
Point3df _mini
Inferior point of the box containing all the meshes.
const T & item(int d) const
static std::string objectType()
static std::string name()
static std::string dataType()
static std::string name()
static std::string dataType()
static std::string objectType()
static std::string dataType()
static std::string name()
static std::string objectType()
int operator==(const AimsBucketItem< T > &thing1, const AimsBucketItem< T > &thing2)
#define DECLARE_GENERIC_OBJECT_TYPE(T)
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle
AIMSDATA_API std::ostream & operator<<(std::ostream &out, const AimsSurface< D, T > &thing)
AIMSDATA_API AimsTimeSurface< 2, Void > AimsSegments
AIMSDATA_API AimsTimeSurface< 4, Void > AimsSurfaceFacet
AIMSDATA_API float norm(const Tensor &thing)
AimsVector< T, 3 > crossed(const AimsVector< T, D > &v1, const AimsVector< T, D > &v2)