TexGen
SurfaceMesh.cpp
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2019 Louise Brown
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 "TexGen.h"
22#include "SurfaceMesh.h"
23
24using namespace TexGen;
25using namespace std;
26
27CSurfaceMesh::CSurfaceMesh(double Seed, bool bFillEnds ) : CMeshDomainPlane(Seed, bFillEnds)
28{
29}
30
32{
33}
34
35void CSurfaceMesh::SaveSurfaceMesh(CTextile &Textile, bool bSaveYarns, bool bSaveDomain, bool bTrimToDomain)
36{
37 XYZ P;
38
39 if (!Textile.AddSurfaceToMesh(m_Mesh, m_DomainMeshes, bTrimToDomain))
40 {
41 TGERROR("Error creating surface mesh.");
42 return;
43 }
45
46 if (!bSaveYarns)
47 m_Mesh.Clear();
48
49 if (bSaveDomain)
50 {
51 if (Textile.GetDomain()->GetType() == "CPrismDomain")
52 MeshDomainPlanes(false); // Could change later so that is periodic across polygon faces
53 else
54 MeshDomainPlanes(true);
55
56 vector<CMesh>::iterator itTriangulatedMeshes;
57 for (itTriangulatedMeshes = m_TriangulatedMeshes.begin(); itTriangulatedMeshes != m_TriangulatedMeshes.end(); ++itTriangulatedMeshes)
58 {
59 m_Mesh.InsertMesh(*itTriangulatedMeshes);
60 }
61 }
62}
63
64void CSurfaceMesh::SaveToSTL(string Filename, bool bBinary)
65{
66 m_Mesh.SaveToSTL( Filename, bBinary );
67}
68
69void CSurfaceMesh::SaveToVTK( string Filename )
70{
71 m_Mesh.SaveToVTK(Filename);
72}
73
74void CSurfaceMesh::SaveToSCIRun(string Filename)
75{
76 m_Mesh.SaveToSCIRun(Filename);
77}
#define TGERROR(MESSAGE)
Macros used to report the file name and line number to the TexGenError and TexGenLog functions.
Definition: Logger.h:29
virtual string GetType() const =0
Derived class should return the class name.
void MeshDomainPlanes(bool bPeriodic)
vector< CMesh > m_DomainMeshes
Vector of meshes used to store domain plane meshes.
vector< CMesh > m_TriangulatedMeshes
Vector of triangulated domain plane meshes.
void InsertMesh(const CMesh &Mesh, XYZ Offset=XYZ(0, 0, 0))
Add the contents of Mesh to this mesh.
Definition: Mesh.cpp:93
void ConvertQuadstoTriangles(bool bQuality=true)
Convert the quad elements to triangles.
Definition: Mesh.cpp:1088
bool SaveToVTK(string Filename, const vector< CMeshDataBase * > *pMeshData=NULL) const
Save the mesh to VTK unstructured grid file format (.vtu)
Definition: Mesh.cpp:2348
bool SaveToSCIRun(string Filename)
Save the mesh to SCIRun format.
Definition: Mesh.cpp:2690
bool SaveToSTL(string Filename, bool bBinary=true) const
Save the mesh to STL file.
Definition: Mesh.cpp:1933
void Clear()
Empty mesh nodes and indices.
Definition: Mesh.cpp:1448
void SaveToSCIRun(string Filename)
Save surface mesh data to SCIRun format.
Definition: SurfaceMesh.cpp:74
void SaveSurfaceMesh(CTextile &Textile, bool bSaveYarns=true, bool bSaveDomain=false, bool bTrimToDomain=true)
Save a textile as a surface mesh with triangulated domain faces.
Definition: SurfaceMesh.cpp:35
void SaveToSTL(string Filename, bool bBinary)
Save surface mesh data to STL file.
Definition: SurfaceMesh.cpp:64
void SaveToVTK(string Filename)
Save surface mesh data to VTK file.
Definition: SurfaceMesh.cpp:69
CMesh m_Mesh
Mesh used to store node points and elements.
Definition: SurfaceMesh.h:65
virtual ~CSurfaceMesh(void)
Definition: SurfaceMesh.cpp:31
Represents a textile cell containing yarns.
Definition: Textile.h:39
const CDomain * GetDomain() const
Definition: Textile.h:287
void AddSurfaceToMesh(CMesh &Mesh, bool bTrimToDomain=false)
Create surface mesh for this textile and add it to the mesh object.
Definition: Textile.cpp:187
Namespace containing a series of customised math operations not found in the standard c++ library.
Struct for representing points in 3D space.
Definition: mymath.h:56