本文整理汇总了C++中ImportParameter::GetRawNodeDataMemoryMaped方法的典型用法代码示例。如果您正苦于以下问题:C++ ImportParameter::GetRawNodeDataMemoryMaped方法的具体用法?C++ ImportParameter::GetRawNodeDataMemoryMaped怎么用?C++ ImportParameter::GetRawNodeDataMemoryMaped使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImportParameter
的用法示例。
在下文中一共展示了ImportParameter::GetRawNodeDataMemoryMaped方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Import
bool NodeDataGenerator::Import(const TypeConfigRef& typeConfig,
const ImportParameter& parameter,
Progress& progress)
{
uint32_t rawNodeCount=0;
uint32_t nodesReadCount=0;
uint32_t nodesWrittenCount=0;
//
// Iterator over all raw nodes, hcekc they type, and convert them from raw nodes
// to nodes if the type is interesting (!=typeIgnore).
//
// Count the bounding box by the way...
//
progress.SetAction("Generating nodes.tmp");
FileScanner scanner;
FileWriter writer;
if (!scanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
"rawnodes.dat"),
FileScanner::Sequential,
parameter.GetRawNodeDataMemoryMaped())) {
progress.Error("Cannot open 'rawnodes.dat'");
return false;
}
if (!scanner.Read(rawNodeCount)) {
progress.Error("Error while reading number of data entries in file");
return false;
}
if (!writer.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
"nodes.tmp"))) {
progress.Error("Cannot create 'nodes.tmp'");
return false;
}
writer.Write(nodesWrittenCount);
for (uint32_t n=1; n<=rawNodeCount; n++) {
progress.SetProgress(n,rawNodeCount);
RawNode rawNode;
Node node;
if (!rawNode.Read(typeConfig,
scanner)) {
progress.Error(std::string("Error while reading data entry ")+
NumberToString(n)+" of "+
NumberToString(rawNodeCount)+
" in file '"+
scanner.GetFilename()+"'");
return false;
}
nodesReadCount++;
if (!rawNode.GetType()->GetIgnore()) {
node.SetFeatures(rawNode.GetFeatureValueBuffer());
node.SetCoords(rawNode.GetCoords());
FileOffset fileOffset;
if (!writer.GetPos(fileOffset)) {
progress.Error(std::string("Error while reading current fileOffset in file '")+
writer.GetFilename()+"'");
return false;
}
writer.Write(rawNode.GetId());
node.Write(typeConfig,
writer);
nodesWrittenCount++;
}
}
if (!scanner.Close()) {
return false;
}
writer.SetPos(0);
writer.Write(nodesWrittenCount);
if (!writer.Close()) {
return false;
}
progress.Info(std::string("Read "+NumberToString(nodesReadCount)+" nodes, wrote "+NumberToString(nodesWrittenCount)+" nodes"));
return true;
}