00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 # ifndef shape_graphic_hpp
00012 # define shape_graphic_hpp
00013
00014 # include <list>
00015 # include <realroot/Seq.hpp>
00016 # include <shape/shape.hpp>
00017 # include <shape/fxv.hpp>
00018
00019 # define TMPL template<class C, class V>
00020 # define SELF graphic<C,V>
00021 # define Shape geometric<V>
00022
00023 namespace mmx {
00024 namespace shape {
00025
00026
00027 template<class C, class V=default_env>
00028 struct graphic : public Shape
00029 {
00030 unsigned type;
00031 enum { E_TRIANGLE, E_QUAD, E_UNSTRUCT };
00032 Seq<C> vertices;
00033 Seq<C> normals ;
00034 Seq<int> edges;
00035 Seq<int> faces;
00036 unsigned m_nbf;
00037 Seq<float> colors;
00038
00039 public:
00040 graphic(void){};
00041 graphic( int nbv, int nbe, int nbf, bool hasnormal = false, bool hascolor = false, int type = E_TRIANGLE ) ;
00042 unsigned nbv() const {return vertices.size()/3;}
00043 unsigned nbe() const {return edges.size()/2;}
00044 unsigned nbf() const {return m_nbf;}
00045
00046 C vertex_coord (unsigned i) const {return vertices[i];}
00047 int edge_index (unsigned i) const {return edges[i];}
00048 int face_index (unsigned i) const {return faces[i];}
00049
00050 virtual ~graphic(void);
00051 } ;
00052
00053 TMPL
00054 SELF::graphic(int nbv, int nbe, int nbf, bool hasnormal, bool hascolor, int type) {
00055 this->type = type;
00056 this->vertices.resize(3*nbv);
00057 this->edges.resize(2*nbe);
00058 if (type == E_QUAD) this->faces.resize(4*nbf); else this->faces.resize(3*nbf);
00059 if ( hasnormal ) this->normals.resize(3*nbv);
00060 if ( hascolor ) this->colors.resize(3*nbv);
00061 }
00062 TMPL
00063 SELF::~graphic() {
00064
00065
00066
00067
00068
00069 }
00070
00071
00072
00073
00074 } ;
00075 } ;
00076
00077 # undef TMPL
00078 # undef SELF
00079 # undef Shape
00080 # undef Viewer
00081 # endif // shape_graphic_hpp