Merge remote-tracking branch 'github/master' into contrib

This commit is contained in:
Leo Terziman
2017-06-08 11:01:11 +02:00
50 changed files with 4328 additions and 2167 deletions

View File

@@ -66,8 +66,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ------------------------------------------------------------------------------------------------
using namespace Assimp;
namespace Assimp
{
namespace Assimp {
// underlying structure for aiPropertyStore
typedef BatchLoader::PropertyMap PropertyMap;
@@ -110,12 +109,11 @@ static std::mutex gLogStreamMutex;
// ------------------------------------------------------------------------------------------------
// Custom LogStream implementation for the C-API
class LogToCallbackRedirector : public LogStream
{
class LogToCallbackRedirector : public LogStream {
public:
explicit LogToCallbackRedirector(const aiLogStream& s)
: stream (s) {
ai_assert(NULL != s.callback);
: stream (s) {
ai_assert(NULL != s.callback);
}
~LogToCallbackRedirector() {
@@ -146,8 +144,7 @@ private:
};
// ------------------------------------------------------------------------------------------------
void ReportSceneNotFoundError()
{
void ReportSceneNotFoundError() {
DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. "
"The C-API does not accept scenes produced by the C++ API and vice versa");
@@ -156,22 +153,18 @@ void ReportSceneNotFoundError()
// ------------------------------------------------------------------------------------------------
// Reads the given file and returns its content.
const aiScene* aiImportFile( const char* pFile, unsigned int pFlags)
{
const aiScene* aiImportFile( const char* pFile, unsigned int pFlags) {
return aiImportFileEx(pFile,pFlags,NULL);
}
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags, aiFileIO* pFS)
{
const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags, aiFileIO* pFS) {
return aiImportFileExWithProperties(pFile, pFlags, pFS, NULL);
}
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFlags,
aiFileIO* pFS,
const aiPropertyStore* props)
{
const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFlags,
aiFileIO* pFS, const aiPropertyStore* props) {
ai_assert(NULL != pFile);
const aiScene* scene = NULL;
@@ -190,7 +183,7 @@ const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFl
pimpl->mMatrixProperties = pp->matrices;
}
// setup a custom IO system if necessary
if (pFS) {
if (pFS) {
imp->SetIOHandler( new CIOSystemWrapper (pFS) );
}
@@ -201,8 +194,7 @@ const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFl
if( scene) {
ScenePrivateData* priv = const_cast<ScenePrivateData*>( ScenePriv(scene) );
priv->mOrigImporter = imp;
}
else {
} else {
// if failed, extract error code and destroy the import
gLastErrorString = imp->GetErrorString();
delete imp;
@@ -210,6 +202,7 @@ const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFl
// return imported data. If the import failed the pointer is NULL anyways
ASSIMP_END_EXCEPTION_REGION(const aiScene*);
return scene;
}

View File

@@ -1726,6 +1726,8 @@ void ColladaLoader::BuildMaterials( ColladaParser& pParser, aiScene* /*pScene*/)
aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pParser,
const Collada::Effect& pEffect, const std::string& pName)
{
aiString result;
// recurse through the param references until we end up at an image
std::string name = pName;
while( 1)
@@ -1744,11 +1746,17 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars
ColladaParser::ImageLibrary::const_iterator imIt = pParser.mImageLibrary.find( name);
if( imIt == pParser.mImageLibrary.end())
{
throw DeadlyImportError( format() <<
"Collada: Unable to resolve effect texture entry \"" << pName << "\", ended up at ID \"" << name << "\"." );
}
//missing texture should not stop the conversion
//throw DeadlyImportError( format() <<
// "Collada: Unable to resolve effect texture entry \"" << pName << "\", ended up at ID \"" << name << "\"." );
aiString result;
DefaultLogger::get()->warn("Collada: Unable to resolve effect texture entry \"" + pName + "\", ended up at ID \"" + name + "\".");
//set default texture file name
result.Set(name + ".jpg");
ConvertPath(result);
return result;
}
// if this is an embedded texture image setup an aiTexture for it
if (imIt->second.mFileName.empty())

View File

@@ -45,6 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOStream.hpp>
#include "ParsingUtils.h"
#include <vector>
namespace Assimp {
// ---------------------------------------------------------------------------
@@ -69,8 +71,8 @@ public:
/// @return true if successful.
bool close();
/// @brief Returns the filesize.
/// @return The filesize.
/// @brief Returns the file-size.
/// @return The file-size.
size_t size() const;
/// @brief Returns the cache size.
@@ -96,7 +98,17 @@ public:
/// @brief Will read the next line.
/// @param buffer The buffer for the next line.
/// @return true if successful.
bool getNextLine( std::vector<T> &buffer );
bool getNextDataLine( std::vector<T> &buffer, T continuationToken );
/// @brief Will read the next line ascii or binary end line char.
/// @param buffer The buffer for the next line.
/// @return true if successful.
bool getNextLine(std::vector<T> &buffer);
/// @brief Will read the next block.
/// @param buffer The buffer for the next block.
/// @return true if successful.
bool getNextBlock( std::vector<T> &buffer );
private:
IOStream *m_stream;
@@ -227,15 +239,35 @@ size_t IOStreamBuffer<T>::getFilePos() const {
template<class T>
inline
bool IOStreamBuffer<T>::getNextLine( std::vector<T> &buffer ) {
bool IOStreamBuffer<T>::getNextDataLine( std::vector<T> &buffer, T continuationToken ) {
buffer.resize( m_cacheSize );
if ( m_cachePos == m_cacheSize || 0 == m_filePos ) {
if ( !readNextBlock() ) {
return false;
}
}
bool continuationFound( false ), endOfDataLine( false );
size_t i = 0;
while ( !IsLineEnd( m_cache[ m_cachePos ] ) ) {
while ( !endOfDataLine ) {
if ( continuationToken == m_cache[ m_cachePos ] ) {
continuationFound = true;
++m_cachePos;
}
if ( IsLineEnd( m_cache[ m_cachePos ] ) ) {
if ( !continuationFound ) {
// the end of the data line
break;
} else {
// skip line end
while ( m_cache[m_cachePos] != '\n') {
++m_cachePos;
}
++m_cachePos;
continuationFound = false;
}
}
buffer[ i ] = m_cache[ m_cachePos ];
m_cachePos++;
i++;
@@ -245,10 +277,63 @@ bool IOStreamBuffer<T>::getNextLine( std::vector<T> &buffer ) {
}
}
}
buffer[ i ] = '\n';
m_cachePos++;
return true;
}
template<class T>
inline
bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
buffer.resize(m_cacheSize);
if (m_cachePos == m_cacheSize || 0 == m_filePos) {
if (!readNextBlock()) {
return false;
}
}
if (IsLineEnd(m_cache[m_cachePos])) {
// skip line end
while (m_cache[m_cachePos] != '\n') {
++m_cachePos;
}
++m_cachePos;
}
size_t i = 0;
while (!IsLineEnd(m_cache[m_cachePos])) {
buffer[i] = m_cache[m_cachePos];
m_cachePos++;
i++;
if (m_cachePos >= m_cacheSize) {
if (!readNextBlock()) {
return false;
}
}
}
buffer[i] = '\n';
m_cachePos++;
return true;
}
template<class T>
inline
bool IOStreamBuffer<T>::getNextBlock( std::vector<T> &buffer) {
//just return the last blockvalue if getNextLine was used before
if ( m_cachePos != 0) {
buffer = std::vector<T>(m_cache.begin() + m_cachePos, m_cache.end());
m_cachePos = 0;
}
else {
if ( !readNextBlock() )
return false;
buffer = std::vector<T>(m_cache.begin(), m_cache.end());
}
return true;
}
} // !ns Assimp

View File

@@ -109,7 +109,7 @@ ObjFile::Model *ObjFileParser::GetModel() const {
return m_pModel;
}
void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer)
/*void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer)
{
auto curPosition = buffer.begin();
do
@@ -123,13 +123,13 @@ void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffe
std::vector<char> tempBuf;
do
{
streamBuffer.getNextLine(tempBuf);
streamBuffer.getNextDataLine(tempBuf, '\\' );
} while (tempBuf[0]=='\n');
*curPosition = ' ';
std::copy(tempBuf.cbegin(), tempBuf.cend(), ++curPosition);
}
} while (*curPosition!='\n');
}
}*/
void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
// only update every 100KB or it'll be too slow
@@ -142,7 +142,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
size_t lastFilePos( 0 );
std::vector<char> buffer;
while ( streamBuffer.getNextLine( buffer ) ) {
while ( streamBuffer.getNextDataLine( buffer, '\\' ) ) {
m_DataIt = buffer.begin();
m_DataItEnd = buffer.end();
@@ -154,14 +154,14 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
progressCounter++;
m_progress->UpdateFileRead( progressOffset + processed * 2, progressTotal );
}
//ignoreNewLines(streamBuffer, buffer);
// parse line
switch (*m_DataIt) {
case 'v': // Parse a vertex texture coordinate
{
++m_DataIt;
if (*m_DataIt == ' ' || *m_DataIt == '\t') {
size_t numComponents = getNumComponentsInLine();
size_t numComponents = getNumComponentsInDataDefinition();
if (numComponents == 3) {
// read in vertex definition
getVector3(m_pModel->m_Vertices);
@@ -245,7 +245,6 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
default:
{
pf_skip_line:
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
}
break;
@@ -274,21 +273,44 @@ void ObjFileParser::copyNextWord(char *pBuffer, size_t length) {
pBuffer[index] = '\0';
}
size_t ObjFileParser::getNumComponentsInLine() {
static bool isDataDefinitionEnd( const char *tmp ) {
if ( *tmp == '\\' ) {
tmp++;
if ( IsLineEnd( *tmp ) ) {
tmp++;
return true;
}
}
return false;
}
size_t ObjFileParser::getNumComponentsInDataDefinition() {
size_t numComponents( 0 );
const char* tmp( &m_DataIt[0] );
while( !IsLineEnd( *tmp ) ) {
bool end_of_definition = false;
while ( !end_of_definition ) {
if ( isDataDefinitionEnd( tmp ) ) {
tmp += 2;
} else if ( IsLineEnd( *tmp ) ) {
end_of_definition = true;
}
if ( !SkipSpaces( &tmp ) ) {
break;
}
const bool isNum( IsNumeric( *tmp ) );
SkipToken( tmp );
++numComponents;
if ( isNum ) {
++numComponents;
}
if ( !SkipSpaces( &tmp ) ) {
break;
}
}
return numComponents;
}
void ObjFileParser::getVector( std::vector<aiVector3D> &point3d_array ) {
size_t numComponents = getNumComponentsInLine();
size_t numComponents = getNumComponentsInDataDefinition();
ai_real x, y, z;
if( 2 == numComponents ) {
copyNextWord( m_buffer, Buffersize );
@@ -397,10 +419,6 @@ static const std::string DefaultObjName = "defaultobject";
// -------------------------------------------------------------------
// Get values for a new face instance
void ObjFileParser::getFace( aiPrimitiveType type ) {
//copyNextLine(m_buffer, Buffersize);
//char *pPtr = m_DataIt;
//char *pPtr = m_buffer;
//char *pEnd = &pPtr[Buffersize];
m_DataIt = getNextToken<DataArrayIt>( m_DataIt, m_DataItEnd );
if ( m_DataIt == m_DataItEnd || *m_DataIt == '\0' ) {
return;
@@ -571,14 +589,7 @@ void ObjFileParser::getMaterialDesc() {
// -------------------------------------------------------------------
// Get a comment, values will be skipped
void ObjFileParser::getComment() {
while (m_DataIt != m_DataItEnd) {
if ( '\n' == (*m_DataIt)) {
++m_DataIt;
break;
} else {
++m_DataIt;
}
}
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
}
// -------------------------------------------------------------------

View File

@@ -91,6 +91,8 @@ protected:
void copyNextWord(char *pBuffer, size_t length);
/// Method to copy the new line.
// void copyNextLine(char *pBuffer, size_t length);
/// Get the number of components in a line.
size_t getNumComponentsInDataDefinition();
/// Stores the vector
void getVector( std::vector<aiVector3D> &point3d_array );
/// Stores the following 3d vector.
@@ -129,8 +131,6 @@ protected:
bool needsNewMesh( const std::string &rMaterialName );
/// Error report in token
void reportErrorTokenInFace();
/// Get the number of components in a line.
size_t getNumComponentsInLine();
private:
// Copy and assignment constructor should be private

View File

@@ -116,14 +116,16 @@ inline char_t skipLine( char_t it, char_t end, unsigned int &uiLine ) {
while( !isEndOfBuffer( it, end ) && !IsLineEnd( *it ) ) {
++it;
}
if ( it != end )
{
if ( it != end ) {
++it;
++uiLine;
}
// fix .. from time to time there are spaces at the beginning of a material line
while ( it != end && (*it == '\t' || *it == ' ') )
while ( it != end && ( *it == '\t' || *it == ' ' ) ) {
++it;
}
return it;
}

File diff suppressed because it is too large Load Diff

View File

@@ -68,7 +68,6 @@ public:
PLYImporter();
~PLYImporter();
public:
// -------------------------------------------------------------------
@@ -78,6 +77,16 @@ public:
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
bool checkSig) const;
// -------------------------------------------------------------------
/** Extract a vertex from the DOM
*/
void LoadVertex(const PLY::Element* pcElement, const PLY::ElementInstance* instElement, unsigned int pos);
// -------------------------------------------------------------------
/** Extract a face from the DOM
*/
void LoadFace(const PLY::Element* pcElement, const PLY::ElementInstance* instElement, unsigned int pos);
protected:
// -------------------------------------------------------------------
@@ -94,53 +103,10 @@ protected:
IOSystem* pIOHandler);
protected:
// -------------------------------------------------------------------
/** Extract vertices from the DOM
*/
void LoadVertices(std::vector<aiVector3D>* pvOut,
bool p_bNormals = false);
// -------------------------------------------------------------------
/** Extract vertex color channels from the DOM
*/
void LoadVertexColor(std::vector<aiColor4D>* pvOut);
// -------------------------------------------------------------------
/** Extract texture coordinate channels from the DOM
*/
void LoadTextureCoordinates(std::vector<aiVector2D>* pvOut);
// -------------------------------------------------------------------
/** Extract a face list from the DOM
*/
void LoadFaces(std::vector<PLY::Face>* pvOut);
// -------------------------------------------------------------------
/** Extract a material list from the DOM
*/
void LoadMaterial(std::vector<aiMaterial*>* pvOut);
// -------------------------------------------------------------------
/** Validate material indices, replace default material identifiers
*/
void ReplaceDefaultMaterial(std::vector<PLY::Face>* avFaces,
std::vector<aiMaterial*>* avMaterials);
// -------------------------------------------------------------------
/** Convert all meshes into our ourer representation
*/
void ConvertMeshes(std::vector<PLY::Face>* avFaces,
const std::vector<aiVector3D>* avPositions,
const std::vector<aiVector3D>* avNormals,
const std::vector<aiColor4D>* avColors,
const std::vector<aiVector2D>* avTexCoords,
const std::vector<aiMaterial*>* avMaterials,
std::vector<aiMesh*>* avOut);
void LoadMaterial(std::vector<aiMaterial*>* pvOut, std::string &defaultTexture, const bool pointsOnly);
// -------------------------------------------------------------------
/** Static helper to parse a color from four single channels in
@@ -151,7 +117,6 @@ protected:
PLY::EDataType aiTypes[4],
aiColor4D* clrOut);
// -------------------------------------------------------------------
/** Static helper to parse a color channel value. The input value
* is normalized to 0-1.
@@ -160,12 +125,14 @@ protected:
PLY::PropertyInstance::ValueUnion val,
PLY::EDataType eType);
/** Buffer to hold the loaded file */
unsigned char* mBuffer;
/** Document object model representation extracted from the file */
PLY::DOM* pcDOM;
/** Mesh generated by loader */
aiMesh* mGeneratedMesh;
};
} // end of namespace Assimp

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,6 @@ Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -46,19 +45,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ParsingUtils.h"
#include "IOStreamBuffer.h"
#include <vector>
namespace Assimp
{
//pre-declaration
class PLYImporter;
// http://local.wasp.uwa.edu.au/~pbourke/dataformats/ply/
// http://w3.impa.br/~lvelho/outgoing/sossai/old/ViHAP_D4.4.2_PLY_format_v1.1.pdf
// http://www.okino.com/conv/exp_ply.htm
namespace PLY
{
// ---------------------------------------------------------------------------------
/*
name type number of bytes
@@ -197,6 +198,9 @@ enum EElementSemantic
//! The element is a material description
EEST_Material,
//! texture path
EEST_TextureFile,
//! Marks invalid entries
EEST_INVALID
};
@@ -238,16 +242,15 @@ public:
//! string is either '\n', '\r' or '\0'. Return value is false
//! if the input string is NOT a valid property (E.g. does
//! not start with the "property" keyword)
static bool ParseProperty (const char* pCur, const char** pCurOut,
Property* pOut);
static bool ParseProperty(std::vector<char> &buffer, Property* pOut);
// -------------------------------------------------------------------
//! Parse a data type from a string
static EDataType ParseDataType(const char* pCur,const char** pCurOut);
static EDataType ParseDataType(std::vector<char> &buffer);
// -------------------------------------------------------------------
//! Parse a semantic from a string
static ESemantic ParseSemantic(const char* pCur,const char** pCurOut);
static ESemantic ParseSemantic(std::vector<char> &buffer);
};
// ---------------------------------------------------------------------------------
@@ -285,13 +288,11 @@ public:
//! Parse an element from a string.
//! The function will parse all properties contained in the
//! element, too.
static bool ParseElement (const char* pCur, const char** pCurOut,
Element* pOut);
static bool ParseElement(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer, Element* pOut);
// -------------------------------------------------------------------
//! Parse a semantic from a string
static EElementSemantic ParseSemantic(const char* pCur,
const char** pCurOut);
static EElementSemantic ParseSemantic(std::vector<char> &buffer);
};
// ---------------------------------------------------------------------------------
@@ -331,13 +332,13 @@ public:
// -------------------------------------------------------------------
//! Parse a property instance
static bool ParseInstance (const char* pCur,const char** pCurOut,
static bool ParseInstance(const char* &pCur,
const Property* prop, PropertyInstance* p_pcOut);
// -------------------------------------------------------------------
//! Parse a property instance in binary format
static bool ParseInstanceBinary (const char* pCur,const char** pCurOut,
const Property* prop, PropertyInstance* p_pcOut,bool p_bBE);
static bool ParseInstanceBinary(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer,
const char* &pCur, unsigned int &bufferSize, const Property* prop, PropertyInstance* p_pcOut, bool p_bBE);
// -------------------------------------------------------------------
//! Get the default value for a given data type
@@ -345,13 +346,12 @@ public:
// -------------------------------------------------------------------
//! Parse a value
static bool ParseValue(const char* pCur,const char** pCurOut,
EDataType eType,ValueUnion* out);
static bool ParseValue(const char* &pCur, EDataType eType, ValueUnion* out);
// -------------------------------------------------------------------
//! Parse a binary value
static bool ParseValueBinary(const char* pCur,const char** pCurOut,
EDataType eType,ValueUnion* out,bool p_bBE);
static bool ParseValueBinary(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer,
const char* &pCur, unsigned int &bufferSize, EDataType eType, ValueUnion* out, bool p_bBE);
// -------------------------------------------------------------------
//! Convert a property value to a given type TYPE
@@ -375,13 +375,13 @@ public:
// -------------------------------------------------------------------
//! Parse an element instance
static bool ParseInstance (const char* pCur,const char** pCurOut,
static bool ParseInstance(const char* &pCur,
const Element* pcElement, ElementInstance* p_pcOut);
// -------------------------------------------------------------------
//! Parse a binary element instance
static bool ParseInstanceBinary (const char* pCur,const char** pCurOut,
const Element* pcElement, ElementInstance* p_pcOut,bool p_bBE);
static bool ParseInstanceBinary(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer,
const char* &pCur, unsigned int &bufferSize, const Element* pcElement, ElementInstance* p_pcOut, bool p_bBE);
};
// ---------------------------------------------------------------------------------
@@ -400,13 +400,13 @@ public:
// -------------------------------------------------------------------
//! Parse an element instance list
static bool ParseInstanceList (const char* pCur,const char** pCurOut,
const Element* pcElement, ElementInstanceList* p_pcOut);
static bool ParseInstanceList(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer,
const Element* pcElement, ElementInstanceList* p_pcOut, PLYImporter* loader);
// -------------------------------------------------------------------
//! Parse a binary element instance list
static bool ParseInstanceListBinary (const char* pCur,const char** pCurOut,
const Element* pcElement, ElementInstanceList* p_pcOut,bool p_bBE);
static bool ParseInstanceListBinary(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer,
const char* &pCur, unsigned int &bufferSize, const Element* pcElement, ElementInstanceList* p_pcOut, PLYImporter* loader, bool p_bBE);
};
// ---------------------------------------------------------------------------------
/** \brief Class to represent the document object model of an ASCII or binary
@@ -428,50 +428,33 @@ public:
//! Parse the DOM for a PLY file. The input string is assumed
//! to be terminated with zero
static bool ParseInstance (const char* pCur,DOM* p_pcOut);
static bool ParseInstanceBinary (const char* pCur,
DOM* p_pcOut,bool p_bBE);
static bool ParseInstance(IOStreamBuffer<char> &streamBuffer, DOM* p_pcOut, PLYImporter* loader);
static bool ParseInstanceBinary(IOStreamBuffer<char> &streamBuffer, DOM* p_pcOut, PLYImporter* loader, bool p_bBE);
//! Skip all comment lines after this
static bool SkipComments (const char* pCur,const char** pCurOut);
static bool SkipComments(std::vector<char> &buffer);
static bool SkipSpaces(std::vector<char> &buffer);
static bool SkipLine(std::vector<char> &buffer);
static bool TokenMatch(std::vector<char> &buffer, const char* token, unsigned int len);
static bool SkipSpacesAndLineEnd(std::vector<char> &buffer);
private:
// -------------------------------------------------------------------
//! Handle the file header and read all element descriptions
bool ParseHeader (const char* pCur,const char** pCurOut, bool p_bBE);
bool ParseHeader(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer, bool p_bBE);
// -------------------------------------------------------------------
//! Read in all element instance lists
bool ParseElementInstanceLists (const char* pCur,const char** pCurOut);
bool ParseElementInstanceLists(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer, PLYImporter* loader);
// -------------------------------------------------------------------
//! Read in all element instance lists for a binary file format
bool ParseElementInstanceListsBinary (const char* pCur,
const char** pCurOut,bool p_bBE);
};
// ---------------------------------------------------------------------------------
/** \brief Helper class to represent a loaded PLY face
*/
class Face
{
public:
Face()
: iMaterialIndex(0xFFFFFFFF)
{
// set all indices to zero by default
mIndices.resize(3,0);
}
public:
//! List of vertex indices
std::vector<unsigned int> mIndices;
//! Material index
unsigned int iMaterialIndex;
bool ParseElementInstanceListsBinary(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer, const char* &pCur, unsigned int &bufferSize, PLYImporter* loader, bool p_bBE);
};
// ---------------------------------------------------------------------------------

View File

@@ -211,20 +211,20 @@ void STLImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
for (unsigned int i = 0; i < pScene->mNumMeshes; i++)
pScene->mRootNode->mMeshes[i] = i;
// create a single default material, using a light gray diffuse color for consistency with
// create a single default material, using a white diffuse color for consistency with
// other geometric types (e.g., PLY).
aiMaterial* pcMat = new aiMaterial();
aiString s;
s.Set(AI_DEFAULT_MATERIAL_NAME);
pcMat->AddProperty(&s, AI_MATKEY_NAME);
aiColor4D clrDiffuse(ai_real(0.6),ai_real(0.6),ai_real(0.6),ai_real(1.0));
aiColor4D clrDiffuse(ai_real(1.0),ai_real(1.0),ai_real(1.0),ai_real(1.0));
if (bMatClr) {
clrDiffuse = clrColorDefault;
}
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_DIFFUSE);
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_SPECULAR);
clrDiffuse = aiColor4D( ai_real( 0.05), ai_real( 0.05), ai_real( 0.05), ai_real( 1.0));
clrDiffuse = aiColor4D( ai_real(1.0), ai_real(1.0), ai_real(1.0), ai_real(1.0));
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_AMBIENT);
pScene->mNumMaterials = 1;

View File

@@ -126,9 +126,8 @@ void SpatialSort::FindPositions( const aiVector3D& pPosition,
const ai_real dist = pPosition * mPlaneNormal;
const ai_real minDist = dist - pRadius, maxDist = dist + pRadius;
// clear the array in this strange fashion because a simple clear() would also deallocate
// the array which we want to avoid
poResults.erase( poResults.begin(), poResults.end());
// clear the array
poResults.clear();
// quick check for positions outside the range
if( mPositions.size() == 0)

View File

@@ -1,3 +1,5 @@
#pragma once
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h
@@ -22,6 +24,7 @@
#include <assimp/defs.h>
#include "StringComparison.h"
#include <assimp/DefaultLogger.hpp>
#ifdef _MSC_VER
@@ -192,7 +195,7 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int*
uint64_t value = 0;
if ( *in < '0' || *in > '9' )
throw std::invalid_argument(std::string("The string \"") + in + "\" cannot be converted into a value.");
throw std::invalid_argument(std::string("The string \"") + in + "\" cannot be converted into a value.");
bool running = true;
while ( running )
@@ -202,8 +205,12 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int*
const uint64_t new_value = ( value * 10 ) + ( *in - '0' );
if (new_value < value) /* numeric overflow, we rely on you */
throw std::overflow_error(std::string("Converting the string \"") + in + "\" into a value resulted in overflow.");
// numeric overflow, we rely on you
if ( new_value < value ) {
DefaultLogger::get()->warn( std::string( "Converting the string \"" ) + in + "\" into a value resulted in overflow." );
return 0;
}
//throw std::overflow_error();
value = new_value;