Commit afe68e6e authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[AD #453] allow order 6 and changing orders. Fixed "normalize" option

parent 42385595
...@@ -298,6 +298,15 @@ public: ...@@ -298,6 +298,15 @@ public:
return components[ components.size() / 2 ]; return components[ components.size() / 2 ];
} }
/**
* Changes the number of scalars held by this WValue.
* \param size The number of scalars stored in the WValue.
*/
void resize( size_t size )
{
m_components.resize( size );
}
protected: protected:
private: private:
/** /**
......
...@@ -168,6 +168,10 @@ void WMTeemGlyphs::properties() ...@@ -168,6 +168,10 @@ void WMTeemGlyphs::properties()
m_sliceIdProp->setMin( 0 ); m_sliceIdProp->setMin( 0 );
m_sliceIdProp->setMax( 128 ); m_sliceIdProp->setMax( 128 );
m_orderProp = m_properties->addProperty( "Order", "Will be rounded to the next even order", 4, m_recompute );
m_orderProp->setMin( 0 );
m_orderProp->setMax( 6 );
m_GFAThresholdProp = m_properties->addProperty( "GFA threshold", "Show only glyphs at voxels above the given generalized fractional" m_GFAThresholdProp = m_properties->addProperty( "GFA threshold", "Show only glyphs at voxels above the given generalized fractional"
" anisotropy (GFA) threshold" " anisotropy (GFA) threshold"
" (if GFA data is present at input connector).", " (if GFA data is present at input connector).",
...@@ -239,6 +243,11 @@ void WMTeemGlyphs::moduleMain() ...@@ -239,6 +243,11 @@ void WMTeemGlyphs::moduleMain()
m_GFAThresholdProp->setMin( gfa->getMin() ); m_GFAThresholdProp->setMin( gfa->getMin() );
} }
if( m_orderProp->get() % 2 != 0 )
{
m_orderProp->set( m_orderProp->get() + 1 );
}
renderSlice( m_sliceIdProp->get() ); renderSlice( m_sliceIdProp->get() );
} }
...@@ -269,6 +278,7 @@ void WMTeemGlyphs::renderSlice( size_t sliceId ) ...@@ -269,6 +278,7 @@ void WMTeemGlyphs::renderSlice( size_t sliceId )
boost::shared_dynamic_cast< WDataSetScalar >( m_inputGFA->getData() ), boost::shared_dynamic_cast< WDataSetScalar >( m_inputGFA->getData() ),
m_GFAThresholdProp->get(), m_GFAThresholdProp->get(),
sliceId, sliceId,
m_orderProp->get(),
m_subdivisionLevelProp->get(), m_subdivisionLevelProp->get(),
m_moduloProp->get(), m_moduloProp->get(),
sliceType, sliceType,
...@@ -358,6 +368,7 @@ WMTeemGlyphs::GlyphGeneration::GlyphGeneration( boost::shared_ptr< WDataSetSpher ...@@ -358,6 +368,7 @@ WMTeemGlyphs::GlyphGeneration::GlyphGeneration( boost::shared_ptr< WDataSetSpher
boost::shared_ptr< WDataSetScalar > dataGFA, boost::shared_ptr< WDataSetScalar > dataGFA,
double thresholdGFA, double thresholdGFA,
const size_t& sliceId, const size_t& sliceId,
const size_t& order,
const size_t& subdivisionLevel, const size_t& subdivisionLevel,
const size_t& modulo, const size_t& modulo,
const size_t& sliceType, const size_t& sliceType,
...@@ -368,6 +379,7 @@ WMTeemGlyphs::GlyphGeneration::GlyphGeneration( boost::shared_ptr< WDataSetSpher ...@@ -368,6 +379,7 @@ WMTeemGlyphs::GlyphGeneration::GlyphGeneration( boost::shared_ptr< WDataSetSpher
m_dataGFA( dataGFA ), m_dataGFA( dataGFA ),
m_grid( boost::shared_dynamic_cast< WGridRegular3D >( dataSet->getGrid() ) ), m_grid( boost::shared_dynamic_cast< WGridRegular3D >( dataSet->getGrid() ) ),
m_thresholdGFA( thresholdGFA ), m_thresholdGFA( thresholdGFA ),
m_order( order ),
m_sliceType( sliceType ), m_sliceType( sliceType ),
m_subdivisionLevel( subdivisionLevel ), m_subdivisionLevel( subdivisionLevel ),
m_modulo( modulo ), m_modulo( modulo ),
...@@ -441,12 +453,25 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB ...@@ -441,12 +453,25 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB
zSlice zSlice
}; };
WAssert( m_sphere->xyzwNum == m_sphere->normNum, "Wrong size of arrays." ); WAssert( m_sphere->xyzwNum == m_sphere->normNum, "Wrong size of arrays." );
WAssert( m_sphere->xyzwNum == m_sphere->rgbaNum, "Wrong size of arrays." ); WAssert( m_sphere->xyzwNum == m_sphere->rgbaNum, "Wrong size of arrays." );
size_t nbVerts = m_sphere->xyzwNum; size_t nbVerts = m_sphere->xyzwNum;
const tijk_type *type = tijk_4o3d_sym; const tijk_type *type = 0; // Initialized to quiet compiler
switch( m_order )
{
case 2:
type = tijk_2o3d_sym;
break;
case 4:
type = tijk_4o3d_sym;
break;
case 6:
type = tijk_6o3d_sym;
break;
default:
WAssert( false, "order above 6 not supported yet." );
}
// memory for the tensor and spherical harmonics data. // memory for the tensor and spherical harmonics data.
float* ten = new float[type->num]; float* ten = new float[type->num];
...@@ -501,7 +526,7 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB ...@@ -501,7 +526,7 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB
//------------------------------- //-------------------------------
// vertex indices // vertex indices
// We have to set them also if we do not darw the glyph becaus otherwise we would leave their // We have to set them also if we do not draw the glyph because otherwise we would leave their
// to be zero. If many indices are zero, they block each other because of synchronized // to be zero. If many indices are zero, they block each other because of synchronized
// memory access to the same memory address. // memory access to the same memory address.
for( unsigned int vertId = 0; vertId < localSphere->indxNum; ++vertId ) for( unsigned int vertId = 0; vertId < localSphere->indxNum; ++vertId )
...@@ -516,16 +541,27 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB ...@@ -516,16 +541,27 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB
} }
wmath::WValue< double > coeffs = m_dataSet->getSphericalHarmonicAt( posId ).getCoefficients(); wmath::WValue< double > coeffs = m_dataSet->getSphericalHarmonicAt( posId ).getCoefficients();
WAssert( coeffs.size() == 15, switch( m_order )
"This module can handle only 4th order spherical harmonics." {
"Thus the input has to be 15 dimensional vectors." ); case 2:
coeffs.resize( 6 );
break;
case 4:
coeffs.resize( 15 );
break;
case 6:
coeffs.resize( 28 );
break;
default:
WAssert( false, "order above 6 not supported yet." );
}
for( size_t coeffId = 0; coeffId < 15; coeffId++ ) for( size_t coeffId = 0; coeffId < coeffs.size(); coeffId++ )
{ {
esh[coeffId] = coeffs[coeffId]; esh[coeffId] = coeffs[coeffId];
} }
// convert even-order spherical harmonics to higher-order tensor // convert even-order spherical harmonics to higher-order tensor
tijk_esh_to_3d_sym_f( ten, esh, 4 ); tijk_esh_to_3d_sym_f( ten, esh, m_order );
// create positive approximation of the tensor // create positive approximation of the tensor
tijk_refine_rankk_parm *parm = tijk_refine_rankk_parm_new(); tijk_refine_rankk_parm *parm = tijk_refine_rankk_parm_new();
...@@ -556,14 +592,19 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB ...@@ -556,14 +592,19 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB
// One can insert per-peak coloring here (see http://www.ci.uchicago.edu/~schultz/sphinx/home-glyph.html ) // One can insert per-peak coloring here (see http://www.ci.uchicago.edu/~schultz/sphinx/home-glyph.html )
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
float scale = m_scale;
if( m_useNormalization ) if( m_useNormalization )
{ {
minMaxNormalization( glyph, nbVertCoords ); minMaxNormalization( glyph, nbVertCoords );
} }
else else
{ {
m_scale = m_scale / radius; // std::cout<< radius << " " << m_scale << std::endl;
if( radius != 0 )
{
scale = m_scale / radius;
}
// std::cout<< m_scale << std::endl<< std::endl;
} }
estimateNormalsAntipodal( glyph, normalize ); estimateNormalsAntipodal( glyph, normalize );
...@@ -575,9 +616,9 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB ...@@ -575,9 +616,9 @@ void WMTeemGlyphs::GlyphGeneration::operator()( size_t id, size_t numThreads, WB
size_t globalVertexId = vertsUpToCurrentIteration + vertId; size_t globalVertexId = vertsUpToCurrentIteration + vertId;
//------------------------------- //-------------------------------
// vertices // vertices
( *m_vertArray )[globalVertexId][0] = glyph->xyzw[nbVertCoords*vertId ] * m_scale + glyphPos[0]; ( *m_vertArray )[globalVertexId][0] = glyph->xyzw[nbVertCoords*vertId ] * scale + glyphPos[0];
( *m_vertArray )[globalVertexId][1] = glyph->xyzw[nbVertCoords*vertId+1] * m_scale + glyphPos[1]; ( *m_vertArray )[globalVertexId][1] = glyph->xyzw[nbVertCoords*vertId+1] * scale + glyphPos[1];
( *m_vertArray )[globalVertexId][2] = glyph->xyzw[nbVertCoords*vertId+2] * m_scale + glyphPos[2]; ( *m_vertArray )[globalVertexId][2] = glyph->xyzw[nbVertCoords*vertId+2] * scale + glyphPos[2];
// ------------------------------------------------ // ------------------------------------------------
// normals // normals
......
...@@ -138,6 +138,7 @@ private: ...@@ -138,6 +138,7 @@ private:
WPropDouble m_GFAThresholdProp; //!< Property holding the threshold of GFA above which glyphs should be drawn. WPropDouble m_GFAThresholdProp; //!< Property holding the threshold of GFA above which glyphs should be drawn.
WPropDouble m_glyphSizeProp; //!< Property holding the size of the displayed glyphs WPropDouble m_glyphSizeProp; //!< Property holding the size of the displayed glyphs
WPropInt m_sliceIdProp; //!< Property holding the slice ID WPropInt m_sliceIdProp; //!< Property holding the slice ID
WPropInt m_orderProp; //!< Property holding the order of the SH to show.
WPropInt m_moduloProp; //!< Property holding information on how many glyphs will be omited between two glyphs (modulo-1). WPropInt m_moduloProp; //!< Property holding information on how many glyphs will be omited between two glyphs (modulo-1).
WPropInt m_subdivisionLevelProp; //!< Property holding information on the subdivision level of the spheres (resolution). WPropInt m_subdivisionLevelProp; //!< Property holding information on the subdivision level of the spheres (resolution).
...@@ -158,6 +159,7 @@ private: ...@@ -158,6 +159,7 @@ private:
* \param dataGFA GFA data for dataSet. * \param dataGFA GFA data for dataSet.
* \param thresholdGFA Threshold of GFA below which we will not draw the glyphs * \param thresholdGFA Threshold of GFA below which we will not draw the glyphs
* \param sliceId Rendered slice * \param sliceId Rendered slice
* \param order Order of the rendered spherical harmonics.
* \param subdivisionLevel Subidivision level of spheres that are basis for glyphs (resolution) * \param subdivisionLevel Subidivision level of spheres that are basis for glyphs (resolution)
* \param modulo Show only every modulo-th glyph in each direction. * \param modulo Show only every modulo-th glyph in each direction.
* \param sliceType Slice direction (sagittal, coronal, axial ) * \param sliceType Slice direction (sagittal, coronal, axial )
...@@ -169,6 +171,7 @@ private: ...@@ -169,6 +171,7 @@ private:
boost::shared_ptr< WDataSetScalar > dataGFA, boost::shared_ptr< WDataSetScalar > dataGFA,
double thresholdGFA, double thresholdGFA,
const size_t& sliceId, const size_t& sliceId,
const size_t& order,
const size_t& subdivisionLevel, const size_t& subdivisionLevel,
const size_t& modulo, const size_t& modulo,
const size_t& sliceType, const size_t& sliceType,
...@@ -218,6 +221,7 @@ private: ...@@ -218,6 +221,7 @@ private:
double m_thresholdGFA; //!< Stores the GFA threshold from the property. double m_thresholdGFA; //!< Stores the GFA threshold from the property.
size_t m_sliceId; //!< Stores option from property. size_t m_sliceId; //!< Stores option from property.
size_t m_order; //!< Stores option from property.
size_t m_sliceType; //!< Stores option from property. size_t m_sliceType; //!< Stores option from property.
size_t m_subdivisionLevel; //!< Store option from property size_t m_subdivisionLevel; //!< Store option from property
size_t m_modulo; //!< Store option from property size_t m_modulo; //!< Store option from property
......
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