本文整理汇总了C++中clipperlib::Paths::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Paths::push_back方法的具体用法?C++ Paths::push_back怎么用?C++ Paths::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clipperlib::Paths
的用法示例。
在下文中一共展示了Paths::push_back方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pathObjectToPolygons
void BooleanTool::pathObjectToPolygons(
const PathObject* object,
ClipperLib::Paths& polygons,
PolyMap& polymap)
{
object->update();
polygons.reserve(polygons.size() + object->parts().size());
for (const auto& part : object->parts())
{
const PathCoordVector& path_coords = part.path_coords;
auto path_coords_end = path_coords.size();
if (part.isClosed())
--path_coords_end;
ClipperLib::Path polygon;
for (auto i = 0u; i < path_coords_end; ++i)
{
auto point = MapCoord { path_coords[i].pos };
polygon.push_back(ClipperLib::IntPoint(point.nativeX(), point.nativeY()));
polymap.insertMulti(polygon.back(), std::make_pair(&part, &path_coords[i]));
}
bool orientation = Orientation(polygon);
if ( (&part == &object->parts().front()) != orientation )
{
std::reverse(polygon.begin(), polygon.end());
}
// Push_back shall move the polygon.
static_assert(std::is_nothrow_move_constructible<ClipperLib::Path>::value, "ClipperLib::Path must be nothrow move constructible");
polygons.push_back(polygon);
}
}
示例2: toClipper
ClipperLib::Paths Clipper::toClipper(const std::vector<ofPolyline>& polylines,
ClipperLib::cInt scale)
{
ClipperLib::Paths paths;
for (auto& polyline: polylines) paths.push_back(toClipper(polyline, scale));
return paths;
}
示例3:
ClipperLib::Paths
Slic3rMultiPoints_to_ClipperPaths(const T &input)
{
ClipperLib::Paths retval;
for (typename T::const_iterator it = input.begin(); it != input.end(); ++it)
retval.push_back(Slic3rMultiPoint_to_ClipperPath(*it));
return retval;
}
示例4: convert
ClipperLib::Paths ClipperHelpers::convert(
const QVector<Path>& paths,
const PositiveLength& maxArcTolerance) noexcept {
ClipperLib::Paths p;
p.reserve(paths.size());
foreach (const Path& path, paths) {
p.push_back(convert(path, maxArcTolerance));
}
示例5:
void
Slic3rMultiPoints_to_ClipperPaths(const T &input, ClipperLib::Paths &output)
{
output.clear();
for (typename T::const_iterator it = input.begin(); it != input.end(); ++it) {
ClipperLib::Path p;
Slic3rMultiPoint_to_ClipperPath(*it, p);
output.push_back(p);
}
}
示例6: polyToClipperPaths
ClipperLib::Paths polyToClipperPaths(const panda::types::Polygon& poly)
{
ClipperLib::Paths paths;
auto contour = pathToClipperPath(poly.contour);
if (!Orientation(contour)) // We want the orientation to be CW
ReversePath(contour);
paths.push_back(contour);
for (const auto& hole : poly.holes)
{
auto path = pathToClipperPath(hole);
if (path.size() < 3)
continue;
// The orientation of holes must be opposite that of outer polygons.
if (Orientation(path))
ReversePath(path);
paths.push_back(path);
}
return paths;
}
示例7: double_polygon_to_path
void Grasp_Calculator::double_polygon_to_path(DPolygon2D double_polygon, ClipperLib::Paths &int_polygon)
{
ClipperLib::cInt factor = 100000;
ClipperLib::Path int_poly;
int_polygon.clear();
for (std::vector<DoublePoint2D>::iterator p2d = double_polygon.begin(); p2d != double_polygon.end(); ++p2d)
{
ClipperLib::IntPoint p;
p.X = (ClipperLib::cInt)(factor * p2d->x);
p.Y = (ClipperLib::cInt)(factor * p2d->y);
int_poly.push_back(p);
}
int_polygon.push_back(int_poly);
}
示例8: setObjectsToBeModeled
// Set the objects (defined by contour points) to be models in the world and scene.
void World::setObjectsToBeModeled(const std::vector<std::vector<cv::Point>> contours) {
int contourSize = (int)contours.size();
for(int i = 0; i < contourSize; i++ )
{
std::vector<cv::Point> currentShape = contours[i];
int numOfPoints = (int)currentShape.size();
b2Vec2 * vertices = new b2Vec2[numOfPoints];
ClipperLib::Paths* polygons = new ClipperLib::Paths();
ClipperLib::Path polygon;
for (int j = 0; j < numOfPoints; j++)
{
vertices[j].x = currentShape[j].x / PTM_RATIO;
vertices[j].y = currentShape[j].y / PTM_RATIO;
//cv::line(m_scene, currentShape[j], currentShape[(j + 1) % numOfPoints], cv::Scalar(0,0,255));
//std::cout << "[" << vertices[j].x << "," <<vertices[j].y << "]" << std::endl;
polygon.push_back(ClipperLib::IntPoint(currentShape[j].x, currentShape[j].y));
}
b2BodyDef objectBodyDef;
objectBodyDef.type = b2_staticBody;
b2Body *objectBody = m_world->CreateBody(&objectBodyDef);
objectBody->SetUserData(polygons);
polygons->push_back(polygon);
b2EdgeShape objectEdgeShape;
b2FixtureDef objectShapeDef;
objectShapeDef.shape = &objectEdgeShape;
for (int j = 0; j < numOfPoints - 1; j++)
{
objectEdgeShape.Set(vertices[j], vertices[j+1]);
objectBody->CreateFixture(&objectShapeDef);
}
objectEdgeShape.Set(vertices[numOfPoints - 1], vertices[0]);
objectBody->CreateFixture(&objectShapeDef);
m_objectBodies.push_back(objectBody);
delete[] vertices;
}
}