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

Function ImportModel

tools/assimp_cmd/Main.cpp:281–330  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Import a specific file

Source from the content-addressed store, hash-verified

279// ------------------------------------------------------------------------------
280// Import a specific file
281const aiScene* ImportModel(
282 const ImportData& imp,
283 const std::string& path)
284{
285 // Attach log streams
286 if (imp.log) {
287 SetLogStreams(imp);
288 }
289 printf("Launching asset import ... OK\n");
290
291 // Now validate this flag combination
292 if(!globalImporter->ValidateFlags(imp.ppFlags)) {
293 printf("ERROR: Unsupported post-processing flags \n");
294 return nullptr;
295 }
296 printf("Validating postprocessing flags ... OK\n");
297 if (imp.showLog) {
298 PrintHorBar();
299 }
300
301
302 // do the actual import, measure time
303 const clock_t first = clock();
304 ConsoleProgressHandler *ph = new ConsoleProgressHandler;
305 globalImporter->SetProgressHandler(ph);
306
307 const aiScene* scene = globalImporter->ReadFile(path,imp.ppFlags);
308
309 if (imp.showLog) {
310 PrintHorBar();
311 }
312 if (!scene) {
313 printf("ERROR: Failed to load file: %s\n", globalImporter->GetErrorString());
314 return nullptr;
315 }
316
317 const clock_t second = ::clock();
318 const double seconds = static_cast<double>(second-first) / CLOCKS_PER_SEC;
319
320 printf("Importing file ... OK \n import took approx. %.5f seconds\n"
321 "\n",seconds);
322
323 if (imp.log) {
324 FreeLogStreams();
325 }
326 globalImporter->SetProgressHandler(nullptr);
327 delete ph;
328
329 return scene;
330}
331
332#ifndef ASSIMP_BUILD_NO_EXPORT
333// ------------------------------------------------------------------------------

Callers 4

Assimp_InfoFunction · 0.85
Assimp_ExportFunction · 0.85
Assimp_ExtractFunction · 0.85
Assimp_DumpFunction · 0.85

Calls 7

SetLogStreamsFunction · 0.85
PrintHorBarFunction · 0.85
FreeLogStreamsFunction · 0.85
ValidateFlagsMethod · 0.80
SetProgressHandlerMethod · 0.45
ReadFileMethod · 0.45
GetErrorStringMethod · 0.45

Tested by

no test coverage detected