miniassimp
diff include/miniassimp/ProgressHandler.hpp @ 0:879c81d94345
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 28 Jan 2019 18:19:26 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/include/miniassimp/ProgressHandler.hpp Mon Jan 28 18:19:26 2019 +0200 1.3 @@ -0,0 +1,145 @@ 1.4 +/* 1.5 +Open Asset Import Library (assimp) 1.6 +---------------------------------------------------------------------- 1.7 + 1.8 +Copyright (c) 2006-2018, assimp team 1.9 + 1.10 + 1.11 +All rights reserved. 1.12 + 1.13 +Redistribution and use of this software in source and binary forms, 1.14 +with or without modification, are permitted provided that the 1.15 +following conditions are met: 1.16 + 1.17 +* Redistributions of source code must retain the above 1.18 + copyright notice, this list of conditions and the 1.19 + following disclaimer. 1.20 + 1.21 +* Redistributions in binary form must reproduce the above 1.22 + copyright notice, this list of conditions and the 1.23 + following disclaimer in the documentation and/or other 1.24 + materials provided with the distribution. 1.25 + 1.26 +* Neither the name of the assimp team, nor the names of its 1.27 + contributors may be used to endorse or promote products 1.28 + derived from this software without specific prior 1.29 + written permission of the assimp team. 1.30 + 1.31 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.32 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.33 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.34 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.35 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.36 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.37 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.38 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.39 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.40 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.41 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.42 + 1.43 +---------------------------------------------------------------------- 1.44 +*/ 1.45 + 1.46 +/** @file ProgressHandler.hpp 1.47 + * @brief Abstract base class 'ProgressHandler'. 1.48 + */ 1.49 +#pragma once 1.50 +#ifndef AI_PROGRESSHANDLER_H_INC 1.51 +#define AI_PROGRESSHANDLER_H_INC 1.52 + 1.53 +#include "types.h" 1.54 + 1.55 +namespace Assimp { 1.56 + 1.57 +// ------------------------------------------------------------------------------------ 1.58 +/** @brief CPP-API: Abstract interface for custom progress report receivers. 1.59 + * 1.60 + * Each #Importer instance maintains its own #ProgressHandler. The default 1.61 + * implementation provided by Assimp doesn't do anything at all. */ 1.62 +class ASSIMP_API ProgressHandler 1.63 +#ifndef SWIG 1.64 + : public Intern::AllocateFromAssimpHeap 1.65 +#endif 1.66 +{ 1.67 +protected: 1.68 + /// @brief Default constructor 1.69 + ProgressHandler () AI_NO_EXCEPT { 1.70 + // empty 1.71 + } 1.72 + 1.73 +public: 1.74 + /// @brief Virtual destructor. 1.75 + virtual ~ProgressHandler () { 1.76 + } 1.77 + 1.78 + // ------------------------------------------------------------------- 1.79 + /** @brief Progress callback. 1.80 + * @param percentage An estimate of the current loading progress, 1.81 + * in percent. Or -1.f if such an estimate is not available. 1.82 + * 1.83 + * There are restriction on what you may do from within your 1.84 + * implementation of this method: no exceptions may be thrown and no 1.85 + * non-const #Importer methods may be called. It is 1.86 + * not generally possible to predict the number of callbacks 1.87 + * fired during a single import. 1.88 + * 1.89 + * @return Return false to abort loading at the next possible 1.90 + * occasion (loaders and Assimp are generally allowed to perform 1.91 + * all needed cleanup tasks prior to returning control to the 1.92 + * caller). If the loading is aborted, #Importer::ReadFile() 1.93 + * returns always NULL. 1.94 + * */ 1.95 + virtual bool Update(float percentage = -1.f) = 0; 1.96 + 1.97 + // ------------------------------------------------------------------- 1.98 + /** @brief Progress callback for file loading steps 1.99 + * @param numberOfSteps The number of total post-processing 1.100 + * steps 1.101 + * @param currentStep The index of the current post-processing 1.102 + * step that will run, or equal to numberOfSteps if all of 1.103 + * them has finished. This number is always strictly monotone 1.104 + * increasing, although not necessarily linearly. 1.105 + * 1.106 + * @note This is currently only used at the start and the end 1.107 + * of the file parsing. 1.108 + * */ 1.109 + virtual void UpdateFileRead(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) { 1.110 + float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f; 1.111 + Update( f * 0.5f ); 1.112 + } 1.113 + 1.114 + // ------------------------------------------------------------------- 1.115 + /** @brief Progress callback for post-processing steps 1.116 + * @param numberOfSteps The number of total post-processing 1.117 + * steps 1.118 + * @param currentStep The index of the current post-processing 1.119 + * step that will run, or equal to numberOfSteps if all of 1.120 + * them has finished. This number is always strictly monotone 1.121 + * increasing, although not necessarily linearly. 1.122 + * */ 1.123 + virtual void UpdatePostProcess(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) { 1.124 + float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f; 1.125 + Update( f * 0.5f + 0.5f ); 1.126 + } 1.127 + 1.128 + 1.129 + // ------------------------------------------------------------------- 1.130 + /** @brief Progress callback for export steps. 1.131 + * @param numberOfSteps The number of total processing 1.132 + * steps 1.133 + * @param currentStep The index of the current post-processing 1.134 + * step that will run, or equal to numberOfSteps if all of 1.135 + * them has finished. This number is always strictly monotone 1.136 + * increasing, although not necessarily linearly. 1.137 + * */ 1.138 + virtual void UpdateFileWrite(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) { 1.139 + float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f; 1.140 + Update(f * 0.5f); 1.141 + } 1.142 +}; // !class ProgressHandler 1.143 + 1.144 +// ------------------------------------------------------------------------------------ 1.145 + 1.146 +} // Namespace Assimp 1.147 + 1.148 +#endif // AI_PROGRESSHANDLER_H_INC