tools/NavGenProj/include/NavGenProjGeometry.h Source File

NavGenProjGeometry.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 // primary contact: MAMU - secondary contact: NOBODY
9 #ifndef GwNavGen_NavGenProjGeometry_H
10 #define GwNavGen_NavGenProjGeometry_H
11 
12 #include "tinyxml.h"
13 #include <string>
14 #include "NavGenProj.h"
16 
17 namespace Kaim
18 {
19 
24 {
25 public:
27  {
28  Clear();
29  }
30 
31  void Clear()
32  {
33  m_fileName = "";
34  m_terrainTypeMaterials.clear();
35  }
36 
38  {
39  Clear();
40  }
41 
42  void SetFileName(std::string geometryFileName)
43  {
44  m_fileName = geometryFileName;
45  }
46 
47  void AddTerrainTypeMaterial(std::string materialName, unsigned int terrainTypeMask)
48  {
49  // Test if material name is not already recorded
50  for (unsigned int i = 0; i < m_terrainTypeMaterials.size(); ++i)
51  {
52  if (m_terrainTypeMaterials[i].m_materialName == materialName)
53  {
54  m_terrainTypeMaterials[i].m_terrainTypeMask = terrainTypeMask;
55  return;
56  }
57  }
58 
59  // Add material
60  NavGenProjTerrainTypeMaterial terrainTypeMaterial(materialName, terrainTypeMask);
61  m_terrainTypeMaterials.push_back(terrainTypeMaterial);
62  }
63 
64  std::string FileType()
65  {
66  std::string fileType = "obj";
67  return fileType;
68  }
69 
70  bool Read(TiXmlNode* node)
71  {
72  TiXmlNode* child;
73  for (child = node->FirstChild(); child != 0; child = child->NextSibling())
74  {
75  NavGenProj::GetParam(child, "filepath", m_fileName);
76  if (strcmp(child->Value(), "TerrainTypeMaterials") == 0)
77  {
78  ReadTerrainTypeMaterialFolder(child);
79  }
80 
81  // deprecated
82  ReadDeprecatedParam(child);
83  }
84  return true;
85  }
86 
87  bool ReadTerrainTypeMaterialFolder(TiXmlNode* node)
88  {
89  TiXmlNode* child;
90  for (child = node->FirstChild(); child != 0; child = child->NextSibling())
91  {
92  if (strcmp(child->Value(), "TerrainTypeMaterial") == 0)
93  {
94  NavGenProjTerrainTypeMaterial terrainTypeMaterial;
95  if (terrainTypeMaterial.Read(child))
96  {
97  m_terrainTypeMaterials.push_back(terrainTypeMaterial);
98  }
99  }
100  }
101  return true;
102  }
103 
104  bool Write(TiXmlNode* node)
105  {
106  // Get geometry folder node
107  TiXmlNode* geometryFolderNode = NavGenProj::GetOrCreateFolderNode(node, "geometries");
108 
109  // Create geometry node
110  TiXmlElement* geometryNode = new TiXmlElement("geometry");
111  geometryFolderNode->LinkEndChild(geometryNode);
112 
113  // Create filePathNode node
114  TiXmlElement* filePathNode = new TiXmlElement("filepath");
115  geometryNode->LinkEndChild(filePathNode);
116  TiXmlText* text = new TiXmlText(m_fileName.c_str());
117  filePathNode->LinkEndChild(text);
118 
119  // Write TerrainTypeMaterials
120  for (int i = 0; i < (int)m_terrainTypeMaterials.size(); i++)
121  {
122  if (m_terrainTypeMaterials[i].Write(geometryNode) == false)
123  return KY_ERROR;
124  }
125 
126  return true;
127  }
128 
129 private:
130  void ReadDeprecatedParam(TiXmlNode* child)
131  {
132  bool tmp;
133  if(NavGenProj::GetParam(child, "counterClockWise", tmp))
134  KY_LOG_WARNING(("[counterClockWise] is deprecated"));
135  }
136 
137 public:
138  std::string m_fileName;
139 
141  std::vector<NavGenProjTerrainTypeMaterial> m_terrainTypeMaterials;
142 };
143 
144 }
145 
146 
147 #endif
An instance of this class is used to represent each input geometry file in a NavGenProj.
Definition: NavGenProjGeometry.h:23
Definition: gamekitcrowddispersion.h:20
#define KY_ERROR
Shorthand for Kaim::Result::Failure.
Definition: types.h:272
Associate a Material with a TerrainType.
Definition: NavGenProjTerrainTypeMaterial.h:26
std::vector< NavGenProjTerrainTypeMaterial > m_terrainTypeMaterials
Stores the list of materials. Do not modify directly. Use AddTerrainTypeMaterial().
Definition: NavGenProjGeometry.h:144