00001 //------------------------------------------------------------------------ 00002 // 00003 // Joe Kniss 00004 // 3-20-03 00005 // ________ ____ ___ 00006 // | \ / | / / 00007 // +---+ \/ |/ / 00008 // +--+| |\ /| < 00009 // | || | \ / | |\ \ 00010 // | | \/ | | \ \ 00011 // \_____| |__| \__\ 00012 // Copyright 2003 00013 // Joe Michael Kniss 00014 // <<< jmk@cs.utah.edu >>> 00015 // "All Your Base are Belong to Us" 00016 //------------------------------------------------------------------------- 00017 00018 /// TFElementSTD.h 00019 00020 #ifndef __TRANSFER_FUNCTION_ELEMENT_STANDARD_DOT_H 00021 #define __TRANSFER_FUNCTION_ELEMENT_STANDARD_DOT_H 00022 00023 #include "TFElement.h" 00024 00025 /////////////////////////////////////////////////////////////////////////// 00026 /// box type tf element 00027 /////////////////////////////////////////////////////////////////////////// 00028 00029 class TFElementBox : public TFElement { 00030 public: 00031 typedef TFElement::PosType PosType; 00032 typedef TFElement::PosVecType PosTypeVec; 00033 typedef TFElement::ValType ValType; 00034 typedef TFElement::ValVecType ValTypeVec; 00035 00036 TFElementBox(); 00037 TFElementBox(const PosType center, const PosType size); 00038 virtual ~TFElementBox(){} 00039 00040 virtual TFEltView *getView(const gutz::vec2i &axes) { return 0; } 00041 00042 ///@name Element Kinds 00043 ///@{ 00044 enum BOX_KIND { 00045 RADIAL, /// circles (default kind) 00046 SEPARABLE /// tent, pyramid 00047 }; 00048 int getKind() const {return _kind;} 00049 void setKind(const int kind) {_kind = kind;} 00050 ///@} 00051 00052 ///@name Position, Size, BBox 00053 ///@{ 00054 00055 /// you can use this like : TFElement::getPos(LL) 00056 /// there is also an interface to the elements 00057 /// below 00058 enum BOX_ELEMENT_IDS { 00059 LL, /// MIN pos (lower left) 00060 UR /// MAX pos (upper right) 00061 }; 00062 00063 /// PosTypeVec[0] = min, PosTypeVec[1] = max 00064 PosTypeVec getBBox() const { return _posVec; } 00065 /// get center 00066 PosType getCenter() const { return (_posVec[LL] + _posVec[UR])/2.0; } 00067 void setCenter(PosType center); 00068 /// get size 00069 PosType getSize() const { return _posVec[UR] - _posVec[LL]; } 00070 void setSize(PosType size); 00071 /// get min, same as getPos(LL) 00072 PosType getMin() const { return _posVec[LL]; } 00073 void setMin(PosType ll); 00074 /// get max, same as getPos(UR) 00075 PosType getMax() const { return _posVec[UR]; } 00076 void setMax(PosType ur); 00077 00078 ///@} 00079 00080 /// not implemented yet 00081 virtual ValType eval(const PosType &pos) const {return STF::tfRangeType_default;} 00082 /// implementing now 00083 ValType eval(const tfVec2 &tfpos, 00084 const gutz::vec2i &posIdx) const; 00085 00086 virtual void rasterize2D(NrroSP n, 00087 const gutz::vec2i &posIdx, 00088 const int kind = STF::TF_RGBA); 00089 00090 protected: 00091 template<class T> 00092 void rasterize2D(Nrro::NrroIter<T> ni) const; 00093 00094 inline SType myEval(const SType p2) const 00095 { 00096 return exp(-p2); 00097 } 00098 00099 /// only called by constructor 00100 void initBox(const PosType center, const PosType size); 00101 virtual void updateBox(); 00102 00103 int _kind; 00104 00105 gutz::vec2i _posIdx; ///< tmp for rasterization 00106 STF::tfRangeIdx _valIdx; 00107 }; 00108 00109 typedef gutz::SmartPtr<TFElementBox> TFElementBoxSP; 00110 00111 #endif 00112