mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-16 02:32:25 +01:00
bug hunting
This commit is contained in:
parent
696ef826bd
commit
4338a2be10
@ -43,6 +43,7 @@ struct Node;
|
|||||||
struct Edge;
|
struct Edge;
|
||||||
|
|
||||||
struct Point {
|
struct Point {
|
||||||
|
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
||||||
/// Default constructor does nothing (for performance).
|
/// Default constructor does nothing (for performance).
|
||||||
@ -118,6 +119,7 @@ struct Point {
|
|||||||
|
|
||||||
// Represents a simple polygon's edge
|
// Represents a simple polygon's edge
|
||||||
struct Edge {
|
struct Edge {
|
||||||
|
|
||||||
Point* p, *q;
|
Point* p, *q;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
@ -62,7 +62,7 @@ Orientation Orient2d(Point& pa, Point& pb, Point& pc)
|
|||||||
double val = detleft - detright;
|
double val = detleft - detright;
|
||||||
if (val > -EPSILON && val < EPSILON) {
|
if (val > -EPSILON && val < EPSILON) {
|
||||||
return COLLINEAR;
|
return COLLINEAR;
|
||||||
} else if (val > 0) {
|
} else if (val > EPSILON) {
|
||||||
return CCW;
|
return CCW;
|
||||||
}
|
}
|
||||||
return CW;
|
return CW;
|
||||||
|
@ -37,9 +37,10 @@ AdvancingFront::AdvancingFront(Node& head, Node& tail)
|
|||||||
search_node_ = &head;
|
search_node_ = &head;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* AdvancingFront::Locate(const double& x)
|
Node* AdvancingFront::LocateNode(const double& x)
|
||||||
{
|
{
|
||||||
Node* node = search_node_;
|
Node* node = search_node_;
|
||||||
|
//printf("L: %p - %p\n", node, node->next);
|
||||||
|
|
||||||
if (x < node->value) {
|
if (x < node->value) {
|
||||||
//printf("<: - %f,%f - %p\n", x, node->value, node->next);
|
//printf("<: - %f,%f - %p\n", x, node->value, node->next);
|
||||||
@ -76,7 +77,7 @@ Node* AdvancingFront::LocatePoint(const Point* point)
|
|||||||
const double px = point->x;
|
const double px = point->x;
|
||||||
Node* node = FindSearchNode(px);
|
Node* node = FindSearchNode(px);
|
||||||
const double nx = node->point->x;
|
const double nx = node->point->x;
|
||||||
printf("AF: %p - %p\n", node, node->next);
|
//printf("LP: %p - %p\n", node, node->next);
|
||||||
|
|
||||||
if (px == nx) {
|
if (px == nx) {
|
||||||
if (point != node->point) {
|
if (point != node->point) {
|
||||||
@ -104,7 +105,6 @@ Node* AdvancingFront::LocatePoint(const Point* point)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
search_node_ = node;
|
search_node_ = node;
|
||||||
printf("\nSN: %p - %p\n", search_node_, search_node_->next);
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ Node* search();
|
|||||||
void set_search(Node* node);
|
void set_search(Node* node);
|
||||||
|
|
||||||
/// Locate insertion point along advancing front
|
/// Locate insertion point along advancing front
|
||||||
Node* Locate(const double& x);
|
Node* LocateNode(const double& x);
|
||||||
|
|
||||||
Node* LocatePoint(const Point* point);
|
Node* LocatePoint(const Point* point);
|
||||||
|
|
||||||
|
@ -47,13 +47,13 @@ void Sweep::SweepPoints(SweepContext& tcx)
|
|||||||
{
|
{
|
||||||
for (int i = 1; i < tcx.point_count(); i++) {
|
for (int i = 1; i < tcx.point_count(); i++) {
|
||||||
Point& point = *tcx.GetPoint(i);
|
Point& point = *tcx.GetPoint(i);
|
||||||
printf("%i = %f,%f ", i, point.x, point.y);
|
//printf("%i = %f,%f ", i, point.x, point.y);
|
||||||
Node& node = PointEvent(tcx, point);
|
Node& node = PointEvent(tcx, point);
|
||||||
printf("1...");
|
//printf("1...");
|
||||||
for (int i = 0; i < point.edge_list.size(); i++) {
|
for (int i = 0; i < point.edge_list.size(); i++) {
|
||||||
EdgeEvent(tcx, point.edge_list[i], node);
|
EdgeEvent(tcx, point.edge_list[i], node);
|
||||||
}
|
}
|
||||||
printf("2!\n");
|
//printf("2!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -707,7 +707,7 @@ void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& t,
|
|||||||
Triangle& ot = t.NeighborAcross(p);
|
Triangle& ot = t.NeighborAcross(p);
|
||||||
Point& op = *ot.OppositePoint(t, p);
|
Point& op = *ot.OppositePoint(t, p);
|
||||||
|
|
||||||
if (&t.NeighborAcross(p) == NULL) {
|
if (&ot == NULL) {
|
||||||
// If we want to integrate the fillEdgeEvent do it here
|
// If we want to integrate the fillEdgeEvent do it here
|
||||||
// With current implementation we should never get here
|
// With current implementation we should never get here
|
||||||
//throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
|
//throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
|
||||||
@ -730,6 +730,7 @@ void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& t,
|
|||||||
// XXX: I think one of the triangles should be legalized here?
|
// XXX: I think one of the triangles should be legalized here?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//printf("flip again!\n");
|
||||||
Orientation o = Orient2d(eq, op, ep);
|
Orientation o = Orient2d(eq, op, ep);
|
||||||
t = NextFlipTriangle(tcx, (int)o, t, ot, p, op);
|
t = NextFlipTriangle(tcx, (int)o, t, ot, p, op);
|
||||||
FlipEdgeEvent(tcx, ep, eq, t, p);
|
FlipEdgeEvent(tcx, ep, eq, t, p);
|
||||||
@ -743,6 +744,7 @@ void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& t,
|
|||||||
|
|
||||||
Triangle& Sweep::NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triangle& ot, Point& p, Point& op)
|
Triangle& Sweep::NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triangle& ot, Point& p, Point& op)
|
||||||
{
|
{
|
||||||
|
//printf("enum %i,%i\n", o, CCW);
|
||||||
if (o == CCW) {
|
if (o == CCW) {
|
||||||
// ot is not crossing edge after flip
|
// ot is not crossing edge after flip
|
||||||
int edge_index = ot.EdgeIndex(&p, &op);
|
int edge_index = ot.EdgeIndex(&p, &op);
|
||||||
@ -754,6 +756,7 @@ Triangle& Sweep::NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triang
|
|||||||
|
|
||||||
// t is not crossing edge after flip
|
// t is not crossing edge after flip
|
||||||
int edge_index = t.EdgeIndex(&p, &op);
|
int edge_index = t.EdgeIndex(&p, &op);
|
||||||
|
//printf("edge_index = %i\n", edge_index);
|
||||||
t.delaunay_edge[edge_index] = true;
|
t.delaunay_edge[edge_index] = true;
|
||||||
Legalize(tcx, t);
|
Legalize(tcx, t);
|
||||||
t.ClearDelunayEdges();
|
t.ClearDelunayEdges();
|
||||||
|
@ -99,7 +99,7 @@ void SweepContext::AddToMap(Triangle* triangle)
|
|||||||
Node& SweepContext::LocateNode(Point& point)
|
Node& SweepContext::LocateNode(Point& point)
|
||||||
{
|
{
|
||||||
// TODO implement search tree
|
// TODO implement search tree
|
||||||
return *front_->Locate(point.x);
|
return *front_->LocateNode(point.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SweepContext::CreateAdvancingFront()
|
void SweepContext::CreateAdvancingFront()
|
||||||
@ -132,7 +132,7 @@ void SweepContext::RemoveNode(Node* node)
|
|||||||
void SweepContext::MapTriangleToNodes(Triangle& t)
|
void SweepContext::MapTriangleToNodes(Triangle& t)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (t.GetNeighbor(i) == NULL) {
|
if (!t.GetNeighbor(i)) {
|
||||||
Node* n = front_->LocatePoint(t.PointCW(*t.GetPoint(i)));
|
Node* n = front_->LocatePoint(t.PointCW(*t.GetPoint(i)));
|
||||||
if (n)
|
if (n)
|
||||||
n->triangle = &t;
|
n->triangle = &t;
|
||||||
|
Loading…
Reference in New Issue
Block a user