Esempio n. 1
0
void
arrangement::compute_convolutionLabels()
{
    // initialize variables
    int compteur_wall = 0;
    int compteur_arc = 0;
    std::vector<std::string > labels;
    for (int i = 0; i < (int) env_points.size(); ++i)
        labels.push_back("none");

    double r = manipulator_diametre/2;

    // compute labels for robot convolution
    for (int i = 0; i < (int) convolutions.size(); ++i)
    {
        for (Arrangement_2::Edge_iterator edge = convolutions[i].edges_begin(); edge != convolutions[i].edges_end(); ++edge)
        {
            if (edge->curve().orientation() == CGAL::COLLINEAR) // if it is a segment
            {
                edge->set_data("w"+std::to_string(compteur_wall));
                edge->twin()->set_data("w"+std::to_string(compteur_wall++));
            }
            else // if it is an arc
            {
                std::string l = getLabel(labels, edge->curve(), compteur_arc, r);
                edge->set_data(l);
                edge->twin()->set_data(l);
            }
        }
    }

    // compute labels for object convolution (usefull just to clean critical curves 2)
    compteur_wall = 0;
    compteur_arc = 0;
    labels.clear();
    for (int i = 0; i < (int) env_points.size(); ++i)
        labels.push_back("none");

    r = target_diametre/2;

    for (int i = 0; i < (int) convolutions_o.size(); ++i)
    {
        for (Arrangement_2::Edge_iterator edge = convolutions_o[i].edges_begin(); edge != convolutions_o[i].edges_end(); ++edge)
        {
            if (edge->curve().orientation() == CGAL::COLLINEAR) // if it is a segment
            {
                edge->set_data("w"+std::to_string(compteur_wall));
                edge->twin()->set_data("w"+std::to_string(compteur_wall++));
            }
            else // if it is an arc
            {
                std::string l = getLabel(labels, edge->curve(), compteur_arc, r);
                edge->set_data(l);
                edge->twin()->set_data(l);
            }
        }
    }
}
Esempio n. 2
0
void
arrangement::compute_ACScell()
{
    /*
    for (int i = 0; i < (int)convolutions.size(); ++i)
        for (Arrangement_2::Edge_iterator edge = convolutions[i].edges_begin(); edge != convolutions[i].edges_end(); ++edge)
        {
            convolution_r_all = Arrangement_2(convolutions[i]);
            insert(convolution_r_all, edge->curve());
            Arrangement_2::Edge_iterator e = convolution_r_all.edges_end();
            e->set_data(edge->data());

        }
    */


    /*
    std::cout << "edge label convo : ";
    for (Arrangement_2::Edge_iterator edge = convolution_r_all.edges_begin(); edge != convolution_r_all.edges_end(); ++edge)
        std::cout << edge->data() << " ";
    std::cout << std::endl;
    */

    for (int i = 0; i < (int)point_in_faces.size(); ++i)
    {
        // do a copy
        Arrangement_2 copy(convolutions[0]);
        Observer observer(copy);

        // add a circle
        Rat_point_2 center(point_in_faces[i][0], point_in_faces[i][1]);
        Rat_circle_2 circle(center, r1r2 * r1r2);
        Conic_curve_2 conic_arc(circle);
        insert(copy, conic_arc);

        // then add rho label for arc
        for (Arrangement_2::Edge_iterator edge = copy.edges_begin(); edge != copy.edges_end(); ++edge)
        {
            if (edge->data().compare("") == 0)
            {
                edge->set_data("rho_");
                edge->twin()->set_data("rho_");
            }
        }

        Walk_pl walk_pl(copy);

        std::vector<std::vector<double> > points;
        compute_pointInCells(copy, points);

        for (int j = 0; j < (int)points.size(); ++j)
        {
            double _x = point_in_faces[i][0] - points[j][0];
            double _y = point_in_faces[i][1] - points[j][1];
            if (r1r2 < sqrt(_x * _x + _y * _y))
            {
                Rational x_(points[j][0]);
                Rational y_(points[j][1]);
                Conic_point_2 p(x_,y_);
                Arrangement_2::Vertex_handle v = insert_point(copy, p, walk_pl);
                try
                {
                    ACScell cell(i);

                    Arrangement_2::Ccb_halfedge_circulator first_outer_ccb = v->face()->outer_ccb();
                    Arrangement_2::Ccb_halfedge_circulator outer_ccb = v->face()->outer_ccb();
                    do
                    {
                        // for retrieving ACScell Begin and End
                        insert(cell.arr, outer_ccb->curve());

                        // then continue
                        cell.addLabel(outer_ccb->data());
                        ++outer_ccb;
                    } while (outer_ccb != first_outer_ccb);

                    ACScells.push_back(cell);
                }
                catch (const std::exception exn) {}
            }
        }
    }

    // clean ACScells
    for (int i = 0; i < (int)ACScells.size(); ++i)
        ACScells[i].cleanLabels();

    // compute ACScells id
    int cpt = 0;
    int previous = 0;
    for (int i = 0; i < (int)ACScells.size(); ++i)
    {
        if (previous != ACScells[i].NCR)
        {
            cpt = 0;
            previous = ACScells[i].NCR;
        }

        ACScells[i].id = std::to_string(ACScells[i].NCR) + "." + std::to_string(cpt);
        ++cpt;
    }
}