Main Page Class List Class Members

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 {
23 enum ICHullError {
24 ICHullErrorOK = 0,
25 ICHullErrorCoplanarPoints,
26 ICHullErrorNoVolume,
27 ICHullErrorInconsistent,
28 ICHullErrorNotEnoughPoints
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);
44 ICHullError Process();
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();
61 CircularListElement<TMMTriangle>* MakeFace(CircularListElement<TMMVertex>* v0,
62 CircularListElement<TMMVertex>* v1,
63 CircularListElement<TMMVertex>* v2,
64 CircularListElement<TMMTriangle>* fold);
66 CircularListElement<TMMTriangle>* MakeConeFace(CircularListElement<TMMEdge>* e, CircularListElement<TMMVertex>* v);
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,
83 CircularListElement<TMMEdge>* e,
84 CircularListElement<TMMVertex>* v);
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
VHACD::ICHull::IsFlat
bool IsFlat()
Definition: vhacdICHull.h:34
VHACD::ICHullError
ICHullError
Incremental Convex Hull algorithm (cf. http://cs.smith.edu/~orourke/books/ftp.html )...
Definition: vhacdICHull.h:23
VHACD::ICHullErrorCoplanarPoints
Definition: vhacdICHull.h:25
VHACD::TMMesh
triangular manifold mesh data structure.
Definition: vhacdManifoldMesh.h:87
VHACD::ICHullErrorOK
Definition: vhacdICHull.h:24
VHACD::ICHull::AddPoint
bool AddPoint(const Vec3< double > &point)
Add one point to the convex-hull.
Definition: vhacdICHull.h:38
VHACD::SArray
SArray.
Definition: vhacdSArray.h:27
VHACD::CircularListElement
CircularListElement class.
Definition: vhacdCircularList.h:22
VHACD::ICHull::operator=
const ICHull & operator=(ICHull &rhs)
VHACD::ICHullErrorNotEnoughPoints
Definition: vhacdICHull.h:28
vhacdManifoldMesh.h
VHACD
Definition: vhacdCircularList.h:19
VHACD::ICHullErrorInconsistent
Definition: vhacdICHull.h:27
VHACD::ICHull::~ICHull
~ICHull(void)
Destructor.
Definition: vhacdICHull.h:55
VHACD::ICHull::ICHull
ICHull()
Constructor.
VHACD::ICHull::GetMesh
TMMesh & GetMesh()
Returns the computed mesh.
Definition: vhacdICHull.h:36
VHACD::ICHullErrorNoVolume
Definition: vhacdICHull.h:26
VHACD::ICHull::IsInside
bool IsInside(const Vec3< double > &pt0, const double eps=0.0)
VHACD::ICHull::Process
ICHullError Process()
VHACD::ICHull
Definition: vhacdICHull.h:30
VHACD::Vec3< double >
VHACD::ICHull::AddPoints
bool AddPoints(const Vec3< double > *points, size_t nPoints)
Add points to the convex-hull.
vhacdVector.h
VHACD::ICHull::sc_eps
static const double sc_eps
Definition: vhacdICHull.h:32