Merge pull request #4293 from assimp/add_colsole_progresshandler_issue_963
Add console progresshandlerpull/4292/head^2
commit
54a8da1d55
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2021, assimp team
|
Copyright (c) 2006-2021, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -51,15 +50,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
/** @brief Internal default implementation of the #ProgressHandler interface. */
|
/**
|
||||||
|
* @brief Internal default implementation of the #ProgressHandler interface.
|
||||||
|
*/
|
||||||
class DefaultProgressHandler : public ProgressHandler {
|
class DefaultProgressHandler : public ProgressHandler {
|
||||||
|
public:
|
||||||
virtual bool Update(float /*percentage*/) {
|
/// @brief Ignores the update callback.
|
||||||
|
bool Update(float) override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}; // !class DefaultProgressHandler
|
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
||||||
#endif
|
#endif // INCLUDED_AI_DEFAULTPROGRESSHANDLER_H
|
||||||
|
|
|
@ -329,7 +329,7 @@ bool Importer::IsDefaultIOHandler() const {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Supplies a custom progress handler to get regular callbacks during importing
|
// Supplies a custom progress handler to get regular callbacks during importing
|
||||||
void Importer::SetProgressHandler ( ProgressHandler* pHandler ) {
|
void Importer::SetProgressHandler(ProgressHandler* pHandler) {
|
||||||
ai_assert(nullptr != pimpl);
|
ai_assert(nullptr != pimpl);
|
||||||
|
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
|
|
|
@ -74,6 +74,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
/// @brief Virtual destructor.
|
/// @brief Virtual destructor.
|
||||||
virtual ~ProgressHandler () {
|
virtual ~ProgressHandler () {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2021, assimp team
|
Copyright (c) 2006-2021, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -47,6 +45,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "Main.h"
|
#include "Main.h"
|
||||||
|
|
||||||
|
#include <assimp/ProgressHandler.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
class ConsoleProgressHandler : public ProgressHandler {
|
||||||
|
public:
|
||||||
|
ConsoleProgressHandler() :
|
||||||
|
ProgressHandler() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
~ConsoleProgressHandler() override {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Update(float percentage) override {
|
||||||
|
std::cout << percentage * 100.0f << " %\n";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
const char* AICMD_MSG_ABOUT =
|
const char* AICMD_MSG_ABOUT =
|
||||||
"------------------------------------------------------ \n"
|
"------------------------------------------------------ \n"
|
||||||
"Open Asset Import Library (\"Assimp\", https://github.com/assimp/assimp) \n"
|
"Open Asset Import Library (\"Assimp\", https://github.com/assimp/assimp) \n"
|
||||||
|
@ -73,10 +90,10 @@ const char* AICMD_MSG_HELP =
|
||||||
"\n Use \'assimp <verb> --help\' for detailed help on a command.\n"
|
"\n Use \'assimp <verb> --help\' for detailed help on a command.\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
/*extern*/ Assimp::Importer* globalImporter = NULL;
|
/*extern*/ Assimp::Importer* globalImporter = nullptr;
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
/*extern*/ Assimp::Exporter* globalExporter = NULL;
|
/*extern*/ Assimp::Exporter* globalExporter = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
@ -286,6 +303,9 @@ const aiScene* ImportModel(
|
||||||
|
|
||||||
// do the actual import, measure time
|
// do the actual import, measure time
|
||||||
const clock_t first = clock();
|
const clock_t first = clock();
|
||||||
|
ConsoleProgressHandler *ph = new ConsoleProgressHandler;
|
||||||
|
globalImporter->SetProgressHandler(ph);
|
||||||
|
|
||||||
const aiScene* scene = globalImporter->ReadFile(path,imp.ppFlags);
|
const aiScene* scene = globalImporter->ReadFile(path,imp.ppFlags);
|
||||||
|
|
||||||
if (imp.showLog) {
|
if (imp.showLog) {
|
||||||
|
@ -305,6 +325,9 @@ const aiScene* ImportModel(
|
||||||
if (imp.log) {
|
if (imp.log) {
|
||||||
FreeLogStreams();
|
FreeLogStreams();
|
||||||
}
|
}
|
||||||
|
globalImporter->SetProgressHandler(nullptr);
|
||||||
|
delete ph;
|
||||||
|
|
||||||
return scene;
|
return scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue