mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-30 01:03:30 +01:00
Merge pull request #19 from pierre-dejoue/master
Add one exception case in Triangle::NeighborAcross
This commit is contained in:
commit
a269fb4743
2
.github/workflows/linux.yml
vendored
2
.github/workflows/linux.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install dependencies
|
||||
run: dnf install -yq cmake ninja-build clang-tools-extra python3-PyYAML
|
||||
run: dnf install -yq cmake ninja-build gcc-c++ clang-tools-extra python3-PyYAML
|
||||
|
||||
- name: Build with GCC
|
||||
run: |
|
||||
|
@ -352,12 +352,18 @@ void Triangle::SetDelunayEdgeCW(const Point& p, bool e)
|
||||
// The neighbor across to given point
|
||||
Triangle& Triangle::NeighborAcross(const Point& opoint)
|
||||
{
|
||||
Triangle* neighbor = nullptr;
|
||||
if (&opoint == points_[0]) {
|
||||
return *neighbors_[0];
|
||||
neighbor = neighbors_[0];
|
||||
} else if (&opoint == points_[1]) {
|
||||
return *neighbors_[1];
|
||||
neighbor = neighbors_[1];
|
||||
} else {
|
||||
neighbor = neighbors_[2];
|
||||
}
|
||||
return *neighbors_[2];
|
||||
if (neighbor == nullptr) {
|
||||
throw std::runtime_error("NeighborAcross - null neighbor");
|
||||
}
|
||||
return *neighbor;
|
||||
}
|
||||
|
||||
void Triangle::DebugPrint()
|
||||
|
@ -54,8 +54,8 @@ void Sweep::SweepPoints(SweepContext& tcx)
|
||||
for (size_t i = 1; i < tcx.point_count(); i++) {
|
||||
Point& point = *tcx.GetPoint(i);
|
||||
Node* node = &PointEvent(tcx, point);
|
||||
for (unsigned int i = 0; i < point.edge_list.size(); i++) {
|
||||
EdgeEvent(tcx, point.edge_list[i], node);
|
||||
for (unsigned int j = 0; j < point.edge_list.size(); j++) {
|
||||
EdgeEvent(tcx, point.edge_list[j], node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,8 +123,7 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl
|
||||
triangle = &triangle->NeighborAcross(point);
|
||||
EdgeEvent( tcx, ep, *p1, triangle, *p1 );
|
||||
} else {
|
||||
std::runtime_error("EdgeEvent - collinear points not supported");
|
||||
assert(0);
|
||||
throw std::runtime_error("EdgeEvent - collinear points not supported");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -140,8 +139,7 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl
|
||||
triangle = &triangle->NeighborAcross(point);
|
||||
EdgeEvent( tcx, ep, *p2, triangle, *p2 );
|
||||
} else {
|
||||
std::runtime_error("EdgeEvent - collinear points not supported");
|
||||
assert(0);
|
||||
throw std::runtime_error("EdgeEvent - collinear points not supported");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
4
testbed/data/deadly_quad.dat
Normal file
4
testbed/data/deadly_quad.dat
Normal file
@ -0,0 +1,4 @@
|
||||
0.0 0.0
|
||||
1.0e-05 0.0
|
||||
1.1e-04 3.0e-07
|
||||
1.0e-04 3.0e-07
|
@ -5,6 +5,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(BasicTest)
|
||||
{
|
||||
@ -40,6 +41,22 @@ BOOST_AUTO_TEST_CASE(QuadTest)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(QuadTestThrow)
|
||||
{
|
||||
// Very narrow quad that demonstrates a failure case during triangulation
|
||||
std::vector<p2t::Point*> polyline {
|
||||
new p2t::Point(0.0, 0.0),
|
||||
new p2t::Point(1.0e-05, 0.0),
|
||||
new p2t::Point(1.1e-04, 3.0e-07),
|
||||
new p2t::Point(1.0e-04, 3.0e-07)
|
||||
};
|
||||
p2t::CDT cdt{ polyline };
|
||||
BOOST_CHECK_THROW(cdt.Triangulate(), std::runtime_error);
|
||||
for (const auto p : polyline) {
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestbedFilesTest)
|
||||
{
|
||||
for (const auto& filename : { "custom.dat", "diamond.dat", "star.dat", "test.dat" }) {
|
||||
|
Loading…
Reference in New Issue
Block a user