WIP of assimp integration.

This commit is contained in:
Areloch 2019-02-08 16:25:43 -06:00
parent 32c7f2c7a7
commit bf170ffbca
2135 changed files with 1260856 additions and 7 deletions

View file

@ -0,0 +1,49 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
using namespace ::Assimp;
AbstractImportExportBase::~AbstractImportExportBase() {
// empty
}

View file

@ -0,0 +1,55 @@
/*
---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------
*/
#pragma once
#include "UnitTestPCH.h"
class AbstractImportExportBase : public ::testing::Test {
public:
virtual ~AbstractImportExportBase();
virtual bool importerTest() = 0;
virtual bool exporterTest();
};
inline
bool AbstractImportExportBase::exporterTest() {
return true;
}

View file

@ -0,0 +1,59 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/importerdesc.h>
using namespace Assimp;
class AssimpAPITest : public ::testing::Test {
};
TEST_F( AssimpAPITest, aiGetImporterDescTest ) {
const aiImporterDesc *desc( NULL );
desc = aiGetImporterDesc( NULL );
EXPECT_EQ( NULL, desc );
desc = aiGetImporterDesc( "obj" );
EXPECT_TRUE( NULL != desc );
}

View file

@ -0,0 +1,9 @@
/* This is just a small test to check whether Assimp's API compiles from C */
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/version.h>
#include <assimp/config.h>
#include <assimp/cimport.h>
#include <assimp/cexport.h>

View file

@ -0,0 +1,71 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/LineSplitter.h>
#include <assimp/DefaultIOSystem.h>
#include <string>
using namespace Assimp;
class utLineSplitter : public ::testing::Test {
// empty
};
TEST_F(utLineSplitter, tokenizetest) {
DefaultIOSystem fs;
IOStream* file = fs.Open(ASSIMP_TEST_MODELS_DIR"/ParsingFiles/linesplitter_tokenizetest.txt", "rb");
StreamReaderLE stream(file);
LineSplitter myLineSplitter(stream);
}
TEST_F( utLineSplitter, issue212Test) {
DefaultIOSystem fs;
IOStream* file = fs.Open(ASSIMP_TEST_MODELS_DIR"/ParsingFiles/linesplitter_emptyline_test.txt", "rb");
StreamReaderLE stream(file);
LineSplitter myLineSplitter(stream);
myLineSplitter++;
EXPECT_THROW( myLineSplitter++, std::logic_error );
}

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utCOBImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule.cob", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utCOBImportExport, importAMFFromFileTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utOgreImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Ogre/TheThing/Mesh.mesh.xml", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utOgreImportExport, importerTest ) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utQ3BSPImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/PK3/SGDTT3.pk3", 0);
return nullptr != scene;
}
};
TEST_F(utQ3BSPImportExport, importerTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,33 @@
#include "UnitTestPCH.h"
#include "../../include/assimp/DefaultLogger.hpp"
#include <math.h>
#include <time.h>
int main(int argc, char* argv[])
{
::testing::InitGoogleTest(&argc, argv);
// seed the randomizer with the current system time
time_t t;time(&t);
srand((unsigned int)t);
// ............................................................................
// create a logger from both CPP
Assimp::DefaultLogger::create("AssimpLog_Cpp.txt",Assimp::Logger::VERBOSE,
aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE);
// .. and C. They should smoothly work together
aiEnableVerboseLogging(AI_TRUE);
aiLogStream logstream= aiGetPredefinedLogStream(aiDefaultLogStream_FILE, "AssimpLog_C.txt");
aiAttachLogStream(&logstream);
int result = RUN_ALL_TESTS();
// ............................................................................
// but shutdown must be done from C to ensure proper deallocation
aiDetachAllLogStreams();
return result;
}

View file

@ -0,0 +1,375 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include <assimp/scene.h>
#include <assimp/mesh.h>
#include <assimp/material.h>
#include <sstream>
namespace Assimp {
SceneDiffer::SceneDiffer()
: m_diffs() {
// empty
}
SceneDiffer::~SceneDiffer() {
// empty
}
bool SceneDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) {
if ( expected == toCompare ) {
return true;
}
if ( nullptr == expected ) {
return false;
}
if ( nullptr == toCompare ) {
return false;
}
// meshes
if ( expected->mNumMeshes != toCompare->mNumMeshes ) {
std::stringstream stream;
stream << "Number of meshes not equal ( expected: " << expected->mNumMeshes << ", found : " << toCompare->mNumMeshes << " )\n";
addDiff( stream.str() );
return false;
}
for ( unsigned int i = 0; i < expected->mNumMeshes; i++ ) {
aiMesh *expMesh( expected->mMeshes[ i ] );
aiMesh *toCompMesh( toCompare->mMeshes[ i ] );
if ( !compareMesh( expMesh, toCompMesh ) ) {
std::stringstream stream;
stream << "Meshes are not equal, index : " << i << "\n";
addDiff( stream.str() );
}
}
// ToDo!
return true;
// materials
if ( expected->mNumMaterials != toCompare->mNumMaterials ) {
std::stringstream stream;
stream << "Number of materials not equal ( expected: " << expected->mNumMaterials << ", found : " << toCompare->mNumMaterials << " )\n";
addDiff( stream.str() );
return false;
}
if ( expected->mNumMaterials > 0 ) {
if ( nullptr == expected->mMaterials || nullptr == toCompare->mMaterials ) {
addDiff( "Number of materials > 0 and mat pointer is nullptr" );
return false;
}
}
for ( unsigned int i = 0; i < expected->mNumMaterials; i++ ) {
aiMaterial *expectedMat( expected->mMaterials[ i ] );
aiMaterial *toCompareMat( expected->mMaterials[ i ] );
if ( !compareMaterial( expectedMat, toCompareMat ) ) {
std::stringstream stream;
stream << "Materials are not equal, index : " << i << "\n";
addDiff( stream.str() );
}
}
return true;
}
void SceneDiffer::showReport() {
if ( m_diffs.empty() ) {
return;
}
for ( std::vector<std::string>::iterator it = m_diffs.begin(); it != m_diffs.end(); it++ ) {
std::cout << *it << "\n";
}
std::cout << std::endl;
}
void SceneDiffer::reset() {
m_diffs.resize( 0 );
}
void SceneDiffer::addDiff( const std::string &diff ) {
if ( diff.empty() ) {
return;
}
m_diffs.push_back( diff );
}
static std::string dumpVector3( const aiVector3D &toDump ) {
std::stringstream stream;
stream << "( " << toDump.x << ", " << toDump.y << ", " << toDump.z << ")";
return stream.str();
}
/*static std::string dumpColor4D( const aiColor4D &toDump ) {
std::stringstream stream;
stream << "( " << toDump.r << ", " << toDump.g << ", " << toDump.b << ", " << toDump.a << ")";
return stream.str();
}*/
static std::string dumpFace( const aiFace &face ) {
std::stringstream stream;
for ( unsigned int i = 0; i < face.mNumIndices; i++ ) {
stream << face.mIndices[ i ];
if ( i < face.mNumIndices - 1 ) {
stream << ", ";
}
else {
stream << "\n";
}
}
return stream.str();
}
bool SceneDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
if ( expected == toCompare ) {
return true;
}
if ( nullptr == expected || nullptr == toCompare ) {
return false;
}
if ( expected->mName != toCompare->mName ) {
std::stringstream stream;
stream << "Mesh name not equal ( expected: " << expected->mName.C_Str() << ", found : " << toCompare->mName.C_Str() << " )\n";
addDiff( stream.str() );
}
if ( expected->mNumVertices != toCompare->mNumVertices ) {
std::stringstream stream;
stream << "Number of vertices not equal ( expected: " << expected->mNumVertices << ", found : " << toCompare->mNumVertices << " )\n";
addDiff( stream.str() );
return false;
}
// positions
if ( expected->HasPositions() != toCompare->HasPositions() ) {
addDiff( "Expected are vertices, toCompare does not have any." );
return false;
}
bool vertEqual( true );
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expVert( expected->mVertices[ i ] );
aiVector3D &toCompVert( toCompare->mVertices[ i ] );
if ( !expVert.Equal( toCompVert ) ) {
std::cout << "index = " << i << dumpVector3( toCompVert ) << "\n";
std::stringstream stream;
stream << "Vertex not equal ( expected: " << dumpVector3( toCompVert ) << ", found: " << dumpVector3( toCompVert ) << "\n";
addDiff( stream.str() );
vertEqual = false;
}
}
if ( !vertEqual ) {
return false;
}
// normals
if ( expected->HasNormals() != toCompare->HasNormals() ) {
addDiff( "Expected are normals, toCompare does not have any." );
return false;
}
// return true;
//ToDo!
/*bool normalEqual( true );
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expNormal( expected->mNormals[ i ] );
aiVector3D &toCompNormal( toCompare->mNormals[ i ] );
if ( expNormal.Equal( toCompNormal ) ) {
std::stringstream stream;
stream << "Normal not equal ( expected: " << dumpVector3( expNormal ) << ", found: " << dumpVector3( toCompNormal ) << "\n";
addDiff( stream.str() );
normalEqual = false;
}
}
if ( !normalEqual ) {
return false;
}
// vertex colors
bool vertColEqual( true );
for ( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++ ) {
if ( expected->HasVertexColors(a) != toCompare->HasVertexColors(a) ) {
addDiff( "Expected are normals, toCompare does not have any." );
return false;
}
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiColor4D &expColor4D( expected->mColors[ a ][ i ] );
aiColor4D &toCompColor4D( toCompare->mColors[ a ][ i ] );
if ( expColor4D != toCompColor4D ) {
std::stringstream stream;
stream << "Color4D not equal ( expected: " << dumpColor4D( expColor4D ) << ", found: " << dumpColor4D( toCompColor4D ) << "\n";
addDiff( stream.str() );
vertColEqual = false;
}
}
if ( !vertColEqual ) {
return false;
}
}
// texture coords
bool texCoordsEqual( true );
for ( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++ ) {
if ( expected->HasTextureCoords( a ) != toCompare->HasTextureCoords( a ) ) {
addDiff( "Expected are texture coords, toCompare does not have any." );
return false;
}
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expTexCoord( expected->mTextureCoords[ a ][ i ] );
aiVector3D &toCompTexCoord( toCompare->mTextureCoords[ a ][ i ] );
if ( expTexCoord.Equal( toCompTexCoord ) ) {
std::stringstream stream;
stream << "Texture coords not equal ( expected: " << dumpVector3( expTexCoord ) << ", found: " << dumpVector3( toCompTexCoord ) << "\n";
addDiff( stream.str() );
vertColEqual = false;
}
}
if ( !vertColEqual ) {
return false;
}
}
// tangents and bi-tangents
if ( expected->HasTangentsAndBitangents() != toCompare->HasTangentsAndBitangents() ) {
addDiff( "Expected are tangents and bi-tangents, toCompare does not have any." );
return false;
}
bool tangentsEqual( true );
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expTangents( expected->mTangents[ i ] );
aiVector3D &toCompTangents( toCompare->mTangents[ i ] );
if ( expTangents.Equal( toCompTangents ) ) {
std::stringstream stream;
stream << "Tangents not equal ( expected: " << dumpVector3( expTangents ) << ", found: " << dumpVector3( toCompTangents ) << "\n";
addDiff( stream.str() );
tangentsEqual = false;
}
aiVector3D &expBiTangents( expected->mBitangents[ i ] );
aiVector3D &toCompBiTangents( toCompare->mBitangents[ i ] );
if ( expBiTangents.Equal( toCompBiTangents ) ) {
std::stringstream stream;
stream << "Tangents not equal ( expected: " << dumpVector3( expBiTangents ) << ", found: " << dumpVector3( toCompBiTangents ) << " )\n";
addDiff( stream.str() );
tangentsEqual = false;
}
}
if ( !tangentsEqual ) {
return false;
}*/
// faces
if ( expected->mNumFaces != toCompare->mNumFaces ) {
std::stringstream stream;
stream << "Number of faces are not equal, ( expected: " << expected->mNumFaces << ", found: " << toCompare->mNumFaces << ")\n";
addDiff( stream.str() );
return false;
}
bool facesEqual( true );
for ( unsigned int i = 0; i < expected->mNumFaces; i++ ) {
aiFace &expFace( expected->mFaces[ i ] );
aiFace &toCompareFace( toCompare->mFaces[ i ] );
if ( !compareFace( &expFace, &toCompareFace ) ) {
addDiff( "Faces are not equal\n" );
addDiff( dumpFace( expFace ) );
addDiff( dumpFace( toCompareFace ) );
facesEqual = false;
}
}
if ( !facesEqual ) {
return false;
}
return true;
}
bool SceneDiffer::compareFace( aiFace *expected, aiFace *toCompare ) {
if ( nullptr == expected ) {
return false;
}
if ( nullptr == toCompare ) {
return false;
}
// same instance
if ( expected == toCompare ) {
return true;
}
// using compare operator
if ( *expected == *toCompare ) {
return true;
}
return false;
}
bool SceneDiffer::compareMaterial( aiMaterial *expected, aiMaterial *toCompare ) {
if ( nullptr == expected ) {
return false;
}
if ( nullptr == toCompare ) {
return false;
}
// same instance
if ( expected == toCompare ) {
return true;
}
// todo!
return true;
}
}

View file

@ -0,0 +1,75 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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.
---------------------------------------------------------------------------
*/
#pragma once
#include "UnitTestPCH.h"
#include <assimp/fast_atof.h>
#include <vector>
#include <string>
struct aiScene;
struct aiMesh;
struct aiMaterial;
struct aiFace;
namespace Assimp {
class SceneDiffer {
public:
SceneDiffer();
~SceneDiffer();
bool isEqual( const aiScene *expected, const aiScene *toCompare );
void showReport();
void reset();
protected:
void addDiff( const std::string &diff );
bool compareMesh( aiMesh *expected, aiMesh *toCompare );
bool compareFace( aiFace *expected, aiFace *toCompare );
bool compareMaterial( aiMaterial *expected, aiMaterial *toCompare );
private:
std::vector<std::string> m_diffs;
};
}

View file

@ -0,0 +1,62 @@
/*
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.
----------------------------------------------------------------------
*/
#pragma once
#include <assimp/DefaultIOStream.h>
using namespace ::Assimp;
class TestDefaultIOStream : public DefaultIOStream {
public:
TestDefaultIOStream()
: DefaultIOStream() {
// empty
}
TestDefaultIOStream( FILE* pFile, const std::string &strFilename )
: DefaultIOStream( pFile, strFilename ) {
// empty
}
virtual ~TestDefaultIOStream() {
// empty
}
};

View file

@ -0,0 +1,84 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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.
---------------------------------------------------------------------------
*/
#pragma once
#include "UnitTestPCH.h"
#include <assimp/IOSystem.hpp>
using namespace std;
namespace Assimp {
static const string Sep = "/";
class TestIOSystem : public IOSystem {
public:
TestIOSystem()
: IOSystem() {
// empty
}
virtual ~TestIOSystem() {
// empty
}
virtual bool Exists( const char* ) const {
return true;
}
virtual char getOsSeparator() const {
return Sep[ 0 ];
}
virtual IOStream* Open( const char* pFile, const char* pMode = "rb" ) {
EXPECT_NE( nullptr, pFile );
EXPECT_NE( nullptr, pMode );
return NULL;
}
virtual void Close( IOStream* pFile ) {
EXPECT_NE( nullptr, pFile );
}
};
} // Namespace Assimp

View file

@ -0,0 +1,105 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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.
---------------------------------------------------------------------------
*/
#pragma once
#include "UnitTestPCH.h"
#include <assimp/scene.h>
#include <assimp/mesh.h>
#include <assimp/material.h>
namespace Assimp {
class TestModelFacttory {
public:
TestModelFacttory() {
// empty
}
~TestModelFacttory() {
// empty
}
static aiScene *createDefaultTestModel( float &opacity ) {
aiScene *scene( new aiScene );
scene->mNumMaterials = 1;
scene->mMaterials = new aiMaterial*[scene->mNumMaterials];
scene->mMaterials[ 0 ] = new aiMaterial;
aiColor3D color( 1, 0, 0 );
EXPECT_EQ( AI_SUCCESS, scene->mMaterials[ 0 ]->AddProperty( &color, 1, AI_MATKEY_COLOR_DIFFUSE ) );
::srand( static_cast< unsigned int >( ::time( NULL ) ) );
opacity = float( rand() ) / float( RAND_MAX );
EXPECT_EQ( AI_SUCCESS, scene->mMaterials[ 0 ]->AddProperty( &opacity, 1, AI_MATKEY_OPACITY ) );
scene->mNumMeshes = 1;
scene->mMeshes = new aiMesh*[scene->mNumMeshes];
scene->mMeshes[ 0 ] = new aiMesh;
scene->mMeshes[ 0 ]->mMaterialIndex = 0;
scene->mMeshes[ 0 ]->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
scene->mMeshes[ 0 ]->mNumVertices = 3;
scene->mMeshes[ 0 ]->mVertices = new aiVector3D[ 3 ];
scene->mMeshes[ 0 ]->mVertices[ 0 ] = aiVector3D( 1, 0, 0 );
scene->mMeshes[ 0 ]->mVertices[ 1 ] = aiVector3D( 0, 1, 0 );
scene->mMeshes[ 0 ]->mVertices[ 2 ] = aiVector3D( 0, 0, 1 );
scene->mMeshes[ 0 ]->mNumFaces = 1;
scene->mMeshes[ 0 ]->mFaces = new aiFace[scene->mMeshes[ 0 ]->mNumFaces];
scene->mMeshes[ 0 ]->mFaces[ 0 ].mNumIndices = 3;
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices = new unsigned int[ 3 ];
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices[ 0 ] = 0;
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices[ 1 ] = 1;
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices[ 2 ] = 2;
scene->mRootNode = new aiNode;
scene->mRootNode->mNumMeshes = 1;
scene->mRootNode->mMeshes = new unsigned int[1]{ 0 };
return scene;
}
static void releaseDefaultTestModel( aiScene **scene ) {
delete *scene;
*scene = nullptr;
}
};
}

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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.
---------------------------------------------------------------------------
*/
#pragma once
#include <assimp/LogStream.hpp>
class UTLogStream : public Assimp::LogStream {
public:
UTLogStream()
: LogStream() {
// empty
}
virtual ~UTLogStream() {
// empty
}
virtual void write(const char* message) {
if ( nullptr != message ) {
m_messages.push_back( std::string( message ) );
}
}
std::vector<std::string> m_messages;
};

View file

@ -0,0 +1,76 @@
/*
---------------------------------------------------------------------------
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,
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.
---------------------------------------------------------------------------
*/
#pragma once
#include <cstdio>
#include <cstdlib>
#include <gtest/gtest.h>
#if defined(__GNUC__) || defined(__clang__)
#define TMP_PATH "/tmp/"
inline FILE* MakeTmpFile(char* tmplate)
{
auto fd = mkstemp(tmplate);
EXPECT_NE(-1, fd);
if(fd == -1)
{
return nullptr;
}
auto fs = fdopen(fd, "w+");
EXPECT_NE(nullptr, fs);
return fs;
}
#elif defined(_MSC_VER)
#include <io.h>
#define TMP_PATH "./"
inline FILE* MakeTmpFile(char* tmplate)
{
auto pathtemplate = _mktemp(tmplate);
EXPECT_NE(pathtemplate, nullptr);
if(pathtemplate == nullptr)
{
return nullptr;
}
auto* fs = std::fopen(pathtemplate, "w+");
EXPECT_NE(fs, nullptr);
return fs;
}
#endif

View file

