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/>.
//
//---------------------------------------------------------------------------
#include <algorithm>
#include <bitset>
#include <list>
#include <boost/unordered_map.hpp>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/LineWidth>
#include "core/dataHandler/WDataSetScalar.h"
#include "core/dataHandler/WGridRegular3D.h"
#include "core/graphicsEngine/WGEGeodeUtils.h"
#include "WBoundaryLines.h"
WBoundaryLines::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 )
: WBoundaryBuilder( texture, properties, slices )
{
m_grid = boost::shared_dynamic_cast< WGridRegular3D >( m_texture->getGrid() );
m_resolution = properties->findProperty( "Resolution" )->toPropDouble();
m_shader = osg::ref_ptr< WGEShader > ( new WGEShader( "WMBoundaryCurvesWMGM-IsoLines", localPath ) );
WAssert( m_grid, "Bug: each DataSetScalar should have a regular grid 3d!!!" );
}
void WBoundaryLines::run( osg::ref_ptr< WGEManagedGroupNode > output, const char sliceNum )
{
computeSliceBB();
if( sliceNum == -1 )
{
for( char i = 0; i < 3; ++i )
{
output->remove( m_slices[i] );
osg::ref_ptr< WGEGroupNode > newNode = generateSlice( i );
m_slices[i]->clear();
m_slices[i]->insert( newNode );
m_shader->apply( m_slices[i] );
output->insert( m_slices[i] );
}
}
else
{
output->remove( m_slices[ sliceNum ] );
osg::ref_ptr< WGEGroupNode > newNode = generateSlice( sliceNum );
m_slices[ sliceNum ]->clear();
m_slices[ sliceNum ]->insert( newNode );
output->insert( m_slices[ sliceNum ] );
}
}
boost::shared_ptr< WGridRegular3D > WBoundaryLines::generateSliceGrid( const unsigned char sliceNum, const double resolution ) const
{
// compute indices of the other dimensions
boost::array< std::pair< size_t, size_t >, 3 > otherDims = { { std::make_pair( 1, 2 ), std::make_pair( 0, 2 ), std::make_pair( 0, 1 ) } }; // NOLINT curly braces
size_t x = otherDims[sliceNum].first;
size_t y = otherDims[sliceNum].second;
boost::array< WVector3d, 3 > directions = getDirections< double >( m_grid );
boost::array< unsigned int, 3 > numCoords = getNbCoords< double >( m_grid );
boost::array< double, 3 > offsets = getOffsets< double >( m_grid );
double delta = 1e-3; // since the positions at the boundaries of the result must lie withing m_grid in order to get the interpolation working.
size_t nbPosX = static_cast< size_t >( ( ( numCoords[x] - 1 ) * offsets[x] - delta ) / resolution );
size_t nbPosY = static_cast< size_t >( ( ( numCoords[y] - 1 ) * offsets[y] - delta ) / resolution );
double slicePos = m_slicePos[ sliceNum ]->get();
if( m_slicePos[ sliceNum ]->get() == numCoords[ sliceNum ] - 1 )
{
slicePos -= delta;
}
WPosition origin = m_grid->getOrigin() + directions[ sliceNum ] * slicePos;
WVector3d xDir = normalize( directions[x] ) * resolution;
WVector3d yDir = normalize( directions[y] ) * resolution;
WMatrix< double > mat( 4, 4 );
mat.makeIdentity();
mat( 0, 0 ) = xDir[0];
mat( 1, 0 ) = xDir[1];
mat( 2, 0 ) = xDir[2];
mat( 0, 1 ) = yDir[0];
mat( 1, 1 ) = yDir[1];
mat( 2, 1 ) = yDir[2];
// set zdirection to an orthogonal vector
WVector3d zDir = cross( xDir, yDir );
mat( 0, 2 ) = zDir[0];
mat( 1, 2 ) = zDir[1];
mat( 2, 2 ) = zDir[2];
mat( 0, 3 ) = origin[0];
mat( 1, 3 ) = origin[1];
mat( 2, 3 ) = origin[2];
WGridTransformOrtho v( mat );
boost::shared_ptr< WGridRegular3D > result( new WGridRegular3D( nbPosX, nbPosY, 1, v ) );
return result;
}
std::list< size_t > WBoundaryLines::extractLineStripEdges( WBoundaryLines::EdgeNeighbourMap *l ) const
{
std::list< size_t > result;
result.push_back( l->begin()->first );
int left = l->begin()->second.first;
int right = l->begin()->second.second;
l->erase( result.front() );
// try first direction as long as possible
while( l->find( right ) != l->end() )
{
size_t pred = result.back();
result.push_back( right );
int newRight = ( *l )[right].second;
if( newRight == static_cast< int >( pred ) )
{
newRight = ( *l )[right].first;
}
l->erase( right );
right = newRight;