30, m_pTextileCallback(
NULL)
50 map<string, CTextile*>::const_iterator itTextile;
53 if (itTextile->second == pTextile)
54 return itTextile->first;
61 if (TextileName.empty())
65 TGERROR(
"Unable to get textile, no textiles have been created");
74 map<string, CTextile*>::iterator itTextile;
77 return itTextile->second;
78 TGERROR(
"Unable to get textile, textile does not exist: " + TextileName);
86 if (TextileName.empty())
88 TGERROR(
"Unable to add textile, given textile name is empty");
96 TGERROR(
"Unable to add textile, textile with that name already exists: " + TextileName);
103 TGLOG(
"Replaced textile \"" << TextileName <<
"\"");
111 TGLOG(
"Added textile \"" << TextileName <<
"\"");
128 TGLOG(
"Added textile \"" << DefaultName <<
"\"");
136 map<string, CTextile*>::iterator itTextile;
140 delete itTextile->second;
142 TGLOG(
"Deleted textile \"" << TextileName <<
"\"");
147 TGERROR(
"Unable to delete textile, textile does not exist: " + TextileName);
153 if (TextileName.empty())
155 map<string, CTextile*>::const_iterator itTextile;
158 TiXmlElement Textile(
"Textile");
159 Textile.SetAttribute(
"name", itTextile->first);
160 itTextile->second->PopulateTiXmlElement(Textile, OutputType);
161 Element.InsertEndChild(Textile);
169 TiXmlElement Textile(
"Textile");
170 Textile.SetAttribute(
"name", TextileName);
172 Element.InsertEndChild(Textile);
179 bool bOverwrite =
false;
182 string Name = pTextile->Attribute(
"name");
183 const string* pType = pTextile->Attribute(
string(
"type"));
186 if (*pType ==
"CTextileWeave2D")
188 else if (*pType ==
"CTextileWeave3D")
190 else if (*pType ==
"CTextileWeave")
192 else if (*pType ==
"CTextileOrthogonal")
194 else if (*pType ==
"CTextileAngleInterlock")
196 else if (*pType ==
"CTextileOffsetAngleInterlock")
198 else if (*pType ==
"CTextileLayerToLayer")
200 else if (*pType ==
"CTextileDecoupledLToL")
202 else if (*pType ==
"CTextile3DWeave")
204 else if (*pType ==
"CShearedTextileWeave2D")
206 else if (*pType ==
"CTextileLayered")
217 TiXmlDocument doc(FileName);
218 TiXmlDeclaration Declaration(
"1.0",
"",
"");
219 doc.InsertEndChild(Declaration);
220 TiXmlElement Root(
"TexGenModel");
223 doc.InsertEndChild(Root);
226 TGLOG(
"XML file saved to \"" << FileName <<
"\"");
230 TGERROR(
"Error saving XML file to \"" << FileName <<
"\"");
236 TGLOGINDENT(
"Loading XML file: \"" << FileName <<
"\"");
237 TiXmlDocument doc(FileName);
240 TiXmlElement* pRoot = doc.RootElement();
243 string Version = pRoot->Attribute(
"version");
246 TGERROR(
"Warning: File was created with version " << Version <<
", current version is " <<
GetVersion());
250 TGLOG(
"XML file loaded from \"" << FileName <<
"\"");
256 TGERROR(
"Error loading XML file from \"" << FileName <<
"\"");
303 map<string, CTextile*>::iterator itTextile;
308 Names.push_back( itTextile->first );
#define TGLOGINDENT(MESSAGE)
Combines the TGLOG macro and TGLOGAUTOINDENT macro in one.
#define TGERROR(MESSAGE)
Macros used to report the file name and line number to the TexGenError and TexGenLog functions.
#define FOR_EACH_TIXMLELEMENT(CHILDELEMENT, PARENTELEMENT, ELEMENTNAME)
Macro to enable looping over tinyxml easier.
Abstract base class to act as an interface between texgen and the logger.
virtual CLogger * Copy() const =0
Logger used to send all log and error messages into a black hole.
Logger used to print all log and error messages to the screen.
Respresents a 2d woven textile with shear applied.
Template used as a base class for creating singletons.
Singleton class holding the Textiles in a database.
bool LoadTiXmlElement(TiXmlElement &Element)
Used for loading data from XML.
void PopulateTiXmlElement(TiXmlElement &Element, string TextileName="", OUTPUT_TYPE OutputType=OUTPUT_STANDARD)
Used for saving data to XML.
string GetName(const CTextile *pTextile) const
Get the name of the textile with given pointer.
map< string, CTextile * > m_Textiles
List of textiles created.
CLogger * m_pLogger
Logger used to keep track of how error messages and log messages displayed or stored.
string GetVersion() const
Get the version of TexGen.
void SetMessages(bool bMessagesOn, const CLogger &Logger)
Switch messages on/off.
void SetTextileCallback(void(*pTextileCallback)(string TextileName, bool bAdded))
Set the callback function when a textile is added or deleted.
void DeleteTextiles()
Clear Textiles.
void SetLogger(const CLogger &Logger)
Set the logger.
void(* m_pTextileCallback)(string TextileName, bool bAdded)
bool ReadFromXML(string FileName)
Read TexGen XML file.
CTextile * GetTextile(string TextileName="")
Get a textile with given name.
bool AddTextile(string TextileName, const CTextile &Textile, bool bOverwrite=false)
Add Textile.
void GetTextileNames(vector< string > &Names)
Get list of textile names.
bool DeleteTextile(string TextileName)
Delete a textile.
void SaveToXML(string FileName, string TextileName="", OUTPUT_TYPE OutputType=OUTPUT_STANDARD)
Save TexGen XML file.
Represents a 3D woven textile.
Represents a 3D angle interlock woven textile.
Represents a textile cell containing yarns.
virtual string GetDefaultName() const
Get the default name to assign to a textile.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
virtual CTextile * Copy() const
Represents a textile made up from several layers of weaves.
Represents a 3D angle interlock woven textile.
Represents a 3D orthogonal woven textile.
Respresents a 2d woven textile.
Respresents a 3d woven textile.
Represents a woven textile.
Namespace containing a series of customised math operations not found in the standard c++ library.
void AddNewUnits(std::string NewUnit, std::string BaseUnits)
std::string stringify(const T &x, int iPrecision=12, bool bScientific=true)
Function to convert a value (e.g. int, double, etc...) to a string.