24CSectionPolygon::CSectionPolygon(
const vector<XY> &PolygonPoints,
bool bSingleQuadrant,
bool bRetainPoints)
25: m_PolygonPoints(PolygonPoints),
26m_bRetainPoints(bRetainPoints)
31 vector<XY>::const_iterator itPoint;
34 for (itPoint = PolygonPoints.end()-2; itPoint != PolygonPoints.begin(); --itPoint)
41 for (itPoint = PolygonPoints.begin(); itPoint != PolygonPoints.end(); ++itPoint)
49 for (itPoint = PolygonPoints.end()-2; itPoint != PolygonPoints.begin(); --itPoint)
90 vector<XY>::const_iterator itPoint;
93 TiXmlElement Point(
"PolygonPoint");
94 Point.SetAttribute(
"value",
stringify(*itPoint));
95 Element.InsertEndChild(Point);
112 vector<double>::const_iterator itT;
113 vector<XY>::const_iterator itPoint;
117 for( itT =
m_t.begin(), i = 0; itT !=
m_t.end(); ++itT, ++i )
119 if ( fabs(*itT - t) < 1e-10 )
125 double t2 = itT ==
m_t.end() ? 1.0 :
m_t[i];
138 vector<XY>::iterator itPoint;
141 itPoint->x *=
Scale.x;
142 itPoint->y *=
Scale.y;
148 vector<XY>::iterator itPoint;
158 vector<XY>::const_iterator itPoint;
159 double dTotalLength = 0.0;
161 XY StartPoint = *itPoint;
162 XY LastPoint = *itPoint;
164 m_t.push_back( 0.0 );
167 dTotalLength +=
GetLength( *itPoint, LastPoint );
168 m_t.push_back( dTotalLength );
169 LastPoint = *itPoint;
171 dTotalLength +=
GetLength( LastPoint, StartPoint );
174 vector<double>::iterator itT;
175 for ( itT =
m_t.begin(); itT !=
m_t.end(); ++itT )
177 *itT /= dTotalLength;
#define FOR_EACH_TIXMLELEMENT(CHILDELEMENT, PARENTELEMENT, ELEMENTNAME)
Macro to enable looping over tinyxml easier.
Abstract base class respresenting a yarn cross-section.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
vector< XY > m_EdgePoints
List of 2d points creating the outline of the cross-section.
bool m_bEquiSpaced
Keep this variable to determine whether the section was created with equidistant points or not.
virtual string GetType() const =0
Derived class should return the class name.
Creates a polygonal section, where a list of points are given to form the closed polygon.
string GetDefaultName() const
Get the default name to assign to a section.
vector< XY > m_PolygonPoints
XY GetPoint(double t) const
Get a point lying on the perimeter correspending to parametric value t.
void CreateSection() const
Create section with edge points same as polygon points.
void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
void Scale(XY Scale)
Change the scale of the section by multiplying each coordinate component by the component given by th...
string GetType() const
Derived class should return the class name.
void CalcTValues()
Assign t value as proportion of distance around perimeter for each point.
vector< double > m_t
The proportion of the distance around the total perimeter range from 0 to 1 for each point.
CSectionPolygon(const vector< XY > &PolygonPoints, bool bSingleQuadrant=false, bool bRetainPoints=false)
bool operator==(const CSection &CompareMe) const
Overloaded equality operator to determine if two sections are the same.
bool m_bRetainPoints
Whether or not to use the polygon points to define the section edge points.
Namespace containing a series of customised math operations not found in the standard c++ library.
double GetLength(const XYZ &Point1, const XYZ &Point2)
Get the length between two points.
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.
Struct for representing points in 2D space.