本文整理汇总了C++中Polygons::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygons::push_back方法的具体用法?C++ Polygons::push_back怎么用?C++ Polygons::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygons
的用法示例。
在下文中一共展示了Polygons::push_back方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Polygons
ExPolygonCollection::operator Polygons() const
{
Polygons polygons;
for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) {
polygons.push_back(it->contour);
for (Polygons::const_iterator ith = it->holes.begin(); ith != it->holes.end(); ++ith) {
polygons.push_back(*ith);
}
}
return polygons;
}
示例2: polygons_append
// Append a vector of Surfaces at the end of another vector of polygons.
inline void polygons_append(Polygons &dst, const SurfacesPtr &src)
{
dst.reserve(dst.size() + number_polygons(src));
for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++ it) {
dst.push_back((*it)->expolygon.contour);
dst.insert(dst.end(), (*it)->expolygon.holes.begin(), (*it)->expolygon.holes.end());
}
}
示例3: polygons_append
inline void polygons_append(Polygons &dst, ExPolygons &&src)
{
dst.reserve(dst.size() + number_polygons(src));
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it) {
dst.push_back(std::move(it->contour));
std::move(std::begin(it->holes), std::end(it->holes), std::back_inserter(dst));
}
}
示例4: to_polygons
inline Polygons to_polygons(ExPolygon &&src)
{
Polygons polygons;
polygons.reserve(src.holes.size() + 1);
polygons.push_back(std::move(src.contour));
std::move(std::begin(src.holes), std::end(src.holes), std::back_inserter(polygons));
return polygons;
}
示例5:
Polygons
ExPolygonCollection::contours() const
{
Polygons contours;
for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) {
contours.push_back(it->contour);
}
return contours;
}
示例6:
Polygons
Polygon::simplify(double tolerance) const
{
Polygon p = *this;
p.points = MultiPoint::_douglas_peucker(p.points, tolerance);
Polygons pp;
pp.push_back(p);
simplify_polygons(pp, pp);
return pp;
}
示例7: fillPolygonLayer
void Slice::fillPolygonLayer(){
//for every layer
for(int j=0; j<this->pointLayer.size(); j++){
Polygons layer;
for(int k=0; k<this->pointLayer.at(j)->size(); k++){
ClipperLib::Polygon p;
for(int i=0; i<this->pointLayer.at(j)->at(k)->size(); i++){
p.push_back(ClipperLib::IntPoint((int)(this->pointLayer.at(j)->at(k)->at(i).x()*1000),(int)(this->pointLayer.at(j)->at(k)->at(i).y()*1000)));
}
layer.push_back(p);
}
this->polygonLayer.append(layer);
}
}
示例8: p
// this only works on CCW polygons as CW will be ripped out by Clipper's simplify_polygons()
Polygons
Polygon::simplify(double tolerance) const
{
// repeat first point at the end in order to apply Douglas-Peucker
// on the whole polygon
Points points = this->points;
points.push_back(points.front());
Polygon p(MultiPoint::_douglas_peucker(points, tolerance));
p.points.pop_back();
Polygons pp;
pp.push_back(p);
simplify_polygons(pp, &pp);
return pp;
}
示例9: top_level_islands
Polygons top_level_islands(const Slic3r::Polygons &polygons)
{
ClipperLib::Paths input;
Slic3rMultiPoints_to_ClipperPaths(polygons, &input);
// init Clipper
ClipperLib::Clipper clipper;
clipper.Clear();
// perform union
clipper.AddPaths(input, ClipperLib::ptSubject, true);
ClipperLib::PolyTree polytree;
clipper.Execute(ClipperLib::ctUnion, polytree, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
// Convert only the top level islands to the output.
Polygons out;
out.reserve(polytree.ChildCount());
for (int i = 0; i < polytree.ChildCount(); ++i) {
out.push_back(Polygon());
ClipperPath_to_Slic3rMultiPoint(polytree.Childs[i]->Contour, &out.back());
}
return out;
}
示例10: processFile
void processFile(const char* input_filename, ConfigSettings& config, GCodeExport& gcode, bool firstFile)
{
for(unsigned int n=1; n<16;n++)
gcode.setExtruderOffset(n, config.extruderOffset[n].p());
gcode.setFlavor(config.gcodeFlavor);
double t = getTime();
log("Loading %s from disk...\n", input_filename);
SimpleModel* m = loadModel(input_filename, config.matrix);
if (!m)
{
log("Failed to load model: %s\n", input_filename);
return;
}
log("Loaded from disk in %5.3fs\n", timeElapsed(t));
log("Analyzing and optimizing model...\n");
OptimizedModel* om = new OptimizedModel(m, Point3(config.objectPosition.X, config.objectPosition.Y, -config.objectSink));
for(unsigned int v = 0; v < m->volumes.size(); v++)
{
log(" Face counts: %i -> %i %0.1f%%\n", (int)m->volumes[v].faces.size(), (int)om->volumes[v].faces.size(), float(om->volumes[v].faces.size()) / float(m->volumes[v].faces.size()) * 100);
log(" Vertex counts: %i -> %i %0.1f%%\n", (int)m->volumes[v].faces.size() * 3, (int)om->volumes[v].points.size(), float(om->volumes[v].points.size()) / float(m->volumes[v].faces.size() * 3) * 100);
}
delete m;
log("Optimize model %5.3fs \n", timeElapsed(t));
//om->saveDebugSTL("c:\\models\\output.stl");
log("Slicing model...\n");
vector<Slicer*> slicerList;
for(unsigned int volumeIdx=0; volumeIdx < om->volumes.size(); volumeIdx++)
{
slicerList.push_back(new Slicer(&om->volumes[volumeIdx], config.initialLayerThickness / 2, config.layerThickness, config.fixHorrible & FIX_HORRIBLE_KEEP_NONE_CLOSED, config.fixHorrible & FIX_HORRIBLE_EXTENSIVE_STITCHING));
//slicerList[volumeIdx]->dumpSegments("C:\\models\\output.html");
}
log("Sliced model in %5.3fs\n", timeElapsed(t));
SliceDataStorage storage;
if (config.supportAngle > -1)
{
fprintf(stdout,"Generating support map...\n");
generateSupportGrid(storage.support, om);
}
storage.modelSize = om->modelSize;
storage.modelMin = om->vMin;
storage.modelMax = om->vMax;
delete om;
log("Generating layer parts...\n");
for(unsigned int volumeIdx=0; volumeIdx < slicerList.size(); volumeIdx++)
{
storage.volumes.push_back(SliceVolumeStorage());
createLayerParts(storage.volumes[volumeIdx], slicerList[volumeIdx], config.fixHorrible & (FIX_HORRIBLE_UNION_ALL_TYPE_A | FIX_HORRIBLE_UNION_ALL_TYPE_B));
delete slicerList[volumeIdx];
}
//carveMultipleVolumes(storage.volumes);
generateMultipleVolumesOverlap(storage.volumes, config.multiVolumeOverlap);
log("Generated layer parts in %5.3fs\n", timeElapsed(t));
//dumpLayerparts(storage, "c:/models/output.html");
const unsigned int totalLayers = storage.volumes[0].layers.size();
for(unsigned int layerNr=0; layerNr<totalLayers; layerNr++)
{
for(unsigned int volumeIdx=0; volumeIdx<storage.volumes.size(); volumeIdx++)
{
generateInsets(&storage.volumes[volumeIdx].layers[layerNr], config.extrusionWidth, config.insetCount);
}
logProgress("inset",layerNr+1,totalLayers);
}
log("Generated inset in %5.3fs\n", timeElapsed(t));
//dumpLayerparts(storage, "c:/models/output.html");
for(unsigned int layerNr=0; layerNr<totalLayers; layerNr++)
{
for(unsigned int volumeIdx=0; volumeIdx<storage.volumes.size(); volumeIdx++)
{
generateSkins(layerNr, storage.volumes[volumeIdx], config.extrusionWidth, config.downSkinCount, config.upSkinCount, config.infillOverlap);
generateSparse(layerNr, storage.volumes[volumeIdx], config.extrusionWidth, config.downSkinCount, config.upSkinCount);
}
logProgress("skin",layerNr+1,totalLayers);
}
log("Generated up/down skin in %5.3fs\n", timeElapsed(t));
generateSkirt(storage, config.skirtDistance, config.extrusionWidth, config.skirtLineCount, config.skirtMinLength);
generateRaft(storage, config.raftMargin, config.supportAngle, config.supportEverywhere > 0, config.supportXYDistance);
for(unsigned int volumeIdx=0; volumeIdx<storage.volumes.size(); volumeIdx++)
{
for(unsigned int layerNr=0; layerNr<totalLayers; layerNr++)
{
for(unsigned int partNr=0; partNr<storage.volumes[volumeIdx].layers[layerNr].parts.size(); partNr++)
{
if (layerNr > 0)
storage.volumes[volumeIdx].layers[layerNr].parts[partNr].bridgeAngle = bridgeAngle(&storage.volumes[volumeIdx].layers[layerNr].parts[partNr], &storage.volumes[volumeIdx].layers[layerNr-1]);
else
storage.volumes[volumeIdx].layers[layerNr].parts[partNr].bridgeAngle = -1;
}
}
}
gcode.setRetractionSettings(config.retractionAmount, config.retractionSpeed, config.retractionAmountExtruderSwitch, config.minimalExtrusionBeforeRetraction);
if (firstFile)
{
//.........这里部分代码省略.........
示例11: Polygons
Polygon::operator Polygons() const
{
Polygons pp;
pp.push_back(*this);
return pp;
}
示例12: Point
void
BridgeDetector::coverage(double angle, Polygons* coverage) const
{
// Clone our expolygon and rotate it so that we work with vertical lines.
ExPolygon expolygon = this->expolygon;
expolygon.rotate(PI/2.0 - angle, Point(0,0));
/* Outset the bridge expolygon by half the amount we used for detecting anchors;
we'll use this one to generate our trapezoids and be sure that their vertices
are inside the anchors and not on their contours leading to false negatives. */
ExPolygons grown;
offset(expolygon, &grown, this->extrusion_width/2.0);
// Compute trapezoids according to a vertical orientation
Polygons trapezoids;
for (ExPolygons::const_iterator it = grown.begin(); it != grown.end(); ++it)
it->get_trapezoids2(&trapezoids, PI/2.0);
// get anchors, convert them to Polygons and rotate them too
Polygons anchors;
for (ExPolygons::const_iterator anchor = this->_anchors.begin(); anchor != this->_anchors.end(); ++anchor) {
Polygons pp = *anchor;
for (Polygons::iterator p = pp.begin(); p != pp.end(); ++p)
p->rotate(PI/2.0 - angle, Point(0,0));
anchors.insert(anchors.end(), pp.begin(), pp.end());
}
Polygons covered;
for (Polygons::const_iterator trapezoid = trapezoids.begin(); trapezoid != trapezoids.end(); ++trapezoid) {
Lines lines = trapezoid->lines();
Lines supported;
intersection(lines, anchors, &supported);
// not nice, we need a more robust non-numeric check
for (size_t i = 0; i < supported.size(); ++i) {
if (supported[i].length() < this->extrusion_width) {
supported.erase(supported.begin() + i);
i--;
}
}
if (supported.size() >= 2) covered.push_back(*trapezoid);
}
// merge trapezoids and rotate them back
Polygons _coverage;
union_(covered, &_coverage);
for (Polygons::iterator p = _coverage.begin(); p != _coverage.end(); ++p)
p->rotate(-(PI/2.0 - angle), Point(0,0));
// intersect trapezoids with actual bridge area to remove extra margins
// and append it to result
intersection(_coverage, this->expolygon, coverage);
/*
if (0) {
my @lines = map @{$_->lines}, @$trapezoids;
$_->rotate(-(PI/2 - $angle), [0,0]) for @lines;
require "Slic3r/SVG.pm";
Slic3r::SVG::output(
"coverage_" . rad2deg($angle) . ".svg",
expolygons => [$self->expolygon],
green_expolygons => $self->_anchors,
red_expolygons => $coverage,
lines => \@lines,
);
}
*/
}
示例13: loadCOCO
list loadCOCO( const std::string & name, int fold ) {
using namespace rapidjson;
// Load the annotations
char buf[1024];
sprintf( buf, COCO_ANNOT.c_str(), name.c_str() );
// Read the json file
Document doc;
std::ifstream t(buf);
std::string json_str = std::string(std::istreambuf_iterator<char>(t),std::istreambuf_iterator<char>());
doc.Parse( (char*)json_str.c_str() );
// Go through all instance labels
std::unordered_map< uint64_t, std::vector<int> > categories;
std::unordered_map< uint64_t, std::vector<float> > areas;
std::unordered_map< uint64_t, std::vector<Polygons> > segments;
const Value & instances = doc["instances"];
for ( Value::ConstValueIterator i = instances.Begin(); i != instances.End(); i++ ) {
// Get the image id
Value::ConstMemberIterator cmi_image_id = i->FindMember("image_id");
eassert( cmi_image_id != i->MemberEnd() );
const int image_id = cmi_image_id->value.GetInt();
// Get the category id
Value::ConstMemberIterator cmi_category_id = i->FindMember("category_id");
eassert( cmi_category_id != i->MemberEnd() );
const int category_id = cmi_category_id->value.GetInt();
// Get the category id
Value::ConstMemberIterator cmi_area = i->FindMember("area");
eassert( cmi_area != i->MemberEnd() );
const float area = cmi_area->value.GetDouble();
// Read the polygon
Value::ConstMemberIterator cmi_segmentation = i->FindMember("segmentation");
eassert( cmi_segmentation != i->MemberEnd() );
const Value & segmentations = cmi_segmentation->value;
// For now just use the first segmentation for each object
Polygons polygons;
for( Value::ConstValueIterator segmentation = segmentations.Begin(); segmentation!=segmentations.End(); segmentation++ ){
Polygon polygon = RMatrixXf( segmentation->Size() / 2, 2 );
float * ppolygon = polygon.data();
for ( Value::ConstValueIterator j = segmentation->Begin(); j != segmentation->End(); j++ )
*(ppolygon++) = j->GetDouble();
polygons.push_back( polygon );
}
if( !ONLY_CONNECTED || polygons.size() == 1 ) {
categories[ image_id ].push_back( category_id );
segments[ image_id ].push_back( polygons );
areas[ image_id ].push_back( area );
}
}
// Load all images
Value::ConstValueIterator B = doc["images"].Begin(), E = doc["images"].End();
const int N = E-B;
Value::ConstValueIterator i0 = B+(fold*N/N_FOLDS), i1 = B+((fold+1)*N/N_FOLDS);
std::vector< std::shared_ptr<Image8u> > images( i1 - i0 );
#pragma omp parallel for
for ( int k=0; k<i1-i0; k++ ) {
Value::ConstValueIterator i = i0+k;
// Get the file name and path
Value::ConstMemberIterator cmi_file_name = i->FindMember("file_name");
eassert( cmi_file_name != i->MemberEnd() );
const std::string file_name = cmi_file_name->value.GetString();
Value::ConstMemberIterator cmi_file_path = i->FindMember("file_path");
eassert( cmi_file_path != i->MemberEnd() );
const std::string file_path = cmi_file_path->value.GetString();
// Add the image entry
images[i-i0] = imreadShared( coco_dir+"/"+file_path+"/"+file_name );
}
// Create the python struct with the result
list r;
for ( Value::ConstValueIterator i = i0; i != i1; i++ ) {
// Get the image id
Value::ConstMemberIterator cmi_image_id = i->FindMember("id");
eassert( cmi_image_id != i->MemberEnd() );
const int image_id = cmi_image_id->value.GetInt();
// Add the image entry
const int N = categories[ image_id ].size();
if( N > 0 ){
dict entry;
entry["id"] = image_id;
entry["image"] = images[i - i0];
entry["categories"] = categories[ image_id ];
entry["areas"] = areas[ image_id ];
entry["segmentation"] = segments[ image_id ];
r.append( entry );
}
// else
// printf("Image '%d' doesn't have any annotations!\n", image_id );
}
return r;
}