OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
map_iso.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GFX_MAP_ISO_HH
20 #define OST_GFX_MAP_ISO_HH
21 
22 /*
23  Author: Ansgar Philippsen, Marco Biasini
24 */
25 
26 #include <boost/shared_ptr.hpp>
27 
28 #include <ost/img/map.hh>
29 #include <ost/img/alg/stat.hh>
30 #include <ost/img/alg/histogram.hh>
31 
33 #include "gfx_object.hh"
34 #include "map_iso_prop.hh"
35 
36 namespace ost { namespace gfx {
37 
38 enum MapIsoType {
41 };
42 
43 class MapIso;
44 typedef boost::shared_ptr<MapIso> MapIsoP;
45 
53 public:
54  MapIso(const String& name, const img::MapHandle& mh,float level, uint a=0);
55 
57  virtual geom::AlignedCuboid GetBoundingBox(bool use_global=false) const;
58 
60  virtual geom::Vec3 GetCenter() const;
61 
62  virtual void CustomRenderGL(RenderPass pass);
63 
64  virtual void CustomRenderPov(PovState& pov);
65 
66  virtual void OnInput(const InputEvent& e);
67 
68  virtual void OnRenderModeChange();
69 
70  void Rebuild();
71 
75  void SetLevel(float l);
76 
77  float GetMinLevel() const;
78  float GetMaxLevel() const;
79 
81  float GetLevel() const;
82 
84  float GetMean() const;
85 
87  float GetStdDev() const;
88 
89 
91  std::vector<int> GetHistogram() const;
92 
94  void SetHistogramBinCount(int count);
95 
97  int GetHistogramBinCount() const;
98 
100  // The following is a hack. For the DataViewer I need to pass a reference to an ImagHandle
101  // that never goes out of scope, so I get a reference from here
102  img::ImageHandle& GetMap();
103 
105  // The following is a hack. For the DataViewer I need to pass a reference to an ImagHandle
106  // that never goes out of scope, so I get a reference from here
107  img::ImageHandle& GetOriginalMap();
108 
110  // The following is a hack. For the DataViewer I need to pass a reference to an ImagHandle
111  // that never goes out of scope, so I get a reference from here
112  img::ImageHandle& GetDownsampledMap();
113 
115  void ShowDownsampledMap();
116 
118  void ShowOriginalMap();
119 
121  bool IsDownsampledMapAvailable() const ;
122 
124  MapIsoType GetShownMapType() const;
125 
130  void SetColor(const Color& color)
131  {
132  color_=color;
133  this->FlagRebuild();
134  }
137  const Color& GetColor() const { return color_; }
138  void SetNSF(float smoothf);
139  void SetDebugOctree(bool flag) { debug_octree_=flag; }
140 
142  void MakeOctreeDirty();
143 
145  bool IfOctreeDirty() const;
146 
147 protected:
148  void UpdateRenderParams();
149  void CalculateStat() const;
150  void CalculateHistogram() const;
151  virtual void CustomPreRenderGL(bool flag);
152  static img::ImageHandle DownsampleMap(const img::ImageHandle& mh);
153 
154 private:
155  img::MapHandle original_mh_;
156  img::MapHandle downsampled_mh_;
157  img::MapHandle mh_;
158  impl::MapOctree octree_;
159  mutable img::alg::Stat stat_;
160  mutable bool stat_calculated_;
161  mutable img::alg::Histogram histogram_;
162  mutable bool histogram_calculated_;
163  int histogram_bin_count_;
164  float level_;
165  bool normals_calculated_;
166  uint alg_;
167  float smoothf_;
168  float min_;
169  float max_;
170  float std_dev_;
171  float min_max_;
172  bool debug_octree_;
173  Color color_;
174  bool dirty_octree_;
175  mutable geom::AlignedCuboid bb_;
176  mutable bool recalc_bb_;
177 };
178 
179 }}
180 
181 #endif