当前位置: 首页>>代码示例>>C++>>正文


C++ ExPolygons类代码示例

本文整理汇总了C++中ExPolygons的典型用法代码示例。如果您正苦于以下问题:C++ ExPolygons类的具体用法?C++ ExPolygons怎么用?C++ ExPolygons使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ExPolygons类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: number_polygons

// Count a nuber of polygons stored inside the vector of expolygons.
// Useful for allocating space for polygons when converting expolygons to polygons.
inline size_t number_polygons(const ExPolygons &expolys)
{
    size_t n_polygons = 0;
    for (ExPolygons::const_iterator it = expolys.begin(); it != expolys.end(); ++ it)
        n_polygons += it->holes.size() + 1;
    return n_polygons;
}
开发者ID:jiripech,项目名称:Slic3r,代码行数:9,代码来源:ExPolygon.hpp

示例2: make_slices

// merge all regions' slices to get islands
void Layer::make_slices()
{
    ExPolygons slices;
    if (m_regions.size() == 1) {
        // optimization: if we only have one region, take its slices
        slices = m_regions.front()->slices;
    } else {
        Polygons slices_p;
        for (LayerRegion *layerm : m_regions)
            polygons_append(slices_p, to_polygons(layerm->slices));
        slices = union_ex(slices_p);
    }
    
    this->slices.expolygons.clear();
    this->slices.expolygons.reserve(slices.size());
    
    // prepare ordering points
    Points ordering_points;
    ordering_points.reserve(slices.size());
    for (const ExPolygon &ex : slices)
        ordering_points.push_back(ex.contour.first_point());
    
    // sort slices
    std::vector<Points::size_type> order;
    Slic3r::Geometry::chained_path(ordering_points, order);
    
    // populate slices vector
    for (size_t i : order)
        this->slices.expolygons.push_back(std::move(slices[i]));
}
开发者ID:repetier,项目名称:Slic3r,代码行数:31,代码来源:Layer.cpp

示例3: expolygons_contain

inline bool expolygons_contain(ExPolygons &expolys, const Point &pt)
{
    for (ExPolygons::iterator p = expolys.begin(); p != expolys.end(); ++p)
        if (p->contains(pt))
            return true;
    return false;
}
开发者ID:jiripech,项目名称:Slic3r,代码行数:7,代码来源:ExPolygon.hpp

示例4: to_expolygons

inline ExPolygons to_expolygons(const SurfacesPtr &src)
{
    ExPolygons expolygons;
    expolygons.reserve(src.size());
    for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++it)
        expolygons.push_back((*it)->expolygon);
    return expolygons;
}
开发者ID:gringer,项目名称:Slic3r,代码行数:8,代码来源:Surface.hpp

示例5: polygons_append

inline void polygons_append(Polygons &dst, const ExPolygons &src) 
{ 
    dst.reserve(dst.size() + number_polygons(src));
    for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it) {
        dst.push_back(it->contour);
        dst.insert(dst.end(), it->holes.begin(), it->holes.end());
    }
}
开发者ID:jiripech,项目名称:Slic3r,代码行数:8,代码来源:ExPolygon.hpp

示例6: ExPolygons

SurfaceCollection::operator ExPolygons() const
{
    ExPolygons expp;
    expp.reserve(this->surfaces.size());
    for (Surfaces::const_iterator surface = this->surfaces.begin(); surface != this->surfaces.end(); ++surface) {
        expp.push_back(surface->expolygon);
    }
    return expp;
}
开发者ID:be3d,项目名称:Slic3r,代码行数:9,代码来源:SurfaceCollection.cpp

示例7: initialized

MotionPlanner::MotionPlanner(const ExPolygons &islands)
    : initialized(false)
{
    ExPolygons expp;
    for (ExPolygons::const_iterator island = islands.begin(); island != islands.end(); ++island)
        island->simplify(SCALED_EPSILON, &expp);
    
    for (ExPolygons::const_iterator island = expp.begin(); island != expp.end(); ++island)
        this->islands.push_back(MotionPlannerEnv(*island));
}
开发者ID:Salandora,项目名称:Slic3r,代码行数:10,代码来源:MotionPlanner.cpp

示例8: to_polygons

inline Polygons to_polygons(const ExPolygons &src)
{
    Polygons polygons;
    polygons.reserve(number_polygons(src));
    for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++it) {
        polygons.push_back(it->contour);
        polygons.insert(polygons.end(), it->holes.begin(), it->holes.end());
    }
    return polygons;
}
开发者ID:jiripech,项目名称:Slic3r,代码行数:10,代码来源:ExPolygon.hpp

