Commit fbaa3afe by Sebastian Eichelbaum

[REMOVE] - removed obsolete grid renderer module.

parent 0627ed6c
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 "${OWmodulesPrefix}_${MODULE_NAME}" ) # prefix all module names with "OWmodule_" to separate them from other libs
SET( ${MODULE_NAME}_COMBINER_SRC ${MODULES_SRC} )
SET( ${MODULE_NAME}_ALL_CPP ${MODULES_SRC} )
FILE( GLOB_RECURSE ${MODULE_NAME}_REMOVE_H "*.h" )
LIST( REMOVE_ITEM ${MODULE_NAME}_ALL_CPP ${${MODULE_NAME}_REMOVE_H} )
IF( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/" )
FILE( GLOB_RECURSE ${MODULE_NAME}_REMOVE_TEST "test/*.cpp" "test/*.h" )
LIST( REMOVE_ITEM ${MODULE_NAME}_ALL_CPP ${${MODULE_NAME}_REMOVE_TEST} )
LIST( REMOVE_ITEM ${MODULE_NAME}_COMBINER_SRC ${${MODULE_NAME}_REMOVE_TEST} )
ENDIF( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/" )
LIST( LENGTH ${MODULE_NAME}_ALL_CPP cpp_count )
IF( ${cpp_count} GREATER 3 )
IF( OW_BUILD_AS_ONE_BIG_FILE )
SET( UNITY_BUILD_FILE_NAME "${MODULE_NAME}UnityBuildFile.cpp" )
GENERATE_UNITY_BUILD_FILE( ${MODULE_NAME}_ALL_CPP )
ADD_LIBRARY( ${MODULE_NAME} SHARED ${UNITY_BUILD_FILE_NAME} ${${MODULE_NAME}_COMBINER_SRC} )
ENDIF( OW_BUILD_AS_ONE_BIG_FILE )
ENDIF( ${cpp_count} GREATER 3 )
IF( ( NOT OW_BUILD_AS_ONE_BIG_FILE ) OR NOT ( ${cpp_count} GREATER 3 ) )
ADD_LIBRARY( ${MODULE_NAME} SHARED ${${MODULE_NAME}_COMBINER_SRC} )
ENDIF( ( NOT OW_BUILD_AS_ONE_BIG_FILE ) OR NOT ( ${cpp_count} GREATER 3 ) )
# Build module lib
#ADD_LIBRARY( ${MODULE_NAME} SHARED ${MODULES_SRC} )
TARGET_LINK_LIBRARIES( ${MODULE_NAME} ${OWKernelName} )
IF(MSVC_IDE)
SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES PREFIX "../")
ENDIF(MSVC_IDE)
# 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}"
"${OWKernelName};${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-Leipzig and CNCF-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 <string>
#include "WMGridRenderer.xpm"
#include "../../kernel/WKernel.h"
#include "WMGridRenderer.h"
// This line is needed by the module loader to actually find your module. Do not remove. Do NOT add a ";" here.
W_LOADABLE_MODULE( WMGridRenderer )
WMGridRenderer::WMGridRenderer():
WModule()
{
}
WMGridRenderer::~WMGridRenderer()
{
// Cleanup!
}
boost::shared_ptr< WModule > WMGridRenderer::factory() const
{
// See "src/modules/template/" for an extensively documented example.
return boost::shared_ptr< WModule >( new WMGridRenderer() );
}
const char** WMGridRenderer::getXPMIcon() const
{
return gridRenderer_xpm;
}
const std::string WMGridRenderer::getName() const
{
return "Grid Renderer";
}
const std::string WMGridRenderer::getDescription() const
{
return "Renders the grid structure of a data set.";
}
void WMGridRenderer::connectors()
{
// initialize connectors
m_input = boost::shared_ptr< WModuleInputData < WDataSetSingle > >(
new WModuleInputData< WDataSetSingle >( shared_from_this(), "grid", "Dataset containing the grid" ) );
addConnector( m_input );
// call WModules initialization
WModule::connectors();
}
void WMGridRenderer::properties()
{
WModule::properties();
}
void WMGridRenderer::moduleMain()
{
m_moduleState.add( m_input->getDataChangedCondition() );
ready();
// loop until the module container requests the module to quit
while( !m_shutdownFlag() )
{
if( !m_input->getData().get() )
{
// OK, the output has not yet sent data
debugLog() << "Waiting for data ...";
m_moduleState.wait();
continue;
}
render();
m_moduleState.wait();
}
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_moduleNode );
}
void WMGridRenderer::render()
{
if( m_gridGeode )
{
m_moduleNode->remove( m_gridGeode );
}
boost::shared_ptr< WGrid > grid = m_input->getData()->getGrid();
boost::shared_ptr< WGridRegular3D > gridR3D;
gridR3D = boost::shared_dynamic_cast< WGridRegular3D >( grid );
WAssert( gridR3D, "This module can only handle regular 3D grids so far." );
//-------------------------------
// DRAW
m_moduleNode = new WGEGroupNode();
osg::Geometry* gridGeometry = new osg::Geometry();
m_gridGeode = osg::ref_ptr< osg::Geode >( new osg::Geode );
m_gridGeode->setName( "grid" );
osg::ref_ptr< osg::Vec3Array > vertArray = new osg::Vec3Array( gridR3D->size() );
for( unsigned int vertId = 0; vertId < gridR3D->size(); ++vertId )
{
wmath::WPosition gridPos = gridR3D->getPosition( vertId );
( *vertArray )[vertId][0] = gridPos[0];
( *vertArray )[vertId][1] = gridPos[1];
( *vertArray )[vertId][2] = gridPos[2];
}
gridGeometry->setVertexArray( vertArray );
osg::DrawElementsUInt* gridElement;
gridElement = new osg::DrawElementsUInt( osg::PrimitiveSet::LINES, 0 );
gridElement->reserve( gridR3D->size() * 2 );
size_t sx = gridR3D->getNbCoordsX();
size_t sy = gridR3D->getNbCoordsY();
size_t sz = gridR3D->getNbCoordsZ();
for( unsigned int vertIdX = 0; vertIdX < sx; ++vertIdX )
{
for( unsigned int vertIdY = 0; vertIdY < sy; ++vertIdY )
{
for( unsigned int vertIdZ = 0; vertIdZ < sz; ++vertIdZ )
{
size_t id = vertIdX + vertIdY * sx + vertIdZ * sx * sy;
if( vertIdX < sx - 1 )
{
gridElement->push_back( id );
gridElement->push_back( id + 1 );
}
if( vertIdY < sy - 1 )
{
gridElement->push_back( id );
gridElement->push_back( id + sx );
}
if( vertIdZ < sz - 1 )
{
gridElement->push_back( id );
gridElement->push_back( id + sx * sy );
}
}
}
}
gridGeometry->addPrimitiveSet( gridElement );
m_gridGeode->addDrawable( gridGeometry );
m_moduleNode->insert( m_gridGeode );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_moduleNode );
}
void WMGridRenderer::activate()
{
if( m_gridGeode )
{
if( m_active->get() )
{
m_gridGeode->setNodeMask( 0xFFFFFFFF );
}
else
{
m_gridGeode->setNodeMask( 0x0 );
}
}
WModule::activate();
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-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 WMGRIDRENDERER_H
#define WMGRIDRENDERER_H
#include <string>
#include <osg/Geode>
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../kernel/WModuleOutputData.h"
/**
* Someone should add some documentation here.
* Probably the best person would be the module's
* creator, i.e. "wiebel".
*
* This is only an empty template for a new module. For
* an example module containing many interesting concepts
* and extensive documentation have a look at "src/modules/template"
*
* \ingroup modules
*/
class WMGridRenderer: public WModule
{
public:
/**
*
*/
WMGridRenderer();
/**
*
*/
virtual ~WMGridRenderer();
/**
* Gives back the name of this module.
* \return the module's name.
*/
virtual const std::string getName() const;
/**
* Gives back a description of this module.
* \return description to module.
*/
virtual const std::string getDescription() const;
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
*
* \return the prototype used to create every module in OpenWalnut.
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Get the icon for this module in XPM format.
*/
virtual const char** getXPMIcon() const;
protected:
/**
* Entry point after loading the module. Runs in separate thread.
*/
virtual void moduleMain();
/**
* Initialize the connectors this module is using.
*/
virtual void connectors();
/**
* Initialize the properties for this module.
*/
virtual void properties();
private:
/**
* Gets signaled from the properties object when something was changed. Now, only m_active is used. This method therefore simply
* activates/deactivates the BBox.
*/
void activate();
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input; //!< Input connector required by this module.
void render(); //!< Helper method doing the actual prparation of the graphics.
osg::ref_ptr< osg::Geode > m_gridGeode; //!< Pointer to geode containing the grid.
osg::ref_ptr< WGEGroupNode > m_moduleNode; //!< Pointer to the modules group node.
};
#endif // WMGRIDRENDERER_H
/* XPM */
static const char * gridRenderer_xpm[] = {
"16 16 2 1",
" c None",
". c #000000",
" ",
" ............. ",
" . . . . . ",
" . . . . . ",
" ............. ",
" . . . . . ",
" . . . . . ",
" ............. ",
" . . . . . ",
" . . . . . ",
" ............. ",
" . . . . . ",
" . . . . . ",
" ............. ",
" ",
" "};
......@@ -9,7 +9,6 @@ ADD_SUBDIRECTORY( distanceMap )
ADD_SUBDIRECTORY( distanceMapIsosurface )
ADD_SUBDIRECTORY( fiberDisplay )
ADD_SUBDIRECTORY( functionalMRIViewer )
ADD_SUBDIRECTORY( gridRenderer )
ADD_SUBDIRECTORY( hud )
ADD_SUBDIRECTORY( imageSpaceLIC )
ADD_SUBDIRECTORY( isosurfaceRaytracer )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment