Add unittest.

pull/2521/head
Kim Kulling 2019-06-24 21:37:53 +02:00
parent 26bd54ae0b
commit 0f66a917e5
8 changed files with 119 additions and 7 deletions

View File

@ -669,6 +669,8 @@ SET( PostProcessing_SRCS
PostProcessing/MakeVerboseFormat.h PostProcessing/MakeVerboseFormat.h
PostProcessing/ScaleProcess.cpp PostProcessing/ScaleProcess.cpp
PostProcessing/ScaleProcess.h PostProcessing/ScaleProcess.h
PostProcessing/GenBoundingBoxesProcess.cpp
PostProcessing/GenBoundingBoxesProcess.h
) )
SOURCE_GROUP( PostProcessing FILES ${PostProcessing_SRCS}) SOURCE_GROUP( PostProcessing FILES ${PostProcessing_SRCS})

View File

@ -89,7 +89,7 @@ void BaseProcess::ExecuteOnScene( Importer* pImp)
// and kill the partially imported data // and kill the partially imported data
delete pImp->Pimpl()->mScene; delete pImp->Pimpl()->mScene;
pImp->Pimpl()->mScene = NULL; pImp->Pimpl()->mScene = nullptr;
} }
} }

View File

@ -131,6 +131,10 @@ corresponding preprocessor flag to selectively disable steps.
#if (!defined ASSIMP_BUILD_NO_GLOBALSCALE_PROCESS) #if (!defined ASSIMP_BUILD_NO_GLOBALSCALE_PROCESS)
# include "PostProcessing/ScaleProcess.h" # include "PostProcessing/ScaleProcess.h"
#endif #endif
#if (!defined ASSIMP_BUILD_NO_GENBOUNDINGBOXES_PROCESS)
# include "PostProcessing/GenBoundingBoxesProcess.h"
#endif
namespace Assimp { namespace Assimp {
@ -246,6 +250,9 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
#if (!defined ASSIMP_BUILD_NO_IMPROVECACHELOCALITY_PROCESS) #if (!defined ASSIMP_BUILD_NO_IMPROVECACHELOCALITY_PROCESS)
out.push_back( new ImproveCacheLocalityProcess()); out.push_back( new ImproveCacheLocalityProcess());
#endif #endif
#if (!defined ASSIMP_BUILD_NO_GENBOUNDINGBOXES_PROCESS)
out.push_back(new GenBoundingBoxesProcess);
#endif
} }
} }

View File

@ -39,23 +39,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
/** @file Defines a post-processing step to generate Axis-aligned bounding
* volumes for all meshes.
*/
#pragma once #pragma once
#ifndef AI_GENBOUNDINGBOXESPROCESS_H_INC #ifndef AI_GENBOUNDINGBOXESPROCESS_H_INC
#define AI_GENBOUNDINGBOXESPROCESS_H_INC #define AI_GENBOUNDINGBOXESPROCESS_H_INC
#ifndef ASSIMP_BUILD_NO_GENBOUNDINGBOXES_PROCESS
#include "Common/BaseProcess.h" #include "Common/BaseProcess.h"
namespace Assimp { namespace Assimp {
class GenBoundingBoxesProcess : public BaseProcess { /** Post-processing process to find axis-aligned bounding volumes for amm meshes
* used in a scene
*/
class ASSIMP_API GenBoundingBoxesProcess : public BaseProcess {
public: public:
/// The class constructor.
GenBoundingBoxesProcess(); GenBoundingBoxesProcess();
/// The class destructor.
~GenBoundingBoxesProcess(); ~GenBoundingBoxesProcess();
/// Will return true, if aiProcess_GenBoundingBoxes is defined.
bool IsActive(unsigned int pFlags) const override; bool IsActive(unsigned int pFlags) const override;
/// The execution callback.
void Execute(aiScene* pScene) override; void Execute(aiScene* pScene) override;
}; };
} // Namespace Assimp } // Namespace Assimp
#endif // #ifndef ASSIMP_BUILD_NO_GENBOUNDINGBOXES_PROCESS
#endif // AI_GENBOUNDINGBOXESPROCESS_H_INC #endif // AI_GENBOUNDINGBOXESPROCESS_H_INC

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2019, assimp team Copyright (c) 2006-2019, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -40,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
/** @file Defines a post processing step to split large meshes into submeshes /** @file Defines a post processing step to split large meshes into sub-meshes
*/ */
#ifndef AI_SPLITLARGEMESHES_H_INC #ifndef AI_SPLITLARGEMESHES_H_INC
#define AI_SPLITLARGEMESHES_H_INC #define AI_SPLITLARGEMESHES_H_INC
@ -51,10 +50,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/mesh.h> #include <assimp/mesh.h>
#include <assimp/scene.h> #include <assimp/scene.h>
// Forward declarations
class SplitLargeMeshesTest; class SplitLargeMeshesTest;
namespace Assimp namespace Assimp {
{
class SplitLargeMeshesProcess_Triangle; class SplitLargeMeshesProcess_Triangle;
class SplitLargeMeshesProcess_Vertex; class SplitLargeMeshesProcess_Vertex;

View File

@ -161,6 +161,7 @@ SET( POST_PROCESSES
unit/utTargetAnimation.cpp unit/utTargetAnimation.cpp
unit/utSortByPType.cpp unit/utSortByPType.cpp
unit/utSceneCombiner.cpp unit/utSceneCombiner.cpp
unit/utGenBoundingBoxesProcess.cpp
) )
SOURCE_GROUP( UnitTests\\Compiler FILES unit/CCompilerTest.c ) SOURCE_GROUP( UnitTests\\Compiler FILES unit/CCompilerTest.c )

View File

@ -1,6 +1,6 @@
ply ply
format ascii 1.0 format ascii 1.0
comment Created by Open Asset Import Library - http://assimp.sf.net (v4.1.3945266037) comment Created by Open Asset Import Library - http://assimp.sf.net (v4.1.649942190)
element vertex 8 element vertex 8
property float x property float x
property float y property float y

View File

@ -0,0 +1,88 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, 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 "PostProcessing/GenBoundingBoxesProcess.h"
#include <assimp/mesh.h>
#include <assimp/scene.h>
using namespace Assimp;
class utGenBoundingBoxesProcess : public ::testing::Test {
public:
void SetUp() override {
mProcess = new GenBoundingBoxesProcess;
mMesh = new aiMesh();
mMesh->mNumVertices = 100;
mMesh->mVertices = new aiVector3D[100];
for (unsigned int i = 0; i < 100; ++i) {
mMesh->mVertices[i] = aiVector3D(i, i, i);
}
mScene = new aiScene();
mScene->mNumMeshes = 1;
mScene->mMeshes = new aiMesh*[1];
mScene->mMeshes[0] = mMesh;
}
void TearDown() override {
delete mProcess;
delete mScene;
}
protected:
GenBoundingBoxesProcess *mProcess;
aiMesh *mMesh;
aiScene* mScene;
};
TEST_F(utGenBoundingBoxesProcess, executeTest) {
mProcess->Execute(mScene);
aiMesh* mesh = mScene->mMeshes[0];
EXPECT_NE(nullptr, mesh);
EXPECT_EQ(0, mesh->mAABB.mMin.x);
EXPECT_EQ(0, mesh->mAABB.mMin.y);
EXPECT_EQ(0, mesh->mAABB.mMin.z);
EXPECT_EQ(99, mesh->mAABB.mMax.x);
EXPECT_EQ(99, mesh->mAABB.mMax.y);
EXPECT_EQ(99, mesh->mAABB.mMax.z);
}