Commit df4bb618 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[MERGE]

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