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]
SlicedVolume.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 SlicedVolume_INCLUDE_ONCE
33 #define SlicedVolume_INCLUDE_ONCE
34 
35 #include <vlVolume/link_config.hpp>
36 #include <vlGraphics/Actor.hpp>
37 #include <vlGraphics/Geometry.hpp>
38 #include <vlGraphics/Light.hpp>
39 
40 namespace vl
41 {
43  {
45 
46  public:
48  SlicedVolume();
49 
50  void onActorRenderStarted(Actor* actor, real frame_clock, const Camera* cam, Renderable* renderable, const Shader* shader, int pass);
51 
52  void onActorDelete(Actor*) { mActor = NULL; }
53 
55  void bindActor(Actor*);
56 
58  virtual void updateUniforms(Actor* actor, real clock, const Camera* camera, Renderable* rend, const Shader* shader);
59 
62  void setSliceCount(int count) { mSliceCount = count; }
63 
66  int sliceCount() const { return mSliceCount; }
67 
69  Geometry* geometry() { return mGeometry.get(); }
70 
72  const Geometry* geometry() const { return mGeometry.get(); }
73 
75  void setBox(const AABB& box);
76 
78  const AABB& box() const { return mBox; }
79 
81  const fvec3* texCoords() const { return mTexCoord; }
82 
84  fvec3* texCoords() { return mTexCoord; }
85 
87  void generateTextureCoordinates(const ivec3& size);
88 
91  void generateTextureCoordinates(const ivec3& img_size, const ivec3& min_corner, const ivec3& max_corner);
92 
94  const Actor* actor() const { return mActor; }
96  Actor* actor() { return mActor; }
97 
98  protected:
103  fvec3 mTexCoord[8];
104  // Naked pointer on purpose in order not to create cyclical dependencies and mem leaks: the Actor owns the SlicedVolume
106  };
107 }
108 
109 #endif
Associates a Renderable object to an Effect and Transform.
Definition: Actor.hpp:130
Geometry * geometry()
Returns the Geometry associated to a SlicedVolume and its bound Actor.
void setSliceCount(int count)
Defines the number of slices used to render the volume: more slices generate a better (and slower) re...
Actor * actor()
Returns the currently bound actor.
const Geometry * geometry() const
Returns the Geometry associated to a SlicedVolume and its bound Actor.
ref< Geometry > mGeometry
int sliceCount() const
Returns the number of slices used to render the volume.
A ActorEventCallback used to render a volume using viewport aligned slices.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
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 fvec3 * texCoords() const
Returns the texture coordinates assigned to each of the 8 box corners of the volume.
The AABB class implements an axis-aligned bounding box using vl::real precision.
Definition: AABB.hpp:44
An abstract class that represents all the objects that can be rendered.
Definition: Renderable.hpp:58
The ActorEventCallback class defines a callback object to react to Actor-related events.
Definition: Actor.hpp:75
#define NULL
Definition: OpenGLDefs.hpp:81
Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects...
Definition: Shader.hpp:1830
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:50
const AABB & box() const
The dimensions of the box enclosing the volume.
fvec3 * texCoords()
Returns the texture coordinates assigned to each of the 8 box corners of the volume.
void onActorDelete(Actor *)
Event notifying that an Actor is being deleted.
const Actor * actor() const
Returns the currently bound actor.