#include <stdio.h>
#include <stdlib.h>
-/// Default constructor does nothing (for performance).
+/** Default constructor does nothing (for performance). */
void
p2t_point_init (P2tPoint* THIS)
return THIS;
}
-/// Construct using coordinates.
+/** Construct using coordinates. */
void
p2t_point_init_dd (P2tPoint* THIS, double x, double y)
g_slice_free (P2tPoint, THIS);
}
-/// Constructor
+/** Constructor */
void
p2t_edge_init (P2tEdge* THIS, P2tPoint* p1, P2tPoint* p2)
}
else if (p1->x == p2->x)
{
- // Repeat points
+ /* Repeat points */
assert (FALSE);
}
}
THIS->interior_ = FALSE;
}
-// Update neighbor pointers
+/* Update neighbor pointers */
void
p2t_triangle_mark_neighbor_pt_pt_tr (P2tTriangle* THIS, P2tPoint* p1, P2tPoint* p2, P2tTriangle* t)
assert (0);
}
-// Exhaustive search to update neighbor pointers
+/* Exhaustive search to update neighbor pointers */
void
p2t_triangle_mark_neighbor_tr (P2tTriangle* THIS, P2tTriangle *t)
p2t_triangle_opposite_point (P2tTriangle* THIS, P2tTriangle* t, P2tPoint* p)
{
P2tPoint *cw = p2t_triangle_point_cw (t, p);
- double x = cw->x;
+ /*double x = cw->x;
double y = cw->y;
x = p->x;
y = p->y;
- P2tPoint* ham = p2t_triangle_point_cw (THIS, cw);
+ P2tPoint* ham = */p2t_triangle_point_cw (THIS, cw);
return p2t_triangle_point_cw (THIS, cw);
}
-// Legalized triangle by rotating clockwise around point(0)
+/* Legalized triangle by rotating clockwise around point(0) */
void
p2t_triangle_legalize_pt (P2tTriangle* THIS, P2tPoint *point)
THIS->points_[2] = point;
}
-// Legalize triagnle by rotating clockwise around oPoint
+/* Legalize triagnle by rotating clockwise around oPoint */
void
p2t_triangle_legalize_pt_pt (P2tTriangle* THIS, P2tPoint *opoint, P2tPoint *npoint)
p2t_triangle_mark_constrained_edge_pt_pt (THIS, edge->p, edge->q);
}
-// Mark edge as constrained
+/* Mark edge as constrained */
void
p2t_triangle_mark_constrained_edge_pt_pt (P2tTriangle* THIS, P2tPoint* p, P2tPoint* q)
}
}
-// The point counter-clockwise to given point
+/* The point counter-clockwise to given point */
P2tPoint*
p2t_triangle_point_cw (P2tTriangle* THIS, P2tPoint* point)
assert (0);
}
-// The point counter-clockwise to given point
+/* The point counter-clockwise to given point */
P2tPoint*
p2t_triangle_point_ccw (P2tTriangle* THIS, P2tPoint* point)
assert (0);
}
-// The neighbor clockwise to given point
+/* The neighbor clockwise to given point */
P2tTriangle*
p2t_triangle_neighbor_cw (P2tTriangle* THIS, P2tPoint* point)
return THIS->neighbors_[0];
}
-// The neighbor counter-clockwise to given point
+/* The neighbor counter-clockwise to given point */
P2tTriangle*
p2t_triangle_neighbor_ccw (P2tTriangle* THIS, P2tPoint* point)
}
}
-// The neighbor across to given point
+/* The neighbor across to given point */
P2tTriangle*
p2t_triangle_neighbor_across (P2tTriangle* THIS, P2tPoint* opoint)
printf ("%f,%f\n", THIS->points_[2]->x, THIS->points_[2]->y);
}
-// WARNING! the function for sorting a g_ptr_array expects to recieve
-// pointers to the pointers (double indirection)!
+/* WARNING! the function for sorting a g_ptr_array expects to recieve
+ * pointers to the pointers (double indirection)! */
gint
p2t_point_cmp (gconstpointer a, gconstpointer b)
}
else if (ap->y == bp->y)
{
- // Make sure q is point with greater x value
+ /* Make sure q is point with greater x value */
if (ap->x < bp->x)
{
return -1;
return 1;
}
-// /// Add two points_ component-wise.
-//
-// Point operator + (const Point& a, const Point& b)
-// {
-// return Point (a.x + b.x, a.y + b.y);
-// }
-//
-// /// Subtract two points_ component-wise.
-//
-// Point operator - (const Point& a, const Point& b)
-// {
-// return Point (a.x - b.x, a.y - b.y);
-// }
-//
-// /// Multiply point by scalar
-//
-// Point operator * (double s, const Point& a)
-// {
-// return Point (s * a.x, s * a.y);
-// }
-
-// gboolean operator == (const Point& a, const Point& b)
+/* gboolean operator == (const Point& a, const Point& b) */
gboolean
p2t_point_equals (const P2tPoint* a, const P2tPoint* b)
{
return a->x == b->x && a->y == b->y;
}
-//
-// gboolean operator != (const Point& a, const Point& b)
-// {
-// return a.x != b.x && a.y != b.y;
-// }
-
-// /// Peform the dot product on two vectors.
-//
-// double
-// Dot (const Point& a, const Point& b)
-// {
-// return a.x * b.x + a.y * b.y;
-// }
-//
-// /// Perform the cross product on two vectors. In 2D this produces a scalar.
-//
-// double
-// Cross (const Point& a, const Point& b)
-// {
-// return a.x * b.y - a.y * b.x;
-// }
-//
-// /// Perform the cross product on a point and a scalar. In 2D this produces
-// /// a point.
-//
-// Point
-// Cross (const Point& a, double s)
-// {
-// return Point (s * a.y, -s * a.x);
-// }
-//
-// /// Perform the cross product on a scalar and a point. In 2D this produces
-// /// a point.
-//
-// Point
-// Cross (const double s, const Point& a)
-// {
-// return Point (-s * a.y, s * a.x);
-// }
P2tPoint*
p2t_triangle_get_point (P2tTriangle* THIS, const int index)
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
*/\r
+#include <math.h>\r
+\r
#include "sweep.h"\r
#include "sweep_context.h"\r
#include "advancing_front.h"\r
p2t_sweep_destroy (P2tSweep* THIS)\r
{\r
int i;\r
- // Clean up memory\r
+ /* Clean up memory */\r
for (i = 0; i < THIS->nodes_->len; i++)\r
{\r
p2t_node_free (node_index (THIS->nodes_, i));\r
g_free (THIS);\r
}\r
\r
-// Triangulate simple polygon with holes\r
+/* Triangulate simple polygon with holes */\r
\r
void\r
p2t_sweep_triangulate (P2tSweep *THIS, P2tSweepContext *tcx)\r
{\r
p2t_sweepcontext_init_triangulation (tcx);\r
p2t_sweepcontext_create_advancingfront (tcx, THIS->nodes_);\r
- // Sweep points; build mesh\r
+ /* Sweep points; build mesh */\r
p2t_sweep_sweep_points (THIS, tcx);\r
- // Clean up\r
+ /* Clean up */\r
p2t_sweep_finalization_polygon (THIS, tcx);\r
}\r
\r
void\r
p2t_sweep_finalization_polygon (P2tSweep *THIS, P2tSweepContext *tcx)\r
{\r
- // Get an Internal triangle to start with\r
+ /* Get an Internal triangle to start with */\r
P2tTriangle* t = p2t_advancingfront_head (p2t_sweepcontext_front (tcx))->next->triangle;\r
P2tPoint* p = p2t_advancingfront_head (p2t_sweepcontext_front (tcx))->next->point;\r
while (!p2t_triangle_get_constrained_edge_cw (t, p))\r
t = p2t_triangle_neighbor_ccw (t, p);\r
}\r
\r
- // Collect interior triangles constrained by edges\r
+ /* Collect interior triangles constrained by edges */\r
p2t_sweepcontext_mesh_clean (tcx, t);\r
}\r
\r
P2tNode* node = p2t_sweepcontext_locate_node (tcx, point);\r
P2tNode* new_node = p2t_sweep_new_front_triangle (THIS, tcx, point, node);\r
\r
- // Only need to check +epsilon since point never have smaller\r
- // x value than node due to how we fetch nodes from the front\r
+ /* Only need to check +epsilon since point never have smaller\r
+ * x value than node due to how we fetch nodes from the front */\r
if (point->x <= node->point->x + EPSILON)\r
{\r
p2t_sweep_fill (THIS, tcx, node);\r
}\r
\r
- //tcx.AddNode(new_node);\r
+ /*tcx.AddNode(new_node); */\r
\r
p2t_sweep_fill_advancingfront (THIS, tcx, new_node);\r
return new_node;\r
return;\r
}\r
\r
- // For now we will do all needed filling\r
- // TODO: integrate with flip process might give some better performance\r
- // but for now this avoid the issue with cases that needs both flips and fills\r
+ /* For now we will do all needed filling\r
+ * TODO: integrate with flip process might give some better performance\r
+ * but for now this avoid the issue with cases that needs both flips and fills\r
+ */\r
p2t_sweep_fill_edge_event (THIS, tcx, edge, node);\r
p2t_sweep_edge_event_pt_pt_tr_pt (THIS, tcx, edge->p, edge->q, node->triangle, edge->q);\r
}\r
void\r
p2t_sweep_edge_event_pt_pt_tr_pt (P2tSweep *THIS, P2tSweepContext *tcx, P2tPoint* ep, P2tPoint* eq, P2tTriangle* triangle, P2tPoint* point)\r
{\r
+ P2tPoint *p1, *p2;\r
+ P2tOrientation o1, o2;\r
+\r
if (p2t_sweep_is_edge_side_of_triangle (THIS, triangle, ep, eq))\r
{\r
return;\r
}\r
\r
- P2tPoint* p1 = p2t_triangle_point_ccw (triangle, point);\r
- P2tOrientation o1 = p2t_orient2d (eq, p1, ep);\r
+ p1 = p2t_triangle_point_ccw (triangle, point);\r
+ o1 = p2t_orient2d (eq, p1, ep);\r
if (o1 == COLLINEAR)\r
{\r
if (p2t_triangle_contains_pt_pt (triangle, eq, p1))\r
{\r
p2t_triangle_mark_constrained_edge_pt_pt (triangle, eq, p1);\r
- // We are modifying the constraint maybe it would be better to\r
- // not change the given constraint and just keep a variable for the new constraint\r
+ /* We are modifying the constraint maybe it would be better to\r
+ * not change the given constraint and just keep a variable for the new constraint\r
+ */\r
tcx->edge_event.constrained_edge->q = p1;\r
triangle = p2t_triangle_neighbor_across (triangle, point);\r
p2t_sweep_edge_event_pt_pt_tr_pt (THIS, tcx, ep, p1, triangle, p1);\r
return;\r
}\r
\r
- P2tPoint* p2 = p2t_triangle_point_cw (triangle, point);\r
- P2tOrientation o2 = p2t_orient2d (eq, p2, ep);\r
+ p2 = p2t_triangle_point_cw (triangle, point);\r
+ o2 = p2t_orient2d (eq, p2, ep);\r
if (o2 == COLLINEAR)\r
{\r
if (p2t_triangle_contains_pt_pt (triangle, eq, p2))\r
{\r
p2t_triangle_mark_constrained_edge_pt_pt (triangle, eq, p2);\r
- // We are modifying the constraint maybe it would be better to\r
- // not change the given constraint and just keep a variable for the new constraint\r
+ /* We are modifying the constraint maybe it would be better to\r
+ * not change the given constraint and just keep a variable for the new constraint\r
+ */\r
tcx->edge_event.constrained_edge->q = p2;\r
triangle = p2t_triangle_neighbor_across (triangle, point);\r
p2t_sweep_edge_event_pt_pt_tr_pt (THIS, tcx, ep, p2, triangle, p2);\r
\r
if (o1 == o2)\r
{\r
- // Need to decide if we are rotating CW or CCW to get to a triangle\r
- // that will cross edge\r
+ /* Need to decide if we are rotating CW or CCW to get to a triangle\r
+ * that will cross edge */\r
if (o1 == CW)\r
{\r
triangle = p2t_triangle_neighbor_ccw (triangle, point);\r
}\r
else\r
{\r
- // This triangle crosses constraint so lets flippin start!\r
+ /* This triangle crosses constraint so lets flippin start! */\r
p2t_sweep_flip_edge_event (THIS, tcx, ep, eq, triangle, point);\r
}\r
}\r
\r
if (index != -1)\r
{\r
+ P2tTriangle *t;\r
p2t_triangle_mark_constrained_edge_i (triangle, index);\r
- P2tTriangle* t = p2t_triangle_get_neighbor (triangle, index);\r
+ t = p2t_triangle_get_neighbor (triangle, index);\r
if (t)\r
{\r
p2t_triangle_mark_constrained_edge_pt_pt (t, ep, eq);\r
p2t_sweep_new_front_triangle (P2tSweep *THIS, P2tSweepContext *tcx, P2tPoint* point, P2tNode *node)\r
{\r
P2tTriangle* triangle = p2t_triangle_new (point, node->point, node->next->point);\r
+ P2tNode *new_node;\r
\r
p2t_triangle_mark_neighbor_tr (triangle, node->triangle);\r
p2t_sweepcontext_add_to_map (tcx, triangle);\r
\r
- P2tNode* new_node = p2t_node_new_pt (point);\r
+ new_node = p2t_node_new_pt (point);\r
g_ptr_array_add (THIS->nodes_, new_node);\r
\r
new_node->next = node->next;\r
{\r
P2tTriangle* triangle = p2t_triangle_new (node->prev->point, node->point, node->next->point);\r
\r
- // TODO: should copy the constrained_edge value from neighbor triangles\r
- // for now constrained_edge values are copied during the legalize\r
+ /* TODO: should copy the constrained_edge value from neighbor triangles\r
+ * for now constrained_edge values are copied during the legalize */\r
p2t_triangle_mark_neighbor_tr (triangle, node->prev->triangle);\r
p2t_triangle_mark_neighbor_tr (triangle, node->triangle);\r
\r
p2t_sweepcontext_add_to_map (tcx, triangle);\r
\r
- // Update the advancing front\r
+ /* Update the advancing front */\r
node->prev->next = node->next;\r
node->next->prev = node->prev;\r
\r
- // If it was legalized the triangle has already been mapped\r
+ /* If it was legalized the triangle has already been mapped */\r
if (!p2t_sweep_legalize (THIS, tcx, triangle))\r
{\r
p2t_sweepcontext_map_triangle_to_nodes (tcx, triangle);\r
p2t_sweep_fill_advancingfront (P2tSweep *THIS, P2tSweepContext *tcx, P2tNode* n)\r
{\r
\r
- // Fill right holes\r
+ /* Fill right holes */\r
P2tNode* node = n->next;\r
\r
while (node->next)\r
{\r
double angle = p2t_sweep_hole_angle (THIS, node);\r
- if (angle > M_PI_2 || angle < -M_PI_2) break;\r
+ if (angle > G_PI_2 || angle < -G_PI_2) break;\r
p2t_sweep_fill (THIS, tcx, node);\r
node = node->next;\r
}\r
\r
- // Fill left holes\r
+ /* Fill left holes */\r
node = n->prev;\r
\r
while (node->prev)\r
{\r
double angle = p2t_sweep_hole_angle (THIS, node);\r
- if (angle > M_PI_2 || angle < -M_PI_2) break;\r
+ if (angle > G_PI_2 || angle < -G_PI_2) break;\r
p2t_sweep_fill (THIS, tcx, node);\r
node = node->prev;\r
}\r
\r
- // Fill right basins\r
+ /* Fill right basins */\r
if (n->next && n->next->next)\r
{\r
double angle = p2t_sweep_basin_angle (THIS, n);\r
p2t_sweep_legalize (P2tSweep *THIS, P2tSweepContext *tcx, P2tTriangle *t)\r
{\r
int i;\r
- // To legalize a triangle we start by finding if any of the three edges\r
- // violate the Delaunay condition\r
+ /* To legalize a triangle we start by finding if any of the three edges\r
+ * violate the Delaunay condition */\r
for (i = 0; i < 3; i++)\r
{\r
+ P2tTriangle *ot;\r
+\r
if (t->delaunay_edge[i])\r
continue;\r
\r
- P2tTriangle* ot = p2t_triangle_get_neighbor (t, i);\r
+ ot = p2t_triangle_get_neighbor (t, i);\r
\r
if (ot)\r
{\r
P2tPoint* p = p2t_triangle_get_point (t, i);\r
P2tPoint* op = p2t_triangle_opposite_point (ot, t, p);\r
int oi = p2t_triangle_index (ot, op);\r
+ gboolean inside;\r
\r
- // If this is a Constrained Edge or a Delaunay Edge(only during recursive legalization)\r
- // then we should not try to legalize\r
+ /* If this is a Constrained Edge or a Delaunay Edge(only during recursive legalization)\r
+ * then we should not try to legalize */\r
if (ot->constrained_edge[oi] || ot->delaunay_edge[oi])\r
{\r
t->constrained_edge[i] = ot->constrained_edge[oi];\r
continue;\r
}\r
\r
- gboolean inside = p2t_sweep_incircle (THIS, p, p2t_triangle_point_ccw (t, p), p2t_triangle_point_cw (t, p), op);\r
+ inside = p2t_sweep_incircle (THIS, p, p2t_triangle_point_ccw (t, p), p2t_triangle_point_cw (t, p), op);\r
\r
if (inside)\r
{\r
- // Lets mark this shared edge as Delaunay\r
+ gboolean not_legalized;\r
+ /* Lets mark this shared edge as Delaunay */\r
t->delaunay_edge[i] = TRUE;\r
ot->delaunay_edge[oi] = TRUE;\r
\r
- // Lets rotate shared edge one vertex CW to legalize it\r
+ /* Lets rotate shared edge one vertex CW to legalize it */\r
p2t_sweep_rotate_triangle_pair (THIS, t, p, ot, op);\r
\r
- // We now got one valid Delaunay Edge shared by two triangles\r
- // This gives us 4 new edges to check for Delaunay\r
+ /* We now got one valid Delaunay Edge shared by two triangles\r
+ * This gives us 4 new edges to check for Delaunay */\r
\r
- // Make sure that triangle to node mapping is done only one time for a specific triangle\r
- gboolean not_legalized = !p2t_sweep_legalize (THIS, tcx, t);\r
+ /* Make sure that triangle to node mapping is done only one time for a specific triangle */\r
+ not_legalized = !p2t_sweep_legalize (THIS, tcx, t);\r
if (not_legalized)\r
{\r
p2t_sweepcontext_map_triangle_to_nodes (tcx, t);\r
if (not_legalized)\r
p2t_sweepcontext_map_triangle_to_nodes (tcx, ot);\r
\r
- // Reset the Delaunay edges, since they only are valid Delaunay edges\r
- // until we add a new triangle or point.\r
- // XXX: need to think about this. Can these edges be tried after we\r
- // return to previous recursive level?\r
+ /* Reset the Delaunay edges, since they only are valid Delaunay edges\r
+ * until we add a new triangle or point.\r
+ * XXX: need to think about this. Can these edges be tried after we\r
+ * return to previous recursive level? */\r
t->delaunay_edge[i] = FALSE;\r
ot->delaunay_edge[oi] = FALSE;\r
\r
- // If triangle have been legalized no need to check the other edges since\r
- // the recursive legalization will handles those so we can end here.\r
+ /* If triangle have been legalized no need to check the other edges since\r
+ * the recursive legalization will handles those so we can end here.*/\r
return TRUE;\r
}\r
}\r
double bdxady = bdx * ady;\r
double oabd = adxbdy - bdxady;\r
\r
+ double cdx, cdy;\r
+ double cdxady, adxcdy, ocad;\r
+\r
+ double bdxcdy, cdxbdy;\r
+ double alift, blift, clift;\r
+ double det;\r
+\r
if (oabd <= 0)\r
return FALSE;\r
\r
- double cdx = pc->x - pd->x;\r
- double cdy = pc->y - pd->y;\r
+ cdx = pc->x - pd->x;\r
+ cdy = pc->y - pd->y;\r
\r
- double cdxady = cdx * ady;\r
- double adxcdy = adx * cdy;\r
- double ocad = cdxady - adxcdy;\r
+ cdxady = cdx * ady;\r
+ adxcdy = adx * cdy;\r
+ ocad = cdxady - adxcdy;\r
\r
if (ocad <= 0)\r
return FALSE;\r
\r
- double bdxcdy = bdx * cdy;\r
- double cdxbdy = cdx * bdy;\r
+ bdxcdy = bdx * cdy;\r
+ cdxbdy = cdx * bdy;\r
\r
- double alift = adx * adx + ady * ady;\r
- double blift = bdx * bdx + bdy * bdy;\r
- double clift = cdx * cdx + cdy * cdy;\r
+ alift = adx * adx + ady * ady;\r
+ blift = bdx * bdx + bdy * bdy;\r
+ clift = cdx * cdx + cdy * cdy;\r
\r
- double det = alift * (bdxcdy - cdxbdy) + blift * ocad + clift * oabd;\r
+ det = alift * (bdxcdy - cdxbdy) + blift * ocad + clift * oabd;\r
\r
return det > 0;\r
}\r
void\r
p2t_sweep_rotate_triangle_pair (P2tSweep *THIS, P2tTriangle *t, P2tPoint* p, P2tTriangle *ot, P2tPoint* op)\r
{\r
- P2tTriangle* n1, *n2, *n3, *n4;\r
+ P2tTriangle *n1, *n2, *n3, *n4;\r
+ gboolean ce1, ce2, ce3, ce4;\r
+ gboolean de1, de2, de3, de4;\r
+\r
n1 = p2t_triangle_neighbor_ccw (t, p);\r
n2 = p2t_triangle_neighbor_cw (t, p);\r
n3 = p2t_triangle_neighbor_ccw (ot, op);\r
n4 = p2t_triangle_neighbor_cw (ot, op);\r
\r
- gboolean ce1, ce2, ce3, ce4;\r
ce1 = p2t_triangle_get_constrained_edge_ccw (t, p);\r
ce2 = p2t_triangle_get_constrained_edge_cw (t, p);\r
ce3 = p2t_triangle_get_constrained_edge_ccw (ot, op);\r
ce4 = p2t_triangle_get_constrained_edge_cw (ot, op);\r
\r
- gboolean de1, de2, de3, de4;\r
de1 = p2t_triangle_get_delunay_edge_ccw (t, p);\r
de2 = p2t_triangle_get_delunay_edge_cw (t, p);\r
de3 = p2t_triangle_get_delunay_edge_ccw (ot, op);\r
p2t_triangle_legalize_pt_pt (t, p, op);\r
p2t_triangle_legalize_pt_pt (ot, op, p);\r
\r
- // Remap delaunay_edge\r
+ /* Remap delaunay_edge */\r
p2t_triangle_set_delunay_edge_ccw (ot, p, de1);\r
p2t_triangle_set_delunay_edge_cw (t, p, de2);\r
p2t_triangle_set_delunay_edge_ccw (t, op, de3);\r
p2t_triangle_set_delunay_edge_cw (ot, op, de4);\r
\r
- // Remap constrained_edge\r
+ /* Remap constrained_edge */\r
p2t_triangle_set_constrained_edge_ccw (ot, p, ce1);\r
p2t_triangle_set_constrained_edge_cw (t, p, ce2);\r
p2t_triangle_set_constrained_edge_ccw (t, op, ce3);\r
p2t_triangle_set_constrained_edge_cw (ot, op, ce4);\r
\r
- // Remap neighbors\r
- // XXX: might optimize the markNeighbor by keeping track of\r
- // what side should be assigned to what neighbor after the\r
- // rotation. Now mark neighbor does lots of testing to find\r
- // the right side.\r
+ /* Remap neighbors\r
+ * XXX: might optimize the markNeighbor by keeping track of\r
+ * what side should be assigned to what neighbor after the\r
+ * rotation. Now mark neighbor does lots of testing to find\r
+ * the right side. */\r
p2t_triangle_clear_neighbors (t);\r
p2t_triangle_clear_neighbors (ot);\r
if (n1) p2t_triangle_mark_neighbor_tr (ot, n1);\r
tcx->basin.left_node = node->next;\r
}\r
\r
- // Find the bottom and right node\r
+ /* Find the bottom and right node */\r
tcx->basin.bottom_node = tcx->basin.left_node;\r
while (tcx->basin.bottom_node->next\r
&& tcx->basin.bottom_node->point->y >= tcx->basin.bottom_node->next->point->y)\r
}\r
if (tcx->basin.bottom_node == tcx->basin.left_node)\r
{\r
- // No valid basin\r
+ /* No valid basin */\r
return;\r
}\r
\r
}\r
if (tcx->basin.right_node == tcx->basin.bottom_node)\r
{\r
- // No valid basins\r
+ /* No valid basins */\r
return;\r
}\r
\r
void\r
p2t_sweep_fill_basin_req (P2tSweep *THIS, P2tSweepContext *tcx, P2tNode* node)\r
{\r
- // if shallow stop filling\r
+ /* if shallow stop filling */\r
if (p2t_sweep_is_shallow (THIS, tcx, node))\r
{\r
return;\r
}\r
else\r
{\r
- // Continue with the neighbor node with lowest Y value\r
+ /* Continue with the neighbor node with lowest Y value */\r
if (node->prev->point->y < node->next->point->y)\r
{\r
node = node->prev;\r
height = tcx->basin.right_node->point->y - node->point->y;\r
}\r
\r
- // if shallow stop filling\r
+ /* if shallow stop filling */\r
if (tcx->basin.width > height)\r
{\r
return TRUE;\r
{\r
while (node->next->point->x < edge->p->x)\r
{\r
- // Check if next node is below the edge\r
+ /* Check if next node is below the edge */\r
if (p2t_orient2d (edge->q, node->next->point, edge->p) == CCW)\r
{\r
p2t_sweep_fill_right_below_edge_event (THIS, tcx, edge, node);\r
{\r
if (p2t_orient2d (node->point, node->next->point, node->next->next->point) == CCW)\r
{\r
- // Concave\r
+ /* Concave */\r
p2t_sweep_fill_right_concave_edge_event (THIS, tcx, edge, node);\r
}\r
else\r
{\r
- // Convex\r
+ /* Convex */\r
p2t_sweep_fill_right_convex_edge_event (THIS, tcx, edge, node);\r
- // Retry this one\r
+ /* Retry this one */\r
p2t_sweep_fill_right_below_edge_event (THIS, tcx, edge, node);\r
}\r
}\r
p2t_sweep_fill (THIS, tcx, node->next);\r
if (node->next->point != edge->p)\r
{\r
- // Next above or below edge?\r
+ /* Next above or below edge? */\r
if (p2t_orient2d (edge->q, node->next->point, edge->p) == CCW)\r
{\r
- // Below\r
+ /* Below */\r
if (p2t_orient2d (node->point, node->next->point, node->next->next->point) == CCW)\r
{\r
- // Next is concave\r
+ /* Next is concave */\r
p2t_sweep_fill_right_concave_edge_event (THIS, tcx, edge, node);\r
}\r
else\r
{\r
- // Next is convex\r
+ /* Next is convex */\r
}\r
}\r
}\r
void\r
p2t_sweep_fill_right_convex_edge_event (P2tSweep *THIS, P2tSweepContext *tcx, P2tEdge* edge, P2tNode* node)\r
{\r
- // Next concave or convex?\r
+ /* Next concave or convex? */\r
if (p2t_orient2d (node->next->point, node->next->next->point, node->next->next->next->point) == CCW)\r
{\r
- // Concave\r
+ /* Concave */\r
p2t_sweep_fill_right_concave_edge_event (THIS, tcx, edge, node->next);\r
}\r
else\r
{\r
- // Convex\r
- // Next above or below edge?\r
+ /* Convex\r
+ * Next above or below edge? */\r
if (p2t_orient2d (edge->q, node->next->next->point, edge->p) == CCW)\r
{\r
- // Below\r
+ /* Below */\r
p2t_sweep_fill_right_convex_edge_event (THIS, tcx, edge, node->next);\r
}\r
else\r
{\r
- // Above\r
+ /* Above */\r
}\r
}\r
}\r
{\r
while (node->prev->point->x > edge->p->x)\r
{\r
- // Check if next node is below the edge\r
+ /* Check if next node is below the edge */\r
if (p2t_orient2d (edge->q, node->prev->point, edge->p) == CW)\r
{\r
p2t_sweep_fill_left_below_edge_event (THIS, tcx, edge, node);\r
{\r
if (p2t_orient2d (node->point, node->prev->point, node->prev->prev->point) == CW)\r
{\r
- // Concave\r
+ /* Concave */\r
p2t_sweep_fill_left_concave_edge_event (THIS, tcx, edge, node);\r
}\r
else\r
{\r
- // Convex\r
+ /* Convex */\r
p2t_sweep_fill_left_convex_edge_event (THIS, tcx, edge, node);\r
- // Retry this one\r
+ /* Retry this one */\r
p2t_sweep_fill_left_below_edge_event (THIS, tcx, edge, node);\r
}\r
}\r
void\r
p2t_sweep_fill_left_convex_edge_event (P2tSweep *THIS, P2tSweepContext *tcx, P2tEdge* edge, P2tNode* node)\r
{\r
- // Next concave or convex?\r
+ /* Next concave or convex? */\r
if (p2t_orient2d (node->prev->point, node->prev->prev->point, node->prev->prev->prev->point) == CW)\r
{\r
- // Concave\r
+ /* Concave */\r
p2t_sweep_fill_left_concave_edge_event (THIS, tcx, edge, node->prev);\r
}\r
else\r
{\r
- // Convex\r
- // Next above or below edge?\r
+ /* Convex\r
+ * Next above or below edge? */\r
if (p2t_orient2d (edge->q, node->prev->prev->point, edge->p) == CW)\r
{\r
- // Below\r
+ /* Below */\r
p2t_sweep_fill_left_convex_edge_event (THIS, tcx, edge, node->prev);\r
}\r
else\r
{\r
- // Above\r
+ /* Above */\r
}\r
}\r
}\r
p2t_sweep_fill (THIS, tcx, node->prev);\r
if (node->prev->point != edge->p)\r
{\r
- // Next above or below edge?\r
+ /* Next above or below edge? */\r
if (p2t_orient2d (edge->q, node->prev->point, edge->p) == CW)\r
{\r
- // Below\r
+ /* Below */\r
if (p2t_orient2d (node->point, node->prev->point, node->prev->prev->point) == CW)\r
{\r
- // Next is concave\r
+ /* Next is concave */\r
p2t_sweep_fill_left_concave_edge_event (THIS, tcx, edge, node);\r
}\r
else\r
{\r
- // Next is convex\r
+ /* Next is convex */\r
}\r
}\r
}\r
\r
if (ot == NULL)\r
{\r
- // If we want to integrate the fillEdgeEvent do it here\r
- // With current implementation we should never get here\r
- //throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");\r
+ /* If we want to integrate the fillEdgeEvent do it here\r
+ * With current implementation we should never get here\r
+ *throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");\r
+ */\r
assert (0);\r
}\r
\r
if (p2t_utils_in_scan_area (p, p2t_triangle_point_ccw (t, p), p2t_triangle_point_cw (t, p), op))\r
{\r
- // Lets rotate shared edge one vertex CW\r
+ /* Lets rotate shared edge one vertex CW */\r
p2t_sweep_rotate_triangle_pair (THIS, t, p, ot, op);\r
p2t_sweepcontext_map_triangle_to_nodes (tcx, t);\r
p2t_sweepcontext_map_triangle_to_nodes (tcx, ot);\r
}\r
else\r
{\r
- // XXX: I think one of the triangles should be legalized here?\r
+ /* XXX: I think one of the triangles should be legalized here? */\r
}\r
}\r
else\r
P2tTriangle*\r
p2t_sweep_next_flip_triangle (P2tSweep *THIS, P2tSweepContext *tcx, int o, P2tTriangle *t, P2tTriangle *ot, P2tPoint* p, P2tPoint* op)\r
{\r
+ int edge_index;\r
+\r
if (o == CCW)\r
{\r
- // ot is not crossing edge after flip\r
+ /* ot is not crossing edge after flip */\r
int edge_index = p2t_triangle_edge_index (ot, p, op);\r
ot->delaunay_edge[edge_index] = TRUE;\r
p2t_sweep_legalize (THIS, tcx, ot);\r
return t;\r
}\r
\r
- // t is not crossing edge after flip\r
- int edge_index = p2t_triangle_edge_index (t, p, op);\r
+ /* t is not crossing edge after flip */\r
+ edge_index = p2t_triangle_edge_index (t, p, op);\r
\r
t->delaunay_edge[edge_index] = TRUE;\r
p2t_sweep_legalize (THIS, tcx, t);\r
P2tOrientation o2d = p2t_orient2d (eq, op, ep);\r
if (o2d == CW)\r
{\r
- // Right\r
+ /* Right */\r
return p2t_triangle_point_ccw (ot, op);\r
}\r
else if (o2d == CCW)\r
{\r
- // Left\r
+ /* Left */\r
return p2t_triangle_point_cw (ot, op);\r
}\r
else\r
{\r
- //throw new RuntimeException("[Unsupported] Opposing point on constrained edge");\r
+ /*throw new RuntimeException("[Unsupported] Opposing point on constrained edge");*/\r
assert (0);\r
}\r
}\r
\r
if (p2t_triangle_neighbor_across (t, p) == NULL)\r
{\r
- // If we want to integrate the fillEdgeEvent do it here\r
- // With current implementation we should never get here\r
- //throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");\r
+ /* If we want to integrate the fillEdgeEvent do it here\r
+ * With current implementation we should never get here\r
+ *throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");\r
+ */\r
assert (0);\r
}\r
\r
if (p2t_utils_in_scan_area (eq, p2t_triangle_point_ccw (flip_triangle, eq), p2t_triangle_point_cw (flip_triangle, eq), op))\r
{\r
- // flip with new edge op->eq\r
+ /* flip with new edge op->eq */\r
p2t_sweep_flip_edge_event (THIS, tcx, eq, op, ot, op);\r
- // TODO: Actually I just figured out that it should be possible to\r
- // improve this by getting the next ot and op before the the above\r
- // flip and continue the flipScanEdgeEvent here\r
- // set new ot and op here and loop back to inScanArea test\r
- // also need to set a new flip_triangle first\r
- // Turns out at first glance that this is somewhat complicated\r
- // so it will have to wait.\r
+ /* TODO: Actually I just figured out that it should be possible to\r
+ * improve this by getting the next ot and op before the the above\r
+ * flip and continue the flipScanEdgeEvent here\r
+ * set new ot and op here and loop back to inScanArea test\r
+ * also need to set a new flip_triangle first\r
+ * Turns out at first glance that this is somewhat complicated\r
+ * so it will have to wait. */\r
}\r
else\r
{\r