[F] Doc changes.
[*] Removed Boost dependency.
[*] Style changes.
-/// \file X3DImporter.hpp
-/// \brief X3D-format files importer for Assimp: main algorithm implementation.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter.cpp
+/// \brief X3D-format files importer for Assimp: main algorithm implementation.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
#include "X3DImporter.hpp"
#include "X3DImporter_Macro.hpp"
-#include "fast_atof.h"
+// Header files, Assimp.
#include "DefaultIOSystem.h"
+#include "fast_atof.h"
-#include <boost/format.hpp>
-#include <boost/scoped_ptr.hpp>
+// Header files, stdlib.
+#include <memory>
#include <string>
namespace Assimp
void X3DImporter::Clear()
{
+ NodeElement_Cur = nullptr;
// Delete all elements
if(NodeElement_List.size())
{
X3DImporter::~X3DImporter()
{
- if(mReader != NULL) delete mReader;
+ if(mReader != nullptr) delete mReader;
// Clear() is accounting if data already is deleted. So, just check again if all data is deleted.
Clear();
}
{
if(((*it)->Type == pType) && ((*it)->ID == pID))
{
- if(pElement != NULL) *pElement = *it;
+ if(pElement != nullptr) *pElement = *it;
return true;
}
if((pStartNode->Type == pType) && (pStartNode->ID == pID))
{
found = true;
- if(pElement != NULL) *pElement = pStartNode;
+ if(pElement != nullptr) *pElement = pStartNode;
goto fne_fn_end;
}// if((pStartNode->Type() == pType) && (pStartNode->ID() == pID))
bool static_search = false;// flag: true if searching in static node.
// At first check if we have deal with static node. Go up thru parent nodes and check flag.
- while(tnd != NULL)
+ while(tnd != nullptr)
{
if(tnd->Type == CX3DImporter_NodeElement::ENET_Group)
{
}
tnd = tnd->Parent;// go up in graph.
- }// while(tnd != NULL)
+ }// while(tnd != nullptr)
// at now call appropriate search function.
if(static_search)
void X3DImporter::Throw_ConvertFail_Str2ArrF(const std::string& pAttrValue)
{
- throw DeadlyImportError(boost::str(boost::format("In <%s> failed to convert attribute value \"%s\" from string to array of floats.") %
- mReader->getNodeName() % pAttrValue));
+ throw DeadlyImportError("In <" + std::string(mReader->getNodeName()) + "> failed to convert attribute value \"" + pAttrValue +
+ "\" from string to array of floats.");
}
void X3DImporter::Throw_DEF_And_USE()
{
- throw DeadlyImportError(boost::str(boost::format("\"DEF\" and \"USE\" can not be defined both in <%s>.") % mReader->getNodeName()));
+ throw DeadlyImportError("\"DEF\" and \"USE\" can not be defined both in <" + std::string(mReader->getNodeName()) + ">.");
}
void X3DImporter::Throw_IncorrectAttr(const std::string& pAttrName)
{
- throw DeadlyImportError(boost::str(boost::format("Node <%s> has incorrect attribute \"%s\".") % mReader->getNodeName() % pAttrName));
+ throw DeadlyImportError("Node <" + std::string(mReader->getNodeName()) + "> has incorrect attribute \"" + pAttrName + "\".");
}
void X3DImporter::Throw_IncorrectAttrValue(const std::string& pAttrName)
{
- throw DeadlyImportError(boost::str(boost::format("Attribute \"%s\" in node <%s> has incorrect value.") % pAttrName % mReader->getNodeName()));
+ throw DeadlyImportError("Attribute \"" + pAttrName + "\" in node <" + std::string(mReader->getNodeName()) + "> has incorrect value.");
}
void X3DImporter::Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription)
void X3DImporter::Throw_USE_NotFound(const std::string& pAttrValue)
{
- throw DeadlyImportError(boost::str(boost::format("Not found node with name \"%s\" in <%s>.") % pAttrValue % mReader->getNodeName()));
+ throw DeadlyImportError("Not found node with name \"" + pAttrValue + "\" in <" + std::string(mReader->getNodeName()) + ">.");
}
/*********************************************************************************************************************************************/
casu_cres:
- if(!found) throw DeadlyImportError(boost::str(boost::format("Unknown node \"%s\" in %s.") % nn % pParentNodeName));
+ if(!found) throw DeadlyImportError("Unknown node \"" + nn + "\" in " + pParentNodeName + ".");
if(close_found)
- LogInfo(boost::str(boost::format("Skipping node \"%s\" in %s.") % nn % pParentNodeName));
+ LogInfo("Skipping node \"" + nn + "\" in " + pParentNodeName + ".");
else
Throw_CloseNotFound(nn);
}
do
{
- int32_t tval32;
const char* ostr;
+ int32_t tval32;
+
tval32 = strtol10(tstr, &ostr);
if(ostr == tstr) break;
// find begin of string(element of string list): "sn".
tbeg = strstr(tok_str, "\"");
- if(tbeg == NULL) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx));
+ if(tbeg == nullptr) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx));
tbeg++;// forward pointer from '\"' symbol to next after it.
tok_str = tbeg;
// find end of string(element of string list): "sn".
tend = strstr(tok_str, "\"");
- if(tend == NULL) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx));
+ if(tend == nullptr) Throw_IncorrectAttrValue(mReader->getAttributeName(pAttrIdx));
tok_str = tend + 1;
// create storage for new string
switch(ts)
{
case 0: goto mg_m_err;
- case 1: prim_type |= aiPrimitiveType_POINT;
- case 2: prim_type |= aiPrimitiveType_LINE;
- case 3: prim_type |= aiPrimitiveType_TRIANGLE;
- default: prim_type |= aiPrimitiveType_POLYGON;
+ case 1: prim_type |= aiPrimitiveType_POINT; break;
+ case 2: prim_type |= aiPrimitiveType_LINE; break;
+ case 3: prim_type |= aiPrimitiveType_TRIANGLE; break;
+ default: prim_type |= aiPrimitiveType_POLYGON; break;
}
tface.mNumIndices = ts;
{
if(pColors.size() < pMesh.mNumVertices)
{
- throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor1. Colors count(%s) can not be less than Vertices count(%s).") %
- pColors.size() % pMesh.mNumVertices));
+ throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Vertices count(" +
+ std::to_string(pMesh.mNumVertices) + ").");
}
// copy colors to mesh
{
if(pColors.size() < pMesh.mNumFaces)
{
- throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor1. Colors count(%s) can not be less than Faces count(%s).") %
- pColors.size() % pMesh.mNumFaces));
+ throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Faces count(" +
+ std::to_string(pMesh.mNumFaces) + ").");
}
// copy colors to mesh
// check indices array count.
if(pColorIdx.size() < pCoordIdx.size())
{
- throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor2. Colors indices count(%s) can not be less than Coords inidces count(%s).") %
- pColorIdx.size() % pCoordIdx.size()));
+ throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + std::to_string(pColorIdx.size()) +
+ ") can not be less than Coords inidces count(" + std::to_string(pCoordIdx.size()) + ").");
}
// create list with colors for every vertex.
col_tgt_arr.resize(pMesh.mNumVertices);
// check indices array count.
if(pColors.size() < pMesh.mNumVertices)
{
- throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor2. Colors count(%s) can not be less than Vertices count(%s).") %
- pColors.size() % pMesh.mNumVertices));
+ throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Vertices count(" +
+ std::to_string(pMesh.mNumVertices) + ").");
}
// create list with colors for every vertex.
col_tgt_arr.resize(pMesh.mNumVertices);
// check indices array count.
if(pColorIdx.size() < pMesh.mNumFaces)
{
- throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor2. Colors indices count(%s) can not be less than Faces count(%s).") %
- pColorIdx.size() % pMesh.mNumFaces));
+ throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + std::to_string(pColorIdx.size()) +
+ ") can not be less than Faces count(" + std::to_string(pMesh.mNumFaces) + ").");
}
// create list with colors for every vertex using faces indices.
col_tgt_arr.resize(pMesh.mNumFaces);
// check indices array count.
if(pColors.size() < pMesh.mNumFaces)
{
- throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddColor2. Colors count(%s) can not be less than Faces count(%s).") %
- pColors.size() % pMesh.mNumFaces));
+ throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Faces count(" +
+ std::to_string(pMesh.mNumFaces) + ").");
}
// create list with colors for every vertex using faces indices.
col_tgt_arr.resize(pMesh.mNumFaces);
for(size_t i = 0; (i < pMesh.mNumVertices) && (i < tind.size()); i++)
{
if(tind[i] >= norm_arr_copy.size())
- throw DeadlyImportError(boost::str(boost::format("MeshGeometry_AddNormal. Normal index(%s) is out of range. Normals count: %s.") %
- tind[i] % norm_arr_copy.size()));
+ throw DeadlyImportError("MeshGeometry_AddNormal. Normal index(" + std::to_string(tind[i]) +
+ ") is out of range. Normals count: " + std::to_string(norm_arr_copy.size()) + ".");
pMesh.mNormals[i] = norm_arr_copy[tind[i]];
}
for(size_t fi = 0, fi_e = faces.size(); fi < fi_e; fi++)
{
if(pMesh.mFaces[fi].mNumIndices != faces.at(fi).mNumIndices)
- throw DeadlyImportError(boost::str(boost::format("Number of indices in texture face and mesh face must be equal. Invalid face index: %s") % fi));
+ throw DeadlyImportError("Number of indices in texture face and mesh face must be equal. Invalid face index: " + std::to_string(fi) + ".");
for(size_t ii = 0; ii < pMesh.mFaces[fi].mNumIndices; ii++)
{
CX3DImporter_NodeElement_Group* new_group = new CX3DImporter_NodeElement_Group(NodeElement_Cur, pStatic);// create new node with current node as parent.
// if we are adding not the root element then add new element to current element child list.
- if(NodeElement_Cur != NULL) NodeElement_Cur->Child.push_back(new_group);
+ if(NodeElement_Cur != nullptr) NodeElement_Cur->Child.push_back(new_group);
NodeElement_List.push_back(new_group);// it's a new element - add it to list.
NodeElement_Cur = new_group;// switch current element to new one.
void X3DImporter::ParseHelper_Node_Exit()
{
// check if we can walk up.
- if(NodeElement_Cur != NULL) NodeElement_Cur = NodeElement_Cur->Parent;
+ if(NodeElement_Cur != nullptr) NodeElement_Cur = NodeElement_Cur->Parent;
}
void X3DImporter::ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString)
void X3DImporter::ParseFile(const std::string& pFile, IOSystem* pIOHandler)
{
irr::io::IrrXMLReader* OldReader = mReader;// store current XMLreader.
-boost::scoped_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
+std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
// Check whether we can read from the file
- if(file.get() == NULL) throw DeadlyImportError("Failed to open X3D file " + pFile + ".");
+ if(file.get() == nullptr) throw DeadlyImportError("Failed to open X3D file " + pFile + ".");
// generate a XML reader for it
- boost::scoped_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));
+ std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(file.get()));
mReader = irr::io::createIrrXMLReader(mIOWrapper.get());
if(!mReader) throw DeadlyImportError("Failed to create XML reader for file" + pFile + ".");
// start reading
{
ms->Value.push_back(mReader->getAttributeValueSafe("content"));
NodeElement_List.push_back(ms);
- if(NodeElement_Cur != NULL) NodeElement_Cur->Child.push_back(ms);
+ if(NodeElement_Cur != nullptr) NodeElement_Cur->Child.push_back(ms);
+
}
}// if(XML_CheckNode_NameEqual("meta"))
}// if(mReader->getNodeType() == irr::io::EXN_ELEMENT)
//
// at first creating root node for aiScene.
pScene->mRootNode = new aiNode;
- pScene->mRootNode->mParent = NULL;
-
+ pScene->mRootNode->mParent = nullptr;
+ pScene->mFlags |= AI_SCENE_FLAGS_ALLOW_SHARED;
//search for root node element
NodeElement_Cur = NodeElement_List.front();
- while(NodeElement_Cur->Parent != NULL) NodeElement_Cur = NodeElement_Cur->Parent;
+ while(NodeElement_Cur->Parent != nullptr) NodeElement_Cur = NodeElement_Cur->Parent;
{// fill aiScene with objects.
std::list<aiMesh*> mesh_list;
-/// \file X3DImporter.hpp
-/// \brief X3D-format files importer for Assimp.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter.hpp
+/// \brief X3D-format files importer for Assimp.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
+// Thanks to acorn89 for support.
#ifndef INCLUDED_AI_X3D_IMPORTER_H
#define INCLUDED_AI_X3D_IMPORTER_H
-// Pay attention - you must include some files from Assimp before including BaseImporter.h.
-// magic region begin
-#include <set>
+#include "X3DImporter_Node.hpp"
-#include "../include/assimp/DefaultLogger.hpp"
-#include "../include/assimp/importerdesc.h"
-#include "../include/assimp/ProgressHandler.hpp"
-#include "../include/assimp/types.h"
-// magic region end
+// Header files, Assimp.
+#include "assimp/DefaultLogger.hpp"
+#include "assimp/importerdesc.h"
+#include "assimp/ProgressHandler.hpp"
+#include "assimp/types.h"
#include "BaseImporter.h"
#include "irrXMLWrapper.h"
-#include "X3DImporter_Node.hpp"
-
namespace Assimp
{
/// duplicates of it )).
///
/// Color for faces.
-/// That's happening when attribute "colorPerVertex" is set to "false". But Assimp do not hold how many colors has mesh and reuire
+/// That's happening when attribute "colorPerVertex" is set to "false". But Assimp do not hold how many colors has mesh and require
/// equal length for mVertices and mColors. You will see the colors but vertices will use call which last used in "colorIdx".
///
/// That's all for now. Enjoy
/// Create filled structure with type \ref aiMaterial from \ref CX3DImporter_NodeElement. This function itseld extract
/// all needed data from scene graph.
/// \param [in] pNodeElement - reference to material element(<Appearance>).
- /// \param [out] pMaterial - pointer to pointer to created material. *pMaterial must be NULL.
+ /// \param [out] pMaterial - pointer to pointer to created material. *pMaterial must be nullptr.
void Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNodeElement, aiMaterial** pMaterial) const;
/// \fn void Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const
/// Create filled structure with type \ref aiMaterial from \ref CX3DImporter_NodeElement. This function itseld extract
/// all needed data from scene graph.
/// \param [in] pNodeElement - reference to geometry object.
- /// \param [out] pMesh - pointer to pointer to created mesh. *pMesh must be NULL.
+ /// \param [out] pMesh - pointer to pointer to created mesh. *pMesh must be nullptr.
void Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const;
/// \fn void Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list<aiMesh*>& pSceneMeshList, std::list<aiMaterial*>& pSceneMaterialList, std::list<aiLight*>& pSceneLightList) const
/// Create aiNode from CX3DImporter_NodeElement. Also function check children and make recursive call.
- /// \param [out] pNode - pointer to pointer to created node. *pNode must be NULL.
+ /// \param [out] pNode - pointer to pointer to created node. *pNode must be nullptr.
/// \param [in] pNodeElement - CX3DImporter_NodeElement which read.
/// \param [out] pSceneNode - aiNode for filling.
/// \param [out] pSceneMeshList - list with aiMesh which belong to scene.
/// \fn X3DImporter()
/// Default constructor.
X3DImporter()
- : NodeElement_Cur(NULL), mReader(NULL)
+ : NodeElement_Cur(nullptr), mReader(nullptr)
{}
/// \fn ~X3DImporter()
-/// \file X3DImporter_Geometry2D.cpp
-/// \brief Parsing data from nodes of "Geometry2D" set of X3D.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Geometry2D.cpp
+/// \brief Parsing data from nodes of "Geometry2D" set of X3D.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
-/// \file X3DImporter_Geometry3D.cpp
-/// \brief Parsing data from nodes of "Geometry3D" set of X3D.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Geometry3D.cpp
+/// \brief Parsing data from nodes of "Geometry3D" set of X3D.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
#include "X3DImporter.hpp"
#include "X3DImporter_Macro.hpp"
+
+// Header files, Assimp.
#include "StandardShapes.h"
namespace Assimp
else
{
const unsigned int tess = 30;///TODO: IME tesselation factor thru ai_property
+
std::vector<aiVector3D> tvec;// temp array for vertices.
// create and if needed - define new geometry object.
else
{
const unsigned int tess = 30;///TODO: IME tesselation factor thru ai_property
+
std::vector<aiVector3D> tside;// temp array for vertices of side.
std::vector<aiVector3D> tcir;// temp array for vertices of circle.
static aiVector3D GeometryHelper_Extrusion_GetNextY(const size_t pSpine_PointIdx, const std::vector<aiVector3D>& pSpine, const bool pSpine_Closed)
{
const size_t spine_idx_last = pSpine.size() - 1;
+
aiVector3D tvec;
if((pSpine_PointIdx == 0) || (pSpine_PointIdx == spine_idx_last))// at first special cases
{
const aiVector3D zero_vec(0);
const size_t spine_idx_last = pSpine.size() - 1;
+
aiVector3D tvec;
// at first special cases
else
{
const unsigned int tess = 3;///TODO: IME tesselation factor thru ai_property
+
std::vector<aiVector3D> tlist;
// create and if needed - define new geometry object.
}// if(!use.empty()) else
}
-
}// namespace Assimp
#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER
-/// \file X3DImporter_Group.cpp
-/// \brief Parsing data from nodes of "Grouping" set of X3D.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Group.cpp
+/// \brief Parsing data from nodes of "Grouping" set of X3D.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
-/// \file X3DImporter_Light.cpp
-/// \brief Parsing data from nodes of "Lighting" set of X3D.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Light.cpp
+/// \brief Parsing data from nodes of "Lighting" set of X3D.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
#include "X3DImporter.hpp"
#include "X3DImporter_Macro.hpp"
-#include <boost/format.hpp>
-
namespace Assimp
{
if(!def.empty())
ne->ID = def;
else
- ne->ID = boost::str(boost::format("DirectionalLight_%s") % (size_t)ne);// make random name
+ ne->ID = "DirectionalLight_" + std::to_string((size_t)ne);// make random name
((CX3DImporter_NodeElement_Light*)ne)->AmbientIntensity = ambientIntensity;
((CX3DImporter_NodeElement_Light*)ne)->Color = color;
// Assimp want a node with name similar to a light. "Why? I don't no." )
ParseHelper_Group_Begin(false);
// make random name
- if(ne->ID.empty()) ne->ID = boost::str(boost::format("PointLight_%s") % (size_t)ne);
+ if(ne->ID.empty()) ne->ID = "PointLight_" + std::to_string((size_t)ne);
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
ParseHelper_Node_Exit();
// Assimp want a node with name similar to a light. "Why? I don't no." )
ParseHelper_Group_Begin(false);
// make random name
- if(ne->ID.empty()) ne->ID = boost::str(boost::format("SpotLight_%s") % (size_t)ne);
+ if(ne->ID.empty()) ne->ID = "SpotLight_" + std::to_string((size_t)ne);
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
ParseHelper_Node_Exit();
-/// \file X3DImporter_Metadata.cpp
-/// \brief Parsing data from nodes of "Metadata" set of X3D.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Metadata.cpp
+/// \brief Parsing data from nodes of "Metadata" set of X3D.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
-/// \file X3DImporter_Rendering.cpp
-/// \brief Parsing data from nodes of "Networking" set of X3D.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Networking.cpp
+/// \brief Parsing data from nodes of "Networking" set of X3D.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
#include "X3DImporter.hpp"
#include "X3DImporter_Macro.hpp"
+// Header files, Assimp.
#include "DefaultIOSystem.h"
namespace Assimp
-/// \file X3DImporter_Node.hpp
-/// \brief Elements of scene graph.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Node.hpp
+/// \brief Elements of scene graph.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef INCLUDED_AI_X3D_IMPORTER_NODE_H
#define INCLUDED_AI_X3D_IMPORTER_NODE_H
+// Header files, Assimp.
+#include "assimp/scene.h"
+#include "assimp/types.h"
+
+// Header files, stdlib.
#include <list>
#include <string>
-#include "../include/assimp/types.h"
-#include "../include/assimp/scene.h"
-
/// \class CX3DImporter_NodeElement
/// Base class for elements of nodes.
class CX3DImporter_NodeElement
public:
std::string ID;///< ID of the element. Can be empty. In X3D synonym for "ID" attribute.
- CX3DImporter_NodeElement* Parent;///< Parrent element. If NULL then this node is root.
+ CX3DImporter_NodeElement* Parent;///< Parrent element. If nullptr then this node is root.
std::list<CX3DImporter_NodeElement*> Child;///< Child elements.
/***********************************************/
-/// \file X3DImporter_Postprocess.cpp
-/// \brief Convert built scenegraph and objects to Assimp scenegraph.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Postprocess.cpp
+/// \brief Convert built scenegraph and objects to Assimp scenegraph.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
#include "X3DImporter.hpp"
-#include "StandardShapes.h"
-#include <boost/format.hpp>
-#include <string>
+// Header files, Assimp.
+#include "StandardShapes.h"
+// Header files, stdlib.
#include <algorithm>
#include <iterator>
+#include <string>
namespace Assimp
{
// starting walk from current element to root
cur_node = NodeElement_Cur;
- if(cur_node != NULL)
+ if(cur_node != nullptr)
{
do
{
if(cur_node->Type == CX3DImporter_NodeElement::ENET_Group) matr.push_back(((CX3DImporter_NodeElement_Group*)cur_node)->Transformation);
cur_node = cur_node->Parent;
- } while(cur_node != NULL);
+ } while(cur_node != nullptr);
}
// multiplicate all matrices in reverse order
void X3DImporter::Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeElement, std::list<aiLight*>& pSceneLightList) const
{
-aiLight* new_light = new aiLight;
const CX3DImporter_NodeElement_Light& ne = *((CX3DImporter_NodeElement_Light*)&pNodeElement);
aiMatrix4x4 transform_matr = PostprocessHelper_Matrix_GlobalToCurrent();
+aiLight* new_light = new aiLight;
new_light->mName = ne.ID;
new_light->mColorAmbient = ne.Color * ne.AmbientIntensity;
break;
default:
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildLight. Unknown type of light: %s") % pNodeElement.Type));
+ throw DeadlyImportError("Postprocess_BuildLight. Unknown type of light: " + std::to_string(pNodeElement.Type) + ".");
}
pSceneLightList.push_back(new_light);
void X3DImporter::Postprocess_BuildMaterial(const CX3DImporter_NodeElement& pNodeElement, aiMaterial** pMaterial) const
{
// check argument
- if(pMaterial == NULL) throw DeadlyImportError("Postprocess_BuildMaterial. pMaterial is NULL.");
- if(*pMaterial != NULL) throw DeadlyImportError("Postprocess_BuildMaterial. *pMaterial must be NULL.");
+ if(pMaterial == nullptr) throw DeadlyImportError("Postprocess_BuildMaterial. pMaterial is nullptr.");
+ if(*pMaterial != nullptr) throw DeadlyImportError("Postprocess_BuildMaterial. *pMaterial must be nullptr.");
*pMaterial = new aiMaterial;
aiMaterial& taimat = **pMaterial;// creating alias for convenience.
void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeElement, aiMesh** pMesh) const
{
// check argument
- if(pMesh == NULL) throw DeadlyImportError("Postprocess_BuildMesh. pMesh is NULL.");
- if(*pMesh != NULL) throw DeadlyImportError("Postprocess_BuildMesh. *pMesh must be NULL.");
+ if(pMesh == nullptr) throw DeadlyImportError("Postprocess_BuildMesh. pMesh is nullptr.");
+ if(*pMesh != nullptr) throw DeadlyImportError("Postprocess_BuildMesh. *pMesh must be nullptr.");
/************************************************************************************************************************************/
/************************************************************ Geometry2D ************************************************************/
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
MeshGeometry_AddTexCoord(**pMesh, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
else
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of ElevationGrid: %s.") % (*ch_it)->Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of ElevationGrid: " + std::to_string((*ch_it)->Type) + ".");
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
return;// mesh is build, nothing to do anymore.
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
else
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of IndexedFaceSet: %s.") % (*ch_it)->Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedFaceSet: " + std::to_string((*ch_it)->Type) + ".");
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
return;// mesh is build, nothing to do anymore.
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
{} // skip because already read when mesh created.
else
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of IndexedLineSet: %s.") % (*ch_it)->Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedLineSet: " + std::to_string((*ch_it)->Type) + ".");
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
return;// mesh is build, nothing to do anymore.
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
else
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of IndexedTriangleSet or IndexedTriangleFanSet, or \
- IndexedTriangleStripSet: %s.") % (*ch_it)->Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedTriangleSet or IndexedTriangleFanSet, or \
+ IndexedTriangleStripSet: " + std::to_string((*ch_it)->Type) + ".");
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
return;// mesh is build, nothing to do anymore.
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
{} // skip because already read when mesh created.
else
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of PointSet: %s.") % (*ch_it)->Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of PointSet: " + std::to_string((*ch_it)->Type) + ".");
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
return;// mesh is build, nothing to do anymore.
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
{} // skip because already read when mesh created.
else
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of LineSet: %s.") % (*ch_it)->Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of LineSet: " + std::to_string((*ch_it)->Type) + ".");
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
return;// mesh is build, nothing to do anymore.
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
else
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of TrianlgeFanSet: %s.") % (*ch_it)->Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeFanSet: " + std::to_string((*ch_it)->Type) + ".");
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
return;// mesh is build, nothing to do anymore.
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
else
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of TrianlgeSet: %s.") % (*ch_it)->Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeSet: " + std::to_string((*ch_it)->Type) + ".");
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
return;// mesh is build, nothing to do anymore.
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
else
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown child of TriangleStripSet: %s.") % (*ch_it)->Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TriangleStripSet: " + std::to_string((*ch_it)->Type) + ".");
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
return;// mesh is build, nothing to do anymore.
}// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleStripSet)
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildMesh. Unknown mesh type: %s.") % pNodeElement.Type));
+ throw DeadlyImportError("Postprocess_BuildMesh. Unknown mesh type: " + std::to_string(pNodeElement.Type) + ".");
}
void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list<aiMesh*>& pSceneMeshList,
std::list<CX3DImporter_NodeElement*>::const_iterator chit_begin = pNodeElement.Child.begin();
std::list<CX3DImporter_NodeElement*>::const_iterator chit_end = pNodeElement.Child.end();
std::list<aiNode*> SceneNode_Child;
-std::list<aiLight*> SceneNode_Light;
std::list<unsigned int> SceneNode_Mesh;
// At first read all metadata
}
else if(!PostprocessHelper_ElementIsMetadata((*it)->Type))// skip metadata
{
- throw DeadlyImportError(boost::str(boost::format("Postprocess_BuildNode. Unknown type: %s.") % (*it)->Type));
+ throw DeadlyImportError("Postprocess_BuildNode. Unknown type: " + std::to_string((*it)->Type) + ".");
}
}// for(std::list<CX3DImporter_NodeElement*>::const_iterator it = chit_begin; it != chit_end; it++)
void X3DImporter::Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& pShapeNodeElement, std::list<unsigned int>& pNodeMeshInd,
std::list<aiMesh*>& pSceneMeshList, std::list<aiMaterial*>& pSceneMaterialList) const
{
-aiMaterial* tmat = NULL;
-aiMesh* tmesh = NULL;
+aiMaterial* tmat = nullptr;
+aiMesh* tmesh = nullptr;
CX3DImporter_NodeElement::EType mesh_type = CX3DImporter_NodeElement::ENET_Invalid;
unsigned int mat_ind = 0;
if(PostprocessHelper_ElementIsMesh((*it)->Type))
{
Postprocess_BuildMesh(**it, &tmesh);
- if(tmesh != NULL)
+ if(tmesh != nullptr)
{
// if mesh successfully built then add data about it to arrays
pNodeMeshInd.push_back(pSceneMeshList.size());
else if((*it)->Type == CX3DImporter_NodeElement::ENET_Appearance)
{
Postprocess_BuildMaterial(**it, &tmat);
- if(tmat != NULL)
+ if(tmat != nullptr)
{
// if material successfully built then add data about it to array
mat_ind = pSceneMaterialList.size();
}// for(std::list<CX3DImporter_NodeElement*>::const_iterator it = pShapeNodeElement.Child.begin(); it != pShapeNodeElement.Child.end(); it++)
// associate read material with read mesh.
- if((tmesh != NULL) && (tmat != NULL))
+ if((tmesh != nullptr) && (tmat != nullptr))
{
tmesh->mMaterialIndex = mat_ind;
// Check texture mapping. If material has texture but mesh has no texture coordinate then try to ask Assimp to generate texture coordinates.
tmat->AddProperty(&tm, 1, AI_MATKEY_MAPPING_DIFFUSE(0));
}// if((tmat->GetTextureCount(aiTextureType_DIFFUSE) != 0) && !tmesh->HasTextureCoords(0))
- }// if((tmesh != NULL) && (tmat != NULL))
+ }// if((tmesh != nullptr) && (tmat != nullptr))
}
void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode) const
{
std::list<CX3DImporter_NodeElement*> meta_list;
-size_t meta_idx = 0;
+size_t meta_idx;
PostprocessHelper_CollectMetadata(pNodeElement, meta_list);// find metadata in current node element.
if(meta_list.size() > 0)
{
- if(pSceneNode.mMetaData != NULL) throw DeadlyImportError("Postprocess. MetaData member in node are not NULL. Something went wrong.");
+ if(pSceneNode.mMetaData != nullptr) throw DeadlyImportError("Postprocess. MetaData member in node are not nullptr. Something went wrong.");
// copy collected metadata to output node.
pSceneNode.mMetaData = new aiMetadata();
pSceneNode.mMetaData->mNumProperties = meta_list.size();
pSceneNode.mMetaData->mKeys = new aiString[pSceneNode.mMetaData->mNumProperties];
pSceneNode.mMetaData->mValues = new aiMetadataEntry[pSceneNode.mMetaData->mNumProperties];
- for(std::list<CX3DImporter_NodeElement*>::const_iterator it = meta_list.begin(); it != meta_list.end(); it++)
+ meta_idx = 0;
+ for(std::list<CX3DImporter_NodeElement*>::const_iterator it = meta_list.begin(); it != meta_list.end(); it++, meta_idx++)
{
CX3DImporter_NodeElement_Meta* cur_meta = (CX3DImporter_NodeElement_Meta*)*it;
-/// \file X3DImporter_Rendering.cpp
-/// \brief Parsing data from nodes of "Rendering" set of X3D.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Rendering.cpp
+/// \brief Parsing data from nodes of "Rendering" set of X3D.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
-/// \file X3DImporter_Shape.cpp
-/// \brief Parsing data from nodes of "Shape" set of X3D.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Shape.cpp
+/// \brief Parsing data from nodes of "Shape" set of X3D.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
-/// \file X3DImporter_Texturing.cpp
-/// \brief Parsing data from nodes of "Texturing" set of X3D.
-/// \date 2015-2016
-/// \author nevorek@gmail.com
+/// \file X3DImporter_Texturing.cpp
+/// \brief Parsing data from nodes of "Texturing" set of X3D.
+/// \date 2015-2016
+/// \author smal.root@gmail.com
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER