OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
WROIArbitrary.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WROIARBITRARY_H
00026 #define WROIARBITRARY_H
00027 
00028 #include <string>
00029 #include <utility>
00030 #include <vector>
00031 
00032 #include <boost/thread.hpp>
00033 
00034 #include "../common/math/linearAlgebra/WLinearAlgebra.h"
00035 #include "../common/math/WMatrix.h"
00036 #include "../common/WColor.h"
00037 #include "WPickHandler.h"
00038 #include "WGEViewer.h"
00039 
00040 #include "WTriangleMesh.h"
00041 
00042 #include "WROI.h"
00043 #include "WExportWGE.h"
00044 
00045 class WDataSetScalar;
00046 
00047 /**
00048  * A box containing information on an arbitrarily shaped a region of interest.
00049  */
00050 class WGE_EXPORT WROIArbitrary : public WROI
00051 {
00052 public:
00053     /**
00054      * constructor
00055      * \param nbCoordsX number of vertices in X direction
00056      * \param nbCoordsY number of vertices in Y direction
00057      * \param nbCoordsZ number of vertices in Z direction
00058      * \param mat the matrix transforming the vertices from canonical space
00059      * \param vals the values at the vertices
00060      * \param triMesh
00061      * \param threshold
00062      * \param maxThreshold The maximum of the values.
00063      * \param color the color to use for the ROI.
00064      */
00065     WROIArbitrary( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
00066                    const WMatrix< double >& mat,
00067                    const std::vector< float >& vals,
00068                    boost::shared_ptr< WTriangleMesh > triMesh,
00069                    float threshold,
00070                    float maxThreshold,
00071                    WColor color );
00072 
00073     /**
00074      * constructor
00075      * \param nbCoordsX number of vertices in X direction
00076      * \param nbCoordsY number of vertices in Y direction
00077      * \param nbCoordsZ number of vertices in Z direction
00078      * \param mat the matrix transforming the vertices from canonical space
00079      * \param vals the values at the vertices
00080      * \param maxThreshold The maximum of the values.
00081      * \param color the color to use for the ROI.
00082      */
00083     WROIArbitrary( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
00084                    const WMatrix< double >& mat,
00085                    const std::vector< float >& vals,
00086                    float maxThreshold,
00087                    WColor color );
00088 
00089 
00090     /**
00091      * destructor
00092      */
00093     virtual ~WROIArbitrary();
00094 
00095     /**
00096      * initalizes the properties
00097      */
00098     void properties();
00099 
00100     /**
00101      *
00102      */
00103     void propertyChanged();
00104 
00105     /**
00106      * setter
00107      * \param threshold
00108      */
00109     void setThreshold( double threshold );
00110 
00111     /**
00112      * getter
00113      *
00114      * \return The threshold on the data in box which leads to the arbitrary ROI
00115      */
00116     double getThreshold();
00117 
00118     /**
00119      * Get the number of vertices in the three coordinate directions
00120      *
00121      * \return A vector containing the numbers of vertices
00122      */
00123     std::vector< size_t > getCoordDimensions();
00124 
00125     /**
00126      * Get the vertex offsets in the three coordinate directions
00127      *
00128      * \return The offsets between point in each of the three coordinate directions
00129      */
00130     std::vector< double > getCoordOffsets();
00131 
00132     /**
00133      * Get the i-th value of the data defining the ROI
00134      * \param i the index of the value
00135      *
00136      * \return The value at the given index.
00137      */
00138     float getValue( size_t i );
00139 
00140     /**
00141      *  updates the graphics
00142      */
00143     virtual void updateGFX();
00144 
00145 protected:
00146 private:
00147     std::vector< size_t > m_nbCoordsVec; //!< The data's number of vertices in X, Y and Z direction.
00148 
00149     WMatrix< double > m_matrix; //!< The 4x4 transformation matrix for the vertices.
00150 
00151     const std::vector< float > m_vals; //!< The data at the vertices.
00152 
00153     boost::shared_ptr< WTriangleMesh > m_triMesh; //!< This triangle mesh is provided as output through the connector.
00154 
00155     WPropDouble m_threshold; //!< the threshold
00156 
00157     /**
00158      * The ROI color
00159      */
00160     WColor m_color;
00161 
00162     /**
00163      * Node callback to handle updates properly
00164      */
00165     class ROIArbNodeCallback : public osg::NodeCallback
00166     {
00167     public: // NOLINT
00168         /**
00169          * operator ()
00170          *
00171          * \param node the osg node
00172          * \param nv the node visitor
00173          */
00174         virtual void operator()( osg::Node* node, osg::NodeVisitor* nv )
00175         {
00176             osg::ref_ptr< WROIArbitrary > module = static_cast< WROIArbitrary* > ( node->getUserData() );
00177             if( module )
00178             {
00179                 module->updateGFX();
00180             }
00181             traverse( node, nv );
00182         }
00183     };
00184 };
00185 
00186 #endif  // WROIARBITRARY_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends