nuclear@0: /* nuclear@0: Open Asset Import Library (assimp) nuclear@0: ---------------------------------------------------------------------- nuclear@0: nuclear@0: Copyright (c) 2006-2018, assimp team nuclear@0: nuclear@0: nuclear@0: All rights reserved. nuclear@0: nuclear@0: Redistribution and use of this software in source and binary forms, nuclear@0: with or without modification, are permitted provided that the nuclear@0: following conditions are met: nuclear@0: nuclear@0: * Redistributions of source code must retain the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer. nuclear@0: nuclear@0: * Redistributions in binary form must reproduce the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer in the documentation and/or other nuclear@0: materials provided with the distribution. nuclear@0: nuclear@0: * Neither the name of the assimp team, nor the names of its nuclear@0: contributors may be used to endorse or promote products nuclear@0: derived from this software without specific prior nuclear@0: written permission of the assimp team. nuclear@0: nuclear@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS nuclear@0: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT nuclear@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR nuclear@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT nuclear@0: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, nuclear@0: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT nuclear@0: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, nuclear@0: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY nuclear@0: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT nuclear@0: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE nuclear@0: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. nuclear@0: nuclear@0: ---------------------------------------------------------------------- nuclear@0: */ nuclear@0: nuclear@0: /** @file Importer.h mostly internal stuff for use by #Assimp::Importer */ nuclear@0: #pragma once nuclear@0: #ifndef INCLUDED_AI_IMPORTER_H nuclear@0: #define INCLUDED_AI_IMPORTER_H nuclear@0: nuclear@0: #include nuclear@0: #include nuclear@0: #include nuclear@0: #include nuclear@0: nuclear@0: struct aiScene; nuclear@0: nuclear@0: namespace Assimp { nuclear@0: class ProgressHandler; nuclear@0: class IOSystem; nuclear@0: class BaseImporter; nuclear@0: class BaseProcess; nuclear@0: class SharedPostProcessInfo; nuclear@0: nuclear@0: nuclear@0: //! @cond never nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** @brief Internal PIMPL implementation for Assimp::Importer nuclear@0: * nuclear@0: * Using this idiom here allows us to drop the dependency from nuclear@0: * std::vector and std::map in the public headers. Furthermore we are dropping nuclear@0: * any STL interface problems caused by mismatching STL settings. All nuclear@0: * size calculation are now done by us, not the app heap. */ nuclear@0: class ImporterPimpl { nuclear@0: public: nuclear@0: // Data type to store the key hash nuclear@0: typedef unsigned int KeyType; nuclear@0: nuclear@0: // typedefs for our four configuration maps. nuclear@0: // We don't need more, so there is no need for a generic solution nuclear@0: typedef std::map IntPropertyMap; nuclear@0: typedef std::map FloatPropertyMap; nuclear@0: typedef std::map StringPropertyMap; nuclear@0: typedef std::map MatrixPropertyMap; nuclear@0: nuclear@0: /** IO handler to use for all file accesses. */ nuclear@0: IOSystem* mIOHandler; nuclear@0: bool mIsDefaultHandler; nuclear@0: nuclear@0: /** Progress handler for feedback. */ nuclear@0: ProgressHandler* mProgressHandler; nuclear@0: bool mIsDefaultProgressHandler; nuclear@0: nuclear@0: /** Format-specific importer worker objects - one for each format we can read.*/ nuclear@0: std::vector< BaseImporter* > mImporter; nuclear@0: nuclear@0: /** Post processing steps we can apply at the imported data. */ nuclear@0: std::vector< BaseProcess* > mPostProcessingSteps; nuclear@0: nuclear@0: /** The imported data, if ReadFile() was successful, NULL otherwise. */ nuclear@0: aiScene* mScene; nuclear@0: nuclear@0: /** The error description, if there was one. */ nuclear@0: std::string mErrorString; nuclear@0: nuclear@0: /** List of integer properties */ nuclear@0: IntPropertyMap mIntProperties; nuclear@0: nuclear@0: /** List of floating-point properties */ nuclear@0: FloatPropertyMap mFloatProperties; nuclear@0: nuclear@0: /** List of string properties */ nuclear@0: StringPropertyMap mStringProperties; nuclear@0: nuclear@0: /** List of Matrix properties */ nuclear@0: MatrixPropertyMap mMatrixProperties; nuclear@0: nuclear@0: /** Used for testing - extra verbose mode causes the ValidateDataStructure-Step nuclear@0: * to be executed before and after every single post-process step */ nuclear@0: bool bExtraVerbose; nuclear@0: nuclear@0: /** Used by post-process steps to share data */ nuclear@0: SharedPostProcessInfo* mPPShared; nuclear@0: nuclear@0: /// The default class constructor. nuclear@0: ImporterPimpl() AI_NO_EXCEPT; nuclear@0: }; nuclear@0: nuclear@0: inline nuclear@0: ImporterPimpl::ImporterPimpl() AI_NO_EXCEPT nuclear@0: : mIOHandler( 0 ) nuclear@0: , mIsDefaultHandler( false ) nuclear@0: , mProgressHandler( 0 ) nuclear@0: , mIsDefaultProgressHandler( false ) nuclear@0: , mImporter() nuclear@0: , mPostProcessingSteps() nuclear@0: , mScene( 0 ) nuclear@0: , mErrorString() nuclear@0: , mIntProperties() nuclear@0: , mFloatProperties() nuclear@0: , mStringProperties() nuclear@0: , mMatrixProperties() nuclear@0: , bExtraVerbose( false ) nuclear@0: , mPPShared( 0 ) { nuclear@0: // empty nuclear@0: } nuclear@0: //! @endcond nuclear@0: nuclear@0: nuclear@0: struct BatchData; nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** FOR IMPORTER PLUGINS ONLY: A helper class to the pleasure of importers nuclear@0: * that need to load many external meshes recursively. nuclear@0: * nuclear@0: * The class uses several threads to load these meshes (or at least it nuclear@0: * could, this has not yet been implemented at the moment). nuclear@0: * nuclear@0: * @note The class may not be used by more than one thread*/ nuclear@0: class ASSIMP_API BatchLoader nuclear@0: { nuclear@0: // friend of Importer nuclear@0: nuclear@0: public: nuclear@0: //! @cond never nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Wraps a full list of configuration properties for an importer. nuclear@0: * Properties can be set using SetGenericProperty */ nuclear@0: struct PropertyMap nuclear@0: { nuclear@0: ImporterPimpl::IntPropertyMap ints; nuclear@0: ImporterPimpl::FloatPropertyMap floats; nuclear@0: ImporterPimpl::StringPropertyMap strings; nuclear@0: ImporterPimpl::MatrixPropertyMap matrices; nuclear@0: nuclear@0: bool operator == (const PropertyMap& prop) const { nuclear@0: // fixme: really isocpp? gcc complains nuclear@0: return ints == prop.ints && floats == prop.floats && strings == prop.strings && matrices == prop.matrices; nuclear@0: } nuclear@0: nuclear@0: bool empty () const { nuclear@0: return ints.empty() && floats.empty() && strings.empty() && matrices.empty(); nuclear@0: } nuclear@0: }; nuclear@0: //! @endcond nuclear@0: nuclear@0: public: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Construct a batch loader from a given IO system to be used nuclear@0: * to access external files nuclear@0: */ nuclear@0: explicit BatchLoader(IOSystem* pIO, bool validate = false ); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** The class destructor. nuclear@0: */ nuclear@0: ~BatchLoader(); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Sets the validation step. True for enable validation during postprocess. nuclear@0: * @param enable True for validation. nuclear@0: */ nuclear@0: void setValidation( bool enabled ); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Returns the current validation step. nuclear@0: * @return The current validation step. nuclear@0: */ nuclear@0: bool getValidation() const; nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Add a new file to the list of files to be loaded. nuclear@0: * @param file File to be loaded nuclear@0: * @param steps Post-processing steps to be executed on the file nuclear@0: * @param map Optional configuration properties nuclear@0: * @return 'Load request channel' - an unique ID that can later nuclear@0: * be used to access the imported file data. nuclear@0: * @see GetImport */ nuclear@0: unsigned int AddLoadRequest ( nuclear@0: const std::string& file, nuclear@0: unsigned int steps = 0, nuclear@0: const PropertyMap* map = NULL nuclear@0: ); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Get an imported scene. nuclear@0: * This polls the import from the internal request list. nuclear@0: * If an import is requested several times, this function nuclear@0: * can be called several times, too. nuclear@0: * nuclear@0: * @param which LRWC returned by AddLoadRequest(). nuclear@0: * @return NULL if there is no scene with this file name nuclear@0: * in the queue of the scene hasn't been loaded yet. */ nuclear@0: aiScene* GetImport( nuclear@0: unsigned int which nuclear@0: ); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Waits until all scenes have been loaded. This returns nuclear@0: * immediately if no scenes are queued.*/ nuclear@0: void LoadAll(); nuclear@0: nuclear@0: private: nuclear@0: // No need to have that in the public API ... nuclear@0: BatchData *m_data; nuclear@0: }; nuclear@0: nuclear@0: } // Namespace Assimp nuclear@0: nuclear@0: #endif // INCLUDED_AI_IMPORTER_H