OpenWalnut  1.5.0dev
WGEGeometryUtils.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WGEGEOMETRYUTILS_H
26 #define WGEGEOMETRYUTILS_H
27 
28 #include <vector>
29 
30 #include <osg/Array>
31 
32 #include "../common/math/linearAlgebra/WPosition.h"
33 #include "WTriangleMesh.h"
34 
35 
36 
37 namespace wge
38 {
39  /**
40  * Creates out of eight corner vertices QUAD vertices.
41  *
42  * \param corners The eight corner vertices which must be in the following order:
43  *
44  * \verbatim
45  z-axis y-axis
46  | /
47  | h___/_g
48  |/: /|
49  d_:___c |
50  | :...|.|
51  |.e | f
52  |_____|/ ____x-axis
53  a b
54  \endverbatim
55  *
56  * The QUADS are generated in the following order:
57  * - a,b,c,d
58  * - b,f,g,c
59  * - f,e,h,g
60  * - e,a,d,h
61  * - d,c,g,h
62  * - a,b,f,e
63  *
64  * \return OSG vertex array where every four vertices describing a QUAD.
65  */
66  osg::ref_ptr< osg::Vec3Array > generateCuboidQuads( const std::vector< WPosition >& corners );
67 
68  /**
69  * Generates for a QUAD given via 3 three points ( the fourth is not needed ) the
70  * normal.
71  *
72  *\param a First point of the QUAD
73  *\param b Second point of the QUAD
74  *\param c Third point of the QUAD
75  *
76  *\return OSG Vector of the normal of the QUAD
77  */
78  osg::Vec3 getQuadNormal( const WPosition& a, const WPosition& b, const WPosition& c );
79 
80  /**
81  * Generates for all QUADS of the Cuboid the normals in the following order:
82  *
83  * \verbatim
84  z-axis y-axis
85  | /
86  | h___/_g
87  |/: /|
88  d_:___c |
89  | :...|.|
90  |.e | f
91  |_____|/ ____x-axis
92  a b
93  \endverbatim
94  *
95  * - a,b,c,d
96  * - b,f,g,c
97  * - f,e,h,g
98  * - e,a,d,h
99  * - d,c,g,h
100  * - a,b,f,e
101  *
102  *\param corners Corner points of the cuboid.
103  *
104  *\return Array of normals in the order as shown above.
105  */
106  osg::ref_ptr< osg::Vec3Array > generateCuboidQuadNormals( const std::vector< WPosition >& corners );
107 
108  /**
109  * Calculate the Delaunay Triangulation of the given points.
110  *
111  * If the parameter transformationFactor is not zero, the points will be
112  * transformed to calcule the triangles to get a better triangulation, but
113  * the returned mesh will consist of the original points.
114  * Every point which lies above the centroid of all points will be put away
115  * from this centroid by transformationFactor * height above the centroid.
116  * Any point below the centroid will be drawn to the centroid because its
117  * height is negative. This effect is inverted with a negative
118  * transformationFactor.
119  * This transformation is used to calculate the head surface between several
120  * electrodes, were a transformationFactor of -0.005 is reasonable.
121  *
122  * \param points vector of the points to triangulate
123  * \param transformationFactor magnitude of the transformation before the
124  * triangulation
125  * \return triangulation as WTriangleMesh
126  */
127  WTriangleMesh::SPtr triangulate( const std::vector< WPosition >& points, double transformationFactor = 0.0 );
128 }
129 
130 #endif // WGEGEOMETRYUTILS_H
This only is a 3d double vector.
std::shared_ptr< WTriangleMesh > SPtr
Shared pointer.
Definition: WTriangleMesh.h:55
Extend the wge utils namespace with additional methods relating WDataTexture3D.
osg::ref_ptr< osg::Vec3Array > generateCuboidQuadNormals(const std::vector< WPosition > &corners)
Generates for all QUADS of the Cuboid the normals in the following order:
WTriangleMesh::SPtr triangulate(const std::vector< WPosition > &points, double transformationFactor=0.0)
Calculate the Delaunay Triangulation of the given points.
osg::Vec3 getQuadNormal(const WPosition &a, const WPosition &b, const WPosition &c)
Generates for a QUAD given via 3 three points ( the fourth is not needed ) the normal.
osg::ref_ptr< osg::Vec3Array > generateCuboidQuads(const std::vector< WPosition > &corners)
Creates out of eight corner vertices QUAD vertices.