1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2017, assimp team
7 
8 
9 All rights reserved.
10 
11 Redistribution and use of this software in source and binary forms,
12 with or without modification, are permitted provided that the following
13 conditions are met:
14 
15 * Redistributions of source code must retain the above
16 copyright notice, this list of conditions and the
17 following disclaimer.
18 
19 * Redistributions in binary form must reproduce the above
20 copyright notice, this list of conditions and the
21 following disclaimer in the documentation and/or other
22 materials provided with the distribution.
23 
24 * Neither the name of the assimp team, nor the names of its
25 contributors may be used to endorse or promote products
26 derived from this software without specific prior
27 written permission of the assimp team.
28 
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 ---------------------------------------------------------------------------
41 */
42 
43 /// \file AMFImporter.hpp
44 /// \brief AMF-format files importer for Assimp.
45 /// \date 2016
46 /// \author smal.root@gmail.com
47 // Thanks to acorn89 for support.
48 
49 #pragma once
50 #ifndef INCLUDED_AI_AMF_IMPORTER_H
51 #define INCLUDED_AI_AMF_IMPORTER_H
52 
53 #include "AMFImporter_Node.hpp"
54 
55 // Header files, Assimp.
56 #include <assimp/DefaultLogger.hpp>
57 #include <assimp/importerdesc.h>
58 #include "assimp/types.h"
59 #include "BaseImporter.h"
60 #include "irrXMLWrapper.h"
61 
62 // Header files, stdlib.
63 #include <set>
64 
65 namespace Assimp
66 {
67 /// \class AMFImporter
68 /// Class that holding scene graph which include: geometry, metadata, materials etc.
69 ///
70 /// Implementing features.
71 ///
72 /// Limitations.
73 ///
74 /// 1. When for texture mapping used set of source textures (r, g, b, a) not only one then attribute "tiled" for all set will be true if it true in any of
75 ///    source textures.
76 ///    Example. Triangle use for texture mapping three textures. Two of them has "tiled" set to false and one - set to true. In scene all three textures
77 ///    will be tiled.
78 ///
79 /// Unsupported features:
80 /// 1. Node <composite>, formulas in <composite> and <color>. For implementing this feature can be used expression parser "muParser" like in project
81 ///    "amf_tools".
82 /// 2. Attribute "profile" in node <color>.
83 /// 3. Curved geometry: <edge>, <normal> and children nodes of them.
84 /// 4. Attributes: "unit" and "version" in <amf> read but do nothing.
85 /// 5. <metadata> stored only for root node <amf>.
86 /// 6. Color averaging of vertices for which <triangle>'s set different colors.
87 ///
88 /// Supported nodes:
89 ///    General:
90 ///        <amf>; <constellation>; <instance> and children <deltax>, <deltay>, <deltaz>, <rx>, <ry>, <rz>; <metadata>;
91 ///
92 ///    Geometry:
93 ///        <object>; <mesh>; <vertices>; <vertex>; <coordinates> and children <x>, <y>, <z>; <volume>; <triangle> and children <v1>, <v2>, <v3>;
94 ///
95 ///    Material:
96 ///        <color> and children <r>, <g>, <b>, <a>; <texture>; <material>;
97 ///        two variants of texture coordinates:
98 ///            new - <texmap> and children <utex1>, <utex2>, <utex3>, <vtex1>, <vtex2>, <vtex3>
99 ///            old - <map> and children <u1>, <u2>, <u3>, <v1>, <v2>, <v3>
100 ///
101 class AMFImporter : public BaseImporter
102 {
103 	/***********************************************/
104 	/******************** Types ********************/
105 	/***********************************************/
106 
107 private:
108 
109 	struct SPP_Material;// forward declaration
110 
111 	/// \struct SPP_Composite
112 	/// Data type for postprocessing step. More suitable container for part of material's composition.
113 	struct SPP_Composite
114 	{
115 		SPP_Material* Material;///< Pointer to material - part of composition.
116 		std::string Formula;///< Formula for calculating ratio of \ref Material.
117 	};
118 
119 	/// \struct SPP_Material
120 	/// Data type for postprocessing step. More suitable container for material.
121 	struct SPP_Material
122 	{
123 		std::string ID;///< Material ID.
124 		std::list<CAMFImporter_NodeElement_Metadata*> Metadata;///< Metadata of material.
125 		CAMFImporter_NodeElement_Color* Color;///< Color of material.
126 		std::list<SPP_Composite> Composition;///< List of child materials if current material is composition of few another.
127 
128 		/// \fn aiColor4D GetColor(const float pX, const float pY, const float pZ) const
129 		/// Return color calculated for specified coordinate.
130 		/// \param [in] pX - "x" coordinate.
131 		/// \param [in] pY - "y" coordinate.
132 		/// \param [in] pZ - "z" coordinate.
133 		/// \return calculated color.
134 		aiColor4D GetColor(const float pX, const float pY, const float pZ) const;
135 	};
136 
137 	/// \struct SPP_Texture
138 	/// Data type for post-processing step. More suitable container for texture.
139 	struct SPP_Texture
140 	{
141 		std::string ID;
142 		size_t      Width, Height, Depth;
143 		bool        Tiled;
144         char        FormatHint[ 9 ];// 8 for string + 1 for terminator.
145 		uint8_t    *Data;
146 	};
147 
148 	///	\struct SComplexFace
149 	/// Data type for post-processing step. Contain face data.
150 	struct SComplexFace
151 	{
152 		aiFace Face;///< Face vertices.
153 		const CAMFImporter_NodeElement_Color* Color;///< Face color. Equal to nullptr if color is not set for the face.
154 		const CAMFImporter_NodeElement_TexMap* TexMap;///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face.
155 	};
156 
157 
158 
159 	/***********************************************/
160 	/****************** Constants ******************/
161 	/***********************************************/
162 
163 private:
164 
165 	static const aiImporterDesc Description;
166 
167 	/***********************************************/
168 	/****************** Variables ******************/
169 	/***********************************************/
170 
171 private:
172 
173     CAMFImporter_NodeElement* mNodeElement_Cur;///< Current element.
174     std::list<CAMFImporter_NodeElement*> mNodeElement_List;///< All elements of scene graph.
175 	irr::io::IrrXMLReader* mReader;///< Pointer to XML-reader object
176 	std::string mUnit;
177 	std::list<SPP_Material> mMaterial_Converted;///< List of converted materials for postprocessing step.
178 	std::list<SPP_Texture> mTexture_Converted;///< List of converted textures for postprocessing step.
179 
180 	/***********************************************/
181 	/****************** Functions ******************/
182 	/***********************************************/
183 
184 private:
185 
186 	/// \fn AMFImporter(const AMFImporter& pScene)
187 	/// Disabled copy constructor.
188 	AMFImporter(const AMFImporter& pScene);
189 
190 	/// \fn AMFImporter& operator=(const AMFImporter& pScene)
191 	/// Disabled assign operator.
192 	AMFImporter& operator=(const AMFImporter& pScene);
193 
194 	/// \fn void Clear()
195 	/// Clear all temporary data.
196 	void Clear();
197 
198 	/***********************************************/
199 	/************* Functions: find set *************/
200 	/***********************************************/
201 
202 	/// \fn bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, aiNode** pNode) const
203 	/// Find specified node element in node elements list ( \ref mNodeElement_List).
204 	/// \param [in] pID - ID(name) of requested node element.
205 	/// \param [in] pType - type of node element.
206 	/// \param [out] pNode - pointer to pointer to item found.
207 	/// \return true - if the node element is found, else - false.
208 	bool Find_NodeElement(const std::string& pID, const CAMFImporter_NodeElement::EType pType, CAMFImporter_NodeElement** pNodeElement) const;
209 
210 	/// \fn bool Find_ConvertedNode(const std::string& pID, std::list<aiNode*>& pNodeList, aiNode** pNode) const
211 	/// Find requested aiNode in node list.
212 	/// \param [in] pID - ID(name) of requested node.
213 	/// \param [in] pNodeList - list of nodes where to find the node.
214 	/// \param [out] pNode - pointer to pointer to item found.
215 	/// \return true - if the node is found, else - false.
216 	bool Find_ConvertedNode(const std::string& pID, std::list<aiNode*>& pNodeList, aiNode** pNode) const;
217 
218 	/// \fn bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const
219 	/// Find material in list for converted materials. Use at postprocessing step.
220 	/// \param [in] pID - material ID.
221 	/// \param [out] pConvertedMaterial - pointer to found converted material (\ref SPP_Material).
222 	/// \return true - if the material is found, else - false.
223 	bool Find_ConvertedMaterial(const std::string& pID, const SPP_Material** pConvertedMaterial) const;
224 
225 	/// \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
226 	/// Find texture in list of converted textures. Use at postprocessing step,
227 	/// \param [in] pID_R - ID of source "red" texture.
228 	/// \param [in] pID_G - ID of source "green" texture.
229 	/// \param [in] pID_B - ID of source "blue" texture.
230 	/// \param [in] pID_A - ID of source "alpha" texture. Use empty string to find RGB-texture.
231 	/// \param [out] pConvertedTextureIndex - pointer where index in list of found texture will be written. If equivalent to nullptr then nothing will be
232 	/// written.
233 	/// \return true - if the texture is found, else - false.
234 	bool Find_ConvertedTexture(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A,
235 								uint32_t* pConvertedTextureIndex = nullptr) const;
236 
237 	/***********************************************/
238 	/********* Functions: postprocess set **********/
239 	/***********************************************/
240 
241 	/// \fn void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector<aiVector3D>& pVertexCoordinateArray, std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray) const
242 	/// Get data stored in <vertices> and place it to arrays.
243 	/// \param [in] pNodeElement - reference to node element which kept <object> data.
244 	/// \param [in] pVertexCoordinateArray - reference to vertices coordinates kept in <vertices>.
245 	/// \param [in] pVertexColorArray - reference to vertices colors for all <vertex's. If color for vertex is not set then corresponding member of array
246 	/// contain nullptr.
247 	void PostprocessHelper_CreateMeshDataArray(const CAMFImporter_NodeElement_Mesh& pNodeElement, std::vector<aiVector3D>& pVertexCoordinateArray,
248 												std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray) const;
249 
250 	/// \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)
251 	/// 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
252 	/// converted texture will be returned. Conversion: set of textures from \ref CAMFImporter_NodeElement_Texture to one \ref SPP_Texture and place it
253 	/// to converted textures list.
254 	/// Any of source ID's can be absent(empty string) or even one ID only specified. But at least one ID must be specified.
255 	/// \param [in] pID_R - ID of source "red" texture.
256 	/// \param [in] pID_G - ID of source "green" texture.
257 	/// \param [in] pID_B - ID of source "blue" texture.
258 	/// \param [in] pID_A - ID of source "alpha" texture.
259 	/// \return index of the texture in array of the converted textures.
260 	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);
261 
262 	/// \fn void PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace>& pInputList, std::list<std::list<SComplexFace> > pOutputList_Separated)
263 	/// 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).
264 	/// \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
265 	/// processing.
266 	/// \param [out] pOutputList_Separated - output list of the faces lists. Separated faces list by used texture IDs. Will be cleared before processing.
267 	void PostprocessHelper_SplitFacesByTextureID(std::list<SComplexFace>& pInputList, std::list<std::list<SComplexFace> >& pOutputList_Separated);
268 
269 	/// \fn void Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& pMetadataList, aiNode& pSceneNode) const
270 	/// Check if child elements of node element is metadata and add it to scene node.
271 	/// \param [in] pMetadataList - reference to list with collected metadata.
272 	/// \param [out] pSceneNode - scene node in which metadata will be added.
273 	void Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& pMetadataList, aiNode& pSceneNode) const;
274 
275 	/// \fn void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list<aiMesh*>& pMeshList, aiNode** pSceneNode)
276 	/// To create aiMesh and aiNode for it from <object>.
277 	/// \param [in] pNodeElement - reference to node element which kept <object> data.
278 	/// \param [out] pMeshList - reference to a list with all aiMesh of the scene.
279 	/// \param [out] pSceneNode - pointer to place where new aiNode will be created.
280 	void Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list<aiMesh*>& pMeshList, aiNode** pSceneNode);
281 
282 	/// \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)
283 	/// Create mesh for every <volume> in <mesh>.
284 	/// \param [in] pNodeElement - reference to node element which kept <mesh> data.
285 	/// \param [in] pVertexCoordinateArray - reference to vertices coordinates for all <volume>'s.
286 	/// \param [in] pVertexColorArray - reference to vertices colors for all <volume>'s. If color for vertex is not set then corresponding member of array
287 	/// contain nullptr.
288 	/// \param [in] pObjectColor - pointer to colors for <object>. If color is not set then argument contain nullptr.
289 	/// \param [in] pMaterialList - reference to a list with defined materials.
290 	/// \param [out] pMeshList - reference to a list with all aiMesh of the scene.
291 	/// \param [out] pSceneNode - reference to aiNode which will own new aiMesh's.
292 	void Postprocess_BuildMeshSet(const CAMFImporter_NodeElement_Mesh& pNodeElement, const std::vector<aiVector3D>& pVertexCoordinateArray,
293 									const std::vector<CAMFImporter_NodeElement_Color*>& pVertexColorArray, const CAMFImporter_NodeElement_Color* pObjectColor,
294 									std::list<aiMesh*>& pMeshList, aiNode& pSceneNode);
295 
296 	/// \fn void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial)
297 	/// Convert material from \ref CAMFImporter_NodeElement_Material to \ref SPP_Material.
298 	/// \param [in] pMaterial - source CAMFImporter_NodeElement_Material.
299 	void Postprocess_BuildMaterial(const CAMFImporter_NodeElement_Material& pMaterial);
300 
301 	/// \fn void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list<aiNode*>& pNodeList) const
302 	/// Create and add to aiNode's list new part of scene graph defined by <constellation>.
303 	/// \param [in] pConstellation - reference to <constellation> node.
304 	/// \param [out] pNodeList - reference to aiNode's list.
305 	void Postprocess_BuildConstellation(CAMFImporter_NodeElement_Constellation& pConstellation, std::list<aiNode*>& pNodeList) const;
306 
307 	/// \fn void Postprocess_BuildScene()
308 	/// Build Assimp scene graph in aiScene from collected data.
309 	/// \param [out] pScene - pointer to aiScene where tree will be built.
310 	void Postprocess_BuildScene(aiScene* pScene);
311 
312 	/***********************************************/
313 	/************* Functions: throw set ************/
314 	/***********************************************/
315 
316 	/// \fn void Throw_CloseNotFound(const std::string& pNode)
317 	/// Call that function when close tag of node not found and exception must be raised.
318 	/// E.g.:
319 	/// <amf>
320 	///     <object>
321 	/// </amf> <!--- object not closed --->
322 	/// \throw DeadlyImportError.
323 	/// \param [in] pNode - node name in which exception happened.
324 	void Throw_CloseNotFound(const std::string& pNode);
325 
326 	/// \fn void Throw_IncorrectAttr(const std::string& pAttrName)
327 	/// Call that function when attribute name is incorrect and exception must be raised.
328 	/// \param [in] pAttrName - attribute name.
329 	/// \throw DeadlyImportError.
330 	void Throw_IncorrectAttr(const std::string& pAttrName);
331 
332 	/// \fn void Throw_IncorrectAttrValue(const std::string& pAttrName)
333 	/// Call that function when attribute value is incorrect and exception must be raised.
334 	/// \param [in] pAttrName - attribute name.
335 	/// \throw DeadlyImportError.
336 	void Throw_IncorrectAttrValue(const std::string& pAttrName);
337 
338 	/// \fn void Throw_MoreThanOnceDefined(const std::string& pNode, const std::string& pDescription)
339 	/// Call that function when some type of nodes are defined twice or more when must be used only once and exception must be raised.
340 	/// E.g.:
341 	/// <object>
342 	///     <color>...    <!--- color defined --->
343 	///     <color>...    <!--- color defined again --->
344 	/// </object>
345 	/// \throw DeadlyImportError.
346 	/// \param [in] pNodeType - type of node which defined one more time.
347 	/// \param [in] pDescription - message about error. E.g. what the node defined while exception raised.
348 	void Throw_MoreThanOnceDefined(const std::string& pNodeType, const std::string& pDescription);
349 
350 	/// \fn void Throw_ID_NotFound(const std::string& pID) const
351 	/// Call that function when referenced element ID are not found in graph and exception must be raised.
352 	/// \param [in] pID - ID of of element which not found.
353 	/// \throw DeadlyImportError.
354 	void Throw_ID_NotFound(const std::string& pID) const;
355 
356 	/***********************************************/
357 	/************** Functions: LOG set *************/
358 	/***********************************************/
359 
360 	/// \fn void LogInfo(const std::string& pMessage)
361 	/// Short variant for calling \ref DefaultLogger::get()->info()
LogInfo(const std::string & pMessage)362 	void LogInfo(const std::string& pMessage) { DefaultLogger::get()->info(pMessage); }
363 
364 	/// \fn void LogWarning(const std::string& pMessage)
365 	/// Short variant for calling \ref DefaultLogger::get()->warn()
LogWarning(const std::string & pMessage)366 	void LogWarning(const std::string& pMessage) { DefaultLogger::get()->warn(pMessage); }
367 
368 	/// \fn void LogError(const std::string& pMessage)
369 	/// Short variant for calling \ref DefaultLogger::get()->error()
LogError(const std::string & pMessage)370 	void LogError(const std::string& pMessage) { DefaultLogger::get()->error(pMessage); }
371 
372 	/***********************************************/
373 	/************** Functions: XML set *************/
374 	/***********************************************/
375 
376 	/// \fn void XML_CheckNode_MustHaveChildren()
377 	/// Check if current node have children: <node>...</node>. If not then exception will throwed.
378 	void XML_CheckNode_MustHaveChildren();
379 
380 	/// \fn bool XML_CheckNode_NameEqual(const std::string& pNodeName)
381 	/// Check if current node name is equal to pNodeName.
382 	/// \param [in] pNodeName - name for checking.
383 	/// return true if current node name is equal to pNodeName, else - false.
XML_CheckNode_NameEqual(const std::string & pNodeName)384 	bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; }
385 
386 	/// \fn void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName)
387 	/// Skip unsupported node and report about that. Depend on node name can be skipped begin tag of node all whole node.
388 	/// \param [in] pParentNodeName - parent node name. Used for reporting.
389 	void XML_CheckNode_SkipUnsupported(const std::string& pParentNodeName);
390 
391 	/// \fn bool XML_SearchNode(const std::string& pNodeName)
392 	/// Search for specified node in file. XML file read pointer(mReader) will point to found node or file end after search is end.
393 	/// \param [in] pNodeName - requested node name.
394 	/// return true - if node is found, else - false.
395 	bool XML_SearchNode(const std::string& pNodeName);
396 
397 	/// \fn bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx)
398 	/// Read attribute value.
399 	/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
400 	/// \return read data.
401 	bool XML_ReadNode_GetAttrVal_AsBool(const int pAttrIdx);
402 
403 	/// \fn float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx)
404 	/// Read attribute value.
405 	/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
406 	/// \return read data.
407 	float XML_ReadNode_GetAttrVal_AsFloat(const int pAttrIdx);
408 
409 	/// \fn uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx)
410 	/// Read attribute value.
411 	/// \param [in] pAttrIdx - attribute index (\ref mReader->getAttribute* set).
412 	/// \return read data.
413 	uint32_t XML_ReadNode_GetAttrVal_AsU32(const int pAttrIdx);
414 
415 	/// \fn float XML_ReadNode_GetVal_AsFloat()
416 	/// Read node value.
417 	/// \return read data.
418 	float XML_ReadNode_GetVal_AsFloat();
419 
420 	/// \fn uint32_t XML_ReadNode_GetVal_AsU32()
421 	/// Read node value.
422 	/// \return read data.
423 	uint32_t XML_ReadNode_GetVal_AsU32();
424 
425 	/// \fn void XML_ReadNode_GetVal_AsString(std::string& pValue)
426 	/// Read node value.
427 	/// \return read data.
428 	void XML_ReadNode_GetVal_AsString(std::string& pValue);
429 
430 	/***********************************************/
431 	/******** Functions: parse set private *********/
432 	/***********************************************/
433 
434 	/// \fn void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode)
435 	/// Make pNode as current and enter deeper for parsing child nodes. At end \ref ParseHelper_Node_Exit must be called.
436 	/// \param [in] pNode - new current node.
437 	void ParseHelper_Node_Enter(CAMFImporter_NodeElement* pNode);
438 
439 	/// \fn void ParseHelper_Group_End()
440 	/// This function must be called when exiting from grouping node. \ref ParseHelper_Group_Begin.
441 	void ParseHelper_Node_Exit();
442 
443 	/// \fn void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString)
444 	/// Attribute values of floating point types can take form ".x"(without leading zero). irrXMLReader can not read this form of values and it
445 	/// must be converted to right form - "0.xxx".
446 	/// \param [in] pInStr - pointer to input string which can contain incorrect form of values.
447 	/// \param [out[ pOutString - output string with right form of values.
448 	void ParseHelper_FixTruncatedFloatString(const char* pInStr, std::string& pOutString);
449 
450 	/// \fn void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const
451 	/// Decode Base64-encoded data.
452 	/// \param [in] pInputBase64 - reference to input Base64-encoded string.
453 	/// \param [out] pOutputData - reference to output array for decoded data.
454 	void ParseHelper_Decode_Base64(const std::string& pInputBase64, std::vector<uint8_t>& pOutputData) const;
455 
456 	/// \fn void ParseNode_Root()
457 	/// Parse <AMF> node of the file.
458 	void ParseNode_Root();
459 
460 	/******** Functions: top nodes *********/
461 
462 	/// \fn void ParseNode_Constellation()
463 	/// Parse <constellation> node of the file.
464 	void ParseNode_Constellation();
465 
466 	/// \fn void ParseNode_Constellation()
467 	/// Parse <instance> node of the file.
468 	void ParseNode_Instance();
469 
470 	/// \fn void ParseNode_Material()
471 	/// Parse <material> node of the file.
472 	void ParseNode_Material();
473 
474 	/// \fn void ParseNode_Metadata()
475 	/// Parse <metadata> node.
476 	void ParseNode_Metadata();
477 
478 	/// \fn void ParseNode_Object()
479 	/// Parse <object> node of the file.
480 	void ParseNode_Object();
481 
482 	/// \fn void ParseNode_Texture()
483 	/// Parse <texture> node of the file.
484 	void ParseNode_Texture();
485 
486 	/******** Functions: geometry nodes *********/
487 
488 	/// \fn void ParseNode_Coordinates()
489 	/// Parse <coordinates> node of the file.
490 	void ParseNode_Coordinates();
491 
492 	/// \fn void ParseNode_Edge()
493 	/// Parse <edge> node of the file.
494 	void ParseNode_Edge();
495 
496 	/// \fn void ParseNode_Mesh()
497 	/// Parse <mesh> node of the file.
498 	void ParseNode_Mesh();
499 
500 	/// \fn void ParseNode_Triangle()
501 	/// Parse <triangle> node of the file.
502 	void ParseNode_Triangle();
503 
504 	/// \fn void ParseNode_Vertex()
505 	/// Parse <vertex> node of the file.
506 	void ParseNode_Vertex();
507 
508 	/// \fn void ParseNode_Vertices()
509 	/// Parse <vertices> node of the file.
510 	void ParseNode_Vertices();
511 
512 	/// \fn void ParseNode_Volume()
513 	/// Parse <volume> node of the file.
514 	void ParseNode_Volume();
515 
516 	/******** Functions: material nodes *********/
517 
518 	/// \fn void ParseNode_Color()
519 	/// Parse <color> node of the file.
520 	void ParseNode_Color();
521 
522 	/// \fn void ParseNode_TexMap(const bool pUseOldName = false)
523 	/// Parse <texmap> of <map> node of the file.
524 	/// \param [in] pUseOldName - if true then use old name of node(and children) - <map>, instead of new name - <texmap>.
525 	void ParseNode_TexMap(const bool pUseOldName = false);
526 
527 public:
528 
529 	/// \fn AMFImporter()
530 	/// Default constructor.
AMFImporter()531 	AMFImporter()
532 		: mNodeElement_Cur(nullptr), mReader(nullptr)
533 	{}
534 
535 	/// \fn ~AMFImporter()
536 	/// Default destructor.
537 	~AMFImporter();
538 
539 	/***********************************************/
540 	/******** Functions: parse set, public *********/
541 	/***********************************************/
542 
543 	/// \fn void ParseFile(const std::string& pFile, IOSystem* pIOHandler)
544 	/// Parse AMF file and fill scene graph. The function has no return value. Result can be found by analyzing the generated graph.
545 	/// Also exception can be throwed if trouble will found.
546 	/// \param [in] pFile - name of file to be parsed.
547 	/// \param [in] pIOHandler - pointer to IO helper object.
548 	void ParseFile(const std::string& pFile, IOSystem* pIOHandler);
549 
550 	/***********************************************/
551 	/********* Functions: BaseImporter set *********/
552 	/***********************************************/
553 
554 	bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool pCheckSig) const;
555 	void GetExtensionList(std::set<std::string>& pExtensionList);
556 	void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
557 	const aiImporterDesc* GetInfo ()const;
558 
559 };// class AMFImporter
560 
561 }// namespace Assimp
562 
563 #endif // INCLUDED_AI_AMF_IMPORTER_H
564