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
3c2dc3c9
Commit
3c2dc3c9
authored
Apr 09, 2010
by
cornimueller
Browse files
[ADD] Perform transformation before triangulate the head surface to get a better looking mesh.
parent
07623160
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
5 deletions
+37
-5
src/graphicsEngine/WGEGeometryUtils.cpp
src/graphicsEngine/WGEGeometryUtils.cpp
+20
-1
src/graphicsEngine/WGEGeometryUtils.h
src/graphicsEngine/WGEGeometryUtils.h
+16
-3
src/modules/eegView/WMEEGView.cpp
src/modules/eegView/WMEEGView.cpp
+1
-1
No files found.
src/graphicsEngine/WGEGeometryUtils.cpp
View file @
3c2dc3c9
...
...
@@ -95,7 +95,7 @@ osg::ref_ptr< osg::Vec3Array > wge::generateCuboidQuadNormals( const std::vector
return
vertices
;
}
WTriangleMesh
wge
::
triangulate
(
const
std
::
vector
<
wmath
::
WPosition
>&
points
)
WTriangleMesh
wge
::
triangulate
(
const
std
::
vector
<
wmath
::
WPosition
>&
points
,
double
transformationFactor
)
{
WTriangleMesh
mesh
;
mesh
.
setVertices
(
points
);
...
...
@@ -104,6 +104,25 @@ WTriangleMesh wge::triangulate( const std::vector< wmath::WPosition >& points )
{
osg
::
ref_ptr
<
osg
::
Vec3Array
>
osgPoints
=
wge
::
osgVec3Array
(
points
);
if
(
transformationFactor
!=
0.0
)
{
// Transform the points as described in the Doxygen description of
// this function.
osg
::
Vec3
centroid
;
for
(
std
::
size_t
pointID
=
0
;
pointID
<
osgPoints
->
size
();
++
pointID
)
{
centroid
+=
(
*
osgPoints
)[
pointID
];
}
centroid
/=
osgPoints
->
size
();
for
(
std
::
size_t
pointID
=
0
;
pointID
<
osgPoints
->
size
();
++
pointID
)
{
const
double
factor
=
(
(
*
osgPoints
)[
pointID
].
z
()
-
centroid
.
z
()
)
*
transformationFactor
+
1.0
;
(
*
osgPoints
)[
pointID
].
x
()
=
(
(
*
osgPoints
)[
pointID
].
x
()
-
centroid
.
x
()
)
*
factor
+
centroid
.
x
();
(
*
osgPoints
)[
pointID
].
y
()
=
(
(
*
osgPoints
)[
pointID
].
y
()
-
centroid
.
y
()
)
*
factor
+
centroid
.
y
();
}
}
// The osg triangulator sorts the points and returns the triangles with
// the indizes of the sorted points. Since we don't want to change the
// sequence of the points, we have to save the original index of each
...
...
src/graphicsEngine/WGEGeometryUtils.h
View file @
3c2dc3c9
...
...
@@ -105,12 +105,25 @@ namespace wge
osg
::
ref_ptr
<
osg
::
Vec3Array
>
generateCuboidQuadNormals
(
const
std
::
vector
<
wmath
::
WPosition
>&
corners
);
/**
* Calculate the Delaunay Triangulat
at
ion of the given points.
* Calculate the Delaunay Triangulation of the given points.
*
* \param points vector of the points to triangulate
* If the parameter transformationFactor is not zero, the points will be
* transformed to calcule the triangles to get a better triangulation, but
* the returned mesh will consist of the original points.
* Every point which lies above the centroid of all points will be put away
* from this centroid by transformationFactor * height above the centroid.
* Any point below the centroid will be drawn to the centroid because its
* height is negative. This effect is inverted with a negative
* transformationFactor.
* This transformation is used to calculate the head surface between several
* electrodes, were a transformationFactor of -0.005 is reasonable.
*
* \param points vector of the points to triangulate
* \param transformationFactor magnitude of the transformation before the
* triangulation
* \return triangulation as WTriangleMesh
*/
WTriangleMesh
triangulate
(
const
std
::
vector
<
wmath
::
WPosition
>&
points
);
WTriangleMesh
triangulate
(
const
std
::
vector
<
wmath
::
WPosition
>&
points
,
double
transformationFactor
=
0.0
);
}
#endif // WGEGEOMETRYUTILS_H
src/modules/eegView/WMEEGView.cpp
View file @
3c2dc3c9
...
...
@@ -608,7 +608,7 @@ osg::ref_ptr< osg::Node > WMEEGView::drawHeadSurface()
const
std
::
size_t
nbPositions
=
positions
.
size
();
WTriangleMesh
mesh
=
wge
::
triangulate
(
positions
);
WTriangleMesh
mesh
=
wge
::
triangulate
(
positions
,
-
0.005
);
osg
::
ref_ptr
<
osg
::
Geometry
>
geometry
=
wge
::
convertToOsgGeometry
(
&
mesh
,
true
);
osg
::
Vec4Array
*
colors
=
new
osg
::
Vec4Array
;
...
...
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