Some refactoring

This commit is contained in:
Matthias Koefferlein 2023-08-16 22:21:49 +02:00
parent 2acedfde6f
commit 5679540c85
3 changed files with 18 additions and 1 deletions

View File

@ -476,6 +476,18 @@ Triangle::find_edge_with (const Vertex *v1, const Vertex *v2) const
tl_assert (false);
}
TriangleEdge *
Triangle::common_edge (const Triangle *other) const
{
for (int i = 0; i < 3; ++i) {
TriangleEdge *e = edge (i);
if (e->other (this) == other) {
return e;
}
}
return 0;
}
int
Triangle::contains (const db::DPoint &point) const
{

View File

@ -476,6 +476,11 @@ public:
*/
TriangleEdge *find_edge_with (const Vertex *v1, const Vertex *v2) const;
/**
* @brief Finds the common edge for both triangles
*/
TriangleEdge *common_edge (const Triangle *other) const;
/**
* @brief Returns a value indicating whether the point is inside (1), on the triangle (0) or outside (-1)
*/

View File

@ -338,7 +338,7 @@ Triangles::insert (db::Vertex *vertex, std::list<tl::weak_ptr<db::Triangle> > *n
return vertex;
}
// the new vertex is on the edge between two triangles
// check, if the new vertex is on an edge (may be edge between triangles or edge on outside)
std::vector<db::TriangleEdge *> on_edges;
for (int i = 0; i < 3; ++i) {
db::TriangleEdge *e = tris.front ()->edge (i);