本文整理汇总了C++中Area::GetFileOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ Area::GetFileOffset方法的具体用法?C++ Area::GetFileOffset怎么用?C++ Area::GetFileOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Area
的用法示例。
在下文中一共展示了Area::GetFileOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TryMerge
bool MergeAreasGenerator::TryMerge(const std::unordered_set<Id>& nodeUseMap,
Area& area,
std::unordered_map<Id,std::set<AreaRef> >& idAreaMap,
std::set<Id>& finishedIds,
std::unordered_set<FileOffset>& mergedAway)
{
for (const auto& ring: area.rings) {
if (!ring.IsOuterRing()) {
continue;
}
std::unordered_set<Id> nodeIds;
std::set<AreaRef> visitedAreas; // It is possible that two areas intersect in multiple nodes, to avoid multiple merge tests, we monitor the visited areas
for (const auto node : ring.nodes) {
Id id=node.GetId();
if(finishedIds.find(id)!=finishedIds.end()) {
continue;
}
// node already occurred
if (nodeIds.find(id)!=nodeIds.end()) {
continue;
}
// Track, that we visited this node
nodeIds.insert(id);
// Uninteresting node
if (nodeUseMap.find(id)==nodeUseMap.end()) {
continue;
}
// We now have an node id other areas with the same node id exist for.
// Let's take a look at all these candidates
std::set<AreaRef>::iterator candidate=idAreaMap[id].begin();
while (candidate!=idAreaMap[id].end()) {
AreaRef candidateArea(*candidate);
// We only merge against "simple" areas
if (candidateArea->rings.size()!=1) {
candidate++;
continue;
}
// The area itself => skip
if (area.GetFileOffset()==candidateArea->GetFileOffset()) {
// TODO: Should not happen?
candidate++;
continue;
}
// Already visited during this merge => skip
if (visitedAreas.find(candidateArea)!=visitedAreas.end()) {
candidate++;
continue;
}
// Area was already merged before => skip
if (mergedAway.find(candidateArea->GetFileOffset())!=mergedAway.end()) {
// TODO: Should not happen?
candidate++;
continue;
}
// Flag as visited (the areas might be registered for other
// nodes shared by both areas, too) and we not want to
// analyze it again
visitedAreas.insert(candidateArea);
size_t firstOuterRing=GetFirstOuterRingWithId(area,
id);
size_t secondOuterRing=GetFirstOuterRingWithId(*candidateArea,
id);
if (area.rings[firstOuterRing].GetFeatureValueBuffer()!=candidateArea->rings[secondOuterRing].GetFeatureValueBuffer()) {
//std::cout << "CANNOT merge areas " << area.GetFileOffset() << " and " << candidateArea->GetFileOffset() << " because of different feature values" << std::endl;
candidate++;
continue;
}
// Yes, we can merge!
PolygonMerger merger;
merger.AddPolygon(area.rings[firstOuterRing].nodes);
merger.AddPolygon(candidateArea->rings[secondOuterRing].nodes);
std::list<PolygonMerger::Polygon> result;
if (merger.Merge(result)) {
if (result.size()==1) {
//std::cout << "MERGE areas " << area.GetFileOffset() << " and " << candidateArea->GetFileOffset() << std::endl;
area.rings[firstOuterRing].nodes=result.front().coords;
//.........这里部分代码省略.........