Commit df4bb618 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[MERGE]

parents a5c8e32d 8f018cae
...@@ -228,20 +228,30 @@ FOREACH( dirname ${EXCLUDE_DIRS} ) ...@@ -228,20 +228,30 @@ FOREACH( dirname ${EXCLUDE_DIRS} )
LIST( REMOVE_ITEM STYLE_CPP ${fname} ) LIST( REMOVE_ITEM STYLE_CPP ${fname} )
ENDFOREACH( fname ) ENDFOREACH( fname )
ENDFOREACH( dirname ) ENDFOREACH( dirname )
IF( CMAKE_COLOR_MAKEFILE ) IF( CMAKE_COLOR_MAKEFILE )
ADD_CUSTOM_TARGET( stylecheck SET( STYLECHECK_OPTIONS "--color" )
COMMAND ${PROJECT_SOURCE_DIR}/../tools/brainlint.py --color ${STYLE_CPP} ${STYLE_H} ELSE()
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} SET( STYLECHECK_OPTIONS "" )
COMMENT "Check if code complies to CodingStandard" ENDIF()
)
IF( CMAKE_HOST_WIN32 )
SET( XARGS_OPTIONS "-n 128" )
ELSE() ELSE()
ADD_CUSTOM_TARGET( stylecheck SET( XARGS_OPTIONS "" )
COMMAND ${PROJECT_SOURCE_DIR}/../tools/brainlint.py ${STYLE_CPP} ${STYLE_H}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Check if code complies to CodingStandard and use noncolored output for violation messages"
)
ENDIF() ENDIF()
FILE( WRITE ${PROJECT_BINARY_DIR}/brainlintlist "" )
FOREACH( fname ${STYLE_CPP} ${STYLE_H} )
FILE( APPEND ${PROJECT_BINARY_DIR}/brainlintlist "${fname}\n" )
ENDFOREACH()
ADD_CUSTOM_TARGET( stylecheck
COMMAND cat ${PROJECT_BINARY_DIR}/brainlintlist | xargs ${XARGS_OPTIONS} ${PROJECT_SOURCE_DIR}/../tools/brainlint.py ${STYLECHECK_OPTIONS}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Check if code complies to CodingStandard"
)
#------------------------------------------------------------------------------------------------------------- #-------------------------------------------------------------------------------------------------------------
# Writes information about the revision of the current code to a file # Writes information about the revision of the current code to a file
ADD_CUSTOM_TARGET( identify ADD_CUSTOM_TARGET( identify
......
...@@ -8,8 +8,7 @@ ADD_SUBDIRECTORY( constraints ) ...@@ -8,8 +8,7 @@ ADD_SUBDIRECTORY( constraints )
ADD_SUBDIRECTORY( math ) ADD_SUBDIRECTORY( math )
ADD_LIBRARY( common ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} ) ADD_LIBRARY( common ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} )
# The OSG Libs are needed for common as the unit tests will fail to compile TARGET_LINK_LIBRARIES( common ${Boost_LIBRARIES} )
TARGET_LINK_LIBRARIES( common ${Boost_LIBRARIES} ${OPENSCENEGRAPH_LIBRARIES} )
# Unit tests # Unit tests
......
...@@ -69,6 +69,11 @@ public: ...@@ -69,6 +69,11 @@ public:
{ {
return 255; return 255;
} }
virtual double getScalarDouble( size_t i ) const
{
return 255;
}
}; };
/** /**
......
...@@ -232,7 +232,7 @@ public: ...@@ -232,7 +232,7 @@ public:
/** /**
* getter * getter
* *
* \return number of vertexes in the mesh * \return number of vertices in the mesh
*/ */
size_t vertSize() const; size_t vertSize() const;
......
...@@ -80,7 +80,7 @@ void WMDistanceMapIsosurface::moduleSetup() ...@@ -80,7 +80,7 @@ void WMDistanceMapIsosurface::moduleSetup()
m_marchingCubesModule->isReady().wait(); m_marchingCubesModule->isReady().wait();
boost::shared_ptr< WProperties > mcProps = m_marchingCubesModule->getProperties(); boost::shared_ptr< WProperties > mcProps = m_marchingCubesModule->getProperties();
m_isoValueProp = mcProps->getProperty( "Iso Value" )->toPropDouble(); m_isoValueProp = mcProps->getProperty( "Iso Value" )->toPropDouble();
m_isoValueProp->set( 0.5 ); m_isoValueProp->set( 0.2 );
m_isoValueProp->setMin( 0.0 ); m_isoValueProp->setMin( 0.0 );
m_isoValueProp->setMax( 1.0 ); m_isoValueProp->setMax( 1.0 );
m_properties->addProperty( m_isoValueProp ); m_properties->addProperty( m_isoValueProp );
...@@ -90,6 +90,10 @@ void WMDistanceMapIsosurface::moduleSetup() ...@@ -90,6 +90,10 @@ void WMDistanceMapIsosurface::moduleSetup()
m_useTextureProp->set( true ); m_useTextureProp->set( true );
m_properties->addProperty( m_useTextureProp ); m_properties->addProperty( m_useTextureProp );
m_opacityProp = mcProps->getProperty( "Opacity %" )->toPropInt();
m_properties->addProperty( m_opacityProp );
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
// Distance Map // Distance Map
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
......
...@@ -98,6 +98,7 @@ protected: ...@@ -98,6 +98,7 @@ protected:
private: private:
WPropDouble m_isoValueProp; //!< Property holding the value for the distance. WPropDouble m_isoValueProp; //!< Property holding the value for the distance.
WPropInt m_opacityProp; //!< Property holding the value for the opacity of the surface.
WPropBool m_useTextureProp; //!< Property indicating whether to use texturing with scalar data sets. WPropBool m_useTextureProp; //!< Property indicating whether to use texturing with scalar data sets.
boost::shared_ptr< WModuleInputForwardData< WDataSetScalar > > m_input; //!< Input connector required by this module. boost::shared_ptr< WModuleInputForwardData< WDataSetScalar > > m_input; //!< Input connector required by this module.
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "../../../common/WLogger.h" #include "../../../common/WLogger.h"
#include "../../../common/math/WPosition.h" #include "../../../common/math/WPosition.h"
#include "../../../common/WIOTools.h" #include "../../../common/WIOTools.h"
#include "../../../graphicsEngine/WTriangleMesh2.h"
#include "../WMMarchingCubes.h" #include "../WMMarchingCubes.h"
static WLogger logger; static WLogger logger;
...@@ -262,7 +263,7 @@ public: ...@@ -262,7 +263,7 @@ public:
void testSaveZero() void testSaveZero()
{ {
WMMarchingCubes mc; WMMarchingCubes mc;
WTriangleMesh triMesh; WTriangleMesh2 triMesh( 0, 0 );
std::string fileName = wiotools::tempFileName(); std::string fileName = wiotools::tempFileName();
bool result = mc.save( fileName, triMesh ); bool result = mc.save( fileName, triMesh );
...@@ -276,16 +277,8 @@ public: ...@@ -276,16 +277,8 @@ public:
void testSaveInfinteNan() void testSaveInfinteNan()
{ {
WMMarchingCubes mc; WMMarchingCubes mc;
WTriangleMesh triMesh;
const unsigned int nbPos = 10; const unsigned int nbPos = 10;
std::vector< Triangle > triangles( 0 ); WTriangleMesh2 triMesh( nbPos, 3 );
Triangle tri;
for( unsigned int i = 0; i < 3; ++i )
{
tri.pointID[i] = i;
}
triangles.push_back( tri );
std::vector< wmath::WPosition > vertices( 0 ); std::vector< wmath::WPosition > vertices( 0 );
for( unsigned int posId = 0; posId < nbPos; ++posId ) for( unsigned int posId = 0; posId < nbPos; ++posId )
...@@ -293,9 +286,8 @@ public: ...@@ -293,9 +286,8 @@ public:
double x = posId * posId + 3.4; double x = posId * posId + 3.4;
double y = posId + 1; double y = posId + 1;
double z = 3. / static_cast< double >( posId ); // provide nan values by dividing with zero double z = 3. / static_cast< double >( posId ); // provide nan values by dividing with zero
vertices.push_back( wmath::WPosition( x, y, z ) ); triMesh.addVertex( x, y, z );
} }
triMesh.setVertices( vertices );
std::string fileName = wiotools::tempFileName(); std::string fileName = wiotools::tempFileName();
...@@ -305,93 +297,92 @@ public: ...@@ -305,93 +297,92 @@ public:
TS_ASSERT_EQUALS( result, false ); // should return false as we did not have all coordinates values finite. TS_ASSERT_EQUALS( result, false ); // should return false as we did not have all coordinates values finite.
TS_ASSERT( !wiotools::fileExists( fileName ) ); TS_ASSERT( !wiotools::fileExists( fileName ) );
} }
// TODO(wiebel): reactivate these when schurade has reactivated loading
/** // /**
* Test reading of surfaces // * Test reading of surfaces
*/ // */
void testLoad() // void testLoad()
{ // {
if( !loggerInitialized ) // if( !loggerInitialized )
{ // {
std::cout << "Initialize logger." << std::endl; // std::cout << "Initialize logger." << std::endl;
logger.run(); // logger.run();
loggerInitialized = true; // loggerInitialized = true;
} // }
WMMarchingCubes mc; // WMMarchingCubes mc;
WTriangleMesh triMesh; // WTriangleMesh2 triMesh = mc.load( "./fixtures/surfaceMeshFile.vtk" );
triMesh = mc.load( "./fixtures/surfaceMeshFile.vtk" );
// TS_ASSERT_EQUALS( triMesh.triangleSize(), 28 );
TS_ASSERT_EQUALS( triMesh.getNumTriangles(), 28 ); // TS_ASSERT_EQUALS( triMesh.vertSize(), 16 );
TS_ASSERT_EQUALS( triMesh.getNumVertices(), 16 ); // TS_ASSERT_EQUALS( triMesh.getTriVertId0( 0 ), 0 );
TS_ASSERT_EQUALS( triMesh.getTriangleVertexId( 0, 0 ), 0 ); // TS_ASSERT_EQUALS( triMesh.getTriVertId0( 1 ), 0 );
TS_ASSERT_EQUALS( triMesh.getTriangleVertexId( 1, 0 ), 0 ); // TS_ASSERT_EQUALS( triMesh.getTriVertId2( 1 ), 5 );
TS_ASSERT_EQUALS( triMesh.getTriangleVertexId( 1, 2 ), 5 ); // TS_ASSERT_EQUALS( triMesh.getTriVertId1( 14 ), 7 );
TS_ASSERT_EQUALS( triMesh.getTriangleVertexId( 14, 1 ), 7 );
// osg::Vec3 expectedPosition( 93.5, 115.5, 41.5 );
wmath::WPosition expectedPosition( 93.5, 115.5, 41.5 ); // TS_ASSERT_EQUALS( triMesh.getVertex( 0 ), expectedPosition );
TS_ASSERT_EQUALS( triMesh.getVertex( 0 ), expectedPosition ); // TS_ASSERT_EQUALS( triMesh.getVertex( 5 ), expectedPosition );
TS_ASSERT_EQUALS( triMesh.getVertex( 5 ), expectedPosition ); // TS_ASSERT_EQUALS( triMesh.getVertex( 7 ), expectedPosition );
TS_ASSERT_EQUALS( triMesh.getVertex( 7 ), expectedPosition ); // TS_ASSERT_DIFFERS( triMesh.getVertex( 8 ), expectedPosition );
TS_ASSERT_DIFFERS( triMesh.getVertex( 8 ), expectedPosition );
// TS_ASSERT_THROWS( mc.load( "no such file" ), std::runtime_error );
TS_ASSERT_THROWS( mc.load( "no such file" ), std::runtime_error ); // }
}
// /**
/** // * Test first saving data and the loading it back.
* Test first saving data and the loading it back. // */
*/ // void testSaveAndLoad()
void testSaveAndLoad() // {
{ // WMMarchingCubes mc;
WMMarchingCubes mc; // WTriangleMesh2 triMesh;
WTriangleMesh triMesh;
// const unsigned int nbPos = 10;
const unsigned int nbPos = 10; // const unsigned int nbTris = nbPos - 2;
const unsigned int nbTris = nbPos - 2; // std::vector< Triangle > triangles( 0 );
std::vector< Triangle > triangles( 0 ); // for( unsigned int triId = 0; triId < nbTris; ++triId )
for( unsigned int triId = 0; triId < nbTris; ++triId ) // {
{ // Triangle tri;
Triangle tri; // for( unsigned int i = 0; i < 3; ++i )
for( unsigned int i = 0; i < 3; ++i ) // {
{ // tri.pointID[i] = triId + i;
tri.pointID[i] = triId + i; // }
} // triangles.push_back( tri );
triangles.push_back( tri ); // }
} // triMesh.setTriangles( triangles );
triMesh.setTriangles( triangles );
// std::vector< wmath::WPosition > vertices( 0 );
std::vector< wmath::WPosition > vertices( 0 ); // for( unsigned int posId = 0; posId < nbPos; ++posId )
for( unsigned int posId = 0; posId < nbPos; ++posId ) // {
{ // double x = posId * posId + 3.4;
double x = posId * posId + 3.4; // double y = posId + 1;
double y = posId + 1; // double z = 3. / static_cast< double >( posId + 1 );
double z = 3. / static_cast< double >( posId + 1 ); // vertices.push_back( wmath::WPosition( x, y, z ) );
vertices.push_back( wmath::WPosition( x, y, z ) ); // }
} // triMesh.setVertices( vertices );
triMesh.setVertices( vertices );
// std::string fileName = wiotools::tempFileName();
std::string fileName = wiotools::tempFileName();
// mc.save( fileName, triMesh );
mc.save( fileName, triMesh ); // WTriangleMesh2 result = mc.load( fileName );
WTriangleMesh result = mc.load( fileName );
// TS_ASSERT_EQUALS( triMesh.getNumTriangles(), result.getNumTriangles() );
TS_ASSERT_EQUALS( triMesh.getNumTriangles(), result.getNumTriangles() ); // TS_ASSERT_EQUALS( triMesh.getNumVertices(), result.getNumVertices() );
TS_ASSERT_EQUALS( triMesh.getNumVertices(), result.getNumVertices() ); // TS_ASSERT_EQUALS( triMesh.getFastAddVertId(), result.getFastAddVertId() );
TS_ASSERT_EQUALS( triMesh.getFastAddVertId(), result.getFastAddVertId() ); // TS_ASSERT_EQUALS( triMesh.getFastAddTriangleId(), result.getFastAddTriangleId() );
TS_ASSERT_EQUALS( triMesh.getFastAddTriangleId(), result.getFastAddTriangleId() );
// for( unsigned int i = 0; i < nbPos; ++i)
for( unsigned int i = 0; i < nbPos; ++i) // {
{ // for( unsigned int j = 0; j < 3; ++j)
for( unsigned int j = 0; j < 3; ++j) // {
{ // double delta = 1e-5;
double delta = 1e-5; // // TODO(wiebel): find out why this works only for delta=1e-5
// TODO(wiebel): find out why this works only for delta=1e-5 // TS_ASSERT_DELTA( triMesh.getVertex( i )[j], result.getVertex( i )[j], delta );
TS_ASSERT_DELTA( triMesh.getVertex( i )[j], result.getVertex( i )[j], delta ); // }
} // }
} // TS_ASSERT( wiotools::fileExists( fileName ) );
TS_ASSERT( wiotools::fileExists( fileName ) ); // std::remove( fileName.c_str() );
std::remove( fileName.c_str() ); // }
}
}; };
#endif // WMMARCHINGCUBES_TEST_H #endif // WMMARCHINGCUBES_TEST_H
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