vhacdManifoldMesh.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_MANIFOLD_MESH_H
17 #define VHACD_MANIFOLD_MESH_H
18 #include "vhacdCircularList.h"
19 #include "vhacdSArray.h"
20 #include "vhacdVector.h"
21 namespace VHACD {
22 class TMMTriangle;
23 class TMMEdge;
24 class TMMesh;
25 class ICHull;
26 
28 class TMMVertex {
29 public:
30  void Initialize();
31  TMMVertex(void);
32  ~TMMVertex(void);
33 
34 private:
35  Vec3<double> m_pos;
36  int32_t m_name;
37  size_t m_id;
38  CircularListElement<TMMEdge>* m_duplicate; // pointer to incident cone edge (or NULL)
39  bool m_onHull;
40  bool m_tag;
41  TMMVertex(const TMMVertex& rhs);
42  friend class ICHull;
43  friend class TMMesh;
44  friend class TMMTriangle;
45  friend class TMMEdge;
46 };
47 
49 class TMMEdge {
50 public:
51  void Initialize();
52  TMMEdge(void);
53  ~TMMEdge(void);
54 
55 private:
56  size_t m_id;
57  CircularListElement<TMMTriangle>* m_triangles[2];
58  CircularListElement<TMMVertex>* m_vertices[2];
60  TMMEdge(const TMMEdge& rhs);
61  friend class ICHull;
62  friend class TMMTriangle;
63  friend class TMMVertex;
64  friend class TMMesh;
65 };
66 
68 class TMMTriangle {
69 public:
70  void Initialize();
71  TMMTriangle(void);
72  ~TMMTriangle(void);
73 
74 private:
75  size_t m_id;
76  CircularListElement<TMMEdge>* m_edges[3];
77  CircularListElement<TMMVertex>* m_vertices[3];
78  bool m_visible;
79 
80  TMMTriangle(const TMMTriangle& rhs);
81  friend class ICHull;
82  friend class TMMesh;
83  friend class TMMVertex;
84  friend class TMMEdge;
85 };
87 class TMMesh {
88 public:
90  inline size_t GetNVertices() const { return m_vertices.GetSize(); }
92  inline size_t GetNEdges() const { return m_edges.GetSize(); }
94  inline size_t GetNTriangles() const { return m_triangles.GetSize(); }
96  inline const CircularList<TMMVertex>& GetVertices() const { return m_vertices; }
98  inline const CircularList<TMMEdge>& GetEdges() const { return m_edges; }
100  inline const CircularList<TMMTriangle>& GetTriangles() const { return m_triangles; }
102  inline CircularList<TMMVertex>& GetVertices() { return m_vertices; }
104  inline CircularList<TMMEdge>& GetEdges() { return m_edges; }
106  inline CircularList<TMMTriangle>& GetTriangles() { return m_triangles; }
108  CircularListElement<TMMVertex>* AddVertex() { return m_vertices.Add(); }
110  CircularListElement<TMMEdge>* AddEdge() { return m_edges.Add(); }
112  CircularListElement<TMMTriangle>* AddTriangle() { return m_triangles.Add(); }
114  void Print();
116  void GetIFS(Vec3<double>* const points, Vec3<int32_t>* const triangles);
118  void Clear();
120  void Copy(TMMesh& mesh);
122  bool CheckConsistancy();
124  bool Normalize();
126  bool Denormalize();
128  TMMesh();
130  virtual ~TMMesh(void);
131 
132 private:
133  CircularList<TMMVertex> m_vertices;
134  CircularList<TMMEdge> m_edges;
135  CircularList<TMMTriangle> m_triangles;
136 
137  // not defined
138  TMMesh(const TMMesh& rhs);
139  friend class ICHull;
140 };
141 }
142 #endif // VHACD_MANIFOLD_MESH_H
friend class TMMTriangle
Definition: vhacdManifoldMesh.h:44
Triangle data structure used in a triangular manifold mesh (TMM).
Definition: vhacdManifoldMesh.h:68
triangular manifold mesh data structure.
Definition: vhacdManifoldMesh.h:87
Edge data structure used in a triangular manifold mesh (TMM).
Definition: vhacdManifoldMesh.h:49
const CircularList< TMMVertex > & GetVertices() const
Returns the vertices circular list.
Definition: vhacdManifoldMesh.h:96
size_t GetNTriangles() const
Returns the number of triangles.
Definition: vhacdManifoldMesh.h:94
CircularListElement class.
Definition: vhacdCircularList.h:22
Vertex data structure used in a triangular manifold mesh (TMM).
Definition: vhacdManifoldMesh.h:28
CircularListElement< TMMVertex > * AddVertex()
Add vertex to the mesh.
Definition: vhacdManifoldMesh.h:108
const CircularList< TMMEdge > & GetEdges() const
Returns the edges circular list.
Definition: vhacdManifoldMesh.h:98
Definition: vhacdCircularList.h:19
CircularListElement< TMMEdge > * AddEdge()
Add vertex to the mesh.
Definition: vhacdManifoldMesh.h:110
friend class TMMesh
Definition: vhacdManifoldMesh.h:43
CircularListElement< TMMTriangle > * AddTriangle()
Add vertex to the mesh.
Definition: vhacdManifoldMesh.h:112
CircularList< TMMTriangle > & GetTriangles()
Returns the triangles circular list.
Definition: vhacdManifoldMesh.h:106
friend class TMMEdge
Definition: vhacdManifoldMesh.h:45
Definition: vhacdICHull.h:30
size_t GetNEdges() const
Returns the number of edges.
Definition: vhacdManifoldMesh.h:92
CircularList< TMMEdge > & GetEdges()
Returns the edges circular list.
Definition: vhacdManifoldMesh.h:104
const CircularList< TMMTriangle > & GetTriangles() const
Returns the triangles circular list.
Definition: vhacdManifoldMesh.h:100
CircularList< TMMVertex > & GetVertices()
Returns the vertices circular list.
Definition: vhacdManifoldMesh.h:102
CircularList class.
Definition: vhacdCircularList.h:44
size_t GetNVertices() const
Returns the number of vertices>
Definition: vhacdManifoldMesh.h:90