OpenLB 1.7
Loading...
Searching...
No Matches
blockLatticeSTLreader.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2010-2015 Thomas Henn, Mathias J. Krause
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
28#ifndef BLOCK_LATTICE_STL_READER_H
29#define BLOCK_LATTICE_STL_READER_H
30
31#include <string>
32#include <vector>
33#include <iostream>
34#include <sstream>
35#include <set>
36#include <limits>
37
43#include "octree.h"
44#include "core/vector.h"
45
46
47// All OpenLB code is contained in this namespace.
48namespace olb {
49
50
51
52
53template<typename T>
55private:
56 /*
57 * Old indicate function (slower, more stable)
58 * Define three rays (X-, Y-, Z-direction) for each leaf and count intersections
59 * with STL for each ray. Odd number of intersection means inside (Majority vote).
60 */
61 void indicate1();
62 /*
63 * New indicate function (faster, less stable)
64 * Define ray in Z-direction for each Voxel in XY-layer. Indicate all nodes on the fly.
65 */
66 void indicate2();
67 /*
68 * New indicate function (faster, less stable)
69 * Define ray in X-direction for each Voxel in YZ-layer. Indicate all nodes on the fly.
70 */
71 void indicate2_Xray();
72 /*
73 * New indicate function (faster, less stable)
74 * Define ray in Y-direction for each Voxel in XZ-layer. Indicate all nodes on the fly.
75 */
76 void indicate2_Yray();
77 /*
78 * Double ray approach: two times (X-, Y-, Z-direction) for each leaf.
79 * Could be use to deal with double layer triangles and face intersections.
80 */
81
82 void indicate3();
83
85 Vector<T,3> findNormalOnSurface(const PhysR<T,3>& pt);
86
88 Vector<T,3> evalSurfaceNormal(const Vector<T,3>& origin);
89
91 T _voxelSize;
93 T _stlSize;
95 T _overlap;
97 Octree<T>* _tree;
99 const std::string _fName;
101 STLmesh<T> _mesh;
103 bool _verbose;
105 mutable OstreamManager clout;
106
107 CuboidGeometry3D<T>& _cuboidGeometry;
108
109 LoadBalancer<T>& _loadBalancer;
110
111 std::vector<std::vector<STLtriangle<T>>> _trianglesInCuboidList;
112
113public:
125 BlockLatticeSTLreader(CuboidGeometry3D<T>& cbg3d, LoadBalancer<T>& hlb, const std::string fName, T voxelSize, T stlSize=1, int method=2,
126 bool verbose = false, T overlap=0., T max=0.);
137 BlockLatticeSTLreader(const std::vector<std::vector<T>> meshPoints, T voxelSize, T stlSize=1, int method=2,
138 bool verbose = false, T overlap=0., T max=0.);
139
140 ~BlockLatticeSTLreader() override;
142 bool operator() (bool output[], const T input[]) override;
143
145 bool distance(T& distance,const Vector<T,3>& origin, const Vector<T,3>& direction, int iC=-1) override;
146
148 T signedDistance(int locC, const Vector<T,3>& input);
150 T signedDistance(const Vector<T,3>& input) override;
151
153 Vector<T,3> surfaceNormal(const Vector<T,3>& pos, const T meshSize=0) override;
154
156 void print();
157
159 void writeSTL(std::string stlName="");
160
162 void writeOctree();
163
165 void setNormalsOutside();
166
170
172 inline Octree<T>* getTree() const
173 {
174 return _tree;
175 };
176
177
180 {
181 return _mesh;
182 };
183};
184
185} // namespace olb
186
187#endif
void writeSTL(std::string stlName="")
Writes STL mesh in Si units.
T signedDistance(int locC, const Vector< T, 3 > &input)
Computes signed distance to closest triangle in direction of the surface normal in local cuboid locC.
STLmesh< T > & getMesh()
Returns mesh.
BlockLatticeSTLreader(CuboidGeometry3D< T > &cbg3d, LoadBalancer< T > &hlb, const std::string fName, T voxelSize, T stlSize=1, int method=2, bool verbose=false, T overlap=0., T max=0.)
Constructs a new BlockLatticeSTLreader from a file.
void print()
Prints console output.
bool operator()(bool output[], const T input[]) override
Returns whether node is inside or not.
void setBoundaryInsideNodes()
Every octree leaf intersected by the STL will be part of the inside nodes.
Octree< T > * getTree() const
Returns tree.
Vector< T, 3 > surfaceNormal(const Vector< T, 3 > &pos, const T meshSize=0) override
Finds and returns normal of the closest surface (triangle)
void setNormalsOutside()
Rearranges normals of triangles to point outside of geometry.
bool distance(T &distance, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, int iC=-1) override
Computes distance to closest triangle intersection.
A cuboid geometry represents a voxel mesh.
IndicatorF3D is an application from .
Base class for all LoadBalancer.
class for marking output with some text
Plain old scalar vector.
Definition vector.h:47
The description of a vector of 3D cuboid – header file.
This file contains indicator functions.
Top level namespace for all of OpenLB.
Octree.
efficient implementation of a vector class