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 
148 
149 protected:
150  void UpdateRenderParams();
151  void CalculateStat() const;
152  void CalculateHistogram() const;
153  virtual void CustomPreRenderGL(bool flag);
154  static img::ImageHandle DownsampleMap(const img::ImageHandle& mh);
155 
156 private:
157  img::MapHandle original_mh_;
158  img::MapHandle downsampled_mh_;
159  img::MapHandle mh_;
160  impl::MapOctree octree_;
161  mutable img::alg::Stat stat_;
162  mutable bool stat_calculated_;
163  mutable img::alg::Histogram histogram_;
164  mutable bool histogram_calculated_;
165  int histogram_bin_count_;
166  float level_;
167  bool normals_calculated_;
168  float smoothf_;
169  float min_;
170  float max_;
171  float std_dev_;
172  float min_max_;
173  bool debug_octree_;
174  Color color_;
175  bool dirty_octree_;
176  mutable geom::AlignedCuboid bb_;
177  mutable bool recalc_bb_;
178 };
179 
180 }}
181 
182 #endif
const Color & GetColor() const
get color
Definition: map_iso.hh:137
void SetDebugOctree(bool flag)
Definition: map_iso.hh:139
std::string String
Definition: base.hh:54
axis-aligned cuboid
Octree datastructure for 3D images.
Definition: map_octree.hh:109
MapIsoType
Definition: map_iso.hh:38
main class for all graphic objects
Definition: gfx_object.hh:51
void SetColor(const Color &color)
set color
Definition: map_iso.hh:130
#define DLLEXPORT_OST_GFX
Three dimensional vector class, using Real precision.
Definition: vec3.hh:42
static bool global_downsampling_flag
Definition: map_iso.hh:147
isocontour rendering for 3D image data
Definition: map_iso.hh:52
ImageStateNonModAlgorithm< HistogramBase > Histogram
Definition: histogram.hh:70
Manage shared instances of images.
ImageStateNonModAlgorithm< StatBase > Stat
Definition: stat.hh:101
boost::shared_ptr< MapIso > MapIsoP
Definition: map_iso.hh:43
unsigned int uint
Definition: base.hh:29