当前位置: 首页>>代码示例>>C++>>正文


C++ BBox::addPoint方法代码示例

本文整理汇总了C++中BBox::addPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ BBox::addPoint方法的具体用法?C++ BBox::addPoint怎么用?C++ BBox::addPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BBox的用法示例。


在下文中一共展示了BBox::addPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: trimRoads

void ControlWidget::trimRoads() {
	BBox bbox;
	bbox.addPoint(QVector2D(mainWin->glWidget->vboRenderManager.minPos.x() + 20, mainWin->glWidget->vboRenderManager.minPos.y() + 20));
	bbox.addPoint(QVector2D(mainWin->glWidget->vboRenderManager.maxPos.x() - 20, mainWin->glWidget->vboRenderManager.maxPos.y() - 20));
	Polygon2D polygon;
	boost::geometry::convert(bbox, polygon);
	GraphUtil::trim(mainWin->urbanGeometry->roads, polygon);

	mainWin->urbanGeometry->update(mainWin->glWidget->vboRenderManager);
	mainWin->glWidget->updateGL();
}
开发者ID:gnishida,项目名称:ExRoadDesigner,代码行数:11,代码来源:ControlWidget.cpp

示例2: saveRoadImage

void PMRoadGenerator::saveRoadImage(RoadGraph& roads, const std::string& filename) {
	BBox bbox;
	RoadVertexIter vi, vend;
	for (boost::tie(vi, vend) = boost::vertices(roads.graph); vi != vend; ++vi) {
		if (!roads.graph[*vi]->valid) continue;

		bbox.addPoint(roads.graph[*vi]->pt);
	}

	cv::Mat result((int)(bbox.dy() + 1), (int)(bbox.dx() + 1), CV_8UC3, cv::Scalar(255, 255, 255));

	RoadEdgeIter ei, eend;
	for (boost::tie(ei, eend) = boost::edges(roads.graph); ei != eend; ++ei) {
		if (!roads.graph[*ei]->valid) continue;

		for (int k = 0; k < roads.graph[*ei]->polyline.size() - 1; ++k) {
			int x1 = roads.graph[*ei]->polyline[k].x() - bbox.minPt.x();
			int y1 = roads.graph[*ei]->polyline[k].y() - bbox.minPt.y();
			int x2 = roads.graph[*ei]->polyline[k + 1].x() - bbox.minPt.x();
			int y2 = roads.graph[*ei]->polyline[k + 1].y() - bbox.minPt.y();

			cv::line(result, cv::Point(x1, y1), cv::Point(x2, y2), cv::Scalar(0, 0, 0), 1, cv::LINE_AA);
		}
	}

	for (boost::tie(vi, vend) = boost::vertices(roads.graph); vi != vend; ++vi) {
		if (!roads.graph[*vi]->valid) continue;

		int count = 0;
		RoadOutEdgeIter oi, oend;
		for (boost::tie(oi, oend) = boost::out_edges(*vi, roads.graph); oi != oend; ++oi) {
			if (roads.graph[*oi]->valid) count++;
		}

		if (count == 2) continue;

		int x = roads.graph[*vi]->pt.x() - bbox.minPt.x();
		int y = roads.graph[*vi]->pt.y() - bbox.minPt.x();
		cv::circle(result, cv::Point(x, y), 5, cv::Scalar(255, 0, 0), 1, cv::LINE_AA);

		QString text = QString::number(count);
		cv::putText(result, text.toUtf8().constData(), cv::Point(x, y), cv::FONT_HERSHEY_PLAIN, 2, cv::Scalar(0, 0, 0), 1, cv::LINE_AA);
	}

	cv::imwrite(filename.c_str(), result);
}
开发者ID:gnishida,项目名称:SimpleCities,代码行数:46,代码来源:PMRoadGenerator.cpp


注:本文中的BBox::addPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。