TexGen
RectangularVoxelMesh.cpp
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2012 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"
22#include "TexGen.h"
23#include "PeriodicBoundaries.h"
24#include <iterator>
25//#define SHINY_PROFILER TRUE
26
27using namespace TexGen;
28
29CRectangularVoxelMesh::CRectangularVoxelMesh(string Type)
30:CVoxelMesh(Type)
31{
32 //m_PeriodicBoundaries = new CPeriodicBoundaries;
33}
34
36{
37 //delete m_PeriodicBoundaries;
38}
39
41{
42 XYZ DomSize;
43
44 m_DomainAABB = Textile.GetDomain()->GetMesh().GetAABB();
45 DomSize = m_DomainAABB.second - m_DomainAABB.first;
46
47 m_VoxSize[0] = DomSize.x / m_XVoxels;
48 m_VoxSize[1] = DomSize.y / m_YVoxels;
49 m_VoxSize[2] = DomSize.z / m_ZVoxels;
50 return true;
51}
52
53void CRectangularVoxelMesh::OutputNodes(ostream &Output, CTextile &Textile, int Filetype )
54{
55 int x,y,z;
56 int iNodeIndex = 1;
57 vector<XYZ> CentrePoints;
58 vector<POINT_INFO> RowInfo;
59
60 if ( Filetype == SCIRUN_EXPORT ) // if outputting in SCIRun format need to output number of voxels
61 Output << (m_XVoxels+1)*(m_YVoxels+1)*(m_ZVoxels+1) << "\n";
62
63 for ( z = 0; z <= m_ZVoxels; ++z )
64 {
65 for ( y = 0; y <= m_YVoxels; ++y )
66 {
67 for ( x = 0; x <=m_XVoxels; ++x )
68 {
69 XYZ Point;
70 Point.x = m_DomainAABB.first.x + m_VoxSize[0] * x;
71 Point.y = m_DomainAABB.first.y + m_VoxSize[1] * y;
72 Point.z = m_DomainAABB.first.z + m_VoxSize[2] * z;
73 if ( Filetype == INP_EXPORT )
74 Output << iNodeIndex << ", ";
75
76 if (Filetype == VTU_EXPORT)
77 m_Mesh.AddNode(Point);
78 else
79 Output << Point << "\n";
80
81 if ( x < m_XVoxels && y < m_YVoxels && z < m_ZVoxels )
82 {
83 Point.x += 0.5*m_VoxSize[0];
84 Point.y += 0.5*m_VoxSize[1];
85 Point.z += 0.5*m_VoxSize[2];
86 CentrePoints.push_back(Point);
87 }
88 ++iNodeIndex;
89 }
90
91 }
92 RowInfo.clear(); // Changed to do layer at a time instead of row to optimise
93 Textile.GetPointInformation( CentrePoints, RowInfo );
94 m_ElementsInfo.insert(m_ElementsInfo.end(), RowInfo.begin(), RowInfo.end() );
95 CentrePoints.clear();
96 }
97 //Textile.GetPointInformation( CentrePoints, m_ElementsInfo );
98}
const CMesh & GetMesh() const
Get the mesh representing the domain as a surface mesh.
Definition: Domain.h:73
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
pair< XYZ, XYZ > GetAABB(double dGrowDistance=0) const
Get an axis aligned bounding box for the mesh.
Definition: Mesh.cpp:340
double m_VoxSize[3]
Voxel size for each axis.
bool CalculateVoxelSizes(CTextile &Textile)
Calculate voxel size based on number of voxels on each axis and domain size.
void OutputNodes(ostream &Output, CTextile &Textile, int Filetype=INP_EXPORT)
Outputs nodes to .inp file and gets element information.
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
pair< XYZ, XYZ > m_DomainAABB
Domain limits.
Definition: VoxelMesh.h:121
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.
@ SCIRUN_EXPORT
Definition: Misc.h:115
@ INP_EXPORT
Definition: Misc.h:113
@ VTU_EXPORT
Definition: Misc.h:114
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