50 for (
int i = 0; i < 3; ++i)
52 int vIndex = tri->V[i];
53 auto vItem =
mVMap.find(vIndex);
54 std::shared_ptr<Vertex> vertex;
55 if (vItem ==
mVMap.end())
58 mVMap[vIndex] = vertex;
62 vertex = vItem->second;
65 vertex->TAdjacent.insert(tri);
67 for (
int j = 0; j < 3; ++j)
69 auto edge = tri->E[j].lock();
72 if (edge->V[0] == vIndex)
74 vertex->VAdjacent.insert(edge->V[1]);
75 vertex->EAdjacent.insert(edge);
77 else if (edge->V[1] == vIndex)
79 vertex->VAdjacent.insert(edge->V[0]);
80 vertex->EAdjacent.insert(edge);
85 LogError(
"Malformed mesh: Triangle edges must not be null.");
97 if (tItem ==
mTMap.end())
102 std::shared_ptr<Triangle> tri = tItem->second;
103 for (
int i = 0; i < 3; ++i)
105 int vIndex = tri->V[i];
106 auto vItem =
mVMap.find(vIndex);
107 if (vItem !=
mVMap.end())
109 std::shared_ptr<Vertex> vertex = vItem->second;
110 for (
int j = 0; j < 3; ++j)
112 auto edge = tri->E[j].lock();
115 if (edge->T[0].lock() && !edge->T[1].lock())
117 if (edge->V[0] == vIndex)
119 vertex->VAdjacent.erase(edge->V[1]);
120 vertex->EAdjacent.erase(edge);
122 else if (edge->V[1] == vIndex)
124 vertex->VAdjacent.erase(edge->V[0]);
125 vertex->EAdjacent.erase(edge);
131 LogError(
"Malformed mesh: Triangle edges must not be null.");
136 vertex->TAdjacent.erase(tri);
138 if (vertex->TAdjacent.size() == 0)
140 LogAssert(vertex->VAdjacent.size() == 0 && vertex->EAdjacent.size() == 0,
141 "Malformed mesh: Inconsistent vertex adjacency information.");
148 LogError(
"Malformed mesh: Vertex must exist in the mesh.");
164 return std::make_shared<Vertex>(vIndex);
std::shared_ptr< Triangle >(* TCreator)(int, int, int)
virtual void Clear() override
#define LogAssert(condition, message)
ETManifoldMesh & operator=(ETManifoldMesh const &mesh)
VETManifoldMesh & operator=(VETManifoldMesh const &mesh)
static std::shared_ptr< Vertex > CreateVertex(int vIndex)
#define LogError(message)
std::shared_ptr< Edge >(* ECreator)(int, int)
virtual std::shared_ptr< Triangle > Insert(int v0, int v1, int v2)
virtual bool Remove(int v0, int v1, int v2) override
virtual ~VETManifoldMesh()
virtual bool Remove(int v0, int v1, int v2)
GLfloat GLfloat GLfloat v2
VETManifoldMesh(VCreator vCreator=nullptr, ECreator eCreator=nullptr, TCreator tCreator=nullptr)
std::map< int, std::shared_ptr< Vertex > > VMap
std::shared_ptr< Vertex >(* VCreator)(int)
virtual std::shared_ptr< Triangle > Insert(int v0, int v1, int v2) override
VMap const & GetVertices() const