Fix static-code findings,

This commit is contained in:
Kim Kulling
2020-03-15 12:16:17 +01:00
parent 976091a6f6
commit 856ca9f2dd
7 changed files with 317 additions and 355 deletions

View File

@@ -5,7 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -47,12 +46,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_PLY_IMPORTER
// internal headers
#include "PlyLoader.h"
#include <assimp/IOStreamBuffer.h>
#include <assimp/importerdesc.h>
#include <assimp/scene.h>
#include <assimp/IOSystem.hpp>
#include <memory>
# include "PlyLoader.h"
# include <assimp/IOStreamBuffer.h>
# include <assimp/importerdesc.h>
# include <assimp/scene.h>
# include <assimp/IOSystem.hpp>
# include <memory>
using namespace ::Assimp;
@@ -87,7 +86,9 @@ inline const T &GetProperty(const std::vector<T> &props, int idx) {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
PLYImporter::PLYImporter() :
mBuffer(nullptr), pcDOM(nullptr), mGeneratedMesh(nullptr) {
mBuffer(nullptr),
pcDOM(nullptr),
mGeneratedMesh(nullptr) {
// empty
}
@@ -127,15 +128,15 @@ static bool isBigEndian(const char *szMe) {
// binary_little_endian
// binary_big_endian
bool isBigEndian(false);
#if (defined AI_BUILD_BIG_ENDIAN)
# if (defined AI_BUILD_BIG_ENDIAN)
if ('l' == *szMe || 'L' == *szMe) {
isBigEndian = true;
}
#else
# else
if ('b' == *szMe || 'B' == *szMe) {
isBigEndian = true;
}
#endif // ! AI_BUILD_BIG_ENDIAN
# endif // ! AI_BUILD_BIG_ENDIAN
return isBigEndian;
}

View File

@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -46,9 +45,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_PLYLOADER_H_INCLUDED
#define AI_PLYLOADER_H_INCLUDED
#include "PlyParser.h"
#include <assimp/BaseImporter.h>
#include <assimp/types.h>
#include "PlyParser.h"
#include <vector>
struct aiNode;
@@ -62,77 +61,72 @@ using namespace PLY;
// ---------------------------------------------------------------------------
/** Importer class to load the stanford PLY file format
*/
class PLYImporter : public BaseImporter
{
class PLYImporter : public BaseImporter {
public:
PLYImporter();
~PLYImporter();
public:
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
* See BaseImporter::CanRead() for details.
*/
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
bool checkSig) const;
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
bool checkSig) const;
// -------------------------------------------------------------------
/** Extract a vertex from the DOM
*/
void LoadVertex(const PLY::Element* pcElement, const PLY::ElementInstance* instElement, unsigned int pos);
void LoadVertex(const PLY::Element *pcElement, const PLY::ElementInstance *instElement, unsigned int pos);
// -------------------------------------------------------------------
/** Extract a face from the DOM
*/
void LoadFace(const PLY::Element* pcElement, const PLY::ElementInstance* instElement, unsigned int pos);
void LoadFace(const PLY::Element *pcElement, const PLY::ElementInstance *instElement, unsigned int pos);
protected:
// -------------------------------------------------------------------
/** Return importer meta information.
* See #BaseImporter::GetInfo for the details
*/
const aiImporterDesc* GetInfo () const;
const aiImporterDesc *GetInfo() const;
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
* See BaseImporter::InternReadFile() for details
*/
void InternReadFile( const std::string& pFile, aiScene* pScene,
IOSystem* pIOHandler);
void InternReadFile(const std::string &pFile, aiScene *pScene,
IOSystem *pIOHandler);
protected:
// -------------------------------------------------------------------
/** Extract a material list from the DOM
*/
void LoadMaterial(std::vector<aiMaterial*>* pvOut, std::string &defaultTexture, const bool pointsOnly);
void LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &defaultTexture, const bool pointsOnly);
// -------------------------------------------------------------------
/** Static helper to parse a color from four single channels in
*/
static void GetMaterialColor(
const std::vector<PLY::PropertyInstance>& avList,
unsigned int aiPositions[4],
PLY::EDataType aiTypes[4],
aiColor4D* clrOut);
const std::vector<PLY::PropertyInstance> &avList,
unsigned int aiPositions[4],
PLY::EDataType aiTypes[4],
aiColor4D *clrOut);
// -------------------------------------------------------------------
/** Static helper to parse a color channel value. The input value
* is normalized to 0-1.
*/
static ai_real NormalizeColorValue (
PLY::PropertyInstance::ValueUnion val,
PLY::EDataType eType);
static ai_real NormalizeColorValue(
PLY::PropertyInstance::ValueUnion val,
PLY::EDataType eType);
/** Buffer to hold the loaded file */
unsigned char* mBuffer;
unsigned char *mBuffer;
/** Document object model representation extracted from the file */
PLY::DOM* pcDOM;
PLY::DOM *pcDOM;
/** Mesh generated by loader */
aiMesh* mGeneratedMesh;
aiMesh *mGeneratedMesh;
};
} // end of namespace Assimp