GteVEManifoldMesh.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <GTEngineDEF.h>
11 #include <map>
12 #include <memory>
13 
14 namespace gte
15 {
16 
18 {
19 public:
20  // Vertex data types.
21  class Vertex;
22  typedef std::shared_ptr<Vertex> (*VCreator)(int);
23  typedef std::map<int, std::shared_ptr<Vertex>> VMap;
24 
25  // Edge data types.
26  class Edge;
27  typedef std::shared_ptr<Edge> (*ECreator)(int, int);
28  typedef std::map<std::pair<int, int>, std::shared_ptr<Edge>> EMap;
29 
30  // Vertex object.
32  {
33  public:
34  virtual ~Vertex();
35  Vertex(int v);
36 
37  // The unique vertex index.
38  int V;
39 
40  // The edges (if any) sharing the vertex.
41  std::weak_ptr<Edge> E[2];
42  };
43 
44  // Edge object.
46  {
47  public:
48  virtual ~Edge();
49  Edge(int v0, int v1);
50 
51  // Vertices, listed as a directed edge <V[0],V[1]>.
52  int V[2];
53 
54  // Adjacent edges. E[i] points to edge sharing V[i].
55  std::weak_ptr<Edge> E[2];
56  };
57 
58 
59  // Construction and destruction.
60  virtual ~VEManifoldMesh();
61  VEManifoldMesh(VCreator vCreator = nullptr, ECreator eCreator = nullptr);
62 
63  // Member access.
64  VMap const& GetVertices() const;
65  EMap const& GetEdges() const;
66 
67  // If the insertion of an edge fails because the mesh would become
68  // nonmanifold, the default behavior is to trigger a LogError message.
69  // You can disable this behavior in situations where you want the Logger
70  // system on but you want to continue gracefully without an assertion.
71  void AssertOnNonmanifoldInsertion(bool doAssert);
72 
73  // If <v0,v1> is not in the mesh, an Edge object is created and returned;
74  // otherwise, <v0,v1> is in the mesh and nullptr is returned. If the
75  // insertion leads to a nonmanifold mesh, the call fails with a nullptr
76  // returned.
77  std::shared_ptr<Edge> Insert(int v0, int v1);
78 
79  // If <v0,v1> is in the mesh, it is removed and 'true' is returned;
80  // otherwise, <v0,v1> is not in the mesh and 'false' is returned.
81  bool Remove(int v0, int v1);
82 
83  // A manifold mesh is closed if each vertex is shared twice.
84  bool IsClosed() const;
85 
86 protected:
87  // The vertex data and default vertex creation.
88  static std::shared_ptr<Vertex> CreateVertex(int v0);
89  VCreator mVCreator;
90  VMap mVMap;
91 
92  // The edge data and default edge creation.
93  static std::shared_ptr<Edge> CreateEdge(int v0, int v1);
94  ECreator mECreator;
95  EMap mEMap;
96  bool mAssertOnNonmanifoldInsertion; // default: true
97 };
98 
99 }
GLfloat GLfloat v1
Definition: glcorearb.h:812
std::map< int, std::shared_ptr< Vertex > > VMap
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
GLfloat v0
Definition: glcorearb.h:811
std::map< std::pair< int, int >, std::shared_ptr< Edge > > EMap
const GLdouble * v
Definition: glcorearb.h:832
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:02