vhacdICHull.h
Go to the documentation of this file.
1 /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
2  All rights reserved.
3 
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 
7  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 
9  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 
11  3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  */
15 #pragma once
16 #ifndef VHACD_ICHULL_H
17 #define VHACD_ICHULL_H
18 #include "vhacdManifoldMesh.h"
19 #include "vhacdVector.h"
20 
21 namespace VHACD {
29 };
30 class ICHull {
31 public:
32  static const double sc_eps;
34  bool IsFlat() { return m_isFlat; }
36  TMMesh& GetMesh() { return m_mesh; }
38  bool AddPoint(const Vec3<double>& point) { return AddPoints(&point, 1); }
40  bool AddPoint(const Vec3<double>& point, int32_t id);
42  bool AddPoints(const Vec3<double>* points, size_t nPoints);
46  ICHullError Process(const uint32_t nPointsCH, const double minVolume = 0.0);
48  bool IsInside(const Vec3<double>& pt0, const double eps = 0.0);
50  const ICHull& operator=(ICHull& rhs);
51 
53  ICHull();
55  ~ICHull(void){};
56 
57 private:
59  ICHullError DoubleTriangle();
68  bool ProcessPoint();
70  bool ComputePointVolume(double& totalVolume, bool markVisibleFaces);
72  bool FindMaxVolumePoint(const double minVolume = 0.0);
74  bool CleanEdges();
76  bool CleanVertices(uint32_t& addedPoints);
78  bool CleanTriangles();
80  bool CleanUp(uint32_t& addedPoints);
82  bool MakeCCW(CircularListElement<TMMTriangle>* f,
85  void Clear();
86 
87 private:
88  static const int32_t sc_dummyIndex;
89  TMMesh m_mesh;
90  SArray<CircularListElement<TMMEdge>*> m_edgesToDelete;
91  SArray<CircularListElement<TMMEdge>*> m_edgesToUpdate;
92  SArray<CircularListElement<TMMTriangle>*> m_trianglesToDelete;
93  Vec3<double> m_normal;
94  bool m_isFlat;
95  ICHull(const ICHull& rhs);
96 };
97 }
98 #endif // VHACD_ICHULL_H
bool IsFlat()
Definition: vhacdICHull.h:34
ICHullError
Incremental Convex Hull algorithm (cf. http://cs.smith.edu/~orourke/books/ftp.html )...
Definition: vhacdICHull.h:23
Definition: vhacdICHull.h:25
triangular manifold mesh data structure.
Definition: vhacdManifoldMesh.h:87
Definition: vhacdICHull.h:24
bool AddPoint(const Vec3< double > &point)
Add one point to the convex-hull.
Definition: vhacdICHull.h:38
SArray.
Definition: vhacdSArray.h:27
CircularListElement class.
Definition: vhacdCircularList.h:22
const ICHull & operator=(ICHull &rhs)
Definition: vhacdICHull.h:28
Definition: vhacdCircularList.h:19
Definition: vhacdICHull.h:27
~ICHull(void)
Destructor.
Definition: vhacdICHull.h:55
ICHull()
Constructor.
TMMesh & GetMesh()
Returns the computed mesh.
Definition: vhacdICHull.h:36
Definition: vhacdICHull.h:26
bool IsInside(const Vec3< double > &pt0, const double eps=0.0)
ICHullError Process()
Definition: vhacdICHull.h:30
bool AddPoints(const Vec3< double > *points, size_t nPoints)
Add points to the convex-hull.
static const double sc_eps
Definition: vhacdICHull.h:32