Add first version of the planned progress feedback API to the public Cpp API. Currently, progress reporting is done between each major import stage.
Fix various issues with the vc9 solution and assimp_cmd. Declare some more Importer methods const. This marks them as safe to use from within a progress callback. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@806 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
2f71990dc2
commit
c5c5338397
|
@ -52,6 +52,7 @@ using namespace Assimp;
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
BaseImporter::BaseImporter()
|
BaseImporter::BaseImporter()
|
||||||
|
: progress()
|
||||||
{
|
{
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
}
|
}
|
||||||
|
@ -65,9 +66,15 @@ BaseImporter::~BaseImporter()
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file and returns the imported data.
|
// Imports the given file and returns the imported data.
|
||||||
aiScene* BaseImporter::ReadFile( const std::string& pFile, IOSystem* pIOHandler)
|
aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
// Construct a file system filter to improve our success ratio reading external files
|
progress = pImp->GetProgressHandler();
|
||||||
|
ai_assert(progress);
|
||||||
|
|
||||||
|
// Gather configuration properties for this run
|
||||||
|
SetupProperties( pImp );
|
||||||
|
|
||||||
|
// Construct a file system filter to improve our success ratio at reading external files
|
||||||
FileSystemFilter filter(pFile,pIOHandler);
|
FileSystemFilter filter(pFile,pIOHandler);
|
||||||
|
|
||||||
// create a scene object to hold the data
|
// create a scene object to hold the data
|
||||||
|
|
|
@ -121,6 +121,10 @@ public:
|
||||||
IOSystem* mIOHandler;
|
IOSystem* mIOHandler;
|
||||||
bool mIsDefaultHandler;
|
bool mIsDefaultHandler;
|
||||||
|
|
||||||
|
/** Progress handler for feedback. */
|
||||||
|
ProgressHandler* mProgressHandler;
|
||||||
|
bool mIsDefaultProgressHandler;
|
||||||
|
|
||||||
/** Format-specific importer worker objects - one for each format we can read.*/
|
/** Format-specific importer worker objects - one for each format we can read.*/
|
||||||
std::vector<BaseImporter*> mImporter;
|
std::vector<BaseImporter*> mImporter;
|
||||||
|
|
||||||
|
@ -205,6 +209,7 @@ public:
|
||||||
* takes care that any partially constructed data is destroyed
|
* takes care that any partially constructed data is destroyed
|
||||||
* beforehand.
|
* beforehand.
|
||||||
*
|
*
|
||||||
|
* @param pImp #Importer object hosting this loader.
|
||||||
* @param pFile Path of the file to be imported.
|
* @param pFile Path of the file to be imported.
|
||||||
* @param pIOHandler IO-Handler used to open this and possible other files.
|
* @param pIOHandler IO-Handler used to open this and possible other files.
|
||||||
* @return The imported data or NULL if failed. If it failed a
|
* @return The imported data or NULL if failed. If it failed a
|
||||||
|
@ -217,6 +222,7 @@ public:
|
||||||
* a suitable response to the caller.
|
* a suitable response to the caller.
|
||||||
*/
|
*/
|
||||||
aiScene* ReadFile(
|
aiScene* ReadFile(
|
||||||
|
const Importer* pImp,
|
||||||
const std::string& pFile,
|
const std::string& pFile,
|
||||||
IOSystem* pIOHandler
|
IOSystem* pIOHandler
|
||||||
);
|
);
|
||||||
|
@ -396,6 +402,9 @@ protected:
|
||||||
|
|
||||||
/** Error description in case there was one. */
|
/** Error description in case there was one. */
|
||||||
std::string mErrorText;
|
std::string mErrorText;
|
||||||
|
|
||||||
|
/** Currently set progress handler */
|
||||||
|
ProgressHandler* progress;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BatchData;
|
struct BatchData;
|
||||||
|
|
|
@ -50,8 +50,9 @@ using namespace Assimp;
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
BaseProcess::BaseProcess()
|
BaseProcess::BaseProcess()
|
||||||
|
: shared()
|
||||||
|
, progress()
|
||||||
{
|
{
|
||||||
shared = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -64,7 +65,13 @@ BaseProcess::~BaseProcess()
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void BaseProcess::ExecuteOnScene( Importer* pImp)
|
void BaseProcess::ExecuteOnScene( Importer* pImp)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != pImp && NULL != pImp->pimpl->mScene)
|
ai_assert(NULL != pImp && NULL != pImp->pimpl->mScene);
|
||||||
|
|
||||||
|
progress = pImp->GetProgressHandler();
|
||||||
|
ai_assert(progress);
|
||||||
|
|
||||||
|
SetupProperties( pImp );
|
||||||
|
|
||||||
// catch exceptions thrown inside the PostProcess-Step
|
// catch exceptions thrown inside the PostProcess-Step
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -276,9 +276,11 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** See the doc of #SharedPostProcessInfo for more details
|
/** See the doc of #SharedPostProcessInfo for more details */
|
||||||
*/
|
|
||||||
SharedPostProcessInfo* shared;
|
SharedPostProcessInfo* shared;
|
||||||
|
|
||||||
|
/** Currently active progress handler */
|
||||||
|
ProgressHandler* progress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ SET( PUBLIC_HEADERS
|
||||||
${HEADER_PATH}/assimp.h
|
${HEADER_PATH}/assimp.h
|
||||||
${HEADER_PATH}/assimp.hpp
|
${HEADER_PATH}/assimp.hpp
|
||||||
${HEADER_PATH}/DefaultLogger.h
|
${HEADER_PATH}/DefaultLogger.h
|
||||||
|
${HEADER_PATH}/ProgressHandler.h
|
||||||
${HEADER_PATH}/IOStream.h
|
${HEADER_PATH}/IOStream.h
|
||||||
${HEADER_PATH}/IOSystem.h
|
${HEADER_PATH}/IOSystem.h
|
||||||
${HEADER_PATH}/Logger.h
|
${HEADER_PATH}/Logger.h
|
||||||
|
@ -86,6 +87,7 @@ SOURCE_GROUP( Common FILES
|
||||||
BaseProcess.h
|
BaseProcess.h
|
||||||
ByteSwap.h
|
ByteSwap.h
|
||||||
ProcessHelper.h
|
ProcessHelper.h
|
||||||
|
DefaultProgressHandler.h
|
||||||
DefaultIOStream.cpp
|
DefaultIOStream.cpp
|
||||||
DefaultIOStream.h
|
DefaultIOStream.h
|
||||||
DefaultIOSystem.cpp
|
DefaultIOSystem.cpp
|
||||||
|
@ -493,6 +495,7 @@ ADD_LIBRARY( assimp SHARED
|
||||||
DefaultIOStream.h
|
DefaultIOStream.h
|
||||||
DefaultIOSystem.cpp
|
DefaultIOSystem.cpp
|
||||||
DefaultIOSystem.h
|
DefaultIOSystem.h
|
||||||
|
DefaultProgressHandler.h
|
||||||
DefaultLogger.cpp
|
DefaultLogger.cpp
|
||||||
FileLogStream.h
|
FileLogStream.h
|
||||||
FindDegenerates.cpp
|
FindDegenerates.cpp
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
Open Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2010, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file ProgressHandler.h
|
||||||
|
* @brief Abstract base class 'ProgressHandler'.
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDED_AI_DEFAULTPROGRESSHANDLER_H
|
||||||
|
#define INCLUDED_AI_DEFAULTPROGRESSHANDLER_H
|
||||||
|
|
||||||
|
#include "../include/ProgressHandler.h"
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
/** @brief Internal default implementation of the #ProgressHandler interface. */
|
||||||
|
class ASSIMP_API DefaultProgressHandler
|
||||||
|
: public ProgressHandler {
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool Update(float percentage) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}; // !class DefaultProgressHandler
|
||||||
|
} // Namespace Assimp
|
||||||
|
|
||||||
|
#endif
|
|
@ -64,6 +64,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "BaseProcess.h"
|
#include "BaseProcess.h"
|
||||||
#include "DefaultIOStream.h"
|
#include "DefaultIOStream.h"
|
||||||
#include "DefaultIOSystem.h"
|
#include "DefaultIOSystem.h"
|
||||||
|
#include "DefaultProgressHandler.h"
|
||||||
#include "GenericProperty.h"
|
#include "GenericProperty.h"
|
||||||
#include "ProcessHelper.h"
|
#include "ProcessHelper.h"
|
||||||
#include "ScenePreprocessor.h"
|
#include "ScenePreprocessor.h"
|
||||||
|
@ -315,6 +316,9 @@ Importer::Importer()
|
||||||
pimpl->mIsDefaultHandler = true;
|
pimpl->mIsDefaultHandler = true;
|
||||||
pimpl->bExtraVerbose = false; // disable extra verbose mode by default
|
pimpl->bExtraVerbose = false; // disable extra verbose mode by default
|
||||||
|
|
||||||
|
pimpl->mProgressHandler = new DefaultProgressHandler();
|
||||||
|
pimpl->mIsDefaultProgressHandler = true;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Add an instance of each worker class here
|
// Add an instance of each worker class here
|
||||||
// (register_new_importers_here)
|
// (register_new_importers_here)
|
||||||
|
@ -623,7 +627,9 @@ aiReturn Importer::UnregisterLoader(BaseImporter* pImp)
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
std::vector<BaseImporter*>::iterator it = std::find(pimpl->mImporter.begin(),pimpl->mImporter.end(),pImp);
|
std::vector<BaseImporter*>::iterator it = std::find(pimpl->mImporter.begin(),
|
||||||
|
pimpl->mImporter.end(),pImp);
|
||||||
|
|
||||||
if (it != pimpl->mImporter.end()) {
|
if (it != pimpl->mImporter.end()) {
|
||||||
pimpl->mImporter.erase(it);
|
pimpl->mImporter.erase(it);
|
||||||
|
|
||||||
|
@ -648,7 +654,9 @@ aiReturn Importer::UnregisterPPStep(BaseProcess* pImp)
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
std::vector<BaseProcess*>::iterator it = std::find(pimpl->mPostProcessingSteps.begin(),pimpl->mPostProcessingSteps.end(),pImp);
|
std::vector<BaseProcess*>::iterator it = std::find(pimpl->mPostProcessingSteps.begin(),
|
||||||
|
pimpl->mPostProcessingSteps.end(),pImp);
|
||||||
|
|
||||||
if (it != pimpl->mPostProcessingSteps.end()) {
|
if (it != pimpl->mPostProcessingSteps.end()) {
|
||||||
pimpl->mPostProcessingSteps.erase(it);
|
pimpl->mPostProcessingSteps.erase(it);
|
||||||
DefaultLogger::get()->info("Unregistering custom post-processing step");
|
DefaultLogger::get()->info("Unregistering custom post-processing step");
|
||||||
|
@ -683,18 +691,54 @@ void Importer::SetIOHandler( IOSystem* pIOHandler)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get the currently set IO handler
|
// Get the currently set IO handler
|
||||||
IOSystem* Importer::GetIOHandler()
|
IOSystem* Importer::GetIOHandler() const
|
||||||
{
|
{
|
||||||
return pimpl->mIOHandler;
|
return pimpl->mIOHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Check whether a custom IO handler is currently set
|
// Check whether a custom IO handler is currently set
|
||||||
bool Importer::IsDefaultIOHandler()
|
bool Importer::IsDefaultIOHandler() const
|
||||||
{
|
{
|
||||||
return pimpl->mIsDefaultHandler;
|
return pimpl->mIsDefaultHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Supplies a custom progress handler to get regular callbacks during importing
|
||||||
|
void Importer::SetProgressHandler ( ProgressHandler* pHandler )
|
||||||
|
{
|
||||||
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
|
// If the new handler is zero, allocate a default implementation.
|
||||||
|
if (!pHandler)
|
||||||
|
{
|
||||||
|
// Release pointer in the possession of the caller
|
||||||
|
pimpl->mProgressHandler = new DefaultProgressHandler();
|
||||||
|
pimpl->mIsDefaultProgressHandler = true;
|
||||||
|
}
|
||||||
|
// Otherwise register the custom handler
|
||||||
|
else if (pimpl->mProgressHandler != pHandler)
|
||||||
|
{
|
||||||
|
delete pimpl->mProgressHandler;
|
||||||
|
pimpl->mProgressHandler = pHandler;
|
||||||
|
pimpl->mIsDefaultProgressHandler = false;
|
||||||
|
}
|
||||||
|
ASSIMP_END_EXCEPTION_REGION(void);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Get the currently set progress handler
|
||||||
|
ProgressHandler* Importer::GetProgressHandler() const
|
||||||
|
{
|
||||||
|
return pimpl->mProgressHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Check whether a custom progress handler is currently set
|
||||||
|
bool Importer::IsDefaultProgressHandler() const
|
||||||
|
{
|
||||||
|
return pimpl->mIsDefaultProgressHandler;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Validate post process step flags
|
// Validate post process step flags
|
||||||
bool _ValidateFlags(unsigned int pFlags)
|
bool _ValidateFlags(unsigned int pFlags)
|
||||||
|
@ -760,7 +804,7 @@ aiScene* Importer::GetOrphanedScene()
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Validate post-processing flags
|
// Validate post-processing flags
|
||||||
bool Importer::ValidateFlags(unsigned int pFlags)
|
bool Importer::ValidateFlags(unsigned int pFlags) const
|
||||||
{
|
{
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
// run basic checks for mutually exclusive flags
|
// run basic checks for mutually exclusive flags
|
||||||
|
@ -770,8 +814,9 @@ bool Importer::ValidateFlags(unsigned int pFlags)
|
||||||
|
|
||||||
// ValidateDS does not anymore occur in the pp list, it plays an awesome extra role ...
|
// ValidateDS does not anymore occur in the pp list, it plays an awesome extra role ...
|
||||||
#ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
|
#ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
|
||||||
if (pFlags & aiProcess_ValidateDataStructure)
|
if (pFlags & aiProcess_ValidateDataStructure) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
pFlags &= ~aiProcess_ValidateDataStructure;
|
pFlags &= ~aiProcess_ValidateDataStructure;
|
||||||
|
|
||||||
|
@ -789,8 +834,9 @@ bool Importer::ValidateFlags(unsigned int pFlags)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!have)
|
if (!have) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSIMP_END_EXCEPTION_REGION(bool);
|
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||||
|
@ -953,13 +999,14 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
|
||||||
|
|
||||||
// Dispatch the reading to the worker class for this format
|
// Dispatch the reading to the worker class for this format
|
||||||
DefaultLogger::get()->info("Found a matching importer for this file format");
|
DefaultLogger::get()->info("Found a matching importer for this file format");
|
||||||
|
pimpl->mProgressHandler->Update();
|
||||||
|
|
||||||
if (profiler) {
|
if (profiler) {
|
||||||
profiler->BeginRegion("import");
|
profiler->BeginRegion("import");
|
||||||
}
|
}
|
||||||
|
|
||||||
imp->SetupProperties( this );
|
pimpl->mScene = imp->ReadFile( this, pFile, pimpl->mIOHandler);
|
||||||
pimpl->mScene = imp->ReadFile( pFile, pimpl->mIOHandler);
|
pimpl->mProgressHandler->Update();
|
||||||
|
|
||||||
if (profiler) {
|
if (profiler) {
|
||||||
profiler->EndRegion("import");
|
profiler->EndRegion("import");
|
||||||
|
@ -988,6 +1035,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
|
||||||
ScenePreprocessor pre(pimpl->mScene);
|
ScenePreprocessor pre(pimpl->mScene);
|
||||||
pre.ProcessScene();
|
pre.ProcessScene();
|
||||||
|
|
||||||
|
pimpl->mProgressHandler->Update();
|
||||||
if (profiler) {
|
if (profiler) {
|
||||||
profiler->EndRegion("preprocess");
|
profiler->EndRegion("preprocess");
|
||||||
}
|
}
|
||||||
|
@ -1083,8 +1131,8 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
|
||||||
profiler->BeginRegion("postprocess");
|
profiler->BeginRegion("postprocess");
|
||||||
}
|
}
|
||||||
|
|
||||||
process->SetupProperties( this );
|
|
||||||
process->ExecuteOnScene ( this );
|
process->ExecuteOnScene ( this );
|
||||||
|
pimpl->mProgressHandler->Update();
|
||||||
|
|
||||||
if (profiler) {
|
if (profiler) {
|
||||||
profiler->EndRegion("postprocess");
|
profiler->EndRegion("postprocess");
|
||||||
|
@ -1123,14 +1171,14 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Helper function to check whether an extension is supported by ASSIMP
|
// Helper function to check whether an extension is supported by ASSIMP
|
||||||
bool Importer::IsExtensionSupported(const char* szExtension)
|
bool Importer::IsExtensionSupported(const char* szExtension) const
|
||||||
{
|
{
|
||||||
return NULL != FindLoader(szExtension);
|
return NULL != FindLoader(szExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Find a loader plugin for a given file extension
|
// Find a loader plugin for a given file extension
|
||||||
BaseImporter* Importer::FindLoader (const char* szExtension)
|
BaseImporter* Importer::FindLoader (const char* szExtension) const
|
||||||
{
|
{
|
||||||
ai_assert(szExtension);
|
ai_assert(szExtension);
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
|
@ -1159,7 +1207,7 @@ BaseImporter* Importer::FindLoader (const char* szExtension)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Helper function to build a list of all file extensions supported by ASSIMP
|
// Helper function to build a list of all file extensions supported by ASSIMP
|
||||||
void Importer::GetExtensionList(aiString& szOut)
|
void Importer::GetExtensionList(aiString& szOut) const
|
||||||
{
|
{
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
std::set<std::string> str;
|
std::set<std::string> str;
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
Open Asset Import Library (ASSIMP)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2010, ASSIMP Development Team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the ASSIMP team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the ASSIMP Development Team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file ProgressHandler.h
|
||||||
|
* @brief Abstract base class 'ProgressHandler'.
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDED_AI_PROGRESSHANDLER_H
|
||||||
|
#define INCLUDED_AI_PROGRESSHANDLER_H
|
||||||
|
#include "aiTypes.h"
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
/** @brief CPP-API: Abstract interface for custom progress report receivers.
|
||||||
|
*
|
||||||
|
* Each #Importer instance maintains its own #ProgressHandler. The default
|
||||||
|
* implementation provided by Assimp doesn't do anything at all. */
|
||||||
|
class ASSIMP_API ProgressHandler
|
||||||
|
: public Intern::AllocateFromAssimpHeap {
|
||||||
|
protected:
|
||||||
|
/** @brief Default constructor */
|
||||||
|
ProgressHandler () {
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
/** @brief Virtual destructor */
|
||||||
|
virtual ~ProgressHandler () {
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** @brief Progress callback.
|
||||||
|
* @param percentage An estimate of the current loading progress,
|
||||||
|
* in percent. Or -1.f if such an estimate is not available.
|
||||||
|
*
|
||||||
|
* There are restriction on what you may do from within your
|
||||||
|
* implementation of this method: no exceptions may be thrown and no
|
||||||
|
* non-const #Importer methods may be called. It is
|
||||||
|
* not generally possible to predict the number of callbacks
|
||||||
|
* fired during a single import.
|
||||||
|
*
|
||||||
|
* @return Return false to abort loading at the next possible
|
||||||
|
* occasion (loaders and Assimp are generally allowed to perform
|
||||||
|
* all needed cleanup tasks prior to returning control to the
|
||||||
|
* caller). If the loading is aborted, #Importer::ReadFile()
|
||||||
|
* returns always NULL.
|
||||||
|
*
|
||||||
|
* @note Currently, percentage is always -1.f because there is
|
||||||
|
* no reliable way to compute it.
|
||||||
|
* */
|
||||||
|
virtual bool Update(float percentage = -1.f) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; // !class ProgressHandler
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
} // Namespace Assimp
|
||||||
|
|
||||||
|
#endif
|
|
@ -60,6 +60,7 @@ namespace Assimp {
|
||||||
class Importer;
|
class Importer;
|
||||||
class IOStream;
|
class IOStream;
|
||||||
class IOSystem;
|
class IOSystem;
|
||||||
|
class ProgressHandler;
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// Plugin development
|
// Plugin development
|
||||||
|
@ -298,21 +299,52 @@ public:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Retrieves the IO handler that is currently set.
|
/** Retrieves the IO handler that is currently set.
|
||||||
* You can use IsDefaultIOHandler() to check whether the returned
|
* You can use #IsDefaultIOHandler() to check whether the returned
|
||||||
* interface is the default IO handler provided by ASSIMP. The default
|
* interface is the default IO handler provided by ASSIMP. The default
|
||||||
* handler is active as long the application doesn't supply its own
|
* handler is active as long the application doesn't supply its own
|
||||||
* custom IO handler via SetIOHandler().
|
* custom IO handler via #SetIOHandler().
|
||||||
* @return A valid IOSystem interface
|
* @return A valid IOSystem interface, never NULL.
|
||||||
*/
|
*/
|
||||||
IOSystem* GetIOHandler();
|
IOSystem* GetIOHandler() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Checks whether a default IO handler is active
|
/** Checks whether a default IO handler is active
|
||||||
* A default handler is active as long the application doesn't
|
* A default handler is active as long the application doesn't
|
||||||
* supply its own custom IO handler via SetIOHandler().
|
* supply its own custom IO handler via #SetIOHandler().
|
||||||
* @return true by default
|
* @return true by default
|
||||||
*/
|
*/
|
||||||
bool IsDefaultIOHandler();
|
bool IsDefaultIOHandler() const;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Supplies a custom progress handler to the importer. This
|
||||||
|
* interface exposes a #Update() callback, which is called
|
||||||
|
* more or less periodically (please don't sue us if it
|
||||||
|
* isn't as periodically as you'd like it to have ...).
|
||||||
|
* This can be used to implement progress bars and loading
|
||||||
|
* timeouts.
|
||||||
|
* @param pHandler Progress callback interface. Pass NULL to
|
||||||
|
* disable progress reporting.
|
||||||
|
* @note Progress handlers can be used to abort the loading
|
||||||
|
* at almost any time.*/
|
||||||
|
void SetProgressHandler ( ProgressHandler* pHandler );
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Retrieves the progress handler that is currently set.
|
||||||
|
* You can use #IsDefaultProgressHandler() to check whether the returned
|
||||||
|
* interface is the default handler provided by ASSIMP. The default
|
||||||
|
* handler is active as long the application doesn't supply its own
|
||||||
|
* custom handler via #SetProgressHandler().
|
||||||
|
* @return A valid ProgressHandler interface, never NULL.
|
||||||
|
*/
|
||||||
|
ProgressHandler* GetProgressHandler() const;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
/** Checks whether a default progress handler is active
|
||||||
|
* A default handler is active as long the application doesn't
|
||||||
|
* supply its own custom progress handler via #SetProgressHandler().
|
||||||
|
* @return true by default
|
||||||
|
*/
|
||||||
|
bool IsDefaultProgressHandler() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Check whether a given set of postprocessing flags
|
/** @brief Check whether a given set of postprocessing flags
|
||||||
|
@ -324,9 +356,9 @@ public:
|
||||||
* you're unsure.
|
* you're unsure.
|
||||||
*
|
*
|
||||||
* @param pFlags Bitwise combination of the aiPostProcess flags.
|
* @param pFlags Bitwise combination of the aiPostProcess flags.
|
||||||
* @return true if this flag combination is not supported.
|
* @return true if this flag combination is fine.
|
||||||
*/
|
*/
|
||||||
bool ValidateFlags(unsigned int pFlags);
|
bool ValidateFlags(unsigned int pFlags) const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Reads the given file and returns its contents if successful.
|
/** Reads the given file and returns its contents if successful.
|
||||||
|
@ -453,7 +485,7 @@ public:
|
||||||
* Must include a trailing dot '.'. Example: ".3ds", ".md3".
|
* Must include a trailing dot '.'. Example: ".3ds", ".md3".
|
||||||
* Cases-insensitive.
|
* Cases-insensitive.
|
||||||
* @return true if the extension is supported, false otherwise */
|
* @return true if the extension is supported, false otherwise */
|
||||||
bool IsExtensionSupported(const char* szExtension);
|
bool IsExtensionSupported(const char* szExtension) const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Returns whether a given file extension is supported by ASSIMP.
|
/** @brief Returns whether a given file extension is supported by ASSIMP.
|
||||||
|
@ -461,7 +493,7 @@ public:
|
||||||
* This function is provided for backward compatibility.
|
* This function is provided for backward compatibility.
|
||||||
* See the const char* version for detailed and up-to-date docs.
|
* See the const char* version for detailed and up-to-date docs.
|
||||||
* @see IsExtensionSupported(const char*) */
|
* @see IsExtensionSupported(const char*) */
|
||||||
inline bool IsExtensionSupported(const std::string& szExtension);
|
inline bool IsExtensionSupported(const std::string& szExtension) const;
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -474,7 +506,7 @@ public:
|
||||||
* @param szOut String to receive the extension list.
|
* @param szOut String to receive the extension list.
|
||||||
* Format of the list: "*.3ds;*.obj;*.dae". This is useful for
|
* Format of the list: "*.3ds;*.obj;*.dae". This is useful for
|
||||||
* use with the WinAPI call GetOpenFileName(Ex). */
|
* use with the WinAPI call GetOpenFileName(Ex). */
|
||||||
void GetExtensionList(aiString& szOut);
|
void GetExtensionList(aiString& szOut) const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Get a full list of all file extensions supported by ASSIMP.
|
/** @brief Get a full list of all file extensions supported by ASSIMP.
|
||||||
|
@ -482,7 +514,7 @@ public:
|
||||||
* This function is provided for backward compatibility.
|
* This function is provided for backward compatibility.
|
||||||
* See the aiString version for detailed and up-to-date docs.
|
* See the aiString version for detailed and up-to-date docs.
|
||||||
* @see GetExtensionList(aiString&)*/
|
* @see GetExtensionList(aiString&)*/
|
||||||
inline void GetExtensionList(std::string& szOut);
|
inline void GetExtensionList(std::string& szOut) const;
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -495,7 +527,7 @@ public:
|
||||||
* is case-insensitive), ".bah", "*.bah" (wild card and dot
|
* is case-insensitive), ".bah", "*.bah" (wild card and dot
|
||||||
* characters at the beginning of the extension are skipped).
|
* characters at the beginning of the extension are skipped).
|
||||||
* @return NULL if there is no loader for the extension.*/
|
* @return NULL if there is no loader for the extension.*/
|
||||||
BaseImporter* FindLoader (const char* szExtension);
|
BaseImporter* FindLoader (const char* szExtension) const;
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -559,22 +591,17 @@ protected:
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
AI_FORCE_INLINE const aiScene* Importer::ReadFile( const std::string& pFile,
|
AI_FORCE_INLINE const aiScene* Importer::ReadFile( const std::string& pFile,unsigned int pFlags){
|
||||||
unsigned int pFlags)
|
|
||||||
{
|
|
||||||
return ReadFile(pFile.c_str(),pFlags);
|
return ReadFile(pFile.c_str(),pFlags);
|
||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
AI_FORCE_INLINE void Importer::GetExtensionList(std::string& szOut)
|
AI_FORCE_INLINE void Importer::GetExtensionList(std::string& szOut) const {
|
||||||
{
|
|
||||||
aiString s;
|
aiString s;
|
||||||
GetExtensionList(s);
|
GetExtensionList(s);
|
||||||
szOut = s.data;
|
szOut = s.data;
|
||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
AI_FORCE_INLINE bool Importer::IsExtensionSupported(
|
AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string& szExtension) const {
|
||||||
const std::string& szExtension)
|
|
||||||
{
|
|
||||||
return IsExtensionSupported(szExtension.c_str());
|
return IsExtensionSupported(szExtension.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,8 @@ Global
|
||||||
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release|x64.ActiveCfg = Release|Win32
|
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release|x64.ActiveCfg = Release|Win32
|
||||||
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|Win32.ActiveCfg = release-dll|Win32
|
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|Win32.ActiveCfg = release-dll|Win32
|
||||||
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|Win32.Build.0 = release-dll|Win32
|
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|Win32.Build.0 = release-dll|Win32
|
||||||
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|x64.ActiveCfg = release-dll|Win32
|
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|x64.ActiveCfg = release-dll|x64
|
||||||
|
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|x64.Build.0 = release-dll|x64
|
||||||
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-noboost-st|Win32.ActiveCfg = release-noboost-st|Win32
|
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-noboost-st|Win32.ActiveCfg = release-noboost-st|Win32
|
||||||
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-noboost-st|Win32.Build.0 = release-noboost-st|Win32
|
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-noboost-st|Win32.Build.0 = release-noboost-st|Win32
|
||||||
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-noboost-st|x64.ActiveCfg = release-noboost-st|Win32
|
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-noboost-st|x64.ActiveCfg = release-noboost-st|Win32
|
||||||
|
|
|
@ -1150,6 +1150,10 @@
|
||||||
RelativePath="..\..\include\NullLogger.h"
|
RelativePath="..\..\include\NullLogger.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\ProgressHandler.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="C"
|
Name="C"
|
||||||
|
@ -2302,6 +2306,10 @@
|
||||||
RelativePath="..\..\code\ByteSwap.h"
|
RelativePath="..\..\code\ByteSwap.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\code\DefaultProgressHandler.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\code\Exceptional.h"
|
RelativePath="..\..\code\Exceptional.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -458,7 +458,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="assimp.lib zlib1.lib"
|
AdditionalDependencies="assimp.lib "
|
||||||
OutputFile="$(OutDir)\assimp.exe"
|
OutputFile="$(OutDir)\assimp.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories=""..\..\lib\assimp_$(ConfigurationName)_$(PlatformName)""
|
AdditionalLibraryDirectories=""..\..\lib\assimp_$(ConfigurationName)_$(PlatformName)""
|
||||||
|
|
Loading…
Reference in New Issue