Skip to content

Commit

Permalink
Removed aiProcess_FindDegenerates from the viewer. The step seems to …
Browse files Browse the repository at this point in the history
…cause some problems that have not yet been solved.

Added irrmesh (Irrlicht Mesh Format) loader to Assimp. Works quite stable, but no lightmapping support yet.
Removed tinyxml, replaced it with irrxml instead. Added an IOStreamToIrrXML wrapper.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@194 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
  • Loading branch information
aramis_acg committed Oct 24, 2008
1 parent 44ea300 commit ce6ce09
Show file tree
Hide file tree
Showing 46 changed files with 4,126 additions and 9,756 deletions.
41 changes: 41 additions & 0 deletions code/BaseImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,46 @@ void BaseImporter::SetupProperties(const Importer* pImp)
// the default implementation does nothing
}

// ------------------------------------------------------------------------------------------------
bool BaseImporter::SearchFileHeaderForToken(IOSystem* pIOHandler,
const std::string& pFile,
const char** tokens,
unsigned int numTokens,
unsigned int searchBytes /* = 200 */)
{
ai_assert(NULL != tokens && 0 != numTokens && NULL != pIOHandler && 0 != searchBytes);

boost::scoped_ptr<IOStream> pStream (pIOHandler->Open(pFile));
if (pStream.get() )
{
// read 200 characters from the file
boost::scoped_ptr<char> _buffer (new char[searchBytes]);
char* buffer = _buffer.get();

unsigned int read = (unsigned int)pStream->Read(buffer,1,searchBytes);
if (!read)return false;

for (unsigned int i = 0; i < read;++i)
buffer[i] = ::tolower(buffer[i]);

// It is not a proper handling of unicode files here ...
// ehm ... but it works in most cases.
char* cur = buffer,*cur2 = buffer,*end = &buffer[read];
while (cur != end)
{
if (*cur)*cur2++ = *cur;
++cur;
}
*cur2 = '\0';

for (unsigned int i = 0; i < numTokens;++i)
{
ai_assert(NULL != tokens[i]);
if (::strstr(buffer,tokens[i]))return true;
}
}
return false;
}



21 changes: 21 additions & 0 deletions code/BaseImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,27 @@ class ASSIMP_API BaseImporter
virtual void InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler) = 0;


// -------------------------------------------------------------------
/** A utility for CanRead().
*
* The function searches the header of a file for a specific token
* and returns true if this token is found. This works for text
* files only. There is a rudimentary handling if UNICODE files.
* The comparison is case independent.
*
* @param pIOSystem IO System to work with
* @param file File name of the file
* @param tokens List of tokens to search for
* @param numTokens Size of the token array
* @param searchBytes Number of bytes to be searched for the tokens.
*/
static bool SearchFileHeaderForToken(IOSystem* pIOSystem,
const std::string& file,
const char** tokens,
unsigned int numTokens,
unsigned int searchBytes = 200);

protected:

/** Error description in case there was one. */
Expand Down
7 changes: 3 additions & 4 deletions code/DXFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "DXFLoader.h"
#include "ParsingUtils.h"
#include "fast_atof.h"
#include "MaterialSystem.h"


using namespace Assimp;
Expand Down Expand Up @@ -246,7 +245,7 @@ void DXFImporter::InternReadFile( const std::string& pFile,
{
aiFace& face = pMesh->mFaces[i];

// check whether we need four,three or two indices here
// check whether we need four, three or two indices here
if (vp[1] == vp[2])
{
face.mNumIndices = 2;
Expand All @@ -263,7 +262,7 @@ void DXFImporter::InternReadFile( const std::string& pFile,
*vpOut++ = vp[a];
if (clr)
{
if (std::numeric_limits<float>::quiet_NaN() != clr[a].r)
if (is_not_qnan( clr[a].r ))
*clrOut = clr[a];

++clrOut;
Expand Down Expand Up @@ -437,7 +436,7 @@ bool DXFImporter::ParsePolyLine()
// optional number of faces
case 72:
{
indices.reserve(strtol10(cursor) * 4u);
indices.reserve(strtol10(cursor));
break;
}

Expand Down
Loading

0 comments on commit ce6ce09

Please sign in to comment.