Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]

X:/dropbox/visualizationlibrary/src/vlVolume/VolumePlot.hpp

Go to the documentation of this file.
00001 /**************************************************************************************/
00002 /*                                                                                    */
00003 /*  Visualization Library                                                             */
00004 /*  http://www.visualizationlibrary.org                                               */
00005 /*                                                                                    */
00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
00007 /*  All rights reserved.                                                              */
00008 /*                                                                                    */
00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
00010 /*  are permitted provided that the following conditions are met:                     */
00011 /*                                                                                    */
00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
00013 /*  list of conditions and the following disclaimer.                                  */
00014 /*                                                                                    */
00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
00017 /*  other materials provided with the distribution.                                   */
00018 /*                                                                                    */
00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
00029 /*                                                                                    */
00030 /**************************************************************************************/
00031 
00032 #ifndef VolumePlot_INCLUDE_ONCE
00033 #define VolumePlot_INCLUDE_ONCE
00034 
00035 #include <vlVolume/link_config.hpp>
00036 #include <vlGraphics/Actor.hpp>
00037 #include <vlGraphics/Geometry.hpp>
00038 #include <vlGraphics/Text.hpp>
00039 #include <vlGraphics/Effect.hpp>
00040 #include <vlCore/Transform.hpp>
00041 #include <vlGraphics/ActorTreeAbstract.hpp>
00042 #include <vlGraphics/SceneManagerActorTree.hpp>
00043 #include <vlVolume/MarchingCubes.hpp>
00044 
00045 namespace vl
00046 {
00047   class SceneManager;
00048 
00050   class VLVOLUME_EXPORT VolumePlot: public Object
00051   {
00052     VL_INSTRUMENT_CLASS(vl::VolumePlot, Object)
00053 
00054   public:
00056     class Function
00057     {
00058     public:
00059       virtual float operator()(float x, float y, float z) const = 0;
00060     };
00061 
00062   public:
00064     VolumePlot();
00065 
00067     void compute(const Function& func, float threshold);
00068 
00070     const Actor* isosurfaceActor() const { return mIsosurfaceActor.get(); }
00072     Actor* isosurfaceActor() { return mIsosurfaceActor.get(); }
00073 
00075     const Geometry* isosurfaceGeometry() const { return mIsosurfaceGeometry.get(); }
00077     Geometry* isosurfaceGeometry() { return mIsosurfaceGeometry.get(); }
00078 
00080     const Effect* isosurfaceEffect() const { return mIsosurfaceEffect.get(); }
00082     Effect* isosurfaceEffect() { return mIsosurfaceEffect.get(); }
00083 
00085     const Effect* boxEffect() const { return mBoxEffect.get(); }
00087     Effect* boxEffect() { return mBoxEffect.get(); }
00088 
00090     const fvec3& minCorner() const { return mMinCorner; }
00092     void setMinCorner(const fvec3& min_corner) { mMinCorner = min_corner; }
00093 
00095     const fvec3& maxCorner() const { return mMaxCorner; }
00097     void setMaxCorner(const fvec3& max_corner) { mMaxCorner = max_corner; }
00098 
00100     const Transform* plotTransform() const { return mPlotTransform.get(); }
00102     Transform* plotTransform() { return mPlotTransform.get(); }
00104     void setPlotTransform(Transform* tr) { mPlotTransform = tr; }
00105 
00107     const ivec3& samplingResolution() const { return mSamplingResolution; }
00109     void setSamplingResolution(const ivec3& size) { mSamplingResolution = size; }
00110 
00112     const String& labelFormat() const { return mLabelFormat; }
00114     void setLabelFormat(const String& format) { mLabelFormat = format; }
00115 
00117     const Font* labelFont() const { return mLabelFont.get(); }
00119     Font* labelFont() { return mLabelFont.get(); }
00121     void setLabelFont(Font* font) { mLabelFont = font; }
00122 
00124     const Text* textTemplate() const { return mTextTemplate.get(); }
00126     Text* textTemplate() { return mTextTemplate.get(); }
00127 
00128     ActorTree* actorTreeMulti() { return mActorTreeMulti.get(); }
00129     const ActorTree* actorTreeMulti() const { return mActorTreeMulti.get(); }
00130 
00131   protected:
00132     void setupLabels(const String& format, const fvec3& min_corner, const fvec3& max_corner, Font* font, Transform* root_tr);
00133     void evaluateFunction(float* scalar, const fvec3& min_corner, const fvec3& max_corner, const Function& func);
00134 
00135   protected:
00136     std::vector< ref<Actor> > mActors;
00137     ref<Transform> mPlotTransform;
00138     ivec3 mSamplingResolution;
00139     String mLabelFormat;
00140     ref< Font > mLabelFont;
00141     fvec3 mMinCorner;
00142     fvec3 mMaxCorner;
00143     ref<Geometry> mIsosurfaceGeometry;
00144     ref<Actor> mIsosurfaceActor;
00145     ref<Effect> mIsosurfaceEffect;
00146     ref<Effect> mBoxEffect;
00147     ref<Text> mTextTemplate;
00148     ref<ActorTree> mActorTreeMulti;
00149   };
00150 }
00151 
00152 #endif

Visualization Library 2011.09.1160 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 2 2013 13:40:44.
Permission is granted to use this page to write and publish articles regarding Visualization Library.