2015-05-19 04:16:51 +00:00
|
|
|
/*
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2022-01-10 20:13:43 +00:00
|
|
|
Copyright (c) 2006-2022, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2017-05-09 17:57:36 +00:00
|
|
|
|
2015-05-19 04:16:51 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
2015-05-19 04:17:45 +00:00
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the
|
2015-05-19 04:16:51 +00:00
|
|
|
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 team.
|
|
|
|
|
2015-05-19 04:17:45 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2015-05-19 04:16:51 +00:00
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2015-05-19 04:17:45 +00:00
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2015-05-19 04:16:51 +00:00
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2015-05-19 04:17:45 +00:00
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2015-05-19 04:16:51 +00:00
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2015-05-19 04:17:45 +00:00
|
|
|
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
|
2015-05-19 04:16:51 +00:00
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file ProgressHandler.hpp
|
|
|
|
* @brief Abstract base class 'ProgressHandler'.
|
|
|
|
*/
|
2016-07-11 18:56:38 +00:00
|
|
|
#pragma once
|
|
|
|
#ifndef AI_PROGRESSHANDLER_H_INC
|
|
|
|
#define AI_PROGRESSHANDLER_H_INC
|
|
|
|
|
2019-10-11 11:27:36 +00:00
|
|
|
#ifdef __GNUC__
|
|
|
|
# pragma GCC system_header
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <assimp/types.h>
|
2016-07-11 18:56:38 +00:00
|
|
|
|
2019-10-11 11:27:36 +00:00
|
|
|
namespace Assimp {
|
2015-05-19 04:16:51 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
/** @brief CPP-API: Abstract interface for custom progress report receivers.
|
|
|
|
*
|
2015-05-19 04:17:45 +00:00
|
|
|
* Each #Importer instance maintains its own #ProgressHandler. The default
|
2015-05-19 04:16:51 +00:00
|
|
|
* implementation provided by Assimp doesn't do anything at all. */
|
|
|
|
class ASSIMP_API ProgressHandler
|
|
|
|
#ifndef SWIG
|
2015-05-19 04:18:29 +00:00
|
|
|
: public Intern::AllocateFromAssimpHeap
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
protected:
|
2018-11-12 21:26:10 +00:00
|
|
|
/// @brief Default constructor
|
2023-01-16 20:47:11 +00:00
|
|
|
ProgressHandler () AI_NO_EXCEPT = default;
|
2018-11-12 21:26:10 +00:00
|
|
|
|
2015-05-19 04:16:51 +00:00
|
|
|
public:
|
2018-11-12 21:26:10 +00:00
|
|
|
/// @brief Virtual destructor.
|
2023-01-16 20:47:11 +00:00
|
|
|
virtual ~ProgressHandler () = default;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** @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()
|
2020-06-23 19:05:42 +00:00
|
|
|
* returns always nullptr.
|
2015-05-19 04:18:29 +00:00
|
|
|
* */
|
|
|
|
virtual bool Update(float percentage = -1.f) = 0;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** @brief Progress callback for file loading steps
|
|
|
|
* @param numberOfSteps The number of total post-processing
|
|
|
|
* steps
|
|
|
|
* @param currentStep The index of the current post-processing
|
|
|
|
* step that will run, or equal to numberOfSteps if all of
|
|
|
|
* them has finished. This number is always strictly monotone
|
|
|
|
* increasing, although not necessarily linearly.
|
|
|
|
*
|
|
|
|
* @note This is currently only used at the start and the end
|
|
|
|
* of the file parsing.
|
|
|
|
* */
|
|
|
|
virtual void UpdateFileRead(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
|
|
|
|
float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f;
|
|
|
|
Update( f * 0.5f );
|
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** @brief Progress callback for post-processing steps
|
|
|
|
* @param numberOfSteps The number of total post-processing
|
|
|
|
* steps
|
|
|
|
* @param currentStep The index of the current post-processing
|
|
|
|
* step that will run, or equal to numberOfSteps if all of
|
|
|
|
* them has finished. This number is always strictly monotone
|
|
|
|
* increasing, although not necessarily linearly.
|
|
|
|
* */
|
|
|
|
virtual void UpdatePostProcess(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
|
|
|
|
float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f;
|
|
|
|
Update( f * 0.5f + 0.5f );
|
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2018-11-12 21:26:10 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** @brief Progress callback for export steps.
|
|
|
|
* @param numberOfSteps The number of total processing
|
|
|
|
* steps
|
|
|
|
* @param currentStep The index of the current post-processing
|
|
|
|
* step that will run, or equal to numberOfSteps if all of
|
|
|
|
* them has finished. This number is always strictly monotone
|
|
|
|
* increasing, although not necessarily linearly.
|
|
|
|
* */
|
|
|
|
virtual void UpdateFileWrite(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
|
|
|
|
float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f;
|
|
|
|
Update(f * 0.5f);
|
|
|
|
}
|
2015-05-19 04:17:45 +00:00
|
|
|
}; // !class ProgressHandler
|
2018-11-12 21:26:10 +00:00
|
|
|
|
2015-05-19 04:16:51 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2018-11-12 21:26:10 +00:00
|
|
|
|
2015-05-19 04:16:51 +00:00
|
|
|
} // Namespace Assimp
|
|
|
|
|
2016-07-11 18:56:38 +00:00
|
|
|
#endif // AI_PROGRESSHANDLER_H_INC
|