TexGen
PropertiesTextile.cpp
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2006 Martin Sherburn
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18=============================================================================*/
19
20#include "PrecompiledHeaders.h"
21#include "PropertiesTextile.h"
22#include "DefaultProperties.h"
23using namespace TexGen;
24
25
26CPropertiesTextile::CPropertiesTextile()
27: m_ArealDensity("kg/m^2")
28,m_GeometryScale("mm")
29, m_MatrixYoungsModulus("MPa")
30, m_MatrixAlpha(MATRIX_ALPHA)
31, m_MatrixPoissonsRatio(0.1)
32{
34}
35
37: CProperties(Element), m_ArealDensity("kg/m^2"), m_GeometryScale("mm")
38, m_MatrixYoungsModulus("MPa")
39, m_MatrixAlpha(MATRIX_ALPHA)
40, m_MatrixPoissonsRatio(0.1)
41{
42 const string* pGeomScale = Element.Attribute(string("GeometryScale"));
43 if (pGeomScale)
44 m_GeometryScale = *pGeomScale;
45 m_ArealDensity.WriteAttribute(Element, "ArealDensity");
46 m_MatrixYoungsModulus.ReadAttribute(Element, "MatrixYoungsModulus");
47 Element.Attribute("MatrixPoissonsRatio", &m_MatrixPoissonsRatio);
48 Element.Attribute("MatrixAlpha", &m_MatrixAlpha);
49}
50
52{
53}
54
55void CPropertiesTextile::PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
56{
57 CProperties::PopulateTiXmlElement(Element, OutputType);
58
59 Element.SetAttribute("GeometryScale", m_GeometryScale);
60 m_ArealDensity.ReadAttribute(Element, "ArealDensity");
61 m_MatrixYoungsModulus.WriteAttribute(Element, "MatrixYoungsModulus");
62 if (m_MatrixPoissonsRatio != 0.0 )
63 Element.SetAttribute("MatrixPoissonsRatio", stringify(m_MatrixPoissonsRatio));
64 if (m_MatrixAlpha != 0.0 )
65 Element.SetAttribute("MatrixAlpha", stringify(m_MatrixAlpha));
66}
67
69{
70 // Check the units are of the same type
71 if (CompatibleUnits("m", Units))
72 {
73 m_GeometryScale = Units;
74 return true;
75 }
76 else
77 {
78 TGERROR("Unable to set geometry scale, units must represent a length!");
79 return false;
80 }
81}
82
83void CPropertiesTextile::SetArealDensity(double dValue, string Units)
84{
85 m_ArealDensity.SetValue(dValue, Units);
86}
87
89{
90 return m_GeometryScale;
91}
92
93double CPropertiesTextile::GetArealDensity(string Units) const
94{
95 return m_ArealDensity.GetValue(Units);
96}
97
98void CPropertiesTextile::SetMatrixYoungsModulus(double dValue, string Units)
99{
100 m_MatrixYoungsModulus.SetValue(dValue, Units);
101}
102
104{
105 m_MatrixPoissonsRatio = dValue;
106}
107
109{
110 m_MatrixAlpha = dValue;
111}
112
114{
115 return m_MatrixYoungsModulus.GetValue(Units);
116}
117
119{
121}
122
124{
125 return m_MatrixAlpha;
126}
127
129{
133}
134
135
136
137
138
139
140
141
142
143
144
145
146
#define MATRIX_POISSON
#define MATRIX_ALPHA
#define MATRIX_E
#define TGERROR(MESSAGE)
Macros used to report the file name and line number to the TexGenError and TexGenLog functions.
Definition: Logger.h:29
Class to store properties related to a textile and/or yarn.
Definition: Properties.h:102
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
Definition: Properties.cpp:86
void SetArealDensity(double dValue, string Units="kg/m^2")
Set the areal density, i.e. the mass per unit area of fabric.
double GetMatrixYoungsModulus(string Units="MPa") const
void SetMatrixAlpha(double dValue)
Set the coefficient of thermal expansion for the matrix.
bool SetGeometryScale(string Units)
Set the scale of the geometry.
void SetDefaultMatrixProperties()
Set default matrix properties as specified by DefaultProperties.h.
void SetMatrixPoissonsRatio(double dValue)
Set the Poisson's ration for matrix.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
double GetArealDensity(string Units="kg/m^2") const
void SetMatrixYoungsModulus(double dValue, string Units="MPa")
Set the Young's modulus for matrix.
double GetValue(string Units) const
Definition: Property.cpp:56
void SetValue(double dValue, string Units)
Definition: Property.cpp:66
void WriteAttribute(TiXmlElement &Element, string AttributeName)
Definition: Property.cpp:31
void ReadAttribute(TiXmlElement &Element, string AttributeName)
Definition: Property.cpp:40
Namespace containing a series of customised math operations not found in the standard c++ library.
OUTPUT_TYPE
Definition: Misc.h:105
bool CompatibleUnits(std::string SourceUnits, std::string TargetUnits, std::string *pErrorMessage)
Definition: Misc.cpp:73
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.
Definition: Misc.h:50