diff --git a/Readme.md b/Readme.md
index 9fecfedf5..81fd9fd9d 100644
--- a/Readme.md
+++ b/Readme.md
@@ -8,10 +8,10 @@ A library to import and export various 3d-model-formats including scene-post-pro
+[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9973693b7bdd4543b07084d5d9cf4745)](https://www.codacy.com/gh/assimp/assimp/dashboard?utm_source=github.com&utm_medium=referral&utm_content=assimp/assimp&utm_campaign=Badge_Grade)
[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
[![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue")
-[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5be56faac64f46fc941ac890fb4febef)](https://www.codacy.com/app/kimkulling/assimp?utm_source=github.com&utm_medium=referral&utm_content=assimp/assimp&utm_campaign=Badge_Grade)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/assimp/assimp.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/assimp/assimp/alerts/)
diff --git a/code/AssetLib/3DS/3DSConverter.cpp b/code/AssetLib/3DS/3DSConverter.cpp
index 12ac7e69e..aca16b0d6 100644
--- a/code/AssetLib/3DS/3DSConverter.cpp
+++ b/code/AssetLib/3DS/3DSConverter.cpp
@@ -69,7 +69,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() {
for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) {
std::string s = mScene->mMaterials[i].mName;
for (std::string::iterator it = s.begin(); it != s.end(); ++it) {
- *it = static_cast(::tolower(*it));
+ *it = static_cast(::tolower(static_cast(*it)));
}
if (std::string::npos == s.find("default")) continue;
@@ -212,7 +212,7 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material &oldMat,
mat.AddProperty(&tex, AI_MATKEY_GLOBAL_BACKGROUND_IMAGE);
// Be sure this is only done for the first material
- mBackgroundImage = std::string("");
+ mBackgroundImage = std::string();
}
// At first add the base ambient color of the scene to the material
diff --git a/code/AssetLib/3DS/3DSExporter.cpp b/code/AssetLib/3DS/3DSExporter.cpp
index 108d917d1..07e9ccfc7 100644
--- a/code/AssetLib/3DS/3DSExporter.cpp
+++ b/code/AssetLib/3DS/3DSExporter.cpp
@@ -102,13 +102,14 @@ private:
// preserves the mesh's given name if it has one. |index| is the index
// of the mesh in |aiScene::mMeshes|.
std::string GetMeshName(const aiMesh &mesh, unsigned int index, const aiNode &node) {
- static const std::string underscore = "_";
+ static const char underscore = '_';
char postfix[10] = { 0 };
ASSIMP_itoa10(postfix, index);
std::string result = node.mName.C_Str();
if (mesh.mName.length > 0) {
- result += underscore + mesh.mName.C_Str();
+ result += underscore;
+ result += mesh.mName.C_Str();
}
return result + underscore + postfix;
}
diff --git a/code/AssetLib/3DS/3DSHelper.h b/code/AssetLib/3DS/3DSHelper.h
index f3f9efb25..1930c0c40 100644
--- a/code/AssetLib/3DS/3DSHelper.h
+++ b/code/AssetLib/3DS/3DSHelper.h
@@ -61,20 +61,10 @@ namespace D3DS {
#include
// ---------------------------------------------------------------------------
-/** Discreet3DS class: Helper class for loading 3ds files. Defines chunks
-* and data structures.
+/** Defines chunks and data structures.
*/
-class Discreet3DS {
-private:
- Discreet3DS() AI_NO_EXCEPT {
- // empty
- }
+namespace Discreet3DS {
- ~Discreet3DS() {
- // empty
- }
-
-public:
//! data structure for a single chunk in a .3ds file
struct Chunk {
uint16_t Flag;
@@ -314,7 +304,7 @@ public:
// camera sub-chunks
CHUNK_CAM_RANGES = 0x4720
};
-};
+}
// ---------------------------------------------------------------------------
/** Helper structure representing a 3ds mesh face */
diff --git a/code/AssetLib/3DS/3DSLoader.cpp b/code/AssetLib/3DS/3DSLoader.cpp
index 0a64f6870..92fe72bbf 100644
--- a/code/AssetLib/3DS/3DSLoader.cpp
+++ b/code/AssetLib/3DS/3DSLoader.cpp
@@ -143,7 +143,13 @@ void Discreet3DSImporter::SetupProperties(const Importer * /*pImp*/) {
// Imports the given file into the given scene structure.
void Discreet3DSImporter::InternReadFile(const std::string &pFile,
aiScene *pScene, IOSystem *pIOHandler) {
- StreamReaderLE theStream(pIOHandler->Open(pFile, "rb"));
+
+ auto theFile = pIOHandler->Open(pFile, "rb");
+ if (!theFile) {
+ throw DeadlyImportError("3DS: Could not open ", pFile);
+ }
+
+ StreamReaderLE theStream(theFile);
// We should have at least one chunk
if (theStream.GetRemainingSize() < 16) {
@@ -164,7 +170,7 @@ void Discreet3DSImporter::InternReadFile(const std::string &pFile,
mRootNode->mHierarchyIndex = -1;
mRootNode->mParent = nullptr;
mMasterScale = 1.0f;
- mBackgroundImage = "";
+ mBackgroundImage = std::string();
bHasBG = false;
bIsPrj = false;
@@ -981,9 +987,9 @@ void Discreet3DSImporter::ParseMeshChunk() {
mMesh.mMat.a3 = stream->GetF4();
mMesh.mMat.b3 = stream->GetF4();
mMesh.mMat.c3 = stream->GetF4();
- mMesh.mMat.d1 = stream->GetF4();
- mMesh.mMat.d2 = stream->GetF4();
- mMesh.mMat.d3 = stream->GetF4();
+ mMesh.mMat.a4 = stream->GetF4();
+ mMesh.mMat.b4 = stream->GetF4();
+ mMesh.mMat.c4 = stream->GetF4();
} break;
case Discreet3DS::CHUNK_MAPLIST: {
diff --git a/code/AssetLib/3MF/3MFXmlTags.h b/code/AssetLib/3MF/3MFXmlTags.h
index 3996c60e5..d447556d6 100644
--- a/code/AssetLib/3MF/3MFXmlTags.h
+++ b/code/AssetLib/3MF/3MFXmlTags.h
@@ -44,63 +44,66 @@ namespace Assimp {
namespace D3MF {
namespace XmlTag {
+ // Root tag
+ const char* const RootTag = "3MF";
+
// Meta-data
- static const std::string meta = "metadata";
- static const std::string meta_name = "name";
+ const char* const meta = "metadata";
+ const char* const meta_name = "name";
// Model-data specific tags
- static const std::string model = "model";
- static const std::string model_unit = "unit";
- static const std::string metadata = "metadata";
- static const std::string resources = "resources";
- static const std::string object = "object";
- static const std::string mesh = "mesh";
- static const std::string components = "components";
- static const std::string component = "component";
- static const std::string vertices = "vertices";
- static const std::string vertex = "vertex";
- static const std::string triangles = "triangles";
- static const std::string triangle = "triangle";
- static const std::string x = "x";
- static const std::string y = "y";
- static const std::string z = "z";
- static const std::string v1 = "v1";
- static const std::string v2 = "v2";
- static const std::string v3 = "v3";
- static const std::string id = "id";
- static const std::string pid = "pid";
- static const std::string pindex = "pindex";
- static const std::string p1 = "p1";
- static const std::string name = "name";
- static const std::string type = "type";
- static const std::string build = "build";
- static const std::string item = "item";
- static const std::string objectid = "objectid";
- static const std::string transform = "transform";
+ const char* const model = "model";
+ const char* const model_unit = "unit";
+ const char* const metadata = "metadata";
+ const char* const resources = "resources";
+ const char* const object = "object";
+ const char* const mesh = "mesh";
+ const char* const components = "components";
+ const char* const component = "component";
+ const char* const vertices = "vertices";
+ const char* const vertex = "vertex";
+ const char* const triangles = "triangles";
+ const char* const triangle = "triangle";
+ const char* const x = "x";
+ const char* const y = "y";
+ const char* const z = "z";
+ const char* const v1 = "v1";
+ const char* const v2 = "v2";
+ const char* const v3 = "v3";
+ const char* const id = "id";
+ const char* const pid = "pid";
+ const char* const pindex = "pindex";
+ const char* const p1 = "p1";
+ const char* const name = "name";
+ const char* const type = "type";
+ const char* const build = "build";
+ const char* const item = "item";
+ const char* const objectid = "objectid";
+ const char* const transform = "transform";
// Material definitions
- static const std::string basematerials = "basematerials";
- static const std::string basematerials_id = "id";
- static const std::string basematerials_base = "base";
- static const std::string basematerials_name = "name";
- static const std::string basematerials_displaycolor = "displaycolor";
+ const char* const basematerials = "basematerials";
+ const char* const basematerials_id = "id";
+ const char* const basematerials_base = "base";
+ const char* const basematerials_name = "name";
+ const char* const basematerials_displaycolor = "displaycolor";
// Meta info tags
- static const std::string CONTENT_TYPES_ARCHIVE = "[Content_Types].xml";
- static const std::string ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels";
- static const std::string SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
- static const std::string SCHEMA_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
- static const std::string RELS_RELATIONSHIP_CONTAINER = "Relationships";
- static const std::string RELS_RELATIONSHIP_NODE = "Relationship";
- static const std::string RELS_ATTRIB_TARGET = "Target";
- static const std::string RELS_ATTRIB_TYPE = "Type";
- static const std::string RELS_ATTRIB_ID = "Id";
- static const std::string PACKAGE_START_PART_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel";
- static const std::string PACKAGE_PRINT_TICKET_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket";
- static const std::string PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture";
- static const std::string PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
- static const std::string PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
-}
+ const char* const CONTENT_TYPES_ARCHIVE = "[Content_Types].xml";
+ const char* const ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels";
+ const char* const SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
+ const char* const SCHEMA_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
+ const char* const RELS_RELATIONSHIP_CONTAINER = "Relationships";
+ const char* const RELS_RELATIONSHIP_NODE = "Relationship";
+ const char* const RELS_ATTRIB_TARGET = "Target";
+ const char* const RELS_ATTRIB_TYPE = "Type";
+ const char* const RELS_ATTRIB_ID = "Id";
+ const char* const PACKAGE_START_PART_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel";
+ const char* const PACKAGE_PRINT_TICKET_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket";
+ const char* const PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture";
+ const char* const PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
+ const char* const PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
+ }
} // Namespace D3MF
} // Namespace Assimp
diff --git a/code/AssetLib/3MF/D3MFExporter.cpp b/code/AssetLib/3MF/D3MFExporter.cpp
index 4a16a0ad3..76a601cbe 100644
--- a/code/AssetLib/3MF/D3MFExporter.cpp
+++ b/code/AssetLib/3MF/D3MFExporter.cpp
@@ -307,18 +307,26 @@ void D3MFExporter::writeMesh(aiMesh *mesh) {
return;
}
- mModelOutput << "<" << XmlTag::mesh << ">" << std::endl;
- mModelOutput << "<" << XmlTag::vertices << ">" << std::endl;
+ mModelOutput << "<"
+ << XmlTag::mesh
+ << ">" << "\n";
+ mModelOutput << "<"
+ << XmlTag::vertices
+ << ">" << "\n";
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
writeVertex(mesh->mVertices[i]);
}
- mModelOutput << "" << XmlTag::vertices << ">" << std::endl;
+ mModelOutput << ""
+ << XmlTag::vertices << ">"
+ << "\n";
const unsigned int matIdx(mesh->mMaterialIndex);
writeFaces(mesh, matIdx);
- mModelOutput << "" << XmlTag::mesh << ">" << std::endl;
+ mModelOutput << ""
+ << XmlTag::mesh << ">"
+ << "\n";
}
void D3MFExporter::writeVertex(const aiVector3D &pos) {
@@ -334,27 +342,34 @@ void D3MFExporter::writeFaces(aiMesh *mesh, unsigned int matIdx) {
if (!mesh->HasFaces()) {
return;
}
- mModelOutput << "<" << XmlTag::triangles << ">" << std::endl;
+ mModelOutput << "<"
+ << XmlTag::triangles << ">"
+ << "\n";
for (unsigned int i = 0; i < mesh->mNumFaces; ++i) {
aiFace ¤tFace = mesh->mFaces[i];
mModelOutput << "<" << XmlTag::triangle << " v1=\"" << currentFace.mIndices[0] << "\" v2=\""
<< currentFace.mIndices[1] << "\" v3=\"" << currentFace.mIndices[2]
<< "\" pid=\"1\" p1=\"" + ai_to_string(matIdx) + "\" />";
- mModelOutput << std::endl;
+ mModelOutput << "\n";
}
- mModelOutput << "" << XmlTag::triangles << ">";
- mModelOutput << std::endl;
+ mModelOutput << ""
+ << XmlTag::triangles
+ << ">";
+ mModelOutput << "\n";
}
void D3MFExporter::writeBuild() {
- mModelOutput << "<" << XmlTag::build << ">" << std::endl;
+ mModelOutput << "<"
+ << XmlTag::build
+ << ">"
+ << "\n";
for (size_t i = 0; i < mBuildItems.size(); ++i) {
mModelOutput << "<" << XmlTag::item << " objectid=\"" << i + 2 << "\"/>";
- mModelOutput << std::endl;
+ mModelOutput << "\n";
}
mModelOutput << "" << XmlTag::build << ">";
- mModelOutput << std::endl;
+ mModelOutput << "\n";
}
void D3MFExporter::zipContentType(const std::string &filename) {
diff --git a/code/AssetLib/3MF/D3MFImporter.cpp b/code/AssetLib/3MF/D3MFImporter.cpp
index f4ddb6054..747af7cfc 100644
--- a/code/AssetLib/3MF/D3MFImporter.cpp
+++ b/code/AssetLib/3MF/D3MFImporter.cpp
@@ -42,6 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
#include "D3MFImporter.h"
+#include "3MFXmlTags.h"
+#include "D3MFOpcPackage.h"
#include
#include
@@ -51,17 +53,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#include
#include
+#include
+
#include
#include