1 /******************************************************************************* 2 Copyright (c) 2012, Jonathan Hiller 3 4 This file is part of the AMF Tools suite. http://amf.wikispaces.com/ 5 AMF Tools is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 AMF Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 7 See <http://www.opensource.org/licenses/lgpl-3.0.html> for license details. 8 *******************************************************************************/ 9 10 #ifndef NAMF_H 11 #define NAMF_H 12 13 #include <string> 14 #include <vector> 15 16 #include "nMetadata.h" 17 #include "nObject.h" 18 #include "nConstellation.h" 19 #include "nTexture.h" 20 #include "nMaterial.h" 21 22 class CXmlStreamWrite; 23 class CXmlStreamRead; 24 25 26 27 enum UnitSystem {UNIT_MM, UNIT_M, UNIT_IN, UNIT_FT, UNIT_UM}; 28 29 class nAmf 30 { 31 public: 32 nAmf(void); 33 ~nAmf(void); nAmf(const nAmf & In)34 nAmf(const nAmf& In) {*this = In;} //copy constructor 35 nAmf& operator=(const nAmf& In); //overload Equals 36 void Clear(void); //clears all data 37 38 //XML read/write 39 bool WriteXML(CXmlStreamWrite* pXML, std::string* pMessage = 0, bool* pCancelFlag = 0); 40 bool ReadXML(CXmlStreamRead* pXML, bool StrictLoad=true, std::string* pMessage = 0, bool* pCancelFlag = 0); 41 bool CheckValid(bool FixNode=true, std::string* pMessage = 0); 42 43 //required attributes 44 45 //optional attributes 46 bool UnitsExist; 47 UnitSystem aUnit; 48 bool VersionExists; 49 double aVersion; 50 51 52 //required children 53 std::vector <nObject> Objects; 54 55 //optional children 56 std::vector <nMetadata> Metadata; 57 std::vector <nConstellation> Constellations; 58 std::vector <nTexture> Textures; 59 std::vector <nMaterial> Materials; 60 61 62 63 //Utilities GetNumObjects(void)64 int GetNumObjects(void) {return (int)Objects.size();} GetNumConstellations(void)65 int GetNumConstellations(void) {return (int)Constellations.size();} GetNumMaterials(void)66 int GetNumMaterials(void) {return (int)Materials.size();} GetNumTextures(void)67 int GetNumTextures(void) {return (int)Textures.size();} 68 69 70 int GetUsedGeoID(void); 71 int GetUnusedGeoID(void); 72 int GetUnusedTexID(void); 73 int GetUnusedMatID(void); 74 bool IsDuplicateGeoID(int IdToCheck); //returns true if two or more of this ID exist 75 bool IsDuplicateTexID(int IdToCheck); //returns true if two or more of this ID exist 76 bool IsDuplicateMatID(int IdToCheck); //returns true if two or more of this ID exist 77 78 79 std::string GetGeoNameFromID(int GeometryID); //finds the name of the object or constellation with this internal ID 80 std::string GetMatNameFromID(int MaterialID); //returns name string for a material if it exists 81 82 nObject* GetObjectByID(int GeometryID); //returns pointer to a constellation that has this ID, or NULL if non exists. 83 nConstellation* GetConstellationByID(int GeometryID); //returns pointer to a constellation that has this ID, or NULL if non exists. 84 nMaterial* GetMaterialByID(int MaterialID); //returns a TEMPORARY pointer to the first material with the specified ID, or NULL if not found 85 nTexture* GetTextureByID(int TextureID); //returns a TEMPORARY pointer to the first texture with the specified ID, or NULL if not found 86 87 int AppendObject(std::string Name = ""); 88 int AppendConstellation(std::string Name = ""); 89 int AppendMaterial(std::string Name = ""); 90 91 void DeleteGeometry(int GeometryID); //Deletes by the internal object ID, not index in the vector!! Removes all instances to this object or constellation, too! 92 void DeleteMaterial(int MaterialID); 93 94 bool IsTopLevelGeo(int GeometryID); //returns true if not referenced by any constellations 95 96 // std::string GetMatName(nVolume* pVolume); //returns name string for material of this volume if it has one. 97 98 99 100 }; 101 102 #endif //NAMF_H 103