Merge branch 'master' of github.com:assimp/assimp

pull/60/head
Alexander Gessler 2013-06-25 16:40:18 +02:00
commit 07c1b2a68f
9 changed files with 81 additions and 66 deletions

View File

@ -58,6 +58,9 @@ void ExportSceneCollada(const char* pFile,IOSystem* pIOSystem, const aiScene* pS
// we're still here - export successfully completed. Write result to the given IOSYstem // we're still here - export successfully completed. Write result to the given IOSYstem
boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt")); boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
if(outfile == NULL) {
throw DeadlyExportError("could not open output .dae file: " + std::string(pFile));
}
// XXX maybe use a small wrapper around IOStream that behaves like std::stringstream in order to avoid the extra copy. // XXX maybe use a small wrapper around IOStream that behaves like std::stringstream in order to avoid the extra copy.
outfile->Write( iDoTheExportThing.mOutput.str().c_str(), static_cast<size_t>(iDoTheExportThing.mOutput.tellp()),1); outfile->Write( iDoTheExportThing.mOutput.str().c_str(), static_cast<size_t>(iDoTheExportThing.mOutput.tellp()),1);

View File

@ -192,11 +192,19 @@ void IFCImporter::InternReadFile( const std::string& pFile,
} }
// search file (same name as the IFCZIP except for the file extension) and place file pointer there // search file (same name as the IFCZIP except for the file extension) and place file pointer there
if ( unzLocateFile( zip, fileName.c_str(), 0 ) == UNZ_OK )
{ if(UNZ_OK == unzGoToFirstFile(zip)) {
do {
//
// get file size, etc. // get file size, etc.
unz_file_info fileInfo; unz_file_info fileInfo;
unzGetCurrentFileInfo( zip , &fileInfo, 0, 0, 0, 0, 0, 0 ); char filename[256];
unzGetCurrentFileInfo( zip , &fileInfo, filename, sizeof(filename), 0, 0, 0, 0 );
if (GetExtension(filename) != "ifc") {
continue;
}
uint8_t* buff = new uint8_t[fileInfo.uncompressed_size]; uint8_t* buff = new uint8_t[fileInfo.uncompressed_size];
@ -212,9 +220,16 @@ void IFCImporter::InternReadFile( const std::string& pFile,
} }
unzCloseCurrentFile( zip ); unzCloseCurrentFile( zip );
stream.reset(new MemoryIOStream(buff,fileInfo.uncompressed_size,true)); stream.reset(new MemoryIOStream(buff,fileInfo.uncompressed_size,true));
break;
if (unzGoToNextFile(zip) == UNZ_END_OF_LIST_OF_FILE) {
ThrowException("Found no IFC file member in IFCZIP file (1)");
}
} while(true);
} }
else { else {
ThrowException("Found no IFC file member in IFCZIP file"); ThrowException("Found no IFC file member in IFCZIP file (2)");
} }
unzClose(zip); unzClose(zip);

View File

@ -59,10 +59,16 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
// we're still here - export successfully completed. Write both the main OBJ file and the material script // we're still here - export successfully completed. Write both the main OBJ file and the material script
{ {
boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt")); boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
if(outfile == NULL) {
throw DeadlyExportError("could not open output .obj file: " + std::string(pFile));
}
outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1); outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
} }
{ {
boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(exporter.GetMaterialLibFileName(),"wt")); boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(exporter.GetMaterialLibFileName(),"wt"));
if(outfile == NULL) {
throw DeadlyExportError("could not open output .mtl file: " + std::string(exporter.GetMaterialLibFileName()));
}
outfile->Write( exporter.mOutputMat.str().c_str(), static_cast<size_t>(exporter.mOutputMat.tellp()),1); outfile->Write( exporter.mOutputMat.str().c_str(), static_cast<size_t>(exporter.mOutputMat.tellp()),1);
} }
} }

1
code/ObjFileData.h 100644 → 100755
View File

@ -283,6 +283,7 @@ struct Model
m_pCurrent(NULL), m_pCurrent(NULL),
m_pCurrentMaterial(NULL), m_pCurrentMaterial(NULL),
m_pDefaultMaterial(NULL), m_pDefaultMaterial(NULL),
m_pGroupFaceIDs(NULL),
m_strActiveGroup(""), m_strActiveGroup(""),
m_pCurrentMesh(NULL) m_pCurrentMesh(NULL)
{ {

View File

@ -528,18 +528,12 @@ int ObjFileParser::getMaterialIndex( const std::string &strMaterialName )
// Getter for a group name. // Getter for a group name.
void ObjFileParser::getGroupName() void ObjFileParser::getGroupName()
{ {
// Get next word from data buffer std::string strGroupName;
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
m_DataIt = getNextWord<DataArrayIt>(m_DataIt, m_DataItEnd); m_DataIt = getName<DataArrayIt>(m_DataIt, m_DataItEnd, strGroupName);
if ( isEndOfBuffer( m_DataIt, m_DataItEnd ) ) if ( isEndOfBuffer( m_DataIt, m_DataItEnd ) )
return; return;
// Store the group name in the group library
char *pStart = &(*m_DataIt);
while ( m_DataIt != m_DataItEnd && !isSeparator(*m_DataIt) )
m_DataIt++;
std::string strGroupName( pStart, &(*m_DataIt) );
// Change active group, if necessary // Change active group, if necessary
if ( m_pModel->m_strActiveGroup != strGroupName ) if ( m_pModel->m_strActiveGroup != strGroupName )
{ {

View File

@ -57,6 +57,10 @@ void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
// we're still here - export successfully completed. Write the file. // we're still here - export successfully completed. Write the file.
boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt")); boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
if(outfile == NULL) {
throw DeadlyExportError("could not open output .ply file: " + std::string(pFile));
}
outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1); outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
} }

View File

@ -57,6 +57,10 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
// we're still here - export successfully completed. Write the file. // we're still here - export successfully completed. Write the file.
boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt")); boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
if(outfile == NULL) {
throw DeadlyExportError("could not open output .stl file: " + std::string(pFile));
}
outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1); outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
} }

