mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-05 22:09:52 +01:00
Additional sanity checks for triangulate operation
This commit is contained in:
parent
4a323bf6d5
commit
905a765c0f
@ -77,7 +77,13 @@ void Sweep::FinalizationPolygon(SweepContext& tcx)
|
|||||||
|
|
||||||
Node& Sweep::PointEvent(SweepContext& tcx, Point& point)
|
Node& Sweep::PointEvent(SweepContext& tcx, Point& point)
|
||||||
{
|
{
|
||||||
Node& node = tcx.LocateNode(point);
|
Node* node_ptr = tcx.LocateNode(point);
|
||||||
|
if (!node_ptr || !node_ptr->point || !node_ptr->next || !node_ptr->next->point)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("PointEvent - null node");
|
||||||
|
}
|
||||||
|
|
||||||
|
Node& node = *node_ptr;
|
||||||
Node& new_node = NewFrontTriangle(tcx, point, node);
|
Node& new_node = NewFrontTriangle(tcx, point, node);
|
||||||
|
|
||||||
// Only need to check +epsilon since point never have smaller
|
// Only need to check +epsilon since point never have smaller
|
||||||
@ -775,10 +781,22 @@ void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle&
|
|||||||
if (ot_ptr == nullptr) {
|
if (ot_ptr == nullptr) {
|
||||||
throw std::runtime_error("FlipScanEdgeEvent - null neighbor across");
|
throw std::runtime_error("FlipScanEdgeEvent - null neighbor across");
|
||||||
}
|
}
|
||||||
Triangle& ot = *ot_ptr;
|
|
||||||
Point& op = *ot.OppositePoint(t, p);
|
|
||||||
|
|
||||||
if (InScanArea(eq, *flip_triangle.PointCCW(eq), *flip_triangle.PointCW(eq), op)) {
|
Point* op_ptr = ot_ptr->OppositePoint(t, p);
|
||||||
|
if (op_ptr == nullptr) {
|
||||||
|
throw std::runtime_error("FlipScanEdgeEvent - null opposing point");
|
||||||
|
}
|
||||||
|
|
||||||
|
Point* p1 = flip_triangle.PointCCW(eq);
|
||||||
|
Point* p2 = flip_triangle.PointCW(eq);
|
||||||
|
if (p1 == nullptr || p2 == nullptr) {
|
||||||
|
throw std::runtime_error("FlipScanEdgeEvent - null on either of points");
|
||||||
|
}
|
||||||
|
|
||||||
|
Triangle& ot = *ot_ptr;
|
||||||
|
Point& op = *op_ptr;
|
||||||
|
|
||||||
|
if (InScanArea(eq, *p1, *p2, op)) {
|
||||||
// flip with new edge op->eq
|
// flip with new edge op->eq
|
||||||
FlipEdgeEvent(tcx, eq, op, &ot, op);
|
FlipEdgeEvent(tcx, eq, op, &ot, op);
|
||||||
// TODO: Actually I just figured out that it should be possible to
|
// TODO: Actually I just figured out that it should be possible to
|
||||||
|
@ -114,10 +114,10 @@ void SweepContext::AddToMap(Triangle* triangle)
|
|||||||
map_.push_back(triangle);
|
map_.push_back(triangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node& SweepContext::LocateNode(const Point& point)
|
Node* SweepContext::LocateNode(const Point& point)
|
||||||
{
|
{
|
||||||
// TODO implement search tree
|
// TODO implement search tree
|
||||||
return *front_->LocateNode(point.x);
|
return front_->LocateNode(point.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SweepContext::CreateAdvancingFront()
|
void SweepContext::CreateAdvancingFront()
|
||||||
|
@ -66,7 +66,7 @@ Point* tail() const;
|
|||||||
|
|
||||||
size_t point_count() const;
|
size_t point_count() const;
|
||||||
|
|
||||||
Node& LocateNode(const Point& point);
|
Node* LocateNode(const Point& point);
|
||||||
|
|
||||||
void RemoveNode(Node* node);
|
void RemoveNode(Node* node);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user