本文整理汇总了C++中clipperlib::Path类的典型用法代码示例。如果您正苦于以下问题:C++ Path类的具体用法?C++ Path怎么用?C++ Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Path类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Area
DLL_PUBLIC double CDECL area(ClipperLib::IntPoint* path, size_t count) {
ClipperLib::Path v = ClipperLib::Path();
for(size_t i = 0; i < count; i++) {
v.emplace(v.end(), path[i].X, path[i].Y);
}
return ClipperLib::Area(v);
}
开发者ID:JuliaPackageMirrors,项目名称:Clipper.jl,代码行数:8,代码来源:cclipper.cpp
示例2:
void
Slic3rMultiPoint_to_ClipperPath(const Slic3r::MultiPoint &input, ClipperLib::Path &output)
{
output.clear();
for (Slic3r::Points::const_iterator pit = input.points.begin(); pit != input.points.end(); ++pit) {
output.push_back(ClipperLib::IntPoint( (*pit).x, (*pit).y ));
}
}
开发者ID:330sc,项目名称:Slic3r,代码行数:8,代码来源:ClipperUtils.cpp
示例3: Orientation
//==============================================================
// Static functions
//==============================================================
DLL_PUBLIC bool CDECL orientation(ClipperLib::IntPoint* path, size_t count) {
ClipperLib::Path v = ClipperLib::Path();
for(size_t i = 0; i < count; i++) {
v.emplace(v.end(), path[i].X, path[i].Y);
}
return ClipperLib::Orientation(v);
}
开发者ID:JuliaPackageMirrors,项目名称:Clipper.jl,代码行数:11,代码来源:cclipper.cpp
示例4: toClipperPath
static ClipperLib::Path toClipperPath(const GeometryCoordinates& ring) {
ClipperLib::Path result;
result.reserve(ring.size());
for (const auto& p : ring) {
result.emplace_back(p.x, p.y);
}
return result;
}
开发者ID:calendreco,项目名称:mapbox-gl-native,代码行数:8,代码来源:geometry_tile.cpp
示例5: expand
Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float epsilon = 2.0) {
int size = points.size();
ERR_FAIL_COND_V(size < 2, Vector<Vector2>());
ClipperLib::Path subj;
ClipperLib::PolyTree solution;
ClipperLib::PolyTree out;
for (int i = 0; i < points.size(); i++) {
subj << ClipperLib::IntPoint(points[i].x * PRECISION, points[i].y * PRECISION);
}
ClipperLib::ClipperOffset co;
co.AddPath(subj, ClipperLib::jtMiter, ClipperLib::etClosedPolygon);
co.Execute(solution, epsilon * PRECISION);
ClipperLib::PolyNode *p = solution.GetFirst();
ERR_FAIL_COND_V(!p, points);
while (p->IsHole()) {
p = p->GetNext();
}
//turn the result into simply polygon (AKA, fix overlap)
//clamp into the specified rect
ClipperLib::Clipper cl;
cl.StrictlySimple(true);
cl.AddPath(p->Contour, ClipperLib::ptSubject, true);
//create the clipping rect
ClipperLib::Path clamp;
clamp.push_back(ClipperLib::IntPoint(0, 0));
clamp.push_back(ClipperLib::IntPoint(rect.size.width * PRECISION, 0));
clamp.push_back(ClipperLib::IntPoint(rect.size.width * PRECISION, rect.size.height * PRECISION));
clamp.push_back(ClipperLib::IntPoint(0, rect.size.height * PRECISION));
cl.AddPath(clamp, ClipperLib::ptClip, true);
cl.Execute(ClipperLib::ctIntersection, out);
Vector<Vector2> outPoints;
ClipperLib::PolyNode *p2 = out.GetFirst();
while (p2->IsHole()) {
p2 = p2->GetNext();
}
int lasti = p2->Contour.size() - 1;
Vector2 prev = Vector2(p2->Contour[lasti].X / PRECISION, p2->Contour[lasti].Y / PRECISION);
for (unsigned int i = 0; i < p2->Contour.size(); i++) {
Vector2 cur = Vector2(p2->Contour[i].X / PRECISION, p2->Contour[i].Y / PRECISION);
if (cur.distance_to(prev) > 0.5) {
outPoints.push_back(cur);
prev = cur;
}
}
return outPoints;
}
开发者ID:93i,项目名称:godot,代码行数:57,代码来源:sprite_editor_plugin.cpp
示例6:
void
ClipperPath_to_Slic3rMultiPoint(const ClipperLib::Path &input, T* output)
{
PROFILE_FUNC();
output->points.clear();
output->points.reserve(input.size());
for (ClipperLib::Path::const_iterator pit = input.begin(); pit != input.end(); ++pit)
output->points.push_back(Slic3r::Point( (*pit).X, (*pit).Y ));
}
开发者ID:jiripech,项目名称:Slic3r,代码行数:9,代码来源:ClipperUtils.cpp
示例7: log
std::vector<Vec2> AutoPolygon::expand(const std::vector<Vec2>& points, const cocos2d::Rect &rect, const float& epsilon)
{
auto size = points.size();
// if there are less than 3 points, then we have nothing
if(size<3)
{
log("AUTOPOLYGON: cannot expand points for %s with less than 3 points, e: %f", _filename.c_str(), epsilon);
return std::vector<Vec2>();
}
ClipperLib::Path subj;
ClipperLib::PolyTree solution;
ClipperLib::PolyTree out;
for(std::vector<Vec2>::const_iterator it = points.begin(); it<points.end(); it++)
{
subj << ClipperLib::IntPoint(it-> x* PRECISION, it->y * PRECISION);
}
ClipperLib::ClipperOffset co;
co.AddPath(subj, ClipperLib::jtMiter, ClipperLib::etClosedPolygon);
co.Execute(solution, epsilon * PRECISION);
ClipperLib::PolyNode* p = solution.GetFirst();
if(!p)
{
log("AUTOPOLYGON: Clipper failed to expand the points");
return points;
}
while(p->IsHole()){
p = p->GetNext();
}
//turn the result into simply polygon (AKA, fix overlap)
//clamp into the specified rect
ClipperLib::Clipper cl;
cl.StrictlySimple(true);
cl.AddPath(p->Contour, ClipperLib::ptSubject, true);
//create the clipping rect
ClipperLib::Path clamp;
clamp.push_back(ClipperLib::IntPoint(0, 0));
clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, 0));
clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, rect.size.height/_scaleFactor * PRECISION));
clamp.push_back(ClipperLib::IntPoint(0, rect.size.height/_scaleFactor * PRECISION));
cl.AddPath(clamp, ClipperLib::ptClip, true);
cl.Execute(ClipperLib::ctIntersection, out);
std::vector<Vec2> outPoints;
ClipperLib::PolyNode* p2 = out.GetFirst();
while(p2->IsHole()){
p2 = p2->GetNext();
}
auto end = p2->Contour.end();
for(std::vector<ClipperLib::IntPoint>::const_iterator pt = p2->Contour.begin(); pt < end; pt++)
{
outPoints.push_back(Vec2(pt->X/PRECISION, pt->Y/PRECISION));
}
return outPoints;
}
开发者ID:Fuzesunshine,项目名称:CocosTest,代码行数:57,代码来源:CCAutoPolygon.cpp
示例8: path
ClipperLib::Path polygon::path(base_int denom) const
{
ClipperLib::Path ret;
for(auto v : this->vertexes)
{
ret.push_back(ClipperLib::IntPoint((ClipperLib::cInt)(v.x.numerator() * (denom / v.x.denominator())), (ClipperLib::cInt)(v.y.numerator() * (denom / v.y.denominator()))));
}
return ret;
}
开发者ID:AngelOfSol,项目名称:dress_app,代码行数:9,代码来源:Polygon.cpp
示例9:
ClipperLib::Path
Slic3rMultiPoint_to_ClipperPath_reversed(const Slic3r::MultiPoint &input)
{
ClipperLib::Path output;
output.reserve(input.points.size());
for (Slic3r::Points::const_reverse_iterator pit = input.points.rbegin(); pit != input.points.rend(); ++pit)
output.emplace_back((*pit)(0), (*pit)(1));
return output;
}
开发者ID:prusa3d,项目名称:Slic3r,代码行数:9,代码来源:ClipperUtils.cpp
示例10: unscaleClipperPolygon
void unscaleClipperPolygon(ClipperLib::Path &polygon)
{
PROFILE_FUNC();
for (ClipperLib::Path::iterator pit = polygon.begin(); pit != polygon.end(); ++pit) {
pit->X += CLIPPER_OFFSET_SCALE_ROUNDING_DELTA;
pit->Y += CLIPPER_OFFSET_SCALE_ROUNDING_DELTA;
pit->X >>= CLIPPER_OFFSET_POWER_OF_2;
pit->Y >>= CLIPPER_OFFSET_POWER_OF_2;
}
}
开发者ID:jiripech,项目名称:Slic3r,代码行数:10,代码来源:ClipperUtils.cpp
示例11: COORD
std::string
SVG::get_path_d(const ClipperLib::Path &path, double scale, bool closed) const
{
std::ostringstream d;
d << "M ";
for (ClipperLib::Path::const_iterator p = path.begin(); p != path.end(); ++p) {
d << COORD(scale * p->X - origin.x) << " ";
d << COORD(scale * p->Y - origin.y) << " ";
}
if (closed) d << "z";
return d.str();
}
开发者ID:Sebastianv650,项目名称:Slic3r,代码行数:12,代码来源:SVG.cpp
示例12: toClipper
ClipperLib::Path Clipper::toClipper(const ofPolyline& polyline,
ClipperLib::cInt scale)
{
ClipperLib::Path path;
for (auto& vertex: polyline.getVertices())
{
path.push_back(toClipper(vertex, scale));
}
return path;
}
开发者ID:bakercp,项目名称:ofxClipper,代码行数:12,代码来源:Clipper.cpp
示例13: path_to_double_polygon
void Grasp_Calculator::path_to_double_polygon(DPolygon2D &double_polygon, ClipperLib::Path int_polygon)
{
ClipperLib::cInt factor = 100000;
double_polygon.clear();
for (std::vector<IntPoint>::iterator ip = int_polygon.begin(); ip != int_polygon.end(); ++ip)
{
DoublePoint2D d2p;
d2p.x = ((double)ip->X) / factor;
d2p.y = ((double)ip->Y) / factor;
double_polygon.push_back(d2p);
}
}
开发者ID:SUTURO,项目名称:suturo_manipulation,代码行数:12,代码来源:suturo_manipulation_grasp_calculator.cpp
示例14: catch
DLL_PUBLIC void CDECL add_offset_path(ClipperLib::ClipperOffset *ptr, ClipperLib::IntPoint* path, size_t count,
ClipperLib::JoinType joinType, ClipperLib::EndType endType) {
ClipperLib::Path v = ClipperLib::Path();
for(size_t i = 0; i < count; i++) {
v.emplace(v.end(), path[i].X, path[i].Y);
}
try {
ptr->AddPath(v, joinType, endType);
} catch(ClipperLib::clipperException e) {
printf(e.what());
}
}
开发者ID:JuliaPackageMirrors,项目名称:Clipper.jl,代码行数:13,代码来源:cclipper.cpp
示例15: 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;
}
}
开发者ID:zivl,项目名称:Crush-Around,代码行数:48,代码来源:World.cpp
示例16: pathToClipperPath
ClipperLib::Path pathToClipperPath(const panda::types::Path& path)
{
ClipperLib::Path out;
auto maxVal = std::numeric_limits<ClipperLib::cInt>::max();
ClipperLib::IntPoint prevPt(maxVal, maxVal);
for (const auto& pt : path.points)
{
auto newPt = convert(pt);
if (newPt == prevPt)
continue;
out.push_back(newPt);
prevPt = newPt;
}
if (path.points.size() > 1 && path.points.back() == path.points.front())
out.pop_back();
return out;
}
开发者ID:cguebert,项目名称:Panda,代码行数:18,代码来源:ClipperUtils.cpp
示例17: rebuildCoordinate
void BooleanTool::rebuildCoordinate(
ClipperLib::Path::size_type index,
const ClipperLib::Path& polygon,
const PolyMap& polymap,
PathObject* object,
bool start_new_part)
{
MapCoord coord(0.001 * polygon.at(index).X, 0.001 * polygon.at(index).Y);
if (polymap.contains(polygon.at(index)))
{
PathCoordInfo info = polymap.value(polygon.at(index));
MapCoord& original = info.first->path->getCoordinate(info.second->index);
if (original.isDashPoint())
coord.setDashPoint(true);
}
object->addCoordinate(coord, start_new_part);
}
开发者ID:kshji,项目名称:mapper,代码行数:18,代码来源:tool_boolean.cpp
示例18: createPathFromBoundingBox
ClipperLib::Path ElementGeometryClipper::createPathFromBoundingBox()
{
double xMin = quadKeyBbox_.minPoint.longitude, yMin = quadKeyBbox_.minPoint.latitude,
xMax = quadKeyBbox_.maxPoint.longitude, yMax = quadKeyBbox_.maxPoint.latitude;
ClipperLib::Path rect;
rect.push_back(ClipperLib::IntPoint(static_cast<ClipperLib::cInt>(xMin*Scale),
static_cast<ClipperLib::cInt>(yMin*Scale)));
rect.push_back(ClipperLib::IntPoint(static_cast<ClipperLib::cInt>(xMax*Scale),
static_cast<ClipperLib::cInt>(yMin*Scale)));
rect.push_back(ClipperLib::IntPoint(static_cast<ClipperLib::cInt>(xMax*Scale),
static_cast<ClipperLib::cInt>(yMax*Scale)));
rect.push_back(ClipperLib::IntPoint(static_cast<ClipperLib::cInt>(xMin*Scale),
static_cast<ClipperLib::cInt>(yMax*Scale)));
return std::move(rect);
}
开发者ID:realwindz,项目名称:utymap,代码行数:18,代码来源:ElementGeometryClipper.cpp
示例19: clipperPathToPath
panda::types::Path clipperPathToPath(const ClipperLib::Path& path)
{
panda::types::Path out;
if (path.empty())
return out;
for (const auto& pt : path)
out.points.push_back(convert(pt));
if (out.points.front() != out.points.back())
out.points.push_back(out.points.front());
return out;
}
开发者ID:cguebert,项目名称:Panda,代码行数:11,代码来源:ClipperUtils.cpp
示例20: fromClipperPath
static GeometryCoordinates fromClipperPath(const ClipperLib::Path& path) {
GeometryCoordinates result;
result.reserve(path.size() + 1);
result.reserve(path.size());
for (const auto& p : path) {
using Coordinate = GeometryCoordinates::coordinate_type;
assert(p.x >= std::numeric_limits<Coordinate>::min());
assert(p.x <= std::numeric_limits<Coordinate>::max());
assert(p.y >= std::numeric_limits<Coordinate>::min());
assert(p.y <= std::numeric_limits<Coordinate>::max());
result.emplace_back(Coordinate(p.x), Coordinate(p.y));
}
// Clipper does not repeat initial point, but our geometry model requires it.
if (!result.empty()) {
result.push_back(result.front());
}
return result;
}
开发者ID:calendreco,项目名称:mapbox-gl-native,代码行数:21,代码来源:geometry_tile.cpp
注:本文中的clipperlib::Path类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论