View File

@ -135,8 +135,9 @@ struct aiFace
//! Default constructor //! Default constructor
aiFace() aiFace()
: mNumIndices( 0 )
, mIndices( NULL )
{ {
mNumIndices = 0; mIndices = NULL;
} }
//! Default destructor. Delete the index array //! Default destructor. Delete the index array
@ -147,13 +148,13 @@ struct aiFace
//! Copy constructor. Copy the index array //! Copy constructor. Copy the index array
aiFace( const aiFace& o) aiFace( const aiFace& o)
: mIndices( NULL )
{ {
mIndices = NULL;
*this = o; *this = o;
} }
//! Assignment operator. Copy the index array //! Assignment operator. Copy the index array
const aiFace& operator = ( const aiFace& o) aiFace& operator = ( const aiFace& o)
{ {
if (&o == this) if (&o == this)
return *this; return *this;
@ -248,17 +249,17 @@ struct aiBone
//! Default constructor //! Default constructor
aiBone() aiBone()
: mNumWeights( 0 )
, mWeights( NULL )
{ {
mNumWeights = 0; mWeights = NULL;
} }
//! Copy constructor //! Copy constructor
aiBone(const aiBone& other) aiBone(const aiBone& other)
: mName( other.mName )
, mNumWeights( other.mNumWeights )
, mOffsetMatrix( other.mOffsetMatrix )
{ {
mNumWeights = other.mNumWeights;
mOffsetMatrix = other.mOffsetMatrix;
mName = other.mName;
if (other.mWeights && other.mNumWeights) if (other.mWeights && other.mNumWeights)
{ {
mWeights = new aiVertexWeight[mNumWeights]; mWeights = new aiVertexWeight[mNumWeights];
@ -378,10 +379,10 @@ struct aiAnimMesh
#ifdef __cplusplus #ifdef __cplusplus
aiAnimMesh() aiAnimMesh()
: mVertices() : mVertices( NULL )
, mNormals() , mNormals( NULL )
, mTangents() , mTangents( NULL )
, mBitangents() , mBitangents( NULL )
, mNumVertices( 0 ) , mNumVertices( 0 )
{ {
// fixme consider moving this to the ctor initializer list as well // fixme consider moving this to the ctor initializer list as well
@ -610,29 +611,28 @@ struct aiMesh
//! Default constructor. Initializes all members to 0 //! Default constructor. Initializes all members to 0
aiMesh() aiMesh()
: mPrimitiveTypes( 0 )
, mNumVertices( 0 )
, mNumFaces( 0 )
, mVertices( NULL )
, mNormals( NULL )
, mTangents( NULL )
, mBitangents( NULL )
, mFaces( NULL )
, mNumBones( 0 )
, mBones( 0 )
, mMaterialIndex( 0 )
, mNumAnimMeshes( 0 )
, mAnimMeshes( NULL )
{ {
mNumVertices = 0;
mNumFaces = 0;
mNumAnimMeshes = 0;
mPrimitiveTypes = 0;
mVertices = NULL; mFaces = NULL;
mNormals = NULL; mTangents = NULL;
mBitangents = NULL;
mAnimMeshes = NULL;
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
{ {
mNumUVComponents[a] = 0; mNumUVComponents[a] = 0;
mTextureCoords[a] = NULL; mTextureCoords[a] = NULL;
} }
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
mColors[a] = NULL; mColors[a] = NULL;
mNumBones = 0; mBones = NULL;
mMaterialIndex = 0;
mNumAnimMeshes = 0;
mAnimMeshes = NULL;
} }
//! Deletes all storage allocated for the mesh //! Deletes all storage allocated for the mesh

View File

@ -2044,18 +2044,6 @@
> >
</File> </File>
</Filter> </Filter>
<Filter
Name="m3"
>
<File
RelativePath="..\..\code\M3Importer.cpp"
>
</File>
<File
RelativePath="..\..\code\M3Importer.h"
>
</File>
</Filter>
<Filter <Filter
Name="xgl" Name="xgl"
> >