TexGen
SectionMesh.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 "SectionMesh.h"
25
26using namespace TexGen;
27CSectionMesh::CSectionMesh(void)
28{
29}
30
32{
33}
34
35CSectionMesh::CSectionMesh(TiXmlElement &Element)
36{
37/* TiXmlElement* pMesh = Element.FirstChildElement("Mesh");
38 if (pMesh)
39 {
40 m_Mesh = CMesh(*pMesh);
41 }*/
42}
43
44void CSectionMesh::PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
45{
46 Element.SetAttribute("type", GetType());
47/* TiXmlElement Mesh("Mesh");
48 m_Mesh.PopulateTiXmlElement(Mesh, OutputType);
49 Element.InsertEndChild(Mesh);*/
50}
51
53{
54 const string* pType = Element.Attribute(string("type"));
55 if (pType)
56 {
57 if (*pType == "CSectionMeshTriangulate")
58 return CSectionMeshTriangulate(Element);
59 else if (*pType == "CSectionMeshRectangular")
60 return CSectionMeshRectangular(Element);
61 else if (*pType == "CSectionMeshRectangleSection")
62 return CSectionMeshRectangleSection(Element);
63 }
65}
66
67bool CSectionMesh::CreateMeshIfNeeded(const vector<XY> &Section) const
68{
69 if (Section != m_Section)
70 {
71 m_Section = Section;
72 return CreateMesh(Section);
73 }
74 return true;
75}
76
77const CMesh &CSectionMesh::GetMesh(const vector<XY> &Section) const
78{
79 CreateMeshIfNeeded(Section);
80 return m_Mesh;
81}
82
83
84
Defines the nodes and elements of a surface or volume mesh.
Definition: Mesh.h:58
Object container to help handle memory management issues.
virtual string GetType() const =0
Derived class should return the class name.
bool CreateMeshIfNeeded(const vector< XY > &Section) const
Create the mesh if it has not already been created.
Definition: SectionMesh.cpp:67
CMesh m_Mesh
Used to cache the result of the previous mesh for efficiency.
Definition: SectionMesh.h:68
const CMesh & GetMesh(const vector< XY > &Section) const
Accessor methods.
Definition: SectionMesh.cpp:77
virtual ~CSectionMesh(void)
Definition: SectionMesh.cpp:31
virtual bool CreateMesh(const vector< XY > &Section) const =0
Create a mesh out of given list of points representing the edge of the section.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
Definition: SectionMesh.cpp:44
static CObjectContainer< CSectionMesh > CreateSectionMesh(TiXmlElement &Element)
Create a section from TiXmlElement.
Definition: SectionMesh.cpp:52
vector< XY > m_Section
Store the section used to request a mesh the last time.
Definition: SectionMesh.h:75
Create a rectangular mesh, the number of layers can be specified or set as -1 for automatic determina...
Create a rectangular mesh, the number of layers can be specified or set as -1 for automatic determina...
Creates a mesh of a section using open source package triangle http://www.cs.cmu.edu/~quake/triangle....
Namespace containing a series of customised math operations not found in the standard c++ library.
OUTPUT_TYPE
Definition: Misc.h:105