------------------------------------------------------------------------------ Import a specific file
| 279 | // ------------------------------------------------------------------------------ |
| 280 | // Import a specific file |
| 281 | const 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 | // ------------------------------------------------------------------------------ |
no test coverage detected