@ -0,0 +1,52 @@
/*
---------------------------------------------------------------------------
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,
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.
---------------------------------------------------------------------------
*/
#pragma once
// We need to be sure to have the same STL settings as Assimp
#include <assimp/cimport.h>
#include <gtest/gtest.h>
#include <memory>
#include <math.h>
#include "UTLogStream.h"
#undef min
#undef max

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class ut3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( ut3DImportExport, import3DFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,68 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class ut3DSImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3DS/fels.3ds", aiProcess_ValidateDataStructure );
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
return nullptr != scene;
#else
return nullptr == scene;
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER
}
};
TEST_F( ut3DSImportExport, import3DSFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utACImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utACImportExport, importACFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,72 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utAMFImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/AMF/test1.amf", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utAMFImportExport, importAMFFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F(utAMFImportExport, importAMFWithMatFromFileTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test_with_mat.amf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}

View file

@ -0,0 +1,68 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utASEImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen.ASE", aiProcess_ValidateDataStructure );
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
return nullptr != scene;
#else
return nullptr == scene;
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER
}
};
TEST_F( utASEImportExport, importACFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,107 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/anim.h>
using namespace Assimp;
class utAnim : public ::testing::Test {
// empty
};
TEST_F( utAnim, aiVectorKeyCreationTest ) {
aiVectorKey defaultConstTest;
EXPECT_DOUBLE_EQ( 0.0, defaultConstTest.mTime );
aiVector3D v( 1, 2, 3 );
aiVectorKey constrWithValuesTest( 1, v );
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
EXPECT_EQ( v, constrWithValuesTest.mValue );
EXPECT_NE( defaultConstTest, constrWithValuesTest );
EXPECT_TRUE( defaultConstTest != constrWithValuesTest );
defaultConstTest.mTime = 1;
constrWithValuesTest.mTime = 2;
EXPECT_TRUE( defaultConstTest < constrWithValuesTest );
}
TEST_F( utAnim, aiQuatKeyTest ) {
aiQuatKey defaultConstrTest;
EXPECT_DOUBLE_EQ( 0.0, defaultConstrTest.mTime );
aiQuaternion q;
aiQuatKey constrWithValuesTest( 1.0, q );
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
EXPECT_EQ( q, constrWithValuesTest.mValue );
}
TEST_F( utAnim, aiNodeAnimTest ) {
bool ok( true );
try {
aiNodeAnim myAnim;
EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPreState );
EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPostState );
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utAnim, aiMeshAnimTest ) {
bool ok( true );
try {
aiMeshAnim myMeshAnim;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utAnim, aiAnimationTest ) {
bool ok( true );
try {
aiAnimation myAnimation;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}

View file

@ -0,0 +1,78 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
#ifndef ASSIMP_BUILD_NO_EXPORT
class utAssbinImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
Exporter exporter;
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "assbin", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.assbin" ) );
const aiScene *newScene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.assbin", aiProcess_ValidateDataStructure );
return newScene != nullptr;
}
};
TEST_F( utAssbinImportExport, exportAssbin3DFromFileTest ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
}
TEST_F( utAssbinImportExport, import3ExportAssbinDFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
#endif // #ifndef ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utB3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/B3D/WusonBlitz.b3d", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utB3DImportExport, importACFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,62 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utBVHImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/BVH/01_01.bvh", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utBVHImportExport, importBlenFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,81 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "Importer.h"
#include "TestIOSystem.h"
using namespace ::Assimp;
class BatchLoaderTest : public ::testing::Test {
public:
virtual void SetUp() {
m_io = new TestIOSystem();
}
virtual void TearDown() {
delete m_io;
}
protected:
TestIOSystem* m_io;
};
TEST_F( BatchLoaderTest, createTest ) {
bool ok( true );
try {
BatchLoader loader( m_io );
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( BatchLoaderTest, validateAccessTest ) {
BatchLoader loader1( m_io );
EXPECT_FALSE( loader1.getValidation() );
loader1.setValidation( true );
EXPECT_TRUE( loader1.getValidation() );
BatchLoader loader2( m_io, true );
EXPECT_TRUE( loader2.getValidation() );
}

View file

@ -0,0 +1,116 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/cexport.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
class BlendImportAreaLight : public ::testing::Test {
public:
virtual void SetUp()
{
im = new Assimp::Importer();
}
virtual void TearDown()
{
delete im;
}
protected:
Assimp::Importer* im;
};
// ------------------------------------------------------------------------------------------------
TEST_F(BlendImportAreaLight, testImportLight)
{
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/AreaLight_269.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != NULL);
ASSERT_TRUE(pTest->HasLights());
std::vector< std::pair<std::string, size_t> > lightNames;
for (size_t i = 0; i < pTest->mNumLights; i++) {
lightNames.push_back(std::make_pair(pTest->mLights[i]->mName.C_Str(), i));
}
std::sort(lightNames.begin(), lightNames.end());
std::vector<aiLight> lights;
for (size_t i = 0; i < pTest->mNumLights; ++i) {
lights.push_back(*pTest->mLights[lightNames[i].second]);
}
ASSERT_STREQ(lights[0].mName.C_Str(), "Bar");
ASSERT_STREQ(lights[1].mName.C_Str(), "Baz");
ASSERT_STREQ(lights[2].mName.C_Str(), "Foo");
ASSERT_EQ(lights[0].mType, aiLightSource_AREA);
ASSERT_EQ(lights[1].mType, aiLightSource_POINT);
ASSERT_EQ(lights[2].mType, aiLightSource_AREA);
EXPECT_FLOAT_EQ(lights[0].mSize.x, 0.5f);
EXPECT_FLOAT_EQ(lights[0].mSize.y, 2.0f);
EXPECT_FLOAT_EQ(lights[2].mSize.x, 1.0f);
EXPECT_FLOAT_EQ(lights[2].mSize.y, 1.0f);
EXPECT_FLOAT_EQ(lights[0].mColorDiffuse.r, 42.0f);
EXPECT_FLOAT_EQ(lights[0].mColorDiffuse.g, 42.0f);
EXPECT_FLOAT_EQ(lights[0].mColorDiffuse.b, 42.0f);
EXPECT_FLOAT_EQ(lights[2].mColorDiffuse.r, 1.0f);
EXPECT_FLOAT_EQ(lights[2].mColorDiffuse.g, 1.0f);
EXPECT_FLOAT_EQ(lights[2].mColorDiffuse.b, 1.0f);
EXPECT_FLOAT_EQ(lights[0].mDirection.x, 0.0f);
EXPECT_FLOAT_EQ(lights[0].mDirection.y, 0.0f);
EXPECT_FLOAT_EQ(lights[0].mDirection.z, -1.0f);
EXPECT_FLOAT_EQ(lights[2].mDirection.x, 0.0f);
EXPECT_FLOAT_EQ(lights[2].mDirection.y, 0.0f);
EXPECT_FLOAT_EQ(lights[2].mDirection.z, -1.0f);
}

View file

@ -0,0 +1,154 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/cexport.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
class BlendImportMaterials : public ::testing::Test {
public:
virtual void SetUp()
{
im = new Assimp::Importer();
}
virtual void TearDown()
{
delete im;
}
protected:
Assimp::Importer* im;
};
// ------------------------------------------------------------------------------------------------
TEST_F(BlendImportMaterials, testImportMaterial)
{
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderMaterial_269.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != NULL);
ASSERT_TRUE(pTest->HasMaterials());
ASSERT_EQ(1U, pTest->mNumMaterials);
auto alpha = pTest->mMaterials[0];
#define ASSERT_PROPERTY_EQ(expected, key, var) \
auto var = expected; \
ASSERT_EQ(aiReturn_SUCCESS, alpha->Get("$mat.blend." key, 0, 0, var)); \
ASSERT_EQ(expected, var);
#define ASSERT_PROPERTY_FLOAT_EQ(expected, key, var) \
auto var = expected; \
ASSERT_EQ(aiReturn_SUCCESS, alpha->Get("$mat.blend." key, 0, 0, var)); \
ASSERT_FLOAT_EQ(expected, var);
ASSERT_PROPERTY_EQ(aiColor3D(0.1f, 0.2f, 0.3f), "diffuse.color", diffuseColor);
ASSERT_PROPERTY_EQ(0.4f, "diffuse.intensity", diffuseIntensity);
ASSERT_PROPERTY_EQ(1, "diffuse.shader", diffuseShader);
ASSERT_PROPERTY_EQ(0, "diffuse.ramp", diffuseRamp);
ASSERT_PROPERTY_EQ(aiColor3D(0.5f, 0.6f, 0.7f), "specular.color", specularColor);
ASSERT_PROPERTY_EQ(0.8f, "specular.intensity", specularIntensity);
ASSERT_PROPERTY_EQ(1, "specular.shader", specularShader);
ASSERT_PROPERTY_EQ(0, "specular.ramp", specularRamp);
ASSERT_PROPERTY_EQ(9, "specular.hardness", specularHardness);
ASSERT_PROPERTY_EQ(1, "transparency.use", transparencyUse);
ASSERT_PROPERTY_EQ(2, "transparency.method", transparencyMethod);
ASSERT_PROPERTY_EQ(0.01f, "transparency.alpha", transparencyAlpha);
ASSERT_PROPERTY_EQ(0.02f, "transparency.specular", transparencySpecular);
ASSERT_PROPERTY_EQ(0.03f, "transparency.fresnel", transparencyFresnel);
ASSERT_PROPERTY_EQ(3.14f, "transparency.blend", transparencyBlend);
ASSERT_PROPERTY_EQ(0.85f, "transparency.ior", transparencyIor);
ASSERT_PROPERTY_FLOAT_EQ(0.128f, "transparency.filter", transparencyFilter);
ASSERT_PROPERTY_FLOAT_EQ(1.298f, "transparency.falloff", transparencyFalloff);
ASSERT_PROPERTY_FLOAT_EQ(0.2376f, "transparency.limit", transparencyLimit);
ASSERT_PROPERTY_EQ(7, "transparency.depth", transparencyDepth);
ASSERT_PROPERTY_FLOAT_EQ(0.678f, "transparency.glossAmount", transparencyGlossAmount);
ASSERT_PROPERTY_FLOAT_EQ(0.208f, "transparency.glossThreshold", transparencyGlossThreshold);
ASSERT_PROPERTY_EQ(17, "transparency.glossSamples", transparencyGlossSamples);
ASSERT_PROPERTY_EQ(1, "mirror.use", mirrorUse);
ASSERT_PROPERTY_FLOAT_EQ(0.28f, "mirror.reflectivity", mirrorReflectivity);
ASSERT_PROPERTY_EQ(aiColor3D(0.25f, 0.5f, 0.128f), "mirror.color", mirrorColor);
ASSERT_PROPERTY_FLOAT_EQ(0.256f, "mirror.fresnel", mirrorFresnel);
ASSERT_PROPERTY_FLOAT_EQ(1.61f, "mirror.blend", mirrorBlend);
ASSERT_PROPERTY_EQ(12, "mirror.depth", mirrorDepth);
ASSERT_PROPERTY_FLOAT_EQ(0.4f, "mirror.maxDist", mirrorMaxDist);
ASSERT_PROPERTY_EQ(1, "mirror.fadeTo", mirrorFadeTo);
ASSERT_PROPERTY_FLOAT_EQ(0.512f, "mirror.glossAmount", mirrorGlossAmount);
ASSERT_PROPERTY_FLOAT_EQ(0.18f, "mirror.glossThreshold", mirrorGlossThreshold);
ASSERT_PROPERTY_EQ(61, "mirror.glossSamples", mirrorGlossSamples);
ASSERT_PROPERTY_FLOAT_EQ(0.87f, "mirror.glossAnisotropic", mirrorGlossAnisotropic);
}
TEST_F(BlendImportMaterials, testImportMaterialwith2texturesAnd2TexCoordMappings)
{
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/plane_2_textures_2_texcoords_279.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != NULL);
// material has 2 diffuse textures
ASSERT_TRUE(pTest->HasMaterials());
EXPECT_EQ(1, pTest->mNumMaterials);
const aiMaterial *pMat = pTest->mMaterials[0];
ASSERT_TRUE(nullptr != pMat);
ASSERT_EQ(2, pMat->GetTextureCount(aiTextureType_DIFFUSE));
aiString aPath;
aiTextureMapping tm = aiTextureMapping::aiTextureMapping_OTHER;
aiReturn result = pMat->GetTexture(aiTextureType_DIFFUSE, 0, &aPath, &tm);
ASSERT_EQ(aiReturn_SUCCESS, result);
result = pMat->GetTexture(aiTextureType_DIFFUSE, 1, &aPath, &tm);
ASSERT_EQ(aiReturn_SUCCESS, result);
// mesh has 2 texturecoord sets
ASSERT_TRUE(pTest->HasMeshes());
EXPECT_EQ(1, pTest->mNumMeshes);
const aiMesh *pMesh = pTest->mMeshes[0];
ASSERT_TRUE(nullptr != pMesh);
ASSERT_TRUE(pMesh->HasTextureCoords(0));
ASSERT_TRUE(pMesh->HasTextureCoords(1));
}

View file

@ -0,0 +1,62 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utBlenderImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/BLEND/box.blend", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utBlenderImporterExporter, importBlenFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,85 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "BlenderIntermediate.h"
#include "./../include/assimp/camera.h"
#include "./../include/assimp/light.h"
#include "./../include/assimp/mesh.h"
#include "./../include/assimp/texture.h"
using namespace ::Assimp;
using namespace ::Assimp::Blender;
class BlenderIntermediateTest : public ::testing::Test {
// empty
};
#define NAME_1 "name1"
#define NAME_2 "name2"
// Updated this test after fixing #1776:
// A comparator in C++ is used for ordering and must implement strict weak ordering,
// which means it must return false for equal values.
// The C++ standard defines and expects this behavior: true if lhs < rhs, false otherwise.
TEST_F( BlenderIntermediateTest,ConversionData_ObjectCompareTest ) {
Object obj1, obj2;
strncpy( obj1.id.name, NAME_1, sizeof(NAME_1) );
strncpy( obj2.id.name, NAME_2, sizeof(NAME_2) );
Blender::ObjectCompare cmp_true_because_first_is_smaller_than_second;
bool res( cmp_true_because_first_is_smaller_than_second( &obj1, &obj2 ) );
EXPECT_TRUE( res );
Blender::ObjectCompare cmp_false_because_equal;
res = cmp_false_because_equal( &obj1, &obj1 );
EXPECT_FALSE( res );
Blender::ObjectCompare cmp_false_because_first_is_greater_than_second;
res = cmp_false_because_first_is_greater_than_second( &obj2, &obj1 );
EXPECT_FALSE( res );
}

View file

@ -0,0 +1,83 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/cexport.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
using namespace ::Assimp;
class BlenderWorkTest : public ::testing::Test {
public:
virtual void SetUp()
{
im = new Assimp::Importer();
}
virtual void TearDown()
{
delete im;
}
protected:
Assimp::Importer* im;
};
TEST_F(BlenderWorkTest,work_279) {
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/test_279.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != NULL);
// material has 2 diffuse textures
ASSERT_TRUE(pTest->HasMaterials());
ASSERT_TRUE(pTest->HasMeshes());
ASSERT_TRUE(pTest->mMeshes[0]->mNumVertices > 0);
ASSERT_EQ(44, pTest->mMeshes[0]->mNumFaces);
EXPECT_EQ(1, pTest->mNumMaterials);
}

View file

@ -0,0 +1,62 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utCSMImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/CSM/ThomasFechten.csm", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utCSMImportExport, importBlenFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,123 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/cexport.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#ifndef ASSIMP_BUILD_NO_EXPORT
class ColladaExportCamera : public ::testing::Test {
public:
virtual void SetUp()
{
ex = new Assimp::Exporter();
im = new Assimp::Importer();
}
virtual void TearDown()
{
delete ex;
delete im;
}
protected:
Assimp::Exporter* ex;
Assimp::Importer* im;
};
TEST_F(ColladaExportCamera, testExportCamera)
{
const char* file = "cameraExp.dae";
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest!=NULL);
ASSERT_TRUE(pTest->HasCameras());
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
const unsigned int origNumCams( pTest->mNumCameras );
std::unique_ptr<float[]> origFOV( new float[ origNumCams ] );
std::unique_ptr<float[]> orifClipPlaneNear( new float[ origNumCams ] );
std::unique_ptr<float[]> orifClipPlaneFar( new float[ origNumCams ] );
std::unique_ptr<aiString[]> names( new aiString[ origNumCams ] );
std::unique_ptr<aiVector3D[]> pos( new aiVector3D[ origNumCams ] );
for (size_t i = 0; i < origNumCams; i++) {
const aiCamera *orig = pTest->mCameras[ i ];
ASSERT_TRUE( orig != nullptr );
origFOV[ i ] = orig->mHorizontalFOV;
orifClipPlaneNear[ i ] = orig->mClipPlaneNear;
orifClipPlaneFar[ i ] = orig->mClipPlaneFar;
names[ i ] = orig->mName;
pos[ i ] = orig->mPosition;
}
const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_TRUE(imported!=NULL);
EXPECT_TRUE( imported->HasCameras() );
EXPECT_EQ( origNumCams, imported->mNumCameras );
for(size_t i=0; i< imported->mNumCameras;i++){
const aiCamera *read = imported->mCameras[ i ];
EXPECT_TRUE( names[ i ] == read->mName );
EXPECT_NEAR( origFOV[ i ],read->mHorizontalFOV, 0.0001f );
EXPECT_FLOAT_EQ( orifClipPlaneNear[ i ], read->mClipPlaneNear);
EXPECT_FLOAT_EQ( orifClipPlaneFar[ i ], read->mClipPlaneFar);
EXPECT_FLOAT_EQ( pos[ i ].x,read->mPosition.x);
EXPECT_FLOAT_EQ( pos[ i ].y,read->mPosition.y);
EXPECT_FLOAT_EQ( pos[ i ].z,read->mPosition.z);
}
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,123 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/cexport.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#ifndef ASSIMP_BUILD_NO_EXPORT
class ColladaExportLight : public ::testing::Test {
public:
virtual void SetUp()
{
ex = new Assimp::Exporter();
im = new Assimp::Importer();
}
virtual void TearDown()
{
delete ex;
delete im;
}
protected:
Assimp::Exporter* ex;
Assimp::Importer* im;
};
// ------------------------------------------------------------------------------------------------
TEST_F(ColladaExportLight, testExportLight)
{
const char* file = "lightsExp.dae";
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/lights.dae", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest!=NULL);
ASSERT_TRUE(pTest->HasLights());
const unsigned int origNumLights( pTest->mNumLights );
std::unique_ptr<aiLight[]> origLights( new aiLight[ origNumLights ] );
std::vector<std::string> origNames;
for (size_t i = 0; i < origNumLights; i++) {
origNames.push_back( pTest->mLights[ i ]->mName.C_Str() );
origLights[ i ] = *(pTest->mLights[ i ]);
}
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_TRUE(imported!=NULL);
EXPECT_TRUE(imported->HasLights());
EXPECT_EQ( origNumLights,imported->mNumLights );
for(size_t i=0; i< origNumLights; i++) {
const aiLight *orig = &origLights[ i ];
const aiLight *read = imported->mLights[i];
EXPECT_EQ( 0,strncmp(origNames[ i ].c_str(),read->mName.C_Str(), origNames[ i ].size() ) );
EXPECT_EQ( orig->mType,read->mType);
EXPECT_FLOAT_EQ(orig->mAttenuationConstant,read->mAttenuationConstant);
EXPECT_FLOAT_EQ(orig->mAttenuationLinear,read->mAttenuationLinear);
EXPECT_NEAR(orig->mAttenuationQuadratic,read->mAttenuationQuadratic, 0.001f);
EXPECT_FLOAT_EQ(orig->mColorAmbient.r,read->mColorAmbient.r);
EXPECT_FLOAT_EQ(orig->mColorAmbient.g,read->mColorAmbient.g);
EXPECT_FLOAT_EQ(orig->mColorAmbient.b,read->mColorAmbient.b);
EXPECT_FLOAT_EQ(orig->mColorDiffuse.r,read->mColorDiffuse.r);
EXPECT_FLOAT_EQ(orig->mColorDiffuse.g,read->mColorDiffuse.g);
EXPECT_FLOAT_EQ(orig->mColorDiffuse.b,read->mColorDiffuse.b);
EXPECT_FLOAT_EQ(orig->mColorSpecular.r,read->mColorSpecular.r);
EXPECT_FLOAT_EQ(orig->mColorSpecular.g,read->mColorSpecular.g);
EXPECT_FLOAT_EQ(orig->mColorSpecular.b,read->mColorSpecular.b);
EXPECT_NEAR(orig->mAngleInnerCone,read->mAngleInnerCone,0.001);
EXPECT_NEAR(orig->mAngleOuterCone,read->mAngleOuterCone,0.001);
}
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,62 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utColladaImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/Collada/duck.dae", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utColladaImportExport, importBlenFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,97 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include "D3MFExporter.h"
class utD3MFImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", aiProcess_ValidateDataStructure);
EXPECT_EQ( 1u, scene->mNumMeshes );
aiMesh *mesh = scene->mMeshes[ 0 ];
EXPECT_NE( nullptr, mesh );
EXPECT_EQ( 12u, mesh->mNumFaces );
EXPECT_EQ( 8u, mesh->mNumVertices );
return ( nullptr != scene );
}
#ifndef ASSIMP_BUILD_NO_EXPORT
virtual bool exporterTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", 0 );
Assimp::Exporter exporter;
return AI_SUCCESS == exporter.Export( scene, "3mf", "test.3mf" );
}
#endif // ASSIMP_BUILD_NO_EXPORT
};
TEST_F(utD3MFImporterExporter, import3MFFromFileTest) {
EXPECT_TRUE(importerTest());
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F( utD3MFImporterExporter, export3MFtoMemTest ) {
EXPECT_TRUE( exporterTest() );
}
TEST_F( utD3MFImporterExporter, roundtrip3MFtoMemTest ) {
EXPECT_TRUE( exporterTest() );
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( "test.3mf", 0 );
EXPECT_NE( nullptr, scene );
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,71 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utDXFImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/DXF/PinkEggFromLW.dxf", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utDXFImporterExporter, importDXFFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utDXFImporterExporter, importerWithoutExtensionTest ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/DXF/lineTest", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
}

View file

@ -0,0 +1,83 @@
/*-------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <gtest/gtest.h>
#include "TestIOStream.h"
#include "UnitTestFileGenerator.h"
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace ::Assimp;
class utDefaultIOStream : public ::testing::Test {
// empty
};
const char data[]{"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui\
sque luctus sem diam, ut eleifend arcu auctor eu. Vestibulum id est vel nulla l\
obortis malesuada ut sed turpis. Nulla a volutpat tortor. Nunc vestibulum portt\
itor sapien ornare sagittis volutpat."};
TEST_F( utDefaultIOStream, FileSizeTest ) {
const auto dataSize = sizeof(data);
const auto dataCount = dataSize / sizeof(*data);
char fpath[] = { TMP_PATH"rndfp.XXXXXX" };
auto* fs = MakeTmpFile(fpath);
ASSERT_NE(nullptr, fs);
{
auto written = std::fwrite(data, sizeof(*data), dataCount, fs );
EXPECT_NE( 0U, written );
auto vflush = std::fflush( fs );
ASSERT_EQ(vflush, 0);
std::fclose(fs);
fs = std::fopen(fpath, "r");
ASSERT_NE(nullptr, fs);
TestDefaultIOStream myStream( fs, fpath);
size_t size = myStream.FileSize();
EXPECT_EQ( size, dataSize);
}
remove(fpath);
}

View file

@ -0,0 +1,84 @@
#include "UnitTestPCH.h"
#include <assimp/cexport.h>
#include <assimp/Exporter.hpp>
#ifndef ASSIMP_BUILD_NO_EXPORT
class ExporterTest : public ::testing::Test {
public:
virtual void SetUp()
{
ex = new Assimp::Exporter();
im = new Assimp::Importer();
pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test.x", aiProcess_ValidateDataStructure);
}
virtual void TearDown()
{
delete ex;
delete im;
}
protected:
const aiScene* pTest;
Assimp::Exporter* ex;
Assimp::Importer* im;
};
// ------------------------------------------------------------------------------------------------
TEST_F(ExporterTest, testExportToFile)
{
const char* file = "unittest_output.dae";
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
// check if we can read it again
EXPECT_TRUE(im->ReadFile(file, aiProcess_ValidateDataStructure));
}
// ------------------------------------------------------------------------------------------------
TEST_F(ExporterTest, testExportToBlob)
{
const aiExportDataBlob* blob = ex->ExportToBlob(pTest,"collada");
ASSERT_TRUE(blob);
EXPECT_TRUE(blob->data);
EXPECT_GT(blob->size, 0U);
EXPECT_EQ(0U, blob->name.length);
// XXX test chained blobs (i.e. obj file with accompanying mtl script)
// check if we can read it again
EXPECT_TRUE(im->ReadFileFromMemory(blob->data,blob->size,0,"dae"));
}
// ------------------------------------------------------------------------------------------------
TEST_F(ExporterTest, testCppExportInterface)
{
EXPECT_TRUE(ex->GetExportFormatCount() > 0);
for(size_t i = 0; i < ex->GetExportFormatCount(); ++i) {
const aiExportFormatDesc* const desc = ex->GetExportFormatDescription(i);
ASSERT_TRUE(desc);
EXPECT_TRUE(desc->description && strlen(desc->description));
EXPECT_TRUE(desc->fileExtension && strlen(desc->fileExtension));
EXPECT_TRUE(desc->id && strlen(desc->id));
}
EXPECT_TRUE(ex->IsDefaultIOHandler());
}
// ------------------------------------------------------------------------------------------------
TEST_F(ExporterTest, testCExportInterface)
{
EXPECT_TRUE(aiGetExportFormatCount() > 0);
for(size_t i = 0; i < aiGetExportFormatCount(); ++i) {
const aiExportFormatDesc* const desc = aiGetExportFormatDescription(i);
EXPECT_TRUE(desc);
// rest has already been validated by testCppExportInterface
}
}
#endif

View file

@ -0,0 +1,116 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include <assimp/material.h>
#include <assimp/scene.h>
#include <assimp/types.h>
using namespace Assimp;
class utFBXImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/spider.fbx", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utFBXImporterExporter, importXFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utFBXImporterExporter, importBareBoxWithoutColorsAndTextureCoords ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/box.fbx", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
EXPECT_EQ(scene->mNumMeshes, 1);
aiMesh* mesh = scene->mMeshes[0];
EXPECT_EQ(mesh->mNumFaces, 12);
EXPECT_EQ(mesh->mNumVertices, 36);
}
TEST_F( utFBXImporterExporter, importPhongMaterial ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/phong_cube.fbx", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
EXPECT_EQ( (unsigned int)1, scene->mNumMaterials );
const aiMaterial *mat = scene->mMaterials[0];
EXPECT_NE( nullptr, mat );
float f; aiColor3D c;
// phong_cube.fbx has all properties defined
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_DIFFUSE, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.5, 0.25, 0.25) );
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_SPECULAR, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.25, 0.25, 0.5) );
EXPECT_EQ( mat->Get(AI_MATKEY_SHININESS_STRENGTH, f), aiReturn_SUCCESS );
EXPECT_EQ( f, 0.5 );
EXPECT_EQ( mat->Get(AI_MATKEY_SHININESS, f), aiReturn_SUCCESS );
EXPECT_EQ( f, 10.0 );
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_AMBIENT, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.125, 0.25, 0.25) );
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_EMISSIVE, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.25, 0.125, 0.25) );
EXPECT_EQ( mat->Get(AI_MATKEY_COLOR_TRANSPARENT, c), aiReturn_SUCCESS );
EXPECT_EQ( c, aiColor3D(0.75, 0.5, 0.25) );
EXPECT_EQ( mat->Get(AI_MATKEY_OPACITY, f), aiReturn_SUCCESS );
EXPECT_EQ( f, 0.5 );
}
TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/global_settings.fbx", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_NE(nullptr, scene->mMetaData);
double factor(0.0);
scene->mMetaData->Get("UnitScaleFactor", factor);
EXPECT_DOUBLE_EQ(500.0, factor);
}

View file

@ -0,0 +1,190 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/fast_atof.h>
namespace {
template <typename Real>
bool IsNan(Real x) {
return x != x;
}
template <typename Real>
bool IsInf(Real x) {
return std::abs(x) == std::numeric_limits<Real>::infinity();
}
} // Namespace
class FastAtofTest : public ::testing::Test
{
protected:
template <typename Real, typename AtofFunc>
static void RunTest(AtofFunc atof_func)
{
const Real kEps = 1e-5f;
#define TEST_CASE(NUM) EXPECT_NEAR(static_cast<Real>(NUM), atof_func(#NUM), kEps)
#define TEST_CASE_NAN(NUM) EXPECT_TRUE(IsNan(atof_func(#NUM)))
#define TEST_CASE_INF(NUM) EXPECT_TRUE(IsInf(atof_func(#NUM)))
TEST_CASE(0);
TEST_CASE(1.354);
TEST_CASE(1054E-3);
TEST_CASE(-1054E-3);
TEST_CASE(-10.54E30);
TEST_CASE(-345554.54e-5);
TEST_CASE(-34555.534954e-5);
TEST_CASE(-34555.534954e-5);
TEST_CASE(549067);
TEST_CASE(567);
TEST_CASE(446);
TEST_CASE(7);
TEST_CASE(73);
TEST_CASE(256);
TEST_CASE(5676);
TEST_CASE(3);
TEST_CASE(738);
TEST_CASE(684);
TEST_CASE(26);
TEST_CASE(673.678e-56);
TEST_CASE(53);
TEST_CASE(67);
TEST_CASE(684);
TEST_CASE(-5437E24);
TEST_CASE(8);
TEST_CASE(84);
TEST_CASE(3);
TEST_CASE(56733.68);
TEST_CASE(786);
TEST_CASE(6478);
TEST_CASE(34563.65683598734);
TEST_CASE(5673);
TEST_CASE(784e-3);
TEST_CASE(8678);
TEST_CASE(46784);
TEST_CASE(-54.0888e-6);
TEST_CASE(100000e10);
TEST_CASE(1e-307);
TEST_CASE(0.000001e-301);
TEST_CASE(0.0000001e-300);
TEST_CASE(0.00000001e-299);
TEST_CASE(1000000e-313);
TEST_CASE(10000000e-314);
TEST_CASE(100000000e-315);
TEST_CASE(12.345);
TEST_CASE(12.345e19);
TEST_CASE(-.1e+9);
TEST_CASE(.125);
TEST_CASE(1e20);
TEST_CASE(0e-19);
TEST_CASE(400012);
TEST_CASE(5.9e-76);
TEST_CASE_INF(inf);
TEST_CASE_INF(inf);
TEST_CASE_INF(infinity);
TEST_CASE_INF(Inf);
TEST_CASE_INF(-Inf);
TEST_CASE_INF(+InFiNiTy);
TEST_CASE_NAN(NAN);
TEST_CASE_NAN(NaN);
TEST_CASE_NAN(nan);
EXPECT_EQ(static_cast<Real>(6), atof_func("006"));
EXPECT_EQ(static_cast<Real>(5.3), atof_func("5.300 "));
/* Failing Cases:
EXPECT_EQ(static_cast<Real>(6), atof_func(" 006"));
EXPECT_EQ(static_cast<Real>(5.3), atof_func(" 5.300 "));
TEST_CASE(-10.54E45);
TEST_CASE(0x0A);
TEST_CASE(0xA0);
TEST_CASE(0x1p1023);
TEST_CASE(0x1000p1011);
TEST_CASE(0x1p1020);
TEST_CASE(0x0.00001p1040);
TEST_CASE(0x1p-1021);
TEST_CASE(0x1000p-1033);
TEST_CASE(0x10000p-1037);
TEST_CASE(0x0.001p-1009);
TEST_CASE(0x0.0001p-1005);
TEST_CASE(0x1.4p+3);
TEST_CASE(0xAp0);
TEST_CASE(0x0Ap0);
TEST_CASE(0x0.A0p8);
TEST_CASE(0x0.50p9);
TEST_CASE(0x0.28p10);
TEST_CASE(0x0.14p11);
TEST_CASE(0x0.0A0p12);
TEST_CASE(0x0.050p13);
TEST_CASE(0x0.028p14);
TEST_CASE(0x0.014p15);
TEST_CASE(0x00.00A0p16);
TEST_CASE(0x00.0050p17);
TEST_CASE(0x00.0028p18);
TEST_CASE(0x00.0014p19);
TEST_CASE(0x1p-1023);
TEST_CASE(0x0.8p-1022);
TEST_CASE(0x80000Ap-23);
TEST_CASE(0x100000000000008p0);
TEST_CASE(0x100000000000008.p0);
TEST_CASE(0x100000000000008.00p0);
TEST_CASE(0x10000000000000800p0);
TEST_CASE(0x10000000000000801p0)
*/
#undef TEST_CASE
#undef TEST_CASE_NAN
#undef TEST_CASE_INF
}
};
struct FastAtofWrapper {
ai_real operator()(const char* str) { return Assimp::fast_atof(str); }
};
TEST_F(FastAtofTest, FastAtof)
{
RunTest<ai_real>(FastAtofWrapper());
}

