Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
1dee2321
Commit
1dee2321
authored
Jul 05, 2012
by
Sebastian Eichelbaum
Browse files
[MERGE]
parents
ce769e61
139c1543
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
235 additions
and
104 deletions
+235
-104
.hgchurn
.hgchurn
+42
-38
src/core/dataHandler/WDataSetVector.cpp
src/core/dataHandler/WDataSetVector.cpp
+4
-5
src/core/dataHandler/test/WDataSetVector_test.h
src/core/dataHandler/test/WDataSetVector_test.h
+112
-53
src/core/graphicsEngine/WTriangleMesh.cpp
src/core/graphicsEngine/WTriangleMesh.cpp
+28
-0
src/core/graphicsEngine/WTriangleMesh.h
src/core/graphicsEngine/WTriangleMesh.h
+5
-0
src/modules/readMesh/WMReadMesh.cpp
src/modules/readMesh/WMReadMesh.cpp
+42
-5
src/modules/readMesh/WMReadMesh.h
src/modules/readMesh/WMReadMesh.h
+2
-3
No files found.
.hgchurn
View file @
1dee2321
wiebel Alexander_Wiebel
wiebel@hegel.informatik.uni-leipzig.de Alexander_Wiebel
openwalnut@dergrosse.de Alexander_Wiebel
wiebel@openwalnut.org Alexander_Wiebel
wiebel_openwalnut@dergrosse.de Alexander_Wiebel
wiebel@bsv_2008a Alexander_Wiebel
math Mathias_Goldau
lmath@voltaire.informatik.uni-leipzig.de Mathias_Goldau
math@informatik.uni-leipzig.de Mathias_Goldau
schurade@spinat.cbs.mpg.de Ralph_Schurade
schurade Ralph_Schurade
softinst@heraklit.informatik.informatik.uni-leipzig.de Sebastian_Eichelbaum
ebaum Sebastian_Eichelbaum
eichelbaum@informatik.uni-leipzig.de Sebastian_Eichelbaum
wiebel
=
Alexander_Wiebel
wiebel@hegel.informatik.uni-leipzig.de
=
Alexander_Wiebel
openwalnut@dergrosse.de
=
Alexander_Wiebel
wiebel@openwalnut.org
=
Alexander_Wiebel
wiebel_openwalnut@dergrosse.de
=
Alexander_Wiebel
wiebel@bsv_2008a
=
Alexander_Wiebel
math
=
Mathias_Goldau
lmath@voltaire.informatik.uni-leipzig.de
=
Mathias_Goldau
math@informatik.uni-leipzig.de
=
Mathias_Goldau
schurade@spinat.cbs.mpg.de
=
Ralph_Schurade
schurade
=
Ralph_Schurade
softinst@heraklit.informatik.informatik.uni-leipzig.de
=
Sebastian_Eichelbaum
ebaum
=
Sebastian_Eichelbaum
eichelbaum@informatik.uni-leipzig.de
=
Sebastian_Eichelbaum
Sebastian Eichelbaum = Sebastian_Eichelbaum
cornimueller Cornelius_Mueller
mam04cvr@studserv.uni-leipzig.de Cornelius_Mueller
hlawit Mario_Hlawitschka
hlawitschka@informatik.uni-leipzig.de Mario_Hlawitschka
hlawit@informatik.uni-leipzig.de Mario_Hlawitschka
hlawitschka@ucdavis.edu Mario_Hlawitschka
mai02igw@informatik.uni-leipzig.de Robin_Ledig
mai02ifw@informatik.uni-leipzig.de Robin_Ledig
mai02igw@studserv.uni-leipzig.de Robin_Ledig
heine@informatik.uni-leipzig.de Christian_Heine
reichenbach@berkeley.informatik.uni-leipzig.de Andre_Reichenbach
reichenbach Andre_Reichenbach
reichenbach@informatik.uni-leipzig.de Andre_Reichenbach
Andre Andre_Reichenbach
philips@informatik.uni-leipzig.de Stefan_Philips
frohl.robert@googlemail.com Robert_Frohl
dirk_albrecht@gmx.net Dirk_Albrecht
albrecht Dirk_Albrecht
mstuber Marcus_Stuber
skiunke Sebastian_Kiunke
a_berres@informatik.uni-kl.de Anne_Berres
gsommer_by@gmx.de Gerald_Sommer
= Unknown___________________
root@openwalnut.com = Unknown___________________
cornimueller = Cornelius_Mueller
cornimueller@googlemail.com = Cornelius_Mueller
mam04cvr@studserv.uni-leipzig.de = Cornelius_Mueller
hlawit = Mario_Hlawitschka
hlawitschka@informatik.uni-leipzig.de = Mario_Hlawitschka
hlawit@informatik.uni-leipzig.de = Mario_Hlawitschka
hlawitschka@ucdavis.edu = Mario_Hlawitschka
mai02igw@informatik.uni-leipzig.de = Robin_Ledig
mai02ifw@informatik.uni-leipzig.de = Robin_Ledig
mai02igw@studserv.uni-leipzig.de = Robin_Ledig
heine@informatik.uni-leipzig.de = Christian_Heine
reichenbach@berkeley.informatik.uni-leipzig.de = Andre_Reichenbach
reichenbach = Andre_Reichenbach
reichenbach@informatik.uni-leipzig.de = Andre_Reichenbach
Andre = Andre_Reichenbach
Andre Reichenbach = Andre_Reichenbach
philips@informatik.uni-leipzig.de = Stefan_Philips
frohl.robert@googlemail.com = Robert_Frohl
dirk_albrecht@gmx.net = Dirk_Albrecht
albrecht = Dirk_Albrecht
mstuber = Marcus_Stuber
matthias.berndt@studserv.uni-leipzig.de = Matthias_Berndt
pieloth@labp.htwk-leipzig.de = Christof_Pieloth
skiunke = Sebastian_Kiunke
a_berres@informatik.uni-kl.de = Anne_Berres
gsommer_by@gmx.de = Gerald_Sommer
= Unknown_________
root@openwalnut.com = Unknown_________
src/core/dataHandler/WDataSetVector.cpp
View file @
1dee2321
...
...
@@ -91,7 +91,6 @@ namespace
boost
::
shared_ptr
<
const
WGridRegular3D
>
grid
=
boost
::
shared_dynamic_cast
<
const
WGridRegular3D
>
(
i_grid
);
WAssert
(
grid
,
"This data set has a grid whose type is not yet supported for interpolation."
);
WAssert
(
grid
->
isNotRotated
(),
"Only feasible for grids that are only translated or scaled so far."
);
WAssert
(
(
i_valueSet
->
order
()
==
1
&&
i_valueSet
->
dimension
()
==
3
),
"Only implemented for 3D Vectors so far."
);
boost
::
array
<
double
,
8
>
h
;
...
...
@@ -108,11 +107,11 @@ namespace
*
vertexIds
=
grid
->
getCellVertexIds
(
cellId
);
WPosition
localPos
=
pos
-
grid
->
getPosition
(
(
*
vertexIds
)[
0
]
);
WPosition
localPos
=
grid
->
getTransform
().
positionToGridSpace
(
pos
-
grid
->
getPosition
(
(
*
vertexIds
)[
0
]
)
);
double
lambdaX
=
localPos
[
0
]
/
grid
->
getOffsetX
()
;
double
lambdaY
=
localPos
[
1
]
/
grid
->
getOffsetY
()
;
double
lambdaZ
=
localPos
[
2
]
/
grid
->
getOffsetZ
()
;
double
lambdaX
=
localPos
[
0
];
double
lambdaY
=
localPos
[
1
];
double
lambdaZ
=
localPos
[
2
];
// lZ lY
// | /
...
...
src/core/dataHandler/test/WDataSetVector_test.h
View file @
1dee2321
...
...
@@ -26,6 +26,7 @@
#define WDATASETVECTOR_TEST_H
#include <vector>
#include <cmath>
#include <boost/array.hpp>
...
...
@@ -53,57 +54,39 @@ public:
*/
void
testInterpolate
(
void
)
{
boost
::
shared_ptr
<
WGrid
>
grid
=
boost
::
shared_ptr
<
WGrid
>
(
new
WGridRegular3D
(
5
,
3
,
3
)
);
boost
::
shared_ptr
<
std
::
vector
<
double
>
>
data
=
boost
::
shared_ptr
<
std
::
vector
<
double
>
>
(
new
std
::
vector
<
double
>
(
grid
->
size
()
*
3
)
);
boost
::
shared_ptr
<
WGridRegular3D
>
grid
(
new
WGridRegular3D
(
2
,
2
,
2
)
);
boost
::
array
<
WPosition
,
8
>
d
=
{
{
WPosition
(
0
,
1
,
2
),
WPosition
(
3
,
4
,
5
),
WPosition
(
6
,
7
,
8
),
// NOLINT braces
WPosition
(
9
,
10
,
11
),
WPosition
(
12
,
13
,
14
),
WPosition
(
15
,
16
,
17
),
WPosition
(
18
,
19
,
20
),
WPosition
(
21
,
22
,
23
)
}
};
// NOLINT braces
boost
::
shared_ptr
<
std
::
vector
<
double
>
>
data
(
new
std
::
vector
<
double
>
);
for
(
size_t
i
=
0
;
i
<
grid
->
size
()
*
3
;
++
i
)
{
(
*
data
)[
i
]
=
i
;
data
->
push_back
(
i
)
;
}
double
almost1
=
1
-
wlimits
::
DBL_EPS
;
boost
::
array
<
WPosition
,
8
>
gridPos
=
{
{
WPosition
(
0
,
0
,
0
),
WPosition
(
almost1
,
0
,
0
),
WPosition
(
0
,
almost1
,
0
),
// NOLINT braces
WPosition
(
almost1
,
almost1
,
0
),
WPosition
(
0
,
0
,
almost1
),
WPosition
(
almost1
,
0
,
almost1
),
WPosition
(
0
,
almost1
,
almost1
),
WPosition
(
almost1
,
almost1
,
almost1
)
}
};
// NOLINT braces
boost
::
shared_ptr
<
WValueSet
<
double
>
>
valueSet
(
new
WValueSet
<
double
>
(
1
,
3
,
data
,
W_DT_DOUBLE
)
);
WDataSetVector
ds
(
valueSet
,
grid
);
bool
success
=
false
;
for
(
size_t
i
=
0
;
i
<
8
;
++
i
)
{
if
(
!
delta
(
ds
.
interpolate
(
gridPos
[
i
],
&
success
),
d
[
i
],
1e-9
)
)
{
std
::
stringstream
ss
;
ss
<<
"i:"
<<
i
<<
" gridPos(i):"
<<
gridPos
[
i
]
<<
" d(i):"
<<
d
[
i
]
<<
" interpol:"
<<
ds
.
interpolate
(
gridPos
[
i
],
&
success
)
<<
"
\n
"
;
TS_FAIL
(
ss
.
str
()
);
}
TS_ASSERT
(
success
);
}
TS_ASSERT_EQUALS
(
ds
.
interpolate
(
WPosition
(
0
,
0
,
0
),
&
success
)[
0
],
(
*
data
)[
0
]
);
TS_ASSERT_EQUALS
(
ds
.
interpolate
(
WPosition
(
0
,
0
,
0
),
&
success
)[
1
],
(
*
data
)[
1
]
);
TS_ASSERT_EQUALS
(
ds
.
interpolate
(
WPosition
(
0
,
0
,
0
),
&
success
)[
2
],
(
*
data
)[
2
]
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
0
,
0
),
&
success
)[
0
],
(
*
data
)[
3
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
0
,
0
),
&
success
)[
1
],
(
*
data
)[
4
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
0
,
0
),
&
success
)[
2
],
(
*
data
)[
5
],
1e-9
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0
,
1
,
0
),
&
success
)[
0
],
(
*
data
)[
15
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0
,
1
,
0
),
&
success
)[
1
],
(
*
data
)[
16
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0
,
1
,
0
),
&
success
)[
2
],
(
*
data
)[
17
],
1e-9
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
1
,
0
),
&
success
)[
0
],
(
*
data
)[
18
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
1
,
0
),
&
success
)[
1
],
(
*
data
)[
19
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
1
,
0
),
&
success
)[
2
],
(
*
data
)[
20
],
1e-9
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0
,
0
,
1
),
&
success
)[
0
],
(
*
data
)[
45
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0
,
0
,
1
),
&
success
)[
1
],
(
*
data
)[
46
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0
,
0
,
1
),
&
success
)[
2
],
(
*
data
)[
47
],
1e-9
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
0
,
1
),
&
success
)[
0
],
(
*
data
)[
48
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
0
,
1
),
&
success
)[
1
],
(
*
data
)[
49
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
0
,
1
),
&
success
)[
2
],
(
*
data
)[
50
],
1e-9
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0
,
1
,
1
),
&
success
)[
0
],
(
*
data
)[
60
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0
,
1
,
1
),
&
success
)[
1
],
(
*
data
)[
61
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0
,
1
,
1
),
&
success
)[
2
],
(
*
data
)[
62
],
1e-9
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
1
,
1
),
&
success
)[
0
],
(
*
data
)[
63
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
1
,
1
),
&
success
)[
1
],
(
*
data
)[
64
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
1
,
1
,
1
),
&
success
)[
2
],
(
*
data
)[
65
],
1e-9
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0.3
,
0.4
,
0.5
),
&
success
)[
0
],
29.4
,
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0.3
,
0.4
,
0.5
),
&
success
)[
1
],
30.4
,
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0.3
,
0.4
,
0.5
),
&
success
)[
2
],
31.4
,
1e-9
);
TS_ASSERT
(
delta
(
ds
.
interpolate
(
WPosition
(
0.3
,
0.4
,
0.5
),
&
success
),
WPosition
(
9.3
,
10.3
,
11.3
),
1e-9
)
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0.5
,
0.5
,
0.5
),
&
success
)[
0
],
31.5
,
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0.5
,
0.5
,
0.5
),
&
success
)[
1
],
32.5
,
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0.5
,
0.5
,
0.5
),
&
success
)[
2
],
33.5
,
1e-9
);
TS_ASSERT
(
delta
(
ds
.
interpolate
(
WPosition
(
0.5
,
0.5
,
0.5
),
&
success
),
WPosition
(
10.5
,
11.5
,
12.5
),
1e-9
)
);
TS_ASSERT
(
success
);
}
...
...
@@ -159,22 +142,15 @@ public:
bool
success
=
false
;
TS_ASSERT_EQUALS
(
ds
.
interpolate
(
WPosition
(
0.0
,
0.0
,
0.0
),
&
success
),
d
[
0
]
);
TS_ASSERT
(
success
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0.9999
,
0.9999
,
0.9999
),
&
success
)[
0
],
d
[
7
][
0
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0.9999
,
0.9999
,
0.9999
),
&
success
)[
1
],
d
[
7
][
1
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
interpolate
(
WPosition
(
0.9999
,
0.9999
,
0.9999
),
&
success
)[
2
],
d
[
7
][
2
],
1e-9
);
TS_ASSERT
(
delta
(
ds
.
interpolate
(
WPosition
(
0.9999
,
0.9999
,
0.9999
),
&
success
),
d
[
7
],
1e-9
)
);
TS_ASSERT
(
success
);
WPosition
expected
(
0.75
,
0.0
,
0.0
);
TS_ASSERT_EQUALS
(
ds
.
interpolate
(
WPosition
(
0.5
,
0.5
,
0.5
),
&
success
),
expected
);
TS_ASSERT_EQUALS
(
ds
.
interpolate
(
WPosition
(
0.5
,
0.5
,
0.5
),
&
success
),
WPosition
(
0.75
,
0.0
,
0.0
)
);
TS_ASSERT
(
success
);
TS_ASSERT_EQUALS
(
ds
.
eigenVectorInterpolate
(
WPosition
(
0.0
,
0.0
,
0.0
),
&
success
),
d
[
0
]
);
TS_ASSERT
(
success
);
expected
=
WPosition
(
-
1.0
,
0.0
,
0.0
);
TS_ASSERT_DELTA
(
ds
.
eigenVectorInterpolate
(
WPosition
(
0.9999
,
0.9999
,
0.9999
),
&
success
)[
0
],
expected
[
0
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
eigenVectorInterpolate
(
WPosition
(
0.9999
,
0.9999
,
0.9999
),
&
success
)[
1
],
expected
[
1
],
1e-9
);
TS_ASSERT_DELTA
(
ds
.
eigenVectorInterpolate
(
WPosition
(
0.9999
,
0.9999
,
0.9999
),
&
success
)[
2
],
expected
[
2
],
1e-9
);
TS_ASSERT
(
delta
(
ds
.
eigenVectorInterpolate
(
WPosition
(
0.9999
,
0.9999
,
0.9999
),
&
success
),
WPosition
(
-
1.0
,
0.0
,
0.0
),
1e-9
)
);
TS_ASSERT
(
success
);
expected
=
WPosition
(
-
1.0
,
0.0
,
0.0
);
TS_ASSERT_EQUALS
(
ds
.
eigenVectorInterpolate
(
WPosition
(
0.5
,
0.5
,
0.5
),
&
success
),
expected
);
TS_ASSERT_EQUALS
(
ds
.
eigenVectorInterpolate
(
WPosition
(
0.5
,
0.5
,
0.5
),
&
success
),
WPosition
(
-
1.0
,
0.0
,
0.0
)
);
TS_ASSERT
(
success
);
}
...
...
@@ -196,6 +172,89 @@ public:
ds
.
interpolate
(
WPosition
(
2.0
,
3.0
,
4.0
),
&
success
);
TS_ASSERT
(
!
success
);
}
/**
* When the grid for this dataset was rotated the interpolation should still work.
*/
void
testRotatedGridInterpolate
(
void
)
{
// rotation around z with 45 degrees
WMatrix
<
double
>
mat
(
4
,
4
);
mat
.
makeIdentity
();
mat
(
0
,
0
)
=
1.0
/
sqrt
(
2.0
);
mat
(
0
,
1
)
=
1.0
/
sqrt
(
2.0
);
mat
(
1
,
0
)
=
-
1.0
/
sqrt
(
2.0
);
mat
(
1
,
1
)
=
1.0
/
sqrt
(
2.0
);
WGridTransformOrtho
v
(
mat
);
boost
::
shared_ptr
<
WGridRegular3D
>
grid
(
new
WGridRegular3D
(
2
,
2
,
2
,
v
)
);
boost
::
shared_ptr
<
std
::
vector
<
double
>
>
data
(
new
std
::
vector
<
double
>
);
boost
::
array
<
WPosition
,
8
>
d
=
{
{
WPosition
(
-
1
,
0
,
0
),
// NOLINT braces
WPosition
(
1
,
0
,
0
),
WPosition
(
1
,
0
,
0
),
WPosition
(
1
,
0
,
0
),
WPosition
(
1
,
0
,
0
),
WPosition
(
1
,
0
,
0
),
WPosition
(
1
,
0
,
0
),
WPosition
(
1
,
0
,
0
)
}
};
// NOLINT braces
for
(
size_t
i
=
0
;
i
<
grid
->
size
();
++
i
)
{
data
->
push_back
(
d
[
i
][
0
]
);
data
->
push_back
(
d
[
i
][
1
]
);
data
->
push_back
(
d
[
i
][
2
]
);
}
boost
::
shared_ptr
<
WValueSet
<
double
>
>
valueSet
(
new
WValueSet
<
double
>
(
1
,
3
,
data
,
W_DT_DOUBLE
)
);
WDataSetVector
ds
(
valueSet
,
grid
);
bool
success
=
false
;
WPosition
pos
=
grid
->
getTransform
().
positionToWorldSpace
(
WPosition
(
0.0
,
0.0
,
0.0
)
);
TS_ASSERT_EQUALS
(
ds
.
interpolate
(
pos
,
&
success
),
d
[
0
]
);
TS_ASSERT
(
success
);
pos
=
grid
->
getTransform
().
positionToWorldSpace
(
WPosition
(
0.9999
,
0.9999
,
0.9999
)
);
TS_ASSERT
(
delta
(
ds
.
interpolate
(
pos
,
&
success
),
d
[
7
],
1e-9
)
);
TS_ASSERT
(
success
);
pos
=
grid
->
getTransform
().
positionToWorldSpace
(
WPosition
(
0.5
,
0.5
,
0.5
)
);
TS_ASSERT_EQUALS
(
ds
.
interpolate
(
pos
,
&
success
),
WPosition
(
0.75
,
0.0
,
0.0
)
);
TS_ASSERT
(
success
);
pos
=
grid
->
getTransform
().
positionToWorldSpace
(
WPosition
(
0.0
,
0.0
,
0.0
)
);
TS_ASSERT_EQUALS
(
ds
.
eigenVectorInterpolate
(
pos
,
&
success
),
d
[
0
]
);
TS_ASSERT
(
success
);
pos
=
grid
->
getTransform
().
positionToWorldSpace
(
WPosition
(
0.9999
,
0.9999
,
0.9999
)
);
TS_ASSERT
(
delta
(
ds
.
eigenVectorInterpolate
(
pos
,
&
success
),
WPosition
(
-
1.0
,
0.0
,
0.0
),
1e-9
)
);
TS_ASSERT
(
success
);
pos
=
grid
->
getTransform
().
positionToWorldSpace
(
WPosition
(
0.5
,
0.5
,
0.5
)
);
TS_ASSERT_EQUALS
(
ds
.
eigenVectorInterpolate
(
pos
,
&
success
),
WPosition
(
-
1.0
,
0.0
,
0.0
)
);
TS_ASSERT
(
success
);
}
private:
/**
* Computes if both vectors are almost similar and their components do not differ from a certain given delta.
*
* \param lhs First vector
* \param rhs Second vector
* \param d The given delta
*
* \return True if and only if all components differing at most by the given delta.
*/
bool
delta
(
WVector3d
lhs
,
WVector3d
rhs
,
double
d
)
{
bool
result
=
true
;
for
(
int
i
=
0
;
result
&&
(
i
<
3
);
++
i
)
{
result
=
result
&&
(
std
::
abs
(
lhs
[
i
]
-
rhs
[
i
]
)
<=
d
);
if
(
!
result
)
{
std
::
cout
.
precision
(
10
);
std
::
cout
.
setf
(
std
::
ios
::
fixed
,
std
::
ios
::
floatfield
);
std
::
cout
<<
"delta failed! => lhs:"
<<
lhs
<<
" rhs:"
<<
rhs
<<
" failed: abs(lhs["
<<
i
<<
"] - rhs["
<<
i
<<
"])="
<<
std
::
abs
(
lhs
[
i
]
-
rhs
[
i
]
)
<<
", but should be: "
<<
d
<<
"
\n
"
;
}
}
return
result
;
}
};
#endif // WDATASETVECTOR_TEST_H
src/core/graphicsEngine/WTriangleMesh.cpp
View file @
1dee2321
...
...
@@ -616,6 +616,34 @@ void WTriangleMesh::zoomMesh( float zoom )
}
}
void
WTriangleMesh
::
rescaleVertexColors
()
{
float
maxR
=
0
;
float
maxG
=
0
;
float
maxB
=
0
;
for
(
size_t
vertId
=
0
;
vertId
<
m_vertColors
->
size
();
++
vertId
)
{
if
(
(
*
m_vertColors
)[
vertId
][
0
]
>
maxR
)
{
maxR
=
(
*
m_vertColors
)[
vertId
][
0
];
}
if
(
(
*
m_vertColors
)[
vertId
][
1
]
>
maxG
)
{
maxG
=
(
*
m_vertColors
)[
vertId
][
1
];
}
if
(
(
*
m_vertColors
)[
vertId
][
2
]
>
maxB
)
{
maxB
=
(
*
m_vertColors
)[
vertId
][
2
];
}
}
for
(
size_t
vertId
=
0
;
vertId
<
m_vertColors
->
size
();
++
vertId
)
{
(
*
m_vertColors
)[
vertId
][
0
]
/=
maxR
;
(
*
m_vertColors
)[
vertId
][
1
]
/=
maxG
;
(
*
m_vertColors
)[
vertId
][
2
]
/=
maxB
;
}
}
std
::
ostream
&
tm_utils
::
operator
<<
(
std
::
ostream
&
os
,
const
WTriangleMesh
&
rhs
)
{
std
::
stringstream
ss
;
...
...
src/core/graphicsEngine/WTriangleMesh.h
View file @
1dee2321
...
...
@@ -374,6 +374,11 @@ public:
*/
bool
operator
==
(
const
WTriangleMesh
&
rhs
)
const
;
/**
* Rescale the vertex colors so that the maximum of all r, g and b values is 1
*/
void
rescaleVertexColors
();
protected:
static
boost
::
shared_ptr
<
WPrototyped
>
m_prototype
;
//!< The prototype as singleton.
private:
...
...
src/modules/readMesh/WMReadMesh.cpp
View file @
1dee2321
...
...
@@ -152,7 +152,7 @@ void WMReadMesh::moduleMain()
switch
(
m_fileTypeSelection
->
get
(
true
).
getItemIndexOfSelected
(
0
)
)
{
case
0
:
m_triMesh
=
readMesh
();
m_triMesh
=
readMesh
VTK
();
break
;
case
1
:
m_triMesh
=
readMeshFnav
();
...
...
@@ -306,7 +306,7 @@ boost::shared_ptr< WTriangleMesh > WMReadMesh::readMeshFnav()
}
boost
::
shared_ptr
<
WTriangleMesh
>
WMReadMesh
::
readMesh
()
boost
::
shared_ptr
<
WTriangleMesh
>
WMReadMesh
::
readMesh
VTK
()
{
namespace
su
=
string_utils
;
...
...
@@ -444,13 +444,15 @@ boost::shared_ptr< WTriangleMesh > WMReadMesh::readMesh()
// ----- Vector as color ---------
char
*
vectorMarker
=
new
char
[
30
];
char
*
vectorName
=
new
char
[
30
];
char
*
vectorDataType
=
new
char
[
30
];
ifs
>>
vectorMarker
>>
vectorName
>>
vectorDataType
;
char
*
vectorInfo1
=
new
char
[
30
];
char
*
vectorInfo2
=
new
char
[
30
];
ifs
>>
vectorMarker
>>
vectorName
>>
vectorInfo1
>>
vectorInfo2
;
if
(
std
::
string
(
vectorMarker
)
==
"VECTORS"
&&
m_propVectorAsColor
->
get
()
&&
std
::
string
(
vector
DataType
)
==
"float"
)
&&
std
::
string
(
vector
Info1
)
==
"float"
)
{
WLogger
::
getLogger
()
->
addLogMessage
(
"Reading colors from vectors"
,
"Read Mesh"
,
LL_DEBUG
);
WColor
vectorComp
;
for
(
unsigned
int
i
=
0
;
i
<
nbVectors
;
++
i
)
{
...
...
@@ -460,12 +462,47 @@ boost::shared_ptr< WTriangleMesh > WMReadMesh::readMesh()
triMesh
->
setVertexColor
(
i
,
vectorComp
);
}
}
if
(
std
::
string
(
vectorMarker
)
==
"ARRAYS"
)
{
//WLogger::getLogger()->addLogMessage( std::string( vectorInfo1[0] ), "Read Mesh", LL_DEBUG );
WAssert
(
vectorInfo1
[
0
]
==
'2'
||
vectorInfo1
[
0
]
==
'3'
,
"Can only deal with 2D or 3D arrays."
);
if
(
m_propVectorAsColor
->
get
()
&&
std
::
string
(
vectorInfo2
)
==
"float"
)
{
WLogger
::
getLogger
()
->
addLogMessage
(
"Reading colors from arrays"
,
"Read Mesh"
,
LL_DEBUG
);
WColor
vectorComp
;
for
(
unsigned
int
i
=
0
;
i
<
nbVectors
;
++
i
)
{
std
::
string
line
;
std
::
getline
(
ifs
,
line
,
'\n'
);
if
(
vectorInfo1
[
0
]
==
'2'
)
{
ifs
>>
vectorComp
[
0
]
>>
vectorComp
[
1
];
vectorComp
[
2
]
=
0
;
}
if
(
vectorInfo1
[
0
]
==
'3'
)
{
ifs
>>
vectorComp
[
0
]
>>
vectorComp
[
1
]
>>
vectorComp
[
2
];
}
triMesh
->
setVertexColor
(
i
,
vectorComp
);
}
}
}
triMesh
->
rescaleVertexColors
();
delete
[]
vectorMarker
;
delete
[]
vectorName
;
delete
[]
vectorInfo1
;
delete
[]
vectorInfo2
;
}
ifs
.
close
();
progress
->
finish
();
delete
[]
cellsMarker
;
delete
[]
cells_typesMarker
;
delete
[]
marker
;
return
triMesh
;
}
...
...
src/modules/readMesh/WMReadMesh.h
View file @
1dee2321
...
...
@@ -104,11 +104,11 @@ private:
void
meshTypeSelected
();
/**
* Reads a mesh file and creates a WTriangleMesh out of it.
* Reads a
VTK
mesh file and creates a WTriangleMesh out of it.
*
* \return Reference to the dataset.
*/
virtual
boost
::
shared_ptr
<
WTriangleMesh
>
readMesh
();
virtual
boost
::
shared_ptr
<
WTriangleMesh
>
readMesh
VTK
();
/**
* Reads a mesh file and creates a WTriangleMesh out of it.
...
...
@@ -124,7 +124,6 @@ private:
* \return Reference to the dataset.
*/
virtual
boost
::
shared_ptr
<
WTriangleMesh
>
readDip
();
/**
* Reads a BrainVISA (.mesh) file and creates a WTriangleMesh out of it.
*
...
...
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