本文整理汇总了C++中Path2d::boundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ Path2d::boundingBox方法的具体用法?C++ Path2d::boundingBox怎么用?C++ Path2d::boundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path2d
的用法示例。
在下文中一共展示了Path2d::boundingBox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blocks
BlocksInfo blocks(const std::vector<Path2d>& boundaries, double side, bool oddeven)
{
std::vector<Path2d> paths;
std::vector<Path2d> grid;
int h, w;
int x0, y0, x1, y1;
P2d p0, p1, po, pa, pb;
for (int j=0,m=boundaries.size(); j<m; j++)
{
Path2d path = boundaries[j] / side;
path.boundingBox(p0, p1, j!=0);
paths.push_back(path);
}
x0 = int(floor(p0.x - side));
y0 = int(floor(p0.y - side));
x1 = int(ceil(p1.x + side));
y1 = int(ceil(p1.y + side));
po.x = x0;
po.y = y0;
for (int j=0,m=paths.size(); j<m; j++)
{
paths[j] -= po; /* align to image origin */
}
w = x1 - x0;
h = y1 - y0;
Image<int> image(w, h);
image.fastBox(0, 0, w, h, 0); /* zero fill */
if (oddeven) {
polyFill(image, 1, paths);
polyDraw(image, 1, paths);
} else {
/* vogliamo solo marcare le aree coperte dai perimetri esterni
* senza considerare eventuali fori */
std::vector<Path2d> spath(1);
for (int j=0,m=paths.size(); j<m; j++)
{
spath[0] = paths[j];
polyFill(image, 1, spath);
polyDraw(image, 1, spath);
}
}
paths.clear();
int num=0;
for(int x=-1; x<w; ++x) {
for (int y=-1; y<h; ++y) {
if (image.pixel(x, y, 0) != 0)
{
std::vector<P2d> points;
pa.x = (x0 + x) * side;
pa.y = (y0 + y) * side;
pb.x = pa.x;
pb.y = pa.y + side;
points.push_back(pa);
points.push_back(pb);
pa.x = pb.x + side;
pa.y = pb.y;
points.push_back(pa);
pb.x = pa.x;
pb.y = pa.y - side;
points.push_back(pb);
pa.x = pb.x - side;
pa.y = pb.y;
points.push_back(pa);
Path2d block(points);
grid.push_back(block);
num++;
}
/* due pixel accanto diversi*/
if (image.pixel(x, y, 0) != image.pixel(x+1, y, 0)) {
std::vector<P2d> points;
pa.x = (x0 + x + 1) * side;
pa.y = (y0 + y) * side;
pb.x = pa.x;
pb.y = pa.y + side;
points.push_back(pa);
points.push_back(pb);
Path2d block(points);
paths.push_back(block);
/* due pixel uno sopra l'altro diversi*/
}
if (image.pixel(x, y, 0) != image.pixel(x, y+1, 0)) {
std::vector<P2d> points;
pa.x = (x0 + x) * side;
pa.y = (y0 + y + 1) * side;
pb.x = pa.x + side;
pb.y = pa.y;
points.push_back(pa);
points.push_back(pb);
Path2d block(points);
paths.push_back(block);
}
}
}
//.........这里部分代码省略.........