View file

@ -0,0 +1,148 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <FindDegenerates.h>
using namespace std;
using namespace Assimp;
class FindDegeneratesProcessTest : public ::testing::Test {
public:
virtual void SetUp();
virtual void TearDown();
protected:
aiMesh* mesh;
FindDegeneratesProcess* process;
};
// ------------------------------------------------------------------------------------------------
void FindDegeneratesProcessTest::SetUp() {
mesh = new aiMesh();
process = new FindDegeneratesProcess();
mesh->mNumFaces = 1000;
mesh->mFaces = new aiFace[1000];
mesh->mNumVertices = 5000*2;
mesh->mVertices = new aiVector3D[5000*2];
for (unsigned int i = 0; i < 5000; ++i) {
mesh->mVertices[i] = mesh->mVertices[i+5000] = aiVector3D((float)i);
}
mesh->mPrimitiveTypes = aiPrimitiveType_LINE | aiPrimitiveType_POINT |
aiPrimitiveType_POLYGON | aiPrimitiveType_TRIANGLE;
unsigned int numOut = 0, numFaces = 0;
for (unsigned int i = 0; i < 1000; ++i) {
aiFace& f = mesh->mFaces[i];
f.mNumIndices = (i % 5)+1; // between 1 and 5
f.mIndices = new unsigned int[f.mNumIndices];
bool had = false;
for (unsigned int n = 0; n < f.mNumIndices;++n) {
// FIXME
#if 0
// some duplicate indices
if ( n && n == (i / 200)+1) {
f.mIndices[n] = f.mIndices[n-1];
had = true;
}
// and some duplicate vertices
#endif
if (n && i % 2 && 0 == n % 2) {
f.mIndices[n] = f.mIndices[n-1]+5000;
had = true;
}
else {
f.mIndices[n] = numOut++;
}
}
if (!had)
++numFaces;
}
mesh->mNumUVComponents[0] = numOut;
mesh->mNumUVComponents[1] = numFaces;
}
void FindDegeneratesProcessTest::TearDown() {
delete mesh;
delete process;
}
TEST_F(FindDegeneratesProcessTest, testDegeneratesDetection) {
process->EnableInstantRemoval(false);
process->ExecuteOnMesh(mesh);
unsigned int out = 0;
for (unsigned int i = 0; i < 1000; ++i) {
aiFace& f = mesh->mFaces[i];
out += f.mNumIndices;
}
EXPECT_EQ(1000U, mesh->mNumFaces);
EXPECT_EQ(10000U, mesh->mNumVertices);
EXPECT_EQ(out, mesh->mNumUVComponents[0]);
EXPECT_EQ(static_cast<unsigned int>(
aiPrimitiveType_LINE | aiPrimitiveType_POINT |
aiPrimitiveType_POLYGON | aiPrimitiveType_TRIANGLE),
mesh->mPrimitiveTypes);
}
TEST_F(FindDegeneratesProcessTest, testDegeneratesRemoval) {
process->EnableAreaCheck(false);
process->EnableInstantRemoval(true);
process->ExecuteOnMesh(mesh);
EXPECT_EQ(mesh->mNumUVComponents[1], mesh->mNumFaces);
}
TEST_F(FindDegeneratesProcessTest, testDegeneratesRemovalWithAreaCheck) {
process->EnableAreaCheck(true);
process->EnableInstantRemoval(true);
process->ExecuteOnMesh(mesh);
EXPECT_EQ(mesh->mNumUVComponents[1]-100, mesh->mNumFaces);
}

View file

@ -0,0 +1,138 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <FindInvalidDataProcess.h>
#include "../../include/assimp/mesh.h"
using namespace std;
using namespace Assimp;
class FindInvalidDataProcessTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
aiMesh* pcMesh;
FindInvalidDataProcess* piProcess;
};
// ------------------------------------------------------------------------------------------------
void FindInvalidDataProcessTest::SetUp()
{
ASSERT_TRUE( AI_MAX_NUMBER_OF_TEXTURECOORDS >= 3);
piProcess = new FindInvalidDataProcess();
pcMesh = new aiMesh();
pcMesh->mNumVertices = 1000;
pcMesh->mVertices = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000;++i)
pcMesh->mVertices[i] = aiVector3D((float)i);
pcMesh->mNormals = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000;++i)
pcMesh->mNormals[i] = aiVector3D((float)i+1);
pcMesh->mTangents = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000;++i)
pcMesh->mTangents[i] = aiVector3D((float)i);
pcMesh->mBitangents = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000;++i)
pcMesh->mBitangents[i] = aiVector3D((float)i);
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a)
{
pcMesh->mTextureCoords[a] = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000;++i)
pcMesh->mTextureCoords[a][i] = aiVector3D((float)i);
}
}
// ------------------------------------------------------------------------------------------------
void FindInvalidDataProcessTest::TearDown()
{
delete piProcess;
delete pcMesh;
}
// ------------------------------------------------------------------------------------------------
TEST_F(FindInvalidDataProcessTest, testStepNegativeResult)
{
::memset(pcMesh->mNormals,0,pcMesh->mNumVertices*sizeof(aiVector3D));
::memset(pcMesh->mBitangents,0,pcMesh->mNumVertices*sizeof(aiVector3D));
pcMesh->mTextureCoords[2][455] = aiVector3D( std::numeric_limits<float>::quiet_NaN() );
piProcess->ProcessMesh(pcMesh);
EXPECT_TRUE(NULL != pcMesh->mVertices);
EXPECT_TRUE(NULL == pcMesh->mNormals);
EXPECT_TRUE(NULL == pcMesh->mTangents);
EXPECT_TRUE(NULL == pcMesh->mBitangents);
for (unsigned int i = 0; i < 2;++i)
EXPECT_TRUE(NULL != pcMesh->mTextureCoords[i]);
for (unsigned int i = 2; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
EXPECT_TRUE(NULL == pcMesh->mTextureCoords[i]);
}
// ------------------------------------------------------------------------------------------------
TEST_F(FindInvalidDataProcessTest, testStepPositiveResult)
{
piProcess->ProcessMesh(pcMesh);
EXPECT_TRUE(NULL != pcMesh->mVertices);
EXPECT_TRUE(NULL != pcMesh->mNormals);
EXPECT_TRUE(NULL != pcMesh->mTangents);
EXPECT_TRUE(NULL != pcMesh->mBitangents);
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
EXPECT_TRUE(NULL != pcMesh->mTextureCoords[i]);
}

View file

@ -0,0 +1,43 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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"

View file

@ -0,0 +1,91 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <GenVertexNormalsProcess.h>
using namespace ::std;
using namespace ::Assimp;
class GenNormalsTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
aiMesh* pcMesh;
GenVertexNormalsProcess* piProcess;
};
// ------------------------------------------------------------------------------------------------
void GenNormalsTest::SetUp()
{
piProcess = new GenVertexNormalsProcess();
pcMesh = new aiMesh();
pcMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
pcMesh->mNumFaces = 1;
pcMesh->mFaces = new aiFace[1];
pcMesh->mFaces[0].mIndices = new unsigned int[pcMesh->mFaces[0].mNumIndices = 3];
pcMesh->mFaces[0].mIndices[0] = 0;
pcMesh->mFaces[0].mIndices[1] = 1;
pcMesh->mFaces[0].mIndices[2] = 1;
pcMesh->mNumVertices = 3;
pcMesh->mVertices = new aiVector3D[3];
pcMesh->mVertices[0] = aiVector3D(0.0f,1.0f,6.0f);
pcMesh->mVertices[1] = aiVector3D(2.0f,3.0f,1.0f);
pcMesh->mVertices[2] = aiVector3D(3.0f,2.0f,4.0f);
}
// ------------------------------------------------------------------------------------------------
void GenNormalsTest::TearDown()
{
delete this->pcMesh;
delete this->piProcess;
}
// ------------------------------------------------------------------------------------------------
TEST_F(GenNormalsTest, testSimpleTriangle)
{
piProcess->GenMeshVertexNormals(pcMesh, 0);
EXPECT_TRUE(pcMesh->mNormals != NULL);
}

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utHMPImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/HMP/terrain.hmp", aiProcess_ValidateDataStructure );
return nullptr != scene;
return true;
}
};
TEST_F( utHMPImportExport, importHMPFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,85 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utIFCImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/IFC/AC14-FZK-Haus.ifc", aiProcess_ValidateDataStructure );
return nullptr != scene;
return true;
}
};
TEST_F( utIFCImportExport, importIFCFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utIFCImportExport, importComplextypeAsColor ) {
std::string asset =
"ISO-10303-21;\n"
"HEADER;\n"
"FILE_DESCRIPTION( ( 'ViewDefinition [CoordinationView, SpaceBoundary2ndLevelAddOnView]', 'Option [Filter: ]' ), '2;1' );\n"
"FILE_NAME( 'S:\\[IFC]\\[COMPLETE-BUILDINGS]\\FZK-MODELS\\FZK-Haus\\ArchiCAD-14\\AC14-FZK-Haus.ifc', '2010-10-07T13:40:52', ( 'Architect' ), ( 'Building Designer Office' ), 'PreProc - EDM 5.0', 'ArchiCAD 14.00 Release 1. Windows Build Number of the Ifc 2x3 interface: 3427', 'The authorising person' );\n"
"FILE_SCHEMA( ( 'IFC2X3' ) );\n"
"ENDSEC;\n"
"\n"
"DATA;\n"
"#1 = IFCORGANIZATION( 'GS', 'Graphisoft', 'Graphisoft', $, $ );\n"
"#2 = IFCPROPERTYSINGLEVALUE( 'Red', $, IFCINTEGER( 255 ), $ );\n"
"#3 = IFCPROPERTYSINGLEVALUE( 'Green', $, IFCINTEGER( 255 ), $ );\n"
"#4 = IFCPROPERTYSINGLEVALUE( 'Blue', $, IFCINTEGER( 255 ), $ );\n"
"#5 = IFCCOMPLEXPROPERTY( 'Color', $, 'Color', ( #19, #20, #21 ) );\n";
Assimp::Importer importer;
const aiScene *scene = importer.ReadFileFromMemory( asset.c_str(), asset.size(), 0 );
EXPECT_EQ( nullptr, scene );
}

View file

@ -0,0 +1,146 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/IOStreamBuffer.h>
#include "TestIOStream.h"
#include "UnitTestFileGenerator.h"
class IOStreamBufferTest : public ::testing::Test {
// empty
};
using namespace Assimp;
TEST_F( IOStreamBufferTest, creationTest ) {
bool ok( true );
try {
IOStreamBuffer<char> myBuffer;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( IOStreamBufferTest, accessCacheSizeTest ) {
IOStreamBuffer<char> myBuffer1;
EXPECT_NE( 0U, myBuffer1.cacheSize() );
IOStreamBuffer<char> myBuffer2( 100 );
EXPECT_EQ( 100U, myBuffer2.cacheSize() );
}
const char data[]{"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui\
sque luctus sem diam, ut eleifend arcu auctor eu. Vestibulum id est vel nulla l\
obortis malesuada ut sed turpis. Nulla a volutpat tortor. Nunc vestibulum portt\
itor sapien ornare sagittis volutpat."};
TEST_F( IOStreamBufferTest, open_close_Test ) {
IOStreamBuffer<char> myBuffer;
EXPECT_FALSE( myBuffer.open( nullptr ) );
EXPECT_FALSE( myBuffer.close() );
const auto dataSize = sizeof(data);
const auto dataCount = dataSize / sizeof(*data);
char fname[]={ "octest.XXXXXX" };
auto* fs = MakeTmpFile(fname);
ASSERT_NE(nullptr, fs);
auto written = std::fwrite( data, sizeof(*data), dataCount, fs );
EXPECT_NE( 0U, written );
auto flushResult = std::fflush( fs );
ASSERT_EQ(0, flushResult);
std::fclose( fs );
fs = std::fopen(fname, "r");
ASSERT_NE(nullptr, fs);
{
TestDefaultIOStream myStream( fs, fname );
EXPECT_TRUE( myBuffer.open( &myStream ) );
EXPECT_FALSE( myBuffer.open( &myStream ) );
EXPECT_TRUE( myBuffer.close() );
}
remove(fname);
}
TEST_F( IOStreamBufferTest, readlineTest ) {
const auto dataSize = sizeof(data);
const auto dataCount = dataSize / sizeof(*data);
char fname[]={ "readlinetest.XXXXXX" };
auto* fs = MakeTmpFile(fname);
ASSERT_NE(nullptr, fs);
auto written = std::fwrite( data, sizeof(*data), dataCount, fs );
EXPECT_NE( 0U, written );
auto flushResult = std::fflush(fs);
ASSERT_EQ(0, flushResult);
std::fclose(fs);
fs = std::fopen(fname, "r");
ASSERT_NE(nullptr, fs);
const auto tCacheSize = 26u;
IOStreamBuffer<char> myBuffer( tCacheSize );
EXPECT_EQ(tCacheSize, myBuffer.cacheSize() );
TestDefaultIOStream myStream( fs, fname );
auto size = myStream.FileSize();
auto numBlocks = size / myBuffer.cacheSize();
if ( size % myBuffer.cacheSize() > 0 ) {
numBlocks++;
}
EXPECT_TRUE( myBuffer.open( &myStream ) );
EXPECT_EQ( numBlocks, myBuffer.getNumBlocks() );
EXPECT_TRUE( myBuffer.close() );
}
TEST_F( IOStreamBufferTest, accessBlockIndexTest ) {
}

View file

@ -0,0 +1,79 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "TestIOSystem.h"
#include <assimp/IOSystem.hpp>
using namespace std;
using namespace Assimp;
class IOSystemTest : public ::testing::Test {
public:
virtual void SetUp() {
pImp = new TestIOSystem();
}
virtual void TearDown() {
delete pImp;
}
protected:
TestIOSystem* pImp;
};
TEST_F( IOSystemTest, accessDirectoryStackTest ) {
EXPECT_FALSE( pImp->PopDirectory() );
EXPECT_EQ( 0U, pImp->StackSize() );
EXPECT_FALSE( pImp->PushDirectory( "" ) );
std::string path = "test/";
EXPECT_TRUE( pImp->PushDirectory( path ) );
EXPECT_EQ( 1U, pImp->StackSize() );
EXPECT_EQ( path, pImp->CurrentDirectory() );
EXPECT_TRUE( pImp->PopDirectory() );
EXPECT_EQ( 0U, pImp->StackSize() );
}
TEST_F( IOSystemTest, delFileTest ) {
EXPECT_FALSE( pImp->DeleteFile( "none" ) );
}

View file

@ -0,0 +1,280 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "../../include/assimp/postprocess.h"
#include "../../include/assimp/scene.h"
#include <assimp/Importer.hpp>
#include <assimp/BaseImporter.h>
#include "TestIOSystem.h"
#include <assimp/DefaultIOSystem.h>
using namespace ::std;
using namespace ::Assimp;
class ImporterTest : public ::testing::Test
{
public:
virtual void SetUp() {
pImp = new Importer();
}
virtual void TearDown() {
delete pImp;
}
protected:
Importer* pImp;
};
#define InputData_BLOCK_SIZE 1310
// test data for Importer::ReadFileFromMemory() - ./test/3DS/CameraRollAnim.3ds
static unsigned char InputData_abRawBlock[1310] = {
77,77,30,5,0,0,2,0,10,0,0,0,3,0,0,0,61,61,91,3,0,0,62,61,10,0,0,0,3,0,0,0,
0,1,10,0,0,0,0,0,128,63,0,64,254,2,0,0,66,111,120,48,49,0,0,65,242,2,0,0,16,65,64,1,
0,0,26,0,102,74,198,193,102,74,198,193,0,0,0,0,205,121,55,66,102,74,198,193,0,0,0,0,102,74,198,193,
138,157,184,65,0,0,0,0,205,121,55,66,138,157,184,65,0,0,0,0,102,74,198,193,102,74,198,193,90,252,26,66,
205,121,55,66,102,74,198,193,90,252,26,66,102,74,198,193,138,157,184,65,90,252,26,66,205,121,55,66,138,157,184,65,
90,252,26,66,102,74,198,193,102,74,198,193,0,0,0,0,205,121,55,66,102,74,198,193,0,0,0,0,205,121,55,66,
102,74,198,193,90,252,26,66,205,121,55,66,102,74,198,193,90,252,26,66,102,74,198,193,102,74,198,193,90,252,26,66,
102,74,198,193,102,74,198,193,0,0,0,0,205,121,55,66,138,157,184,65,0,0,0,0,205,121,55,66,102,74,198,193,
90,252,26,66,205,121,55,66,138,157,184,65,0,0,0,0,102,74,198,193,138,157,184,65,0,0,0,0,102,74,198,193,
138,157,184,65,90,252,26,66,102,74,198,193,138,157,184,65,90,252,26,66,205,121,55,66,138,157,184,65,90,252,26,66,
205,121,55,66,138,157,184,65,0,0,0,0,102,74,198,193,138,157,184,65,0,0,0,0,102,74,198,193,102,74,198,193,
90,252,26,66,102,74,198,193,102,74,198,193,90,252,26,66,102,74,198,193,138,157,184,65,0,0,0,0,64,65,216,0,
0,0,26,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,
0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,
0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,
0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,
0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,
0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,
0,0,128,63,0,0,128,63,0,0,128,63,0,0,0,0,0,0,0,0,96,65,54,0,0,0,0,0,128,63,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,53,169,
40,65,176,205,90,191,0,0,0,0,32,65,158,0,0,0,12,0,0,0,2,0,3,0,6,0,3,0,1,0,0,0,
6,0,4,0,5,0,7,0,6,0,7,0,6,0,4,0,6,0,8,0,9,0,10,0,6,0,11,0,12,0,13,0,
6,0,1,0,14,0,7,0,6,0,7,0,15,0,1,0,6,0,16,0,17,0,18,0,6,0,19,0,20,0,21,0,
6,0,22,0,0,0,23,0,6,0,24,0,6,0,25,0,6,0,80,65,54,0,0,0,2,0,0,0,2,0,0,0,
4,0,0,0,4,0,0,0,8,0,0,0,8,0,0,0,16,0,0,0,16,0,0,0,32,0,0,0,32,0,0,0,
64,0,0,0,64,0,0,0,0,64,67,0,0,0,67,97,109,101,114,97,48,49,0,0,71,52,0,0,0,189,19,25,
195,136,104,81,64,147,56,182,65,96,233,20,194,67,196,97,190,147,56,182,65,0,0,0,0,85,85,85,66,32,71,14,
0,0,0,0,0,0,0,0,0,122,68,0,176,179,1,0,0,10,176,21,0,0,0,5,0,77,65,88,83,67,69,78,
69,0,44,1,0,0,8,176,14,0,0,0,0,0,0,0,44,1,0,0,9,176,10,0,0,0,128,2,0,0,2,176,
168,0,0,0,48,176,8,0,0,0,0,0,16,176,18,0,0,0,66,111,120,48,49,0,0,64,0,0,255,255,19,176,
18,0,0,0,0,0,0,128,0,0,0,128,0,0,0,128,32,176,38,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,0,0,0,0,53,169,40,65,176,205,90,191,0,0,0,0,33,176,42,0,0,0,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
34,176,38,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,
128,63,0,0,128,63,3,176,143,0,0,0,48,176,8,0,0,0,1,0,16,176,21,0,0,0,67,97,109,101,114,97,
48,49,0,0,64,0,0,255,255,32,176,38,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,
0,0,0,189,19,25,195,136,104,81,64,147,56,182,65,35,176,30,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
0,0,0,0,0,0,0,0,0,0,0,52,66,36,176,40,0,0,0,0,0,0,0,0,0,120,0,0,0,2,0,0,
0,0,0,0,0,0,0,120,13,90,189,120,0,0,0,0,0,99,156,154,194,4,176,73,0,0,0,48,176,8,0,0,
0,2,0,16,176,21,0,0,0,67,97,109,101,114,97,48,49,0,0,64,0,0,255,255,32,176,38,0,0,0,0,0,
0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,96,233,20,194,67,196,97,190,147,56,182,65,
};
#define AIUT_DEF_ERROR_TEXT "sorry, this is a test"
static const aiImporterDesc desc = {
"UNIT TEST - IMPORTER",
"",
"",
"",
0,
0,
0,
0,
0,
"apple mac linux windows"
};
class TestPlugin : public BaseImporter
{
public:
virtual bool CanRead(
const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*test*/) const
{
std::string::size_type pos = pFile.find_last_of('.');
// no file extension - can't read
if( pos == std::string::npos)
return false;
std::string extension = pFile.substr( pos);
// todo ... make case-insensitive
return (extension == ".apple" || extension == ".mac" ||
extension == ".linux" || extension == ".windows" );
}
virtual const aiImporterDesc* GetInfo () const
{
return & desc;
}
virtual void InternReadFile(
const std::string& /*pFile*/, aiScene* /*pScene*/, IOSystem* /*pIOHandler*/)
{
throw DeadlyImportError(AIUT_DEF_ERROR_TEXT);
}
};
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testMemoryRead)
{
const aiScene* sc = pImp->ReadFileFromMemory(InputData_abRawBlock,InputData_BLOCK_SIZE,
aiProcessPreset_TargetRealtime_Quality,"3ds");
ASSERT_TRUE(sc != NULL);
EXPECT_EQ(aiString("<3DSRoot>"), sc->mRootNode->mName);
EXPECT_EQ(1U, sc->mNumMeshes);
EXPECT_EQ(24U, sc->mMeshes[0]->mNumVertices);
EXPECT_EQ(12U, sc->mMeshes[0]->mNumFaces);
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testIntProperty)
{
bool b = pImp->SetPropertyInteger("quakquak",1503);
EXPECT_FALSE(b);
EXPECT_EQ(1503, pImp->GetPropertyInteger("quakquak",0));
EXPECT_EQ(314159, pImp->GetPropertyInteger("not_there",314159));
b = pImp->SetPropertyInteger("quakquak",1504);
EXPECT_TRUE(b);
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testFloatProperty)
{
bool b = pImp->SetPropertyFloat("quakquak",1503.f);
EXPECT_TRUE(!b);
EXPECT_EQ(1503.f, pImp->GetPropertyFloat("quakquak",0.f));
EXPECT_EQ(314159.f, pImp->GetPropertyFloat("not_there",314159.f));
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testStringProperty)
{
bool b = pImp->SetPropertyString("quakquak","test");
EXPECT_TRUE(!b);
EXPECT_EQ("test", pImp->GetPropertyString("quakquak","weghwekg"));
EXPECT_EQ("ILoveYou", pImp->GetPropertyString("not_there","ILoveYou"));
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testPluginInterface)
{
pImp->RegisterLoader(new TestPlugin());
EXPECT_TRUE(pImp->IsExtensionSupported(".apple"));
EXPECT_TRUE(pImp->IsExtensionSupported(".mac"));
EXPECT_TRUE(pImp->IsExtensionSupported("*.linux"));
EXPECT_TRUE(pImp->IsExtensionSupported("windows"));
EXPECT_TRUE(pImp->IsExtensionSupported(".x")); /* x and 3ds must be available in this Assimp build, of course! */
EXPECT_TRUE(pImp->IsExtensionSupported(".3ds"));
EXPECT_FALSE(pImp->IsExtensionSupported("."));
TestPlugin* p = (TestPlugin*) pImp->GetImporter(".windows");
ASSERT_TRUE(NULL != p);
try {
p->InternReadFile("",0,NULL);
}
catch ( const DeadlyImportError& dead)
{
EXPECT_TRUE(!strcmp(dead.what(),AIUT_DEF_ERROR_TEXT));
// unregister the plugin and delete it
pImp->UnregisterLoader(p);
delete p;
return;
}
EXPECT_TRUE(false); // control shouldn't reach this point
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testExtensionCheck)
{
std::string s;
pImp->GetExtensionList(s);
// TODO
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testMultipleReads)
{
// see http://sourceforge.net/projects/assimp/forums/forum/817654/topic/3591099
// Check whether reading and post-processing multiple times using
// the same objects is *generally* fine. This test doesn't target
// importers. Testing post-processing stability is the main point.
const unsigned int flags =
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_GenSmoothNormals |
aiProcess_ValidateDataStructure |
aiProcess_RemoveRedundantMaterials |
aiProcess_SortByPType |
aiProcess_FindDegenerates |
aiProcess_FindInvalidData |
aiProcess_GenUVCoords |
aiProcess_OptimizeMeshes |
aiProcess_OptimizeGraph;
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test.x",flags));
//EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/dwarf.x",flags)); # is in nonbsd
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/Testwuson.X",flags));
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x",flags));
//EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/dwarf.x",flags)); # is in nonbsd
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x",flags));
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/BCN_Epileptic.X",flags));
//EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/dwarf.x",flags)); # is in nonbsd
}
TEST_F( ImporterTest, SearchFileHeaderForTokenTest ) {
//DefaultIOSystem ioSystem;
// BaseImporter::SearchFileHeaderForToken( &ioSystem, assetPath, Token, 2 )
}

View file

@ -0,0 +1,44 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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"

View file

@ -0,0 +1,82 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
#include "TestModelFactory.h"
using namespace Assimp;
class utIssues : public ::testing::Test {
};
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F( utIssues, OpacityBugWhenExporting_727 ) {
float opacity;
aiScene *scene( TestModelFacttory::createDefaultTestModel( opacity ) );
Assimp::Importer importer;
Assimp::Exporter exporter;
std::string path = "dae";
const aiExportFormatDesc *desc( exporter.GetExportFormatDescription( 0 ) );
EXPECT_NE( desc, nullptr );
path.append( desc->fileExtension );
EXPECT_EQ( AI_SUCCESS, exporter.Export( scene, desc->id, path ) );
const aiScene *newScene( importer.ReadFile( path, aiProcess_ValidateDataStructure ) );
EXPECT_TRUE( NULL != newScene );
float newOpacity;
if ( newScene->mNumMaterials > 0 ) {
std::cout << "Desc = " << desc->description << "\n";
EXPECT_EQ( AI_SUCCESS, newScene->mMaterials[ 0 ]->Get( AI_MATKEY_OPACITY, newOpacity ) );
EXPECT_EQ( opacity, newOpacity );
}
delete scene;
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,145 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <JoinVerticesProcess.h>
using namespace std;
using namespace Assimp;
class JoinVerticesTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
JoinVerticesProcess* piProcess;
aiMesh* pcMesh;
};
// ------------------------------------------------------------------------------------------------
void JoinVerticesTest::SetUp()
{
// construct the process
piProcess = new JoinVerticesProcess();
// create a quite small mesh for testing purposes -
// the mesh itself is *something* but it has redundant vertices
pcMesh = new aiMesh();
pcMesh->mNumVertices = 900;
aiVector3D*& pv = pcMesh->mVertices = new aiVector3D[900];
for (unsigned int i = 0; i < 3;++i)
{
const unsigned int base = i*300;
for (unsigned int a = 0; a < 300;++a)
{
pv[base+a].x = pv[base+a].y = pv[base+a].z = (float)a;
}
}
// generate faces - each vertex is referenced once
pcMesh->mNumFaces = 300;
pcMesh->mFaces = new aiFace[300];
for (unsigned int i = 0,p = 0; i < 300;++i)
{
aiFace& face = pcMesh->mFaces[i];
face.mIndices = new unsigned int[ face.mNumIndices = 3 ];
for (unsigned int a = 0; a < 3;++a)
face.mIndices[a] = p++;
}
// generate extra members - set them to zero to make sure they're identical
pcMesh->mTextureCoords[0] = new aiVector3D[900];
for (unsigned int i = 0; i < 900;++i)pcMesh->mTextureCoords[0][i] = aiVector3D( 0.f );
pcMesh->mNormals = new aiVector3D[900];
for (unsigned int i = 0; i < 900;++i)pcMesh->mNormals[i] = aiVector3D( 0.f );
pcMesh->mTangents = new aiVector3D[900];
for (unsigned int i = 0; i < 900;++i)pcMesh->mTangents[i] = aiVector3D( 0.f );
pcMesh->mBitangents = new aiVector3D[900];
for (unsigned int i = 0; i < 900;++i)pcMesh->mBitangents[i] = aiVector3D( 0.f );
}
// ------------------------------------------------------------------------------------------------
void JoinVerticesTest::TearDown()
{
delete this->pcMesh;
delete this->piProcess;
}
// ------------------------------------------------------------------------------------------------
TEST_F(JoinVerticesTest, testProcess)
{
// execute the step on the given data
piProcess->ProcessMesh(pcMesh,0);
// the number of faces shouldn't change
ASSERT_EQ(300U, pcMesh->mNumFaces);
ASSERT_EQ(300U, pcMesh->mNumVertices);
ASSERT_TRUE(NULL != pcMesh->mNormals);
ASSERT_TRUE(NULL != pcMesh->mTangents);
ASSERT_TRUE(NULL != pcMesh->mBitangents);
ASSERT_TRUE(NULL != pcMesh->mTextureCoords[0]);
// the order doesn't care
float fSum = 0.f;
for (unsigned int i = 0; i < 300;++i)
{
aiVector3D& v = pcMesh->mVertices[i];
fSum += v.x + v.y + v.z;
EXPECT_FALSE(pcMesh->mNormals[i].x);
EXPECT_FALSE(pcMesh->mTangents[i].x);
EXPECT_FALSE(pcMesh->mBitangents[i].x);
EXPECT_FALSE(pcMesh->mTextureCoords[0][i].x);
}
EXPECT_EQ(150.f*299.f*3.f, fSum); // gaussian sum equation
}

View file

@ -0,0 +1,142 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utLWSImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/LWS/move_x.lws", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F( utLWSImportExport, importLWSFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F(utLWSImportExport, importLWSmove_x_post_linear) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_linear.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_bezier) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_bezier.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_stepped) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_stepped.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_oldformat_56) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_oldformat_56.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_post_offset_repeat) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_offset_repeat.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_hermite) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_hermite.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_y_pre_ofrep_post_osc) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_y_pre_ofrep_post_osc.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_oldformat_6) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_oldformat_6.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_post_repeat) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_repeat.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_linear) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_linear.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_post_constant) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_constant.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_post_reset) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_reset.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_spline) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_spline.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}

View file

@ -0,0 +1,140 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <LimitBoneWeightsProcess.h>
using namespace std;
using namespace Assimp;
class LimitBoneWeightsTest : public ::testing::Test {
public:
virtual void SetUp();
virtual void TearDown();
protected:
LimitBoneWeightsProcess* piProcess;
aiMesh* pcMesh;
};
// ------------------------------------------------------------------------------------------------
void LimitBoneWeightsTest::SetUp()
{
// construct the process
this->piProcess = new LimitBoneWeightsProcess();
// now need to create a nice mesh for testing purposes
this->pcMesh = new aiMesh();
pcMesh->mNumVertices = 500;
pcMesh->mVertices = new aiVector3D[500]; // uninit.
pcMesh->mNumBones = 30;
pcMesh->mBones = new aiBone*[30];
unsigned int iCur = 0;
for (unsigned int i = 0; i < 30;++i)
{
aiBone* pc = pcMesh->mBones[i] = new aiBone();
pc->mNumWeights = 250;
pc->mWeights = new aiVertexWeight[pc->mNumWeights];
for (unsigned int qq = 0; qq < pc->mNumWeights;++qq)
{
aiVertexWeight& v = pc->mWeights[qq];
v.mVertexId = iCur++;
if (500 == iCur)iCur = 0;
v.mWeight = 1.0f / 15; // each vertex should occur once in two bones
}
}
}
// ------------------------------------------------------------------------------------------------
void LimitBoneWeightsTest::TearDown()
{
delete pcMesh;
delete piProcess;
}
// ------------------------------------------------------------------------------------------------
TEST_F(LimitBoneWeightsTest, testProcess)
{
// execute the step on the given data
piProcess->ProcessMesh(pcMesh);
// check whether everything is ok ...
typedef std::vector<LimitBoneWeightsProcess::Weight> VertexWeightList;
VertexWeightList* asWeights = new VertexWeightList[pcMesh->mNumVertices];
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
asWeights[i].reserve(4);
// sort back as per-vertex lists
for (unsigned int i = 0; i < pcMesh->mNumBones;++i)
{
aiBone& pcBone = **(pcMesh->mBones+i);
for (unsigned int q = 0; q < pcBone.mNumWeights;++q)
{
aiVertexWeight weight = pcBone.mWeights[q];
asWeights[weight.mVertexId].push_back(LimitBoneWeightsProcess::Weight (i,weight.mWeight));
}
}
// now validate the size of the lists and check whether all weights sum to 1.0f
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
{
EXPECT_LE(asWeights[i].size(), 4U);
float fSum = 0.0f;
for (VertexWeightList::const_iterator
iter = asWeights[i].begin();
iter != asWeights[i].end();++iter)
{
fSum += (*iter).mWeight;
}
EXPECT_GE(fSum, 0.95F);
EXPECT_LE(fSum, 1.04F);
}
// delete allocated storage
delete[] asWeights;
// everything seems to be OK
}

View file

@ -0,0 +1,63 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utMDCImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/MDC/spider.mdc", 0);
return true;
return nullptr != scene;
}
};
TEST_F( utMDCImportExport, importMDCFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,143 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <MaterialSystem.h>
using namespace ::std;
using namespace ::Assimp;
class MaterialSystemTest : public ::testing::Test
{
public:
virtual void SetUp() { this->pcMat = new aiMaterial(); }
virtual void TearDown() { delete this->pcMat; }
protected:
aiMaterial* pcMat;
};
// ------------------------------------------------------------------------------------------------
TEST_F(MaterialSystemTest, testFloatProperty)
{
float pf = 150392.63f;
this->pcMat->AddProperty(&pf,1,"testKey1");
pf = 0.0f;
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey1",0,0,pf));
EXPECT_EQ(150392.63f, pf);
}
// ------------------------------------------------------------------------------------------------
TEST_F(MaterialSystemTest, testFloatArrayProperty)
{
float pf[] = {0.0f,1.0f,2.0f,3.0f};
unsigned int pMax = sizeof(pf) / sizeof(float);
this->pcMat->AddProperty(pf,pMax,"testKey2");
pf[0] = pf[1] = pf[2] = pf[3] = 12.0f;
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2",0,0,pf,&pMax));
EXPECT_EQ(sizeof(pf) / sizeof(float), pMax);
EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3] );
}
// ------------------------------------------------------------------------------------------------
TEST_F(MaterialSystemTest, testIntProperty)
{
int pf = 15039263;
this->pcMat->AddProperty(&pf,1,"testKey3");
pf = 12;
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey3",0,0,pf));
EXPECT_EQ(15039263, pf);
}
// ------------------------------------------------------------------------------------------------
TEST_F(MaterialSystemTest, testIntArrayProperty)
{
int pf[] = {0,1,2,3};
unsigned int pMax = sizeof(pf) / sizeof(int);
this->pcMat->AddProperty(pf,pMax,"testKey4");
pf[0] = pf[1] = pf[2] = pf[3] = 12;
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey4",0,0,pf,&pMax));
EXPECT_EQ(sizeof(pf) / sizeof(int), pMax);
EXPECT_TRUE(!pf[0] && 1 == pf[1] && 2 == pf[2] && 3 == pf[3] );
}
// ------------------------------------------------------------------------------------------------
TEST_F(MaterialSystemTest, testColorProperty)
{
aiColor4D clr;
clr.r = 2.0f;clr.g = 3.0f;clr.b = 4.0f;clr.a = 5.0f;
this->pcMat->AddProperty(&clr,1,"testKey5");
clr.b = 1.0f;
clr.a = clr.g = clr.r = 0.0f;
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey5",0,0,clr));
EXPECT_TRUE(clr.r == 2.0f && clr.g == 3.0f && clr.b == 4.0f && clr.a == 5.0f);
}
// ------------------------------------------------------------------------------------------------
TEST_F(MaterialSystemTest, testStringProperty) {
aiString s;
s.Set("Hello, this is a small test");
this->pcMat->AddProperty(&s,"testKey6");
s.Set("358358");
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey6",0,0,s));
EXPECT_STREQ("Hello, this is a small test", s.data);
}
// ------------------------------------------------------------------------------------------------
TEST_F(MaterialSystemTest, testMaterialNameAccess) {
aiMaterial *mat = new aiMaterial();
EXPECT_NE(nullptr, mat);
aiString name = mat->GetName();
const int retValue(strncmp(name.C_Str(), AI_DEFAULT_MATERIAL_NAME, name.length));
EXPECT_EQ(0, retValue );
delete mat;
}

View file

@ -0,0 +1,101 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <iostream>
using namespace ::Assimp;
class utMatrix3x3Test : public ::testing::Test {
// empty
};
TEST_F( utMatrix3x3Test, FromToMatrixTest ) {
aiVector3D res;
aiMatrix3x3 trafo;
const double PRECISION = 0.000001;
// axes test
aiVector3D axes[] =
{ aiVector3D(1, 0, 0)
, aiVector3D(0, 1, 0)
, aiVector3D(0, 0, 1)
};
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
aiMatrix3x3::FromToMatrix( axes[i], axes[j], trafo );
res = trafo * axes[i];
ASSERT_NEAR( axes[j].x, res.x, PRECISION );
ASSERT_NEAR( axes[j].y, res.y, PRECISION );
ASSERT_NEAR( axes[j].z, res.z, PRECISION );
}
}
// random test
const int NUM_SAMPLES = 10000;
aiVector3D from, to;
for (int i = 0; i < NUM_SAMPLES; ++i) {
from = aiVector3D
( 1.f * rand() / RAND_MAX
, 1.f * rand() / RAND_MAX
, 1.f * rand() / RAND_MAX
).Normalize();
to = aiVector3D
( 1.f * rand() / RAND_MAX
, 1.f * rand() / RAND_MAX
, 1.f * rand() / RAND_MAX
).Normalize();
aiMatrix3x3::FromToMatrix( from, to, trafo );
res = trafo * from;
ASSERT_NEAR( to.x, res.x, PRECISION );
ASSERT_NEAR( to.y, res.y, PRECISION );
ASSERT_NEAR( to.z, res.z, PRECISION );
}
}

View file

