OpenStructure
Loading...
Searching...
No Matches
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
36namespace ost { namespace gfx {
37
38class MapSlab;
39typedef 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
56public:
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
77 void SetPlane(const geom::Plane& p);
78
80
81
82 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);
91protected:
92 virtual void CustomPreRenderGL(bool flag);
93
94 void Rebuild();
95
96private:
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
axis-aligned cuboid
Three dimensional vector class, using Real precision.
Definition vec3.hh:48
main class for all graphic objects
Definition gfx_object.hh:52
color gradient
Definition gradient.hh:59
Render slice of 3d image.
Definition map_slab.hh:46
virtual geom::AlignedCuboid GetBoundingBox(bool use_tf=true) const
returns the bounding box of this object
virtual void CustomRenderPov(PovState &pov)
get plane of slab
geom::Plane GetPlane() const
void ColorBy(const Color &c1, const Color &c2)
color by interpolating between two colors with min/max of slab
void ColorBy(const Gradient &g, float minv, float maxv)
color by gradient, using explicit min/max values
void ColorBy(const Gradient &g)
color by gradient, using min/max of slab
void ColorBy(const Color &c1, const Color &c2, float minv, float maxv)
color by interpolating between two colors with explicit min and max values
virtual geom::Vec3 GetCenter() const
get geometric center
virtual void CustomRenderGL(RenderPass pass)
void SetPlane(const geom::Plane &p)
set slab plane
virtual void CustomPreRenderGL(bool flag)
MapSlab(const String &name, const img::MapHandle &mh, const geom::Plane &p)
create new slab
Manage shared instances of images.
#define DLLEXPORT_OST_GFX
unsigned int uint
Definition base.hh:29
std::string String
Definition base.hh:54
boost::shared_ptr< MapSlab > MapSlabP
Definition map_slab.hh:39
Definition base.dox:1