37#ifndef AIMS_SURFACE_SURFACE_H
38#define AIMS_SURFACE_SURFACE_H
41#include <cartobase/smart/rcptr.h>
67template <
int D,
class T>
78 typedef std::vector< AimsVector< uint, D > >
Polygons;
108 const std::vector< AimsVector<uint,D> >&
polygon()
const
136 return !( *
this == s );
141 std::ostream& operator << <>( std::ostream& out,
147template <
int D,
class T>
inline
150 float xmini=1e38,ymini=1e38,zmini=1e38;
152 std::vector<Point3df>::const_iterator 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);
162template <
int D,
class T>
inline
165 float xmaxi=-1e38,ymaxi=-1e38,zmaxi=-1e38;
167 std::vector<Point3df>::const_iterator 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);
177template <
int D,
class T>
inline
187template <
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());
208 for (i=0; i<nPoly; ++i)
209 for (Polygons::size_type j=0; j<3; j++)
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++)
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> > >
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 )
270 for( it=polySet.second.begin(); it != polySet.second.end(); ++it )
284template <
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() <<
"}";
314template <
int D,
class T>
316 :
public virtual carto::RCObject,
public std::map< int, AimsSurface<D,T> >
348 const std::vector<Point3df>&
vertex()
const
351 std::vector<Point3df>&
vertex() {
return (*
this)[0].vertex(); }
354 const std::vector<Point3df>&
normal()
const
357 std::vector<Point3df>&
normal() {
return (*
this)[0].normal(); }
363 std::vector<T>&
texture() {
return (*
this)[0].texture(); }
366 const std::vector< AimsVector<uint,D> >&
polygon()
const
370 {
return (*
this)[0].polygon(); }
391 return !( *
this == other );
396 std::map<int, AimsSurface<D, T> >::operator = ( other );
406 std::ostream& operator << <>( std::ostream& out,
422#ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
446 {
return "Segments"; }
482template <
int D,
class T>
inline
486 float xmini=1e38,ymini=1e38,zmini=1e38;
489 for (it=this->begin();it!=this->end();it++)
491 tmp = ((*it).second).
minimum();
492 if (tmp.
item(0) < xmini) xmini = tmp.
item(0);
493 if (tmp.
item(1) < ymini) ymini = tmp.
item(1);
494 if (tmp.
item(2) < zmini) zmini = tmp.
item(2);
500template <
int D,
class T>
inline
504 float xmaxi=-1e38,ymaxi=-1e38,zmaxi=-1e38;
507 for (it=this->begin();it!=this->end();it++)
509 tmp = ((*it).second).
maximum();
510 if (tmp.
item(0) > xmaxi) xmaxi = tmp.
item(0);
511 if (tmp.
item(1) > ymaxi) ymaxi = tmp.
item(1);
512 if (tmp.
item(2) > zmaxi) zmaxi = tmp.
item(2);
518template <
int D,
class T>
inline
522 for (it=this->begin();it!=this->end();it++)
523 ((*it).second).erase();
524 std::map< int, AimsSurface<D,T> >
::erase( this->begin(), this->end() );
527template <
int D,
class T>
inline
539 for (it=this->begin();it!=this->end();it++)
540 ((*it).second).updateNormals();
548 for (it=this->begin();it!=this->end();it++)
549 ((*it).second).updateNormals();
553template <
int D,
typename T>
inline
557 if( this->size() != other.size() )
562 for( i=this->begin(), j=other.begin(); i!=e; ++i, ++j )
564 if( i->first != j->first )
566 if( i->second != j->second )
573template <
int D,
class T>
inline
581 for (it=thing.begin();it!=thing.end();it++)
583 out <<
"t=" << (*it).first <<
",";
584 out << (*it).second <<
"},";
587 return out <<
"NULL}" << std::flush;
608#define _mesh_type AimsTimeSurface<2, float>
612#define _mesh_type AimsTimeSurface<3, float>
616#define _mesh_type AimsTimeSurface<4, float>
620#define _mesh_type AimsTimeSurface<2, Point2df>
624#define _mesh_type AimsTimeSurface<3, Point2df>
628#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.
const std::vector< Point3df > & normal() const
Get a const reference to the vector of normals.
void erase()
Clear the mesh.
std::vector< Point3df > _normal
virtual ~AimsSurface()
Destructor does nothing.
void setMaxi()
Calculate the superior point of the box containing the mesh.
const std::vector< AimsVector< uint, D > > & polygon() const
Get a const reference to the vector of polygons.
std::vector< Point3df > _vertex
std::vector< T > & texture()
Get a non const reference to the vector of textures.
std::vector< Point3df > & normal()
Get a non const reference to the vector of normals.
void updateNormals()
Update/Compute the normals.
Point3df minimum() const
Get the inferior point of the box containing the mesh.
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< Void > _texture
const std::vector< T > & texture() const
Get a const reference to the vector of textures.
const std::vector< Point3df > & vertex() const
Get a const reference to the vector of vertices.
std::vector< AimsVector< uint, D > > Polygons
std::vector< AimsVector< uint, D > > & polygon()
Get a non const reference to the 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.
const aims::PythonHeader & header() const
Get the header.
aims::PythonHeader _header
std::map< int, AimsSurface< D, Void > >::const_iterator const_iterator
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 of the 0 surface.
std::vector< T > & texture()
Get a non const reference to the vector of textures of the 0 surface.
virtual ~AimsTimeSurface()
Destructor does nothing.
const std::vector< T > & texture() const
Get a const reference to the vector of textures of the 0 surface.
std::map< int, AimsSurface< D, Void > >::iterator iterator
void setMini()
Calculates the inferior point of the box containing all the meshes.
void updateNormals()
Update/Compute the normals.
AimsTimeSurface(const AimsTimeSurface< D, T > &other)
std::vector< AimsVector< uint, D > > & polygon()
Get a non const reference to the vector of polygons of the 0 surface.
std::vector< Point3df > & vertex()
Get a non const reference to the vector of verteces of the 0 surface.
void setMaxi()
Calculates the superior point of the box containing all the meshes.
std::vector< Point3df > & normal()
Get a non const reference to the vector of normals of the 0 surface.
aims::PythonHeader & header()
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.
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()
#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
AimsVector< float, 3 > Point3df
AimsVector< T, 3 > crossed(const AimsVector< T, D > &v1, const AimsVector< T, D > &v2)
float norm(const AimsVector< T, D > &v1)