Example #1
0
static
double total_inflection_for_contour_unchecked (
    const Boundary &b, Boundary::contour_iterator cit)
{
    Boundary::edge_iterator eit = b.edges_begin (cit),
        eit_end = b.edges_end (cit);
    double acc = 0.;
    for (; eit != eit_end; ++eit)
        acc += b.inflection_after_edge (eit);
    return acc;
}
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;
}