|
@@ -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 <assimp/StringComparison.h>
|
|
|
#include <assimp/StringUtils.h>
|
|
@@ -51,17 +53,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
#include <assimp/scene.h>
|
|
|
#include <assimp/DefaultLogger.hpp>
|
|
|
#include <assimp/IOSystem.hpp>
|
|
|
+#include <assimp/fast_atof.h>
|
|
|
+
|
|
|
#include <cassert>
|
|
|
#include <map>
|
|
|
#include <memory>
|
|
|
#include <string>
|
|
|
#include <vector>
|
|
|
-
|
|
|
-#include "3MFXmlTags.h"
|
|
|
-#include "D3MFOpcPackage.h"
|
|
|
-#include <assimp/fast_atof.h>
|
|
|
-
|
|
|
#include <iomanip>
|
|
|
+#include <string.h>
|
|
|
|
|
|
namespace Assimp {
|
|
|
namespace D3MF {
|
|
@@ -72,32 +72,39 @@ enum class ResourceType {
|
|
|
RT_Unknown
|
|
|
}; // To be extended with other resource types (eg. material extension resources like Texture2d, Texture2dGroup...)
|
|
|
|
|
|
-class Resource
|
|
|
-{
|
|
|
+class Resource {
|
|
|
public:
|
|
|
- Resource(int id) :
|
|
|
- mId(id) {}
|
|
|
+ int mId;
|
|
|
|
|
|
- virtual ~Resource() {}
|
|
|
+ Resource(int id) :
|
|
|
+ mId(id) {
|
|
|
+ // empty
|
|
|
+ }
|
|
|
|
|
|
- int mId;
|
|
|
+ virtual ~Resource() {
|
|
|
+ // empty
|
|
|
+ }
|
|
|
|
|
|
- virtual ResourceType getType() {
|
|
|
+ virtual ResourceType getType() const {
|
|
|
return ResourceType::RT_Unknown;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
class BaseMaterials : public Resource {
|
|
|
public:
|
|
|
+ std::vector<aiMaterial *> mMaterials;
|
|
|
+ std::vector<unsigned int> mMaterialIndex;
|
|
|
+
|
|
|
BaseMaterials(int id) :
|
|
|
Resource(id),
|
|
|
mMaterials(),
|
|
|
- mMaterialIndex() {}
|
|
|
+ mMaterialIndex() {
|
|
|
+ // empty
|
|
|
+ }
|
|
|
|
|
|
- std::vector<aiMaterial *> mMaterials;
|
|
|
- std::vector<unsigned int> mMaterialIndex;
|
|
|
+ ~BaseMaterials() = default;
|
|
|
|
|
|
- virtual ResourceType getType() {
|
|
|
+ ResourceType getType() const override {
|
|
|
return ResourceType::RT_BaseMaterials;
|
|
|
}
|
|
|
};
|
|
@@ -109,24 +116,26 @@ struct Component {
|
|
|
|
|
|
class Object : public Resource {
|
|
|
public:
|
|
|
- std::vector<aiMesh*> mMeshes;
|
|
|
+ std::vector<aiMesh *> mMeshes;
|
|
|
std::vector<unsigned int> mMeshIndex;
|
|
|
std::vector<Component> mComponents;
|
|
|
std::string mName;
|
|
|
|
|
|
Object(int id) :
|
|
|
Resource(id),
|
|
|
- mName(std::string("Object_") + ai_to_string(id)) {}
|
|
|
+ mName(std::string("Object_") + ai_to_string(id)) {
|
|
|
+ // empty
|
|
|
+ }
|
|
|
+
|
|
|
+ ~Object() = default;
|
|
|
|
|
|
- virtual ResourceType getType() {
|
|
|
+ ResourceType getType() const override {
|
|
|
return ResourceType::RT_Object;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|
|
|
class XmlSerializer {
|
|
|
public:
|
|
|
-
|
|
|
XmlSerializer(XmlParser *xmlParser) :
|
|
|
mResourcesDictionnary(),
|
|
|
mMaterialCount(0),
|
|
@@ -136,7 +145,7 @@ public:
|
|
|
}
|
|
|
|
|
|
~XmlSerializer() {
|
|
|
- for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); it++) {
|
|
|
+ for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); ++it ) {
|
|
|
delete it->second;
|
|
|
}
|
|
|
}
|
|
@@ -146,28 +155,28 @@ public:
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- scene->mRootNode = new aiNode("3MF");
|
|
|
+ scene->mRootNode = new aiNode(XmlTag::RootTag);
|
|
|
|
|
|
- XmlNode node = mXmlParser->getRootNode().child("model");
|
|
|
+ XmlNode node = mXmlParser->getRootNode().child(XmlTag::model);
|
|
|
if (node.empty()) {
|
|
|
return;
|
|
|
}
|
|
|
- XmlNode resNode = node.child("resources");
|
|
|
- for (XmlNode currentNode = resNode.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
|
|
- const std::string ¤tNodeName = currentNode.name();
|
|
|
- if (currentNodeName == D3MF::XmlTag::object) {
|
|
|
- ReadObject(currentNode);;
|
|
|
- } else if (currentNodeName == D3MF::XmlTag::basematerials) {
|
|
|
+ XmlNode resNode = node.child(XmlTag::resources);
|
|
|
+ for (auto ¤tNode : resNode.children()) {
|
|
|
+ const std::string currentNodeName = currentNode.name();
|
|
|
+ if (currentNodeName == XmlTag::object) {
|
|
|
+ ReadObject(currentNode);
|
|
|
+ } else if (currentNodeName == XmlTag::basematerials) {
|
|
|
ReadBaseMaterials(currentNode);
|
|
|
- } else if (currentNodeName == D3MF::XmlTag::meta) {
|
|
|
+ } else if (currentNodeName == XmlTag::meta) {
|
|
|
ReadMetadata(currentNode);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- XmlNode buildNode = node.child("build");
|
|
|
- for (XmlNode currentNode = buildNode.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
|
|
- const std::string ¤tNodeName = currentNode.name();
|
|
|
- if (currentNodeName == D3MF::XmlTag::item) {
|
|
|
+ XmlNode buildNode = node.child(XmlTag::build);
|
|
|
+ for (auto ¤tNode : buildNode.children()) {
|
|
|
+ const std::string currentNodeName = currentNode.name();
|
|
|
+ if (currentNodeName == XmlTag::item) {
|
|
|
int objectId = -1;
|
|
|
std::string transformationMatrixStr;
|
|
|
aiMatrix4x4 transformationMatrix;
|
|
@@ -186,10 +195,9 @@ public:
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// import the metadata
|
|
|
if (!mMetaData.empty()) {
|
|
|
- const size_t numMeta(mMetaData.size());
|
|
|
+ const size_t numMeta = mMetaData.size();
|
|
|
scene->mMetaData = aiMetadata::Alloc(static_cast<unsigned int>(numMeta));
|
|
|
for (size_t i = 0; i < numMeta; ++i) {
|
|
|
aiString val(mMetaData[i].value);
|
|
@@ -201,22 +209,22 @@ public:
|
|
|
scene->mNumMeshes = static_cast<unsigned int>(mMeshCount);
|
|
|
if (scene->mNumMeshes != 0) {
|
|
|
scene->mMeshes = new aiMesh *[scene->mNumMeshes]();
|
|
|
- for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); it++) {
|
|
|
+ for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); ++it) {
|
|
|
if (it->second->getType() == ResourceType::RT_Object) {
|
|
|
- Object *obj = static_cast<Object*>(it->second);
|
|
|
+ Object *obj = static_cast<Object *>(it->second);
|
|
|
+ ai_assert(nullptr != obj);
|
|
|
for (unsigned int i = 0; i < obj->mMeshes.size(); ++i) {
|
|
|
scene->mMeshes[obj->mMeshIndex[i]] = obj->mMeshes[i];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
|
|
|
// import the materials
|
|
|
- scene->mNumMaterials = static_cast<unsigned int>(mMaterialCount);
|
|
|
+ scene->mNumMaterials = mMaterialCount;
|
|
|
if (scene->mNumMaterials != 0) {
|
|
|
scene->mMaterials = new aiMaterial *[scene->mNumMaterials];
|
|
|
- for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); it++) {
|
|
|
+ for (auto it = mResourcesDictionnary.begin(); it != mResourcesDictionnary.end(); ++it) {
|
|
|
if (it->second->getType() == ResourceType::RT_BaseMaterials) {
|
|
|
BaseMaterials *baseMaterials = static_cast<BaseMaterials *>(it->second);
|
|
|
for (unsigned int i = 0; i < baseMaterials->mMaterials.size(); ++i) {
|
|
@@ -228,35 +236,36 @@ public:
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
+ void addObjectToNode(aiNode *parent, Object *obj, aiMatrix4x4 nodeTransform) {
|
|
|
+ ai_assert(nullptr != obj);
|
|
|
|
|
|
- void addObjectToNode(aiNode* parent, Object* obj, aiMatrix4x4 nodeTransform) {
|
|
|
aiNode *sceneNode = new aiNode(obj->mName);
|
|
|
sceneNode->mNumMeshes = static_cast<unsigned int>(obj->mMeshes.size());
|
|
|
sceneNode->mMeshes = new unsigned int[sceneNode->mNumMeshes];
|
|
|
std::copy(obj->mMeshIndex.begin(), obj->mMeshIndex.end(), sceneNode->mMeshes);
|
|
|
|
|
|
sceneNode->mTransformation = nodeTransform;
|
|
|
-
|
|
|
- parent->addChildren(1, &sceneNode);
|
|
|
+ if (nullptr != parent) {
|
|
|
+ parent->addChildren(1, &sceneNode);
|
|
|
+ }
|
|
|
|
|
|
for (size_t i = 0; i < obj->mComponents.size(); ++i) {
|
|
|
Component c = obj->mComponents[i];
|
|
|
auto it = mResourcesDictionnary.find(c.mObjectId);
|
|
|
if (it != mResourcesDictionnary.end() && it->second->getType() == ResourceType::RT_Object) {
|
|
|
- addObjectToNode(sceneNode, static_cast<Object*>(it->second), c.mTransformation);
|
|
|
+ addObjectToNode(sceneNode, static_cast<Object *>(it->second), c.mTransformation);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- bool getNodeAttribute(const XmlNode& node, const std::string& attribute, std::string& value) {
|
|
|
+ bool getNodeAttribute(const XmlNode &node, const std::string &attribute, std::string &value) {
|
|
|
pugi::xml_attribute objectAttribute = node.attribute(attribute.c_str());
|
|
|
if (!objectAttribute.empty()) {
|
|
|
value = objectAttribute.as_string();
|
|
|
return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
}
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
bool getNodeAttribute(const XmlNode &node, const std::string &attribute, int &value) {
|
|
@@ -265,9 +274,9 @@ private:
|
|
|
if (ret) {
|
|
|
value = std::atoi(strValue.c_str());
|
|
|
return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
aiMatrix4x4 parseTransformMatrix(std::string matrixStr) {
|
|
@@ -287,7 +296,7 @@ private:
|
|
|
}
|
|
|
}
|
|
|
if (currentNumber.size() > 0) {
|
|
|
- float f = std::stof(currentNumber);
|
|
|
+ const float f = std::stof(currentNumber);
|
|
|
numbers.push_back(f);
|
|
|
}
|
|
|
|
|
@@ -311,29 +320,26 @@ private:
|
|
|
transformMatrix.b4 = numbers[10];
|
|
|
transformMatrix.c4 = numbers[11];
|
|
|
transformMatrix.d4 = 1;
|
|
|
+
|
|
|
return transformMatrix;
|
|
|
}
|
|
|
|
|
|
void ReadObject(XmlNode &node) {
|
|
|
int id = -1, pid = -1, pindex = -1;
|
|
|
- bool hasId = getNodeAttribute(node, D3MF::XmlTag::id, id);
|
|
|
- //bool hasType = getNodeAttribute(node, D3MF::XmlTag::type, type); not used currently
|
|
|
- bool hasPid = getNodeAttribute(node, D3MF::XmlTag::pid, pid);
|
|
|
- bool hasPindex = getNodeAttribute(node, D3MF::XmlTag::pindex, pindex);
|
|
|
-
|
|
|
- std::string idStr = ai_to_string(id);
|
|
|
-
|
|
|
+ bool hasId = getNodeAttribute(node, XmlTag::id, id);
|
|
|
+ bool hasPid = getNodeAttribute(node, XmlTag::pid, pid);
|
|
|
+ bool hasPindex = getNodeAttribute(node, XmlTag::pindex, pindex);
|
|
|
if (!hasId) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
Object *obj = new Object(id);
|
|
|
|
|
|
- for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
|
|
+ for (XmlNode ¤tNode : node.children()) {
|
|
|
const std::string ¤tName = currentNode.name();
|
|
|
if (currentName == D3MF::XmlTag::mesh) {
|
|
|
auto mesh = ReadMesh(currentNode);
|
|
|
- mesh->mName.Set(idStr);
|
|
|
+ mesh->mName.Set(ai_to_string(id));
|
|
|
|
|
|
if (hasPid) {
|
|
|
auto it = mResourcesDictionnary.find(pid);
|
|
@@ -347,8 +353,9 @@ private:
|
|
|
obj->mMeshIndex.push_back(mMeshCount);
|
|
|
mMeshCount++;
|
|
|
} else if (currentName == D3MF::XmlTag::components) {
|
|
|
- for (XmlNode currentSubNode = currentNode.first_child(); currentSubNode; currentSubNode = currentSubNode.next_sibling()) {
|
|
|
- if (currentSubNode.name() == D3MF::XmlTag::component) {
|
|
|
+ for (XmlNode ¤tSubNode : currentNode.children()) {
|
|
|
+ const std::string subNodeName = currentSubNode.name();
|
|
|
+ if (subNodeName == D3MF::XmlTag::component) {
|
|
|
int objectId = -1;
|
|
|
std::string componentTransformStr;
|
|
|
aiMatrix4x4 componentTransform;
|
|
@@ -356,8 +363,9 @@ private:
|
|
|
componentTransform = parseTransformMatrix(componentTransformStr);
|
|
|
}
|
|
|
|
|
|
- if (getNodeAttribute(currentSubNode, D3MF::XmlTag::objectid, objectId))
|
|
|
+ if (getNodeAttribute(currentSubNode, D3MF::XmlTag::objectid, objectId)) {
|
|
|
obj->mComponents.push_back({ objectId, componentTransform });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -369,21 +377,20 @@ private:
|
|
|
aiMesh *ReadMesh(XmlNode &node) {
|
|
|
aiMesh *mesh = new aiMesh();
|
|
|
|
|
|
- for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
|
|
- const std::string ¤tName = currentNode.name();
|
|
|
- if (currentName == D3MF::XmlTag::vertices) {
|
|
|
+ for (XmlNode ¤tNode : node.children()) {
|
|
|
+ const std::string currentName = currentNode.name();
|
|
|
+ if (currentName == XmlTag::vertices) {
|
|
|
ImportVertices(currentNode, mesh);
|
|
|
- } else if (currentName == D3MF::XmlTag::triangles) {
|
|
|
+ } else if (currentName == XmlTag::triangles) {
|
|
|
ImportTriangles(currentNode, mesh);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
return mesh;
|
|
|
}
|
|
|
|
|
|
void ReadMetadata(XmlNode &node) {
|
|
|
- pugi::xml_attribute attribute = node.attribute(D3MF::XmlTag::meta_name.c_str());
|
|
|
+ pugi::xml_attribute attribute = node.attribute(D3MF::XmlTag::meta_name);
|
|
|
const std::string name = attribute.as_string();
|
|
|
const std::string value = node.value();
|
|
|
if (name.empty()) {
|
|
@@ -398,9 +405,9 @@ private:
|
|
|
|
|
|
void ImportVertices(XmlNode &node, aiMesh *mesh) {
|
|
|
std::vector<aiVector3D> vertices;
|
|
|
- for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
|
|
- const std::string ¤tName = currentNode.name();
|
|
|
- if (currentName == D3MF::XmlTag::vertex) {
|
|
|
+ for (XmlNode ¤tNode : node.children()) {
|
|
|
+ const std::string currentName = currentNode.name();
|
|
|
+ if (currentName == XmlTag::vertex) {
|
|
|
vertices.push_back(ReadVertex(currentNode));
|
|
|
}
|
|
|
}
|
|
@@ -412,29 +419,28 @@ private:
|
|
|
|
|
|
aiVector3D ReadVertex(XmlNode &node) {
|
|
|
aiVector3D vertex;
|
|
|
- vertex.x = ai_strtof(node.attribute(D3MF::XmlTag::x.c_str()).as_string(), nullptr);
|
|
|
- vertex.y = ai_strtof(node.attribute(D3MF::XmlTag::y.c_str()).as_string(), nullptr);
|
|
|
- vertex.z = ai_strtof(node.attribute(D3MF::XmlTag::z.c_str()).as_string(), nullptr);
|
|
|
+ vertex.x = ai_strtof(node.attribute(XmlTag::x).as_string(), nullptr);
|
|
|
+ vertex.y = ai_strtof(node.attribute(XmlTag::y).as_string(), nullptr);
|
|
|
+ vertex.z = ai_strtof(node.attribute(XmlTag::z).as_string(), nullptr);
|
|
|
|
|
|
return vertex;
|
|
|
}
|
|
|
|
|
|
void ImportTriangles(XmlNode &node, aiMesh *mesh) {
|
|
|
std::vector<aiFace> faces;
|
|
|
- for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
|
|
|
- const std::string ¤tName = currentNode.name();
|
|
|
- if (currentName == D3MF::XmlTag::triangle) {
|
|
|
+ for (XmlNode ¤tNode : node.children()) {
|
|
|
+ const std::string currentName = currentNode.name();
|
|
|
+ if (currentName == XmlTag::triangle) {
|
|
|
aiFace face = ReadTriangle(currentNode);
|
|
|
faces.push_back(face);
|
|
|
|
|
|
- int pid = 0, p1;
|
|
|
+ int pid = 0, p1 = 0;
|
|
|
bool hasPid = getNodeAttribute(currentNode, D3MF::XmlTag::pid, pid);
|
|
|
bool hasP1 = getNodeAttribute(currentNode, D3MF::XmlTag::p1, p1);
|
|
|
|
|
|
if (hasPid && hasP1) {
|
|
|
auto it = mResourcesDictionnary.find(pid);
|
|
|
- if (it != mResourcesDictionnary.end())
|
|
|
- {
|
|
|
+ if (it != mResourcesDictionnary.end()) {
|
|
|
if (it->second->getType() == ResourceType::RT_BaseMaterials) {
|
|
|
BaseMaterials *baseMaterials = static_cast<BaseMaterials *>(it->second);
|
|
|
mesh->mMaterialIndex = baseMaterials->mMaterialIndex[p1];
|
|
@@ -457,9 +463,9 @@ private:
|
|
|
|
|
|
face.mNumIndices = 3;
|
|
|
face.mIndices = new unsigned int[face.mNumIndices];
|
|
|
- face.mIndices[0] = static_cast<unsigned int>(std::atoi(node.attribute(D3MF::XmlTag::v1.c_str()).as_string()));
|
|
|
- face.mIndices[1] = static_cast<unsigned int>(std::atoi(node.attribute(D3MF::XmlTag::v2.c_str()).as_string()));
|
|
|
- face.mIndices[2] = static_cast<unsigned int>(std::atoi(node.attribute(D3MF::XmlTag::v3.c_str()).as_string()));
|
|
|
+ face.mIndices[0] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v1).as_string()));
|
|
|
+ face.mIndices[1] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v2).as_string()));
|
|
|
+ face.mIndices[2] = static_cast<unsigned int>(std::atoi(node.attribute(XmlTag::v3).as_string()));
|
|
|
|
|
|
return face;
|
|
|
}
|
|
@@ -467,14 +473,14 @@ private:
|
|
|
void ReadBaseMaterials(XmlNode &node) {
|
|
|
int id = -1;
|
|
|
if (getNodeAttribute(node, D3MF::XmlTag::basematerials_id, id)) {
|
|
|
- BaseMaterials* baseMaterials = new BaseMaterials(id);
|
|
|
+ BaseMaterials *baseMaterials = new BaseMaterials(id);
|
|
|
|
|
|
- for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling())
|
|
|
- {
|
|
|
- if (currentNode.name() == D3MF::XmlTag::basematerials_base) {
|
|
|
+ for (XmlNode ¤tNode : node.children()) {
|
|
|
+ const std::string currentName = currentNode.name();
|
|
|
+ if (currentName == XmlTag::basematerials_base) {
|
|
|
baseMaterials->mMaterialIndex.push_back(mMaterialCount);
|
|
|
baseMaterials->mMaterials.push_back(readMaterialDef(currentNode, id));
|
|
|
- mMaterialCount++;
|
|
|
+ ++mMaterialCount;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -488,7 +494,7 @@ private:
|
|
|
}
|
|
|
|
|
|
//format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1)
|
|
|
- const size_t len(strlen(color));
|
|
|
+ const size_t len = strlen(color);
|
|
|
if (9 != len && 7 != len) {
|
|
|
return false;
|
|
|
}
|
|
@@ -517,7 +523,7 @@ private:
|
|
|
}
|
|
|
|
|
|
void assignDiffuseColor(XmlNode &node, aiMaterial *mat) {
|
|
|
- const char *color = node.attribute(D3MF::XmlTag::basematerials_displaycolor.c_str()).as_string();
|
|
|
+ const char *color = node.attribute(XmlTag::basematerials_displaycolor).as_string();
|
|
|
aiColor4D diffuse;
|
|
|
if (parseColor(color, diffuse)) {
|
|
|
mat->AddProperty<aiColor4D>(&diffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
|
@@ -531,7 +537,7 @@ private:
|
|
|
bool hasName = getNodeAttribute(node, D3MF::XmlTag::basematerials_name, name);
|
|
|
|
|
|
std::string stdMaterialName;
|
|
|
- std::string strId(ai_to_string(basematerialsId));
|
|
|
+ const std::string strId(ai_to_string(basematerialsId));
|
|
|
stdMaterialName += "id";
|
|
|
stdMaterialName += strId;
|
|
|
stdMaterialName += "_";
|
|
@@ -556,13 +562,15 @@ private:
|
|
|
std::string value;
|
|
|
};
|
|
|
std::vector<MetaEntry> mMetaData;
|
|
|
- std::map<unsigned int, Resource*> mResourcesDictionnary;
|
|
|
+ std::map<unsigned int, Resource *> mResourcesDictionnary;
|
|
|
unsigned int mMaterialCount, mMeshCount;
|
|
|
XmlParser *mXmlParser;
|
|
|
};
|
|
|
|
|
|
} //namespace D3MF
|
|
|
|
|
|
+using namespace D3MF;
|
|
|
+
|
|
|
static const aiImporterDesc desc = {
|
|
|
"3mf Importer",
|
|
|
"",
|
|
@@ -596,7 +604,7 @@ bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bo
|
|
|
if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) {
|
|
|
return false;
|
|
|
}
|
|
|
- D3MF::D3MFOpcPackage opcPackage(pIOHandler, filename);
|
|
|
+ D3MFOpcPackage opcPackage(pIOHandler, filename);
|
|
|
return opcPackage.validate();
|
|
|
}
|
|
|
|
|
@@ -612,11 +620,11 @@ const aiImporterDesc *D3MFImporter::GetInfo() const {
|
|
|
}
|
|
|
|
|
|
void D3MFImporter::InternReadFile(const std::string &filename, aiScene *pScene, IOSystem *pIOHandler) {
|
|
|
- D3MF::D3MFOpcPackage opcPackage(pIOHandler, filename);
|
|
|
+ D3MFOpcPackage opcPackage(pIOHandler, filename);
|
|
|
|
|
|
XmlParser xmlParser;
|
|
|
if (xmlParser.parse(opcPackage.RootStream())) {
|
|
|
- D3MF::XmlSerializer xmlSerializer(&xmlParser);
|
|
|
+ XmlSerializer xmlSerializer(&xmlParser);
|
|
|
xmlSerializer.ImportXml(pScene);
|
|
|
}
|
|
|
}
|