Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
94e19258
Commit
94e19258
authored
Nov 25, 2010
by
Sebastian Eichelbaum
Browse files
[MERGE]
parents
ee2144bc
758df595
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1038 additions
and
67 deletions
+1038
-67
src/dataHandler/WDataHandlerEnums.h
src/dataHandler/WDataHandlerEnums.h
+12
-1
src/dataHandler/WDataSetSphericalHarmonics.cpp
src/dataHandler/WDataSetSphericalHarmonics.cpp
+1
-1
src/dataHandler/io/WReaderNIfTI.cpp
src/dataHandler/io/WReaderNIfTI.cpp
+2
-2
src/dataHandler/io/WReaderNIfTI.h
src/dataHandler/io/WReaderNIfTI.h
+3
-1
src/graphicsEngine/WPickHandler.cpp
src/graphicsEngine/WPickHandler.cpp
+14
-9
src/graphicsEngine/WPickHandler.h
src/graphicsEngine/WPickHandler.h
+8
-1
src/modules/fiberDisplay/WMFiberDisplay.cpp
src/modules/fiberDisplay/WMFiberDisplay.cpp
+49
-9
src/modules/fiberDisplay/WMFiberDisplay.h
src/modules/fiberDisplay/WMFiberDisplay.h
+15
-5
src/modules/modules-io.toolbox
src/modules/modules-io.toolbox
+1
-0
src/modules/readMesh/WMReadMesh.cpp
src/modules/readMesh/WMReadMesh.cpp
+1
-1
src/modules/readMesh/WMReadMesh.h
src/modules/readMesh/WMReadMesh.h
+2
-2
src/modules/readMesh/WMReadMesh.xpm
src/modules/readMesh/WMReadMesh.xpm
+35
-35
src/modules/readSphericalHarmonics/CMakeLists.txt
src/modules/readSphericalHarmonics/CMakeLists.txt
+46
-0
src/modules/readSphericalHarmonics/WMReadSphericalHarmonics.cpp
...dules/readSphericalHarmonics/WMReadSphericalHarmonics.cpp
+120
-0
src/modules/readSphericalHarmonics/WMReadSphericalHarmonics.h
...modules/readSphericalHarmonics/WMReadSphericalHarmonics.h
+113
-0
src/modules/readSphericalHarmonics/WMReadSphericalHarmonics.xpm
...dules/readSphericalHarmonics/WMReadSphericalHarmonics.xpm
+616
-0
No files found.
src/dataHandler/WDataHandlerEnums.h
View file @
94e19258
...
...
@@ -28,7 +28,7 @@
#include <stdint.h>
/**
* Data
set
types and number values taken from the nifti1.h, at this point it's unknown if it makes sense
* Data types and number values taken from the nifti1.h, at this point it's unknown if it makes sense
* to keep the bit coding, but it doesn't hurt either
* \ingroup dataHandler
*/
...
...
@@ -173,6 +173,17 @@ enum qformOrientation
Inferior_to_Superior
};
/**
* Data set types. Not complete! Only those used for distinctions so far.
* \ingroup dataHandler
*/
enum
DataSetType
{
W_DATASET_NONE
=
0
,
W_DATASET_SINGLE
=
1
,
W_DATASET_SPHERICALHARMONICS
=
2
};
/**
* \defgroup dataHandler Data Handler
*
...
...
src/dataHandler/WDataSetSphericalHarmonics.cpp
View file @
94e19258
...
...
@@ -41,7 +41,7 @@ WDataSetSphericalHarmonics::WDataSetSphericalHarmonics( boost::shared_ptr< WValu
m_valueSet
=
boost
::
shared_dynamic_cast
<
WValueSet
<
double
>
>
(
newValueSet
);
WAssert
(
newValueSet
,
"No value set given."
);
WAssert
(
newGrid
,
"No grid given."
);
WAssert
(
m_valueSet
,
"No WValueSet<double given."
);
WAssert
(
m_valueSet
,
"No WValueSet<double
>
given."
);
}
WDataSetSphericalHarmonics
::
WDataSetSphericalHarmonics
()
...
...
src/dataHandler/io/WReaderNIfTI.cpp
View file @
94e19258
...
...
@@ -83,7 +83,7 @@ wmath::WMatrix< double > WReaderNIfTI::convertMatrix( const mat44& in )
return
out
;
}
boost
::
shared_ptr
<
WDataSet
>
WReaderNIfTI
::
load
()
boost
::
shared_ptr
<
WDataSet
>
WReaderNIfTI
::
load
(
DataSetType
dataSetType
)
{
nifti_image
*
header
=
nifti_image_read
(
m_fname
.
c_str
(),
0
);
...
...
@@ -186,7 +186,7 @@ boost::shared_ptr< WDataSet > WReaderNIfTI::load()
// }
// else
if
(
!
description
.
compare
(
"WDataSetSphericalHarmonics"
)
)
if
(
description
.
compare
(
"WDataSetSphericalHarmonics"
)
==
0
||
dataSetType
==
W_DATASET_SPHERICALHARMONICS
)
{
wlog
::
debug
(
"WReaderNIfTI"
)
<<
"Load as spherical harmonics"
<<
std
::
endl
;
newDataSet
=
boost
::
shared_ptr
<
WDataSet
>
(
new
WDataSetSphericalHarmonics
(
newValueSet
,
newGrid
)
);
...
...
src/dataHandler/io/WReaderNIfTI.h
View file @
94e19258
...
...
@@ -58,9 +58,11 @@ public:
/**
* Loads the dataset.
*
* \param dataSetType This parameter can be used to tell the function in advance how it should interprete the data.
*
* \return the dataset loaded.
*/
virtual
boost
::
shared_ptr
<
WDataSet
>
load
();
virtual
boost
::
shared_ptr
<
WDataSet
>
load
(
DataSetType
dataSetType
=
W_DATASET_NONE
);
protected:
private:
...
...
src/graphicsEngine/WPickHandler.cpp
View file @
94e19258
...
...
@@ -162,6 +162,19 @@ std::string extractSuitableName( osgUtil::LineSegmentIntersector::Intersections:
return
""
;
// This line will not be reached.
}
void
WPickHandler
::
updatePickInfoModifierKeys
(
WPickInfo
*
pickInfo
)
{
if
(
m_shift
)
{
pickInfo
->
setModifierKey
(
WPickInfo
::
SHIFT
);
}
if
(
m_ctrl
)
{
pickInfo
->
setModifierKey
(
WPickInfo
::
STRG
);
}
}
void
WPickHandler
::
pick
(
osgViewer
::
View
*
view
,
const
osgGA
::
GUIEventAdapter
&
ea
)
{
osgUtil
::
LineSegmentIntersector
::
Intersections
intersections
;
...
...
@@ -171,15 +184,7 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
WPickInfo
pickInfo
;
if
(
m_shift
)
{
pickInfo
.
setModifierKey
(
WPickInfo
::
SHIFT
);
}
if
(
m_ctrl
)
{
pickInfo
.
setModifierKey
(
WPickInfo
::
STRG
);
}
updatePickInfoModifierKeys
(
&
pickInfo
);
// if we are in another viewer than the main view we just need the pixel position
if
(
m_viewerName
!=
""
&&
m_viewerName
!=
"main"
)
...
...
src/graphicsEngine/WPickHandler.h
View file @
94e19258
...
...
@@ -128,7 +128,14 @@ protected:
private:
boost
::
signals2
::
signal1
<
void
,
WPickInfo
>
m_pickSignal
;
//!< One can register to this signal to receive pick events.
/**
* Sets the current modifiers to the provided pickInfo
*
* \param pickInfo This pickInfo will be updated.
*/
void
updatePickInfoModifierKeys
(
WPickInfo
*
pickInfo
);
boost
::
signals2
::
signal1
<
void
,
WPickInfo
>
m_pickSignal
;
//!< One can register to this signal to receive pick events.
};
#endif // WPICKHANDLER_H
src/modules/fiberDisplay/WMFiberDisplay.cpp
View file @
94e19258
...
...
@@ -70,10 +70,13 @@ void WMFiberDisplay::connectors()
{
using
boost
::
shared_ptr
;
typedef
WModuleInputData
<
const
WDataSetFibers
>
FiberInputData
;
// just an alias
typedef
WModuleOutputData
<
WDataSetFibers
>
FiberOutputData
;
// just an alias
m_fiberInput
=
shared_ptr
<
FiberInputData
>
(
new
FiberInputData
(
shared_from_this
(),
"fiberInput"
,
"A loaded fiber dataset."
)
);
m_fiberOutput
=
shared_ptr
<
FiberOutputData
>
(
new
FiberOutputData
(
shared_from_this
(),
"fiberOutput"
,
"The selected fibers."
)
);
addConnector
(
m_fiberInput
);
addConnector
(
m_fiberOutput
);
WModule
::
connectors
();
// call WModules initialization
}
...
...
@@ -169,13 +172,12 @@ void WMFiberDisplay::properties()
m_tubeThickness
->
setMin
(
0
);
m_tubeThickness
->
setMax
(
300
);
m_save
=
m_properties
->
addProperty
(
"Save"
,
"Saves the selected fiber bundles."
,
false
,
m_propCondition
);
m_saveFileName
=
m_properties
->
addProperty
(
"File name"
,
""
,
WPathHelper
::
getAppPath
()
);
m_cullBoxGroup
=
m_properties
->
addPropertyGroup
(
"Box Culling"
,
"Properties only related to the box culling."
,
m_propCondition
);
m_activateCullBox
=
m_cullBoxGroup
->
addProperty
(
"Activate"
,
"Activates the cull box"
,
false
,
m_propCondition
);
m_showCullBox
=
m_cullBoxGroup
->
addProperty
(
"Show cull box"
,
"Shows/hides the cull box"
,
false
,
m_propCondition
);
m_insideCullBox
=
m_cullBoxGroup
->
addProperty
(
"Inside - outside"
,
"Show fibers inside or outside the cull box"
,
true
,
m_propCondition
);
m_propUpdateOutputTrigger
=
m_properties
->
addProperty
(
"Update Output"
,
"Update!"
,
WPVBaseTypes
::
PV_TRIGGER_READY
,
m_propCondition
);
}
...
...
@@ -227,6 +229,12 @@ void WMFiberDisplay::moduleMain()
m_cullBox
->
hide
();
}
}
if
(
m_propUpdateOutputTrigger
->
get
(
true
)
==
WPVBaseTypes
::
PV_TRIGGER_TRIGGERED
)
{
updateOutput
();
m_propUpdateOutputTrigger
->
set
(
WPVBaseTypes
::
PV_TRIGGER_READY
,
false
);
}
}
con
.
disconnect
();
...
...
@@ -388,12 +396,6 @@ void WMFiberDisplay::updateRenderModes()
}
}
void
WMFiberDisplay
::
saveSelected
()
{
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
active
=
m_fiberSelector
->
getBitfield
();
m_dataset
->
saveSelected
(
m_saveFileName
->
getAsString
(),
active
);
}
void
WMFiberDisplay
::
updateTexture
()
{
osg
::
StateSet
*
rootState
=
m_osgNode
->
getOrCreateStateSet
();
...
...
@@ -450,3 +452,41 @@ void WMFiberDisplay::updateCallback()
updateRenderModes
();
}
void
WMFiberDisplay
::
updateOutput
()
{
boost
::
shared_ptr
<
std
::
vector
<
bool
>
>
active
=
m_fiberSelector
->
getBitfield
();
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
vertices
=
boost
::
shared_ptr
<
std
::
vector
<
float
>
>
(
new
std
::
vector
<
float
>
()
);
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
lineStartIndexes
=
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
(
new
std
::
vector
<
size_t
>
()
);
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
lineLengths
=
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
(
new
std
::
vector
<
size_t
>
()
);
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
verticesReverse
=
boost
::
shared_ptr
<
std
::
vector
<
size_t
>
>
(
new
std
::
vector
<
size_t
>
()
);
std
::
pair
<
wmath
::
WPosition
,
wmath
::
WPosition
>
boundingBox
=
m_dataset
->
getBoundingBox
();
size_t
countLines
=
0
;
for
(
size_t
l
=
0
;
l
<
active
->
size
();
++
l
)
{
if
(
(
*
active
)[
l
]
)
{
size_t
pc
=
m_dataset
->
getLineStartIndexes
()
->
at
(
l
)
*
3
;
lineStartIndexes
->
push_back
(
vertices
->
size
()
/
3
);
lineLengths
->
push_back
(
m_dataset
->
getLineLengths
()
->
at
(
l
)
);
for
(
size_t
j
=
0
;
j
<
m_dataset
->
getLineLengths
()
->
at
(
l
);
++
j
)
{
vertices
->
push_back
(
m_dataset
->
getVertices
()
->
at
(
pc
)
);
++
pc
;
vertices
->
push_back
(
m_dataset
->
getVertices
()
->
at
(
pc
)
);
++
pc
;
vertices
->
push_back
(
m_dataset
->
getVertices
()
->
at
(
pc
)
);
++
pc
;
verticesReverse
->
push_back
(
countLines
);
}
++
countLines
;
}
}
boost
::
shared_ptr
<
WDataSetFibers
>
newOutput
=
boost
::
shared_ptr
<
WDataSetFibers
>
(
new
WDataSetFibers
(
vertices
,
lineStartIndexes
,
lineLengths
,
verticesReverse
,
boundingBox
)
);
m_fiberOutput
->
updateData
(
newOutput
);
}
src/modules/fiberDisplay/WMFiberDisplay.h
View file @
94e19258
...
...
@@ -39,6 +39,7 @@
#include "../../kernel/WFiberSelector.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../kernel/WModuleOutputData.h"
/**
* Module for drawing fibers
...
...
@@ -148,9 +149,6 @@ private:
WPropBool
m_useTubesProp
;
//!< Property indicating whether to use tubes for the fibers tracts.
WPropBool
m_useTextureProp
;
//!< Property indicating whether to use tubes for the fibers tracts.
WPropDouble
m_tubeThickness
;
//!< Property determining the thickness of tubes .
WPropBool
m_save
;
//!< this should be a button
WPropFilename
m_saveFileName
;
//!< the filename for saving
WBoolFlag
m_noData
;
//!< Flag indicating whether there is data to display.
WPropGroup
m_cullBoxGroup
;
//!< property group for box culling
...
...
@@ -158,11 +156,22 @@ private:
WPropBool
m_showCullBox
;
//!< Enable/Disable showing of the cull box
WPropBool
m_insideCullBox
;
//!< if true fibers inside the cull box are shown, outside if false
/**
* This property triggers the updating of the output connector, as it would be too slow to do on every
* selection change
*/
WPropTrigger
m_propUpdateOutputTrigger
;
/**
* Input connector for a fiber dataset.
*/
boost
::
shared_ptr
<
WModuleInputData
<
const
WDataSetFibers
>
>
m_fiberInput
;
/**
* Output connector for a fiber dataset.
*/
boost
::
shared_ptr
<
WModuleOutputData
<
WDataSetFibers
>
>
m_fiberOutput
;
/**
* Pointer to the fiber data set
*/
...
...
@@ -250,9 +259,10 @@ private:
osg
::
ref_ptr
<
WROIBox
>
m_cullBox
;
//!< stores a pointer to the cull box
/**
* saves the currently selected (active field from roi manager) fibers to a file
* updates the output connector with the currently selected fiber,
* this is done on demand to avoid recomputation every time the selection changes
*/
void
saveSelected
();
void
updateOutput
();
/**
* creates and initializes the uniform parameters for the shader
...
...
src/modules/modules-io.toolbox
View file @
94e19258
ADD_SUBDIRECTORY( exportGeometry )
ADD_SUBDIRECTORY( readMesh )
ADD_SUBDIRECTORY( readSphericalHarmonics )
ADD_SUBDIRECTORY( writeMesh )
ADD_SUBDIRECTORY( writeNIfTI )
ADD_SUBDIRECTORY( writeTracts )
src/modules/readMesh/WMReadMesh.cpp
View file @
94e19258
...
...
@@ -55,7 +55,7 @@ boost::shared_ptr< WModule > WMReadMesh::factory() const
const
char
**
WMReadMesh
::
getXPMIcon
()
const
{
return
r
eadMesh_xpm
;
return
WMR
eadMesh_xpm
;
}
const
std
::
string
WMReadMesh
::
getName
()
const
...
...
src/modules/readMesh/WMReadMesh.h
View file @
94e19258
...
...
@@ -111,8 +111,8 @@ private:
virtual
boost
::
shared_ptr
<
WTriangleMesh
>
read
();
boost
::
shared_ptr
<
WTriangleMesh
>
m_triMesh
;
//!< This triangle mesh is provided as output through the connector.
boost
::
shared_ptr
<
WModuleOutputData
<
WTriangleMesh
>
>
m_output
;
//!<
In
put connector
requir
ed by this module.
boost
::
shared_ptr
<
WCondition
>
m_propCondition
;
//!<A condition used to notify about changes in several properties.
boost
::
shared_ptr
<
WModuleOutputData
<
WTriangleMesh
>
>
m_output
;
//!<
Out
put connector
provid
ed by this module.
boost
::
shared_ptr
<
WCondition
>
m_propCondition
;
//!<
A condition used to notify about changes in several properties.
WPropTrigger
m_readTriggerProp
;
//!< This property triggers the actual reading,
WPropFilename
m_meshFile
;
//!< The mesh will be read from this file.
};
...
...
src/modules/readMesh/WMReadMesh.xpm
View file @
94e19258
/* XPM */
static const char *
r
eadMesh_xpm[] = {
static const char *
WMR
eadMesh_xpm[] = {
"32 32 3 1",
" c None",
". c #
7F6DC5
",
"+ c #
000000
",
"
",
"
..
",
"
...
...
.....
",
"
........
..
...... ..
",
"
..... .............
..
",
"
..
...
.....
..
",
"
.
..
...
..
",
"
.
..
....
..
",
"
..
...
.. ...
..
",
"
..
...
.. ...
..
",
"
..
..
.. ...
..
",
"
.
..
.
.. ..
",
"
.
...
.
.. ..
",
"
..
...
....
",
"
.........................
",
"
........ ... .......
",
"
..
...
....
",
"
..
....
.. ..
",
"
.
...
.
.. ..
",
"
..
...
.
.. +..
",
"
..
...
..
..
++.
",
"
..
..
.. ..
+++
",
"
.
..
.. ..
++++
",
"
.
..
+++++++++++++++
",
"
.. ...
++++++++++++++++
",
"
.....
++++++++++++++++
",
"
....
.....++++++++++++++++
",
"
.. ........ +++++++++++++++
",
"
........
++++
",
"
...
+++
",
"
++
",
"
+
"};
". c #
000000
",
"+ c #
7F6DC5
",
"
.........
",
"
..........
",
"
..++++++
...
+++++
",
"
..+++++++
..
+
++++++ ++
",
"
..+++++ ...++++++++++++
++
",
"..........
+++++
++
",
"
......
..
.
+++
++
",
"
.
.
+
..
++
++++
++
",
"..
++
...
+++
++ +++
++
",
"..
++
...
+++ ++ +++
++
",
"..
++
..
++ ++ +++
++
",
"
..
+
..
.
++
+
++ ++
",
"
..
+
...
++++ ++ ++
",
"
++
+++
++++
",
"
+++++++++++++++++++++++++
",
"
++++++++ +++ +++++++
",
"
++
+++
++++
",
"
++
++++
++ ++
",
"
+
+++
+
++ ++
",
"
++
+++
+
++ .++
",
"
++
+++
++
++
..+
",
"
++
++
++ ++
...
",
"
+
++
++ ++
....
",
"
+
++
...............
",
"
++ +++
................
",
"
+++++
................
",
"
++++
+++++................
",
"
++ ++++++++ ...............
",
"
++++++++
....
",
"
+++
...
",
"
..
",
"
.
"};
src/modules/readSphericalHarmonics/CMakeLists.txt
0 → 100644
View file @
94e19258
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
)
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
}
"
"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
)
src/modules/readSphericalHarmonics/WMReadSphericalHarmonics.cpp
0 → 100644
View file @
94e19258
//---------------------------------------------------------------------------
//
// 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 "../../dataHandler/WDataHandlerEnums.h"
#include "../../dataHandler/io/WReaderNIfTI.h"
#include "../../graphicsEngine/WGERequirement.h"
#include "../../kernel/WKernel.h"
#include "WMReadSphericalHarmonics.xpm"
#include "WMReadSphericalHarmonics.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
(
WMReadSphericalHarmonics
)
WMReadSphericalHarmonics
::
WMReadSphericalHarmonics
()
:
WModule
()
{
}
WMReadSphericalHarmonics
::~
WMReadSphericalHarmonics
()
{
}
boost
::
shared_ptr
<
WModule
>
WMReadSphericalHarmonics
::
factory
()
const
{
return
boost
::
shared_ptr
<
WModule
>
(
new
WMReadSphericalHarmonics
()
);
}
const
char
**
WMReadSphericalHarmonics
::
getXPMIcon
()
const
{
return
WMReadSphericalHarmonics_xpm
;
}
const
std
::
string
WMReadSphericalHarmonics
::
getName
()
const
{
// Specify your module name here. This name must be UNIQUE!
return
"Read Spherical Harmonics"
;
}
const
std
::
string
WMReadSphericalHarmonics
::
getDescription
()
const
{
return
"This modules loads data from vectors in NIfTI files as SphericalHarmonicsDatasets."
;
}
void
WMReadSphericalHarmonics
::
connectors
()
{
m_output
=
boost
::
shared_ptr
<
WModuleOutputData
<
WDataSetSphericalHarmonics
>
>
(
new
WModuleOutputData
<
WDataSetSphericalHarmonics
>
(
shared_from_this
(),
"Spherical Harmonics"
,
"A loaded spherical harmonics dataset."
)
);
addConnector
(
m_output
);
WModule
::
connectors
();
}
void
WMReadSphericalHarmonics
::
properties
()
{
m_propCondition
=
boost
::
shared_ptr
<
WCondition
>
(
new
WCondition
()
);
m_dataFile
=
m_properties
->
addProperty
(
"NIfTI file"
,
""
,
WPathHelper
::
getAppPath
()
);
m_readTriggerProp
=
m_properties
->
addProperty
(
"Do read"
,
"Press!"
,
WPVBaseTypes
::
PV_TRIGGER_READY
,
m_propCondition
);
WPropertyHelper
::
PC_PATHEXISTS
::
addTo
(
m_dataFile
);
WModule
::
properties
();
}
void
WMReadSphericalHarmonics
::
requirements
()
{
m_requirements
.
push_back
(
new
WGERequirement
()
);
}
void
WMReadSphericalHarmonics
::
moduleMain
()
{
m_moduleState
.
add
(
m_propCondition
);
ready
();
while
(
!
m_shutdownFlag
()
)
{
m_moduleState
.
wait
();
if
(
m_shutdownFlag
()
)
{
break
;
}
std
::
string
fileName
=
m_dataFile
->
get
().
string
();
WReaderNIfTI
niiLoader
(
fileName
);
boost
::
shared_ptr
<
WDataSet
>
data
;
data
=
niiLoader
.
load
(
W_DATASET_SPHERICALHARMONICS
);
if
(
data
)
{
m_data
=
boost
::
shared_dynamic_cast
<
WDataSetSphericalHarmonics
>
(
data
);
if
(
m_data
)
{
m_runtimeName
->
set
(
string_utils
::
tokenize
(
fileName
,
"/"
).
back
()
);
m_output
->
updateData
(
m_data
);
}
}
m_readTriggerProp
->
set
(
WPVBaseTypes
::
PV_TRIGGER_READY
,
false
);
}
}
src/modules/readSphericalHarmonics/WMReadSphericalHarmonics.h
0 → 100644
View file @
94e19258
//---------------------------------------------------------------------------
//
// 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 WMREADSPHERICALHARMONICS_H
#define WMREADSPHERICALHARMONICS_H
#include <string>
#include <osg/Geode>
#include "../../dataHandler/WDataSetSphericalHarmonics.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../kernel/WModuleOutputData.h"
/**
* This module loads spherical harmonics data given as vectors of coefficients from NIfTI files.
*
* \ingroup modules
*/
class
WMReadSphericalHarmonics
:
public
WModule
{
public:
/**
*
*/
WMReadSphericalHarmonics
();
/**
*
*/
virtual
~
WMReadSphericalHarmonics
();
/**