Blender  V3.3
btConvexHullComputer.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2011 Ole Kniemeyer, MAXON, www.maxon.net
3 
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose,
7 including commercial applications, and to alter it and redistribute it freely,
8 subject to the following restrictions:
9 
10 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.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
13 */
14 
15 #ifndef BT_CONVEX_HULL_COMPUTER_H
16 #define BT_CONVEX_HULL_COMPUTER_H
17 
18 #include "btVector3.h"
19 #include "btAlignedObjectArray.h"
20 
25 {
26 private:
27  btScalar compute(const void* coords, bool doubleCoords, int stride, int count, btScalar shrink, btScalar shrinkClamp);
28 
29 public:
30  class Edge
31  {
32  private:
33  int next;
34  int reverse;
35  int targetVertex;
36 
37  friend class btConvexHullComputer;
38 
39  public:
40  int getSourceVertex() const
41  {
42  return (this + reverse)->targetVertex;
43  }
44 
45  int getTargetVertex() const
46  {
47  return targetVertex;
48  }
49 
50  const Edge* getNextEdgeOfVertex() const // clockwise list of all edges of a vertex
51  {
52  return this + next;
53  }
54 
55  const Edge* getNextEdgeOfFace() const // counter-clockwise list of all edges of a face
56  {
57  return (this + reverse)->getNextEdgeOfVertex();
58  }
59 
60  const Edge* getReverseEdge() const
61  {
62  return this + reverse;
63  }
64  };
65 
66  // Vertices of the output hull
68 
69  // The original vertex index in the input coords array
71 
72  // Edges of the output hull
74 
75  // 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
77 
78  /*
79  Compute convex hull of "count" vertices stored in "coords". "stride" is the difference in bytes
80  between the addresses of consecutive vertices. If "shrink" is positive, the convex hull is shrunken
81  by that amount (each face is moved by "shrink" length units towards the center along its normal).
82  If "shrinkClamp" is positive, "shrink" is clamped to not exceed "shrinkClamp * innerRadius", where "innerRadius"
83  is the minimum distance of a face to the center of the convex hull.
84 
85  The returned value is the amount by which the hull has been shrunken. If it is negative, the amount was so large
86  that the resulting convex hull is empty.
87 
88  The output convex hull can be found in the member variables "vertices", "edges", "faces".
89  */
90  btScalar compute(const float* coords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
91  {
92  return compute(coords, false, stride, count, shrink, shrinkClamp);
93  }
94 
95  // same as above, but double precision
96  btScalar compute(const double* coords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
97  {
98  return compute(coords, true, stride, count, shrink, shrinkClamp);
99  }
100 };
101 
102 #endif //BT_CONVEX_HULL_COMPUTER_H
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
const Edge * getNextEdgeOfFace() const
const Edge * getReverseEdge() const
const Edge * getNextEdgeOfVertex() const
btAlignedObjectArray< btVector3 > vertices
btAlignedObjectArray< int > original_vertex_index
btScalar compute(const double *coords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
btAlignedObjectArray< int > faces
btScalar compute(const float *coords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
btAlignedObjectArray< Edge > edges
int count
static ulong * next