Commit 2886b615 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE] merged in OW 1.4 state

parents 020eae36 81147e23
......@@ -160,7 +160,7 @@ namespace
{
double calcAreaScale( const double bucket, const size_t j )
{
double theta = piDouble - ( j * bucket + ( bucket / 2.0 ) );
double theta = pi() - ( j * bucket + ( bucket / 2.0 ) );
return 1.0 / sin( theta );
}
}
......@@ -171,7 +171,7 @@ WGETexture2D::RPtr WHistogram2D::getSphereTexture()
size_t imageWidth = m_buckets[0];
size_t imageHeight = m_buckets[1];
double maxCount = 0.0;
const double bucket = piDouble / static_cast< double >( imageHeight );
const double bucket = pi() / static_cast< double >( imageHeight );
double areaScale = 0.0;
for( size_t j = 0; j < imageHeight; ++j ) // get max bin for scaling
......
......@@ -37,17 +37,40 @@
* Classes and functions of math module of OpenWalnut.
*/
// Pi constants - we don't use the macro M_PI, because it is not part of the C++-standard.
// ref.: http://stackoverflow.com/questions/1727881/how-to-use-the-pi-constant-in-c
/**
* The pi constant in float format
* Get a PI constant in an arbitrary type.
*
* \tparam T the desired type
*
* \return pi in the desired type.
*/
template< typename T >
T pi()
{
return boost::math::constants::pi< T >();
}
/**
* Get a PI constant as double.
*
* \return pi as double.
*/
inline double pi()
{
return boost::math::constants::pi< double >();
}
/**
* For the lazy programmer and backwards compatibility, define pi() to be PI as double. Since defines are usually a bad idea (for aliasing), you
* should avoid using this. Use the \ref pi function directly.
*/
const float piFloat = boost::math::constants::pi<float>();
#define piDouble pi()
/**
* The pi constant in double format
* For the lazy programmer and backwards compatibility, define piFloat to be PI as float. Since defines are usually a bad idea (for aliasing), you
* should avoid using this. Use the \ref pi function directly.
*/
const double piDouble = boost::math::constants::pi<double>();
#define piFloat pi< float >()
/**
* Checks if the triangle intersects with the given plane. If you are interested in the points of
......
......@@ -645,7 +645,7 @@ WMatrix< T > WSymmetricSphericalHarmonic< T >::getSHFittingMatrixForConstantSoli
wlog::debug( "" ) << "P*result: " << result;
// correction factor
T correctionFactor = 1.0 / ( 16.0 * std::pow( static_cast< T >( piDouble ), 2 ) );
T correctionFactor = 1.0 / ( 16.0 * std::pow( static_cast< T >( pi() ), 2 ) );
result *= correctionFactor;
return result;
......@@ -767,7 +767,7 @@ WMatrix< T > WSymmetricSphericalHarmonic< T >::calcFRTMatrix( size_t order )
WMatrix< T > result( R, R );
for( size_t k = 0; k <= order; k += 2 )
{
T h = 2.0 * static_cast< T >( piDouble ) * static_cast< T >( std::pow( static_cast< T >( -1 ), static_cast< T >( k / 2 ) ) ) *
T h = 2.0 * static_cast< T >( pi() ) * static_cast< T >( std::pow( static_cast< T >( -1 ), static_cast< T >( k / 2 ) ) ) *
static_cast< T >( oddFactorial( ( k <= 1 ) ? 1 : k - 1 ) ) / static_cast< T >( evenFactorial( k ) );
for( int m = -static_cast< int >( k ); m <= static_cast< int >( k ); ++m )
{
......@@ -859,7 +859,7 @@ void WSymmetricSphericalHarmonic< T >::normalize()
T scale = 0.0;
if( m_SHCoefficients.size() > 0 )
{
scale = std::sqrt( 4.0 * static_cast< T >( piDouble ) ) * m_SHCoefficients[0];
scale = std::sqrt( 4.0 * static_cast< T >( pi() ) ) * m_SHCoefficients[0];
}
for( size_t i = 0; i < m_SHCoefficients.size(); i++ )
{
......
......@@ -65,14 +65,14 @@ public:
reference.setZero();
// j 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
// lj 0 2 2 2 2 2 4 4 4 4 4 4 4 4 4
reference( 0, 0 ) = 2.0 * piDouble;
reference( 0, 0 ) = 2.0 * pi();
for( size_t i = 1; i <= 5; i++ )
{
reference( i, i ) = -2.0 * piDouble * 1.0 / 2.0;
reference( i, i ) = -2.0 * pi() * 1.0 / 2.0;
}
for( size_t i = 6; i <= 14; i++ )
{
reference( i, i ) = 2.0 * piDouble * 3.0 / 8.0;
reference( i, i ) = 2.0 * pi() * 3.0 / 8.0;
}
for( size_t i = 0; i < 15; ++i )
......
......@@ -790,11 +790,11 @@ osg::ref_ptr< osg::Group > wge::creatCoordinateSystem(
osg::Matrixd matrixTranslateFrom0 = osg::Matrixd::translate( middle.x(), middle.y(), middle.z() );
graphXTransform->setMatrix( matrixTranslateTo0 * osg::Matrixd::rotate(
90.0 * piDouble / 180.0,
90.0 * pi() / 180.0,
osg::Vec3f( 0.0, 1.0, 0.0 ) ) * matrixTranslateFrom0
);
graphYTransform->setMatrix( matrixTranslateTo0 * osg::Matrixd::rotate(
-90.0 * piDouble / 180.0,
-90.0 * pi() / 180.0,
osg::Vec3f( 1.0, 0.0, 0.0 ) ) * matrixTranslateFrom0
);
......
......@@ -878,7 +878,7 @@ osg::Vec3 WTriangleMesh::estimateSmoothedVertexPosition( std::size_t vtx, float
// calc f
double dist = ( m_verts->operator[] ( vtx ) - center ).length();
double f = 1.0 / ( sigmaDistance * sqrt( 2.0 * piDouble ) ) * exp( -0.5 * dist * dist );
double f = 1.0 / ( sigmaDistance * sqrt( 2.0 * pi() ) ) * exp( -0.5 * dist * dist );
double g;
if( !mollify )
......@@ -890,7 +890,7 @@ osg::Vec3 WTriangleMesh::estimateSmoothedVertexPosition( std::size_t vtx, float
dist = ( p - pred ).length();
}
g = 1.0 / ( sigmaInfluence * sqrt( 2.0 * piDouble ) ) * exp( -0.5 * dist * dist );
g = 1.0 / ( sigmaInfluence * sqrt( 2.0 * pi() ) ) * exp( -0.5 * dist * dist );
sum += area * f * g;
res += center * area * f * g;
......
......@@ -111,12 +111,12 @@ void WGEAnimationManipulator::setTimer( WTimer::ConstSPtr timer )
double degToRad( double deg )
{
return deg * ( piDouble / 180.0 );
return deg * ( pi() / 180.0 );
}
double radToDeg( double rad )
{
return rad * ( 180.0 / piDouble );
return rad * ( 180.0 / pi() );
}
template < typename T >
......@@ -161,7 +161,7 @@ double smooth( double value, double min, double max )
}
double scaledValue = ( value - min ) / max;
return min + max * ( 0.5 * ( 1.0 + cos( piDouble + ( scaledValue * piDouble ) ) ) );
return min + max * ( 0.5 * ( 1.0 + cos( pi() + ( scaledValue * pi() ) ) ) );
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -335,8 +335,8 @@ void WGEAnimationManipulator::handleFrame()
// this brings the BBox to the center, makes it larger and rotates the front towards the camera
osg::Matrixd mBBTranslate = osg::Matrixd::translate( -159.0 / 2.0, -199.0 / 2.0, -159.0 / 2.0 );
osg::Matrixd mBBScale = osg::Matrixd::scale( 1.5, 1.5, 1.5 );
osg::Matrixd mBBRotate = osg::Matrixd::rotate( -piDouble / 2.0, 1.0, 0.0, 0.0 ) *
osg::Matrixd::rotate( piDouble, 0.0, 1.0, 0.0 );
osg::Matrixd mBBRotate = osg::Matrixd::rotate( -pi() / 2.0, 1.0, 0.0, 0.0 ) *
osg::Matrixd::rotate( pi(), 0.0, 1.0, 0.0 );
// Scene 1:
// construct the animation here.
Rotator rotateToBack = Rotator( elapsed, 0.0, Transformation::axeY, 360.0, 22.5 );
......@@ -360,8 +360,8 @@ void WGEAnimationManipulator::handleFrame()
// this brings the BBox to the center, makes it larger and rotates the front towards the camera
// osg::Matrixd mBBTranslate = osg::Matrixd::translate( -159.0 / 2.0, -199.0 / 2.0, -179.0 / 2.0 );
// osg::Matrixd mBBScale = osg::Matrixd::scale( 2.0, 2.0, 2.0 );
// osg::Matrixd mBBRotate = osg::Matrixd::rotate( -piDouble / 2.0, 1.0, 0.0, 0.0 ) *
// osg::Matrixd::rotate( piDouble, 0.0, 1.0, 0.0 );
// osg::Matrixd mBBRotate = osg::Matrixd::rotate( -pi() / 2.0, 1.0, 0.0, 0.0 ) *
// osg::Matrixd::rotate( pi(), 0.0, 1.0, 0.0 );
// Transformation rotateToBack = Rotator( elapsed, 0.0, Transformation::axeY, 360.0, 22.5 );
// Transformation translateABitUp = Translator( elapsed, rotateToBack.finish() - 5.0, Transformation::axeY * -45.0, 0.25 );
// Transformation zoomNei = Zoomer( elapsed, rotateToBack.finish() - 5.0, 2.00, 0.25 );
......
......@@ -316,12 +316,12 @@ void WSphericalHarmonicsCoefficientsThread< T >::threadMain()
double scale = 1.0;
if( m_parameter.m_normalize )
{
scale *= std::sqrt( 4.0 * piDouble ) / coefficients[ 0 ];
scale *= std::sqrt( 4.0 * pi() ) / coefficients[ 0 ];
}
if( m_parameter.m_csa )
{
coefficients[ 0 ] = 1.0 / ( 2.0 * std::sqrt( piDouble ) );
coefficients[ 0 ] = 1.0 / ( 2.0 * std::sqrt( pi() ) );
}
for( std::size_t j = 0; j < l; j++ )
......
......@@ -114,7 +114,9 @@ private:
class MainViewEventHandler : public osgGA::GUIEventHandler
{
public:
//! The type for the signal used for notification on left button presses.
/**
* Signal for handling left button signals
*/
typedef boost::signals2::signal< bool ( WVector2f ) > LeftButtonPushSignalType;
/**
......
......@@ -76,8 +76,8 @@ void WDataCreatorFiberSpiral::operator()( WProgress::SPtr progress,
double a1 = static_cast< double >( std::rand() % 255 ) / 255.0; // NOLINT - rand_r has portability issues.
double a2 = static_cast< double >( std::rand() % 255 ) / 255.0; // NOLINT - rand_r has portability issues.
double seedX = cos( 2.0 * piDouble * a1 ) * tubeRadius;
double seedY = sin( 2.0 * piDouble * a2 ) * tubeRadius;
double seedX = cos( 2.0 * pi() * a1 ) * tubeRadius;
double seedY = sin( 2.0 * pi() * a2 ) * tubeRadius;
double seedZ = sqrt( tubeRadius - ( seedX * seedX ) - ( seedY * seedY ) );
WPosition seed( seedX, seedY, seedZ );
......@@ -85,7 +85,7 @@ void WDataCreatorFiberSpiral::operator()( WProgress::SPtr progress,
for( size_t vidx = 0; vidx < numVertsPerFiber; ++vidx )
{
double v = static_cast< double >( vidx ) / static_cast< double >( numVertsPerFiber - 1 );
double degree = v * 2.0 * piDouble * numRotations;
double degree = v * 2.0 * pi() * numRotations;
double X = seed.x() + cos( degree ) * v * spiralRadius;
double Y = seed.y() + sin( degree ) * v * spiralRadius;
......
......@@ -34,7 +34,7 @@ WManipulatorRotation::WManipulatorRotation()
m_axis = m_properties->addProperty( "Rotation axis", "Axis to rotate around in world coordinates.", WPosition( 0.0, 0.0, 1.0 ) );
m_angle = m_properties->addProperty( "Rotation angle", "The angle to rotate.", 0.0 );
m_angle->setMin( 0.0 );
m_angle->setMax( 2.0 * piDouble );
m_angle->setMax( 2.0 * pi() );
}
WManipulatorRotation::~WManipulatorRotation()
......
#---------------------------------------------------------------------------
#
# 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/>.
#
#---------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Some common setup
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# we use the directory name as module name
GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Search own dependencies
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# 1: FindPackage( LibYouNeed )
# 2: INCLUDE_DIRECTORIES( ${LIBYOUNEED_INCLUDE_DIR} )
# 3: LINK_DIRECTORIES( ${LIBYOUNEED_LIBRARY_DIRS} )
# 4: Add ${LIBYOUNEED_LIBRARY} as _MODULE_DEPENDENCIES parameter to SETUP_MODULE
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Setup for compilation
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Let this function do the job. It sets up tests and copies shaders automatically. It additionally configures the stylecheck mechanism for this
# module.
SETUP_MODULE( ${MODULE_NAME} # name of the module
"${CMAKE_CURRENT_SOURCE_DIR}" # where to find the source ${CMAKE_CURRENT_SOURCE_DIR} is a good idea here mostly
"" # does your module need additional libs to compile?
"" # do you want to exclude files from stylechecking? (externals for example)
)
//---------------------------------------------------------------------------
//
// 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 "WToolkit.h"
#include <boost/shared_ptr.hpp>
#include <core/kernel/WModule.h>
#include "hierchClustDisplay/WMHierchClustDisplay.h"
#include "partition2Mesh/WMPartition2Mesh.h"
// This file's purpose is to provide a list of modules as entry point for OpenWalnut's module loader.
// Add your modules here. If you miss this step, OpenWalnut will not be able to load your modules.
extern "C" void WLoadModule( WModuleList& m ) // NOLINT
{
m.push_back( boost::shared_ptr< WModule >( new WMHierchClustDisplay ) );
m.push_back( boost::shared_ptr< WModule >( new WMPartition2Mesh ) );
}
//---------------------------------------------------------------------------
//
// 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 WTOOLKIT_H
#define WTOOLKIT_H
// nothing to do here. Have a look at WToolkit.cpp for registration of all the modules inside the toolbox.
#endif // WTOOLKIT_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/>.
//
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//
// Project: hClustering
//
// Whole-Brain Connectivity-Based Hierarchical Parcellation Project
// David Moreno-Dominguez
// d.mor.dom@gmail.com
// moreno@cbs.mpg.de
// www.cbs.mpg.de/~moreno//
// This file is also part of OpenWalnut ( http://www.openwalnut.org ).
//
// hClustering 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.
// http://creativecommons.org/licenses/by-nc/3.0
//
// hClustering 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.
//
//---------------------------------------------------------------------------
#include <string>
#include <vector>
#include "WFileParser.h"
WFileParser::WFileParser( const std::string fileName ) :
m_fileName( fileName ),
m_tagIndicator( "#" ),
m_endIndicator( "end" ),
m_delimiter( " " )
{
}
WFileParser::~WFileParser()
{
}
bool WFileParser::readFile()
{
using namespace boost::filesystem; //NOLINT
if( !exists( m_fileName ) )
{
//debugLog() << "file doesn't exist";
return false;
}
std::ifstream ifs( m_fileName.c_str(), std::ifstream::in );
std::string line;
if( !ifs.is_open() )
{
//debugLog() << "file open failed";
ifs.close();
return false;
}
while( !ifs.eof() )
{
getline( ifs, line );
m_rawLines.push_back( line );
}
ifs.close();
return true;
}
std::vector<std::string>WFileParser::getLinesForTag( std::string tag )
{
std::string startTag = m_tagIndicator + tag;
std::string endTag = m_tagIndicator + m_endIndicator + tag;
std::vector<std::string>returnVector;
size_t i = 0;
while( i < m_rawLines.size() )
{
if( m_rawLines[i] == startTag )
{
//debugLog() << "coordinates tag at line " << i;
++i;
break;
}
else
{
++i;
}
}
while( i < m_rawLines.size() )
{
if( m_rawLines[i] == endTag )
{
//debugLog() << "endcoordinates tag at line " << i;
++i;
break;
}
else
{
returnVector.push_back( m_rawLines[i] );
++i;
}
}
return returnVector;
}
std::vector< std::vector<std::string> >WFileParser::getLinesForTagSeparated( std::string tag )
{
std::string startTag = m_tagIndicator + tag;
std::string endTag = m_tagIndicator + m_endIndicator + tag;
std::vector<std::vector<std::string > >returnVector;
size_t i = 0;
while( i < m_rawLines.size() )
{
if( m_rawLines[i] == startTag )
{
//debugLog() << "coordinates tag at line " << i;
++i;
break;
}
else
{
++i;
}
}
while( i < m_rawLines.size() )
{
if( m_rawLines[i] == endTag )
{
//debugLog() << "endcoordinates tag at line " << i;
++i;
break;
}
else
{
std::vector<std::string>svec;
boost::regex reg( m_delimiter );
boost::sregex_token_iterator it( m_rawLines[i].begin(), m_rawLines[i].end(), reg, -1 );
boost::sregex_token_iterator end;
while( it != end )
{
svec.push_back( *it++ );
}
returnVector.push_back( svec );
++i;
}
}
return returnVector;
}
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------