OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WGEGEOMETRYUTILS_H 00026 #define WGEGEOMETRYUTILS_H 00027 00028 #include <vector> 00029 00030 #include <osg/Array> 00031 00032 #include "../common/math/linearAlgebra/WPosition.h" 00033 #include "WTriangleMesh.h" 00034 00035 00036 00037 namespace wge 00038 { 00039 /** 00040 * Creates out of eight corner vertices QUAD vertices. 00041 * 00042 * \param corners The eight corner vertices which must be in the following order: 00043 * 00044 * \verbatim 00045 z-axis y-axis 00046 | / 00047 | h___/_g 00048 |/: /| 00049 d_:___c | 00050 | :...|.| 00051 |.e | f 00052 |_____|/ ____x-axis 00053 a b 00054 \endverbatim 00055 * 00056 * The QUADS are generated in the following order: 00057 * - a,b,c,d 00058 * - b,f,g,c 00059 * - f,e,h,g 00060 * - e,a,d,h 00061 * - d,c,g,h 00062 * - a,b,f,e 00063 * 00064 * \return OSG vertex array where every four vertices describing a QUAD. 00065 */ 00066 osg::ref_ptr< osg::Vec3Array > generateCuboidQuads( const std::vector< WPosition >& corners ); 00067 00068 /** 00069 * Generates for a QUAD given via 3 three points ( the fourth is not needed ) the 00070 * normal. 00071 * 00072 *\param a First point of the QUAD 00073 *\param b Second point of the QUAD 00074 *\param c Third point of the QUAD 00075 * 00076 *\return OSG Vector of the normal of the QUAD 00077 */ 00078 osg::Vec3 getQuadNormal( const WPosition& a, const WPosition& b, const WPosition& c ); 00079 00080 /** 00081 * Generates for all QUADS of the Cuboid the normals in the following order: 00082 * 00083 * \verbatim 00084 z-axis y-axis 00085 | / 00086 | h___/_g 00087 |/: /| 00088 d_:___c | 00089 | :...|.| 00090 |.e | f 00091 |_____|/ ____x-axis 00092 a b 00093 \endverbatim 00094 * 00095 * - a,b,c,d 00096 * - b,f,g,c 00097 * - f,e,h,g 00098 * - e,a,d,h 00099 * - d,c,g,h 00100 * - a,b,f,e 00101 * 00102 *\param corners Corner points of the cuboid. 00103 * 00104 *\return Array of normals in the order as shown above. 00105 */ 00106 osg::ref_ptr< osg::Vec3Array > generateCuboidQuadNormals( const std::vector< WPosition >& corners ); 00107 00108 /** 00109 * Calculate the Delaunay Triangulation of the given points. 00110 * 00111 * If the parameter transformationFactor is not zero, the points will be 00112 * transformed to calcule the triangles to get a better triangulation, but 00113 * the returned mesh will consist of the original points. 00114 * Every point which lies above the centroid of all points will be put away 00115 * from this centroid by transformationFactor * height above the centroid. 00116 * Any point below the centroid will be drawn to the centroid because its 00117 * height is negative. This effect is inverted with a negative 00118 * transformationFactor. 00119 * This transformation is used to calculate the head surface between several 00120 * electrodes, were a transformationFactor of -0.005 is reasonable. 00121 * 00122 * \param points vector of the points to triangulate 00123 * \param transformationFactor magnitude of the transformation before the 00124 * triangulation 00125 * \return triangulation as WTriangleMesh 00126 */ 00127 WTriangleMesh::SPtr triangulate( const std::vector< WPosition >& points, double transformationFactor = 0.0 ); 00128 } 00129 00130 #endif // WGEGEOMETRYUTILS_H