00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GFX_MAP_ISO_HH
00020 #define OST_GFX_MAP_ISO_HH
00021
00022
00023
00024
00025
00026 #include <boost/shared_ptr.hpp>
00027
00028 #include <ost/img/map.hh>
00029 #include <ost/img/alg/stat.hh>
00030 #include <ost/img/alg/histogram.hh>
00031
00032 #include <ost/gfx/impl/map_octree.hh>
00033 #include "gfx_object.hh"
00034 #include "map_iso_prop.hh"
00035
00036 namespace ost { namespace gfx {
00037
00038 enum MapIsoType {
00039 ORIGINAL_MAP,
00040 DOWNSAMPLED_MAP
00041 };
00042
00043 class MapIso;
00044 typedef boost::shared_ptr<MapIso> MapIsoP;
00045
00052 class DLLEXPORT_OST_GFX MapIso: public GfxObj {
00053 public:
00054 MapIso(const String& name, const img::MapHandle& mh,float level, uint a=0);
00055
00057 virtual geom::AlignedCuboid GetBoundingBox(bool use_global=false) const;
00058
00060 virtual geom::Vec3 GetCenter() const;
00061
00062 virtual void CustomRenderGL(RenderPass pass);
00063
00064 virtual void CustomRenderPov(PovState& pov);
00065
00066 virtual void OnInput(const InputEvent& e);
00067
00068 virtual void OnRenderModeChange();
00069
00070 void Rebuild();
00071
00075 void SetLevel(float l);
00076
00077 float GetMinLevel() const;
00078 float GetMaxLevel() const;
00079
00081 float GetLevel() const;
00082
00084 float GetMean() const;
00085
00087 float GetStdDev() const;
00088
00089
00091 std::vector<int> GetHistogram() const;
00092
00094 void SetHistogramBinCount(int count);
00095
00097 int GetHistogramBinCount() const;
00098
00100
00101
00102 img::ImageHandle& GetMap();
00103
00105
00106
00107 img::ImageHandle& GetOriginalMap();
00108
00110
00111
00112 img::ImageHandle& GetDownsampledMap();
00113
00115 void ShowDownsampledMap();
00116
00118 void ShowOriginalMap();
00119
00121 bool IsDownsampledMapAvailable() const ;
00122
00124 MapIsoType GetShownMapType() const;
00125
00130 void SetColor(const Color& color)
00131 {
00132 color_=color;
00133 this->FlagRebuild();
00134 }
00137 const Color& GetColor() const { return color_; }
00138 void SetNSF(float smoothf);
00139 void SetDebugOctree(bool flag) { debug_octree_=flag; }
00140
00142 void MakeOctreeDirty();
00143
00145 bool IfOctreeDirty() const;
00146
00147 static bool global_downsampling_flag;
00148
00149 protected:
00150 void UpdateRenderParams();
00151 void CalculateStat() const;
00152 void CalculateHistogram() const;
00153 virtual void CustomPreRenderGL(bool flag);
00154 static img::ImageHandle DownsampleMap(const img::ImageHandle& mh);
00155
00156 private:
00157 img::MapHandle original_mh_;
00158 img::MapHandle downsampled_mh_;
00159 img::MapHandle mh_;
00160 impl::MapOctree octree_;
00161 mutable img::alg::Stat stat_;
00162 mutable bool stat_calculated_;
00163 mutable img::alg::Histogram histogram_;
00164 mutable bool histogram_calculated_;
00165 int histogram_bin_count_;
00166 float level_;
00167 bool normals_calculated_;
00168 float smoothf_;
00169 float min_;
00170 float max_;
00171 float std_dev_;
00172 float min_max_;
00173 bool debug_octree_;
00174 Color color_;
00175 bool dirty_octree_;
00176 mutable geom::AlignedCuboid bb_;
00177 mutable bool recalc_bb_;
00178 };
00179
00180 }}
00181
00182 #endif