MCPcopy Create free account
hub / github.com/assimp/assimp / InternReadFile

Method InternReadFile

code/AssetLib/X3D/X3DImporter.cpp:266–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266void X3DImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
267 mpIOHandler = pIOHandler;
268
269 Clear();
270 std::stringstream ss = ConvertVrmlFileToX3dXmlFile(pFile);
271 const bool isReadFromMem{ ss.str().length() > 0 };
272 if (!isReadFromMem) {
273 std::shared_ptr<IOStream> stream(pIOHandler->Open(pFile, "rb"));
274 if (!stream) {
275 throw DeadlyImportError("Could not open file for reading");
276 }
277 }
278 std::string::size_type slashPos = pFile.find_last_of("\\/");
279
280 mScene = pScene;
281 pScene->mRootNode = new aiNode(pFile);
282 pScene->mRootNode->mParent = nullptr;
283 pScene->mFlags |= AI_SCENE_FLAGS_ALLOW_SHARED;
284
285 if (isReadFromMem) {
286 ParseFile(ss);
287 } else {
288 pIOHandler->PushDirectory(slashPos == std::string::npos ? std::string() : pFile.substr(0, slashPos + 1));
289 ParseFile(pFile, pIOHandler);
290 pIOHandler->PopDirectory();
291 }
292
293 //search for root node element
294
295 mNodeElementCur = NodeElement_List.front();
296 if (mNodeElementCur == nullptr) {
297 return;
298 }
299 while (mNodeElementCur->Parent != nullptr) {
300 mNodeElementCur = mNodeElementCur->Parent;
301 }
302
303 { // fill aiScene with objects.
304 std::list<aiMesh *> mesh_list;
305 std::list<aiMaterial *> mat_list;
306 std::list<aiLight *> light_list;
307
308 // create nodes tree
309 Postprocess_BuildNode(*mNodeElementCur, *pScene->mRootNode, mesh_list, mat_list, light_list);
310 // copy needed data to scene
311 if (!mesh_list.empty()) {
312 std::list<aiMesh *>::const_iterator it = mesh_list.begin();
313
314 pScene->mNumMeshes = static_cast<unsigned int>(mesh_list.size());
315 pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
316 for (size_t i = 0; i < pScene->mNumMeshes; i++)
317 pScene->mMeshes[i] = *it++;
318 }
319
320 if (!mat_list.empty()) {
321 std::list<aiMaterial *>::const_iterator it = mat_list.begin();
322
323 pScene->mNumMaterials = static_cast<unsigned int>(mat_list.size());

Callers

nothing calls this directly

Calls 11

DeadlyImportErrorFunction · 0.85
strMethod · 0.80
ClearFunction · 0.50
OpenMethod · 0.45
PushDirectoryMethod · 0.45
PopDirectoryMethod · 0.45
frontMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected