Skip to content

Commit

Permalink
- Change BaseImporter::GetExtensionList to add all known file extensi…
Browse files Browse the repository at this point in the history
…ons to a std::set, so uniqueness is guaranteed. Also rewrite all related functions in Importer. NOTE: This does *not* change the public interface.

- FIX build error on vc8/release-noboost x64, ConvertUTF.c had wrong PCH settings.
- ADD knowext and listext verbs to assimp_cmd, add some raw docs.
- Update unit tests to reflect these changes. Currently I keep getting failures in some tests, this needs to be resolved *urgently*.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@567 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
  • Loading branch information
aramis_acg committed Mar 2, 2010
1 parent 8ef1e5b commit 5738860
Show file tree
Hide file tree
Showing 72 changed files with 416 additions and 261 deletions.
8 changes: 5 additions & 3 deletions code/3DSLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandle

// ------------------------------------------------------------------------------------------------
// Get list of all extension supported by this loader
void Discreet3DSImporter::GetExtensionList(std::string& append)
void Discreet3DSImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.3ds;*.prj");
extensions.insert("3ds");
extensions.insert("prj");
}

// ------------------------------------------------------------------------------------------------
Expand All @@ -130,8 +131,9 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
this->stream = &stream;

// We should have at least one chunk
if (stream.GetRemainingSize() < 16)
if (stream.GetRemainingSize() < 16) {
throw new ImportErrorException("3DS file is either empty or corrupt: " + pFile);
}

// Allocate our temporary 3DS representation
mScene = new D3DS::Scene();
Expand Down
2 changes: 1 addition & 1 deletion code/3DSLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Discreet3DSImporter : public BaseImporter
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);

// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
Expand Down
6 changes: 4 additions & 2 deletions code/ACLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ bool AC3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool

// ------------------------------------------------------------------------------------------------
// Get list of file extensions handled by this loader
void AC3DImporter::GetExtensionList(std::string& append)
void AC3DImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.ac;*.acc;*.ac3d");
extensions.insert("ac");
extensions.insert("acc");
extensions.insert("ac3d");
}

// ------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion code/ACLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class AC3DImporter : public BaseImporter
// -------------------------------------------------------------------
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details */
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);

// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
Expand Down
5 changes: 3 additions & 2 deletions code/ASELoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ bool ASEImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}

// ------------------------------------------------------------------------------------------------
void ASEImporter::GetExtensionList(std::string& append)
void ASEImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.ase;*.ask");
extensions.insert("ase");
extensions.insert("ask");
}

// ------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion code/ASELoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ASEImporter : public BaseImporter
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);

// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
Expand Down
3 changes: 1 addition & 2 deletions code/Assimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,7 @@ void aiGetExtensionList(aiString* szOut)
boost::mutex::scoped_lock lock(gMutex);
#endif

