24CSectionMeshRectangleSection::CSectionMeshRectangleSection(
int iNumLayers)
25: m_iNumLayers(iNumLayers)
51 if (Section.size() % 2 != 0)
54 TGERROR(
"Unable to create section mesh, the number of sections points specified is odd: " << Section.size());
60 p2 = Section[Section.size()/2];
62 double dAngle = atan2( dp.
y, dp.
x );
63 bool bRotated =
false;
65 vector<XY> NewSection;
66 if ( fabs( dAngle ) > 0.0000001 )
69 for (
int i = 0; i < (int)Section.size(); ++i )
72 RotPoint.
x = Section[i].x*cos(dAngle) + Section[i].y*sin(dAngle);
73 RotPoint.
y = Section[i].y*cos(dAngle) - Section[i].x*sin(dAngle);
74 NewSection.push_back(RotPoint);
79 NewSection.insert(NewSection.begin(), Section.begin(), Section.end() );
87 int iNumColumns = NewSection.size()/2-iNumLayers;
91 TGERROR(
"Unable to create section mesh, the number of columns is less than 1: " << iNumColumns);
96 vector<double> YPoints;
97 vector<double> XPoints;
102 double dXSpacing = (
Max.x -
Min.
x)/iNumColumns;
103 double dYSpacing = (
Max.y -
Min.
y)/iNumLayers;
105 double YPoint =
Min.
y;
107 for (i=0; i<iNumLayers+1; ++i)
109 YPoints.push_back(YPoint);
113 double XPoint =
Min.
x;
115 for (i=0; i<iNumColumns+1; ++i)
117 XPoints.push_back(XPoint);
124 for (i=0; i<iNumLayers+1; ++i)
126 for (j=0; j<iNumColumns+1; ++j)
128 XYZ Point( XPoints[j], YPoints[i], 0 );
132 RotPoint.
x = Point.
x*cos(-dAngle) + Point.
y*sin(-dAngle);
133 RotPoint.
y = Point.
y*cos(-dAngle) - Point.
x*sin(-dAngle);
141 for (i=0; i<iNumLayers; ++i)
143 for (j=0; j<iNumColumns; ++j)
151 bool bSurfaceNodes =
true;
155 for ( j = 1; j < iNumColumns; ++j )
157 Indices.push_back(j);
159 for ( i = 1; i < iNumLayers; ++i )
161 Indices.push_back( iNumColumns + i * (iNumColumns+1) );
163 for ( j = iNumColumns-1; j > 0; --j )
165 Indices.push_back( j + iNumLayers * (iNumColumns+1) );
167 for ( i = iNumLayers-1; i > 0; --i )
169 Indices.push_back( i * (iNumColumns+1) );
171 Indices.push_back( Indices[0] );
183 for (i=0; i<(int)Section.size(); ++i)
188 if (abs(DP.
x) > abs(DP.
y))
#define TGERROR(MESSAGE)
Macros used to report the file name and line number to the TexGenError and TexGenLog functions.
bool AddElement(ELEMENT_TYPE Type, const vector< int > &Indices)
Add an element to the mesh of given type with node number checking.
const list< int > & GetIndices(ELEMENT_TYPE ElemType) const
Get the element indices of a given element type.
void SetNode(int iIndex, XYZ Node)
Set the node at given index.
void SetNumNodes(int NumNodes)
Resize the vector size.
void Clear()
Empty mesh nodes and indices.
CMesh m_Mesh
Used to cache the result of the previous mesh for efficiency.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
int CalculateNumberofLayers(const vector< XY > &Section) const
void SetNumLayers(int iNum)
CSectionMeshRectangleSection(int iNumLayers=-1)
bool CreateMesh(const vector< XY > &Section) const
Create a mesh out of given list of points representing the edge of the section.
~CSectionMeshRectangleSection(void)
void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
Namespace containing a series of customised math operations not found in the standard c++ library.
void GetMinMaxXY(const std::vector< XY > &Points, XY &Min, XY &Max)
double Max(XYZ &Vector)
Get maximum element of vector and return it.
XYZ Min(const XYZ &P1, const XYZ &P2)
Given two points, return a new point who's coordinates are the smaller of the two.
Struct for representing points in 2D space.
Struct for representing points in 3D space.