Esempio n. 1
0
static void traverse_pt(ClipperLib::PolyNodes &nodes, Slic3r::Polygons &retval)
{
    /* use a nearest neighbor search to order these children
       TODO: supply start_near to chained_path() too? */
    
    // collect ordering points
    Points ordering_points;
    ordering_points.reserve(nodes.size());
    for (ClipperLib::PolyNodes::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
        Point p((*it)->Contour.front().X, (*it)->Contour.front().Y);
        ordering_points.push_back(p);
    }
    
    // perform the ordering
    ClipperLib::PolyNodes ordered_nodes;
    Slic3r::Geometry::chained_path_items(ordering_points, nodes, ordered_nodes);
    
    // push results recursively
    for (ClipperLib::PolyNodes::iterator it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) {
        // traverse the next depth
        traverse_pt((*it)->Childs, retval);
        
        Polygon p;
        ClipperPath_to_Slic3rMultiPoint((*it)->Contour, p);
        retval.push_back(p);
        if ((*it)->IsHole()) retval.back().reverse();  // ccw
    }
}
Esempio n. 2
0
void
ClipperPolygons_to_Slic3rPolygons(const ClipperLib::Polygons &input, Slic3r::Polygons &output)
{
    output.clear();
    for (ClipperLib::Polygons::const_iterator it = input.begin(); it != input.end(); ++it) {
        Slic3r::Polygon p;
        ClipperPolygon_to_Slic3rPolygon(*it, p);
        output.push_back(p);
    }
}