Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
df4bb618
Commit
df4bb618
authored
Apr 08, 2010
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Plain Diff
[MERGE]
parents
a5c8e32d
8f018cae
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
123 additions
and
113 deletions
+123
-113
src/CMakeLists.txt
src/CMakeLists.txt
+20
-10
src/common/CMakeLists.txt
src/common/CMakeLists.txt
+1
-2
src/dataHandler/test/WValueSetBase_test.h
src/dataHandler/test/WValueSetBase_test.h
+5
-0
src/graphicsEngine/WTriangleMesh2.h
src/graphicsEngine/WTriangleMesh2.h
+1
-1
src/modules/distanceMap/WMDistanceMapIsosurface.cpp
src/modules/distanceMap/WMDistanceMapIsosurface.cpp
+5
-1
src/modules/distanceMap/WMDistanceMapIsosurface.h
src/modules/distanceMap/WMDistanceMapIsosurface.h
+1
-0
src/modules/marchingCubes/test/WMMarchingCubes_test.h
src/modules/marchingCubes/test/WMMarchingCubes_test.h
+90
-99
No files found.
src/CMakeLists.txt
View file @
df4bb618
...
...
@@ -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
...
...
src/common/CMakeLists.txt
View file @
df4bb618
...
...
@@ -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
...
...
src/dataHandler/test/WValueSetBase_test.h
View file @
df4bb618
...
...
@@ -69,6 +69,11 @@ public:
{
return
255
;
}
virtual
double
getScalarDouble
(
size_t
i
)
const
{
return
255
;
}
};
/**
...
...
src/graphicsEngine/WTriangleMesh2.h
View file @
df4bb618
...
...
@@ -232,7 +232,7 @@ public:
/**
* getter
*
* \return number of vert
ex
es in the mesh
* \return number of vert
ic
es in the mesh
*/
size_t
vertSize
()
const
;
...
...
src/modules/distanceMap/WMDistanceMapIsosurface.cpp
View file @
df4bb618
...
...
@@ -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
//////////////////////////////////////////////////////////////////////////////////
...
...
src/modules/distanceMap/WMDistanceMapIsosurface.h
View file @
df4bb618
...
...
@@ -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.
...
...
src/modules/marchingCubes/test/WMMarchingCubes_test.h
View file @
df4bb618
...
...
@@ -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
;
WTriangleMesh
2
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment