| 16 | {} |
| 17 | |
| 18 | RootNodePtr MapResourceLoader::load() |
| 19 | { |
| 20 | // Create a new map root node |
| 21 | auto root = std::make_shared<RootNode>(""); |
| 22 | |
| 23 | try |
| 24 | { |
| 25 | // Our importer taking care of scene insertion |
| 26 | MapImporter importFilter(root, _stream); |
| 27 | |
| 28 | // Acquire a map reader/parser |
| 29 | IMapReaderPtr reader = _format.getMapReader(importFilter); |
| 30 | |
| 31 | rMessage() << "Using " << _format.getMapFormatName() << " format to load the data." << std::endl; |
| 32 | |
| 33 | // Start parsing |
| 34 | reader->readFromStream(_stream); |
| 35 | |
| 36 | // Prepare child primitives |
| 37 | scene::addOriginToChildPrimitives(root); |
| 38 | |
| 39 | // Move the index mapping to this class before destroying the import filter |
| 40 | _indexMapping.swap(importFilter.getNodeMap()); |
| 41 | |
| 42 | return root; |
| 43 | } |
| 44 | catch (FileOperation::OperationCancelled&) |
| 45 | { |
| 46 | // Clear out the root node, otherwise we end up with half a map |
| 47 | scene::NodeRemover remover; |
| 48 | root->traverseChildren(remover); |
| 49 | |
| 50 | throw IMapResource::OperationException(_("Map loading cancelled"), true); // cancelled flag set |
| 51 | } |
| 52 | catch (IMapReader::FailureException& e) |
| 53 | { |
| 54 | // Clear out the root node, otherwise we end up with half a map |
| 55 | scene::NodeRemover remover; |
| 56 | root->traverseChildren(remover); |
| 57 | |
| 58 | // Convert the exception, pass the same message |
| 59 | throw IMapResource::OperationException(e.what()); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | void MapResourceLoader::loadInfoFile(std::istream& stream, const RootNodePtr& root) |
| 64 | { |
nothing calls this directly
no test coverage detected