00001 #ifndef _VUTFDESIGN_H_
00002 #define _VUTFDESIGN_H_
00003
00004 #include "vuColour.h"
00005 #include "vuColourRGBa.h"
00006 #include "vuTFIntensity.h"
00007 #include "vuDVector.h"
00008 #include "vuSimpleTypes.h"
00009 #include "vuParser.h"
00010
00012
00038 class vuTFDesign : public vuTFIntensity, public vuParser
00039 {
00040 public:
00041
00043 struct OpacityNode
00044 {
00045 OpacityNode(byte i=0, float o=0) : intensity(i), opacity(o) {};
00046
00047 dword intensity;
00048 float opacity;
00049 };
00050
00051
00053 struct ColourNode
00054 {
00055 ColourNode(byte intensity = 0, dword ncomp = 32, const float val = 0);
00056 ColourNode(byte intensity, dword ncomp, const vuColourN& _col);
00057 ColourNode(byte intensity, dword ncomp, const float* _col);
00058
00059 dword intensity;
00060 float col[32];
00061 };
00062
00063
00064
00065 public:
00067
00071 vuTFDesign(dword ncomp = 4, dword range = 256);
00072 virtual ~vuTFDesign() {};
00073
00075
00077 dword addOpacity(byte intensity, float alpha);
00079 void removeOpacity(dword index);
00081 dword getNumOpacities() const;
00083 const OpacityNode& getOpacity(dword index) const;
00085 float getOpacitySmoothing() const;
00087
00089 void setOpacitySmoothing(float rate);
00090
00092
00094 dword addColour(dword intensity, const vuColourN& _col);
00096
00098 dword addColour(dword intensity, const float* _col);
00100 void removeColour(dword index);
00102 dword getNumColours() const;
00104 const ColourNode& getColour(dword index) const;
00106 dword getColourNodeIndex(const ColourNode& cnode) const;
00107
00109 virtual void clearAllNodes();
00111 float getColourSmoothing() const;
00113
00115 void setColourSmoothing(float rate);
00116
00118
00122 virtual void generateFunction();
00123
00125 virtual void generateOpacities();
00126
00130 bool loadTF(const char* fname);
00134 bool saveTF(const char* fname) const;
00135
00136 protected:
00138 void smooth(float *array,float percent) const;
00139
00142 void Parse(const char* filename) throw (const char *);
00149 virtual void parseTFunc();
00154 virtual void writeTFunc(ofstream &ofp) const;
00155
00157 bool writeNComp(ofstream &ofp) const;
00158
00162 bool readNComp();
00163
00169 bool readOpacity();
00172 bool writeOpacities(ofstream &ofp) const;
00173
00179 bool readColour();
00182 bool writeColours(ofstream &ofp) const;
00183
00184
00185
00186
00188 vuDVector<OpacityNode> m_Opacities;
00190 float m_OpacitySmoothing;
00191
00193 vuDVector<ColourNode> m_Colours;
00195 float m_ColourSmoothing;
00196
00197 };
00198
00199 #endif
00200