shape_doc 0.1
|
00001 /***************************************************************************** 00002 * M a t h e m a g i x 00003 ***************************************************************************** 00004 * Graphic 00005 * Bernard Mourrain 00006 ***************************************************************************** 00007 * Copyright (C) 2009 INRIA Sophia-Antipolis 00008 ***************************************************************************** 00009 * Comments : 00010 ****************************************************************************/ 00011 # ifndef shape_graphic_hpp 00012 # define shape_graphic_hpp 00013 00014 # include <list> 00015 # include <shape/shape.hpp> 00016 # include <shape/fxv.hpp> 00017 00018 # define TMPL template<class C, class V> 00019 # define SELF graphic<C,V> 00020 # define Shape geometric<V> 00021 00022 namespace mmx { 00023 namespace shape { 00024 00025 00026 template<class C, class V=default_env> 00027 struct graphic : public Shape 00028 { 00029 enum { E_VERTEX, E_LINE, E_TRIANGLE, E_QUAD }; 00030 unsigned type; 00031 unsigned nbv; 00032 unsigned nbi; 00033 C * vertices; 00034 C * normals ; // can be zero 00035 float * colors ; 00036 int * indices ; 00037 public: 00038 graphic(void){}; 00039 graphic( int type, int nbv, int nbi, bool hasnormal = false ) ; 00040 virtual ~graphic(void); 00041 } ; 00042 00043 TMPL 00044 SELF::graphic( int t, int nbv, int nbi, bool hasnormal ) { 00045 this->type = t; 00046 this->nbv = nbv; 00047 this->nbi = nbi; 00048 vertices = new double[3*nbv]; 00049 if ( hasnormal ) normals = new double[3*nbv]; 00050 else normals = 0; 00051 indices = new int[nbi]; 00052 colors=new float[3*nbv]; 00053 } 00054 00055 TMPL 00056 SELF::~graphic() { 00057 if ( vertices ) delete[] vertices; 00058 if ( normals ) delete[] normals; 00059 if ( indices ) delete[] indices; 00060 if ( colors ) delete[] colors; 00061 } 00062 00063 //-------------------------------------------------------------------- 00064 00065 00066 } ; // namespace shape 00067 } ; // namespace mmx 00068 //==================================================================== 00069 # undef TMPL 00070 # undef SELF 00071 # undef Shape 00072 # undef Viewer 00073 # endif // shape_graphic_hpp