OpenLB 1.8.1
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 CuboidDecomposition3D<T>& _cuboidDecomposition;
108
109 LoadBalancer<T>& _loadBalancer;
110
111 std::vector<std::vector<STLtriangle<T>>> _trianglesInCuboidList;
112
113 std::vector<std::vector<std::vector<STLtriangle<T>>>> _neighbouringTriangleInCuboidList;
114
115public:
127 BlockLatticeSTLreader(CuboidDecomposition3D<T>& cbg3d, LoadBalancer<T>& hlb, const std::string fName, T voxelSize, T stlSize=1, int method=2,
128 bool verbose = false, T overlap=0., T max=0.);
139 BlockLatticeSTLreader(const std::vector<std::vector<T>> meshPoints, T voxelSize, T stlSize=1, int method=2,
140 bool verbose = false, T overlap=0., T max=0.);
141
142 ~BlockLatticeSTLreader() override;
144 bool operator() (bool output[], const T input[]) override;
145
147 bool distance(T& distance,const Vector<T,3>& origin, const Vector<T,3>& direction, int iC=-1) override;
148
150 T signedDistance(int locC, const Vector<T,3>& input);
152 T signedDistance(const Vector<T,3>& input) override;
153
154 /* /// Computes signed distance to closest triangle in direction of the surface normal in local cuboid locC
155 T signedDistance(int locC, const Vector<T,3>& input, STLtriangle<T>& _triangle);
157 T signedDistance(const Vector<T,3>& input, STLtriangle<T>& _triangle);// override;*/
158
160 Vector<T,3> surfaceNormal(const Vector<T,3>& pos, const T meshSize=0) override;
161
163 void print();
164
166 void writeSTL(std::string stlName="");
167
169 void writeOctree();
170
172 void setNormalsOutside();
173
177
179 inline Octree<T>* getTree() const
180 {
181 return _tree;
182 };
183
184
187 {
188 return _mesh;
189 };
192};
193} // namespace olb
194
195#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.
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.
BlockLatticeSTLreader(CuboidDecomposition3D< 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.
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 createNeighbouringTriangleInCuboidVector()
Needed for the signed Distance function: Creates a list of neighbouring triangles for each 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.
IndicatorF3D is an application from .
Definition aliases.h:244
Base class for all LoadBalancer.
Definition vtiWriter.h:42
class for marking output with some text
Plain old scalar vector.
This file contains indicator functions.
Top level namespace for all of OpenLB.
Octree.
efficient implementation of a vector class