Commit ea63da8a authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[REMOVE] removed schmahmanPandySlices module as it caused an error during...

[REMOVE] removed schmahmanPandySlices module as it caused an error during startup (there was now WLoadableModule symbol)
parent c0124b68
......@@ -30,7 +30,6 @@ ADD_MODULE( imageExtractor )
ADD_MODULE( paintTexture )
ADD_MODULE( probTractDisplay )
ADD_MODULE( scalarSegmentation )
ADD_MODULE( schmahmannPandyaSlices )
ADD_MODULE( splineSurface )
ADD_MODULE( surfaceIllustrator )
ADD_MODULE( surfaceParameterAnimator )
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
// #include "boundaryCurvesWMGM/WMBoundaryCurvesWMGM.h"
// #include "core/kernel/WModule.h"
// #include "probTractDisplaySP/WMProbTractDisplaySP.h"
// #include "slices/WMSlices.h"
// #include "WSchmahmannPandyaSlicesMain.h"
//
// extern "C" void WLoadModule( WModuleList& m ) // NOLINT const ref
// {
// m.push_back( boost::shared_ptr< WModule >( new WMBoundaryCurvesWMGM ) );
// m.push_back( boost::shared_ptr< WModule >( new WMProbTractDisplaySP ) );
// m.push_back( boost::shared_ptr< WModule >( new WMSlices ) );
// }
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WSCHMAHMANNPANDYASLICESMAIN_H
#define WSCHMAHMANNPANDYASLICESMAIN_H
#endif // WSCHMAHMANNPANDYASLICESMAIN_H
FILE( GLOB_RECURSE MODULES_SRC "*.cpp" "*.h" )
# Grab module name and setup target directories
GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
SET( MODULE_TARGET_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/modules/${MODULE_NAME} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( MODULE_DIRNAME ${MODULE_NAME} )
SET( MODULE_NAME "OWmodule_${MODULE_NAME}" ) # prefix all module names with "OWmodule_" to separate them from other libs
# Build module lib
ADD_LIBRARY( ${MODULE_NAME} SHARED ${MODULES_SRC} )
TARGET_LINK_LIBRARIES( ${MODULE_NAME} OWkernel )
# Copy local shaders to module target directory
IF( OW_COPY_SHADERS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/shaders ) # copy shaders only if the user wants it
ADD_CUSTOM_TARGET( ${MODULE_NAME}_CopyShaders
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders ${MODULE_TARGET_DIR}/shaders/
COMMENT "Copy shaders of ${MODULE_NAME}"
)
ADD_DEPENDENCIES( ${MODULE_NAME} ${MODULE_NAME}_CopyShaders )
ENDIF()
# Build unit tests
IF( OW_COMPILE_TESTS )
# This ensures that the test is copied to the module directory
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
CXXTEST_ADD_TESTS_FROM_LIST( "${MODULES_SRC}"
"OWkernel;${MODULE_NAME}"
)
# Copy fixtures if they exist
IF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
ADD_CUSTOM_TARGET( ${MODULE_NAME}_CopyFixtures
# as the "test" target runs in CMakes temporary build dir, the fixtures need to be placed there too.
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures ${CMAKE_BINARY_DIR}/modules/${MODULE_DIRNAME}/fixtures/
COMMENT "Copy fixtures of ${MODULE_NAME}"
)
ADD_DEPENDENCIES( ${MODULE_NAME} ${MODULE_NAME}_CopyFixtures )
ENDIF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
ENDIF( OW_COMPILE_TESTS )
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "core/common/WProperties.h"
#include "core/dataHandler/WDataSetScalar.h"
#include "WBoundaryBuilder.h"
WBoundaryBuilder::WBoundaryBuilder( boost::shared_ptr< const WDataSetScalar > texture, boost::shared_ptr< const WProperties > properties,
boost::array< osg::ref_ptr< WGEManagedGroupNode >, 3 > *slices )
: m_texture( texture ),
m_slices( *slices ) // copy the pointers
{
m_slicePos[0] = properties->findProperty( "Slices" )->toPropGroup()->findProperty( "Sagittal Position" )->toPropDouble();
m_slicePos[1] = properties->findProperty( "Slices" )->toPropGroup()->findProperty( "Coronal Position" )->toPropDouble();
m_slicePos[2] = properties->findProperty( "Slices" )->toPropGroup()->findProperty( "Axial Position" )->toPropDouble();
m_grayMatter = properties->findProperty( "Gray Matter" )->toPropDouble();
m_whiteMatter = properties->findProperty( "White Matter" )->toPropDouble();
m_gmColor = properties->findProperty( "Gray Matter Color" )->toPropColor();
m_wmColor = properties->findProperty( "White Matter Color" )->toPropColor();
}
WBoundaryBuilder::~WBoundaryBuilder()
{
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WBOUNDARYBUILDER_H
#define WBOUNDARYBUILDER_H
#include <boost/array.hpp>
#include <boost/shared_ptr.hpp>
#include <osg/ref_ptr>
#include "core/common/WProperties.h"
#include "core/graphicsEngine/shaders/WGEShader.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
// forward declarations
class WGEManagedGroupNode;
class WDataSetScalar;
/**
* Abstract base class for a boundary builder which needs serveral input paramertes \ref WBoundaryBuilder constructor
* and provides an interface: \ref run for generating the graphics.
*/
class WBoundaryBuilder
{
public:
/**
* Constructs an builder instance.
*
* \param texture The underlying scalar dataset to compute those boundaries for
* \param properties Properties, like slice positions, thresholds etc.
* \param slices Slice geodes which are controlled (hide/unhide) by the module.
*/
WBoundaryBuilder( boost::shared_ptr< const WDataSetScalar > texture,
boost::shared_ptr< const WProperties > properties,
boost::array< osg::ref_ptr< WGEManagedGroupNode >, 3 > *slices );
/**
* Destructs this.
*/
virtual ~WBoundaryBuilder();
/**
* Starts rendering and finally insert result in output.
*
* \param output Where to put/insert the results.
* \param sliceNum If given -1 all slice will perform an update, otherwise only the slice with the given slice number.
*/
virtual void run( osg::ref_ptr< WGEManagedGroupNode > output, const char sliceNum = -1 ) = 0;
protected:
/**
* The underlying scalar dataset to compute those boundaries for.
*/
boost::shared_ptr< const WDataSetScalar > m_texture;
/**
* The three slice positions.
* 0 : xSlice, 1 : ySlice, 2 : zSlice
*/
boost::array< WPropDouble, 3 > m_slicePos;
/**
* Pointer to the three slices.
* 0 : xSlice, 1 : ySlice, 2 : zSlice
*/
boost::array< osg::ref_ptr< WGEManagedGroupNode >, 3 > m_slices;
/**
* Gray matter threshold.
*/
WPropDouble m_grayMatter;
/**
* White matter threshold.
*/
WPropDouble m_whiteMatter;
/**
* Shader generating the curves of gray and white matter.
*/
osg::ref_ptr< WGEShader > m_shader;
/**
* Gray matter color.
*/
WPropColor m_gmColor;
/**
* White matter color.
*/
WPropColor m_wmColor;
private:
};
#endif // WBOUNDARYBUILDER_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "core/dataHandler/WDataSetScalar.h"
#include "core/dataHandler/WGridRegular3D.h"
#include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
#include "core/graphicsEngine/WGEGeodeUtils.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
#include "WBoundaryFragments.h"
WBoundaryFragments::WBoundaryFragments( boost::shared_ptr< const WDataSetScalar > texture, boost::shared_ptr< const WProperties > properties,
boost::array< osg::ref_ptr< WGEManagedGroupNode >, 3 > *slices, boost::filesystem::path localPath )
: WBoundaryBuilder( texture, properties, slices )
{
m_shader = osg::ref_ptr< WGEShader > ( new WGEShader( "WMBoundaryCurvesWMGM-Fragments", localPath ) );
}
void WBoundaryFragments::run( osg::ref_ptr< WGEManagedGroupNode > output, const char /* sliceNum */ )
{
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_texture->getGrid() );
// create a new geodes containing the slices
m_slices[0]->addChild( wge::genFinitePlane( grid->getOrigin(), grid->getNbCoordsY() * grid->getDirectionY(),
grid->getNbCoordsZ() * grid->getDirectionZ() ) );
m_slices[1]->addChild( wge::genFinitePlane( grid->getOrigin(), grid->getNbCoordsX() * grid->getDirectionX(),
grid->getNbCoordsZ() * grid->getDirectionZ() ) );
m_slices[2]->addChild( wge::genFinitePlane( grid->getOrigin(), grid->getNbCoordsX() * grid->getDirectionX(),
grid->getNbCoordsY() * grid->getDirectionY() ) );
osg::ref_ptr< osg::Uniform > u_grayMatter = new WGEPropertyUniform< WPropDouble >( "u_grayMatter", m_grayMatter );
osg::ref_ptr< osg::Uniform > u_whiteMatter = new WGEPropertyUniform< WPropDouble >( "u_whiteMatter", m_whiteMatter );
osg::ref_ptr< osg::Uniform > u_gmColor = new WGEPropertyUniform< WPropColor >( "u_gmColor", m_gmColor );
osg::ref_ptr< osg::Uniform > u_wmColor = new WGEPropertyUniform< WPropColor >( "u_wmColor", m_wmColor );
for( char i = 0; i < 3; ++i )
{
m_shader->apply( m_slices[i] );
wge::bindTexture( m_slices[i], m_texture->getTexture() );
osg::StateSet *ss = m_slices[i]->getOrCreateStateSet();
ss->addUniform( u_grayMatter );
ss->addUniform( u_whiteMatter );
ss->addUniform( u_gmColor );
ss->addUniform( u_wmColor );
ss->addUniform( new WGEPropertyUniform< WPropDouble >( "u_vertexShift", m_slicePos[i] ) );
ss->addUniform( new osg::Uniform( "u_vertexShiftDirection", static_cast< osg::Vec3f >( getDirections< double >( grid )[i] ) ) );
output->insert( m_slices[i] );
}
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WBOUNDARYFRAGMENTS_H
#define WBOUNDARYFRAGMENTS_H
#include <boost/filesystem.hpp>
#include <osg/ref_ptr>
#include "core/graphicsEngine/shaders/WGEShader.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
#include "WBoundaryBuilder.h"
// forward declarations
class WDataSetScalar;
/**
* Constructs the boundary surface curves of the WM and GM via a shader approach.
*/
class WBoundaryFragments : public WBoundaryBuilder
{
public:
/**
* Constructs an builder instance.
*
* \param texture The underlying scalar dataset to compute those boundaries for
* \param properties Properties, like slice positions, thresholds etc.
* \param slices Slice geodes which are controlled (hide/unhide) by the module.
* \param localPath Path where to search for the shaders.
*/
WBoundaryFragments( boost::shared_ptr< const WDataSetScalar > texture,
boost::shared_ptr< const WProperties > properties,
boost::array< osg::ref_ptr< WGEManagedGroupNode >, 3 > *slices,
boost::filesystem::path localPath );
/**
* Starts rendering and finally insert result in output.
*
* \param output Where to put/insert the results.
* \param sliceNum If given -1 all slice will perform an update, otherwise only the slice with the given slice number.
*/
virtual void run( osg::ref_ptr< WGEManagedGroupNode > output, const char sliceNum = -1 );
protected:
private:
};
#endif // WBOUNDARYFRAGMENTS_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WBOUNDARYLINES_H
#define WBOUNDARYLINES_H
#include <list>
#include <utility>
#include <vector>
#include <boost/array.hpp>
#include <boost/unordered_map.hpp>
#include <osg/Geometry>
#include "core/common/WBoundingBox.h"
#include "WBoundaryBuilder.h"
// forward declarations
template< typename T >
class WGridRegular3DTemplate;
class WDataSetScalar;
/**
* Computes boundary lines with an iso lines approach instead of the fragment shader.
*/
class WBoundaryLines : public WBoundaryBuilder
{
public:
/**
* Constructs an builder instance.
*
* \param texture The underlying scalar dataset to compute those boundaries for
* \param properties Properties, like slice positions, thresholds etc.
* \param slices Slice geodes which are controlled (hide/unhide) by the module.
* \param localPath The path where the shaders reside
*/
WBoundaryLines( boost::shared_ptr< const WDataSetScalar > texture,
boost::shared_ptr< const WProperties > properties,
boost::array< osg::ref_ptr< WGEManagedGroupNode >, 3 > *slices,
boost::filesystem::path localPath );
/**
* Starts rendering and finally insert result in output.
*
* \param output Where to put/insert the results.
* \param sliceNum If given -1 all slice will perform an update, otherwise only the slice with the given slice number.
*/
virtual void run( osg::ref_ptr< WGEManagedGroupNode > output, const char sliceNum = -1 );
protected:
private:
/**
* Map for edgeID -> ( neighbourEdgeID1, neighbourEdgeID2 ).
*/
typedef boost::unordered_map< size_t, std::pair< int , int > > EdgeNeighbourMap;
/**
* Two pointIDs describing an edge.
*/
typedef std::pair< std::size_t, std::size_t > Edge;
//todo(math): Edge is wrong here, since that are not point but EdgeIDs
/**
* Vector of segments where two edgeIDs describing an segment.
*/
typedef std::vector< Edge > SegmentVector;
/**
* List of segments where two edgeIDs describing an segment.
*/
typedef std::list< Edge > SegmentList;
/**
* Creates for each slice number the corresponding geodes for a bounding box as well
* for the boundary curves.
*
* \param sliceNum For which slice the geode should be generated.
*
* \return A WGEGroupNode containing the bb geode as well as the boundary curve geode.
*/
osg::ref_ptr< WGEGroupNode > generateSlice( const unsigned char sliceNum ) const;
/**
* In order to compute iso lines of the gray and white matter for a specific slice, we need a grid to operate on. This
* grid represents a WGridRegular2DIn3D but the last dimension/numCoordsZ() is set to 1.
*
* \param sliceNum For which slice the grid should be generated.
* \param resolution The size of the cells in that grid.
*
* \return The 2D grid for the given slice.
*/
boost::shared_ptr< WGridRegular3DTemplate< double > > generateSliceGrid( const unsigned char sliceNum, const double resolution ) const;
/**
* Extracts the sequence of edges representing a line strip, where the first element in the hash map is a member of.
*
* \param l The hash map, containing edge numbers as keys and their left and right neighbour as the value pair.
*
* \return List of edge number of the line strip.
*/
std::list< size_t > extractLineStripEdges( EdgeNeighbourMap *l ) const;
/**
* Constructs a hash map where each grid edgeID ( the key ), has a pair of neighbour edgeIDs ( value ).
*
* \param segments List of segments given as pair of edgeIDs.
*
* \return The edge neighbour map.
*/
boost::shared_ptr< EdgeNeighbourMap > generateEdgeNeighbourMap( const SegmentList& segments ) const;
/**
* Construct a iso lines geometry for the given isovalue.
*
* \param isoValue The iso value
* \param map Containing edgeIDs as keys and
* \param edgeIDToPointIDs
* \param interpolates
* \param sliceGrid
*
* \return The osg geometry.
*/
osg::ref_ptr< osg::Geometry > traverseEdgeHashMap( double isoValue, boost::shared_ptr< WBoundaryLines::EdgeNeighbourMap > map,
const std::vector< Edge >& edgeIDToPointIDs, const std::vector< double > &interpolates,
boost::shared_ptr< const WGridRegular3DTemplate< double > > sliceGrid ) const;
/**
* Generates the bounding boxes for all three slices.
*/
void computeSliceBB();
/**
* Boundingboxes for each slice.
* 0 : xSlice, 1 : ySlice, 2 : zSlice
*/
boost::array< WBoundingBox, 3 > m_sliceBB;
/**
* Shortcut for the WRegularGrid3D given via the m_texture dataset.
*/
boost::shared_ptr< WGridRegular3DTemplate< double > > m_grid;
/**
* Defines the size of quads to be processed for the iso curve computation.
*/
WPropDouble m_resolution;
};
#endif // WBOUNDARYLINES_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//