@ -0,0 +1,95 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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"
using namespace Assimp;
class utMatrix4x4 : public ::testing::Test {
};
TEST_F( utMatrix4x4, badIndexOperatorTest ) {
aiMatrix4x4 m;
ai_real *a0 = m[ 4 ];
EXPECT_EQ( NULL, a0 );
}
TEST_F( utMatrix4x4, indexOperatorTest ) {
aiMatrix4x4 m;
ai_real *a0 = m[ 0 ];
EXPECT_FLOAT_EQ( 1.0, *a0 );
ai_real *a1 = a0+1;
EXPECT_FLOAT_EQ( 0.0, *a1 );
ai_real *a2 = a0 + 2;
EXPECT_FLOAT_EQ( 0.0, *a2 );
ai_real *a3 = a0 + 3;
EXPECT_FLOAT_EQ( 0.0, *a3 );
ai_real *a4 = m[ 1 ];
EXPECT_FLOAT_EQ( 0.0, *a4 );
ai_real *a5 = a4 + 1;
EXPECT_FLOAT_EQ( 1.0, *a5 );
ai_real *a6 = a4 + 2;
EXPECT_FLOAT_EQ( 0.0, *a6 );
ai_real *a7 = a4 + 3;
EXPECT_FLOAT_EQ( 0.0, *a7 );
ai_real *a8 = m[ 2 ];
EXPECT_FLOAT_EQ( 0.0, *a8 );
ai_real *a9 = a8 + 1;
EXPECT_FLOAT_EQ( 0.0, *a9 );
ai_real *a10 = a8 + 2;
EXPECT_FLOAT_EQ( 1.0, *a10 );
ai_real *a11 = a8 + 3;
EXPECT_FLOAT_EQ( 0.0, *a11 );
ai_real *a12 = m[ 3 ];
EXPECT_FLOAT_EQ( 0.0, *a12 );
ai_real *a13 = a12 + 1;
EXPECT_FLOAT_EQ( 0.0, *a13 );
ai_real *a14 = a12 + 2;
EXPECT_FLOAT_EQ( 0.0, *a14 );
ai_real *a15 = a12 + 3;
EXPECT_FLOAT_EQ( 1.0, *a15 );
}

View file

@ -0,0 +1,254 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/metadata.h>
using namespace ::Assimp;
class utMetadata: public ::testing::Test {
protected:
aiMetadata *m_data;
virtual void SetUp() {
m_data = nullptr;
}
virtual void TearDown() {
aiMetadata::Dealloc( m_data );
}
};
TEST_F( utMetadata, creationTest ) {
bool ok( true );
try {
aiMetadata data;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utMetadata, allocTest ) {
aiMetadata *data = aiMetadata::Alloc( 0 );
EXPECT_EQ( nullptr, data );
data = aiMetadata::Alloc( 1 );
EXPECT_NE( nullptr, data );
EXPECT_EQ( 1U, data->mNumProperties );
EXPECT_NE( nullptr, data->mKeys );
EXPECT_NE( nullptr, data->mValues );
aiMetadata::Dealloc( data );
}
TEST_F( utMetadata, get_set_pod_Test ) {
m_data = aiMetadata::Alloc( 5 );
// int, 32 bit
unsigned int index( 0 );
bool success( false );
const std::string key_int = "test_int";
success = m_data->Set( index, key_int, 1 );
EXPECT_TRUE( success );
success = m_data->Set( index + 10, key_int, 1 );
EXPECT_FALSE( success );
// unsigned int, 64 bit
index++;
const std::string key_uint = "test_uint";
success = m_data->Set<uint64_t>( index, key_uint, 1UL );
EXPECT_TRUE( success );
uint64_t result_uint( 0 );
success = m_data->Get( key_uint, result_uint );
EXPECT_TRUE( success );
EXPECT_EQ( 1UL, result_uint );
// bool
index++;
const std::string key_bool = "test_bool";
success = m_data->Set( index, key_bool, true );
EXPECT_TRUE( success );
bool result_bool( false );
success = m_data->Get( key_bool, result_bool );
EXPECT_TRUE( success );
EXPECT_EQ( true, result_bool );
// float
index++;
const std::string key_float = "test_float";
float fVal = 2.0f;
success = m_data->Set( index, key_float, fVal );
EXPECT_TRUE( success );
float result_float( 0.0f );
success = m_data->Get( key_float, result_float );
EXPECT_TRUE( success );
EXPECT_FLOAT_EQ( 2.0f, result_float );
// double
index++;
const std::string key_double = "test_double";
double dVal = 3.0;
success = m_data->Set( index, key_double, dVal );
EXPECT_TRUE( success );
double result_double( 0.0 );
success = m_data->Get( key_double, result_double );
EXPECT_TRUE( success );
EXPECT_DOUBLE_EQ( 3.0, result_double );
// error
int result;
success = m_data->Get( "bla", result );
EXPECT_FALSE( success );
}
TEST_F( utMetadata, get_set_string_Test ) {
m_data = aiMetadata::Alloc( 1 );
unsigned int index( 0 );
bool success( false );
const std::string key = "test";
success = m_data->Set( index, key, aiString( std::string( "test" ) ) );
EXPECT_TRUE( success );
success = m_data->Set( index+10, key, aiString( std::string( "test" ) ) );
EXPECT_FALSE( success );
aiString result;
success = m_data->Get( key, result );
EXPECT_EQ( aiString( std::string( "test" ) ), result );
EXPECT_TRUE( success );
success = m_data->Get( "bla", result );
EXPECT_FALSE( success );
}
TEST_F( utMetadata, get_set_aiVector3D_Test ) {
m_data = aiMetadata::Alloc( 1 );
unsigned int index( 0 );
bool success( false );
const std::string key = "test";
aiVector3D vec( 1, 2, 3 );
success = m_data->Set( index, key, vec );
EXPECT_TRUE( success );
aiVector3D result( 0, 0, 0 );
success = m_data->Get( key, result );
EXPECT_EQ( vec, result );
EXPECT_TRUE( success );
}
TEST_F( utMetadata, copy_test ) {
m_data = aiMetadata::Alloc( AI_META_MAX );
bool bv = true;
m_data->Set( 0, "bool", bv );
int32_t i32v = -10;
m_data->Set( 1, "int32", i32v );
uint64_t ui64v = static_cast<uint64_t>( 10 );
m_data->Set( 2, "uint64", ui64v );
float fv = 1.0f;
m_data->Set( 3, "float", fv );
double dv = 2.0;
m_data->Set( 4, "double", dv );
const aiString strVal( std::string( "test" ) );
m_data->Set( 5, "aiString", strVal );
aiVector3D vecVal( 1, 2, 3 );
m_data->Set( 6, "aiVector3D", vecVal );
aiMetadata copy( *m_data );
EXPECT_EQ( 7u, copy.mNumProperties );
// bool test
{
bool v;
EXPECT_TRUE( copy.Get( "bool", v ) );
EXPECT_EQ( bv, v );
}
// int32_t test
{
int32_t v = 0;
bool ok = copy.Get( "int32", v );
EXPECT_TRUE( ok );
EXPECT_EQ( i32v, v );
}
// uint64_t test
{
uint64_t v;
bool ok = copy.Get( "uint64", v );
EXPECT_TRUE( ok );
EXPECT_EQ( ui64v, v );
}
// float test
{
float v;
EXPECT_TRUE( copy.Get( "float", v ) );
EXPECT_EQ( fv, v );
}
// double test
{
double v;
EXPECT_TRUE( copy.Get( "double", v ) );
EXPECT_EQ( dv, v );
}
// bool test
{
aiString v;
EXPECT_TRUE( copy.Get( "aiString", v ) );
EXPECT_EQ( strVal, v );
}
// bool test
{
aiVector3D v;
EXPECT_TRUE( copy.Get( "aiVector3D", v ) );
EXPECT_EQ( vecVal, v );
}
}

View file

@ -0,0 +1,112 @@
/*
---------------------------------------------------------------------------
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 "BoostWorkaround/boost/tuple/tuple.hpp"
#define ASSIMP_FORCE_NOBOOST
#include "BoostWorkaround/boost/format.hpp"
#include <assimp/TinyFormatter.h>
using namespace std;
using namespace Assimp;
using namespace Assimp::Formatter;
// ------------------------------------------------------------------------------------------------
TEST(NoBoostTest, testFormat)
{
EXPECT_EQ( "Ahoi!", boost::str( boost::format("Ahoi!") ));
EXPECT_EQ( "Ahoi! %", boost::str( boost::format("Ahoi! %%") ));
EXPECT_EQ( "Ahoi! ", boost::str( boost::format("Ahoi! %s") ));
EXPECT_EQ( "Ahoi! !!", boost::str( boost::format("Ahoi! %s") % "!!" ));
EXPECT_EQ( "Ahoi! !!", boost::str( boost::format("Ahoi! %s") % "!!" % "!!" ));
EXPECT_EQ( "abc", boost::str( boost::format("%s%s%s") % "a" % std::string("b") % "c" ));
}
struct another
{
int dummy;
};
// ------------------------------------------------------------------------------------------------
TEST(NoBoostTest, Tuple) {
// Implicit conversion
boost::tuple<unsigned,unsigned,unsigned> first = boost::make_tuple(4,4,4);
EXPECT_EQ(4U, first.get<0>());
EXPECT_EQ(4U, first.get<1>());
EXPECT_EQ(4U, first.get<2>());
boost::tuple<int, float, double, bool, another> second=
boost::make_tuple(1,1.0f,0.0,false,another());
bool b = second.get<3>();
// check empty tuple
boost::tuple<> third;
third;
// FIXME: Explicit conversion not really required yet
boost::tuple<float,float,float> last =
(boost::tuple<float,float,float>)boost::make_tuple(1.,2.,3.);
EXPECT_EQ(1.f, last.get<0>());
EXPECT_EQ(2.f, last.get<1>());
EXPECT_EQ(3.f, last.get<2>());
// Non-const access
first.get<0>() = 1;
first.get<1>() = 2;
first.get<2>() = 3;
EXPECT_EQ(1U, first.get<0>());
EXPECT_EQ(2U, first.get<1>());
EXPECT_EQ(3U, first.get<2>());
// Const cases
const boost::tuple<unsigned,unsigned,unsigned> constant = boost::make_tuple(5,5,5);
first.get<0>() = constant.get<0>();
EXPECT_EQ(5U, constant.get<0>());
EXPECT_EQ(5U, first.get<0>());
// Direct assignment w. explicit conversion
last = first;
EXPECT_EQ(5.f, last.get<0>());
EXPECT_EQ(2.f, last.get<1>());
EXPECT_EQ(3.f, last.get<2>());
}

View file

@ -0,0 +1,398 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
static const float VertComponents[ 24 * 3 ] = {
-0.500000, 0.500000, 0.500000,
-0.500000, 0.500000, -0.500000,
-0.500000, -0.500000, -0.500000,
-0.500000, -0.500000, 0.500000,
-0.500000, -0.500000, -0.500000,
0.500000, -0.500000, -0.500000,
0.500000, -0.500000, 0.500000,
-0.500000, -0.500000, 0.500000,
-0.500000, 0.500000, -0.500000,
0.500000, 0.500000, -0.500000,
0.500000, -0.500000, -0.500000,
-0.500000, -0.500000, -0.500000,
0.500000, 0.500000, 0.500000,
0.500000, 0.500000, -0.500000,
-0.500000, 0.500000, -0.500000,
-0.500000, 0.500000, 0.500000,
0.500000, -0.500000, 0.500000,
0.500000, 0.500000, 0.500000,
-0.500000, 0.500000, 0.500000,
-0.500000, -0.500000, 0.500000,
0.500000, -0.500000, -0.500000,
0.500000, 0.500000, -0.500000,
0.500000, 0.500000, 0.500000f,
0.500000, -0.500000, 0.500000f
};
static const std::string ObjModel =
"o 1\n"
"\n"
"# Vertex list\n"
"\n"
"v -0.5 -0.5 0.5\n"
"v -0.5 -0.5 -0.5\n"
"v -0.5 0.5 -0.5\n"
"v -0.5 0.5 0.5\n"
"v 0.5 -0.5 0.5\n"
"v 0.5 -0.5 -0.5\n"
"v 0.5 0.5 -0.5\n"
"v 0.5 0.5 0.5\n"
"\n"
"# Point / Line / Face list\n"
"\n"
"g Box01\n"
"usemtl Default\n"
"f 4 3 2 1\n"
"f 2 6 5 1\n"
"f 3 7 6 2\n"
"f 8 7 3 4\n"
"f 5 8 4 1\n"
"f 6 7 8 5\n"
"\n"
"# End of file\n";
static const std::string ObjModel_Issue1111 =
"o 1\n"
"\n"
"# Vertex list\n"
"\n"
"v -0.5 -0.5 0.5\n"
"v -0.5 -0.5 -0.5\n"
"v -0.5 0.5 -0.5\n"
"\n"
"usemtl\n"
"f 1 2 3\n"
"\n"
"# End of file\n";
class utObjImportExport : public AbstractImportExportBase {
protected:
virtual void SetUp() {
m_im = new Assimp::Importer;
}
virtual void TearDown() {
delete m_im;
m_im = nullptr;
}
aiScene *createScene() {
aiScene *expScene = new aiScene;
expScene->mNumMeshes = 1;
expScene->mMeshes = new aiMesh*[ 1 ];
aiMesh *mesh = new aiMesh;
mesh->mName.Set( "1" );
mesh->mNumVertices = 24;
mesh->mVertices = new aiVector3D[ 24 ];
::memcpy( &mesh->mVertices->x, &VertComponents[ 0 ], sizeof( float ) * 24 * 3 );
mesh->mNumFaces = 6;
mesh->mFaces = new aiFace[ mesh->mNumFaces ];
mesh->mFaces[ 0 ].mNumIndices = 4;
mesh->mFaces[ 0 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 0 ].mIndices[ 0 ] = 0;
mesh->mFaces[ 0 ].mIndices[ 1 ] = 1;
mesh->mFaces[ 0 ].mIndices[ 2 ] = 2;
mesh->mFaces[ 0 ].mIndices[ 3 ] = 3;
mesh->mFaces[ 1 ].mNumIndices = 4;
mesh->mFaces[ 1 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 1 ].mIndices[ 0 ] = 4;
mesh->mFaces[ 1 ].mIndices[ 1 ] = 5;
mesh->mFaces[ 1 ].mIndices[ 2 ] = 6;
mesh->mFaces[ 1 ].mIndices[ 3 ] = 7;
mesh->mFaces[ 2 ].mNumIndices = 4;
mesh->mFaces[ 2 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 2 ].mIndices[ 0 ] = 8;
mesh->mFaces[ 2 ].mIndices[ 1 ] = 9;
mesh->mFaces[ 2 ].mIndices[ 2 ] = 10;
mesh->mFaces[ 2 ].mIndices[ 3 ] = 11;
mesh->mFaces[ 3 ].mNumIndices = 4;
mesh->mFaces[ 3 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 3 ].mIndices[ 0 ] = 12;
mesh->mFaces[ 3 ].mIndices[ 1 ] = 13;
mesh->mFaces[ 3 ].mIndices[ 2 ] = 14;
mesh->mFaces[ 3 ].mIndices[ 3 ] = 15;
mesh->mFaces[ 4 ].mNumIndices = 4;
mesh->mFaces[ 4 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 4 ].mIndices[ 0 ] = 16;
mesh->mFaces[ 4 ].mIndices[ 1 ] = 17;
mesh->mFaces[ 4 ].mIndices[ 2 ] = 18;
mesh->mFaces[ 4 ].mIndices[ 3 ] = 19;
mesh->mFaces[ 5 ].mNumIndices = 4;
mesh->mFaces[ 5 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 5 ].mIndices[ 0 ] = 20;
mesh->mFaces[ 5 ].mIndices[ 1 ] = 21;
mesh->mFaces[ 5 ].mIndices[ 2 ] = 22;
mesh->mFaces[ 5 ].mIndices[ 3 ] = 23;
expScene->mMeshes[ 0 ] = mesh;
expScene->mNumMaterials = 1;
expScene->mMaterials = new aiMaterial*[ expScene->mNumMaterials ];
return expScene;
}
virtual bool importerTest() {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
#ifndef ASSIMP_BUILD_NO_EXPORT
virtual bool exporterTest() {
::Assimp::Importer importer;
::Assimp::Exporter exporter;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.obj" ) );
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "objnomtl", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_nomtl_test.obj" ) );
return true;
}
#endif // ASSIMP_BUILD_NO_EXPORT
protected:
::Assimp::Importer *m_im;
aiScene *m_expectedScene;
};
TEST_F( utObjImportExport, importObjFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F( utObjImportExport, exportObjFromFileTest ) {
EXPECT_TRUE( exporterTest() );
}
#endif // ASSIMP_BUILD_NO_EXPORT
TEST_F( utObjImportExport, obj_import_test ) {
const aiScene *scene = m_im->ReadFileFromMemory( (void*) ObjModel.c_str(), ObjModel.size(), 0 );
aiScene *expected = createScene();
EXPECT_NE( nullptr, scene );
SceneDiffer differ;
EXPECT_TRUE( differ.isEqual( expected, scene ) );
differ.showReport();
m_im->FreeScene();
for(unsigned int i = 0; i < expected->mNumMeshes; ++i)
{
delete expected->mMeshes[i];
}
delete[] expected->mMeshes;
expected->mMeshes = nullptr;
delete[] expected->mMaterials;
expected->mMaterials = nullptr;
delete expected;
}
TEST_F( utObjImportExport, issue1111_no_mat_name_Test ) {
const aiScene *scene = m_im->ReadFileFromMemory( ( void* ) ObjModel_Issue1111.c_str(), ObjModel_Issue1111.size(), 0 );
EXPECT_NE( nullptr, scene );
}
TEST_F( utObjImportExport, issue809_vertex_color_Test ) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors.obj", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
#ifndef ASSIMP_BUILD_NO_EXPORT
::Assimp::Exporter exporter;
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/test.obj" ) );
#endif // ASSIMP_BUILD_NO_EXPORT
}
TEST_F( utObjImportExport, issue1923_vertex_color_Test ) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors_uni.obj", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
scene = importer.GetOrphanedScene();
#ifndef ASSIMP_BUILD_NO_EXPORT
::Assimp::Exporter exporter;
const aiExportDataBlob* blob = exporter.ExportToBlob( scene, "obj");
EXPECT_NE( nullptr, blob );
const aiScene *sceneReImport = importer.ReadFileFromMemory( blob->data, blob->size, aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
SceneDiffer differ;
EXPECT_TRUE( differ.isEqual( scene, sceneReImport ) );
#endif // ASSIMP_BUILD_NO_EXPORT
delete scene;
}
TEST_F( utObjImportExport, issue1453_segfault ) {
static const std::string ObjModel =
"v 0.0 0.0 0.0\n"
"v 0.0 0.0 1.0\n"
"v 0.0 1.0 0.0\n"
"v 0.0 1.0 1.0\n"
"v 1.0 0.0 0.0\n"
"v 1.0 0.0 1.0\n"
"v 1.0 1.0 0.0\n"
"v 1.0 1.0 1.0\nB";
Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory( ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure );
EXPECT_EQ( nullptr, scene );
}
TEST_F(utObjImportExport, relative_indices_Test) {
static const std::string ObjModel =
"v -0.500000 0.000000 0.400000\n"
"v -0.500000 0.000000 -0.800000\n"
"v -0.500000 1.000000 -0.800000\n"
"v -0.500000 1.000000 0.400000\n"
"f -4 -3 -2 -1\nB";
Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mNumMeshes, 1U);
const aiMesh *mesh = scene->mMeshes[0];
EXPECT_EQ(mesh->mNumVertices, 4U);
EXPECT_EQ(mesh->mNumFaces, 1U);
const aiFace face = mesh->mFaces[0];
EXPECT_EQ(face.mNumIndices, 4U);
for (unsigned int i = 0; i < face.mNumIndices; ++i)
{
EXPECT_EQ(face.mIndices[i], i);
}
}
TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
static const std::string ObjModel =
"v -0.500000 0.000000 0.400000 0.50000\n"
"v -0.500000 0.000000 -0.800000 1.00000\n"
"v 0.500000 1.000000 -0.800000 0.5000\n"
"f 1 2 3\nB";
Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mNumMeshes, 1U);
const aiMesh *mesh = scene->mMeshes[0];
EXPECT_EQ(mesh->mNumVertices, 3U);
EXPECT_EQ(mesh->mNumFaces, 1U);
const aiFace face = mesh->mFaces[0];
EXPECT_EQ(face.mNumIndices, 3U);
const aiVector3D vertice = mesh->mVertices[0];
EXPECT_EQ(vertice.x, -1.0f);
EXPECT_EQ(vertice.y, 0.0f);
EXPECT_EQ(vertice.z, 0.8f);
}
TEST_F(utObjImportExport, homogeneous_coordinates_divide_by_zero_Test) {
static const std::string ObjModel =
"v -0.500000 0.000000 0.400000 0.\n"
"v -0.500000 0.000000 -0.800000 1.00000\n"
"v 0.500000 1.000000 -0.800000 0.5000\n"
"f 1 2 3\nB";
Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure);
EXPECT_EQ(nullptr, scene);
}
TEST_F(utObjImportExport, 0based_array_Test) {
static const std::string ObjModel =
"v -0.500000 0.000000 0.400000\n"
"v -0.500000 0.000000 -0.800000\n"
"v -0.500000 1.000000 -0.800000\n"
"f 0 1 2\nB";
Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), 0);
EXPECT_EQ(nullptr, scene);
}
TEST_F( utObjImportExport, mtllib_after_g ) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_mtllib_after_g.obj", aiProcess_ValidateDataStructure );
ASSERT_NE( nullptr, scene );
EXPECT_EQ(scene->mNumMeshes, 1U);
const aiMesh *mesh = scene->mMeshes[0];
const aiMaterial* mat = scene->mMaterials[mesh->mMaterialIndex];
aiString name;
ASSERT_EQ(aiReturn_SUCCESS, mat->Get(AI_MATKEY_NAME, name));
EXPECT_STREQ("MyMaterial", name.C_Str());
}
TEST_F(utObjImportExport, import_point_cloud) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/point_cloud.obj", 0 );
ASSERT_NE(nullptr, scene);
}

View file

@ -0,0 +1,118 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "ObjTools.h"
#include "ObjFileParser.h"
using namespace ::Assimp;
class utObjTools : public ::testing::Test {
// empty
};
class TestObjFileParser : public ObjFileParser {
public:
TestObjFileParser() : ObjFileParser(){
// empty
}
~TestObjFileParser() {
// empty
}
void testCopyNextWord( char *pBuffer, size_t length ) {
copyNextWord( pBuffer, length );
}
size_t testGetNumComponentsInDataDefinition() {
return getNumComponentsInDataDefinition();
}
};
TEST_F( utObjTools, skipDataLine_OneLine_Success ) {
std::vector<char> buffer;
std::string data( "v -0.5 -0.5 0.5\nend" );
buffer.resize( data.size() );
::memcpy( &buffer[ 0 ], &data[ 0 ], data.size() );
std::vector<char>::iterator itBegin( buffer.begin() ), itEnd( buffer.end() );
unsigned int line = 0;
std::vector<char>::iterator current = skipLine<std::vector<char>::iterator>( itBegin, itEnd, line );
EXPECT_EQ( 'e', *current );
}
TEST_F( utObjTools, skipDataLine_TwoLines_Success ) {
TestObjFileParser test_parser;
std::string data( "vn -2.061493116917992e-15 -0.9009688496589661 \\\n-0.4338837265968323" );
std::vector<char> buffer;
buffer.resize( data.size() );
::memcpy( &buffer[ 0 ], &data[ 0 ], data.size() );
test_parser.setBuffer( buffer );
static const size_t Size = 4096UL;
char data_buffer[ Size ];
test_parser.testCopyNextWord( data_buffer, Size );
EXPECT_EQ( 0, strncmp( data_buffer, "vn", 2 ) );
test_parser.testCopyNextWord( data_buffer, Size );
EXPECT_EQ( data_buffer[0], '-' );
test_parser.testCopyNextWord( data_buffer, Size );
EXPECT_EQ( data_buffer[0], '-' );
test_parser.testCopyNextWord( data_buffer, Size );
EXPECT_EQ( data_buffer[ 0 ], '-' );
}
TEST_F( utObjTools, countComponents_TwoLines_Success ) {
TestObjFileParser test_parser;
std::string data( "-2.061493116917992e-15 -0.9009688496589661 \\\n-0.4338837265968323" );
std::vector<char> buffer;
buffer.resize( data.size() + 1 );
::memcpy( &buffer[ 0 ], &data[ 0 ], data.size() );
buffer[ buffer.size() - 1 ] = '\0';
test_parser.setBuffer( buffer );
size_t numComps = test_parser.testGetNumComponentsInDataDefinition();
EXPECT_EQ( 3U, numComps );
}

View file

@ -0,0 +1,76 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
using namespace Assimp;
class utOpenGEXImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0 );
return nullptr != scene;
}
};
TEST_F( utOpenGEXImportExport, importLWSFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utOpenGEXImportExport, Importissue1262_NoCrash ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OpenGEX/light_issue1262.ogex", 0 );
EXPECT_NE( nullptr, scene );
}
TEST_F(utOpenGEXImportExport, Importissue1340_EmptyCameraObject) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/empty_camera.ogex", 0);
EXPECT_NE(nullptr, scene);
}

View file

@ -0,0 +1,180 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/scene.h>
#include "AbstractImportExportBase.h"
#include <assimp/postprocess.h>
using namespace ::Assimp;
class utPLYImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure);
EXPECT_EQ( 1u, scene->mNumMeshes );
EXPECT_NE( nullptr, scene->mMeshes[0] );
EXPECT_EQ( 8u, scene->mMeshes[0]->mNumVertices );
EXPECT_EQ( 6u, scene->mMeshes[0]->mNumFaces );
return (nullptr != scene);
}
#ifndef ASSIMP_BUILD_NO_EXPORT
virtual bool exporterTest() {
Importer importer;
Exporter exporter;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "ply", ASSIMP_TEST_MODELS_DIR "/PLY/cube_test.ply"));
return true;
}
#endif // ASSIMP_BUILD_NO_EXPORT
};
TEST_F( utPLYImportExport, importTest_Success ) {
EXPECT_TRUE( importerTest() );
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F(utPLYImportExport, exportTest_Success ) {
EXPECT_TRUE(exporterTest());
}
#endif // ASSIMP_BUILD_NO_EXPORT
//Test issue 1623, crash when loading two PLY files in a row
TEST_F(utPLYImportExport, importerMultipleTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_NE(nullptr, scene->mMeshes[0]);
EXPECT_EQ(6u, scene->mMeshes[0]->mNumFaces);
}
TEST_F(utPLYImportExport, importPLYwithUV) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube_uv.ply", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_NE(nullptr, scene->mMeshes[0]);
//This test model is using n-gons, so 6 faces instead of 12 tris
EXPECT_EQ(6u, scene->mMeshes[0]->mNumFaces);
EXPECT_EQ(aiPrimitiveType_POLYGON, scene->mMeshes[0]->mPrimitiveTypes);
EXPECT_EQ(true, scene->mMeshes[0]->HasTextureCoords(0));
}
TEST_F(utPLYImportExport, importBinaryPLY) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube_binary.ply", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_NE(nullptr, scene->mMeshes[0]);
//This test model is double sided, so 12 faces instead of 6
EXPECT_EQ(12u, scene->mMeshes[0]->mNumFaces);
}
TEST_F( utPLYImportExport, vertexColorTest ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/PLY/float-color.ply", aiProcess_ValidateDataStructure);
EXPECT_NE( nullptr, scene );
EXPECT_EQ(1u, scene->mMeshes[0]->mNumFaces);
EXPECT_EQ(aiPrimitiveType_TRIANGLE, scene->mMeshes[0]->mPrimitiveTypes);
EXPECT_EQ(true, scene->mMeshes[0]->HasVertexColors(0));
auto first_face = scene->mMeshes[0]->mFaces[0];
EXPECT_EQ(3u, first_face.mNumIndices);
EXPECT_EQ(0u, first_face.mIndices[0]);
EXPECT_EQ(1u, first_face.mIndices[1]);
EXPECT_EQ(2u, first_face.mIndices[2]);
}
// Test issue #623, PLY importer should not automatically create faces
TEST_F(utPLYImportExport, pointcloudTest) {
Assimp::Importer importer;
//Could not use aiProcess_ValidateDataStructure since it's missing faces.
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/issue623.ply", 0);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(1u, scene->mNumMeshes);
EXPECT_NE(nullptr, scene->mMeshes[0]);
EXPECT_EQ(24u, scene->mMeshes[0]->mNumVertices);
EXPECT_EQ(aiPrimitiveType::aiPrimitiveType_POINT, scene->mMeshes[0]->mPrimitiveTypes);
EXPECT_EQ(0u, scene->mMeshes[0]->mNumFaces);
}
static const char *test_file =
"ply\n"
"format ascii 1.0\n"
"element vertex 4\n"
"property float x\n"
"property float y\n"
"property float z\n"
"property uchar red\n"
"property uchar green\n"
"property uchar blue\n"
"property float nx\n"
"property float ny\n"
"property float nz\n"
"end_header\n"
"0.0 0.0 0.0 255 255 255 0.0 1.0 0.0\n"
"0.0 0.0 1.0 255 0 255 0.0 0.0 1.0\n"
"0.0 1.0 0.0 255 255 0 1.0 0.0 0.0\n"
"0.0 1.0 1.0 0 255 255 1.0 1.0 0.0\n";
TEST_F( utPLYImportExport, parseErrorTest ) {
Assimp::Importer importer;
//Could not use aiProcess_ValidateDataStructure since it's missing faces.
const aiScene *scene = importer.ReadFileFromMemory( test_file, strlen( test_file ), 0);
EXPECT_NE( nullptr, scene );
}

View file

@ -0,0 +1,63 @@
/*
---------------------------------------------------------------------------
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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include "MMDImporter.h"
#include <assimp/Importer.hpp>
using namespace ::Assimp;
class utPMXImporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
/*const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/../models-nonbsd/MMD/Alicia_blade.pmx", aiProcess_ValidateDataStructure );
return nullptr != scene;*/
return true;
}
};
TEST_F( utPMXImporter, importTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,159 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <PretransformVertices.h>
using namespace std;
using namespace Assimp;
class PretransformVerticesTest : public ::testing::Test {
public:
virtual void SetUp();
virtual void TearDown();
protected:
aiScene* scene;
PretransformVertices* process;
};
// ------------------------------------------------------------------------------------------------
void AddNodes(unsigned int num, aiNode* father, unsigned int depth)
{
father->mChildren = new aiNode*[father->mNumChildren = 5];
for (unsigned int i = 0; i < 5; ++i) {
aiNode* nd = father->mChildren[i] = new aiNode();
nd->mName.length = sprintf(nd->mName.data,"%i%i",depth,i);
// spawn two meshes
nd->mMeshes = new unsigned int[nd->mNumMeshes = 2];
nd->mMeshes[0] = num*5+i;
nd->mMeshes[1] = 24-(num*5+i); // mesh 12 is special ... it references the same mesh twice
// setup an unique transformation matrix
nd->mTransformation.a1 = num*5.f+i + 1;
}
if (depth > 1) {
for (unsigned int i = 0; i < 5; ++i)
AddNodes(i, father->mChildren[i],depth-1);
}
}
// ------------------------------------------------------------------------------------------------
void PretransformVerticesTest::SetUp()
{
scene = new aiScene();
// add 5 empty materials
scene->mMaterials = new aiMaterial*[scene->mNumMaterials = 5];
for (unsigned int i = 0; i < 5;++i) {
scene->mMaterials[i] = new aiMaterial();
}
// add 25 test meshes
scene->mMeshes = new aiMesh*[scene->mNumMeshes = 25];
for ( unsigned int i = 0; i < 25; ++i) {
aiMesh* mesh = scene->mMeshes[ i ] = new aiMesh();
mesh->mPrimitiveTypes = aiPrimitiveType_POINT;
mesh->mFaces = new aiFace[ mesh->mNumFaces = 10+i ];
mesh->mVertices = new aiVector3D[mesh->mNumVertices = mesh->mNumFaces];
for (unsigned int a = 0; a < mesh->mNumFaces; ++a ) {
aiFace& f = mesh->mFaces[ a ];
f.mIndices = new unsigned int [ f.mNumIndices = 1 ];
f.mIndices[0] = a*3;
mesh->mVertices[a] = aiVector3D((float)i,(float)a,0.f);
}
mesh->mMaterialIndex = i%5;
if (i % 2) {
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
for ( unsigned int normalIdx=0; normalIdx<mesh->mNumVertices; ++normalIdx ) {
mesh->mNormals[ normalIdx ].x = 1.0f;
mesh->mNormals[ normalIdx ].y = 1.0f;
mesh->mNormals[ normalIdx ].z = 1.0f;
mesh->mNormals[ normalIdx ].Normalize();
}
}
}
// construct some nodes (1+25)
scene->mRootNode = new aiNode();
scene->mRootNode->mName.Set("Root");
AddNodes(0,scene->mRootNode,2);
process = new PretransformVertices();
}
// ------------------------------------------------------------------------------------------------
void PretransformVerticesTest::TearDown()
{
delete scene;
delete process;
}
// ------------------------------------------------------------------------------------------------
TEST_F(PretransformVerticesTest, testProcessCollapseHierarchy)
{
process->KeepHierarchy(false);
process->Execute(scene);
EXPECT_EQ(5U, scene->mNumMaterials);
EXPECT_EQ(10U, scene->mNumMeshes); // every second mesh has normals
}
// ------------------------------------------------------------------------------------------------
TEST_F(PretransformVerticesTest, testProcessKeepHierarchy)
{
process->KeepHierarchy(true);
process->Execute(scene);
EXPECT_EQ(5U, scene->mNumMaterials);
EXPECT_EQ(49U, scene->mNumMeshes); // see note on mesh 12 above
}

View file

@ -0,0 +1,77 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "UTLogStream.h"
#include <assimp/Profiler.h>
#include <assimp/DefaultLogger.hpp>
using namespace ::Assimp;
using namespace ::Assimp::Profiling;
class utProfiler : public ::testing::Test {
public:
LogStream *m_stream;
/*virtual void SetUp() {
m_stream = new UTLogStream;
DefaultLogger::create();
DefaultLogger::get()->attachStream( m_stream );
}
virtual void TearDown() {
DefaultLogger::get()->detatchStream( m_stream );
m_stream = nullptr;
}*/
};
TEST_F( utProfiler, addRegion_success ) {
Profiler myProfiler;
myProfiler.BeginRegion( "t1" );
for ( int i=0; i<10; i++ ) {
volatile int j=0;
j++;
}
myProfiler.EndRegion( "t1" );
//UTLogStream *stream( (UTLogStream*) m_stream );
//EXPECT_FALSE( stream->m_messages.empty() );
}

View file

@ -0,0 +1,63 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utQ3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/Q3D/earth.q3o", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F(utQ3DImportExport, importTest) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,98 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/RemoveComments.h>
using namespace std;
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
TEST(RemoveCommentsTest, testSingleLineComments)
{
const char* szTest = "int i = 0; \n"
"if (4 == //)\n"
"\ttrue) { // do something here \n"
"\t// hello ... and bye //\n";
const size_t len( ::strlen( szTest ) + 1 );
char* szTest2 = new char[ len ];
::strncpy( szTest2, szTest, len );
const char* szTestResult = "int i = 0; \n"
"if (4 == \n"
"\ttrue) { \n"
"\t \n";
CommentRemover::RemoveLineComments("//",szTest2,' ');
EXPECT_STREQ(szTestResult, szTest2);
delete[] szTest2;
}
// ------------------------------------------------------------------------------------------------
TEST(RemoveCommentsTest, testMultiLineComments)
{
const char* szTest =
"/* comment to be removed */\n"
"valid text /* \n "
" comment across multiple lines */"
" / * Incomplete comment */ /* /* multiple comments */ */";
const char* szTestResult =
" \n"
"valid text "
" "
" / * Incomplete comment */ */";
const size_t len( ::strlen( szTest ) + 1 );
char* szTest2 = new char[ len ];
::strncpy( szTest2, szTest, len );
CommentRemover::RemoveMultiLineComments("/*","*/",szTest2,' ');
EXPECT_STREQ(szTestResult, szTest2);
delete[] szTest2;
}

View file

@ -0,0 +1,232 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <RemoveVCProcess.h>
#include <MaterialSystem.h>
using namespace std;
using namespace Assimp;
class RemoveVCProcessTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
RemoveVCProcess* piProcess;
aiScene* pScene;
};
// ------------------------------------------------------------------------------------------------
void RemoveVCProcessTest::SetUp()
{
// construct the process
piProcess = new RemoveVCProcess();
pScene = new aiScene();
// fill the scene ..
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes = 2];
pScene->mMeshes[0] = new aiMesh();
pScene->mMeshes[1] = new aiMesh();
pScene->mMeshes[0]->mNumVertices = 120;
pScene->mMeshes[0]->mVertices = new aiVector3D[120];
pScene->mMeshes[0]->mNormals = new aiVector3D[120];
pScene->mMeshes[0]->mTextureCoords[0] = new aiVector3D[120];
pScene->mMeshes[0]->mTextureCoords[1] = new aiVector3D[120];
pScene->mMeshes[0]->mTextureCoords[2] = new aiVector3D[120];
pScene->mMeshes[0]->mTextureCoords[3] = new aiVector3D[120];
pScene->mMeshes[1]->mNumVertices = 120;
pScene->mMeshes[1]->mVertices = new aiVector3D[120];
pScene->mAnimations = new aiAnimation*[pScene->mNumAnimations = 2];
pScene->mAnimations[0] = new aiAnimation();
pScene->mAnimations[1] = new aiAnimation();
pScene->mTextures = new aiTexture*[pScene->mNumTextures = 2];
pScene->mTextures[0] = new aiTexture();
pScene->mTextures[1] = new aiTexture();
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = 2];
pScene->mMaterials[0] = new aiMaterial();
pScene->mMaterials[1] = new aiMaterial();
pScene->mLights = new aiLight*[pScene->mNumLights = 2];
pScene->mLights[0] = new aiLight();
pScene->mLights[1] = new aiLight();
pScene->mCameras = new aiCamera*[pScene->mNumCameras = 2];
pScene->mCameras[0] = new aiCamera();
pScene->mCameras[1] = new aiCamera();
// COMPILE TEST: aiMaterial may no add any extra members,
// so we don't need a virtual destructor
char check[sizeof(aiMaterial) == sizeof(aiMaterial) ? 10 : -1];
check[0] = 0;
// to remove compiler warning
EXPECT_EQ( 0, check[0] );
}
// ------------------------------------------------------------------------------------------------
void RemoveVCProcessTest::TearDown()
{
delete pScene;
delete piProcess;
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testMeshRemove)
{
piProcess->SetDeleteFlags(aiComponent_MESHES);
piProcess->Execute(pScene);
EXPECT_TRUE(NULL == pScene->mMeshes);
EXPECT_EQ(0U, pScene->mNumMeshes);
EXPECT_TRUE(pScene->mFlags == AI_SCENE_FLAGS_INCOMPLETE);
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testAnimRemove)
{
piProcess->SetDeleteFlags(aiComponent_ANIMATIONS);
piProcess->Execute(pScene);
EXPECT_TRUE(NULL == pScene->mAnimations);
EXPECT_EQ(0U, pScene->mNumAnimations);
EXPECT_EQ(0U, pScene->mFlags);
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testMaterialRemove)
{
piProcess->SetDeleteFlags(aiComponent_MATERIALS);
piProcess->Execute(pScene);
// there should be one default material now ...
EXPECT_TRUE(1 == pScene->mNumMaterials &&
pScene->mMeshes[0]->mMaterialIndex == 0 &&
pScene->mMeshes[1]->mMaterialIndex == 0);
EXPECT_EQ(0U, pScene->mFlags);
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testTextureRemove)
{
piProcess->SetDeleteFlags(aiComponent_TEXTURES);
piProcess->Execute(pScene);
EXPECT_TRUE(NULL == pScene->mTextures);
EXPECT_EQ(0U, pScene->mNumTextures);
EXPECT_EQ(0U, pScene->mFlags);
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testCameraRemove)
{
piProcess->SetDeleteFlags(aiComponent_CAMERAS);
piProcess->Execute(pScene);
EXPECT_TRUE(NULL == pScene->mCameras);
EXPECT_EQ(0U, pScene->mNumCameras);
EXPECT_EQ(0U, pScene->mFlags);
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testLightRemove)
{
piProcess->SetDeleteFlags(aiComponent_LIGHTS);
piProcess->Execute(pScene);
EXPECT_TRUE(NULL == pScene->mLights);
EXPECT_EQ(0U, pScene->mNumLights);
EXPECT_EQ(0U, pScene->mFlags);
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testMeshComponentsRemoveA)
{
piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_TEXCOORDSn(2) | aiComponent_TEXCOORDSn(3));
piProcess->Execute(pScene);
EXPECT_TRUE(pScene->mMeshes[0]->mTextureCoords[0] &&
!pScene->mMeshes[0]->mTextureCoords[1] &&
!pScene->mMeshes[0]->mTextureCoords[2] &&
!pScene->mMeshes[0]->mTextureCoords[3]);
EXPECT_EQ(0U, pScene->mFlags);
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testMeshComponentsRemoveB)
{
piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_NORMALS);
piProcess->Execute(pScene);
EXPECT_TRUE(pScene->mMeshes[0]->mTextureCoords[0] &&
pScene->mMeshes[0]->mTextureCoords[1] &&
pScene->mMeshes[0]->mTextureCoords[2] && // shift forward ...
!pScene->mMeshes[0]->mTextureCoords[3] &&
!pScene->mMeshes[0]->mNormals);
EXPECT_EQ(0U, pScene->mFlags);
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testRemoveEverything)
{
piProcess->SetDeleteFlags(aiComponent_LIGHTS | aiComponent_ANIMATIONS |
aiComponent_MATERIALS | aiComponent_MESHES | aiComponent_CAMERAS | aiComponent_TEXTURES);
piProcess->Execute(pScene);
EXPECT_EQ(0U, pScene->mNumAnimations);
EXPECT_EQ(0U, pScene->mNumCameras);
EXPECT_EQ(0U, pScene->mNumLights);
EXPECT_EQ(0U, pScene->mNumMeshes);
EXPECT_EQ(0U, pScene->mNumTextures);
// Only the default material should remain.
EXPECT_EQ(1U, pScene->mNumMaterials);
}

