Example #1
0
// perform sanity checking on a Boundary.
// this is not public code for now.
static void assert_boundary (const Boundary &b) {
#ifndef NDEBUG
    Boundary::contour_iterator cit;
    for (cit = b.contours_begin (); cit != b.contours_end (); ++cit) {
        Boundary::edge_iterator eit     = b.edges_begin (cit),
                                eit_end = b.edges_end (cit);
        while (eit != eit_end) {
            Boundary::edge_iterator next_eit = eit;
            ++next_eit;
            if (! (normed_diff (b.edge_vertex1 (eit),
                                b.edge_vertex0 (next_eit))
                   < VERTEX_MERGE_TOLERANCE)) {
                die ("assert_boundary: contour is not continuous.");
            }

            eit = next_eit;
        }
    }
#endif // NDEBUG
}
Example #2
0
double total_inflection_for_contour (const Boundary &b,
    Boundary::contour_iterator cit)
{
    double acc = total_inflection_for_contour_unchecked (b, cit);
    // total inflection should be +/-2pi.
    if (! (fabs (fabs (acc) - 2*M_PI) < 1e-3)) {
        Boundary::edge_iterator eit = b.edges_begin (cit),
            eit_end = b.edges_end (cit);
        int ctr = 0;
        for (eit = b.edges_begin (cit); eit != eit_end; ++eit) {
            vec_t v0 = b.edge_vertex0 (eit);
            vec_t v1 = b.edge_vertex1 (eit);
            fprintf (stderr, "infl at edge %.4i = %f\n"
                "(%f,%f) (%f,%f)\n", ctr++,
                b.inflection_after_edge (eit),
                v0[0], v0[1], v1[0], v1[1]);
        }
        die ("total_inflection_for_contour (contour_id = %i):\n%.20e\n%.20e",
            *cit, acc, 2*M_PI);
    }
    return acc;
}