示例9: union_ex

void
LayerRegion::merge_slices()
{
    // without safety offset, artifacts are generated (GH #2494)
    ExPolygons expp = union_ex((Polygons)this->slices, true);
    this->slices.surfaces.clear();
    this->slices.surfaces.reserve(expp.size());
    
    for (ExPolygons::const_iterator expoly = expp.begin(); expoly != expp.end(); ++expoly)
        this->slices.surfaces.push_back(Surface(stInternal, *expoly));
}
开发者ID:jeffkyjin,项目名称:Slic3r,代码行数:11,代码来源:LayerRegion.cpp

示例10: if

void
SLAPrint::_infill_layer(size_t i, const Fill* _fill)
{
    Layer &layer = this->layers[i];
    
    const float shell_thickness = this->config.get_abs_value("perimeter_extrusion_width", this->config.layer_height.value);
    
    // In order to detect what regions of this layer need to be solid,
    // perform an intersection with layers within the requested shell thickness.
    Polygons internal = layer.slices;
    for (size_t j = 0; j < this->layers.size(); ++j) {
        const Layer &other = this->layers[j];
        if (abs(other.print_z - layer.print_z) > shell_thickness) continue;
    
        if (j == 0 || j == this->layers.size()-1) {
            internal.clear();
            break;
        } else if (i != j) {
            internal = intersection(internal, other.slices);
            if (internal.empty()) break;
        }
    }
    
    // If we have no internal infill, just print the whole layer as a solid slice.
    if (internal.empty()) return;
    layer.solid = false;
    
    const Polygons infill = offset(layer.slices, -scale_(shell_thickness));
    
    // Generate solid infill
    layer.solid_infill << diff_ex(infill, internal, true);
    
    // Generate internal infill
    {
        std::auto_ptr<Fill> fill(_fill->clone());
        fill->layer_id = i;
        fill->z        = layer.print_z;
        
        ExtrusionPath templ(erInternalInfill);
        templ.width = fill->spacing;
        const ExPolygons internal_ex = intersection_ex(infill, internal);
        for (ExPolygons::const_iterator it = internal_ex.begin(); it != internal_ex.end(); ++it) {
            Polylines polylines = fill->fill_surface(Surface(stInternal, *it));
            layer.infill.append(polylines, templ);
        }
    }
    
    // Generate perimeter(s).
    layer.perimeters << diff_ex(
        layer.slices,
        offset(layer.slices, -scale_(shell_thickness))
    );
}
开发者ID:jeffkyjin,项目名称:Slic3r,代码行数:53,代码来源:SLAPrint.cpp

示例11: PolyTreeToExPolygons

vector<ExPoly> Clipping::getExPolys(const CL::PolyTree &ctree, double z,
				    double extrusionfactor)
{
  ExPolygons cexpolys;
  PolyTreeToExPolygons(&ctree, cexpolys);
  vector<ExPoly> expolys(cexpolys.size());
  for (uint j = 0 ; j < cexpolys.size(); j++) {
    expolys[j].outer = getPoly(cexpolys[0].outer, z, extrusionfactor);
    for (uint i = 0 ; i < cexpolys[j].holes.size(); i++)
      expolys[j].holes.push_back(getPoly(cexpolys[j].holes[i], z, extrusionfactor));
  }
  return expolys;
}
开发者ID:Funny-DK,项目名称:repsnapper,代码行数:13,代码来源:clipping.cpp

示例12: diff_ex

ExtrusionEntityCollection
PerimeterGenerator::_fill_gaps(double min, double max, double w,
    const Polygons &gaps) const
{
    ExtrusionEntityCollection coll;
    
    min *= (1 - INSET_OVERLAP_TOLERANCE);
    
    ExPolygons curr = diff_ex(
        offset2(gaps, -min/2, +min/2),
        offset2(gaps, -max/2, +max/2),
        true
    );
    
    Polylines polylines;
    for (ExPolygons::const_iterator ex = curr.begin(); ex != curr.end(); ++ex)
        ex->medial_axis(max, min/2, &polylines);
    if (polylines.empty())
        return coll;
    
    #ifdef SLIC3R_DEBUG
    if (!curr.empty())
        printf("  %zu gaps filled with extrusion width = %f\n", curr.size(), w);
    #endif
    
    //my $flow = $layerm->flow(FLOW_ROLE_SOLID_INFILL, 0, $w);
    Flow flow(
        w, this->layer_height, this->solid_infill_flow.nozzle_diameter
    );
    
    double mm3_per_mm = flow.mm3_per_mm();
    
    for (Polylines::const_iterator p = polylines.begin(); p != polylines.end(); ++p) {
        ExtrusionPath path(erGapFill);
        path.polyline   = *p;
        path.mm3_per_mm = mm3_per_mm;
        path.width      = flow.width;
        path.height     = this->layer_height;
        
        if (p->is_valid() && p->first_point().coincides_with(p->last_point())) {
            // since medial_axis() now returns only Polyline objects, detect loops here
            ExtrusionLoop loop;
            loop.paths.push_back(path);
            coll.append(loop);
        } else {
            coll.append(path);
        }
    }
    
    return coll;
}
开发者ID:2bright,项目名称:Slic3r,代码行数:51,代码来源:PerimeterGenerator.cpp