View file

@ -0,0 +1,191 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <RemoveRedundantMaterials.h>
#include <MaterialSystem.h>
using namespace std;
using namespace Assimp;
class RemoveRedundantMatsTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
RemoveRedundantMatsProcess* piProcess;
aiScene* pcScene1;
};
// ------------------------------------------------------------------------------------------------
aiMaterial* getUniqueMaterial1()
{
// setup an unique name for each material - this shouldn't care
aiString mTemp;
mTemp.Set("UniqueMat1");
aiMaterial* pcMat = new aiMaterial();
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
float f = 2.0f;
pcMat->AddProperty<float>(&f, 1, AI_MATKEY_BUMPSCALING);
pcMat->AddProperty<float>(&f, 1, AI_MATKEY_SHININESS_STRENGTH);
return pcMat;
}
// ------------------------------------------------------------------------------------------------
aiMaterial* getUniqueMaterial2()
{
// setup an unique name for each material - this shouldn't care
aiString mTemp;
mTemp.Set("Unique Mat2");
aiMaterial* pcMat = new aiMaterial();
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
float f = 4.0f;int i = 1;
pcMat->AddProperty<float>(&f, 1, AI_MATKEY_BUMPSCALING);
pcMat->AddProperty<int>(&i, 1, AI_MATKEY_ENABLE_WIREFRAME);
return pcMat;
}
// ------------------------------------------------------------------------------------------------
aiMaterial* getUniqueMaterial3()
{
// setup an unique name for each material - this shouldn't care
aiString mTemp;
mTemp.Set("Complex material name");
aiMaterial* pcMat = new aiMaterial();
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
return pcMat;
}
// ------------------------------------------------------------------------------------------------
void RemoveRedundantMatsTest::SetUp()
{
// construct the process
piProcess = new RemoveRedundantMatsProcess();
// create a scene with 5 materials (2 is a duplicate of 0, 3 of 1)
pcScene1 = new aiScene();
pcScene1->mNumMaterials = 5;
pcScene1->mMaterials = new aiMaterial*[5];
pcScene1->mMaterials[0] = getUniqueMaterial1();
pcScene1->mMaterials[1] = getUniqueMaterial2();
pcScene1->mMaterials[4] = getUniqueMaterial3();
// all materials must be referenced
pcScene1->mNumMeshes = 5;
pcScene1->mMeshes = new aiMesh*[5];
for (unsigned int i = 0; i < 5;++i) {
pcScene1->mMeshes[i] = new aiMesh();
pcScene1->mMeshes[i]->mMaterialIndex = i;
}
// setup an unique name for each material - this shouldn't care
aiString mTemp;
mTemp.length = 1;
mTemp.data[0] = 48;
mTemp.data[1] = 0;
aiMaterial* pcMat;
pcScene1->mMaterials[2] = pcMat = new aiMaterial();
aiMaterial::CopyPropertyList(pcMat,(const aiMaterial*)pcScene1->mMaterials[0]);
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
mTemp.data[0]++;
pcScene1->mMaterials[3] = pcMat = new aiMaterial();
aiMaterial::CopyPropertyList(pcMat,(const aiMaterial*)pcScene1->mMaterials[1]);
pcMat->AddProperty(&mTemp,AI_MATKEY_NAME);
mTemp.data[0]++;
}
// ------------------------------------------------------------------------------------------------
void RemoveRedundantMatsTest::TearDown()
{
delete piProcess;
delete pcScene1;
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveRedundantMatsTest, testRedundantMaterials)
{
piProcess->SetFixedMaterialsString();
piProcess->Execute(pcScene1);
EXPECT_EQ(3U, pcScene1->mNumMaterials);
EXPECT_TRUE(0 != pcScene1->mMaterials &&
0 != pcScene1->mMaterials[0] &&
0 != pcScene1->mMaterials[1] &&
0 != pcScene1->mMaterials[2]);
aiString sName;
EXPECT_EQ(AI_SUCCESS, aiGetMaterialString(pcScene1->mMaterials[2],AI_MATKEY_NAME,&sName));
EXPECT_STREQ("Complex material name", sName.data);
}
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveRedundantMatsTest, testRedundantMaterialsWithExcludeList)
{
piProcess->SetFixedMaterialsString("\'Unique Mat2\'\t\'Complex material name\' and_another_one_which_we_wont_use");
piProcess->Execute(pcScene1);
EXPECT_EQ(4U, pcScene1->mNumMaterials);
EXPECT_TRUE(0 != pcScene1->mMaterials &&
0 != pcScene1->mMaterials[0] &&
0 != pcScene1->mMaterials[1] &&
0 != pcScene1->mMaterials[2] &&
0 != pcScene1->mMaterials[3]);
aiString sName;
EXPECT_EQ(AI_SUCCESS, aiGetMaterialString(pcScene1->mMaterials[3],AI_MATKEY_NAME,&sName));
EXPECT_STREQ("Complex material name", sName.data);
}

