construct a scene object
| 87 | |
| 88 | // construct a scene object |
| 89 | SceneLoad::Result construct() const |
| 90 | { |
| 91 | auto scene = std::make_shared<SceneRootObject>(); |
| 92 | |
| 93 | bool constructed; |
| 94 | if ( loadedObjects_.size() == 1 ) |
| 95 | { |
| 96 | const auto& object = loadedObjects_.front(); |
| 97 | auto typeName = std::string( object->typeName() ); |
| 98 | if ( typeName == SceneRootObject::StaticTypeName() || ( typeName == Object::StaticTypeName() && object->xf() == AffineXf3f() ) ) |
| 99 | { |
| 100 | scene = createRootFormObject( object ); |
| 101 | constructed = false; |
| 102 | } |
| 103 | else |
| 104 | { |
| 105 | constructed = true; |
| 106 | scene->addChild( object ); |
| 107 | } |
| 108 | } |
| 109 | else |
| 110 | { |
| 111 | constructed = true; |
| 112 | for ( const auto& object : loadedObjects_ ) |
| 113 | scene->addChild( object ); |
| 114 | } |
| 115 | |
| 116 | SceneLoad::Result ret{ |
| 117 | .scene = std::move( scene ), |
| 118 | .isSceneConstructed = constructed, |
| 119 | .loadedFiles = loadedFiles_, |
| 120 | .errorSummary = errorSummary_.str(), |
| 121 | .warningSummary = warningSummary_.str(), |
| 122 | }; |
| 123 | |
| 124 | if ( ret.loadedFiles.empty() ) |
| 125 | ret.scene = nullptr; // Don't emit the root object on failure. |
| 126 | else |
| 127 | { |
| 128 | // If something is loaded, consider errors as warnings |
| 129 | if ( !ret.errorSummary.empty() ) |
| 130 | { |
| 131 | if ( ret.warningSummary.empty() ) |
| 132 | ret.warningSummary = std::move( ret.errorSummary ); |
| 133 | else |
| 134 | { |
| 135 | ret.warningSummary += "\n\n"; |
| 136 | ret.warningSummary += ret.errorSummary; |
| 137 | } |
| 138 | ret.errorSummary.clear(); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | return ret; |
| 143 | } |
| 144 | |
| 145 | private: |
| 146 | const std::optional<LengthUnit> targetUnit_; |
no test coverage detected