示例13: AddOuterPolyNodeToExPolygons

void Clipping::AddOuterPolyNodeToExPolygons(const CL::PolyNode * polynode,
					    ExPolygons& expolygons)
{
  size_t cnt = expolygons.size();
  expolygons.resize(cnt + 1);
  expolygons[cnt].outer = polynode->Contour;
  expolygons[cnt].holes.resize(polynode->ChildCount());
  for (int i = 0; i < polynode->ChildCount(); ++i)
  {
    expolygons[cnt].holes[i] = polynode->Childs[i]->Contour;
    //Add outer polygons contained by (nested within) holes ...
    for (int j = 0; j < polynode->Childs[i]->ChildCount(); ++j)
      AddOuterPolyNodeToExPolygons(polynode->Childs[i]->Childs[j], expolygons);
  }
}
开发者ID:Funny-DK,项目名称:repsnapper,代码行数:15,代码来源:clipping.cpp

示例14:

void
SurfaceCollection::simplify(double tolerance)
{
    Surfaces ss;
    for (Surfaces::const_iterator it_s = this->surfaces.begin(); it_s != this->surfaces.end(); ++it_s) {
        ExPolygons expp;
        it_s->expolygon.simplify(tolerance, expp);
        for (ExPolygons::const_iterator it_e = expp.begin(); it_e != expp.end(); ++it_e) {
            Surface s = *it_s;
            s.expolygon = *it_e;
            ss.push_back(s);
        }
    }
    this->surfaces = ss;
}
开发者ID:Gfermoto,项目名称:Slic3r,代码行数:15,代码来源:SurfaceCollection.cpp

示例15: offset

void
MotionPlanner::initialize()
{
    if (this->initialized) return;
    if (this->islands.empty()) return;  // prevent initialization of empty BoundingBox
    
    ExPolygons expp;
    for (ExPolygons::const_iterator island = this->islands.begin(); island != this->islands.end(); ++island) {
        island->simplify(SCALED_EPSILON, expp);
    }
    this->islands = expp;
    
    // loop through islands in order to create inner expolygons and collect their contours
    this->inner.reserve(this->islands.size());
    Polygons outer_holes;
    for (ExPolygons::const_iterator island = this->islands.begin(); island != this->islands.end(); ++island) {
        this->inner.push_back(ExPolygonCollection());
        offset(*island, &this->inner.back().expolygons, -MP_INNER_MARGIN);
        
        outer_holes.push_back(island->contour);
    }
    
    // grow island contours in order to prepare holes of the outer environment
    // This is actually wrong because it might merge contours that are close,
    // thus confusing the island check in shortest_path() below
    //offset(outer_holes, &outer_holes, +MP_OUTER_MARGIN);
    
    // generate outer contour as bounding box of everything
    Points points;
    for (Polygons::const_iterator contour = outer_holes.begin(); contour != outer_holes.end(); ++contour)
        points.insert(points.end(), contour->points.begin(), contour->points.end());
    BoundingBox bb(points);
    
    // grow outer contour
    Polygons contour;
    offset(bb.polygon(), &contour, +MP_OUTER_MARGIN);
    assert(contour.size() == 1);
    
    // make expolygon for outer environment
    ExPolygons outer;
    diff(contour, outer_holes, &outer);
    assert(outer.size() == 1);
    this->outer = outer.front();
    
    this->graphs.resize(this->islands.size() + 1, NULL);
    this->initialized = true;
}
开发者ID:PetteriAimonen,项目名称:Slic3r,代码行数:47,代码来源:MotionPlanner.cpp


注:本文中的ExPolygons类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。