TexGen
RotatedVoxelMesh.cpp
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2018 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 "RotatedVoxelMesh.h"
22#include "TexGen.h"
23//#include "ShearedPeriodicBoundaries.h"
24#include <iterator>
25//#define SHINY_PROFILER TRUE
26
27
28using namespace TexGen;
29
30CRotatedVoxelMesh::CRotatedVoxelMesh(string Type)
31:CVoxelMesh(Type)
32{
33
34}
35
37{
38
39}
40
42{
43 XYZ DomSize;
44 CMesh Mesh = Textile.GetDomain()->GetMesh();
45
46 m_StartPoint = Mesh.GetNode(0);
47 XYZ Node4 = Mesh.GetNode(4);
48 XYZ Node2 = Mesh.GetNode(2);
49 XYZ Node1 = Mesh.GetNode(1);
50 DomSize.x = GetLength( m_StartPoint, Node4 );
51 DomSize.y = GetLength( m_StartPoint, Node2 );
52 DomSize.z = GetLength( m_StartPoint, Node1 );
53
54 XYZ XVec = Node4 - m_StartPoint;
55 XYZ YVec = Node2 - m_StartPoint;
56 XYZ ZVec = Node1 - m_StartPoint;
57 m_RotatedVoxSize[0] = XVec / m_XVoxels;
58 m_RotatedVoxSize[1] = YVec / m_YVoxels;
59 m_RotatedVoxSize[2] = ZVec / m_ZVoxels;
60
61 return true;
62}
63
64void CRotatedVoxelMesh::OutputNodes(ostream &Output, CTextile &Textile, int Filetype )
65{
66 int x,y,z;
67 int iNodeIndex = 1;
68 vector<XYZ> CentrePoints;
69 vector<POINT_INFO> RowInfo;
70 XYZ StartPoint = m_StartPoint;
71
72 for ( z = 0; z <= m_ZVoxels; ++z )
73 {
74 StartPoint = m_StartPoint + m_RotatedVoxSize[2] * z;
75
76 for ( y = 0; y <= m_YVoxels; ++y )
77 {
78 XYZ YStartPoint;
79 YStartPoint = StartPoint + m_RotatedVoxSize[1] * y;
80
81 for ( x = 0; x <=m_XVoxels; ++x )
82 {
83 XYZ Point;
84 Point = YStartPoint + m_RotatedVoxSize[0] * x;
85
86 if (Filetype == INP_EXPORT)
87 {
88 Output << iNodeIndex << ", ";
89 Output << Point << "\n";
90 }
91 else if (Filetype == VTU_EXPORT)
92 m_Mesh.AddNode(Point);
93
94 if ( x < m_XVoxels && y < m_YVoxels && z < m_ZVoxels )
95 {
96 Point.x += 0.5*m_RotatedVoxSize[0].x;
97 Point.x += 0.5*m_RotatedVoxSize[1].x;
98 Point.x += 0.5*m_RotatedVoxSize[2].x;
99 Point.y += 0.5*m_RotatedVoxSize[0].y;
100 Point.y += 0.5*m_RotatedVoxSize[1].y;
101 Point.y += 0.5*m_RotatedVoxSize[2].y;
102 Point.z += 0.5*m_RotatedVoxSize[0].z;
103 Point.z += 0.5*m_RotatedVoxSize[1].z;
104 Point.z += 0.5*m_RotatedVoxSize[2].z;
105 CentrePoints.push_back(Point);
106 }
107 ++iNodeIndex;
108 }
109
110 }
111 RowInfo.clear(); // Changed to do layer at a time instead of row to optimise
112 Textile.GetPointInformation( CentrePoints, RowInfo );
113 m_ElementsInfo.insert(m_ElementsInfo.end(), RowInfo.begin(), RowInfo.end() );
114 CentrePoints.clear();
115 }
116}
const CMesh & GetMesh() const
Get the mesh representing the domain as a surface mesh.
Definition: Domain.h:73
Defines the nodes and elements of a surface or volume mesh.
Definition: Mesh.h:58
const int AddNode(XYZ Node)
Append a node to the list of nodes, the integer returns the index of the node
Definition: Mesh.cpp:2624
const XYZ & GetNode(int iIndex) const
Get the node with given ID.
Definition: Mesh.cpp:2636
void OutputNodes(ostream &Output, CTextile &Textile, int Filetype=INP_EXPORT)
Outputs nodes to .inp file and gets element information.
XYZ m_RotatedVoxSize[3]
x, y, z lengths of rotated voxels
XYZ m_StartPoint
Reference point for generating voxel grid (Point 0 of domain mesh)
bool CalculateVoxelSizes(CTextile &Textile)
Calculate voxel size based on number of voxels on each axis and domain size.
Represents a textile cell containing yarns.
Definition: Textile.h:39
const CDomain * GetDomain() const
Definition: Textile.h:287
void GetPointInformation(const vector< XYZ > &Points, vector< POINT_INFO > &PointsInfo, double dTolerance=1e-9)
Get useful information of a list of points.
Definition: Textile.cpp:410
Class used to generate voxel mesh for output to ABAQUS.
Definition: VoxelMesh.h:35
int m_XVoxels
Number of voxels along x,y and z axes.
Definition: VoxelMesh.h:115
vector< POINT_INFO > m_ElementsInfo
Element information as calculated by GetPointInformation.
Definition: VoxelMesh.h:123
CMesh m_Mesh
Find intersections of yarn surfaces with grid of lines from node points in each axis.
Definition: VoxelMesh.h:112
Namespace containing a series of customised math operations not found in the standard c++ library.
@ INP_EXPORT
Definition: Misc.h:113
@ VTU_EXPORT
Definition: Misc.h:114
double GetLength(const XYZ &Point1, const XYZ &Point2)
Get the length between two points.
Definition: mymath.h:540
Struct for representing points in 3D space.
Definition: mymath.h:56
double z
Definition: mymath.h:57
double x
Definition: mymath.h:57
double y
Definition: mymath.h:57