btConvexHullComputer.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2011 Ole Kniemeyer, MAXON, www.maxon.net
00003 
00004 This software is provided 'as-is', without any express or implied warranty.
00005 In no event will the authors be held liable for any damages arising from the use of this software.
00006 Permission is granted to anyone to use this software for any purpose, 
00007 including commercial applications, and to alter it and redistribute it freely, 
00008 subject to the following restrictions:
00009 
00010 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00011 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00012 3. This notice may not be removed or altered from any source distribution.
00013 */
00014 
00015 #ifndef BT_CONVEX_HULL_COMPUTER_H
00016 #define BT_CONVEX_HULL_COMPUTER_H
00017 
00018 #include "btVector3.h"
00019 #include "btAlignedObjectArray.h"
00020 
00024 class btConvexHullComputer
00025 {
00026         private:
00027                 btScalar compute(const void* coords, bool doubleCoords, int stride, int count, btScalar shrink, btScalar shrinkClamp);
00028 
00029         public:
00030 
00031                 class Edge
00032                 {
00033                         private:
00034                                 int next;
00035                                 int reverse;
00036                                 int targetVertex;
00037 
00038                                 friend class btConvexHullComputer;
00039 
00040                         public:
00041                                 int getSourceVertex() const
00042                                 {
00043                                         return (this + reverse)->targetVertex;
00044                                 }
00045 
00046                                 int getTargetVertex() const
00047                                 {
00048                                         return targetVertex;
00049                                 }
00050 
00051                                 const Edge* getNextEdgeOfVertex() const // clockwise list of all edges of a vertex
00052                                 {
00053                                         return this + next;
00054                                 }
00055 
00056                                 const Edge* getNextEdgeOfFace() const // counter-clockwise list of all edges of a face
00057                                 {
00058                                         return (this + reverse)->getNextEdgeOfVertex();
00059                                 }
00060 
00061                                 const Edge* getReverseEdge() const
00062                                 {
00063                                         return this + reverse;
00064                                 }
00065                 };
00066 
00067 
00068                 // Vertices of the output hull
00069                 btAlignedObjectArray<btVector3> vertices;
00070 
00071                 // Edges of the output hull
00072                 btAlignedObjectArray<Edge> edges;
00073 
00074                 // Faces of the convex hull. Each entry is an index into the "edges" array pointing to an edge of the face. Faces are planar n-gons
00075                 btAlignedObjectArray<int> faces;
00076 
00077                 /*
00078                 Compute convex hull of "count" vertices stored in "coords". "stride" is the difference in bytes
00079                 between the addresses of consecutive vertices. If "shrink" is positive, the convex hull is shrunken
00080                 by that amount (each face is moved by "shrink" length units towards the center along its normal).
00081                 If "shrinkClamp" is positive, "shrink" is clamped to not exceed "shrinkClamp * innerRadius", where "innerRadius"
00082                 is the minimum distance of a face to the center of the convex hull.
00083 
00084                 The returned value is the amount by which the hull has been shrunken. If it is negative, the amount was so large
00085                 that the resulting convex hull is empty.
00086 
00087                 The output convex hull can be found in the member variables "vertices", "edges", "faces".
00088                 */
00089                 btScalar compute(const float* coords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
00090                 {
00091                         return compute(coords, false, stride, count, shrink, shrinkClamp);
00092                 }
00093 
00094                 // same as above, but double precision
00095                 btScalar compute(const double* coords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
00096                 {
00097                         return compute(coords, true, stride, count, shrink, shrinkClamp);
00098                 }
00099 };
00100 
00101 
00102 #endif //BT_CONVEX_HULL_COMPUTER_H
00103 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


bullet
Author(s): Erwin Coumans, ROS package maintained by Tully Foote
autogenerated on Wed Oct 31 2012 07:54:31