Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
VolumePlot.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef VolumePlot_INCLUDE_ONCE
33 #define VolumePlot_INCLUDE_ONCE
34 
35 #include <vlVolume/link_config.hpp>
36 #include <vlGraphics/Actor.hpp>
37 #include <vlGraphics/Geometry.hpp>
38 #include <vlGraphics/Text.hpp>
39 #include <vlGraphics/Effect.hpp>
40 #include <vlCore/Transform.hpp>
44 
45 namespace vl
46 {
47  class SceneManager;
48 
51  {
53 
54  public:
56  class Function
57  {
58  public:
59  virtual float operator()(float x, float y, float z) const = 0;
60  };
61 
62  public:
64  VolumePlot();
65 
67  void compute(const Function& func, float threshold);
68 
70  const Actor* isosurfaceActor() const { return mIsosurfaceActor.get(); }
72  Actor* isosurfaceActor() { return mIsosurfaceActor.get(); }
73 
75  const Geometry* isosurfaceGeometry() const { return mIsosurfaceGeometry.get(); }
77  Geometry* isosurfaceGeometry() { return mIsosurfaceGeometry.get(); }
78 
80  const Effect* isosurfaceEffect() const { return mIsosurfaceEffect.get(); }
82  Effect* isosurfaceEffect() { return mIsosurfaceEffect.get(); }
83 
85  const Effect* boxEffect() const { return mBoxEffect.get(); }
87  Effect* boxEffect() { return mBoxEffect.get(); }
88 
90  const fvec3& minCorner() const { return mMinCorner; }
92  void setMinCorner(const fvec3& min_corner) { mMinCorner = min_corner; }
93 
95  const fvec3& maxCorner() const { return mMaxCorner; }
97  void setMaxCorner(const fvec3& max_corner) { mMaxCorner = max_corner; }
98 
100  const Transform* plotTransform() const { return mPlotTransform.get(); }
102  Transform* plotTransform() { return mPlotTransform.get(); }
104  void setPlotTransform(Transform* tr) { mPlotTransform = tr; }
105 
107  const ivec3& samplingResolution() const { return mSamplingResolution; }
109  void setSamplingResolution(const ivec3& size) { mSamplingResolution = size; }
110 
112  const String& labelFormat() const { return mLabelFormat; }
114  void setLabelFormat(const String& format) { mLabelFormat = format; }
115 
117  const Font* labelFont() const { return mLabelFont.get(); }
119  Font* labelFont() { return mLabelFont.get(); }
121  void setLabelFont(Font* font) { mLabelFont = font; }
122 
124  const Text* textTemplate() const { return mTextTemplate.get(); }
126  Text* textTemplate() { return mTextTemplate.get(); }
127 
128  ActorTree* actorTreeMulti() { return mActorTreeMulti.get(); }
129  const ActorTree* actorTreeMulti() const { return mActorTreeMulti.get(); }
130 
131  protected:
132  void setupLabels(const String& format, const fvec3& min_corner, const fvec3& max_corner, Font* font, Transform* root_tr);
133  void evaluateFunction(float* scalar, const fvec3& min_corner, const fvec3& max_corner, const Function& func);
134 
135  protected:
136  std::vector< ref<Actor> > mActors;
149  };
150 }
151 
152 #endif
Associates a Renderable object to an Effect and Transform.
Definition: Actor.hpp:130
const Effect * isosurfaceEffect() const
Used to get/set the rendering options (like color, material, transparency) etc. of the isosurface...
Definition: VolumePlot.hpp:80
ref< Text > mTextTemplate
Definition: VolumePlot.hpp:147
Implements a 4x4 matrix transform used to define the position and orientation of an Actor...
Definition: Transform.hpp:72
ref< Effect > mIsosurfaceEffect
Definition: VolumePlot.hpp:145
Generates a 3D plot with labels and isosurface. The isosurface is generated using the MarchingCubes a...
Definition: VolumePlot.hpp:50
String mLabelFormat
Definition: VolumePlot.hpp:139
Geometry * isosurfaceGeometry()
The Geometry representing the isosurface.
Definition: VolumePlot.hpp:77
const fvec3 & minCorner() const
Default value: fvec3(-1,-1,-1)
Definition: VolumePlot.hpp:90
A Renderable that renders text with a given Font.
Definition: Text.hpp:50
ActorTree * actorTreeMulti()
Definition: VolumePlot.hpp:128
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
const String & labelFormat() const
Sets the format of the labels.
Definition: VolumePlot.hpp:112
A font to be used with a Text renderable.
Definition: Font.hpp:127
void setLabelFont(Font *font)
The Font to be used for the box labels.
Definition: VolumePlot.hpp:121
const Geometry * isosurfaceGeometry() const
The Geometry representing the isosurface.
Definition: VolumePlot.hpp:75
ref< Actor > mIsosurfaceActor
Definition: VolumePlot.hpp:144
void setPlotTransform(Transform *tr)
The transform associated to the whole plot.
Definition: VolumePlot.hpp:104
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
Text * textTemplate()
A Text used to initialize the plot labels.
Definition: VolumePlot.hpp:126
The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.
Definition: Geometry.hpp:66
Visualization Library main namespace.
const Transform * plotTransform() const
The transform associated to the whole plot.
Definition: VolumePlot.hpp:100
Effect * boxEffect()
Used to get/set the rendering options (like color, material, transparency) etc. of the box...
Definition: VolumePlot.hpp:87
ref< Transform > mPlotTransform
Definition: VolumePlot.hpp:137
std::vector< ref< Actor > > mActors
Definition: VolumePlot.hpp:136
A function to be used with VolumePlot.
Definition: VolumePlot.hpp:56
The base class for all the reference counted objects.
Definition: Object.hpp:158
Actor * isosurfaceActor()
The Actor representing the isosurface.
Definition: VolumePlot.hpp:72
ref< Effect > mBoxEffect
Definition: VolumePlot.hpp:146
ref< Font > mLabelFont
Definition: VolumePlot.hpp:140
ivec3 mSamplingResolution
Definition: VolumePlot.hpp:138
Defines the sequence of Shader objects used to render an Actor.
Definition: Effect.hpp:91
void setSamplingResolution(const ivec3 &size)
Default value: ivec3(64,64,64)
Definition: VolumePlot.hpp:109
const Actor * isosurfaceActor() const
The Actor representing the isosurface.
Definition: VolumePlot.hpp:70
const ActorTree * actorTreeMulti() const
Definition: VolumePlot.hpp:129
Font * labelFont()
The Font to be used for the box labels.
Definition: VolumePlot.hpp:119
const fvec3 & maxCorner() const
Default value: fvec3(+1,+1,+1)
Definition: VolumePlot.hpp:95
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
void setLabelFormat(const String &format)
Sets the format of the label to be generated, es. "(%.2n %.2n %.2n)" or "<%.3n, %.3n, %.3n>".
Definition: VolumePlot.hpp:114
const ivec3 & samplingResolution() const
Default value: ivec3(64,64,64)
Definition: VolumePlot.hpp:107
Transform * plotTransform()
The transform associated to the whole plot.
Definition: VolumePlot.hpp:102
Effect * isosurfaceEffect()
Used to get/set the rendering options (like color, material, transparency) etc. of the isosurface...
Definition: VolumePlot.hpp:82
The ActorTree class implements a generic tree whose nodes contain Actors.
Definition: ActorTree.hpp:62
void setMaxCorner(const fvec3 &max_corner)
Default value: fvec3(+1,+1,+1)
Definition: VolumePlot.hpp:97
const Effect * boxEffect() const
Used to get/set the rendering options (like color, material, transparency) etc. of the box...
Definition: VolumePlot.hpp:85
const Text * textTemplate() const
A Text used to initialize the plot labels.
Definition: VolumePlot.hpp:124
const Font * labelFont() const
The Font to be used for the box labels.
Definition: VolumePlot.hpp:117
void setMinCorner(const fvec3 &min_corner)
Default value: fvec3(-1,-1,-1)
Definition: VolumePlot.hpp:92
ref< Geometry > mIsosurfaceGeometry
Definition: VolumePlot.hpp:143
ref< ActorTree > mActorTreeMulti
Definition: VolumePlot.hpp:148