00001 00006 #pragma once 00007 00008 #include <deque> 00009 #include <vector> 00010 00011 #include "extern/QuickCG.h" 00012 00013 #include <boost/archive/xml_iarchive.hpp> 00014 #include <boost/archive/xml_oarchive.hpp> 00015 #include <boost/serialization/nvp.hpp> 00016 #include <boost/serialization/deque.hpp> 00017 00019 00022 class Transferfunction { 00023 friend class boost::serialization::access; 00024 private: 00025 std::deque<std::pair<float,ColorRGB> > color; 00026 std::deque<std::pair<float,float>> alpha; 00027 00028 protected: 00029 00030 template<class Archive> 00031 void serialize(Archive & ar, const unsigned int version) 00032 { 00033 ar & BOOST_SERIALIZATION_NVP(color); 00034 ar & BOOST_SERIALIZATION_NVP(alpha); 00035 } 00036 00037 public: 00038 Transferfunction(); 00039 Transferfunction(const Transferfunction &t); 00040 Transferfunction &operator=(const Transferfunction &t); 00041 00042 void clear(); 00043 void clearAlpha(); 00044 void clearColor(); 00045 00046 void set(const float &position,const ColorRGB &color); 00047 void set(const float &position,const float &alpha); 00048 00049 void remColor(const float &position); 00050 ColorRGB getColor(const float &pos) const; 00051 00052 float getNextColorPos(const float &pos) const; 00053 float getPrevColorPos(const float &pos) const; 00054 00055 void remAlpha(const float &position); 00056 float getAlpha(const float &pos) const; 00057 00058 float getNextAlphaPos(const float &pos) const; 00059 float getPrevAlphaPos(const float &pos) const; 00060 00061 std::vector<ColorRGB> getColorArray(const unsigned size) const; 00062 std::vector<float> getAlphaArray(const unsigned size) const; 00063 std::vector<unsigned char> getRGBAArray(const unsigned size) const; 00064 };