OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
map_slab.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-2020 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_SLAB_HH
20 #define OST_GFX_MAP_SLAB_HH
21 
22 /*
23  Author: Ansgar Philippsen
24 */
25 
26 #include <boost/shared_ptr.hpp>
27 #include <boost/shared_array.hpp>
28 
29 #include <ost/geom/geom.hh>
30 
31 #include <ost/img/map.hh>
32 
33 #include "gfx_object.hh"
34 #include "glext_include.hh"
35 
36 namespace ost { namespace gfx {
37 
38 class MapSlab;
39 typedef boost::shared_ptr<MapSlab> MapSlabP;
40 
48  struct PolyListEntry{
49  PolyListEntry() {}
50  PolyListEntry(const geom::Vec3& pp, const geom::Vec2& tt): p(pp), t(tt) {}
51  geom::Vec3 p;
52  geom::Vec3 t;
53  };
54  typedef std::vector<PolyListEntry> PolyList;
55 
56 public:
62  MapSlab(const String& name, const img::MapHandle& mh,
63  const geom::Plane& p);
64 
65  virtual geom::AlignedCuboid GetBoundingBox(bool use_tf=true) const;
66 
67  virtual geom::Vec3 GetCenter() const;
68  virtual void CustomRenderGL(RenderPass pass);
69 
71  virtual void CustomRenderPov(PovState& pov);
72 
73  geom::Plane GetPlane() const;
77  void SetPlane(const geom::Plane& p);
78 
80 
81  void ColorBy(const Gradient& g, float minv, float maxv);
84  void ColorBy(const Gradient& g);
87  void ColorBy(const Color& c1, const Color& c2, float minv, float maxv);
89  void ColorBy(const Color& c1, const Color& c2);
91 protected:
92  virtual void CustomPreRenderGL(bool flag);
93 
94  void Rebuild();
95 
96 private:
97  img::MapHandle mh_;
98  geom::Plane plane_;
99  uint usize_;
100  uint vsize_;
101  GLuint tex_id_;
102  boost::shared_array<float> tex_data_;
103  bool rebuild_;
104 
105  bool valid_;
106  geom::Vec3 c0_,c1_,c2_,c3_;
107  PolyList poly_list_;
108 
109  float minv_,maxv_;
110  Gradient grad_;
111 
112  bool calc_poly();
113  void rebuild_tex();
114  void render_slab();
115 };
116 
117 }}
118 
119 #endif
std::string String
Definition: base.hh:54
axis-aligned cuboid
main class for all graphic objects
Definition: gfx_object.hh:51
Render slice of 3d image.
Definition: map_slab.hh:46
boost::shared_ptr< MapSlab > MapSlabP
Definition: map_slab.hh:38
#define DLLEXPORT_OST_GFX
Three dimensional vector class, using Real precision.
Definition: vec3.hh:43
Manage shared instances of images.
color gradient
Definition: gradient.hh:59
unsigned int uint
Definition: base.hh:29