File: nAmf.h

package info (click to toggle)
repsnapper 2.5a5-3
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 5,452 kB
  • sloc: cpp: 61,683; ansic: 7,084; perl: 692; xml: 396; makefile: 348; sh: 231
file content (102 lines) | stat: -rw-r--r-- 3,985 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*******************************************************************************
Copyright (c) 2012, Jonathan Hiller

This file is part of the AMF Tools suite. http://amf.wikispaces.com/
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.
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.
See <http://www.opensource.org/licenses/lgpl-3.0.html> for license details.
*******************************************************************************/

#ifndef NAMF_H
#define NAMF_H

#include <string>
#include <vector>

#include "nMetadata.h"
#include "nObject.h"
#include "nConstellation.h"
#include "nTexture.h"
#include "nMaterial.h"

class CXmlStreamWrite;
class CXmlStreamRead;



enum UnitSystem {UNIT_MM, UNIT_M, UNIT_IN, UNIT_FT, UNIT_UM};

class nAmf
{
	public:
	nAmf(void);
	~nAmf(void);
	nAmf(const nAmf& In) {*this = In;} //copy constructor
	nAmf& operator=(const nAmf& In); //overload Equals
	void Clear(void); //clears all data

	//XML read/write
	bool WriteXML(CXmlStreamWrite* pXML, std::string* pMessage = 0, bool* pCancelFlag = 0);
	bool ReadXML(CXmlStreamRead* pXML, bool StrictLoad=true, std::string* pMessage = 0, bool* pCancelFlag = 0);
	bool CheckValid(bool FixNode=true, std::string* pMessage = 0);

	//required attributes

	//optional attributes
	bool UnitsExist;
	UnitSystem aUnit;
	bool VersionExists;
	double aVersion;


	//required children
	std::vector <nObject> Objects;

	//optional children
	std::vector <nMetadata> Metadata;
	std::vector <nConstellation> Constellations;
	std::vector <nTexture> Textures;
	std::vector <nMaterial> Materials;



	//Utilities
	int GetNumObjects(void) {return (int)Objects.size();}
	int GetNumConstellations(void) {return (int)Constellations.size();}
	int GetNumMaterials(void) {return (int)Materials.size();}
	int GetNumTextures(void) {return (int)Textures.size();}


	int GetUsedGeoID(void);
	int GetUnusedGeoID(void);
	int GetUnusedTexID(void);
	int GetUnusedMatID(void);
	bool IsDuplicateGeoID(int IdToCheck); //returns true if two or more of this ID exist
	bool IsDuplicateTexID(int IdToCheck); //returns true if two or more of this ID exist
	bool IsDuplicateMatID(int IdToCheck); //returns true if two or more of this ID exist


	std::string GetGeoNameFromID(int GeometryID); //finds the name of the object or constellation with this internal ID
	std::string GetMatNameFromID(int MaterialID); //returns name string for a material if it exists

	nObject* GetObjectByID(int GeometryID); //returns pointer to a constellation that has this ID, or NULL if non exists.
	nConstellation* GetConstellationByID(int GeometryID); //returns pointer to a constellation that has this ID, or NULL if non exists.
	nMaterial* GetMaterialByID(int MaterialID); //returns a TEMPORARY pointer to the first material with the specified ID, or NULL if not found
	nTexture* GetTextureByID(int TextureID); //returns a TEMPORARY pointer to the first texture with the specified ID, or NULL if not found

	int AppendObject(std::string Name = "");
	int AppendConstellation(std::string Name = "");
	int AppendMaterial(std::string Name = "");

	void DeleteGeometry(int GeometryID); //Deletes by the internal object ID, not index in the vector!! Removes all instances to this object or constellation, too!
	void DeleteMaterial(int MaterialID);

	bool IsTopLevelGeo(int GeometryID); //returns true if not referenced by any constellations

//	std::string GetMatName(nVolume* pVolume); //returns name string for material of this volume if it has one.



};

#endif  //NAMF_H