本文整理汇总了C++中Polylines::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Polylines::empty方法的具体用法?C++ Polylines::empty怎么用?C++ Polylines::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polylines
的用法示例。
在下文中一共展示了Polylines::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chained_path
Polylines PolylineCollection::chained_path(const Polylines &src, bool no_reverse)
{
return (src.empty() || src.front().points.empty()) ?
Polylines() :
_chained_path_from(src, src.front().first_point(), no_reverse
#if SLIC3R_CPPVER >= 11
, false
#endif
);
}
示例2: leftmost_point
Point PolylineCollection::leftmost_point(const Polylines &polylines)
{
if (polylines.empty()) CONFESS("leftmost_point() called on empty PolylineCollection");
Polylines::const_iterator it = polylines.begin();
Point p = it->leftmost_point();
for (++ it; it != polylines.end(); ++it) {
Point p2 = it->leftmost_point();
if (p2.x < p.x)
p = p2;
}
return p;
}
示例3: flow
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;
}
示例4: _fill_surface_single
void FillGyroid::_fill_surface_single(
const FillParams ¶ms,
unsigned int thickness_layers,
const std::pair<float, Point> &direction,
ExPolygon &expolygon,
Polylines &polylines_out)
{
// no rotation is supported for this infill pattern
BoundingBox bb = expolygon.contour.bounding_box();
coord_t distance = coord_t(scale_(this->spacing) / (params.density*this->scaling));
// align bounding box to a multiple of our grid module
bb.merge(_align_to_grid(bb.min, Point(2*M_PI*distance, 2*M_PI*distance)));
// generate pattern
Polylines polylines = make_gyroid_waves(
scale_(this->z),
params.density*this->scaling,
this->spacing,
ceil(bb.size().x / distance) + 1.,
ceil(bb.size().y / distance) + 1.);
// move pattern in place
for (Polyline &polyline : polylines)
polyline.translate(bb.min.x, bb.min.y);
// clip pattern to boundaries
polylines = intersection_pl(polylines, (Polygons)expolygon);
// connect lines
if (! params.dont_connect && ! polylines.empty()) { // prevent calling leftmost_point() on empty collections
ExPolygon expolygon_off;
{
ExPolygons expolygons_off = offset_ex(expolygon, (float)SCALED_EPSILON);
if (! expolygons_off.empty()) {
// When expanding a polygon, the number of islands could only shrink. Therefore the offset_ex shall generate exactly one expanded island for one input island.
assert(expolygons_off.size() == 1);
std::swap(expolygon_off, expolygons_off.front());
}
}
Polylines chained = PolylineCollection::chained_path_from(
std::move(polylines),
PolylineCollection::leftmost_point(polylines), false); // reverse allowed
bool first = true;
for (Polyline &polyline : chained) {
if (! first) {
// Try to connect the lines.
Points &pts_end = polylines_out.back().points;
const Point &first_point = polyline.points.front();
const Point &last_point = pts_end.back();
// TODO: we should also check that both points are on a fill_boundary to avoid
// connecting paths on the boundaries of internal regions
// TODO: avoid crossing current infill path
if (first_point.distance_to(last_point) <= 5 * distance &&
expolygon_off.contains(Line(last_point, first_point))) {
// Append the polyline.
pts_end.insert(pts_end.end(), polyline.points.begin(), polyline.points.end());
continue;
}
}
// The lines cannot be connected.
polylines_out.emplace_back(std::move(polyline));
first = false;
}
}
}
示例5: templ
/// The LayerRegion at this point of time may contain
/// surfaces of various types (internal/bridge/top/bottom/solid).
/// The infills are generated on the groups of surfaces with a compatible type.
/// Fills an array of ExtrusionPathCollection objects containing the infills generated now
/// and the thin fills generated by generate_perimeters().
void
LayerRegion::make_fill()
{
this->fills.clear();
const double fill_density = this->region()->config.fill_density;
const Flow infill_flow = this->flow(frInfill);
const Flow solid_infill_flow = this->flow(frSolidInfill);
const Flow top_solid_infill_flow = this->flow(frTopSolidInfill);
const coord_t perimeter_spacing = this->flow(frPerimeter).scaled_spacing();
SurfaceCollection surfaces;
// merge adjacent surfaces
// in case of bridge surfaces, the ones with defined angle will be attached to the ones
// without any angle (shouldn't this logic be moved to process_external_surfaces()?)
{
Polygons polygons_bridged;
polygons_bridged.reserve(this->fill_surfaces.surfaces.size());
for (Surfaces::const_iterator it = this->fill_surfaces.surfaces.begin(); it != this->fill_surfaces.surfaces.end(); ++it)
if (it->is_bridge() && it->bridge_angle >= 0)
append_to(polygons_bridged, (Polygons)*it);
// group surfaces by distinct properties (equal surface_type, thickness, thickness_layers, bridge_angle)
// group is of type SurfaceCollection
// FIXME: Use some smart heuristics to merge similar surfaces to eliminate tiny regions.
std::vector<SurfacesConstPtr> groups;
this->fill_surfaces.group(&groups);
// merge compatible solid groups (we can generate continuous infill for them)
{
// cache flow widths and patterns used for all solid groups
// (we'll use them for comparing compatible groups)
std::vector<SurfaceGroupAttrib> group_attrib(groups.size());
for (size_t i = 0; i < groups.size(); ++i) {
const Surface &surface = *groups[i].front();
// we can only merge solid non-bridge surfaces, so discard
// non-solid or bridge surfaces
if (!surface.is_solid() || surface.is_bridge()) continue;
group_attrib[i].is_solid = true;
group_attrib[i].fw = (surface.is_top()) ? top_solid_infill_flow.width : solid_infill_flow.width;
group_attrib[i].pattern = surface.is_top() ? this->region()->config.top_infill_pattern.value
: surface.is_bottom() ? this->region()->config.bottom_infill_pattern.value
: ipRectilinear;
}
// Loop through solid groups, find compatible groups and append them to this one.
for (size_t i = 0; i < groups.size(); ++i) {
if (!group_attrib[i].is_solid)
continue;
for (size_t j = i + 1; j < groups.size();) {
if (group_attrib[i] == group_attrib[j]) {
// groups are compatible, merge them
append_to(groups[i], groups[j]);
groups.erase(groups.begin() + j);
group_attrib.erase(group_attrib.begin() + j);
} else {
++j;
}
}
}
}
// Give priority to oriented bridges. Process the bridges in the first round, the rest of the surfaces in the 2nd round.
for (size_t round = 0; round < 2; ++ round) {
for (std::vector<SurfacesConstPtr>::const_iterator it_group = groups.begin(); it_group != groups.end(); ++ it_group) {
const SurfacesConstPtr &group = *it_group;
const bool is_oriented_bridge = group.front()->is_bridge() && group.front()->bridge_angle >= 0;
if (is_oriented_bridge != (round == 0))
continue;
// Make a union of polygons defining the infiill regions of a group, use a safety offset.
Polygons union_p = union_(to_polygons(group), true);
// Subtract surfaces having a defined bridge_angle from any other, use a safety offset.
if (!is_oriented_bridge && !polygons_bridged.empty())
union_p = diff(union_p, polygons_bridged, true);
// subtract any other surface already processed
//FIXME Vojtech: Because the bridge surfaces came first, they are subtracted twice!
surfaces.append(
diff_ex(union_p, to_polygons(surfaces), true),
*group.front() // template
);
}
}
}
// we need to detect any narrow surfaces that might collapse
// when adding spacing below
// such narrow surfaces are often generated in sloping walls
// by bridge_over_infill() and combine_infill() as a result of the
// subtraction of the combinable area from the layer infill area,
// which leaves small areas near the perimeters
// we are going to grow such regions by overlapping them with the void (if any)
//.........这里部分代码省略.........