View file

@ -0,0 +1,77 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "code/RemoveVCProcess.h"
#include <assimp/mesh.h>
#include <assimp/scene.h>
using namespace ::Assimp;
class utRevmoveVCProcess : public ::testing::Test {
// empty
};
TEST_F( utRevmoveVCProcess, createTest ) {
bool ok = true;
try {
RemoveVCProcess *process = new RemoveVCProcess;
delete process;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utRevmoveVCProcess, issue1266_ProcessMeshTest_NoCrash ) {
aiScene *scene = new aiScene;
scene->mNumMeshes = 1;
scene->mMeshes = new aiMesh*[ 1 ];
aiMesh *mesh = new aiMesh;
mesh->mNumVertices = 1;
mesh->mColors[ 0 ] = new aiColor4D[ 2 ];
scene->mMeshes[ 0 ] = mesh;
std::unique_ptr<RemoveVCProcess> process(new RemoveVCProcess);
process->Execute( scene );
delete scene;
}

View file

@ -0,0 +1,73 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include "AbstractImportExportBase.h"
using namespace ::Assimp;
class utSIBImporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SIB/heffalump.sib", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utSIBImporter, createTest ) {
bool ok( true );
try {
SIBImporter myImporter;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utSIBImporter, importTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,80 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SMDLoader.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include "AbstractImportExportBase.h"
using namespace ::Assimp;
class utSMDImporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/triangle.smd", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utSMDImporter, createTest ) {
bool ok( true );
try {
SMDImporter myImporter;
}
catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utSMDImporter, importTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utSMDImporter, issue_899_Texture_garbage_at_end_of_string_Test ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/holy_grailref.smd", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
}

View file

@ -0,0 +1,168 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include <assimp/Exporter.hpp>
#include <assimp/scene.h>
#include <vector>
using namespace Assimp;
class utSTLImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utSTLImporterExporter, importSTLFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F(utSTLImporterExporter, test_multiple) {
// import same file twice, each with its own importer
// must work both times and not crash
Assimp::Importer importer1;
const aiScene *scene1 = importer1.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure );
EXPECT_NE(nullptr, scene1);
Assimp::Importer importer2;
const aiScene *scene2 = importer2.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure );
EXPECT_NE(nullptr, scene2);
}
TEST_F( utSTLImporterExporter, test_with_two_solids ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_two_solids.stl", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
}
TEST_F(utSTLImporterExporter, test_with_empty_solid) {
Assimp::Importer importer;
//STL File with empty mesh. We should still be able to import other meshes in this file. ValidateDataStructure should fail.
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_empty_solid.stl", 0);
EXPECT_NE(nullptr, scene);
const aiScene *scene2 = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_empty_solid.stl", aiProcess_ValidateDataStructure);
EXPECT_EQ(nullptr, scene2);
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F(utSTLImporterExporter, exporterTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure);
Assimp::Exporter mAiExporter;
mAiExporter.Export( scene, "stl", "spiderExport.stl" );
const aiScene *scene2 = importer.ReadFile("spiderExport.stl", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene2);
}
TEST_F(utSTLImporterExporter, test_export_pointclouds) {
struct XYZ {
float x, y, z;
};
std::vector<XYZ> points;
for (size_t i = 0; i < 10; ++i) {
XYZ current;
current.x = static_cast<float>(i);
current.y = static_cast<float>(i);
current.z = static_cast<float>(i);
points.push_back(current);
}
aiScene scene;
scene.mRootNode = new aiNode();
scene.mMeshes = new aiMesh*[1];
scene.mMeshes[0] = nullptr;
scene.mNumMeshes = 1;
scene.mMaterials = new aiMaterial*[1];
scene.mMaterials[0] = nullptr;
scene.mNumMaterials = 1;
scene.mMaterials[0] = new aiMaterial();
scene.mMeshes[0] = new aiMesh();
scene.mMeshes[0]->mMaterialIndex = 0;
scene.mRootNode->mMeshes = new unsigned int[1];
scene.mRootNode->mMeshes[0] = 0;
scene.mRootNode->mNumMeshes = 1;
auto pMesh = scene.mMeshes[0];
long numValidPoints = points.size();
pMesh->mVertices = new aiVector3D[numValidPoints];
pMesh->mNumVertices = numValidPoints;
int i = 0;
for (XYZ &p : points) {
pMesh->mVertices[i] = aiVector3D(p.x, p.y, p.z);
++i;
}
Assimp::Exporter mAiExporter;
ExportProperties *properties = new ExportProperties;
properties->SetPropertyBool(AI_CONFIG_EXPORT_POINT_CLOUDS, true);
mAiExporter.Export(&scene, "stl", "testExport.stl", 0, properties );
delete properties;
}
#endif

View file

@ -0,0 +1,86 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "ScaleProcess.h"
#include "TestModelFactory.h"
namespace Assimp {
namespace UnitTest {
class utScaleProcess : public ::testing::Test {
// empty
};
TEST_F( utScaleProcess, createTest ) {
bool ok = true;
try {
ScaleProcess process;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utScaleProcess, accessScaleTest ) {
ScaleProcess process;
EXPECT_FLOAT_EQ( AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT, process.getScale() );
process.setScale( 2.0f );
EXPECT_FLOAT_EQ( 2.0f, process.getScale() );
}
TEST_F( utScaleProcess, rescaleModelTest ) {
float opacity;
aiScene *testScene = TestModelFacttory::createDefaultTestModel( opacity );
ai_real v1 = testScene->mRootNode->mTransformation.a1;
ScaleProcess process;
process.setScale( 10.0f );
process.Execute( testScene );
ai_real v2 = testScene->mRootNode->mTransformation.a1;
const ai_real scale = v2 / v1;
EXPECT_FLOAT_EQ( scale, 10.0f );
TestModelFacttory::releaseDefaultTestModel( &testScene );
}
} // Namespace UnitTest
} // Namespace Assimp

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
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 <assimp/scene.h>
using namespace ::Assimp;
class utScene : public ::testing::Test {
// empty
};
TEST_F( utScene, aiNode_addChildrenTest ) {
aiNode myNode;
static const size_t NumChildren = 10;
aiNode **childrenPtr = new aiNode*[ NumChildren ];
for ( unsigned int i = 0; i < NumChildren; i++ ) {
childrenPtr[ i ] = new aiNode;
}
myNode.addChildren( NumChildren, childrenPtr );
EXPECT_EQ( NumChildren, myNode.mNumChildren );
for ( unsigned int i = 0; i < NumChildren; i++ ) {
EXPECT_EQ( childrenPtr[ i ], myNode.mChildren[ i ] );
}
}

View file

@ -0,0 +1,79 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/SceneCombiner.h>
#include <assimp/mesh.h>
#include <memory>
using namespace ::Assimp;
class utSceneCombiner : public ::testing::Test {
// empty
};
TEST_F( utSceneCombiner, MergeMeshes_ValidNames_Test ) {
std::vector<aiMesh*> merge_list;
aiMesh *mesh1 = new aiMesh;
mesh1->mName.Set( "mesh_1" );
merge_list.push_back( mesh1 );
aiMesh *mesh2 = new aiMesh;
mesh2->mName.Set( "mesh_2" );
merge_list.push_back( mesh2 );
aiMesh *mesh3 = new aiMesh;
mesh3->mName.Set( "mesh_3" );
merge_list.push_back( mesh3 );
std::unique_ptr<aiMesh> out;
aiMesh* ptr = nullptr;
SceneCombiner::MergeMeshes( &ptr, 0, merge_list.begin(), merge_list.end() );
out.reset(ptr);
std::string outName = out->mName.C_Str();
EXPECT_EQ( "mesh_1.mesh_2.mesh_3", outName );
}
TEST_F( utSceneCombiner, CopySceneWithNullptr_AI_NO_EXCEPTion ) {
EXPECT_NO_THROW( SceneCombiner::CopyScene( nullptr, nullptr ) );
EXPECT_NO_THROW( SceneCombiner::CopySceneFlat( nullptr, nullptr ) );
}

View file

@ -0,0 +1,205 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/mesh.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <ScenePreprocessor.h>
using namespace std;
using namespace Assimp;
class ScenePreprocessorTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
void CheckIfOnly(aiMesh* p, unsigned int num, unsigned flag);
void ProcessAnimation(aiAnimation* anim) { pp->ProcessAnimation(anim); }
void ProcessMesh(aiMesh* mesh) { pp->ProcessMesh(mesh); }
ScenePreprocessor* pp;
aiScene* scene;
};
// ------------------------------------------------------------------------------------------------
void ScenePreprocessorTest::SetUp()
{
// setup a dummy scene with a single node
scene = new aiScene();
scene->mRootNode = new aiNode();
scene->mRootNode->mName.Set("<test>");
// add some translation
scene->mRootNode->mTransformation.a4 = 1.f;
scene->mRootNode->mTransformation.b4 = 2.f;
scene->mRootNode->mTransformation.c4 = 3.f;
// and allocate a ScenePreprocessor to operate on the scene
pp = new ScenePreprocessor(scene);
}
// ------------------------------------------------------------------------------------------------
void ScenePreprocessorTest::TearDown()
{
delete pp;
delete scene;
}
// ------------------------------------------------------------------------------------------------
// Check whether ProcessMesh() returns flag for a mesh that consist of primitives with num indices
void ScenePreprocessorTest::CheckIfOnly(aiMesh* p, unsigned int num, unsigned int flag)
{
// Triangles only
for (unsigned i = 0; i < p->mNumFaces;++i) {
p->mFaces[i].mNumIndices = num;
}
pp->ProcessMesh(p);
EXPECT_EQ(flag, p->mPrimitiveTypes);
p->mPrimitiveTypes = 0;
}
// ------------------------------------------------------------------------------------------------
// Check whether a mesh is preprocessed correctly. Case 1: The mesh needs preprocessing
TEST_F(ScenePreprocessorTest, testMeshPreprocessingPos)
{
aiMesh* p = new aiMesh();
p->mNumFaces = 100;
p->mFaces = new aiFace[p->mNumFaces];
p->mTextureCoords[0] = new aiVector3D[10];
p->mNumUVComponents[0] = 0;
p->mNumUVComponents[1] = 0;
CheckIfOnly(p,1,aiPrimitiveType_POINT);
CheckIfOnly(p,2,aiPrimitiveType_LINE);
CheckIfOnly(p,3,aiPrimitiveType_TRIANGLE);
CheckIfOnly(p,4,aiPrimitiveType_POLYGON);
CheckIfOnly(p,1249,aiPrimitiveType_POLYGON);
// Polygons and triangles mixed
unsigned i;
for (i = 0; i < p->mNumFaces/2;++i) {
p->mFaces[i].mNumIndices = 3;
}
for (; i < p->mNumFaces-p->mNumFaces/4;++i) {
p->mFaces[i].mNumIndices = 4;
}
for (; i < p->mNumFaces;++i) {
p->mFaces[i].mNumIndices = 10;
}
ProcessMesh(p);
EXPECT_EQ(static_cast<unsigned int>(aiPrimitiveType_TRIANGLE|aiPrimitiveType_POLYGON),
p->mPrimitiveTypes);
EXPECT_EQ(2U, p->mNumUVComponents[0]);
EXPECT_EQ(0U, p->mNumUVComponents[1]);
delete p;
}
// ------------------------------------------------------------------------------------------------
// Check whether a mesh is preprocessed correctly. Case 1: The mesh doesn't need preprocessing
TEST_F(ScenePreprocessorTest, testMeshPreprocessingNeg)
{
aiMesh* p = new aiMesh();
p->mPrimitiveTypes = aiPrimitiveType_TRIANGLE|aiPrimitiveType_POLYGON;
ProcessMesh(p);
// should be unmodified
EXPECT_EQ(static_cast<unsigned int>(aiPrimitiveType_TRIANGLE|aiPrimitiveType_POLYGON),
p->mPrimitiveTypes);
delete p;
}
// ------------------------------------------------------------------------------------------------
// Make a dummy animation with a single channel, '<test>'
aiAnimation* MakeDummyAnimation()
{
aiAnimation* p = new aiAnimation();
p->mNumChannels = 1;
p->mChannels = new aiNodeAnim*[1];
aiNodeAnim* anim = p->mChannels[0] = new aiNodeAnim();
anim->mNodeName.Set("<test>");
return p;
}
// ------------------------------------------------------------------------------------------------
// Check whether an anim is preprocessed correctly. Case 1: The anim needs preprocessing
TEST_F(ScenePreprocessorTest, testAnimationPreprocessingPos)
{
aiAnimation* p = MakeDummyAnimation();
aiNodeAnim* anim = p->mChannels[0];
// we don't set the animation duration, but generate scaling channels
anim->mNumScalingKeys = 10;
anim->mScalingKeys = new aiVectorKey[10];
for (unsigned int i = 0; i < 10;++i) {
anim->mScalingKeys[i].mTime = i;
anim->mScalingKeys[i].mValue = aiVector3D((float)i);
}
ProcessAnimation(p);
// we should now have a proper duration
EXPECT_NEAR(p->mDuration, 9., 0.005);
// ... one scaling key
EXPECT_TRUE(anim->mNumPositionKeys == 1 &&
anim->mPositionKeys &&
anim->mPositionKeys[0].mTime == 0.0 &&
anim->mPositionKeys[0].mValue == aiVector3D(1.f,2.f,3.f));
// ... and one rotation key
EXPECT_TRUE(anim->mNumRotationKeys == 1 && anim->mRotationKeys &&
anim->mRotationKeys[0].mTime == 0.0);
delete p;
}

View file

@ -0,0 +1,127 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <BaseProcess.h>
using namespace std;
using namespace Assimp;
class SharedPPDataTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
SharedPostProcessInfo* shared;
};
// ------------------------------------------------------------------------------------------------
void SharedPPDataTest::SetUp()
{
shared = new SharedPostProcessInfo();
}
// ------------------------------------------------------------------------------------------------
void SharedPPDataTest::TearDown()
{
delete shared;
}
// ------------------------------------------------------------------------------------------------
TEST_F(SharedPPDataTest, testPODProperty)
{
int i = 5;
shared->AddProperty("test",i);
int o = 0;
EXPECT_TRUE(shared->GetProperty("test",o));
EXPECT_EQ(5, o);
EXPECT_FALSE(shared->GetProperty("test2",o));
EXPECT_EQ(5, o);
float f = 12.f, m;
shared->AddProperty("test",f);
EXPECT_TRUE(shared->GetProperty("test",m));
EXPECT_EQ(12.f, m);
}
// ------------------------------------------------------------------------------------------------
TEST_F(SharedPPDataTest, testPropertyPointer)
{
int *i = new int;
shared->AddProperty("test16",i);
int* o;
EXPECT_TRUE(shared->GetProperty("test16",o));
EXPECT_EQ(i, o);
shared->RemoveProperty("test16");
EXPECT_FALSE(shared->GetProperty("test16",o));
}
static bool destructed;
struct TestType
{
~TestType()
{
destructed = true;
}
};
// ------------------------------------------------------------------------------------------------
TEST_F(SharedPPDataTest, testPropertyDeallocation)
{
SharedPostProcessInfo* localShared = new SharedPostProcessInfo();
destructed = false;
TestType *out, * pip = new TestType();
localShared->AddProperty("quak",pip);
EXPECT_TRUE(localShared->GetProperty("quak",out));
EXPECT_EQ(pip, out);
delete localShared;
EXPECT_TRUE(destructed);
}

View file

@ -0,0 +1,62 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "simd.h"
using namespace ::Assimp;
class utSimd : public ::testing::Test {
protected:
// empty
};
TEST_F( utSimd, SSE2SupportedTest ) {
bool isSupported;
isSupported = CPUSupportsSSE2();
if ( isSupported ) {
std::cout << "Supported" << std::endl;
} else {
std::cout << "Not supported" << std::endl;
}
}

View file

@ -0,0 +1,235 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <ScenePreprocessor.h>
#include <SortByPTypeProcess.h>
using namespace std;
using namespace Assimp;
class SortByPTypeProcessTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
SortByPTypeProcess* process1;
aiScene* scene;
};
// ------------------------------------------------------------------------------------------------
static unsigned int num[10][4] =
{
{0,0,0,1000},
{0,0,1000,0},
{0,1000,0,0},
{1000,0,0,0},
{500,500,0,0},
{500,0,500,0},
{0,330,330,340},
{250,250,250,250},
{100,100,100,700},
{0,100,0,900},
};
// ------------------------------------------------------------------------------------------------
static unsigned int result[10] =
{
aiPrimitiveType_POLYGON,
aiPrimitiveType_TRIANGLE,
aiPrimitiveType_LINE,
aiPrimitiveType_POINT,
aiPrimitiveType_POINT | aiPrimitiveType_LINE,
aiPrimitiveType_POINT | aiPrimitiveType_TRIANGLE,
aiPrimitiveType_TRIANGLE | aiPrimitiveType_LINE | aiPrimitiveType_POLYGON,
aiPrimitiveType_POLYGON | aiPrimitiveType_LINE | aiPrimitiveType_TRIANGLE | aiPrimitiveType_POINT,
aiPrimitiveType_POLYGON | aiPrimitiveType_LINE | aiPrimitiveType_TRIANGLE | aiPrimitiveType_POINT,
aiPrimitiveType_LINE | aiPrimitiveType_POLYGON,
};
// ------------------------------------------------------------------------------------------------
void SortByPTypeProcessTest::SetUp()
{
// process0 = new DeterminePTypeHelperProcess();
process1 = new SortByPTypeProcess();
scene = new aiScene();
scene->mNumMeshes = 10;
scene->mMeshes = new aiMesh*[10];
bool five = false;
for (unsigned int i = 0; i < 10; ++i)
{
aiMesh* mesh = scene->mMeshes[i] = new aiMesh();
mesh->mNumFaces = 1000;
aiFace* faces = mesh->mFaces = new aiFace[1000];
aiVector3D* pv = mesh->mVertices = new aiVector3D[mesh->mNumFaces*5];
aiVector3D* pn = mesh->mNormals = new aiVector3D[mesh->mNumFaces*5];
aiVector3D* pt = mesh->mTangents = new aiVector3D[mesh->mNumFaces*5];
aiVector3D* pb = mesh->mBitangents = new aiVector3D[mesh->mNumFaces*5];
aiVector3D* puv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumFaces*5];
unsigned int remaining[4] = {num[i][0],num[i][1],num[i][2],num[i][3]};
unsigned int n = 0;
for (unsigned int m = 0; m < 1000; ++m)
{
unsigned int idx = m % 4;
while (true)
{
if (!remaining[idx])
{
if (4 == ++idx)idx = 0;
continue;
}
break;
}
faces->mNumIndices = idx+1;
if (4 == faces->mNumIndices)
{
if(five)++faces->mNumIndices;
five = !five;
}
faces->mIndices = new unsigned int[faces->mNumIndices];
for (unsigned int q = 0; q <faces->mNumIndices;++q,++n)
{
faces->mIndices[q] = n;
float f = (float)remaining[idx];
// (the values need to be unique - otherwise all degenerates would be removed)
*pv++ = aiVector3D(f,f+1.f,f+q);
*pn++ = aiVector3D(f,f+1.f,f+q);
*pt++ = aiVector3D(f,f+1.f,f+q);
*pb++ = aiVector3D(f,f+1.f,f+q);
*puv++ = aiVector3D(f,f+1.f,f+q);
}
++faces;
--remaining[idx];
}
mesh->mNumVertices = n;
}
scene->mRootNode = new aiNode();
scene->mRootNode->mNumChildren = 5;
scene->mRootNode->mChildren = new aiNode*[5];
for (unsigned int i = 0; i< 5;++i )
{
aiNode* node = scene->mRootNode->mChildren[i] = new aiNode();
node->mNumMeshes = 2;
node->mMeshes = new unsigned int[2];
node->mMeshes[0] = (i<<1u);
node->mMeshes[1] = (i<<1u)+1;
}
}
// ------------------------------------------------------------------------------------------------
void SortByPTypeProcessTest::TearDown()
{
//delete process0;
delete process1;
delete scene;
}
// ------------------------------------------------------------------------------------------------
//TEST_F(SortByPTypeProcessTest, DeterminePTypeStep()
//{
// process0->Execute(scene);
//
// for (unsigned int i = 0; i < 10; ++i)
// {
// aiMesh* mesh = scene->mMeshes[i];
// EXPECT_TRUE(mesh->mPrimitiveTypes == result[i]);
// }
//}
// ------------------------------------------------------------------------------------------------
TEST_F(SortByPTypeProcessTest, SortByPTypeStep)
{
// process0->Execute(scene);
// and another small test for ScenePreprocessor
ScenePreprocessor s(scene);
s.ProcessScene();
for (unsigned int m = 0; m< 10;++m)
EXPECT_EQ(result[m], scene->mMeshes[m]->mPrimitiveTypes);
process1->Execute(scene);
unsigned int idx = 0;
for (unsigned int m = 0,real = 0; m< 10;++m)
{
for (unsigned int n = 0; n < 4;++n)
{
if ((idx = num[m][n]))
{
EXPECT_TRUE(real < scene->mNumMeshes);
aiMesh* mesh = scene->mMeshes[real];
EXPECT_TRUE(NULL != mesh);
EXPECT_EQ(AI_PRIMITIVE_TYPE_FOR_N_INDICES(n+1), mesh->mPrimitiveTypes);
EXPECT_TRUE(NULL != mesh->mVertices);
EXPECT_TRUE(NULL != mesh->mNormals);
EXPECT_TRUE(NULL != mesh->mTangents);
EXPECT_TRUE(NULL != mesh->mBitangents);
EXPECT_TRUE(NULL != mesh->mTextureCoords[0]);
EXPECT_TRUE(mesh->mNumFaces == idx);
for (unsigned int f = 0; f < mesh->mNumFaces;++f)
{
aiFace& face = mesh->mFaces[f];
EXPECT_TRUE(face.mNumIndices == (n+1) || (3 == n && face.mNumIndices > 3));
}
++real;
}
}
}
}

View file