if (!gActiveImports.empty())
{
if (!gActiveImports.empty()) {
(*(gActiveImports.begin())).second->GetExtensionList(*szOut);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions code/B3DImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ bool B3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}

// ------------------------------------------------------------------------------------------------
void B3DImporter::GetExtensionList( std::string& append ){
append.append("*.b3d");
void B3DImporter::GetExtensionList( std::set<std::string>& extensions ){
extensions.insert("b3d");
}

#ifdef DEBUG_B3D
Expand Down
2 changes: 1 addition & 1 deletion code/B3DImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class B3DImporter : public BaseImporter{

protected:

virtual void GetExtensionList(std::string& append);
virtual void GetExtensionList(std::set<std::string>& extensions);
virtual void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);

private:
Expand Down
4 changes: 2 additions & 2 deletions code/BVHLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ class BVHLoader : public BaseImporter
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList( std::string& append)
void GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.bvh");
extensions.insert("bvh");
}

/** Imports the given file into the given scene structure.
Expand Down
97 changes: 60 additions & 37 deletions code/BaseImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ class ASSIMP_API ImportErrorException
{
public:
/** Constructor with arguments */
ImportErrorException( const std::string& pErrorText)
{
ImportErrorException( const std::string& pErrorText) {
mErrorText = pErrorText;
}

Expand Down Expand Up @@ -164,7 +163,7 @@ class ASSIMP_API BaseImporter
* the file extension is enough. If no suitable loader is found with
* this strategy, CanRead() is called again, the 'checkSig' parameter
* set to true this time. Now the implementation is expected to
* perform a full check of the file format, possibly searching the
* perform a full check of the file structure, possibly searching the
* first bytes of the file for magic identifiers or keywords.
*
* @param pFile Path and file name of the file to be examined.
Expand All @@ -174,14 +173,12 @@ class ASSIMP_API BaseImporter
* contents of the file to be loaded for magic bytes, keywords, etc
* to be able to load files with unknown/not existent file extensions.
* @return true if the class can read this file, false if not.
*
* @note Sometimes ASSIMP uses this method to determine whether a
* a given file extension is generally supported. In this case the
* file extension is passed in the pFile parameter, pIOHandler is NULL
*/
virtual bool CanRead( const std::string& pFile,
IOSystem* pIOHandler, bool checkSig) const = 0;

virtual bool CanRead(
const std::string& pFile,
IOSystem* pIOHandler,
bool checkSig
) const = 0;

// -------------------------------------------------------------------
/** Imports the given file and returns the imported data.
Expand All @@ -201,7 +198,10 @@ class ASSIMP_API BaseImporter
* in InternReadFile(), this function will catch it and transform it into
* a suitable response to the caller.
*/
aiScene* ReadFile( const std::string& pFile, IOSystem* pIOHandler);
aiScene* ReadFile(
const std::string& pFile,
IOSystem* pIOHandler
);

// -------------------------------------------------------------------
/** Returns the error description of the last error that occured.
Expand All @@ -218,18 +218,22 @@ class ASSIMP_API BaseImporter
* basing on the Importer's configuration property list.
* @param pImp Importer instance
*/
virtual void SetupProperties(const Importer* pImp);
virtual void SetupProperties(
const Importer* pImp
);

protected:

// -------------------------------------------------------------------
/** Called by Importer::GetExtensionList() for each loaded importer.
* Importer implementations should append all file extensions
* which they supported to the passed string.
* Example: "*.blabb;*.quak;*.gug;*.foo" (no delimiter after the last!)
* @param append Output string
*/
virtual void GetExtensionList(std::string& append) = 0;
* Implementations are expected to insert() all file extensions
* handled by them into the extension set. A loader capable of
* reading certain files with the extension BLA would place the
* string bla (lower-case!) in the output set.
* @param extensions Output set. */
virtual void GetExtensionList(
std::set<std::string>& extensions
) = 0;

// -------------------------------------------------------------------
/** Imports the given file into the given scene structure. The
Expand Down Expand Up @@ -274,10 +278,12 @@ class ASSIMP_API BaseImporter
* @param pScene The scene object to hold the imported data.
* NULL is not a valid parameter.
* @param pIOHandler The IO handler to use for any file access.
* NULL is not a valid parameter.
*/
virtual void InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler) = 0;
* NULL is not a valid parameter. */
virtual void InternReadFile(
const std::string& pFile,
aiScene* pScene,
IOSystem* pIOHandler
) = 0;

public: // static utilities

Expand All @@ -295,11 +301,12 @@ class ASSIMP_API BaseImporter
* @param numTokens Size of the token array
* @param searchBytes Number of bytes to be searched for the tokens.
*/
static bool SearchFileHeaderForToken(IOSystem* pIOSystem,
static bool SearchFileHeaderForToken(
IOSystem* pIOSystem,
const std::string& file,
const char** tokens,
unsigned int numTokens,
unsigned int searchBytes = 200);
const char** tokens,
unsigned int numTokens,
unsigned int searchBytes = 200);


// -------------------------------------------------------------------
Expand All @@ -310,7 +317,8 @@ class ASSIMP_API BaseImporter
* @param ext2 Optional third extension
* @note Case-insensitive
*/
static bool SimpleExtensionCheck (const std::string& pFile,
static bool SimpleExtensionCheck (
const std::string& pFile,
const char* ext0,
const char* ext1 = NULL,
const char* ext2 = NULL);
Expand All @@ -320,7 +328,8 @@ class ASSIMP_API BaseImporter
* @param pFile Input file
* @return Extension without trailing dot, all lowercase
*/
static std::string GetExtension (const std::string& pFile);
static std::string GetExtension (
const std::string& pFile);

// -------------------------------------------------------------------
/** @brief Check whether a file starts with one or more magic tokens
Expand All @@ -336,7 +345,9 @@ class ASSIMP_API BaseImporter
* byte-swapped variant of all tokens (big endian). Only for
* tokens of size 2,4.
*/
static bool CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile,
static bool CheckMagicToken(
IOSystem* pIOHandler,
const std::string& pFile,
const void* magic,
unsigned int num,
unsigned int offset = 0,
Expand All @@ -348,7 +359,8 @@ class ASSIMP_API BaseImporter
*
* @param data File buffer to be converted to UTF8 data. The buffer
* is resized as appropriate. */
static void ConvertToUTF8(std::vector<char>& data);
static void ConvertToUTF8(
std::vector<char>& data);

// -------------------------------------------------------------------
/** Utility for text file loaders which copies the contents of the
Expand All @@ -358,7 +370,8 @@ class ASSIMP_API BaseImporter
* @param data Output buffer to be resized and filled with the
* converted text file data. The buffer is terminated with
* a binary 0. */
static void TextFileToBuffer(IOStream* stream,
static void TextFileToBuffer(
IOStream* stream,
std::vector<char>& data);

protected:
Expand All @@ -377,7 +390,7 @@ struct BatchData;
* could, this has not yet been implemented at the moment).
*
* @note The class may not be used by more than one thread*/
class ASSIMP_API BatchLoader
class ASSIMP_API BatchLoader
{
// friend of Importer

Expand Down Expand Up @@ -408,10 +421,12 @@ class ASSIMP_API BatchLoader


// -------------------------------------------------------------------
/** Construct a batch loader from a given IO system to be used to acess external files */
/** Construct a batch loader from a given IO system to be used
* to acess external files */
BatchLoader(IOSystem* pIO);
~BatchLoader();


// -------------------------------------------------------------------
/** Add a new file to the list of files to be loaded.
* @param file File to be loaded
Expand All @@ -420,8 +435,12 @@ class ASSIMP_API BatchLoader
* @return 'Load request channel' - an unique ID that can later
* be used to access the imported file data.
* @see GetImport */
unsigned int AddLoadRequest (const std::string& file,
unsigned int steps = 0, const PropertyMap* map = NULL);
unsigned int AddLoadRequest (
const std::string& file,
unsigned int steps = 0,
const PropertyMap* map = NULL
);


// -------------------------------------------------------------------
/** Get an imported scene.
Expand All @@ -432,10 +451,14 @@ class ASSIMP_API BatchLoader
* @param which LRWC returned by AddLoadRequest().
* @return NULL if there is no scene with this file name
* in the queue of the scene hasn't been loaded yet. */
aiScene* GetImport (unsigned int which);
aiScene* GetImport(
unsigned int which
);


// -------------------------------------------------------------------
/** Waits until all scenes have been loaded. */
/** Waits until all scenes have been loaded. This returns
* immediately if no scenes are queued.*/
void LoadAll();

private:
Expand Down
4 changes: 2 additions & 2 deletions code/CSMLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ bool CSMImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool

// ------------------------------------------------------------------------------------------------
// Build a string of all file extensions supported
void CSMImporter::GetExtensionList(std::string& append)
void CSMImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.csm");
extensions.insert("csm");
}

// ------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion code/CSMLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CSMImporter : public BaseImporter
protected:

// -------------------------------------------------------------------
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);


// -------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions code/ColladaLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo

// ------------------------------------------------------------------------------------------------
// Get file extension list
void ColladaLoader::GetExtensionList( std::string& append)
void ColladaLoader::GetExtensionList( std::set<std::string>& extensions )
{
append.append("*.dae");
extensions.insert("dae");
}

// ------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion code/ColladaLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ColladaLoader : public BaseImporter
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList( std::string& append);
void GetExtensionList( std::set<std::string>& extensions);

/** Imports the given file into the given scene structure.
* See BaseImporter::InternReadFile() for details
Expand Down
4 changes: 2 additions & 2 deletions code/DXFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool

// ------------------------------------------------------------------------------------------------
// Get a list of all supported file extensions
void DXFImporter::GetExtensionList(std::string& append)
void DXFImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.dxf");
extensions.insert("dxf");
}

// ------------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 5738860

Please sign in to comment.