Refactoring: Code cleanup post-processing.

pull/5009/head
Kim Kulling 2023-03-14 23:32:03 +01:00
parent 1147f0c8bd
commit 31ae9cde1c
29 changed files with 93 additions and 149 deletions

View File

@ -60,10 +60,6 @@ CalcTangentsProcess::CalcTangentsProcess() :
// nothing to do here
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
CalcTangentsProcess::~CalcTangentsProcess() = default;
// ------------------------------------------------------------------------------------------------
// Returns whether the processing step is present in the given flag field.
bool CalcTangentsProcess::IsActive(unsigned int pFlags) const {

View File

@ -59,14 +59,11 @@ namespace Assimp
* because the joining of vertices also considers tangents and bitangents for
* uniqueness.
*/
class ASSIMP_API_WINONLY CalcTangentsProcess : public BaseProcess
{
class ASSIMP_API_WINONLY CalcTangentsProcess : public BaseProcess {
public:
CalcTangentsProcess();
~CalcTangentsProcess();
~CalcTangentsProcess() override = default;
public:
// -------------------------------------------------------------------
/** Returns whether the processing step is present in the given flag.
* @param pFlags The processing flags the importer was called with.
@ -74,19 +71,17 @@ public:
* @return true if the process is present in this flag fields,
* false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Called prior to ExecuteOnScene().
* The function is a request to the process to update its configuration
* basing on the Importer's configuration property list.
*/
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
// setter for configMaxAngle
inline void SetMaxSmoothAngle(float f)
{
void SetMaxSmoothAngle(float f) {
configMaxAngle =f;
}

View File

@ -57,14 +57,6 @@ namespace {
const static ai_real angle_epsilon = ai_real( 0.95 );
}
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
ComputeUVMappingProcess::ComputeUVMappingProcess() = default;
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
ComputeUVMappingProcess::~ComputeUVMappingProcess() = default;
// ------------------------------------------------------------------------------------------------
// Returns whether the processing step is present in the given flag field.
bool ComputeUVMappingProcess::IsActive( unsigned int pFlags) const

View File

@ -59,13 +59,10 @@ namespace Assimp {
/** ComputeUVMappingProcess - converts special mappings, such as spherical,
* cylindrical or boxed to proper UV coordinates for rendering.
*/
class ComputeUVMappingProcess : public BaseProcess
{
public:
ComputeUVMappingProcess();
~ComputeUVMappingProcess();
class ComputeUVMappingProcess : public BaseProcess {
public:
ComputeUVMappingProcess() = default;
~ComputeUVMappingProcess() override = default;
// -------------------------------------------------------------------
/** Returns whether the processing step is present in the given flag field.
@ -73,14 +70,14 @@ public:
* combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
protected:
@ -125,8 +122,7 @@ protected:
private:
// temporary structure to describe a mapping
struct MappingInfo
{
struct MappingInfo {
explicit MappingInfo(aiTextureMapping _type)
: type (_type)
, axis (0.f,1.f,0.f)
@ -137,8 +133,7 @@ private:
aiVector3D axis;
unsigned int uv;
bool operator== (const MappingInfo& other)
{
bool operator== (const MappingInfo& other) {
return type == other.type && axis == other.axis;
}
};

View File

@ -79,14 +79,6 @@ void flipUVs(aiMeshType *pMesh) {
} // namespace
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
MakeLeftHandedProcess::MakeLeftHandedProcess() = default;
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
MakeLeftHandedProcess::~MakeLeftHandedProcess() = default;
// ------------------------------------------------------------------------------------------------
// Returns whether the processing step is present in the given flag field.
bool MakeLeftHandedProcess::IsActive(unsigned int pFlags) const {
@ -305,14 +297,6 @@ void FlipUVsProcess::ProcessMesh(aiMesh *pMesh) {
#ifndef ASSIMP_BUILD_NO_FLIPWINDING_PROCESS
// # FlipWindingOrderProcess
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
FlipWindingOrderProcess::FlipWindingOrderProcess() = default;
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
FlipWindingOrderProcess::~FlipWindingOrderProcess() = default;
// ------------------------------------------------------------------------------------------------
// Returns whether the processing step is present in the given flag field.
bool FlipWindingOrderProcess::IsActive(unsigned int pFlags) const {

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2022, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@ -72,22 +71,18 @@ namespace Assimp {
*
* @note RH-LH and LH-RH is the same, so this class can be used for both
*/
class MakeLeftHandedProcess : public BaseProcess
{
class MakeLeftHandedProcess : public BaseProcess {
public:
MakeLeftHandedProcess();
~MakeLeftHandedProcess();
MakeLeftHandedProcess() = default;
~MakeLeftHandedProcess() override = default;
// -------------------------------------------------------------------
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
protected:
// -------------------------------------------------------------------
/** Recursively converts a node and all of its children
*/
@ -120,24 +115,22 @@ protected:
// ---------------------------------------------------------------------------
/** Postprocessing step to flip the face order of the imported data
*/
class FlipWindingOrderProcess : public BaseProcess
{
class FlipWindingOrderProcess : public BaseProcess {
friend class Importer;
public:
/** Constructor to be privately used by Importer */
FlipWindingOrderProcess();
FlipWindingOrderProcess() = default;
/** Destructor, private as well */
~FlipWindingOrderProcess();
~FlipWindingOrderProcess() override = default;
// -------------------------------------------------------------------
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
public:
/** Some other types of post-processing require winding order flips */
static void ProcessMesh( aiMesh* pMesh);
};

View File

@ -79,14 +79,14 @@ public:
* @return true if the process is present in this flag fields,
* false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Called prior to ExecuteOnScene().
* The function is a request to the process to update its configuration
* basing on the Importer's configuration property list.
*/
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
protected:
// -------------------------------------------------------------------

View File

@ -64,15 +64,14 @@ public:
* combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
private:
bool DropMeshFaceNormals(aiMesh* pcMesh);

View File

@ -68,13 +68,13 @@ public:
~EmbedTexturesProcess() override = default;
/// Overwritten, @see BaseProcess
virtual bool IsActive(unsigned int pFlags) const;
bool IsActive(unsigned int pFlags) const override;
/// Overwritten, @see BaseProcess
virtual void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
/// Overwritten, @see BaseProcess
virtual void Execute(aiScene* pScene);
virtual void Execute(aiScene* pScene) override;
private:
// Resolve the path and add the file content to the scene as a texture.

View File

@ -63,15 +63,15 @@ public:
// -------------------------------------------------------------------
// Check whether step is active
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
// Execute step on a given scene
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
// Setup import settings
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
// -------------------------------------------------------------------
// Execute step on a given mesh

View File

@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PostProcessing/ProcessHelper.h"
class FindInstancesProcessTest;
namespace Assimp {
// -------------------------------------------------------------------------------
@ -60,8 +61,7 @@ namespace Assimp {
* @param in Input mesh
* @return Hash.
*/
inline
uint64_t GetMeshHash(aiMesh* in) {
inline uint64_t GetMeshHash(aiMesh* in) {
ai_assert(nullptr != in);
// ... get an unique value representing the vertex format of the mesh
@ -83,8 +83,7 @@ uint64_t GetMeshHash(aiMesh* in) {
* @param e Epsilon
* @return true if the arrays are identical
*/
inline
bool CompareArrays(const aiVector3D* first, const aiVector3D* second,
inline bool CompareArrays(const aiVector3D* first, const aiVector3D* second,
unsigned int size, float e) {
for (const aiVector3D* end = first+size; first != end; ++first,++second) {
if ( (*first - *second).SquareLength() >= e)
@ -114,15 +113,15 @@ public:
// -------------------------------------------------------------------
// Check whether step is active in given flags combination
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
// Execute step on a given scene
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
// Setup properties prior to executing the process
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
private:
bool configSpeedFlag;

View File

@ -71,15 +71,15 @@ public:
// -------------------------------------------------------------------
/// Returns active state.
bool IsActive(unsigned int pFlags) const;
bool IsActive(unsigned int pFlags) const override;
// -------------------------------------------------------------------
/// Setup import settings
void SetupProperties(const Importer *pImp);
void SetupProperties(const Importer *pImp) override;
// -------------------------------------------------------------------
/// Run the step
void Execute(aiScene *pScene);
void Execute(aiScene *pScene) override;
// -------------------------------------------------------------------
/// Executes the post-processing step on the given mesh

View File

@ -69,14 +69,14 @@ public:
* combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
protected:

View File

@ -66,15 +66,14 @@ public:
* combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
private:
bool GenMeshFaceNormals(aiMesh* pcMesh);

View File

@ -72,22 +72,21 @@ public:
* @return true if the process is present in this flag fields,
* false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Called prior to ExecuteOnScene().
* The function is a request to the process to update its configuration
* basing on the Importer's configuration property list.
*/
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// setter for configMaxAngle
inline void SetMaxSmoothAngle(ai_real f) {

View File

@ -69,15 +69,15 @@ public:
// -------------------------------------------------------------------
// Check whether the pp step is active
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
// Executes the pp step on a given scene
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
// Configures the pp step
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
protected:
// -------------------------------------------------------------------

View File

@ -74,14 +74,14 @@ public:
* combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
/** Unites identical vertices in the given mesh.

View File

@ -86,27 +86,27 @@ public:
* @return true if the process is present in this flag fields,
* false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Called prior to ExecuteOnScene().
* The function is a request to the process to update its configuration
* basing on the Importer's configuration property list.
*/
void SetupProperties(const Importer* pImp);
// -------------------------------------------------------------------
/** Limits the bone weight count for all vertices in the given mesh.
* @param pMesh The mesh to process.
*/
void ProcessMesh( aiMesh* pMesh);
void SetupProperties(const Importer* pImp) override;
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
/** Limits the bone weight count for all vertices in the given mesh.
* @param pMesh The mesh to process.
*/
void ProcessMesh( aiMesh* pMesh);
// -------------------------------------------------------------------
/** Describes a bone weight on a vertex */

View File

@ -78,7 +78,7 @@ public:
* @param pFlags The processing flags the importer was called with. A bitwise
* combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not */
bool IsActive( unsigned int /*pFlags*/ ) const
bool IsActive( unsigned int /*pFlags*/ ) const override
{
// NOTE: There is no direct flag that corresponds to
// this postprocess step.
@ -89,7 +89,7 @@ public:
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at. */
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
public:

View File

@ -93,16 +93,14 @@ public:
unsigned int output_id;
};
public:
// -------------------------------------------------------------------
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
// -------------------------------------------------------------------
/** @brief Specify whether you want meshes with different

View File

@ -66,15 +66,15 @@ public:
// -------------------------------------------------------------------
// Check whether step is active
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
// Execute step on a given scene
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
// Setup import settings
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
// -------------------------------------------------------------------
/** @brief Set list of fixed (inmutable) materials

View File

@ -69,37 +69,35 @@ public:
* combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
/** Called prior to ExecuteOnScene().
* The function is a request to the process to update its configuration
* basing on the Importer's configuration property list.
*/
virtual void SetupProperties(const Importer* pImp);
virtual void SetupProperties(const Importer* pImp) override;
// -------------------------------------------------------------------
/** Manually setup the configuration flags for the step
*
* @param Bitwise combination of the #aiComponent enumerated values.
*/
void SetDeleteFlags(unsigned int f)
{
void SetDeleteFlags(unsigned int f) {
configDeleteFlags = f;
}
// -------------------------------------------------------------------
/** Query the current configuration.
*/
unsigned int GetDeleteFlags() const
{
unsigned int GetDeleteFlags() const {
return configDeleteFlags;
}

View File

@ -74,13 +74,13 @@ public:
ai_real getScale() const;
/// Overwritten, @see BaseProcess
virtual bool IsActive( unsigned int pFlags ) const;
virtual bool IsActive( unsigned int pFlags ) const override;
/// Overwritten, @see BaseProcess
virtual void SetupProperties( const Importer* pImp );
virtual void SetupProperties( const Importer* pImp ) override;
/// Overwritten, @see BaseProcess
virtual void Execute( aiScene* pScene );
virtual void Execute( aiScene* pScene ) override;
private:
void traverseNodes( aiNode *currentNode, unsigned int nested_node_id = 0 );

View File

@ -66,13 +66,13 @@ public:
~SortByPTypeProcess() override = default;
// -------------------------------------------------------------------
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
private:
int mConfigRemoveMeshes;

View File

@ -75,7 +75,7 @@ public:
/// @brief Called prior to ExecuteOnScene().
/// The function is a request to the process to update its configuration
/// basing on the Importer's configuration property list.
virtual void SetupProperties(const Importer* pImp);
virtual void SetupProperties(const Importer* pImp) override;
protected:
/// Executes the post processing step on the given imported data.

View File

@ -99,7 +99,7 @@ public:
* @return true if the process is present in this flag fields,
* false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Called prior to ExecuteOnScene().
@ -121,7 +121,7 @@ public:
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
//! Apply the algorithm to a given mesh

View File

@ -201,14 +201,13 @@ public:
~TextureTransformStep() override = default;
// -------------------------------------------------------------------
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer* pImp) override;
protected:
// -------------------------------------------------------------------

View File

@ -72,14 +72,14 @@ public:
* combination of #aiPostProcessSteps.
* @return true if the process is present in this flag fields, false if not.
*/
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
/** Executes the post processing step on the given imported data.
* At the moment a process is not supposed to fail.
* @param pScene The imported data to work at.
*/
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
// -------------------------------------------------------------------
/** Triangulates the given mesh.

View File

@ -69,8 +69,7 @@ namespace Assimp {
/** Validates the whole ASSIMP scene data structure for correctness.
* ImportErrorException is thrown of the scene is corrupt.*/
// --------------------------------------------------------------------------------------
class ValidateDSProcess : public BaseProcess
{
class ValidateDSProcess : public BaseProcess {
public:
// -------------------------------------------------------------------
/// The default class constructor / destructor.
@ -78,13 +77,12 @@ public:
~ValidateDSProcess() override = default;
// -------------------------------------------------------------------
bool IsActive( unsigned int pFlags) const;
bool IsActive( unsigned int pFlags) const override;
// -------------------------------------------------------------------
void Execute( aiScene* pScene);
void Execute( aiScene* pScene) override;
protected:
// -------------------------------------------------------------------
/** Report a validation error. This will throw an exception,
* control won't return.