@ -0,0 +1,170 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <SplitLargeMeshes.h>
using namespace std;
using namespace Assimp;
class SplitLargeMeshesTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
SplitLargeMeshesProcess_Triangle* piProcessTriangle;
SplitLargeMeshesProcess_Vertex* piProcessVertex;
};
// ------------------------------------------------------------------------------------------------
void SplitLargeMeshesTest::SetUp()
{
// construct the processes
this->piProcessTriangle = new SplitLargeMeshesProcess_Triangle();
this->piProcessVertex = new SplitLargeMeshesProcess_Vertex();
this->piProcessTriangle->SetLimit(1000);
this->piProcessVertex->SetLimit(1000);
}
// ------------------------------------------------------------------------------------------------
void SplitLargeMeshesTest::TearDown()
{
delete this->piProcessTriangle;
delete this->piProcessVertex;
}
// ------------------------------------------------------------------------------------------------
TEST_F(SplitLargeMeshesTest, testVertexSplit)
{
std::vector< std::pair<aiMesh*, unsigned int> > avOut;
aiMesh *pcMesh1 = new aiMesh();
pcMesh1->mNumVertices = 2100; // quersumme: 3
pcMesh1->mVertices = new aiVector3D[pcMesh1->mNumVertices];
pcMesh1->mNormals = new aiVector3D[pcMesh1->mNumVertices];
pcMesh1->mNumFaces = pcMesh1->mNumVertices / 3;
pcMesh1->mFaces = new aiFace[pcMesh1->mNumFaces];
unsigned int qq = 0;
for (unsigned int i = 0; i < pcMesh1->mNumFaces;++i)
{
aiFace& face = pcMesh1->mFaces[i];
face.mNumIndices = 3;
face.mIndices = new unsigned int[3];
face.mIndices[0] = qq++;
face.mIndices[1] = qq++;
face.mIndices[2] = qq++;
}
int iOldFaceNum = (int)pcMesh1->mNumFaces;
piProcessVertex->SplitMesh(0,pcMesh1,avOut);
for (std::vector< std::pair<aiMesh*, unsigned int> >::const_iterator
iter = avOut.begin(), end = avOut.end();
iter != end; ++iter)
{
aiMesh* mesh = (*iter).first;
EXPECT_LT(mesh->mNumVertices, 1000U);
EXPECT_TRUE(NULL != mesh->mNormals);
EXPECT_TRUE(NULL != mesh->mVertices);
iOldFaceNum -= mesh->mNumFaces;
delete mesh;
}
EXPECT_EQ(0, iOldFaceNum);
}
// ------------------------------------------------------------------------------------------------
TEST_F(SplitLargeMeshesTest, testTriangleSplit)
{
std::vector< std::pair<aiMesh*, unsigned int> > avOut;
// generate many, many faces with randomized indices for
// the second mesh
aiMesh *pcMesh2 = new aiMesh();
pcMesh2->mNumVertices = 3000;
pcMesh2->mVertices = new aiVector3D[pcMesh2->mNumVertices];
pcMesh2->mNormals = new aiVector3D[pcMesh2->mNumVertices];
pcMesh2->mNumFaces = 10000;
pcMesh2->mFaces = new aiFace[pcMesh2->mNumFaces];
for (unsigned int i = 0; i < pcMesh2->mNumFaces;++i)
{
aiFace& face = pcMesh2->mFaces[i];
face.mNumIndices = 3;
face.mIndices = new unsigned int[3];
face.mIndices[0] = (unsigned int)((rand() / (float)RAND_MAX) * pcMesh2->mNumVertices);
face.mIndices[1] = (unsigned int)((rand() / (float)RAND_MAX) * pcMesh2->mNumVertices);
face.mIndices[2] = (unsigned int)((rand() / (float)RAND_MAX) * pcMesh2->mNumVertices);
}
// the number of faces shouldn't change
int iOldFaceNum = (int)pcMesh2->mNumFaces;
piProcessTriangle->SplitMesh(0,pcMesh2,avOut);
for (std::vector< std::pair<aiMesh*, unsigned int> >::const_iterator
iter = avOut.begin(), end = avOut.end();
iter != end; ++iter)
{
aiMesh* mesh = (*iter).first;
EXPECT_LT(mesh->mNumFaces, 1000U);
EXPECT_TRUE(NULL != mesh->mNormals);
EXPECT_TRUE(NULL != mesh->mVertices);
iOldFaceNum -= mesh->mNumFaces;
delete mesh;
}
EXPECT_EQ(0, iOldFaceNum);
}

View file

@ -0,0 +1,70 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/StringUtils.h>
class utStringUtils : public ::testing::Test {
};
TEST_F( utStringUtils, to_string_Test ) {
std::string res = to_string( 1 );
EXPECT_EQ( res, "1" );
res = to_string( 1.0f );
EXPECT_EQ( res, "1" );
}
TEST_F( utStringUtils, ai_strtofTest ) {
float res = ai_strtof( nullptr, nullptr );
EXPECT_FLOAT_EQ( res, 0.0f );
std::string testStr1 = "200.0";
res = ai_strtof( testStr1.c_str(), nullptr );
EXPECT_FLOAT_EQ( res, 200.0f );
std::string testStr2 = "200.0 xxx";
const char *begin( testStr2.c_str() );
const char *end( begin + 6 );
res = ai_strtof( begin, end );
EXPECT_FLOAT_EQ( res, 200.0f );
}

View file

@ -0,0 +1,45 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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"
// TODO

View file

@ -0,0 +1,45 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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"
// TODO

View file

@ -0,0 +1,140 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/scene.h>
#include <TriangulateProcess.h>
using namespace std;
using namespace Assimp;
class TriangulateProcessTest : public ::testing::Test {
public:
virtual void SetUp();
virtual void TearDown();
protected:
aiMesh* pcMesh;
TriangulateProcess* piProcess;
};
void TriangulateProcessTest::SetUp() {
piProcess = new TriangulateProcess();
pcMesh = new aiMesh();
pcMesh->mNumFaces = 1000;
pcMesh->mFaces = new aiFace[1000];
pcMesh->mVertices = new aiVector3D[10000];
pcMesh->mPrimitiveTypes = aiPrimitiveType_POINT | aiPrimitiveType_LINE |
aiPrimitiveType_LINE | aiPrimitiveType_POLYGON;
for (unsigned int m = 0, t = 0, q = 4; m < 1000; ++m) {
++t;
aiFace& face = pcMesh->mFaces[m];
face.mNumIndices = t;
if (4 == t) {
face.mNumIndices = q++;
t = 0;
if (10 == q)q = 4;
}
face.mIndices = new unsigned int[face.mNumIndices];
for (unsigned int p = 0; p < face.mNumIndices; ++p) {
face.mIndices[ p ] = pcMesh->mNumVertices;
// construct fully convex input data in ccw winding, xy plane
aiVector3D& v = pcMesh->mVertices[pcMesh->mNumVertices++];
v.z = 0.f;
v.x = cos (p * (float)(AI_MATH_TWO_PI)/face.mNumIndices);
v.y = sin (p * (float)(AI_MATH_TWO_PI)/face.mNumIndices);
}
}
}
void TriangulateProcessTest::TearDown() {
delete piProcess;
delete pcMesh;
}
TEST_F(TriangulateProcessTest, testTriangulation) {
piProcess->TriangulateMesh(pcMesh);
for (unsigned int m = 0, t = 0, q = 4, max = 1000, idx = 0; m < max;++m) {
++t;
aiFace& face = pcMesh->mFaces[m];
if (4 == t) {
t = 0;
max += q-3;
std::vector<bool> ait(q,false);
for (unsigned int i = 0, tt = q-2; i < tt; ++i,++m) {
aiFace& face = pcMesh->mFaces[m];
EXPECT_EQ(3U, face.mNumIndices);
for (unsigned int qqq = 0; qqq < face.mNumIndices; ++qqq) {
ait[face.mIndices[qqq]-idx] = true;
}
}
for (std::vector<bool>::const_iterator it = ait.begin(); it != ait.end(); ++it) {
EXPECT_TRUE(*it);
}
--m;
idx+=q;
if ( ++q == 10 ) {
q = 4;
}
} else {
EXPECT_EQ(t, face.mNumIndices);
for (unsigned int i = 0; i < face.mNumIndices; ++i,++idx) {
EXPECT_EQ(idx, face.mIndices[i]);
}
}
}
// we should have no valid normal vectors now necause we aren't a pure polygon mesh
EXPECT_TRUE(pcMesh->mNormals == NULL);
}

View file

@ -0,0 +1,77 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/types.h>
using namespace Assimp;
class utTypes : public ::testing::Test {
// empty
};
TEST_F( utTypes, Color3dCpmpareOpTest ) {
aiColor3D col1( 1, 2, 3 );
aiColor3D col2( 4, 5, 6 );
aiColor3D col3( col1 );
EXPECT_FALSE( col1 == col2 );
EXPECT_FALSE( col2 == col3 );
EXPECT_TRUE( col1 == col3 );
EXPECT_TRUE( col1 != col2 );
EXPECT_TRUE( col2 != col3 );
EXPECT_FALSE( col1 != col3 );
}
TEST_F( utTypes, Color3dIndexOpTest ) {
aiColor3D col( 1, 2, 3 );
const ai_real r = col[ 0 ];
EXPECT_FLOAT_EQ( 1, r );
const ai_real g = col[ 1 ];
EXPECT_FLOAT_EQ( 2, g );
const ai_real b = col[ 2 ];
EXPECT_FLOAT_EQ( 3, b );
}

View file

@ -0,0 +1,70 @@
/*-------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/vector3.h>
using namespace ::Assimp;
class utVector3 : public ::testing::Test {
// empty
};
TEST_F(utVector3, CreationTest) {
aiVector3D v0;
aiVector3D v1( 1.0f, 2.0f, 3.0f );
EXPECT_FLOAT_EQ (1.0f, v1[ 0 ] );
EXPECT_FLOAT_EQ( 2.0f, v1[ 1 ] );
EXPECT_FLOAT_EQ( 3.0f, v1[ 2 ] );
aiVector3D v2( 1 );
EXPECT_FLOAT_EQ( 1.0f, v2[ 0 ] );
EXPECT_FLOAT_EQ( 1.0f, v2[ 1 ] );
EXPECT_FLOAT_EQ( 1.0f, v2[ 2 ] );
aiVector3D v3( v1 );
EXPECT_FLOAT_EQ( v1[ 0 ], v3[ 0 ] );
EXPECT_FLOAT_EQ( v1[ 1 ], v3[ 1 ] );
EXPECT_FLOAT_EQ( v1[ 2 ], v3[ 2 ] );
}
TEST_F( utVector3, BracketOpTest ) {
aiVector3D v(1.0f, 2.0f, 3.0f);
EXPECT_FLOAT_EQ( 1.0f, v[ 0 ] );
EXPECT_FLOAT_EQ( 2.0f, v[ 1 ] );
EXPECT_FLOAT_EQ( 3.0f, v[ 2 ] );
}

View file

@ -0,0 +1,77 @@
/*-------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 <assimp/version.h>
class utVersion : public ::testing::Test {
// empty
};
TEST_F( utVersion, aiGetLegalStringTest ) {
const char *lv( aiGetLegalString() );
EXPECT_NE( lv, nullptr );
std::string text( lv );
size_t pos( text.find( std::string( "2017" ) ) );
EXPECT_NE( pos, std::string::npos );
}
TEST_F( utVersion, aiGetVersionMinorTest ) {
EXPECT_EQ( aiGetVersionMinor(), 1U );
}
TEST_F( utVersion, aiGetVersionMajorTest ) {
EXPECT_EQ( aiGetVersionMajor(), 4U );
}
TEST_F( utVersion, aiGetCompileFlagsTest ) {
EXPECT_NE( aiGetCompileFlags(), 0U );
}
TEST_F( utVersion, aiGetVersionRevisionTest ) {
EXPECT_NE( aiGetVersionRevision(), 0U );
}
TEST_F( utVersion, aiGetBranchNameTest ) {
EXPECT_NE( nullptr, aiGetBranchName() );
}

View file

@ -0,0 +1,229 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "assimp/types.h"
#include "assimp/mesh.h"
#include <VertexTriangleAdjacency.h>
using namespace std;
using namespace Assimp;
class VTAdjacencyTest : public ::testing::Test
{
protected:
void checkMesh(const aiMesh& mesh);
};
// ------------------------------------------------------------------------------------------------
TEST_F(VTAdjacencyTest, largeRandomDataSet)
{
// build a test mesh with randomized input data
// *******************************************************************************
aiMesh mesh;
mesh.mNumVertices = 500;
mesh.mNumFaces = 600;
mesh.mFaces = new aiFace[600];
unsigned int iCurrent = 0;
for (unsigned int i = 0; i < 600;++i)
{
aiFace& face = mesh.mFaces[i];
face.mNumIndices = 3;
face.mIndices = new unsigned int[3];
if (499 == iCurrent)iCurrent = 0;
face.mIndices[0] = iCurrent++;
while(face.mIndices[0] == ( face.mIndices[1] = (unsigned int)(((float)rand()/RAND_MAX)*499)));
while(face.mIndices[0] == ( face.mIndices[2] = (unsigned int)(((float)rand()/RAND_MAX)*499)) ||
face.mIndices[1] == face.mIndices[2]);
}
checkMesh(mesh);
}
// ------------------------------------------------------------------------------------------------
TEST_F(VTAdjacencyTest, smallDataSet)
{
// build a test mesh - this one is extremely small
// *******************************************************************************
aiMesh mesh;
mesh.mNumVertices = 5;
mesh.mNumFaces = 3;
mesh.mFaces = new aiFace[3];
mesh.mFaces[0].mIndices = new unsigned int[3];
mesh.mFaces[0].mNumIndices = 3;
mesh.mFaces[1].mIndices = new unsigned int[3];
mesh.mFaces[1].mNumIndices = 3;
mesh.mFaces[2].mIndices = new unsigned int[3];
mesh.mFaces[2].mNumIndices = 3;
mesh.mFaces[0].mIndices[0] = 1;
mesh.mFaces[0].mIndices[1] = 3;
mesh.mFaces[0].mIndices[2] = 2;
mesh.mFaces[1].mIndices[0] = 0;
mesh.mFaces[1].mIndices[1] = 2;
mesh.mFaces[1].mIndices[2] = 3;
mesh.mFaces[2].mIndices[0] = 3;
mesh.mFaces[2].mIndices[1] = 0;
mesh.mFaces[2].mIndices[2] = 4;
checkMesh(mesh);
}
// ------------------------------------------------------------------------------------------------
TEST_F(VTAdjacencyTest, unreferencedVerticesSet)
{
// build a test mesh which does not reference all vertices
// *******************************************************************************
aiMesh mesh;
mesh.mNumVertices = 500;
mesh.mNumFaces = 600;
mesh.mFaces = new aiFace[600];
unsigned int iCurrent = 0;
for (unsigned int i = 0; i < 600;++i)
{
aiFace& face = mesh.mFaces[i];
face.mNumIndices = 3;
face.mIndices = new unsigned int[3];
if (499 == iCurrent)iCurrent = 0;
face.mIndices[0] = iCurrent++;
if (499 == iCurrent)iCurrent = 0;
face.mIndices[1] = iCurrent++;
if (499 == iCurrent)iCurrent = 0;
face.mIndices[2] = iCurrent++;
if (rand() > RAND_MAX/2 && face.mIndices[0])
{
face.mIndices[0]--;
}
else if (face.mIndices[1]) face.mIndices[1]--;
}
checkMesh(mesh);
}
// ------------------------------------------------------------------------------------------------
void VTAdjacencyTest::checkMesh(const aiMesh& mesh)
{
VertexTriangleAdjacency adj(mesh.mFaces,mesh.mNumFaces,mesh.mNumVertices,true);
unsigned int* const piNum = adj.mLiveTriangles;
// check the primary adjacency table and check whether all faces
// are contained in the list
unsigned int maxOfs = 0;
for (unsigned int i = 0; i < mesh.mNumFaces;++i)
{
aiFace& face = mesh.mFaces[i];
for (unsigned int qq = 0; qq < 3 ;++qq)
{
const unsigned int idx = face.mIndices[qq];
const unsigned int num = piNum[idx];
// go to this offset
const unsigned int ofs = adj.mOffsetTable[idx];
maxOfs = std::max(ofs+num,maxOfs);
unsigned int* pi = &adj.mAdjacencyTable[ofs];
// and search for us ...
unsigned int tt = 0;
for (; tt < num;++tt,++pi)
{
if (i == *pi)
{
// mask our entry in the table. Finally all entries should be masked
*pi = 0xffffffff;
// there shouldn't be two entries for the same face
break;
}
}
// assert if *this* vertex has not been found in the table
EXPECT_LT(tt, num);
}
}
// now check whether there are invalid faces
const unsigned int* pi = adj.mAdjacencyTable;
for (unsigned int i = 0; i < maxOfs;++i,++pi)
{
EXPECT_EQ(0xffffffff, *pi);
}
// check the numTrianglesPerVertex table
for (unsigned int i = 0; i < mesh.mNumFaces;++i)
{
aiFace& face = mesh.mFaces[i];
for (unsigned int qq = 0; qq < 3 ;++qq)
{
const unsigned int idx = face.mIndices[qq];
// we should not reach 0 here ...
EXPECT_NE(0U, piNum[idx]);
piNum[idx]--;
}
}
// check whether we reached 0 in all entries
for (unsigned int i = 0; i < mesh.mNumVertices;++i)
{
EXPECT_FALSE(piNum[i]);
}
}

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utX3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utX3DImportExport, importX3DFromFileTest ) {
EXPECT_TRUE( importerTest() );
}

View file

@ -0,0 +1,69 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "SceneDiffer.h"
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utXImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X/test.x", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utXImporterExporter, importXFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utXImporterExporter, heap_overflow_in_tokenizer ) {
Assimp::Importer importer;
EXPECT_NO_THROW( importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X/OV_GetNextToken", 0 ) );
}

View file

@ -0,0 +1,383 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <array>
using namespace Assimp;
class utglTF2ImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE( scene, nullptr );
if ( !scene ) return false;
EXPECT_TRUE( scene->HasMaterials() );
if ( !scene->HasMaterials() ) return false;
const aiMaterial *material = scene->mMaterials[0];
aiString path;
aiTextureMapMode modes[2];
EXPECT_EQ( aiReturn_SUCCESS, material->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes) );
EXPECT_STREQ( path.C_Str(), "CesiumLogoFlat.png" );
EXPECT_EQ( modes[0], aiTextureMapMode_Mirror );
EXPECT_EQ( modes[1], aiTextureMapMode_Clamp );
return true;
}
virtual bool binaryImporterTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/2CylinderEngine-glTF-Binary/2CylinderEngine.glb", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
#ifndef ASSIMP_BUILD_NO_EXPORT
virtual bool exporterTest() {
Assimp::Importer importer;
Assimp::Exporter exporter;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "gltf2", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured_out.gltf" ) );
return true;
}
#endif // ASSIMP_BUILD_NO_EXPORT
};
TEST_F( utglTF2ImportExport, importglTF2FromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utglTF2ImportExport, importBinaryglTF2FromFileTest ) {
EXPECT_TRUE( binaryImporterTest() );
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F(utglTF2ImportExport, importglTF2AndExportToOBJ) {
Assimp::Importer importer;
Assimp::Exporter exporter;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured_out.obj"));
}
TEST_F(utglTF2ImportExport, importglTF2EmbeddedAndExportToOBJ) {
Assimp::Importer importer;
Assimp::Exporter exporter;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-Embedded/BoxTextured.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF-Embedded/BoxTextured_out.obj"));
}
#endif // ASSIMP_BUILD_NO_EXPORT
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModePointsWithoutIndices) {
Assimp::Importer importer;
//Points without indices
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_00.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 1024);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 1);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesWithoutIndices) {
Assimp::Importer importer;
//Lines without indices
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_01.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 8);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i*2);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], i*2 + 1);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesLoopWithoutIndices) {
Assimp::Importer importer;
//Lines loop without indices
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_02.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
std::array<int, 5> l1 = {{ 0, 1, 2, 3, 0 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLinesStripWithoutIndices) {
Assimp::Importer importer;
//Lines strip without indices
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_03.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 5);
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 2);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], i + 1);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStripWithoutIndices) {
Assimp::Importer importer;
//Triangles strip without indices
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_04.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
std::array<int, 3> f1 = {{ 0, 1, 2 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
}
std::array<int, 3> f2 = {{ 2, 1, 3 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFanWithoutIndices) {
Assimp::Importer importer;
//Triangles fan without indices
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_05.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
std::array<int, 3> f1 = {{ 0, 1, 2 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
}
std::array<int, 3> f2 = {{ 0, 2, 3 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesWithoutIndices) {
Assimp::Importer importer;
//Triangles without indices
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_06.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 6);
std::array<int, 3> f1 = {{ 0, 1, 2 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
}
std::array<int, 3> f2 = {{ 3, 4, 5 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModePoints) {
Assimp::Importer importer;
//Line loop
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_07.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 1024);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mNumIndices, 1);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], i);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) {
Assimp::Importer importer;
//Lines
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
std::array<int, 5> l1 = {{ 0, 3, 2, 1, 0 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) {
Assimp::Importer importer;
//Line loop
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
std::array<int, 5> l1 = {{ 0, 3, 2, 1, 0 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i+1]);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineStrip) {
Assimp::Importer importer;
//Lines Strip
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
std::array<int, 5> l1 = {{ 0, 3, 2, 1, 0 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[1], l1[i + 1]);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) {
Assimp::Importer importer;
//Triangles strip
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_11.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
std::array<int, 3> f1 = {{ 0, 3, 1 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
}
std::array<int, 3> f2 = {{ 1, 3, 2 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
}
}
TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFan) {
Assimp::Importer importer;
//Triangles fan
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_12.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4);
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2);
std::array<int, 3> f1 = {{ 0, 3, 2 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
}
std::array<int, 3> f2 = {{ 0, 2, 1 }};
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3);
for (int i = 0; i < 3; ++i)
{
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
}
}
std::vector<char> ReadFile(const char* name) {
std::vector<char> ret;
FILE* p = ::fopen(name, "r");
if (nullptr == p) {
return ret;
}
::fseek(p, 0, SEEK_END);
const auto size = ::ftell(p);
::fseek(p, 0, SEEK_SET);
ret.resize(size);
::fread(&ret[0], 1, size, p);
::fclose(p);
return ret;
}
TEST_F(utglTF2ImportExport, importglTF2FromMemory) {
/*const auto flags = aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_RemoveComponent |
aiProcess_GenSmoothNormals | aiProcess_PreTransformVertices | aiProcess_FixInfacingNormals |
aiProcess_FindDegenerates | aiProcess_GenUVCoords | aiProcess_SortByPType;
const auto& buff = ReadFile("C:\\Users\\kimkulling\\Downloads\\camel\\camel\\scene.gltf");*/
/*const aiScene* Scene = ::aiImportFileFromMemory(&buff[0], buff.size(), flags, ".gltf");
EXPECT_EQ( nullptr, Scene );*/
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) {
EXPECT_TRUE( exporterTest() );
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,62 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
class utglTFImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF/TwoBoxes/TwoBoxes.gltf", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
TEST_F( utglTFImportExport, importglTFFromFileTest ) {
EXPECT_TRUE( importerTest() );
}