diff --git a/code/JoinVerticesProcess.h b/code/JoinVerticesProcess.h index af92040d2..b1a9aa910 100644 --- a/code/JoinVerticesProcess.h +++ b/code/JoinVerticesProcess.h @@ -62,7 +62,6 @@ namespace Assimp class ASSIMP_API JoinVerticesProcess : public BaseProcess { public: - JoinVerticesProcess(); ~JoinVerticesProcess(); diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index 8e91ce7c3..8594a4126 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -197,13 +197,15 @@ static aiString ReadString(StreamReaderLE* stream, uint32_t numWChars) // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -SIBImporter::SIBImporter() -{} +SIBImporter::SIBImporter() { + // empty +} // ------------------------------------------------------------------------------------------------ // Destructor, private as well -SIBImporter::~SIBImporter() -{} +SIBImporter::~SIBImporter() { + // empty +} // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. @@ -508,7 +510,7 @@ struct TempMesh std::vector vtx; std::vector nrm; std::vector uv; - std::vector faces; + std::vector faces; }; static void ReadShape(SIB* sib, StreamReaderLE* stream) @@ -546,7 +548,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream) stream->SetReadLimit(oldLimit); } - assert(smesh.faceStart.size() == smesh.mtls.size()); // sanity check + ai_assert(smesh.faceStart.size() == smesh.mtls.size()); // sanity check // Silo doesn't store any normals in the file - we need to compute // them ourselves. We can't let AssImp handle it as AssImp doesn't @@ -792,8 +794,9 @@ static void ReadInstance(SIB* sib, StreamReaderLE* stream) stream->SetReadLimit(oldLimit); } - if (shapeIndex >= sib->objs.size()) - throw DeadlyImportError("SIB: Invalid shape index."); + if ( shapeIndex >= sib->objs.size() ) { + throw DeadlyImportError( "SIB: Invalid shape index." ); + } const SIBObject& src = sib->objs[shapeIndex]; inst.meshIdx = src.meshIdx; @@ -805,8 +808,9 @@ static void ReadInstance(SIB* sib, StreamReaderLE* stream) static void CheckVersion(StreamReaderLE* stream) { uint32_t version = stream->GetU4(); - if (version != 1) - throw DeadlyImportError("SIB: Unsupported file version."); + if ( version != 1 ) { + throw DeadlyImportError( "SIB: Unsupported file version." ); + } } static void ReadScene(SIB* sib, StreamReaderLE* stream) diff --git a/code/SIBImporter.h b/code/SIBImporter.h index d82a40da0..bd71104c6 100644 --- a/code/SIBImporter.h +++ b/code/SIBImporter.h @@ -53,15 +53,13 @@ namespace Assimp { // --------------------------------------------------------------------------- /** Importer class for the Nevercenter Silo SIB scene format */ -class SIBImporter : public BaseImporter +class ASSIMP_API SIBImporter : public BaseImporter { public: SIBImporter(); ~SIBImporter(); - public: - // ------------------------------------------------------------------- /** Returns whether the class can handle the format of the given file. * See BaseImporter::CanRead() for details. @@ -70,7 +68,6 @@ public: bool checkSig) const; protected: - // ------------------------------------------------------------------- /** Return importer meta information. * See #BaseImporter::GetInfo for the details @@ -85,7 +82,6 @@ protected: IOSystem* pIOHandler); private: - struct MeshInformation { explicit MeshInformation(const std::string& _name) diff --git a/code/TriangulateProcess.cpp b/code/TriangulateProcess.cpp index f19f85037..883a45e3d 100644 --- a/code/TriangulateProcess.cpp +++ b/code/TriangulateProcess.cpp @@ -57,9 +57,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - dump all polygons and their triangulation sequences to * a file */ - - - #ifndef ASSIMP_BUILD_NO_TRIANGULATE_PROCESS #include "TriangulateProcess.h" #include "ProcessHelper.h" @@ -106,11 +103,15 @@ void TriangulateProcess::Execute( aiScene* pScene) bool bHas = false; for( unsigned int a = 0; a < pScene->mNumMeshes; a++) { - if( TriangulateMesh( pScene->mMeshes[a])) + if ( TriangulateMesh( pScene->mMeshes[ a ] ) ) { bHas = true; + } + } + if ( bHas ) { + DefaultLogger::get()->info( "TriangulateProcess finished. All polygons have been triangulated." ); + } else { + DefaultLogger::get()->debug( "TriangulateProcess finished. There was nothing to be done." ); } - if (bHas)DefaultLogger::get()->info ("TriangulateProcess finished. All polygons have been triangulated."); - else DefaultLogger::get()->debug("TriangulateProcess finished. There was nothing to be done."); } @@ -155,7 +156,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) } // Just another check whether aiMesh::mPrimitiveTypes is correct - assert(numOut != pMesh->mNumFaces); + ai_assert(numOut != pMesh->mNumFaces); aiVector3D* nor_out = NULL; @@ -184,7 +185,6 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) aiColor4D* clr = pMesh->mColors[0]; #endif - #ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS FILE* fout = fopen(POLY_OUTPUT_FILE,"a"); #endif @@ -276,7 +276,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) { // A polygon with more than 3 vertices can be either concave or convex. // Usually everything we're getting is convex and we could easily - // triangulate by trifanning. However, LightWave is probably the only + // triangulate by tri-fanning. However, LightWave is probably the only // modeling suite to make extensive use of highly concave, monster polygons ... // so we need to apply the full 'ear cutting' algorithm to get it right. @@ -325,7 +325,6 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) done[tmp] = false; } - #ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS // plot the plane onto which we mapped the polygon to a 2D ASCII pic aiVector2D bmin,bmax; @@ -404,14 +403,13 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) if (num_found == 2) { // Due to the 'two ear theorem', every simple polygon with more than three points must - // have 2 'ears'. Here's definitely someting wrong ... but we don't give up yet. + // have 2 'ears'. Here's definitely something wrong ... but we don't give up yet. // - // Instead we're continuting with the standard trifanning algorithm which we'd + // Instead we're continuing with the standard tri-fanning algorithm which we'd // use if we had only convex polygons. That's life. DefaultLogger::get()->error("Failed to triangulate polygon (no ear found). Probably not a simple polygon?"); - #ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS fprintf(fout,"critical error here, no ear found! "); #endif diff --git a/include/assimp/types.h b/include/assimp/types.h index 4a2e133e4..7904413b0 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -109,7 +109,8 @@ extern "C" { /** Maximum dimension for strings, ASSIMP strings are zero terminated. */ #ifdef __cplusplus -static const size_t MAXLEN = 1024; +static +const size_t MAXLEN = 1024; #else # define MAXLEN 1024 #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c97480ccd..038a68d62 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -83,6 +83,7 @@ SET( TEST_SRCS unit/utMetadata.cpp unit/SceneDiffer.h unit/SceneDiffer.cpp + unit/utSIBImporter.cpp unit/utObjImportExport.cpp unit/utPretransformVertices.cpp unit/utRemoveComments.cpp diff --git a/test/unit/utSIBImporter.cpp b/test/unit/utSIBImporter.cpp new file mode 100644 index 000000000..727824431 --- /dev/null +++ b/test/unit/utSIBImporter.cpp @@ -0,0 +1,59 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2016, assimp team + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ +#include "UnitTestPCH.h" + +#include "SIBImporter.h" + +using namespace ::Assimp; + +class utSIBImporter : public ::testing::Test { + // empty +}; + +TEST_F( utSIBImporter, createTest ) { + bool ok( true ); + try { + SIBImporter myImporter; + } catch ( ... ) { + ok = false; + } + EXPECT_TRUE( ok ); +}