fix warnings

pull/3012/head
kkulling 2020-03-11 09:43:55 +01:00
parent 02e5698a38
commit f8757322be
12 changed files with 331 additions and 344 deletions

View File

@ -5,8 +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,

View File

@ -70,7 +70,7 @@ namespace
template<>
size_t select_ftell<8>(FILE* file)
{
return ::_ftelli64(file);
return (size_t)::_ftelli64(file);
}
template<>

View File

@ -5,8 +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,
@ -74,6 +72,7 @@ typedef int32_t ai_int32;
typedef uint32_t ai_uint32;
#ifdef __cplusplus
#include <cstring>
#include <new> // for std::nothrow_t
#include <string> // for aiString::Set(const std::string&)

View File

@ -49,7 +49,9 @@ using namespace Assimp;
class TestProgressHandler : public ProgressHandler {
public:
TestProgressHandler() : ProgressHandler() {
TestProgressHandler() :
ProgressHandler(),
mPercentage (0.f) {
// empty
}
@ -60,6 +62,7 @@ public:
bool Update(float percentage = -1.f) override {
return true;
}
float mPercentage;
};
class ExporterTest : public ::testing::Test {
@ -79,8 +82,7 @@ TEST_F(ExporterTest, ExporterIdTest) {
EXPECT_NE(0u, exportFormatCount) << "No registered exporters";
typedef std::map<std::string, const aiExportFormatDesc *> ExportIdMap;
ExportIdMap exporterMap;
for (size_t i = 0; i < exportFormatCount; ++i)
{
for (size_t i = 0; i < exportFormatCount; ++i) {
// Check that the exporter description exists and makes sense
const aiExportFormatDesc *desc = exporter.GetExportFormatDescription(i);
ASSERT_NE(nullptr, desc) << "Missing aiExportFormatDesc at index " << i;

View File

@ -88,8 +88,6 @@ bool SceneDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) {
}
}
// ToDo!
return true;
// materials
if ( expected->mNumMaterials != toCompare->mNumMaterials ) {
std::stringstream stream;
@ -112,6 +110,7 @@ bool SceneDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) {
std::stringstream stream;
stream << "Materials are not equal, index : " << i << "\n";
addDiff( stream.str() );
return false;
}
}

View File

@ -41,13 +41,13 @@ 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 "SceneDiffer.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
using namespace Assimp;
@ -240,8 +240,7 @@ TEST_F( utObjImportExport, obj_import_test ) {
differ.showReport();
m_im->FreeScene();
for(unsigned int i = 0; i < expected->mNumMeshes; ++i)
{
for (unsigned int i = 0; i < expected->mNumMeshes; ++i) {
delete expected->mMeshes[i];
}
delete[] expected->mMeshes;
@ -290,7 +289,7 @@ TEST_F( utObjImportExport, issue1923_vertex_color_Test ) {
}
TEST_F(utObjImportExport, issue1453_segfault) {
static const char *ObjModel =
static const char *CurObjModel =
"v 0.0 0.0 0.0\n"
"v 0.0 0.0 1.0\n"
"v 0.0 1.0 0.0\n"
@ -301,12 +300,12 @@ TEST_F( utObjImportExport, issue1453_segfault ) {
"v 1.0 1.0 1.0\nB";
Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory( ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure );
const aiScene *scene = myimporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), aiProcess_ValidateDataStructure);
EXPECT_EQ(nullptr, scene);
}
TEST_F(utObjImportExport, relative_indices_Test) {
static const char *ObjModel =
static const char *CurObjModel =
"v -0.500000 0.000000 0.400000\n"
"v -0.500000 0.000000 -0.800000\n"
"v -0.500000 1.000000 -0.800000\n"
@ -314,7 +313,7 @@ TEST_F(utObjImportExport, relative_indices_Test) {
"f -4 -3 -2 -1\nB";
Assimp::Importer myimporter;
const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), aiProcess_ValidateDataStructure);
const aiScene *scene = myimporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mNumMeshes, 1U);
@ -323,22 +322,20 @@ TEST_F(utObjImportExport, relative_indices_Test) {
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)
{
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
EXPECT_EQ(face.mIndices[i], i);
}
}
TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
static const char *ObjModel =
static const char *CurObjModel =
"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, strlen(ObjModel), aiProcess_ValidateDataStructure);
const aiScene *scene = myimporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mNumMeshes, 1U);
@ -354,31 +351,31 @@ TEST_F(utObjImportExport, homogeneous_coordinates_Test) {
}
TEST_F(utObjImportExport, homogeneous_coordinates_divide_by_zero_Test) {
static const char *ObjModel =
static const char *CurObjModel =
"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, strlen(ObjModel), aiProcess_ValidateDataStructure);
const aiScene *scene = myimporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), aiProcess_ValidateDataStructure);
EXPECT_EQ(nullptr, scene);
}
TEST_F(utObjImportExport, 0based_array_Test) {
static const char *ObjModel =
static const char *CurObjModel =
"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, strlen(ObjModel), 0);
const aiScene *scene = myImporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), 0);
EXPECT_EQ(nullptr, scene);
}
TEST_F(utObjImportExport, invalid_normals_uvs) {
static const char *ObjModel =
static const char *CurObjModel =
"v -0.500000 0.000000 0.400000\n"
"v -0.500000 0.000000 -0.800000\n"
"v -0.500000 1.000000 -0.800000\n"
@ -387,12 +384,12 @@ TEST_F(utObjImportExport, invalid_normals_uvs) {
"f 1/1/1 1/1/1 2/2/2\nB";
Assimp::Importer myImporter;
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
const aiScene *scene = myImporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), 0);
EXPECT_NE(nullptr, scene);
}
TEST_F(utObjImportExport, no_vt_just_vns) {
static const char *ObjModel =
static const char *CurObjModel =
"v 0 0 0\n"
"v 0 0 0\n"
"v 0 0 0\n"
@ -420,7 +417,7 @@ TEST_F(utObjImportExport, no_vt_just_vns) {
"f 10/10 11/11 12/12\n";
Assimp::Importer myImporter;
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
const aiScene *scene = myImporter.ReadFileFromMemory(CurObjModel, strlen(CurObjModel), 0);
EXPECT_NE(nullptr, scene);
}

View File

@ -183,7 +183,7 @@ TEST_F(SortByPTypeProcessTest, SortByPTypeStep) {
unsigned int idx = 0;
for (unsigned int m = 0,real = 0; m< 10;++m) {
for (unsigned int n = 0; n < 4;++n) {
idx = num[m][n])
idx = num[m][n];
if (idx) {
EXPECT_TRUE(real < mScene->mNumMeshes);

View File

@ -112,10 +112,10 @@ TEST_F(TriangulateProcessTest, testTriangulation) {
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);
const aiFace& curFace = pcMesh->mFaces[m];
EXPECT_EQ(3U, curFace.mNumIndices);
for (unsigned int qqq = 0; qqq < face.mNumIndices; ++qqq) {
for (unsigned int qqq = 0; qqq < curFace.mNumIndices; ++qqq) {
ait[face.mIndices[qqq]-idx] = true;
}
}

View File

@ -142,9 +142,9 @@ int Assimp_Export(const char* const* params, unsigned int num)
// if no output file is specified, take the file name from input file
if (out[0] == '-') {
std::string::size_type s = in.find_last_of('.');
if (s == std::string::npos) {
s = in.length();
std::string::size_type pos = in.find_last_of('.');
if (pos == std::string::npos) {
pos = in.length();
}
out = in.substr(0,s);

View File

@ -155,7 +155,7 @@ int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int
info.biWidth = width;
info.biHeight = height;
info.biPlanes = 1;
info.biBitCount = numc<<3;
info.biBitCount = (int16_t) numc<<3;
info.biCompression = 0;
info.biSizeImage = width*height*numc;
info.biXPelsPerMeter = 1; // dummy

View File

@ -56,8 +56,7 @@ const char* AICMD_MSG_DUMP_HELP =
"\t[See the assimp_cmd docs for a full list of all common parameters] \n"
"\t -cfast Fast post processing preset, runs just a few important steps \n"
"\t -cdefault Default post processing: runs all recommended steps\n"
"\t -cfull Fires almost all post processing steps \n"
;
"\t -cfull Fires almost all post processing steps \n";
#include "Common/assbin_chunks.h"
#include <assimp/DefaultIOSystem.h>
@ -70,8 +69,7 @@ FILE* out = NULL;
bool shortened = false;
// -----------------------------------------------------------------------------------
int Assimp_Dump (const char* const* params, unsigned int num)
{
int Assimp_Dump(const char *const *params, unsigned int num) {
const char *fail = "assimp dump: Invalid number of arguments. "
"See \'assimp dump --help\'\r\n";
@ -81,18 +79,18 @@ int Assimp_Dump (const char* const* params, unsigned int num)
return AssimpCmdError::Success;
}
// asssimp dump in out [options]
// assimp dump in out [options]
if (num < 1) {
printf("%s", fail);
return AssimpCmdError::InvalidNumberOfArguments;
}
std::string in = std::string(params[0]);
std::string out = (num > 1 ? std::string(params[1]) : std::string("-"));
std::string cur_out = (num > 1 ? std::string(params[1]) : std::string("-"));
// store full command line
std::string cmd;
for (unsigned int i = (out[0] == '-' ? 1 : 2); i < num;++i) {
for (unsigned int i = (cur_out[0] == '-' ? 1 : 2); i < num; ++i) {
if (!params[i]) continue;
cmd.append(params[i]);
cmd.append(" ");
@ -102,18 +100,16 @@ int Assimp_Dump (const char* const* params, unsigned int num)
ImportData import;
ProcessStandardArguments(import, params + 1, num - 1);
bool binary = false, shortened = false,compressed=false;
bool binary = false, cur_shortened = false, compressed = false;
// process other flags
for (unsigned int i = 1; i < num; ++i) {
if (!params[i]) continue;
if (!strcmp(params[i], "-b") || !strcmp(params[i], "--binary")) {
binary = true;
}
else if (!strcmp( params[i], "-s") || !strcmp( params[i], "--short")) {
shortened = true;
}
else if (!strcmp( params[i], "-z") || !strcmp( params[i], "--compressed")) {
} else if (!strcmp(params[i], "-s") || !strcmp(params[i], "--short")) {
cur_shortened = true;
} else if (!strcmp(params[i], "-z") || !strcmp(params[i], "--compressed")) {
compressed = true;
}
#if 0
@ -124,17 +120,17 @@ int Assimp_Dump (const char* const* params, unsigned int num)
#endif
}
if (out[0] == '-') {
if (cur_out[0] == '-') {
// take file name from input file
std::string::size_type s = in.find_last_of('.');
if (s == std::string::npos) {
s = in.length();
}
out = in.substr(0,s);
out.append((binary ? ".assbin" : ".assxml"));
if (shortened && binary) {
out.append(".regress");
cur_out = in.substr(0, s);
cur_out.append((binary ? ".assbin" : ".assxml"));
if (cur_shortened && binary) {
cur_out.append(".regress");
}
}
@ -149,19 +145,16 @@ int Assimp_Dump (const char* const* params, unsigned int num)
// Dump the main model, using the appropriate method.
std::unique_ptr<IOSystem> pIOSystem(new DefaultIOSystem());
if (binary) {
DumpSceneToAssbin(out.c_str(), cmd.c_str(), pIOSystem.get(),
DumpSceneToAssbin(cur_out.c_str(), cmd.c_str(), pIOSystem.get(),
scene, shortened, compressed);
}
else {
DumpSceneToAssxml(out.c_str(), cmd.c_str(), pIOSystem.get(),
} else {
DumpSceneToAssxml(cur_out.c_str(), cmd.c_str(), pIOSystem.get(),
scene, shortened);
}
}
catch (const std::exception& e) {
} catch (const std::exception &e) {
printf("%s", ("assimp dump: " + std::string(e.what())).c_str());
return AssimpCmdError::ExceptionWasRaised;
}
catch (...) {
} catch (...) {
printf("assimp dump: An unknown exception occured.\n");
return AssimpCmdError::ExceptionWasRaised;
}
@ -169,4 +162,3 @@ int Assimp_Dump (const char* const* params, unsigned int num)
printf("assimp dump: Wrote output dump %s\n", out.c_str());
return AssimpCmdError::Success;
}