void IntersectionInfoCache::makePolygonDrawData(std::vector<GeoLocation>& vecPoints, std::vector<uint16>& triangleIndexList, uint8 drawelement, //多边形描画数据 vector<IntersectionImageData>& imageData) { std::vector<PolygonTessVertex> points; uint32 pointcount = vecPoints.size(); points.reserve(pointcount); for(int32 i = 0;i < pointcount;++i) { PolygonTessVertex m_point; m_point.vertex.x = vecPoints[i].longitude; m_point.vertex.y = vecPoints[i].latitude; points.emplace_back(m_point); } TessPolygon(points, triangleIndexList); std::vector<GeoLocation> vecTessPoints; uint32 pointcountTess = points.size(); vecTessPoints.reserve(pointcountTess); for(int32 i = 0;i < pointcountTess;++i) { GeoLocation m_point; m_point.longitude = points[i].vertex.x; m_point.latitude = points[i].vertex.y; vecTessPoints.emplace_back(m_point); } IntersectionImageData tempimagedata; tempimagedata.drawelement = drawelement; tempimagedata.vertex.assign(vecTessPoints.begin(), vecTessPoints.end()); tempimagedata.index.assign(triangleIndexList.begin(), triangleIndexList.end()); imageData.emplace_back(tempimagedata); }加上注释
时间: 2024-04-07 09:32:53 浏览: 182
以下是对该段代码的注释:
```cpp
void IntersectionInfoCache::makePolygonDrawData(std::vector<GeoLocation>& vecPoints, std::vector<uint16>& triangleIndexList, uint8 drawelement, vector<IntersectionImageData>& imageData) {
// 存储多边形顶点的数组
std::vector<PolygonTessVertex> points;
uint32 pointcount = vecPoints.size();
points.reserve(pointcount);
// 将多边形顶点数组转换为Tessellation算法所需的点数组
for (int32 i = 0; i < pointcount; ++i) {
PolygonTessVertex m_point;
m_point.vertex.x = vecPoints[i].longitude;
m_point.vertex.y = vecPoints[i].latitude;
points.emplace_back(m_point);
}
// 对多边形进行Tessellation
TessPolygon(points, triangleIndexList);
// 存储Tessellation后的顶点数组
std::vector<GeoLocation> vecTessPoints;
uint32 pointcountTess = points.size();
vecTessPoints.reserve(pointcountTess);
// 将Tessellation后的点数组转换为GeoLocation类型的数组
for (int32 i = 0; i < pointcountTess; ++i) {
GeoLocation m_point;
m_point.longitude = points[i].vertex.x;
m_point.latitude = points[i].vertex.y;
vecTessPoints.emplace_back(m_point);
}
// 存储多边形描画数据
IntersectionImageData tempimagedata;
tempimagedata.drawelement = drawelement;
tempimagedata.vertex.assign(vecTessPoints.begin(), vecTessPoints.end());
tempimagedata.index.assign(triangleIndexList.begin(), triangleIndexList.end());
imageData.emplace_back(tempimagedata);
}
```
注释中解释了该函数的实现过程,主要实现是将多边形顶点数组转换为Tessellation算法所需的点数组,然后对多边形进行Tessellation,将Tessellation后的点数组转换为GeoLocation类型的数组,最后将多边形描画数据存储到IntersectionImageData结构体中,然后将结构体存储到imageData数组中。
阅读全文