TexGen
SectionEllipse.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 "SectionEllipse.h"
22using namespace TexGen;
23
24CSectionEllipse::CSectionEllipse(double dWidth, double dHeight)
25: m_dWidth(dWidth)
26, m_dHeight(dHeight)
27{
28}
29
31{
32}
33
34bool CSectionEllipse::operator == (const CSection &CompareMe) const
35{
36 if (CompareMe.GetType() != GetType())
37 return false;
38 return m_dWidth == ((CSectionEllipse*)&CompareMe)->m_dWidth &&
39 m_dHeight == ((CSectionEllipse*)&CompareMe)->m_dHeight;
40}
41
43: CSection(Element)
44, m_dWidth(0)
45, m_dHeight(0)
46{
47 Element.Attribute("Width", &m_dWidth);
48 Element.Attribute("Height", &m_dHeight);
49}
50
51void CSectionEllipse::PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
52{
53 CSection::PopulateTiXmlElement(Element, OutputType);
54 Element.SetAttribute("Width", stringify(m_dWidth));
55 Element.SetAttribute("Height", stringify(m_dHeight));
56}
57
59{
60 return XY(0.5*m_dWidth*cos(t*2*PI), 0.5*m_dHeight*sin(t*2*PI));
61}
62
64{
65 return "Ellipse(W:" + stringify(m_dWidth) + ",H:" + stringify(m_dHeight) + ")";
66}
67
68
69
70
71
72
Elliptical Section.
string GetType() const
Derived class should return the class name.
bool operator==(const CSection &CompareMe) const
Overloaded equality operator to determine if two sections are the same.
void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
CSectionEllipse(double dWidth, double dHeight)
string GetDefaultName() const
Get the default name to assign to a section.
XY GetPoint(double t) const
Get a point lying on the perimeter correspending to parametric value t.
Abstract base class respresenting a yarn cross-section.
Definition: Section.h:31
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
Definition: Section.cpp:51
virtual string GetType() const =0
Derived class should return the class name.
#define PI
Definition: mymath.h:30
Namespace containing a series of customised math operations not found in the standard c++ library.
OUTPUT_TYPE
Definition: Misc.h:105
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
Struct for representing points in 2D space.
Definition: mymath.h:103