Skip to content

Commit

Permalink
#142 Bugfixes and refactoring
Browse files Browse the repository at this point in the history
- Fix multiple hanging edges, add regression tests
- Fix zeroes in `overlapCount`, fix tests
- Refactor splitting edge
  • Loading branch information
artem-ogre committed Oct 4, 2023
1 parent 200021b commit 1dfe29d
Show file tree
Hide file tree
Showing 89 changed files with 1,550 additions and 154 deletions.
3 changes: 3 additions & 0 deletions CDT/include/CDTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ CDT_EXPORT T distance(const V2d<T>& a, const V2d<T>& b);
template <typename T>
CDT_EXPORT T distanceSquared(const V2d<T>& a, const V2d<T>& b);

/// Check if any of triangle's vertices belongs to a super-triangle
CDT_EXPORT bool touchesSuperTriangle(const Triangle& t);

} // namespace CDT

#ifndef CDT_USE_AS_COMPILED_LIBRARY
Expand Down
5 changes: 5 additions & 0 deletions CDT/include/CDTUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,9 @@ T distanceSquared(const V2d<T>& a, const V2d<T>& b)
return distanceSquared(a.x, a.y, b.x, b.y);
}

bool touchesSuperTriangle(const Triangle& t)
{
return t.vertices[0] < 3 || t.vertices[1] < 3 || t.vertices[2] < 3;
}

} // namespace CDT
34 changes: 33 additions & 1 deletion CDT/include/Triangulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,40 @@ class CDT_EXPORT Triangulation
*/
void finalizeTriangulation(const TriIndUSet& removedTriangles);
TriIndUSet growToBoundary(std::stack<TriInd> seeds) const;
void fixEdge(const Edge& edge, BoundaryOverlapCount overlaps);
void fixEdge(const Edge& edge);
void fixEdge(const Edge& edge, const Edge& originalEdge);
/**
* Split existing constraint (fixed) edge
* @param edge fixed edge to split
* @param iSplitVert index of the vertex to be used as a split vertex
*/
void splitFixedEdge(const Edge& edge, const VertInd iSplitVert);
/**
* Add a vertex that splits an edge into the triangulation
* @param splitVert position of split vertex
* @param iT index of a first triangle adjacent to the split edge
* @param iTopo index of a second triangle adjacent to the split edge
* (opposed to the first triangle)
* @return index of a newly added split vertex
*/
VertInd addSplitEdgeVertex(
const V2d<T>& splitVert,
const TriInd iT,
const TriInd iTopo);
/**
* Split fixed edge and add a split vertex into the triangulation
* @param edge fixed edge to split
* @param splitVert position of split vertex
* @param iT index of a first triangle adjacent to the split edge
* @param iTopo index of a second triangle adjacent to the split edge
* (opposed to the first triangle)
* @return index of a newly added split vertex
*/
VertInd splitFixedEdgeAt(
const Edge& edge,
const V2d<T>& splitVert,
const TriInd iT,
const TriInd iTopo);
/**
* Flag triangle as dummy
* @note Advanced method for manually modifying the triangulation from
Expand Down Expand Up @@ -551,6 +582,7 @@ class CDT_EXPORT Triangulation
VertInd superGeomVertCount,
V2d<T> boxMin,
V2d<T> boxMax);
std::pair<TriInd, TriInd> edgeTriangles(VertInd a, VertInd b) const;
bool hasEdge(VertInd a, VertInd b) const;
void setAdjacentTriangle(const VertInd v, const TriInd t);
void pivotVertexTriangleCW(VertInd v);
Expand Down
Loading

0 comments on commit 1dfe29d

Please sign in to comment.