mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-05 22:09:52 +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:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install dependencies
|
- 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
|
- name: Build with GCC
|
||||||
run: |
|
run: |
|
||||||
|
@ -352,12 +352,18 @@ void Triangle::SetDelunayEdgeCW(const Point& p, bool e)
|
|||||||
// The neighbor across to given point
|
// The neighbor across to given point
|
||||||
Triangle& Triangle::NeighborAcross(const Point& opoint)
|
Triangle& Triangle::NeighborAcross(const Point& opoint)
|
||||||
{
|
{
|
||||||
|
Triangle* neighbor = nullptr;
|
||||||
if (&opoint == points_[0]) {
|
if (&opoint == points_[0]) {
|
||||||
return *neighbors_[0];
|
neighbor = neighbors_[0];
|
||||||
} else if (&opoint == points_[1]) {
|
} 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()
|
void Triangle::DebugPrint()
|
||||||
|
@ -54,8 +54,8 @@ void Sweep::SweepPoints(SweepContext& tcx)
|
|||||||
for (size_t i = 1; i < tcx.point_count(); i++) {
|
for (size_t i = 1; i < tcx.point_count(); i++) {
|
||||||
Point& point = *tcx.GetPoint(i);
|
Point& point = *tcx.GetPoint(i);
|
||||||
Node* node = &PointEvent(tcx, point);
|
Node* node = &PointEvent(tcx, point);
|
||||||
for (unsigned int i = 0; i < point.edge_list.size(); i++) {
|
for (unsigned int j = 0; j < point.edge_list.size(); j++) {
|
||||||
EdgeEvent(tcx, point.edge_list[i], node);
|
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);
|
triangle = &triangle->NeighborAcross(point);
|
||||||
EdgeEvent( tcx, ep, *p1, triangle, *p1 );
|
EdgeEvent( tcx, ep, *p1, triangle, *p1 );
|
||||||
} else {
|
} else {
|
||||||
std::runtime_error("EdgeEvent - collinear points not supported");
|
throw std::runtime_error("EdgeEvent - collinear points not supported");
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -140,8 +139,7 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl
|
|||||||
triangle = &triangle->NeighborAcross(point);
|
triangle = &triangle->NeighborAcross(point);
|
||||||
EdgeEvent( tcx, ep, *p2, triangle, *p2 );
|
EdgeEvent( tcx, ep, *p2, triangle, *p2 );
|
||||||
} else {
|
} else {
|
||||||
std::runtime_error("EdgeEvent - collinear points not supported");
|
throw std::runtime_error("EdgeEvent - collinear points not supported");
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
return;
|
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 <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(BasicTest)
|
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)
|
BOOST_AUTO_TEST_CASE(TestbedFilesTest)
|
||||||
{
|
{
|
||||||
for (const auto& filename : { "custom.dat", "diamond.dat", "star.dat", "test.dat" }) {
|
for (const auto& filename : { "custom.dat", "diamond.dat", "star.dat", "test.dat" }) {
|
||||||
|
Loading…
Reference in New Issue
Block a user