本文整理汇总了C++中box2d::intersect方法的典型用法代码示例。如果您正苦于以下问题:C++ box2d::intersect方法的具体用法?C++ box2d::intersect怎么用?C++ box2d::intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类box2d
的用法示例。
在下文中一共展示了box2d::intersect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: info
tiled_multi_file_policy(std::string const& file_pattern,
std::string const& format,
unsigned tile_size,
box2d<double> extent,
box2d<double> bbox,
unsigned width,
unsigned height,
unsigned tile_stride)
: image_width_(width),
image_height_(height),
tile_size_(tile_size),
tile_stride_(tile_stride)
{
double lox = extent.minx();
double loy = extent.miny();
//int max_x = int(std::ceil(double(width) / double(tile_size)));
//int max_y = int(std::ceil(double(height) / double(tile_size)));
double pixel_x = extent.width() / double(width);
double pixel_y = extent.height() / double(height);
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: PIXEL SIZE("<< pixel_x << "," << pixel_y << ")" << std::endl;
#endif
// intersection of query with extent => new query
box2d<double> e = bbox.intersect(extent);
const int x_min = int(std::floor((e.minx() - lox) / (tile_size * pixel_x)));
const int y_min = int(std::floor((e.miny() - loy) / (tile_size * pixel_y)));
const int x_max = int(std::ceil((e.maxx() - lox) / (tile_size * pixel_x)));
const int y_max = int(std::ceil((e.maxy() - loy) / (tile_size * pixel_y)));
for (int x = x_min; x < x_max; ++x)
{
for (int y = y_min; y < y_max; ++y)
{
// x0, y0, x1, y1 => projection-space image coordinates.
double x0 = lox + x*tile_size*pixel_x;
double y0 = loy + y*tile_size*pixel_y;
double x1 = x0 + tile_size*pixel_x;
double y1 = y0 + tile_size*pixel_y;
// check if it intersects the query
if (e.intersects(box2d<double>(x0,y0,x1,y1)))
{
// tile_box => intersection of tile with query in projection-space.
box2d<double> tile_box = e.intersect(box2d<double>(x0,y0,x1,y1));
std::string file = interpolate(file_pattern, x, y);
raster_info info(file,format,tile_box,tile_size,tile_size);
infos_.push_back(info);
}
}
}
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: INFO SIZE=" << infos_.size() << " " << file_pattern << std::endl;
#endif
}