Commit f2ed7cba authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - skeleton for fiber coloring algorithm alowing fibers to be colored...

[ADD] - skeleton for fiber coloring algorithm alowing fibers to be colored using, for example, angles between segments ...
parent 2967661d
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 <vector>
#include <string>
#include "../../kernel/WKernel.h"
#include "../../common/WPropertyHelper.h"
#include "../../dataHandler/WDataHandler.h"
#include "../../dataHandler/WDataTexture3D.h"
#include "WMFiberParameterColoring.h"
#include "WMFiberParameterColoring.xpm"
// This line is needed by the module loader to actually find your module. You need to add this to your module too. Do NOT add a ";" here.
W_LOADABLE_MODULE( WMFiberParameterColoring )
WMFiberParameterColoring::WMFiberParameterColoring():
WModule()
{
}
WMFiberParameterColoring::~WMFiberParameterColoring()
{
// Cleanup!
}
boost::shared_ptr< WModule > WMFiberParameterColoring::factory() const
{
return boost::shared_ptr< WModule >( new WMFiberParameterColoring() );
}
const char** WMFiberParameterColoring::getXPMIcon() const
{
return WMFiberParameterColoring_xpm;
}
const std::string WMFiberParameterColoring::getName() const
{
return "Fiber Parameter Coloring";
}
const std::string WMFiberParameterColoring::getDescription() const
{
return "This module can color fibers according to different parameters and schemes.";
}
void WMFiberParameterColoring::connectors()
{
// The input fiber dataset
m_fiberInput = boost::shared_ptr< WModuleInputData < WDataSetFibers > >(
new WModuleInputData< WDataSetFibers >( shared_from_this(), "fibers", "The fiber dataset to color" )
);
// As properties, every connector needs to be added to the list of connectors.
addConnector( m_fiberInput );
// the selected fibers go to this output
m_fiberOutput = boost::shared_ptr< WModuleOutputData < WDataSetFibers > >(
new WModuleOutputData< WDataSetFibers >( shared_from_this(),
"out", "The fiber dataset colored by this module." )
);
// As above: make it known.
addConnector( m_fiberOutput );
// call WModule's initialization
WModule::connectors();
}
void WMFiberParameterColoring::properties()
{
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
// call WModule's initialization
WModule::properties();
}
void WMFiberParameterColoring::moduleMain()
{
// get notified about data changes
m_moduleState.setResetable( true, true );
m_moduleState.add( m_fiberInput->getDataChangedCondition() );
// Remember the condition provided to some properties in properties()? The condition can now be used with this condition set.
m_moduleState.add( m_propCondition );
ready();
// main loop
while ( !m_shutdownFlag() )
{
debugLog() << "Waiting ...";
m_moduleState.wait();
// woke up since the module is requested to finish?
if ( m_shutdownFlag() )
{
break;
}
// To query whether an input was updated, simply ask the input:
bool dataUpdated = m_fiberInput->updated();
boost::shared_ptr< WDataSetFibers > dataSet = m_fiberInput->getData();
bool dataValid = ( dataSet );
if ( !dataValid && !dataUpdated )
{
continue;
}
// update coloring
dataSet->getVertices()->size();
debugLog() << "Done";
}
}
//---------------------------------------------------------------------------
//
// 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 WMFIBERPARAMETERCOLORING_H
#define WMFIBERPARAMETERCOLORING_H
#include <string>
#include "../../dataHandler/WDataSetScalar.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../kernel/WModuleOutputData.h"
/**
* This modules takes a dataset and equalizes its histogram.
*
* \ingroup modules
*/
class WMFiberParameterColoring: public WModule
{
public:
/**
* Default constructor.
*/
WMFiberParameterColoring();
/**
* Destructor.
*/
virtual ~WMFiberParameterColoring();
/**
* 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:
/**
* The fiber dataset which is going to be filtered.
*/
boost::shared_ptr< WModuleInputData< WDataSetFibers > > m_fiberInput;
/**
* The output connector used to provide the calculated data to other modules.
*/
boost::shared_ptr< WModuleOutputData< WDataSetFibers > > m_fiberOutput;
/**
* A condition used to notify about changes in several properties.
*/
boost::shared_ptr< WCondition > m_propCondition;
};
#endif // WMFIBERPARAMETERCOLORING_H
/* XPM */
static const char * WMFiberParameterColoring_xpm[] = {
"16 16 3 1",
" c None",
". c #000000",
"+ c #0000FF",
" . ",
" + ",
" + .. ",
" + .. ",
" + ... ",
" + .. ... ",
" + .. ... ",
" + ....... ",
" + ........ ",
" + ......... ",
" + .......... ",
" + ............ ",
" +..............",
" +............. ",
" ++++++++++++++.",
" "};
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