mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-30 01:03:30 +01:00
delete nodes from memory
This commit is contained in:
parent
fe67bffee8
commit
15db727895
@ -87,7 +87,8 @@ 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, true);
|
Fill(tcx, node);
|
||||||
|
tcx.RemoveNode(&node);
|
||||||
}
|
}
|
||||||
|
|
||||||
//tcx.AddNode(new_node);
|
//tcx.AddNode(new_node);
|
||||||
@ -187,7 +188,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, bool point_event)
|
void Sweep::Fill(SweepContext& tcx, Node& node)
|
||||||
{
|
{
|
||||||
Triangle* triangle = new Triangle(*node.prev->point, *node.point, *node.next->point);
|
Triangle* triangle = new Triangle(*node.prev->point, *node.point, *node.next->point);
|
||||||
|
|
||||||
@ -206,10 +207,6 @@ void Sweep::Fill(SweepContext& tcx, Node& node, bool point_event)
|
|||||||
if (!Legalize(tcx, *triangle)) {
|
if (!Legalize(tcx, *triangle)) {
|
||||||
tcx.MapTriangleToNodes(*triangle);
|
tcx.MapTriangleToNodes(*triangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(point_event) {
|
|
||||||
tcx.RemoveNode(&node);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,8 +225,10 @@ 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, false);
|
Fill(tcx, *node);
|
||||||
|
Node *temp = node;
|
||||||
node = node->next;
|
node = node->next;
|
||||||
|
delete temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill left holes
|
// Fill left holes
|
||||||
@ -238,8 +237,10 @@ 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, false);
|
Fill(tcx, *node);
|
||||||
|
Node *temp = node;
|
||||||
node = node->prev;
|
node = node->prev;
|
||||||
|
delete temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill right basins
|
// Fill right basins
|
||||||
@ -525,7 +526,7 @@ void Sweep::FillBasinReq(SweepContext& tcx, Node* node)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fill(tcx, *node, false);
|
Fill(tcx, *node);
|
||||||
|
|
||||||
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;
|
||||||
@ -608,7 +609,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, false);
|
Fill(tcx, *node.next);
|
||||||
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) {
|
||||||
@ -688,7 +689,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, false);
|
Fill(tcx, *node.prev);
|
||||||
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, bool point_event);
|
void Fill(SweepContext& tcx, Node& node);
|
||||||
|
|
||||||
bool Legalize(SweepContext& tcx, Triangle& t);
|
bool Legalize(SweepContext& tcx, Triangle& t);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user