arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

VolSamples.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     10-11-02
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2002 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 //VolSamples.h
00019 
00020 // Container class for volume samples (slices)
00021 
00022 #ifndef __VOLUME_SAMPLES_DOT_H
00023 #define __VOLUME_SAMPLES_DOT_H
00024 
00025 #include <arrayGutz.h>
00026 #include <mathGutz.h>
00027 #include <list>
00028 #include <vector>
00029 #include <smartptr.h>
00030 #include <drawableGlift.h>
00031 
00032 typedef glift::GenPrimGL
00033    <
00034       glift::VertAttribV3F, 
00035       glift::TexCoordAttribV4F, 
00036       glift::IndexAttribV3UI
00037    > VSPRIM;
00038 
00039 class VolSamples : public VSPRIM
00040 {
00041 public:
00042    VolSamples(unsigned int size, 
00043       unsigned int nTcoords = 1);
00044    VolSamples(const VolSamples &v)
00045       : VSPRIM((VSPRIM)v) {}
00046    virtual ~VolSamples(){}
00047 
00048 protected:
00049 };
00050 
00051 
00052 ///////////////////////////////////////////////////////////////////////////
00053 /// Usefull typedefs
00054 ///////////////////////////////////////////////////////////////////////////
00055 
00056 typedef gutz::SmartPtr<VolSamples>           VolSamplesSP;
00057 
00058 typedef std::list<VolSamplesSP>            VolSamplesList;
00059 typedef std::list<VolSamplesSP>::iterator  VolSamplesListIter;
00060 
00061 typedef std::vector<VolSamplesSP>            VolSamplesVec;
00062 typedef std::vector<VolSamplesSP>::iterator  VolSamplesVecIter;
00063 
00064 
00065 
00066 
00067 #if 0
00068 
00069 class VolSamples : public Counted<VolSamples> {
00070 public:
00071    VolSamples(int size)
00072       : _verts(size, gutz::vec3f(0)),
00073       _tcoords(NTEXCOORDS, size, gutz::vec4f(0)),
00074       _idx(size, gutz::vec3ui(0)),
00075       _prims(size, gutz::vec2ui(0)),
00076       _nVerts(0),
00077       _nTris(0),
00078       _nPrims(0),
00079       _bound(false),
00080       _optimize(true)
00081    {
00082       _texCoordEnabled[0] = true;
00083       for(int i=1; i<NTEXCOORDS; ++i)
00084          _texCoordEnabled[i] = false;
00085    }
00086 
00087    enum{
00088       NTEXCOORDS = 8
00089    };
00090 
00091    virtual ~VolSamples(){}
00092 
00093    //TODO: copy and set operators that allow the size of the
00094    // arrays to change.  Also, possibly add dynamic arrays 
00095    // to this containter so we don't have to worry about the
00096    // size of the elements.
00097 
00098    gutz::arrayw1v3f  getVerts()                  {return gutz::arrayw1v3f(_verts);}
00099    gutz::arrayw1v4f  getTcoords(int tcNum = 0)   {return gutz::arrayw1v4f(_tcoords[tcNum]);}
00100    gutz::arrayw1v3ui getIdx()                    {return gutz::arrayw1v3ui(_idx);}
00101    gutz::arrayw1v2ui getPrims()                  {return gutz::arrayw1v2ui(_prims);}
00102 
00103    void         setNumVerts(unsigned int nVerts) {_nVerts = nVerts;}
00104    unsigned int getNumVerts()                    {return _nVerts;}
00105 
00106    void         setNumTris(unsigned int nTris)   {_nTris = nTris;}
00107    unsigned int getNumTris()                     {return _nTris;}
00108 
00109    void         setNumPrims(unsigned int nPrims) {_nPrims = nPrims;}
00110    unsigned int getNumPrims()                    {return _nPrims;}
00111 
00112    /////////////////////////////////
00113    /// enable / disable texcoords
00114    void         enableTexCoord(int tc)           {_texCoordEnabled[tc] = true;}
00115    bool         isTexCoordEnabled(int tc)        {return _texCoordEnabled[tc];}
00116    void         disableTexCoord(int tc)          {_texCoordEnabled[tc] = false;}
00117    void         disableTexCoordAll()             {for(int i=0; i<NTEXCOORDS; ++i) _texCoordEnabled[i] = false;}
00118 
00119    /////////////////////////////////
00120    /// optimize on or off??
00121    void         setOptimize(bool onoff) { _optimize;}
00122    bool         isOptimized()           {return _optimize;}
00123 
00124    /////////////////////////////////
00125    /// prepare for rendering
00126    void         bind()                           {_bound = true; bindDef();}
00127    /////////////////////////////////
00128    /// done rendering
00129    void         release()                        {_bound = false; releaseDef();}
00130 
00131    /////////////////////////////////
00132    /// render
00133    void         drawAll();
00134    void         draw(int primId);
00135 
00136 protected:
00137 
00138    virtual void bindDef();
00139    virtual void releaseDef();
00140 
00141    gutz::arrayo1v3f  _verts;
00142    gutz::arrayo2v4f  _tcoords;
00143    gutz::arrayo1v3ui _idx;
00144    gutz::arrayo1v2ui _prims;
00145 
00146    unsigned int      _nVerts;
00147    unsigned int      _nTris;
00148    unsigned int      _nPrims;
00149 
00150    bool              _bound;
00151    bool              _optimize;
00152 
00153    bool              _texCoordEnabled[NTEXCOORDS];
00154 };
00155 
00156 #endif
00157 
00158 #endif
00159 

Send questions, comments, and bug reports to:
jmk