mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-26 15:26:12 +01:00
delete point event node from memory
This commit is contained in:
parent
2ce7776ec2
commit
fe67bffee8
@ -87,7 +87,7 @@ Node& Sweep::PointEvent(SweepContext& tcx, Point& point)
|
|||||||
// Only need to check +epsilon since point never have smaller
|
// Only need to check +epsilon since point never have smaller
|
||||||
// x value than node due to how we fetch nodes from the front
|
// x value than node due to how we fetch nodes from the front
|
||||||
if (point.x <= node.point->x + EPSILON) {
|
if (point.x <= node.point->x + EPSILON) {
|
||||||
Fill(tcx, node);
|
Fill(tcx, node, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//tcx.AddNode(new_node);
|
//tcx.AddNode(new_node);
|
||||||
@ -187,7 +187,7 @@ Node& Sweep::NewFrontTriangle(SweepContext& tcx, Point& point, Node& node)
|
|||||||
* @param tcx
|
* @param tcx
|
||||||
* @param node - middle node, that is the bottom of the hole
|
* @param node - middle node, that is the bottom of the hole
|
||||||
*/
|
*/
|
||||||
void Sweep::Fill(SweepContext& tcx, Node& node)
|
void Sweep::Fill(SweepContext& tcx, Node& node, bool point_event)
|
||||||
{
|
{
|
||||||
Triangle* triangle = new Triangle(*node.prev->point, *node.point, *node.next->point);
|
Triangle* triangle = new Triangle(*node.prev->point, *node.point, *node.next->point);
|
||||||
|
|
||||||
@ -207,8 +207,10 @@ void Sweep::Fill(SweepContext& tcx, Node& node)
|
|||||||
tcx.MapTriangleToNodes(*triangle);
|
tcx.MapTriangleToNodes(*triangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: delete node from memory
|
if(point_event) {
|
||||||
//tcx.RemoveNode(node);
|
tcx.RemoveNode(&node);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,7 +228,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
|
|||||||
while (node->next) {
|
while (node->next) {
|
||||||
double angle = HoleAngle(*node);
|
double angle = HoleAngle(*node);
|
||||||
if (angle > M_PI_2 || angle < -M_PI_2) break;
|
if (angle > M_PI_2 || angle < -M_PI_2) break;
|
||||||
Fill(tcx, *node);
|
Fill(tcx, *node, false);
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +238,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
|
|||||||
while (node->prev) {
|
while (node->prev) {
|
||||||
double angle = HoleAngle(*node);
|
double angle = HoleAngle(*node);
|
||||||
if (angle > M_PI_2 || angle < -M_PI_2) break;
|
if (angle > M_PI_2 || angle < -M_PI_2) break;
|
||||||
Fill(tcx, *node);
|
Fill(tcx, *node, false);
|
||||||
node = node->prev;
|
node = node->prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +525,7 @@ void Sweep::FillBasinReq(SweepContext& tcx, Node* node)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fill(tcx, *node);
|
Fill(tcx, *node, false);
|
||||||
|
|
||||||
if (node->prev == tcx.basin.left_node && node->next == tcx.basin.right_node) {
|
if (node->prev == tcx.basin.left_node && node->next == tcx.basin.right_node) {
|
||||||
return;
|
return;
|
||||||
@ -606,7 +608,7 @@ void Sweep::FillRightBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
|||||||
|
|
||||||
void Sweep::FillRightConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
void Sweep::FillRightConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
||||||
{
|
{
|
||||||
Fill(tcx, *node.next);
|
Fill(tcx, *node.next, false);
|
||||||
if (node.next->point != edge->p) {
|
if (node.next->point != edge->p) {
|
||||||
// Next above or below edge?
|
// Next above or below edge?
|
||||||
if (Orient2d(*edge->q, *node.next->point, *edge->p) == CCW) {
|
if (Orient2d(*edge->q, *node.next->point, *edge->p) == CCW) {
|
||||||
@ -686,7 +688,7 @@ void Sweep::FillLeftConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
|||||||
|
|
||||||
void Sweep::FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
void Sweep::FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
|
||||||
{
|
{
|
||||||
Fill(tcx, *node.prev);
|
Fill(tcx, *node.prev, false);
|
||||||
if (node.prev->point != edge->p) {
|
if (node.prev->point != edge->p) {
|
||||||
// Next above or below edge?
|
// Next above or below edge?
|
||||||
if (Orient2d(*edge->q, *node.prev->point, *edge->p) == CW) {
|
if (Orient2d(*edge->q, *node.prev->point, *edge->p) == CW) {
|
||||||
|
@ -64,7 +64,7 @@ void EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangle, Poin
|
|||||||
|
|
||||||
Node& NewFrontTriangle(SweepContext& tcx, Point& point, Node& node);
|
Node& NewFrontTriangle(SweepContext& tcx, Point& point, Node& node);
|
||||||
|
|
||||||
void Fill(SweepContext& tcx, Node& node);
|
void Fill(SweepContext& tcx, Node& node, bool point_event);
|
||||||
|
|
||||||
bool Legalize(SweepContext& tcx, Triangle& t);
|
bool Legalize(SweepContext& tcx, Triangle& t);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user