Fix static-code-analysis findings.

pull/2151/head
kimkulling 2018-09-21 16:07:09 +02:00
parent 0795ebda46
commit f818a909e5
55 changed files with 646 additions and 13122 deletions

View File

@ -66,7 +66,7 @@ namespace D3DS {
*/
class Discreet3DS {
private:
Discreet3DS() {
Discreet3DS() noexcept {
// empty
}
@ -328,10 +328,9 @@ struct Face : public FaceWithSmoothingGroup
// ---------------------------------------------------------------------------
/** Helper structure representing a texture */
struct Texture
{
struct Texture {
//! Default constructor
Texture()
Texture() noexcept
: mOffsetU (0.0)
, mOffsetV (0.0)
, mScaleU (1.0)
@ -339,8 +338,7 @@ struct Texture
, mRotation (0.0)
, mMapMode (aiTextureMapMode_Wrap)
, bPrivate()
, iUVSrc (0)
{
, iUVSrc (0) {
mTextureBlend = get_qnan();
}
@ -394,7 +392,7 @@ struct Material
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
Material(Material &&other)
Material(Material &&other) noexcept
: mName(std::move(other.mName))
, mDiffuse(std::move(other.mDiffuse))
, mSpecularExponent(std::move(other.mSpecularExponent))
@ -418,7 +416,7 @@ struct Material
}
Material &operator=(Material &&other) {
Material &operator=(Material &&other) noexcept {
if (this == &other) {
return *this;
}
@ -447,7 +445,7 @@ struct Material
}
~Material() {}
virtual ~Material() {}
//! Name of the material

View File

@ -63,8 +63,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Header files, stdlib.
#include <set>
namespace Assimp
{
namespace Assimp {
/// \class AMFImporter
/// Class that holding scene graph which include: geometry, metadata, materials etc.
///
@ -99,34 +99,25 @@ namespace Assimp
/// new - <texmap> and children <utex1>, <utex2>, <utex3>, <vtex1>, <vtex2>, <vtex3>
/// old - <map> and children <u1>, <u2>, <u3>, <v1>, <v2>, <v3>
///
class AMFImporter : public BaseImporter
{
/***********************************************/
/******************** Types ********************/
/***********************************************/
class AMFImporter : public BaseImporter {
private:
struct SPP_Material;// forward declaration
/// \struct SPP_Composite
/// Data type for postprocessing step. More suitable container for part of material's composition.
struct SPP_Composite
{
/// Data type for post-processing step. More suitable container for part of material's composition.
struct SPP_Composite {
SPP_Material* Material;///< Pointer to material - part of composition.
std::string Formula;///< Formula for calculating ratio of \ref Material.
};
/// \struct SPP_Material
/// Data type for postprocessing step. More suitable container for material.
struct SPP_Material
{
/// Data type for post-processing step. More suitable container for material.
struct SPP_Material {
std::string ID;///< Material ID.
std::list<CAMFImporter_NodeElement_Metadata*> Metadata;///< Metadata of material.
CAMFImporter_NodeElement_Color* Color;///< Color of material.
std::list<SPP_Composite> Composition;///< List of child materials if current material is composition of few another.
/// \fn aiColor4D GetColor(const float pX, const float pY, const float pZ) const
/// Return color calculated for specified coordinate.
/// \param [in] pX - "x" coordinate.
/// \param [in] pY - "y" coordinate.
@ -135,64 +126,22 @@ private:
aiColor4D GetColor(const float pX, const float pY, const float pZ) const;
};
/// \struct SPP_Texture
/// Data type for post-processing step. More suitable container for texture.
struct SPP_Texture
{
struct SPP_Texture {
std::string ID;
size_t Width, Height, Depth;
bool Tiled;
char FormatHint[ 9 ];// 8 for string + 1 for terminator.
char FormatHint[9];// 8 for string + 1 for terminator.
uint8_t *Data;
};
/// \struct SComplexFace
/// Data type for post-processing step. Contain face data.
struct SComplexFace
{
struct SComplexFace {
aiFace Face;///< Face vertices.
const CAMFImporter_NodeElement_Color* Color;///< Face color. Equal to nullptr if color is not set for the face.
const CAMFImporter_NodeElement_TexMap* TexMap;///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face.
};
/***********************************************/
/****************** Constants ******************/
/***********************************************/
private:
static const aiImporterDesc Description;
/***********************************************/
/****************** Variables ******************/
/***********************************************/
private:
CAMFImporter_NodeElement* mNodeElement_Cur;///< Current element.
std::list<CAMFImporter_NodeElement*> mNodeElement_List;///< All elements of scene graph.
irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object
std::string mUnit;
std::list<SPP_Material> mMaterial_Converted;///< List of converted materials for postprocessing step.
std::list<SPP_Texture> mTexture_Converted;///< List of converted textures for postprocessing step.
/***********************************************/
/****************** Functions ******************/
/***********************************************/
private:
/// \fn AMFImporter(const AMFImporter& pScene)
/// Disabled copy constructor.
AMFImporter(const AMFImporter& pScene);
/// \fn AMFImporter& operator=(const AMFImporter& pScene)
/// Disabled assign operator.
AMFImporter& operator=(const AMFImporter& pScene);
/// \fn void Clear()
/// Clear all temporary data.
void Clear();
@ -200,7 +149,6 @@ private:
/************* Functions: find set *************/
/***********************************************/
/// \fn bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, aiNode** pNode) const
/// Find specified node element in node elements list ( \ref mNodeElement_List).
/// \param [in] pID - ID(name) of requested node element.
/// \param [in] pType - type of node element.
@ -208,7 +156,6 @@ private:
/// \return true - if the node element is found, else - false.
bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement** pNodeElement) const;
/// \fn bool Find_ConvertedNode(const std::string& pID, std::list<aiNode*>& pNodeList, aiNode** pNode) const
/// Find requested aiNode in node list.
/// \param [in] pID - ID(name) of requested node.
/// \param [in] pNodeList - list of nodes where to find the node.
@ -216,14 +163,12 @@ private:
/// \return true - if the node is found, else - false.
bool Find_ConvertedNode(const std::string& pID, std::list<aiNode*>& pNodeList, aiNode** pNode) const;
/// \fn bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const
/// Find material in list for converted materials. Use at postprocessing step.
/// \param [in] pID - material ID.
/// \param [out] pConvertedMaterial - pointer to found converted material (\ref SPP_Material).
/// \return true - if the material is found, else - false.
bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const;
/// \fn bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A, uint32_t* pConvertedTextureIndex = nullptr) const
/// Find texture in list of converted textures. Use at postprocessing step,
/// \param [in] pID_R - ID of source "red" texture.
/// \param [in] pID_G - ID of source "green" texture.
@ -235,11 +180,7 @@ private:
bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A,
uint32_t* pConvertedTextureIndex = nullptr) const;
/***********************************************/
/********* Functions: postprocess set **********/
/***********************************************/
/// \fn void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector<aiVector3D>& pVertexCoordinateArray, std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray) const
/// Get data stored in <vertices> and place it to arrays.
/// \param [in] pNodeElement - reference to node element which kept <object> data.
/// \param [in] pVertexCoordinateArray - reference to vertices coordinates kept in <vertices>.
@ -248,7 +189,6 @@ private:
void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector<aiVector3D>& pVertexCoordinateArray,
std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray) const;
/// \fn size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A)
/// Return converted texture ID which related to specified source textures ID's. If converted texture does not exist then it will be created and ID on new
/// converted texture will be returned. Conversion: set of textures from \ref CAMFImporter_NodeElement_Texture to one \ref SPP_Texture and place it
/// to converted textures list.
@ -260,27 +200,23 @@ private:
/// \return index of the texture in array of the converted textures.
size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A);
/// \fn void PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace>& pInputList, std::list<std::list<SComplexFace> > pOutputList_Separated)
/// Separate input list by texture IDs. This step is needed because aiMesh can contain mesh which is use only one texture (or set: diffuse, bump etc).
/// \param [in] pInputList - input list with faces. Some of them can contain color or texture mapping, or both of them, or nothing. Will be cleared after
/// processing.
/// \param [out] pOutputList_Separated - output list of the faces lists. Separated faces list by used texture IDs. Will be cleared before processing.
void PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace>& pInputList, std::list<std::list<SComplexFace> >& pOutputList_Separated);
/// \fn void Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& pMetadataList, aiNode& pSceneNode) const
/// Check if child elements of node element is metadata and add it to scene node.
/// \param [in] pMetadataList - reference to list with collected metadata.
/// \param [out] pSceneNode - scene node in which metadata will be added.
void Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& pMetadataList, aiNode& pSceneNode) const;
/// \fn void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list<aiMesh*>& pMeshList, aiNode** pSceneNode)
/// To create aiMesh and aiNode for it from <object>.
/// \param [in] pNodeElement - reference to node element which kept <object> data.
/// \param [out] pMeshList - reference to a list with all aiMesh of the scene.
/// \param [out] pSceneNode - pointer to place where new aiNode will be created.
void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list<aiMesh*>& pMeshList, aiNode** pSceneNode);
/// \fn void Postprocess_BuildMeshSet(const CAMFImporter_NodeElement_Mesh& pNodeElement, const std::vector<aiVector3D>& pVertexCoordinateArray, const std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor, std::list<aiMesh*>& pMeshList, aiNode& pSceneNode)
/// Create mesh for every <volume> in <mesh>.
/// \param [in] pNodeElement - reference to node element which kept <mesh> data.
/// \param [in] pVertexCoordinateArray - reference to vertices coordinates for all <volume>'s.
@ -294,27 +230,20 @@ private:
const std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor,
std::list<aiMesh*>& pMeshList, aiNode& pSceneNode);
/// \fn void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial)
/// Convert material from \ref CAMFImporter_NodeElement_Material to \ref SPP_Material.
/// \param [in] pMaterial - source CAMFImporter_NodeElement_Material.
void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial);
/// \fn void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list<aiNode*>& pNodeList) const
/// Create and add to aiNode's list new part of scene graph defined by <constellation>.
/// \param [in] pConstellation - reference to <constellation> node.
/// \param [out] pNodeList - reference to aiNode's list.
void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list<aiNode*>& pNodeList) const;
/// \fn void Postprocess_BuildScene()
/// Build Assimp scene graph in aiScene from collected data.
/// \param [out] pScene - pointer to aiScene where tree will be built.
void Postprocess_BuildScene(aiScene* pScene);
/***********************************************/
/************* Functions: throw set ************/
/***********************************************/
/// \fn void Throw_CloseNotFound(const std::string& pNode)
/// Call that function when close tag of node not found and exception must be raised.
/// E.g.:
/// <amf>
@ -324,19 +253,16 @@ private:
/// \param [in] pNode - node name in which exception happened.
void Throw_CloseNotFound(const std::string& pNode);
/// \fn void Throw_IncorrectAttr(const std::string& pAttrName)
/// Call that function when attribute name is incorrect and exception must be raised.
/// \param [in] pAttrName - attribute name.
/// \throw DeadlyImportError.
void Throw_IncorrectAttr(const std::string& pAttrName);
/// \fn void Throw_IncorrectAttrValue(const std::string& pAttrName)
/// Call that function when attribute value is incorrect and exception must be raised.
/// \param [in] pAttrName - attribute name.
/// \throw DeadlyImportError.
void Throw_IncorrectAttrValue(const std::string& pAttrName);
/// \fn void Throw_MoreThanOnceDefined(const std::string& pNode, const std::string& pDescription)
/// Call that function when some type of nodes are defined twice or more when must be used only once and exception must be raised.
/// E.g.:
/// <object>
@ -348,204 +274,158 @@ private:
/// \param [in] pDescription - message about error. E.g. what the node defined while exception raised.
void Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription);
/// \fn void Throw_ID_NotFound(const std::string& pID) const
/// Call that function when referenced element ID are not found in graph and exception must be raised.
/// \param [in] pID - ID of of element which not found.
/// \throw DeadlyImportError.
void Throw_ID_NotFound(const std::string& pID) const;
/***********************************************/
/************** Functions: LOG set *************/
/***********************************************/
/***********************************************/
/************** Functions: XML set *************/
/***********************************************/
/// \fn void XML_CheckNode_MustHaveChildren()
/// Check if current node have children: <node>...</node>. If not then exception will throwed.
void XML_CheckNode_MustHaveChildren();
/// \fn bool XML_CheckNode_NameEqual(const std::string& pNodeName)
/// Check if current node name is equal to pNodeName.
/// \param [in] pNodeName - name for checking.
/// return true if current node name is equal to pNodeName, else - false.
bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; }
/// \fn void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName)
/// Skip unsupported node and report about that. Depend on node name can be skipped begin tag of node all whole node.
/// \param [in] pParentNodeName - parent node name. Used for reporting.
void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName);
/// \fn bool XML_SearchNode(const std::string& pNodeName)
/// Search for specified node in file. XML file read pointer(mReader) will point to found node or file end after search is end.
/// \param [in] pNodeName - requested node name.
/// return true - if node is found, else - false.
bool XML_SearchNode(const std::string& pNodeName);
/// \fn bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx)
/// Read attribute value.
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
/// \return read data.
bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx);
/// \fn float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx)
/// Read attribute value.
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
/// \return read data.
float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx);
/// \fn uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx)
/// Read attribute value.
/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
/// \return read data.
uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx);
/// \fn float XML_ReadNode_GetVal_AsFloat()
/// Read node value.
/// \return read data.
float XML_ReadNode_GetVal_AsFloat();
/// \fn uint32_t XML_ReadNode_GetVal_AsU32()
/// Read node value.
/// \return read data.
uint32_t XML_ReadNode_GetVal_AsU32();
/// \fn void XML_ReadNode_GetVal_AsString(std::string& pValue)
/// Read node value.
/// \return read data.
void XML_ReadNode_GetVal_AsString(std::string& pValue);
/***********************************************/
/******** Functions: parse set private *********/
/***********************************************/
/// \fn void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode)
/// Make pNode as current and enter deeper for parsing child nodes. At end \ref ParseHelper_Node_Exit must be called.
/// \param [in] pNode - new current node.
void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode);
/// \fn void ParseHelper_Group_End()
/// This function must be called when exiting from grouping node. \ref ParseHelper_Group_Begin.
void ParseHelper_Node_Exit();
/// \fn void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString)
/// Attribute values of floating point types can take form ".x"(without leading zero). irrXMLReader can not read this form of values and it
/// must be converted to right form - "0.xxx".
/// \param [in] pInStr - pointer to input string which can contain incorrect form of values.
/// \param [out[ pOutString - output string with right form of values.
void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString);
/// \fn void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const
/// Decode Base64-encoded data.
/// \param [in] pInputBase64 - reference to input Base64-encoded string.
/// \param [out] pOutputData - reference to output array for decoded data.
void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const;
/// \fn void ParseNode_Root()
/// Parse <AMF> node of the file.
void ParseNode_Root();
/******** Functions: top nodes *********/
/// \fn void ParseNode_Constellation()
/// Parse <constellation> node of the file.
void ParseNode_Constellation();
/// \fn void ParseNode_Constellation()
/// Parse <instance> node of the file.
void ParseNode_Instance();
/// \fn void ParseNode_Material()
/// Parse <material> node of the file.
void ParseNode_Material();
/// \fn void ParseNode_Metadata()
/// Parse <metadata> node.
void ParseNode_Metadata();
/// \fn void ParseNode_Object()
/// Parse <object> node of the file.
void ParseNode_Object();
/// \fn void ParseNode_Texture()
/// Parse <texture> node of the file.
void ParseNode_Texture();
/******** Functions: geometry nodes *********/
/// \fn void ParseNode_Coordinates()
/// Parse <coordinates> node of the file.
void ParseNode_Coordinates();
/// \fn void ParseNode_Edge()
/// Parse <edge> node of the file.
void ParseNode_Edge();
/// \fn void ParseNode_Mesh()
/// Parse <mesh> node of the file.
void ParseNode_Mesh();
/// \fn void ParseNode_Triangle()
/// Parse <triangle> node of the file.
void ParseNode_Triangle();
/// \fn void ParseNode_Vertex()
/// Parse <vertex> node of the file.
void ParseNode_Vertex();
/// \fn void ParseNode_Vertices()
/// Parse <vertices> node of the file.
void ParseNode_Vertices();
/// \fn void ParseNode_Volume()
/// Parse <volume> node of the file.
void ParseNode_Volume();
/******** Functions: material nodes *********/
/// \fn void ParseNode_Color()
/// Parse <color> node of the file.
void ParseNode_Color();
/// \fn void ParseNode_TexMap(const bool pUseOldName = false)
/// Parse <texmap> of <map> node of the file.
/// \param [in] pUseOldName - if true then use old name of node(and children) - <map>, instead of new name - <texmap>.
void ParseNode_TexMap(const bool pUseOldName = false);
public:
/// \fn AMFImporter()
/// Default constructor.
AMFImporter()
: mNodeElement_Cur(nullptr), mReader(nullptr)
{}
AMFImporter() noexcept
: mNodeElement_Cur(nullptr)
, mReader(nullptr) {
// empty
}
/// \fn ~AMFImporter()
/// Default destructor.
~AMFImporter();
/***********************************************/
/******** Functions: parse set, public *********/
/***********************************************/
/// \fn void ParseFile(const std::string& pFile, IOSystem* pIOHandler)
/// Parse AMF file and fill scene graph. The function has no return value. Result can be found by analyzing the generated graph.
/// Also exception can be throwed if trouble will found.
/// Also exception can be thrown if trouble will found.
/// \param [in] pFile - name of file to be parsed.
/// \param [in] pIOHandler - pointer to IO helper object.
void ParseFile(const std::string& pFile, IOSystem* pIOHandler);
/***********************************************/
/********* Functions: BaseImporter set *********/
/***********************************************/
bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const;
void GetExtensionList(std::set<std::string>& pExtensionList);
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
const aiImporterDesc* GetInfo ()const;
};// class AMFImporter
AMFImporter(const AMFImporter& pScene) = delete;
AMFImporter& operator=(const AMFImporter& pScene) = delete;
private:
static const aiImporterDesc Description;
CAMFImporter_NodeElement* mNodeElement_Cur;///< Current element.
std::list<CAMFImporter_NodeElement*> mNodeElement_List;///< All elements of scene graph.
irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object
std::string mUnit;
std::list<SPP_Material> mMaterial_Converted;///< List of converted materials for postprocessing step.
std::list<SPP_Texture> mTexture_Converted;///< List of converted textures for postprocessing step.
};
}// namespace Assimp

View File

@ -68,10 +68,9 @@ namespace Assimp
// Multi elements - No.
// Red, Greed, Blue and Alpha (transparency) component of a color in sRGB space, values ranging from 0 to 1. The
// values can be specified as constants, or as a formula depending on the coordinates.
void AMFImporter::ParseNode_Color()
{
std::string profile;
CAMFImporter_NodeElement* ne;
void AMFImporter::ParseNode_Color() {
std::string profile;
CAMFImporter_NodeElement* ne;
// Read attributes for node <color>.
MACRO_ATTRREAD_LOOPBEG;
@ -98,15 +97,19 @@ CAMFImporter_NodeElement* ne;
MACRO_NODECHECK_LOOPEND("color");
ParseHelper_Node_Exit();
// check that all components was defined
if(!(read_flag[0] && read_flag[1] && read_flag[2])) throw DeadlyImportError("Not all color components are defined.");
// check if <a> is absent. Then manually add "a == 1".
if(!read_flag[3]) als.Color.a = 1;
if (!(read_flag[0] && read_flag[1] && read_flag[2])) {
throw DeadlyImportError("Not all color components are defined.");
}
}// if(!mReader->isEmptyElement())
// check if <a> is absent. Then manually add "a == 1".
if (!read_flag[3]) {
als.Color.a = 1;
}
}
else
{
mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
}// if(!mReader->isEmptyElement()) else
}
als.Composed = false;
mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
@ -119,10 +122,9 @@ CAMFImporter_NodeElement* ne;
// An available material.
// Multi elements - Yes.
// Parent element - <amf>.
void AMFImporter::ParseNode_Material()
{
std::string id;
CAMFImporter_NodeElement* ne;
void AMFImporter::ParseNode_Material() {
std::string id;
CAMFImporter_NodeElement* ne;
// Read attributes for node <color>.
MACRO_ATTRREAD_LOOPBEG;
@ -131,8 +133,10 @@ CAMFImporter_NodeElement* ne;
// create new object.
ne = new CAMFImporter_NodeElement_Material(mNodeElement_Cur);
// and assign read data
((CAMFImporter_NodeElement_Material*)ne)->ID = id;
// Check for child nodes
if(!mReader->isEmptyElement())
{
@ -154,11 +158,11 @@ CAMFImporter_NodeElement* ne;
if(XML_CheckNode_NameEqual("metadata")) { ParseNode_Metadata(); continue; }
MACRO_NODECHECK_LOOPEND("material");
ParseHelper_Node_Exit();
}// if(!mReader->isEmptyElement())
}
else
{
mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
}// if(!mReader->isEmptyElement()) else
}
mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
}
@ -181,14 +185,13 @@ CAMFImporter_NodeElement* ne;
// Parent element - <amf>.
void AMFImporter::ParseNode_Texture()
{
std::string id;
uint32_t width = 0;
uint32_t height = 0;
uint32_t depth = 1;
std::string type;
bool tiled = false;
std::string enc64_data;
CAMFImporter_NodeElement* ne;
std::string id;
uint32_t width = 0;
uint32_t height = 0;
uint32_t depth = 1;
std::string type;
bool tiled = false;
std::string enc64_data;
// Read attributes for node <color>.
MACRO_ATTRREAD_LOOPBEG;
@ -201,20 +204,34 @@ CAMFImporter_NodeElement* ne;
MACRO_ATTRREAD_LOOPEND;
// create new texture object.
ne = new CAMFImporter_NodeElement_Texture(mNodeElement_Cur);
CAMFImporter_NodeElement *ne = new CAMFImporter_NodeElement_Texture(mNodeElement_Cur);
CAMFImporter_NodeElement_Texture& als = *((CAMFImporter_NodeElement_Texture*)ne);// alias for convenience
// Check for child nodes
if(!mReader->isEmptyElement()) XML_ReadNode_GetVal_AsString(enc64_data);
if (!mReader->isEmptyElement()) {
XML_ReadNode_GetVal_AsString(enc64_data);
}
// check that all components was defined
if(id.empty()) throw DeadlyImportError("ID for texture must be defined.");
if(width < 1) Throw_IncorrectAttrValue("width");
if(height < 1) Throw_IncorrectAttrValue("height");
if(depth < 1) Throw_IncorrectAttrValue("depth");
if(type != "grayscale") Throw_IncorrectAttrValue("type");
if(enc64_data.empty()) throw DeadlyImportError("Texture data not defined.");
if (id.empty()) {
throw DeadlyImportError("ID for texture must be defined.");
}
if (width < 1) {
Throw_IncorrectAttrValue("width");
}
if (height < 1) {
Throw_IncorrectAttrValue("height");
}
if (depth < 1) {
Throw_IncorrectAttrValue("depth");
}
if (type != "grayscale") {
Throw_IncorrectAttrValue("type");
}
if (enc64_data.empty()) {
throw DeadlyImportError("Texture data not defined.");
}
// copy data
als.ID = id;
als.Width = width;
@ -222,8 +239,11 @@ CAMFImporter_NodeElement* ne;
als.Depth = depth;
als.Tiled = tiled;
ParseHelper_Decode_Base64(enc64_data, als.Data);
// check data size
if((width * height * depth) != als.Data.size()) throw DeadlyImportError("Texture has incorrect data size.");
if ((width * height * depth) != als.Data.size()) {
throw DeadlyImportError("Texture has incorrect data size.");
}
mNodeElement_Cur->Child.push_back(ne);// Add element to child list of current element
mNodeElement_List.push_back(ne);// and to node element list because its a new object in graph.
@ -243,10 +263,8 @@ CAMFImporter_NodeElement* ne;
// <utex1>, <utex2>, <utex3>, <vtex1>, <vtex2>, <vtex3>. Old name: <u1>, <u2>, <u3>, <v1>, <v2>, <v3>.
// Multi elements - No.
// Texture coordinates for every vertex of triangle.
void AMFImporter::ParseNode_TexMap(const bool pUseOldName)
{
std::string rtexid, gtexid, btexid, atexid;
CAMFImporter_NodeElement* ne;
void AMFImporter::ParseNode_TexMap(const bool pUseOldName) {
std::string rtexid, gtexid, btexid, atexid;
// Read attributes for node <color>.
MACRO_ATTRREAD_LOOPBEG;
@ -257,7 +275,7 @@ CAMFImporter_NodeElement* ne;
MACRO_ATTRREAD_LOOPEND;
// create new texture coordinates object.
ne = new CAMFImporter_NodeElement_TexMap(mNodeElement_Cur);
CAMFImporter_NodeElement *ne = new CAMFImporter_NodeElement_TexMap(mNodeElement_Cur);
CAMFImporter_NodeElement_TexMap& als = *((CAMFImporter_NodeElement_TexMap*)ne);// alias for convenience
// check data

View File

@ -62,7 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/// \class CAMFImporter_NodeElement
/// Base class for elements of nodes.
class CAMFImporter_NodeElement {
public:
/// Define what data type contain node element.
enum EType {
@ -96,15 +95,11 @@ public: /// Destructor, virtual..
// empty
}
private:
/// Disabled copy constructor.
CAMFImporter_NodeElement(const CAMFImporter_NodeElement& pNodeElement);
/// Disabled assign operator.
CAMFImporter_NodeElement& operator=(const CAMFImporter_NodeElement& pNodeElement);
/// Disabled default constructor.
CAMFImporter_NodeElement();
/// Disabled copy constructor and co.
CAMFImporter_NodeElement(const CAMFImporter_NodeElement& pNodeElement) = delete;
CAMFImporter_NodeElement(CAMFImporter_NodeElement&&) = delete;
CAMFImporter_NodeElement& operator=(const CAMFImporter_NodeElement& pNodeElement) = delete;
CAMFImporter_NodeElement() = delete;
protected:
/// In constructor inheritor must set element type.
@ -200,30 +195,27 @@ struct CAMFImporter_NodeElement_Root : public CAMFImporter_NodeElement
/// \struct CAMFImporter_NodeElement_Color
/// Structure that define object node.
struct CAMFImporter_NodeElement_Color : public CAMFImporter_NodeElement
{
/****************** Variables ******************/
struct CAMFImporter_NodeElement_Color : public CAMFImporter_NodeElement {
bool Composed; ///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color.
std::string Color_Composed[4]; ///< By components formulas of composed color. [0..3] - RGBA.
aiColor4D Color; ///< Constant color.
std::string Profile; ///< The ICC color space used to interpret the three color channels r, g and b..
bool Composed;///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color.
std::string Color_Composed[4];///< By components formulas of composed color. [0..3] => RGBA.
aiColor4D Color;///< Constant color.
std::string Profile;///< The ICC color space used to interpret the three color channels <r>, <g> and <b>..
/****************** Functions ******************/
/// \fn CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent)
/// Constructor.
/// \param [in] pParent - pointer to parent node.
/// @brief Constructor.
/// @param [in] pParent - pointer to parent node.
CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent)
: CAMFImporter_NodeElement(ENET_Color, pParent)
{}
};// struct CAMFImporter_NodeElement_Color
, Composed( false )
, Color_Composed{""}
, Color()
, Profile() {
// empty
}
};
/// \struct CAMFImporter_NodeElement_Material
/// Structure that define material node.
struct CAMFImporter_NodeElement_Material : public CAMFImporter_NodeElement
{
struct CAMFImporter_NodeElement_Material : public CAMFImporter_NodeElement {
/// \fn CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent)
/// Constructor.
/// \param [in] pParent - pointer to parent node.
@ -339,43 +331,39 @@ struct CAMFImporter_NodeElement_Coordinates : public CAMFImporter_NodeElement
/// \struct CAMFImporter_NodeElement_TexMap
/// Structure that define texture coordinates node.
struct CAMFImporter_NodeElement_TexMap : public CAMFImporter_NodeElement
{
/****************** Variables ******************/
struct CAMFImporter_NodeElement_TexMap : public CAMFImporter_NodeElement {
aiVector3D TextureCoordinate[3];///< Texture coordinates.
std::string TextureID_R;///< Texture ID for red color component.
std::string TextureID_G;///< Texture ID for green color component.
std::string TextureID_B;///< Texture ID for blue color component.
std::string TextureID_A;///< Texture ID for alpha color component.
/****************** Functions ******************/
/// \fn CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent)
/// Constructor.
/// \param [in] pParent - pointer to parent node.
CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent)
: CAMFImporter_NodeElement(ENET_TexMap, pParent)
{}
};// struct CAMFImporter_NodeElement_TexMap
, TextureCoordinate{}
, TextureID_R()
, TextureID_G()
, TextureID_B()
, TextureID_A() {
// empty
}
};
/// \struct CAMFImporter_NodeElement_Triangle
/// Structure that define triangle node.
struct CAMFImporter_NodeElement_Triangle : public CAMFImporter_NodeElement
{
/****************** Variables ******************/
struct CAMFImporter_NodeElement_Triangle : public CAMFImporter_NodeElement {
size_t V[3];///< Triangle vertices.
/****************** Functions ******************/
/// \fn CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent)
/// Constructor.
/// \param [in] pParent - pointer to parent node.
CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent)
: CAMFImporter_NodeElement(ENET_Triangle, pParent)
{}
, V{}{
// empty
}
};// struct CAMFImporter_NodeElement_Triangle

View File

@ -85,7 +85,7 @@ struct Material : public D3DS::Material
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
Material(Material &&other)
Material(Material &&other) noexcept
: D3DS::Material(std::move(other))
, avSubMaterials(std::move(other.avSubMaterials))
, pcInstance(std::move(other.pcInstance))
@ -95,7 +95,7 @@ struct Material : public D3DS::Material
}
Material &operator=(Material &&other) {
Material &operator=(Material &&other) noexcept {
if (this == &other) {
return *this;
}
@ -127,19 +127,14 @@ struct Material : public D3DS::Material
// ---------------------------------------------------------------------------
/** Helper structure to represent an ASE file face */
struct Face : public FaceWithSmoothingGroup
{
struct Face : public FaceWithSmoothingGroup {
//! Default constructor. Initializes everything with 0
Face()
{
mColorIndices[0] = mColorIndices[1] = mColorIndices[2] = 0;
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
{
amUVIndices[i][0] = amUVIndices[i][1] = amUVIndices[i][2] = 0;
}
iMaterial = DEFAULT_MATINDEX;
iFace = 0;
Face() noexcept
: amUVIndices{0}
, mColorIndices{0}
, iMaterial(DEFAULT_MATINDEX)
, iFace(0) {
// empty
}
//! special value to indicate that no material index has
@ -147,8 +142,6 @@ struct Face : public FaceWithSmoothingGroup
//! will replace this value later.
static const unsigned int DEFAULT_MATINDEX = 0xFFFFFFFF;
//! Indices into each list of texture coordinates
unsigned int amUVIndices[AI_MAX_NUMBER_OF_TEXTURECOORDS][3];
@ -204,7 +197,7 @@ struct Animation
TCB = 0x2
} mRotationType, mScalingType, mPositionType;
Animation()
Animation() noexcept
: mRotationType (TRACK)
, mScalingType (TRACK)
, mPositionType (TRACK)
@ -223,14 +216,13 @@ struct Animation
// ---------------------------------------------------------------------------
/** Helper structure to represent the inheritance information of an ASE node */
struct InheritanceInfo
{
struct InheritanceInfo {
//! Default constructor
InheritanceInfo()
{
// set the inheritance flag for all axes by default to true
for (unsigned int i = 0; i < 3;++i)
abInheritPosition[i] = abInheritRotation[i] = abInheritScaling[i] = true;
InheritanceInfo() noexcept
: abInheritPosition{true}
, abInheritRotation{true}
, abInheritScaling{true} {
// empty
}
//! Inherit the parent's position?, axis order is x,y,z
@ -291,24 +283,23 @@ struct BaseNode
// ---------------------------------------------------------------------------
/** Helper structure to represent an ASE file mesh */
struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode
{
struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode {
//! Default constructor has been deleted
Mesh() = delete;
//! Construction from an existing name
explicit Mesh(const std::string &name)
: BaseNode (BaseNode::Mesh, name)
: BaseNode( BaseNode::Mesh, name )
, amTexCoords{ }
, mVertexColors()
, mBoneVertices()
, mBones()
, iMaterialIndex(Face::DEFAULT_MATINDEX)
, bSkip (false)
{
// use 2 texture vertex components by default
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
this->mNumUVComponents[c] = 2;
, mNumUVComponents{ 2 }
, bSkip (false) {
// empty
}
//! List of all texture coordinate sets
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
@ -396,12 +387,11 @@ struct Camera : public BaseNode
// ---------------------------------------------------------------------------
/** Helper structure to represent an ASE helper object (dummy) */
struct Dummy : public BaseNode
{
struct Dummy : public BaseNode {
//! Constructor
Dummy()
: BaseNode (BaseNode::Dummy, "DUMMY")
{
Dummy() noexcept
: BaseNode (BaseNode::Dummy, "DUMMY") {
// empty
}
};
@ -416,12 +406,11 @@ struct Dummy : public BaseNode
// -------------------------------------------------------------------------------
/** \brief Class to parse ASE files
*/
class Parser
{
class Parser {
private:
Parser() {}
Parser() noexcept {
// empty
}
public:

View File

@ -65,7 +65,7 @@ using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
BaseImporter::BaseImporter()
BaseImporter::BaseImporter() noexcept
: m_progress() {
// nothing to do here
}

View File

@ -53,7 +53,7 @@ using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
BaseProcess::BaseProcess()
BaseProcess::BaseProcess() noexcept
: shared()
, progress()
{

View File

@ -211,20 +211,16 @@ private:
* should be executed. If the function returns true, the class' Execute()
* function is called subsequently.
*/
class ASSIMP_API_WINONLY BaseProcess
{
class ASSIMP_API_WINONLY BaseProcess {
friend class Importer;
public:
/** Constructor to be privately used by Importer */
BaseProcess();
BaseProcess() noexcept;
/** Destructor, private as well */
virtual ~BaseProcess();
public:
// -------------------------------------------------------------------
/** Returns whether the processing step is present in the given flag.
* @param pFlags The processing flags the importer was called with. A

View File

@ -137,9 +137,7 @@ void COBImporter::SetupProperties(const Importer* /*pImp*/)
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
void COBImporter::InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler)
{
void COBImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
COB::Scene scene;
std::unique_ptr<StreamReaderLE> stream(new StreamReaderLE( pIOHandler->Open(pFile,"rb")) );

View File

@ -119,7 +119,7 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
}
}
aiTexel* imageContent = new aiTexel[1u + imageSize / sizeof(aiTexel)];
aiTexel* imageContent = new aiTexel[ 1ul + static_cast<unsigned long>( imageSize ) / sizeof(aiTexel)];
file.seekg(0, std::ios::beg);
file.read(reinterpret_cast<char*>(imageContent), imageSize);

View File

@ -120,11 +120,11 @@ public:
SharedPostProcessInfo* mPPShared;
/// The default class constructor.
ImporterPimpl();
ImporterPimpl() noexcept;
};
inline
ImporterPimpl::ImporterPimpl()
ImporterPimpl::ImporterPimpl() noexcept
: mIOHandler( nullptr )
, mIsDefaultHandler( false )
, mProgressHandler( nullptr )

View File

@ -113,14 +113,14 @@ enum PrePostBehaviour
// ---------------------------------------------------------------------------
/** \brief Data structure for a LWO animation keyframe
*/
struct Key
{
Key()
: time(),
value(),
inter (IT_LINE),
params()
{}
struct Key {
Key() noexcept
: time()
, value()
, inter(IT_LINE)
, params() {
// empty
}
//! Current time
double time;
@ -144,17 +144,16 @@ struct Key
// ---------------------------------------------------------------------------
/** \brief Data structure for a LWO animation envelope
*/
struct Envelope
{
Envelope()
struct Envelope {
Envelope() noexcept
: index()
, type (EnvelopeType_Unknown)
, pre (PrePostBehaviour_Constant)
, post (PrePostBehaviour_Constant)
, old_first (0)
, old_last (0)
{}
, type(EnvelopeType_Unknown)
, pre(PrePostBehaviour_Constant)
, post(PrePostBehaviour_Constant)
, old_first(0)
, old_last(0) {
// empty
}
//! Index of this envelope
unsigned int index;
@ -162,7 +161,7 @@ struct Envelope
//! Type of envelope
EnvelopeType type;
//! Pre and post-behaviour
//! Pre- and post-behavior
PrePostBehaviour pre,post;
//! Keyframes for this envelope

View File

@ -261,14 +261,14 @@ namespace LWO {
* \note We can't use the code in SmoothingGroups.inl here - the mesh
* structures of 3DS/ASE and LWO are too different.
*/
struct Face : public aiFace
{
struct Face : public aiFace {
//! Default construction
Face()
: surfaceIndex (0)
, smoothGroup (0)
, type (AI_LWO_FACE)
{}
Face() noexcept
: surfaceIndex( 0 )
, smoothGroup( 0 )
, type( AI_LWO_FACE ) {
// empty
}
//! Construction from given type
explicit Face(uint32_t _type)

View File

@ -120,7 +120,7 @@ public:
{
unsigned int mBone; ///< Index of the bone
float mWeight; ///< Weight of that bone on this vertex
Weight()
Weight() noexcept
: mBone(0)
, mWeight(0.0f)
{ }

View File

@ -125,7 +125,7 @@ enum AlphaTestFunc
*/
struct ShaderMapBlock
{
ShaderMapBlock()
ShaderMapBlock() noexcept
: blend_src (BLEND_NONE)
, blend_dest (BLEND_NONE)
, alpha_test (AT_NONE)
@ -150,7 +150,7 @@ struct ShaderMapBlock
*/
struct ShaderDataBlock
{
ShaderDataBlock()
ShaderDataBlock() noexcept
: cull (CULL_CW)
{}

View File

@ -192,14 +192,14 @@ typedef std::vector< FrameDesc > FrameList;
// ---------------------------------------------------------------------------
/** Represents a vertex descriptor in a MD5 file
*/
struct VertexDesc
{
VertexDesc()
: mFirstWeight (0)
, mNumWeights (0)
{}
struct VertexDesc {
VertexDesc() noexcept
: mFirstWeight(0)
, mNumWeights(0) {
// empty
}
//! UV cordinate of the vertex
//! UV coordinate of the vertex
aiVector2D mUV;
//! Index of the first weight of the vertex in

View File

@ -118,23 +118,23 @@ struct Surface
uint32_t ulOffsetFrameBaseFrames ;
uint32_t ulOffsetFrameCompFrames ;
uint32_t ulOffsetEnd;
Surface()
: ulIdent(),
ulFlags(),
ulNumCompFrames(),
ulNumBaseFrames(),
ulNumShaders(),
ulNumVertices(),
ulNumTriangles(),
ulOffsetTriangles(),
ulOffsetShaders(),
ulOffsetTexCoords(),
ulOffsetBaseVerts(),
ulOffsetCompVerts(),
ulOffsetFrameBaseFrames(),
ulOffsetFrameCompFrames(),
ulOffsetEnd()
{
Surface() noexcept
: ulIdent()
, ucName{ 0 }
, ulFlags()
, ulNumCompFrames()
, ulNumBaseFrames()
, ulNumShaders()
, ulNumVertices()
, ulNumTriangles()
, ulOffsetTriangles()
, ulOffsetShaders()
, ulOffsetTexCoords()
, ulOffsetBaseVerts()
, ulOffsetCompVerts()
, ulOffsetFrameBaseFrames()
, ulOffsetFrameCompFrames()
, ulOffsetEnd() {
ucName[AI_MDC_MAXQPATH-1] = '\0';
}
} PACK_STRUCT;

View File

@ -717,11 +717,10 @@ struct GroupFrame
*/
struct IntFace_MDL7 {
// provide a constructor for our own convenience
IntFace_MDL7()
{
// set everything to zero
mIndices[0] = mIndices[1] = mIndices[2] = 0;
iMatIndex[0] = iMatIndex[1] = 0;
IntFace_MDL7() noexcept
: mIndices { 0 }
, iMatIndex{ 0 } {
// empty
}
//! Vertex indices
@ -737,13 +736,12 @@ struct IntFace_MDL7 {
* which has been created from two single materials along with the
* original material indices.
*/
struct IntMaterial_MDL7
{
struct IntMaterial_MDL7 {
// provide a constructor for our own convenience
IntMaterial_MDL7()
{
pcMat = NULL;
iOldMatIndices[0] = iOldMatIndices[1] = 0;
IntMaterial_MDL7() noexcept
: pcMat( nullptr )
, iOldMatIndices{ 0 } {
// empty
}
//! Material instance
@ -761,7 +759,7 @@ struct IntMaterial_MDL7
struct IntBone_MDL7 : aiBone
{
//! Default constructor
IntBone_MDL7() : iParent (0xffff)
IntBone_MDL7() noexcept : iParent (0xffff)
{
pkeyPositions.reserve(30);
pkeyScalings.reserve(30);
@ -806,12 +804,12 @@ struct IntFrameInfo_MDL7
struct IntGroupInfo_MDL7
{
//! Default constructor
IntGroupInfo_MDL7()
IntGroupInfo_MDL7() noexcept
: iIndex(0)
, pcGroup(NULL)
, pcGroupUVs(NULL)
, pcGroupTris(NULL)
, pcGroupVerts(NULL)
, pcGroup(nullptr)
, pcGroupUVs(nullptr)
, pcGroupTris(nullptr)
, pcGroupVerts(nullptr)
{}
//! Construction from an existing group header
@ -843,7 +841,7 @@ struct IntGroupInfo_MDL7
//! Holds the data that belongs to a MDL7 mesh group
struct IntGroupData_MDL7
{
IntGroupData_MDL7()
IntGroupData_MDL7() noexcept
: bNeed2UV(false)
{}
@ -872,10 +870,9 @@ struct IntGroupData_MDL7
// -------------------------------------------------------------------------------------
//! Holds data from an MDL7 file that is shared by all mesh groups
struct IntSharedData_MDL7
{
struct IntSharedData_MDL7 {
//! Default constructor
IntSharedData_MDL7()
IntSharedData_MDL7() noexcept
: apcOutBones(),
iNum()
{

View File

@ -67,20 +67,22 @@ namespace Assimp {
class OptimizeMeshesProcess : public BaseProcess
{
public:
/// @brief The class constructor.
OptimizeMeshesProcess();
/// @brief The class destcructor,
~OptimizeMeshesProcess();
/** @brief Internal utility to store additional mesh info
*/
struct MeshInfo
{
MeshInfo()
: instance_cnt (0)
, vertex_format (0)
, output_id (0xffffffff)
{}
struct MeshInfo {
MeshInfo() noexcept
: instance_cnt(0)
, vertex_format(0)
, output_id(0xffffffff) {
// empty
}
//! Number of times this mesh is referenced
unsigned int instance_cnt;

View File

@ -209,7 +209,7 @@ enum EElementSemantic {
class Property {
public:
//! Default constructor
Property()
Property() noexcept
: eType (EDT_Int)
, Semantic()
, bIsList(false)
@ -257,7 +257,7 @@ public:
class Element {
public:
//! Default constructor
Element()
Element() noexcept
: eSemantic (EEST_INVALID)
, NumOccur(0) {
// empty
@ -297,8 +297,9 @@ class PropertyInstance
public:
//! Default constructor
PropertyInstance ()
{}
PropertyInstance() noexcept {
// empty
}
union ValueUnion
{
@ -356,13 +357,13 @@ public:
// ---------------------------------------------------------------------------------
/** \brief Class for an element instance in a PLY file
*/
class ElementInstance
{
class ElementInstance {
public:
//! Default constructor
ElementInstance ()
{}
ElementInstance() noexcept
: alProperties() {
// empty
}
//! List of all parsed properties
std::vector< PropertyInstance > alProperties;
@ -386,8 +387,10 @@ class ElementInstanceList
public:
//! Default constructor
ElementInstanceList ()
{}
ElementInstanceList() noexcept
: alInstances() {
// empty
}
//! List of all element instances
std::vector< ElementInstance > alInstances;
@ -411,8 +414,11 @@ class DOM
public:
//! Default constructor
DOM()
{}
DOM() noexcept
: alElements()
, alElementData() {
}
//! Contains all elements of the file format

View File

@ -63,16 +63,16 @@ struct aiNode;
#include <vector>
namespace Assimp {
namespace SMD {
// ---------------------------------------------------------------------------
/** Data structure for a vertex in a SMD file
*/
struct Vertex
{
Vertex() : iParentNode(UINT_MAX)
{}
struct Vertex {
Vertex() noexcept
: iParentNode(UINT_MAX) {
// empty
}
//! Vertex position, normal and texture coordinate
aiVector3D pos,nor,uv;
@ -90,10 +90,12 @@ struct Vertex
// ---------------------------------------------------------------------------
/** Data structure for a face in a SMD file
*/
struct Face
{
Face() : iTexture(0x0)
{}
struct Face {
Face() noexcept
: iTexture(0x0)
, avVertices{} {
// empty
}
//! Texture index for the face
unsigned int iTexture;
@ -105,11 +107,12 @@ struct Face
// ---------------------------------------------------------------------------
/** Data structure for a bone in a SMD file
*/
struct Bone
{
struct Bone {
//! Default constructor
Bone() : iParent(UINT_MAX), bIsUsed(false)
{
Bone() noexcept
: iParent(UINT_MAX)
, bIsUsed(false) {
// empty
}
//! Destructor
@ -124,12 +127,10 @@ struct Bone
uint32_t iParent;
//! Animation of the bone
struct Animation
{
struct Animation {
//! Public default constructor
Animation()
: iFirstTimeKey()
{
Animation() noexcept
: iFirstTimeKey() {
asKeys.reserve(20);
}

View File

@ -56,7 +56,7 @@ class Importer;
struct ScenePrivateData {
// The struct constructor.
ScenePrivateData();
ScenePrivateData() noexcept;
// Importer that originally loaded the scene though the C-API
// If set, this object is owned by this private data instance.
@ -74,7 +74,7 @@ struct ScenePrivateData {
};
inline
ScenePrivateData::ScenePrivateData()
ScenePrivateData::ScenePrivateData() noexcept
: mOrigImporter( nullptr )
, mPPStepsApplied( 0 )
, mIsCopy( false ) {

View File

@ -65,14 +65,14 @@ namespace Assimp {
/** Small helper structure representing a shortcut into the material list
* to be able to update some values quickly.
*/
struct TTUpdateInfo
{
TTUpdateInfo() :
directShortcut (NULL)
, mat (NULL)
, semantic (0)
, index (0)
{}
struct TTUpdateInfo {
TTUpdateInfo() noexcept
: directShortcut(nullptr)
, mat(nullptr)
, semantic(0)
, index(0) {
// empty
}
//! Direct shortcut, if available
unsigned int* directShortcut;
@ -88,15 +88,14 @@ struct TTUpdateInfo
// ---------------------------------------------------------------------------
/** Helper class representing texture coordinate transformations
*/
struct STransformVecInfo : public aiUVTransform
{
STransformVecInfo()
: uvIndex (0)
, mapU (aiTextureMapMode_Wrap)
, mapV (aiTextureMapMode_Wrap)
, lockedPos (AI_TT_UV_IDX_LOCK_NONE)
{}
struct STransformVecInfo : public aiUVTransform {
STransformVecInfo() noexcept
: uvIndex(0)
, mapU(aiTextureMapMode_Wrap)
, mapV(aiTextureMapMode_Wrap)
, lockedPos(AI_TT_UV_IDX_LOCK_NONE) {
// empty
}
//! Source texture coordinate index
unsigned int uvIndex;

View File

@ -55,32 +55,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/anim.h>
#include <assimp/Defines.h>
namespace Assimp
{
namespace XFile
{
namespace Assimp {
namespace XFile {
/** Helper structure representing a XFile mesh face */
struct Face
{
struct Face {
std::vector<unsigned int> mIndices;
};
/** Helper structure representing a texture filename inside a material and its potential source */
struct TexEntry
{
struct TexEntry {
std::string mName;
bool mIsNormalMap; // true if the texname was specified in a NormalmapFilename tag
TexEntry() { mIsNormalMap = false; }
TexEntry( const std::string& pName, bool pIsNormalMap = false)
: mName( pName), mIsNormalMap( pIsNormalMap)
{ /* done */ }
TexEntry() noexcept
: mName()
, mIsNormalMap(false) {
// empty
}
TexEntry(const std::string& pName, bool pIsNormalMap = false)
: mName(pName)
, mIsNormalMap(pIsNormalMap) {
// empty
}
};
/** Helper structure representing a XFile material */
struct Material
{
struct Material {
std::string mName;
bool mIsReference; // if true, mName holds a name by which the actual material can be found in the material list
aiColor4D mDiffuse;
@ -88,19 +89,18 @@ struct Material
aiColor3D mSpecular;
aiColor3D mEmissive;
std::vector<TexEntry> mTextures;
size_t sceneIndex; ///< the index under which it was stored in the scene's material list
Material()
: mIsReference(false),
mSpecularExponent(),
sceneIndex(SIZE_MAX)
{}
Material() noexcept
: mIsReference(false)
, mSpecularExponent()
, sceneIndex(SIZE_MAX) {
// empty
}
};
/** Helper structure to represent a bone weight */
struct BoneWeight
{
struct BoneWeight {
unsigned int mVertex;
ai_real mWeight;
};
@ -114,8 +114,7 @@ struct Bone
};
/** Helper structure to represent an XFile mesh */
struct Mesh
{
struct Mesh {
std::string mName;
std::vector<aiVector3D> mPositions;
std::vector<Face> mPosFaces;
@ -131,38 +130,65 @@ struct Mesh
std::vector<Bone> mBones;
explicit Mesh(const std::string &pName = "") { mName = pName; mNumTextures = 0; mNumColorSets = 0; }
explicit Mesh(const std::string &pName = "") noexcept
: mName( pName )
, mPositions()
, mPosFaces()
, mNormals()
, mNormFaces()
, mNumTextures(0)
, mTexCoords{}
, mNumColorSets(0)
, mColors{}
, mFaceMaterials()
, mMaterials()
, mBones() {
// empty
}
};
/** Helper structure to represent a XFile frame */
struct Node
{
struct Node {
std::string mName;
aiMatrix4x4 mTrafoMatrix;
Node* mParent;
std::vector<Node*> mChildren;
std::vector<Mesh*> mMeshes;
Node() { mParent = NULL; }
explicit Node( Node* pParent) { mParent = pParent; }
~Node()
{
for( unsigned int a = 0; a < mChildren.size(); a++)
Node() noexcept
: mName()
, mTrafoMatrix()
, mParent(nullptr)
, mChildren()
, mMeshes() {
// empty
}
explicit Node( Node* pParent)
: mName()
, mTrafoMatrix()
, mParent(pParent)
, mChildren()
, mMeshes() {
// empty
}
~Node() {
for (unsigned int a = 0; a < mChildren.size(); ++a ) {
delete mChildren[a];
for( unsigned int a = 0; a < mMeshes.size(); a++)
}
for (unsigned int a = 0; a < mMeshes.size(); ++a) {
delete mMeshes[a];
}
}
};
struct MatrixKey
{
struct MatrixKey {
double mTime;
aiMatrix4x4 mMatrix;
};
/** Helper structure representing a single animated bone in a XFile */
struct AnimBone
{
struct AnimBone {
std::string mBoneName;
std::vector<aiVectorKey> mPosKeys; // either three separate key sequences for position, rotation, scaling
std::vector<aiQuatKey> mRotKeys;
@ -194,15 +220,23 @@ struct Scene
std::vector<Animation*> mAnims;
unsigned int mAnimTicksPerSecond;
Scene() { mRootNode = NULL; mAnimTicksPerSecond = 0; }
~Scene()
{
Scene() noexcept
: mRootNode(nullptr)
, mGlobalMeshes()
, mGlobalMaterials()
, mAnimTicksPerSecond(0) {
// empty
}
~Scene() {
delete mRootNode;
for( unsigned int a = 0; a < mGlobalMeshes.size(); a++)
mRootNode = nullptr;
for (unsigned int a = 0; a < mGlobalMeshes.size(); ++a ) {
delete mGlobalMeshes[a];
for( unsigned int a = 0; a < mAnims.size(); a++)
}
for (unsigned int a = 0; a < mAnims.size(); ++a ) {
delete mAnims[a];
}
}
};
} // end of namespace XFile

View File

@ -21,8 +21,7 @@ class array
{
public:
array()
array() noexcept
: data(0), allocated(0), used(0),
free_when_destroyed(true), is_sorted(true)
{

View File

@ -77,19 +77,17 @@ class IOStream;
* imports the given file. ReadFile is not overridable, it just calls
* InternReadFile() and catches any ImportErrorException that might occur.
*/
class ASSIMP_API BaseImporter
{
class ASSIMP_API BaseImporter {
friend class Importer;
public:
/** Constructor to be privately used by #Importer */
BaseImporter();
BaseImporter() noexcept;
/** Destructor, private as well */
virtual ~BaseImporter();
public:
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
*

View File

@ -60,9 +60,8 @@ namespace Assimp {
* This is required to read big-endian model formats on little-endian machines,
* and vice versa. Direct use of this class is DEPRECATED. Use #StreamReader instead. */
// --------------------------------------------------------------------------------------
class ByteSwap
{
ByteSwap() {}
class ByteSwap {
ByteSwap() noexcept {}
public:

View File

@ -69,7 +69,7 @@ class ASSIMP_API DefaultIOStream : public IOStream
#endif // __ANDROID__
protected:
DefaultIOStream();
DefaultIOStream() noexcept;
DefaultIOStream(FILE* pFile, const std::string &strFilename);
public:
@ -111,27 +111,25 @@ private:
FILE* mFile;
// Filename
std::string mFilename;
// Cached file size
mutable size_t mCachedSize;
};
// ----------------------------------------------------------------------------------
inline DefaultIOStream::DefaultIOStream () :
mFile (NULL),
mFilename (""),
mCachedSize(SIZE_MAX)
{
inline
DefaultIOStream::DefaultIOStream() noexcept
: mFile(nullptr)
, mFilename("")
, mCachedSize(SIZE_MAX) {
// empty
}
// ----------------------------------------------------------------------------------
inline DefaultIOStream::DefaultIOStream (FILE* pFile,
const std::string &strFilename) :
mFile(pFile),
mFilename(strFilename),
mCachedSize(SIZE_MAX)
{
inline
DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename)
: mFile(pFile)
, mFilename(strFilename)
, mCachedSize(SIZE_MAX) {
// empty
}
// ----------------------------------------------------------------------------------

View File

@ -71,7 +71,7 @@ class ASSIMP_API IOStream
{
protected:
/** Constructor protected, use IOSystem::Open() to create an instance. */
IOStream();
IOStream() noexcept;
public:
// -------------------------------------------------------------------
@ -126,7 +126,7 @@ public:
// ----------------------------------------------------------------------------------
inline
IOStream::IOStream() {
IOStream::IOStream() noexcept {
// empty
}

View File

@ -95,7 +95,7 @@ public:
* Create an instance of your derived class and assign it to an
* #Assimp::Importer instance by calling Importer::SetIOHandler().
*/
IOSystem();
IOSystem() noexcept;
// -------------------------------------------------------------------
/** @brief Virtual destructor.
@ -105,9 +105,6 @@ public:
*/
virtual ~IOSystem();
public:
// -------------------------------------------------------------------
/** @brief For backward compatibility
* @see Exists(const char*)
@ -233,7 +230,7 @@ private:
// ----------------------------------------------------------------------------
AI_FORCE_INLINE
IOSystem::IOSystem()
IOSystem::IOSystem() noexcept
: m_pathStack() {
// empty
}

View File

@ -65,7 +65,7 @@ class ASSIMP_API LogStream
{
protected:
/** @brief Default constructor */
LogStream();
LogStream() noexcept;
public:
/** @brief Virtual destructor */
@ -91,12 +91,12 @@ public:
* @return New LogStream instance. */
static LogStream* createDefaultStream(aiDefaultLogStream stream,
const char* name = "AssimpLog.txt",
IOSystem* io = NULL);
IOSystem* io = nullptr );
}; // !class LogStream
inline
LogStream::LogStream() {
LogStream::LogStream() noexcept {
// empty
}

View File

@ -161,7 +161,7 @@ protected:
/**
* Default constructor
*/
Logger();
Logger() noexcept;
/**
* Construction with a given log severity
@ -215,8 +215,9 @@ protected:
// ----------------------------------------------------------------------------------
// Default constructor
inline
Logger::Logger() {
setLogSeverity(NORMAL);
Logger::Logger() noexcept
: m_Severity(NORMAL) {
// empty
}
// ----------------------------------------------------------------------------------
@ -229,8 +230,9 @@ Logger::~Logger() {
// ----------------------------------------------------------------------------------
// Construction with given logging severity
inline
Logger::Logger(LogSeverity severity) {
setLogSeverity(severity);
Logger::Logger(LogSeverity severity)
: m_Severity(severity) {
// empty
}
// ----------------------------------------------------------------------------------

View File

@ -63,7 +63,7 @@ class ASSIMP_API ProgressHandler
{
protected:
/** @brief Default constructor */
ProgressHandler () {
ProgressHandler () noexcept {
}
public:
/** @brief Virtual destructor */

View File

@ -111,26 +111,34 @@ protected:
// -------------------------------------------------------------------
/** An entry in a spatially sorted position array. Consists of a
* vertex index, its position and its precalculated distance from
* vertex index, its position and its pre-calculated distance from
* the reference plane */
// -------------------------------------------------------------------
struct Entry
{
struct Entry {
unsigned int mIndex; ///< The vertex referred by this entry
aiVector3D mPosition; ///< Position
uint32_t mSmoothGroups;
float mDistance; ///< Distance of this vertex to the sorting plane
Entry() { /** intentionally not initialized.*/ }
Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG)
:
mIndex( pIndex),
mPosition( pPosition),
mSmoothGroups (pSG),
mDistance( pDistance)
{ }
Entry() noexcept
: mIndex(0)
, mPosition()
, mSmoothGroups(0)
, mDistance(0.0f) {
// empty
}
bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG)
: mIndex( pIndex)
, mPosition( pPosition)
, mSmoothGroups(pSG)
, mDistance( pDistance) {
// empty
}
bool operator < (const Entry& e) const {
return mDistance < e.mDistance;
}
};
// all positions, sorted by distance to the sorting plane

View File

@ -52,12 +52,10 @@ http://www.jalix.org/ressources/graphics/3DS/_unofficials/3ds-unofficial.txt */
// ---------------------------------------------------------------------------
/** Helper structure representing a face with smoothing groups assigned */
struct FaceWithSmoothingGroup
{
FaceWithSmoothingGroup()
: mIndices(),
iSmoothGroup(0)
{
struct FaceWithSmoothingGroup {
FaceWithSmoothingGroup() noexcept
: mIndices()
, iSmoothGroup(0) {
// in debug builds set all indices to a common magic value
#ifdef ASSIMP_BUILD_DEBUG
this->mIndices[0] = 0xffffffff;

View File

@ -153,7 +153,7 @@ protected:
aiVector3D mPosition; ///< Position
ai_real mDistance; ///< Distance of this vertex to the sorting plane
Entry()
Entry() noexcept
: mIndex( 999999999 ), mPosition(), mDistance( 99999. ) {
// empty
}

View File

@ -70,7 +70,7 @@ struct aiVectorKey
#ifdef __cplusplus
/// @brief The default constructor.
aiVectorKey()
aiVectorKey() noexcept
: mTime( 0.0 )
, mValue() {
// empty
@ -116,7 +116,7 @@ struct aiQuatKey
C_STRUCT aiQuaternion mValue;
#ifdef __cplusplus
aiQuatKey()
aiQuatKey() noexcept
: mTime( 0.0 )
, mValue() {
// empty
@ -163,7 +163,7 @@ struct aiMeshKey
#ifdef __cplusplus
aiMeshKey()
aiMeshKey() noexcept
: mTime(0.0)
, mValue(0)
{
@ -210,10 +210,10 @@ struct aiMeshMorphKey
/** The number of values and weights */
unsigned int mNumValuesAndWeights;
#ifdef __cplusplus
aiMeshMorphKey()
aiMeshMorphKey() noexcept
: mTime(0.0)
, mValues(NULL)
, mWeights(NULL)
, mValues(nullptr)
, mWeights(nullptr)
, mNumValuesAndWeights(0)
{
@ -324,13 +324,13 @@ struct aiNodeAnim {
C_ENUM aiAnimBehaviour mPostState;
#ifdef __cplusplus
aiNodeAnim()
aiNodeAnim() noexcept
: mNumPositionKeys( 0 )
, mPositionKeys( NULL )
, mPositionKeys( nullptr )
, mNumRotationKeys( 0 )
, mRotationKeys( NULL )
, mRotationKeys( nullptr )
, mNumScalingKeys( 0 )
, mScalingKeys( NULL )
, mScalingKeys( nullptr )
, mPreState( aiAnimBehaviour_DEFAULT )
, mPostState( aiAnimBehaviour_DEFAULT ) {
// empty
@ -366,7 +366,7 @@ struct aiMeshAnim
#ifdef __cplusplus
aiMeshAnim()
aiMeshAnim() noexcept
: mNumKeys()
, mKeys()
{}
@ -397,7 +397,7 @@ struct aiMeshMorphAnim
#ifdef __cplusplus
aiMeshMorphAnim()
aiMeshMorphAnim() noexcept
: mNumKeys()
, mKeys()
{}
@ -451,15 +451,15 @@ struct aiAnimation {
C_STRUCT aiMeshMorphAnim **mMorphMeshChannels;
#ifdef __cplusplus
aiAnimation()
aiAnimation() noexcept
: mDuration(-1.)
, mTicksPerSecond(0.)
, mNumChannels(0)
, mChannels(NULL)
, mChannels(nullptr)
, mNumMeshChannels(0)
, mMeshChannels(NULL)
, mMeshChannels(nullptr)
, mNumMorphMeshChannels(0)
, mMorphMeshChannels(NULL) {
, mMorphMeshChannels(nullptr) {
// empty
}

View File

@ -174,7 +174,7 @@ struct aiCamera
#ifdef __cplusplus
aiCamera()
aiCamera() noexcept
: mUp (0.f,1.f,0.f)
, mLookAt (0.f,0.f,1.f)
, mHorizontalFOV (0.25f * (float)AI_MATH_PI)

View File

@ -59,7 +59,7 @@ template <typename TReal>
class aiColor4t
{
public:
aiColor4t () : r(), g(), b(), a() {}
aiColor4t() noexcept : r(), g(), b(), a() {}
aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
: r(_r), g(_g), b(_b), a(_a) {}
explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}

View File

@ -195,7 +195,7 @@ uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_ino
break;
}
const uint64_t new_value = ( value * 10 ) + ( *in - '0' );
const uint64_t new_value = ( value * (uint64_t) 10 ) + ( (uint64_t) ( *in - '0' ) );
// numeric overflow, we rely on you
if ( new_value < value ) {

View File

@ -237,7 +237,7 @@ struct aiLight
#ifdef __cplusplus
aiLight()
aiLight() noexcept
: mType (aiLightSource_UNDEFINED)
, mAttenuationConstant (0.f)
, mAttenuationLinear (1.f)

View File

@ -483,7 +483,7 @@ struct aiUVTransform
#ifdef __cplusplus
aiUVTransform()
aiUVTransform() noexcept
: mTranslation (0.0,0.0)
, mScaling (1.0,1.0)
, mRotation (0.0)
@ -607,7 +607,7 @@ struct aiMaterialProperty
#ifdef __cplusplus
aiMaterialProperty()
aiMaterialProperty() noexcept
: mSemantic( 0 )
, mIndex( 0 )
, mDataLength( 0 )

View File

@ -69,7 +69,7 @@ class aiMatrix3x3t
{
public:
aiMatrix3x3t () :
aiMatrix3x3t() noexcept :
a1(static_cast<TReal>(1.0f)), a2(), a3(),
b1(), b2(static_cast<TReal>(1.0f)), b3(),
c1(), c2(), c3(static_cast<TReal>(1.0f)) {}

View File

@ -71,7 +71,7 @@ class aiMatrix4x4t
public:
/** set to identity */
aiMatrix4x4t ();
aiMatrix4x4t() noexcept;
/** construction from single values */
aiMatrix4x4t ( TReal _a1, TReal _a2, TReal _a3, TReal _a4,

View File

@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------------------
template <typename TReal>
aiMatrix4x4t<TReal> ::aiMatrix4x4t () :
aiMatrix4x4t<TReal>::aiMatrix4x4t() noexcept :
a1(1.0f), a2(), a3(), a4(),
b1(), b2(1.0f), b3(), b4(),
c1(), c2(), c3(1.0f), c4(),
@ -71,7 +71,7 @@ aiMatrix4x4t<TReal> ::aiMatrix4x4t () :
// ----------------------------------------------------------------------------------------
template <typename TReal>
aiMatrix4x4t<TReal> ::aiMatrix4x4t (TReal _a1, TReal _a2, TReal _a3, TReal _a4,
aiMatrix4x4t<TReal>::aiMatrix4x4t (TReal _a1, TReal _a2, TReal _a3, TReal _a4,
TReal _b1, TReal _b2, TReal _b3, TReal _b4,
TReal _c1, TReal _c2, TReal _c3, TReal _c4,
TReal _d1, TReal _d2, TReal _d3, TReal _d4) :

View File

@ -136,10 +136,10 @@ struct aiFace
#ifdef __cplusplus
//! Default constructor
aiFace()
aiFace() noexcept
: mNumIndices( 0 )
, mIndices( NULL )
{
, mIndices( nullptr ) {
// empty
}
//! Default destructor. Delete the index array
@ -150,47 +150,56 @@ struct aiFace
//! Copy constructor. Copy the index array
aiFace( const aiFace& o)
: mIndices( NULL )
{
: mNumIndices(0)
, mIndices( nullptr ) {
*this = o;
}
//! Assignment operator. Copy the index array
aiFace& operator = ( const aiFace& o)
{
if (&o == this)
aiFace& operator = ( const aiFace& o) {
if (&o == this) {
return *this;
}
delete[] mIndices;
mNumIndices = o.mNumIndices;
if (mNumIndices) {
mIndices = new unsigned int[mNumIndices];
::memcpy( mIndices, o.mIndices, mNumIndices * sizeof( unsigned int));
} else {
mIndices = nullptr;
}
else {
mIndices = NULL;
}
return *this;
}
//! Comparison operator. Checks whether the index array
//! of two faces is identical
bool operator== (const aiFace& o) const
{
if (mIndices == o.mIndices)return true;
else if (mIndices && mNumIndices == o.mNumIndices)
{
for (unsigned int i = 0;i < this->mNumIndices;++i)
if (mIndices[i] != o.mIndices[i])return false;
bool operator== (const aiFace& o) const {
if (mIndices == o.mIndices) {
return true;
}
if (nullptr != mIndices && mNumIndices != o.mNumIndices) {
return false;
}
if (nullptr == mIndices) {
return false;
}
for (unsigned int i = 0; i < this->mNumIndices; ++i) {
if (mIndices[i] != o.mIndices[i]) {
return false;
}
}
return true;
}
//! Inverse comparison operator. Checks whether the index
//! array of two faces is NOT identical
bool operator != (const aiFace& o) const
{
bool operator != (const aiFace& o) const {
return !(*this == o);
}
#endif // __cplusplus
@ -211,13 +220,13 @@ struct aiVertexWeight {
#ifdef __cplusplus
//! Default constructor
aiVertexWeight()
aiVertexWeight() noexcept
: mVertexId(0)
, mWeight(0.0f) {
// empty
}
//! Initialisation from a given index and vertex weight factor
//! Initialization from a given index and vertex weight factor
//! \param pID ID
//! \param pWeight Vertex weight factor
aiVertexWeight( unsigned int pID, float pWeight )
@ -273,10 +282,11 @@ struct aiBone {
#ifdef __cplusplus
//! Default constructor
aiBone()
aiBone() noexcept
: mName()
, mNumWeights( 0 )
, mWeights( nullptr ) {
, mWeights( nullptr )
, mOffsetMatrix() {
// empty
}
@ -284,10 +294,9 @@ struct aiBone {
aiBone(const aiBone& other)
: mName( other.mName )
, mNumWeights( other.mNumWeights )
, mOffsetMatrix( other.mOffsetMatrix )
{
if (other.mWeights && other.mNumWeights)
{
, mWeights(nullptr)
, mOffsetMatrix( other.mOffsetMatrix ) {
if (other.mWeights && other.mNumWeights) {
mWeights = new aiVertexWeight[mNumWeights];
::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight));
}
@ -295,8 +304,7 @@ struct aiBone {
//! Assignment operator
aiBone &operator=(const aiBone& other)
{
aiBone &operator=(const aiBone& other) {
if (this == &other) {
return *this;
}
@ -332,8 +340,7 @@ struct aiBone {
return true;
}
//! Destructor - deletes the array of vertex weights
~aiBone()
{
~aiBone() {
delete [] mWeights;
}
#endif // __cplusplus
@ -447,11 +454,13 @@ struct aiAnimMesh
#ifdef __cplusplus
aiAnimMesh()
: mVertices( NULL )
, mNormals( NULL )
, mTangents( NULL )
, mBitangents( NULL )
aiAnimMesh() noexcept
: mVertices( nullptr )
, mNormals(nullptr)
, mTangents(nullptr)
, mBitangents(nullptr)
, mColors()
, mTextureCoords()
, mNumVertices( 0 )
, mWeight( 0.0f )
{
@ -706,35 +715,36 @@ struct aiMesh
#ifdef __cplusplus
//! Default constructor. Initializes all members to 0
aiMesh()
aiMesh() noexcept
: mPrimitiveTypes( 0 )
, mNumVertices( 0 )
, mNumFaces( 0 )
, mVertices( NULL )
, mNormals( NULL )
, mTangents( NULL )
, mBitangents( NULL )
, mFaces( NULL )
, mVertices( nullptr )
, mNormals(nullptr)
, mTangents(nullptr)
, mBitangents(nullptr)
, mColors()
, mTextureCoords()
, mNumUVComponents()
, mFaces(nullptr)
, mNumBones( 0 )
, mBones( NULL )
, mBones(nullptr)
, mMaterialIndex( 0 )
, mNumAnimMeshes( 0 )
, mAnimMeshes( NULL )
, mMethod( 0 )
{
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
{
, mAnimMeshes(nullptr)
, mMethod( 0 ) {
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a ) {
mNumUVComponents[a] = 0;
mTextureCoords[a] = NULL;
mTextureCoords[a] = nullptr;
}
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
mColors[a] = NULL;
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) {
mColors[a] = nullptr;
}
}
//! Deletes all storage allocated for the mesh
~aiMesh()
{
~aiMesh() {
delete [] mVertices;
delete [] mNormals;
delete [] mTangents;
@ -767,63 +777,67 @@ struct aiMesh
//! Check whether the mesh contains positions. Provided no special
//! scene flags are set, this will always be true
bool HasPositions() const
{ return mVertices != NULL && mNumVertices > 0; }
{ return mVertices != nullptr && mNumVertices > 0; }
//! Check whether the mesh contains faces. If no special scene flags
//! are set this should always return true
bool HasFaces() const
{ return mFaces != NULL && mNumFaces > 0; }
{ return mFaces != nullptr && mNumFaces > 0; }
//! Check whether the mesh contains normal vectors
bool HasNormals() const
{ return mNormals != NULL && mNumVertices > 0; }
{ return mNormals != nullptr && mNumVertices > 0; }
//! Check whether the mesh contains tangent and bitangent vectors
//! It is not possible that it contains tangents and no bitangents
//! (or the other way round). The existence of one of them
//! implies that the second is there, too.
bool HasTangentsAndBitangents() const
{ return mTangents != NULL && mBitangents != NULL && mNumVertices > 0; }
{ return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0; }
//! Check whether the mesh contains a vertex color set
//! \param pIndex Index of the vertex color set
bool HasVertexColors( unsigned int pIndex) const
{
if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS)
bool HasVertexColors( unsigned int pIndex) const {
if (pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS) {
return false;
else
return mColors[pIndex] != NULL && mNumVertices > 0;
} else {
return mColors[pIndex] != nullptr && mNumVertices > 0;
}
}
//! Check whether the mesh contains a texture coordinate set
//! \param pIndex Index of the texture coordinates set
bool HasTextureCoords( unsigned int pIndex) const
{
if( pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS)
bool HasTextureCoords( unsigned int pIndex) const {
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
return false;
else
return mTextureCoords[pIndex] != NULL && mNumVertices > 0;
} else {
return mTextureCoords[pIndex] != nullptr && mNumVertices > 0;
}
}
//! Get the number of UV channels the mesh contains
unsigned int GetNumUVChannels() const
{
unsigned int n = 0;
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n])++n;
unsigned int GetNumUVChannels() const {
unsigned int n( 0 );
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) {
++n;
}
return n;
}
//! Get the number of vertex color channels the mesh contains
unsigned int GetNumColorChannels() const
{
unsigned int n = 0;
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n])++n;
unsigned int GetNumColorChannels() const {
unsigned int n(0);
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n]) {
++n;
}
return n;
}
//! Check whether the mesh contains bones
inline bool HasBones() const
{ return mBones != NULL && mNumBones > 0; }
bool HasBones() const {
return mBones != nullptr && mNumBones > 0;
}
#endif // __cplusplus
};

View File

@ -129,7 +129,7 @@ struct aiMetadata {
/**
* @brief The default constructor, set all members to zero by default.
*/
aiMetadata()
aiMetadata() noexcept
: mNumProperties(0)
, mKeys(nullptr)
, mValues(nullptr) {
@ -141,11 +141,11 @@ struct aiMetadata {
, mKeys( nullptr )
, mValues( nullptr ) {
mKeys = new aiString[ mNumProperties ];
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
for ( size_t i = 0; i < static_cast<size_t>( mNumProperties ); ++i ) {
mKeys[ i ] = rhs.mKeys[ i ];
}
mValues = new aiMetadataEntry[ mNumProperties ];
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
for ( size_t i = 0; i < static_cast<size_t>(mNumProperties); ++i ) {
mValues[ i ].mType = rhs.mValues[ i ].mType;
switch ( rhs.mValues[ i ].mType ) {
case AI_BOOL:

View File

@ -60,7 +60,7 @@ template <typename TReal>
class aiQuaterniont
{
public:
aiQuaterniont() : w(1.0), x(), y(), z() {}
aiQuaterniont() noexcept : w(1.0), x(), y(), z() {}
aiQuaterniont(TReal pw, TReal px, TReal py, TReal pz)
: w(pw), x(px), y(py), z(pz) {}

View File

@ -131,8 +131,7 @@ struct aiTexel
* as the texture paths (a single asterisk character followed by the
* zero-based index of the texture in the aiScene::mTextures array).
*/
struct aiTexture
{
struct aiTexture {
/** Width of the texture, in pixels
*
* If mHeight is zero the texture is compressed in a format
@ -193,24 +192,27 @@ struct aiTexture
//! @param s Input string. 3 characters are maximally processed.
//! Example values: "jpg", "png"
//! @return true if the given string matches the format hint
bool CheckFormat(const char* s) const
{
bool CheckFormat(const char* s) const {
if (nullptr == s) {
return false;
}
return (0 == ::strncmp(achFormatHint, s, sizeof(achFormatHint)));
}
// Construction
aiTexture ()
: mWidth (0)
, mHeight (0)
, pcData (NULL)
{
aiTexture() noexcept
: mWidth(0)
, mHeight(0)
, achFormatHint{ 0 }
, pcData(nullptr)
, mFilename() {
achFormatHint[0] = achFormatHint[1] = 0;
achFormatHint[2] = achFormatHint[3] = 0;
}
// Destruction
~aiTexture ()
{
~aiTexture () {
delete[] pcData;
}
#endif

View File

@ -122,7 +122,8 @@ extern "C" {
struct aiPlane
{
#ifdef __cplusplus
aiPlane () : a(0.f), b(0.f), c(0.f), d(0.f) {}
aiPlane () noexcept : a(0.f), b(0.f), c(0.f), d(0.f) {
}
aiPlane (ai_real _a, ai_real _b, ai_real _c, ai_real _d)
: a(_a), b(_b), c(_c), d(_d) {}
@ -140,7 +141,7 @@ struct aiPlane
struct aiRay
{
#ifdef __cplusplus
aiRay () {}
aiRay () noexcept {}
aiRay (const aiVector3D& _pos, const aiVector3D& _dir)
: pos(_pos), dir(_dir) {}
@ -158,7 +159,7 @@ struct aiRay
struct aiColor3D
{
#ifdef __cplusplus
aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
aiColor3D () noexcept : r(0.0f), g(0.0f), b(0.0f) {}
aiColor3D (ai_real _r, ai_real _g, ai_real _b) : r(_r), g(_g), b(_b) {}
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
@ -253,9 +254,9 @@ struct aiString
{
#ifdef __cplusplus
/** Default constructor, the string is set to have zero length */
aiString() :
length(0)
{
aiString() noexcept
: length( 0 )
, data {0} {
data[0] = '\0';
#ifdef ASSIMP_BUILD_DEBUG
@ -305,7 +306,7 @@ struct aiString
}
/** Assigment operator */
/** Assignment operator */
aiString& operator = (const aiString &rOther) {
if (this == &rOther) {
return *this;
@ -373,7 +374,7 @@ struct aiString
#endif // !__cplusplus
/** Binary length of the string excluding the terminal 0. This is NOT the
* logical length of strings containing UTF-8 multibyte sequences! It's
* logical length of strings containing UTF-8 multi-byte sequences! It's
* the number of bytes from the beginning of the string to its end.*/
size_t length;
@ -479,7 +480,7 @@ struct aiMemoryInfo
#ifdef __cplusplus
/** Default constructor */
aiMemoryInfo()
aiMemoryInfo() noexcept
: textures (0)
, materials (0)
, meshes (0)

View File

@ -66,7 +66,7 @@ template <typename TReal>
class aiVector3t
{
public:
aiVector3t() : x(), y(), z() {}
aiVector3t() noexcept : x(), y(), z() {}
aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
aiVector3t( const aiVector3t& o ) : x(o.x), y(o.y), z(o.z) {}

View File

@ -5,7 +5,7 @@
# Open Asset Import Library (ASSIMP)
# ---------------------------------------------------------------------------
#
# Copyright (c) 2006-2010, ASSIMP Development Team
# Copyright (c) 2006-2018, ASSIMP Development Team
#
# All rights reserved.
#
@ -280,8 +280,3 @@ def work(filename):
if __name__ == "__main__":
sys.exit(work(sys.argv[1] if len(sys.argv)>1 else 'schema.exp'))

File diff suppressed because it is too large Load Diff

View File

@ -117,6 +117,7 @@ SET( IMPORTERS
unit/utB3DImportExport.cpp
unit/utMDCImportExport.cpp
unit/utAssbinImportExport.cpp
unit/ImportExport/utCOBImportExport.cpp
)
SET( MATERIAL

View File

@ -59,6 +59,14 @@ public:
}
};
TEST_F( utAMFImportExport, importACFromFileTest ) {
TEST_F( utAMFImportExport, importAMFFromFileTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F(utAMFImportExport, importAMFWithMatFromFileTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test_with_mat.amf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}