OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::STLreader< T > Class Template Reference

#include <stlReader.h>

+ Inheritance diagram for olb::STLreader< T >:
+ Collaboration diagram for olb::STLreader< T >:

Public Member Functions

 STLreader (const std::string fName, T voxelSize, T stlSize=1, RayMode method=RayMode::FastRayZ, bool verbose=false, T overlap=0., T max=0.)
 Constructs a new STLreader from a file.
 
 STLreader (const std::vector< std::vector< T > > meshPoints, T voxelSize, T stlSize=1, RayMode method=RayMode::FastRayZ, bool verbose=false, T overlap=0., T max=0.)
 Constructs a new STLreader from a file.
 
 ~STLreader () override
 
bool operator() (bool output[], const T input[]) override
 Returns whether node is inside or not.
 
bool isInsideRootTree (const T input[])
 Returns whether node is inside the top-level octree or not.
 
Vector< T, 3 > closestPointInBoundingBox (const Vector< T, 3 > &input)
 Returns the closest point in the bounding box If input is already inside, then it returns input.
 
bool distance (T &distance, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, int iC=-1) override
 Computes distance to closest triangle intersection.
 
distanceToClosestSurfacePoint (Vector< T, 3 > physR)
 
Vector< T, 3 > normalAtClosestSurfacePoint (Vector< T, 3 > physR)
 
signedDistance (const Vector< T, 3 > &input) override
 Computes signed distance to closest triangle in direction of the surface normal Using the cached information (faster, but less accurate)
 
signedDistanceExact (const Vector< T, 3 > &input) override
 Computes exact signed distance to closest triangle in direction of the surface normal Much slower, but more accurate.
 
template<SignMode SIGNMODE>
signedDistance (const Vector< T, 3 > &input)
 Computes signed distance to closest triangle in direction of the surface normal.
 
Vector< T, 3 > surfaceNormal (const Vector< T, 3 > &pos, const T meshSize=0) override
 Finds and returns normal of the closest surface (triangle) Using the cached information (faster, but less accurate)
 
Vector< T, 3 > surfaceNormalExact (const Vector< T, 3 > &pos, const T meshSize=0) override
 Finds and returns normal of the closest surface (triangle) Much slower, but more accurate.
 
template<SignMode SIGNMODE>
Vector< T, 3 > surfaceNormal (const Vector< T, 3 > &pos, const T meshSize=0)
 Finds and returns normal of the closest surface (triangle)
 
void print ()
 Prints console output.
 
void writeSTL (std::string stlName="")
 Writes STL mesh in Si units.
 
void writeOctree ()
 Writes Octree.
 
void setNormalsOutside ()
 Rearranges normals of triangles to point outside of geometry.
 
void setBoundaryInsideNodes ()
 Every octree leaf intersected by the STL will be part of the inside nodes.
 
Octree< T > * getTree () const
 Returns tree.
 
STLmesh< T > & getMesh ()
 Returns mesh.
 
 STLreader (const std::string fName, T voxelSize, T stlSize=1, RayMode method=RayMode::FastRayZ, bool verbose=false, T overlap=0., T max=0.)
 Constructs a new STLreader from a file.
 
 STLreader (const std::vector< std::vector< T > > meshPoints, T voxelSize, T stlSize=1, RayMode method=RayMode::FastRayZ, bool verbose=false, T overlap=0., T max=0.)
 Constructs a new STLreader from a file.
 
 ~STLreader () override
 
bool operator() (bool output[], const T input[]) override
 Returns whether node is inside or not.
 
bool isInsideRootTree (const T input[])
 Returns whether node is inside the top-level octree or not.
 
Vector< T, 3 > closestPointInBoundingBox (const Vector< T, 3 > &input)
 Returns the closest point in the bounding box If input is already inside, then it returns input.
 
bool distance (T &distance, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, int iC=-1) override
 Computes distance to closest triangle intersection.
 
signedDistance (const Vector< T, 3 > &input) override
 Computes signed distance to closest triangle in direction of the surface normal Using the cached information (faster, but less accurate)
 
signedDistanceExact (const Vector< T, 3 > &input) override
 Computes exact signed distance to closest triangle in direction of the surface normal Much slower, but more accurate.
 
template<SignMode SIGNMODE>
signedDistance (const Vector< T, 3 > &input)
 Computes signed distance to closest triangle in direction of the surface normal.
 
Vector< T, 3 > surfaceNormal (const Vector< T, 3 > &pos, const T meshSize=0) override
 Finds and returns normal of the closest surface (triangle) Using the cached information (faster, but less accurate)
 
Vector< T, 3 > surfaceNormalExact (const Vector< T, 3 > &pos, const T meshSize=0) override
 Finds and returns normal of the closest surface (triangle) Much slower, but more accurate.
 
template<SignMode SIGNMODE>
Vector< T, 3 > surfaceNormal (const Vector< T, 3 > &pos, const T meshSize=0)
 Finds and returns normal of the closest surface (triangle)
 
void print ()
 Prints console output.
 
void writeSTL (std::string stlName="")
 Writes STL mesh in Si units.
 
void writeOctree ()
 Writes Octree.
 
void setNormalsOutside ()
 Rearranges normals of triangles to point outside of geometry.
 
void setBoundaryInsideNodes ()
 Every octree leaf intersected by the STL will be part of the inside nodes.
 
Octree< T > * getTree () const
 Returns tree.
 
STLmesh< T > & getMesh ()
 Returns mesh.
 
- Public Member Functions inherited from olb::IndicatorF3D< T >
virtual Vector< S, 3 > & getMin ()
 
virtual Vector< S, 3 > & getMax ()
 
virtual bool distance (S &distance, const Vector< S, 3 > &origin, S precision, const Vector< S, 3 > &direction)
 
virtual bool distance (S &distance, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, S precision, S pitch)
 
virtual bool distance (S &distance, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, int iC=-1)
 
virtual bool distance (S &distance, const Vector< S, 3 > &origin)
 
virtual bool distance (S &distance, const S input[])
 
virtual bool normal (Vector< S, 3 > &normal, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, int iC=-1)
 returns true and the normal if there was one found for an given origin and direction
 
virtual bool rotOnAxis (Vector< S, 3 > &vec_rot, const Vector< S, 3 > &vec, const Vector< S, 3 > &axis, S &theta)
 Rotate vector around axis by angle theta.
 
virtual bool operator() (bool output[1], const S input[3])
 Returns true if input is inside the indicator.
 
virtual S signedDistance (const Vector< S, 3 > &input)
 Returns signed distance to the nearest point on the indicator surface Uses the fastest, but potentially less accurate method.
 
virtual S signedDistanceExact (const Vector< S, 3 > &input)
 Returns exact signed distance to the nearest point on the indicator surface Uses the most accurate, but slower method This is usually sufficient for fluid-wall interactions.
 
virtual Vector< S, 3 > surfaceNormal (const Vector< S, 3 > &pos, const S meshSize)
 Return surface normal Uses the fastest, but potentially less accurate method.
 
virtual Vector< S, 3 > surfaceNormalExact (const Vector< S, 3 > &pos, const S meshSize)
 Return surface normal Uses the most accurate, but slower method This is likely necessary for particle-wall interactions.
 
Vector< S, 3 > surfaceNormal (const Vector< S, 3 > &pos, const S meshSize, std::function< Vector< S, 3 >(const Vector< S, 3 > &)> transformPos)
 Return surface normal after possible translation and rotation Uses the fastest, but potentially less accurate method.
 
Vector< S, 3 > surfaceNormalExact (const Vector< S, 3 > &pos, const S meshSize, std::function< Vector< S, 3 >(const Vector< S, 3 > &)> transformPos)
 Return surface normal after possible translation and rotation Uses the fastest, but potentially less accurate method.
 
bool isInsideBox (Vector< S, 3 > point)
 Returns true if point is inside a cube with corners _myMin and _myMax
 
virtual Vector< S, 3 > getSample (const std::function< S()> &randomness) const
 
- Public Member Functions inherited from olb::GenericF< bool, S >
virtual ~GenericF ()=default
 
int getSourceDim () const
 read only access to member variable _m
 
int getTargetDim () const
 read only access to member variable _n
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
virtual bool operator() (bool output[], const S input[])=0
 has to be implemented for 'every' derived class
 
bool operator() (bool output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (bool output[], S input0)
 
bool operator() (bool output[], S input0, S input1)
 
bool operator() (bool output[], S input0, S input1, S input2)
 
bool operator() (bool output[], S input0, S input1, S input2, S input3)
 

Additional Inherited Members

- Public Types inherited from olb::GenericF< bool, S >
using targetType
 
using sourceType
 
- Public Attributes inherited from olb::GenericF< bool, S >
std::shared_ptr< GenericF< bool, S > > _ptrCalcC
 memory management, frees resouces (calcClass)
 
- Protected Member Functions inherited from olb::IndicatorF3D< T >
 IndicatorF3D ()
 
- Protected Member Functions inherited from olb::GenericF< bool, S >
 GenericF (int targetDim, int sourceDim)
 
- Protected Attributes inherited from olb::IndicatorF3D< T >
Vector< S, 3 > _myMin
 
Vector< S, 3 > _myMax
 

Detailed Description

template<typename T>
class olb::STLreader< T >

Definition at line 240 of file STLreaderForSubgridParticleWallContact.h.

Constructor & Destructor Documentation

◆ STLreader() [1/4]

template<typename T >
olb::STLreader< T >::STLreader ( const std::string fName,
T voxelSize,
T stlSize = 1,
RayMode method = RayMode::FastRayZ,
bool verbose = false,
T overlap = 0.,
T max = 0. )

Constructs a new STLreader from a file.

Parameters
fNameThe STL file name
voxelSizeVoxelsize in SI units
stlSizeConversion factor for STL (e.g. STL in mm stlSize=10^-3)
methodChoose indication method 0: fast, less stable 1: slow, more stable (for untight STLs)
verboseGet additional information.

Find center of tree and move by _voxelSize/4.

Create tree

Compute _myMin, _myMax such that they are the smallest (greatest) Voxel inside the STL.

Indicate nodes of the tree. (Inside/Outside)

Find center of tree and move by _voxelSize/4.

Create tree

Compute _myMin, _myMax such that they are the smallest (greatest) Voxel inside the STL.

Indicate nodes of the tree. (Inside/Outside)

Definition at line 848 of file stlReader.hh.

850 : _voxelSize(voxelSize),
851 _stlSize(stlSize),
852 _overlap(overlap),
853 _fName(fName),
854 _mesh(fName, stlSize),
855 _verbose(verbose),
856 clout(std::cout, "STLreader")
857{
858 this->getName() = "STLreader";
859
860 if (_verbose) {
861 clout << "Voxelizing ..." << std::endl;
862 }
863
864 Vector<T,3> extension = _mesh.getMax() - _mesh.getMin();
865 if ( util::nearZero(max) ) {
866 max = util::max(extension[0], util::max(extension[1], extension[2])) + _voxelSize;
867 }
868 int j = 0;
869 for (; _voxelSize * util::pow(2, j) < max; j++)
870 ;
871 Vector<T,3> center;
872 T radius = _voxelSize * util::pow(2, j - 1);
873
875 for (unsigned i = 0; i < 3; i++) {
876 center[i] = (_mesh.getMin()[i] + _mesh.getMax()[i]) / 2. - _voxelSize / 4.;
877 }
878
880 _tree = new Octree<T>(center, radius, &_mesh, j, _overlap);
881
883 for (int i = 0; i < 3; i++) {
884 this->_myMin[i] = center[i] + _voxelSize / 2.;
885 this->_myMax[i] = center[i] - _voxelSize / 2.;
886 }
887 for (int i = 0; i < 3; i++) {
888 while (this->_myMin[i] > _mesh.getMin()[i]) {
889 this->_myMin[i] -= _voxelSize;
890 }
891 while (this->_myMax[i] < _mesh.getMax()[i]) {
892 this->_myMax[i] += _voxelSize;
893 }
894 this->_myMax[i] -= _voxelSize;
895 this->_myMin[i] += _voxelSize;
896 }
897
899 switch (method) {
900 case RayMode::Robust:
901 indicate1();
902 break;
904 indicate3();
905 break;
907 indicate2_Xray();
908 break;
910 indicate2_Yray();
911 break;
912 default:
913 indicate2();
914 break;
915 }
916
917 if (_verbose) {
918 print();
919 }
920 if (_verbose) {
921 clout << "Voxelizing ... OK" << std::endl;
922 }
923}
std::string & getName()
Definition genericF.hh:51
Vector< S, 3 > _myMax
Vector< S, 3 > _myMin
void print()
Prints console output.
Expr max(Expr a, Expr b)
Definition expr.cpp:245
Expr pow(Expr base, Expr exp)
Definition expr.cpp:235
bool nearZero(T a) any_platform
return true if a is close to zero
Definition util.h:402
constexpr T max(const ScalarVector< T, D, IMPL > &v)
Definition vector.h:466
@ DoubleRay
Indicate function with ray in Y-direction(faster, less stable).
@ FastRayX
Old indicate function (slower, more stable)
@ FastRayY
Indicate function with ray in X-direction(faster, less stable).
@ Robust
Indicate function with ray in Z-direction(faster, less stable). Default option.

References olb::IndicatorF3D< T >::_myMax, olb::IndicatorF3D< T >::_myMin, olb::DoubleRay, olb::FastRayX, olb::FastRayY, olb::GenericF< bool, S >::getName(), olb::max(), olb::util::max(), olb::util::nearZero(), olb::util::pow(), olb::STLreader< T >::print(), and olb::Robust.

+ Here is the call graph for this function:

◆ STLreader() [2/4]

template<typename T >
olb::STLreader< T >::STLreader ( const std::vector< std::vector< T > > meshPoints,
T voxelSize,
T stlSize = 1,
RayMode method = RayMode::FastRayZ,
bool verbose = false,
T overlap = 0.,
T max = 0. )

Constructs a new STLreader from a file.

Parameters
fNameThe STL file name
voxelSizeVoxelsize in SI units
stlSizeConversion factor for STL (e.g. STL in mm stlSize=10^-3)
methodChoose indication method 0: fast, less stable 1: slow, more stable (for untight STLs)
verboseGet additional information.

Find center of tree and move by _voxelSize/4.

Create tree

Compute _myMin, _myMax such that they are the smallest (greatest) Voxel inside the STL.

Find center of tree and move by _voxelSize/4.

Create tree

Compute _myMin, _myMax such that they are the smallest (greatest) Voxel inside the STL.

Definition at line 929 of file stlReader.hh.

931 : _voxelSize(voxelSize),
932 _stlSize(stlSize),
933 _overlap(overlap),
934 _fName("meshPoints.stl"),
935 _mesh(meshPoints, stlSize),
936 _verbose(verbose),
937 clout(std::cout, "STLreader")
938{
939 this->getName() = "STLreader";
940
941 if (_verbose) {
942 clout << "Voxelizing ..." << std::endl;
943 }
944
945 Vector<T,3> extension = _mesh.getMax() - _mesh.getMin();
946 if ( util::nearZero(max) ) {
947 max = util::max(extension[0], util::max(extension[1], extension[2])) + _voxelSize;
948 }
949 int j = 0;
950 for (; _voxelSize * util::pow(2, j) < max; j++)
951 ;
952 Vector<T,3> center;
953 T radius = _voxelSize * util::pow(2, j - 1);
954
956 for (unsigned i = 0; i < 3; i++) {
957 center[i] = (_mesh.getMin()[i] + _mesh.getMax()[i]) / 2. - _voxelSize / 4.;
958 }
959
961
962 _tree = new Octree<T>(center, radius, &_mesh, j, _overlap);
963
965 for (int i = 0; i < 3; i++) {
966 this->_myMin[i] = center[i] + _voxelSize / 2.;
967 this->_myMax[i] = center[i] - _voxelSize / 2.;
968 }
969 for (int i = 0; i < 3; i++) {
970 while (this->_myMin[i] > _mesh.getMin()[i]) {
971 this->_myMin[i] -= _voxelSize;
972 }
973 while (this->_myMax[i] < _mesh.getMax()[i]) {
974 this->_myMax[i] += _voxelSize;
975 }
976 this->_myMax[i] -= _voxelSize;
977 this->_myMin[i] += _voxelSize;
978 }
979 //automaticly choose the method with minimum extension in its direction
980
981 /*if(extension[0] == std::min_element(extension.begin(), extension.end())){
982 method = 4;
983 }
984 else if(extension[1] == std::min_element(extension.begin(), extension.end())){
985 method = 5;
986 }
987 else if(extension[2] == std::min_element(extension.begin(), extension.end())){
988 method = 0;
989 }
990 */
991
992
993 // Indicate nodes of the tree. (Inside/Outside)
994 switch (method) {
995 case RayMode::Robust:
996 indicate1();
997 break;
999 indicate3();
1000 break;
1001 case RayMode::FastRayX:
1002 indicate2_Xray();
1003 break;
1004 case RayMode::FastRayY:
1005 indicate2_Yray();
1006 break;
1007 default:
1008 indicate2();
1009 break;
1010 }
1011
1013
1014 if (_verbose) {
1015 print();
1016 }
1017 if (_verbose) {
1018 clout << "Voxelizing ... OK" << std::endl;
1019 }
1020}
void setNormalsOutside()
Rearranges normals of triangles to point outside of geometry.

References olb::IndicatorF3D< T >::_myMax, olb::IndicatorF3D< T >::_myMin, olb::DoubleRay, olb::FastRayX, olb::FastRayY, olb::GenericF< bool, S >::getName(), olb::max(), olb::util::max(), olb::util::nearZero(), olb::util::pow(), olb::STLreader< T >::print(), olb::Robust, and olb::STLreader< T >::setNormalsOutside().

+ Here is the call graph for this function:

◆ ~STLreader() [1/2]

template<typename T >
olb::STLreader< T >::~STLreader ( )
override

Definition at line 1023 of file stlReader.hh.

1024{
1025 delete _tree;
1026}

◆ STLreader() [3/4]

template<typename T >
olb::STLreader< T >::STLreader ( const std::string fName,
T voxelSize,
T stlSize = 1,
RayMode method = RayMode::FastRayZ,
bool verbose = false,
T overlap = 0.,
T max = 0. )

Constructs a new STLreader from a file.

Parameters
fNameThe STL file name
voxelSizeVoxelsize in SI units
stlSizeConversion factor for STL (e.g. STL in mm stlSize=10^-3)
methodChoose indication method 0: fast, less stable 1: slow, more stable (for untight STLs)
verboseGet additional information.

◆ STLreader() [4/4]

template<typename T >
olb::STLreader< T >::STLreader ( const std::vector< std::vector< T > > meshPoints,
T voxelSize,
T stlSize = 1,
RayMode method = RayMode::FastRayZ,
bool verbose = false,
T overlap = 0.,
T max = 0. )

Constructs a new STLreader from a file.

Parameters
fNameThe STL file name
voxelSizeVoxelsize in SI units
stlSizeConversion factor for STL (e.g. STL in mm stlSize=10^-3)
methodChoose indication method 0: fast, less stable 1: slow, more stable (for untight STLs)
verboseGet additional information.

◆ ~STLreader() [2/2]

template<typename T >
olb::STLreader< T >::~STLreader ( )
override

Member Function Documentation

◆ closestPointInBoundingBox() [1/2]

template<typename T >
Vector< T, 3 > olb::STLreader< T >::closestPointInBoundingBox ( const Vector< T, 3 > & input)

Returns the closest point in the bounding box If input is already inside, then it returns input.

Definition at line 1383 of file stlReader.hh.

1384{
1385 T coords = _tree->getRadius();
1386 Vector<T,3> c(_tree->getCenter());
1387 Vector<T,3> closestPoint;
1388 for(int i = 0; i < 3; ++i) {
1389 closestPoint[i] = util::max(c[i] - coords, util::min(c[i] + coords, input[i]));
1390 }
1391 return closestPoint;
1392}
platform_constant int c[Q][D]
Definition functions.h:57
Expr min(Expr a, Expr b)
Definition expr.cpp:249

References olb::util::max(), and olb::util::min().

+ Here is the call graph for this function:

◆ closestPointInBoundingBox() [2/2]

template<typename T >
Vector< T, 3 > olb::STLreader< T >::closestPointInBoundingBox ( const Vector< T, 3 > & input)

Returns the closest point in the bounding box If input is already inside, then it returns input.

◆ distance() [1/2]

template<typename T >
bool olb::STLreader< T >::distance ( T & distance,
const Vector< T, 3 > & origin,
const Vector< T, 3 > & direction,
int iC = -1 )
override

Computes distance to closest triangle intersection.

Definition at line 1396 of file stlReader.hh.

1398{
1399 Octree<T>* node = nullptr;
1400 Vector<T,3> dir(direction);
1401 dir = normalize(dir);
1402 Vector<T,3> extends = _mesh.getMax() - _mesh.getMin();
1403 Vector<T,3> pt(origin);
1404 Vector<T,3> q;
1405 Vector<T,3> s;
1406 Vector<T,3> center = _mesh.getMin() + 1 / 2. * extends;
1407 T step = _voxelSize / 1000., a = 0;
1408
1409 for (int i = 0; i < 3; i++) {
1410 extends[i] /= 2.;
1411 }
1412
1413 if (!(_mesh.getMin()[0] < origin[0] && origin[0] < _mesh.getMax()[0]
1414 && _mesh.getMin()[1] < origin[1] && origin[1] < _mesh.getMax()[1]
1415 && _mesh.getMin()[2] < origin[2] && origin[2] < _mesh.getMax()[2])) {
1416 T t = T(), d = T();
1417 bool foundQ = false;
1418
1419 if (dir[0] > 0) {
1420 d = _mesh.getMin()[0];
1421 t = (d - origin[0]) / dir[0];
1422 pt[0] = origin[0] + (t + step) * dir[0];
1423 pt[1] = origin[1] + (t + step) * dir[1];
1424 pt[2] = origin[2] + (t + step) * dir[2];
1425
1426 if (_mesh.getMin()[1] < pt[1] && pt[1] < _mesh.getMax()[1]
1427 && _mesh.getMin()[2] < pt[2] && pt[2] < _mesh.getMax()[2]) {
1428 foundQ = true;
1429 }
1430 }
1431 else if (dir[0] < 0) {
1432 d = _mesh.getMax()[0];
1433 t = (d - origin[0]) / dir[0];
1434 pt[0] = origin[0] + (t + step) * dir[0];
1435 pt[1] = origin[1] + (t + step) * dir[1];
1436 pt[2] = origin[2] + (t + step) * dir[2];
1437 if (_mesh.getMin()[1] < pt[1] && pt[1] < _mesh.getMax()[1]
1438 && _mesh.getMin()[2] < pt[2] && pt[2] < _mesh.getMax()[2]) {
1439 foundQ = true;
1440 }
1441 }
1442
1443 if (dir[1] > 0 && !foundQ) {
1444 d = _mesh.getMin()[1];
1445 t = (d - origin[1]) / dir[1];
1446 pt[0] = origin[0] + (t + step) * dir[0];
1447 pt[1] = origin[1] + (t + step) * dir[1];
1448 pt[2] = origin[2] + (t + step) * dir[2];
1449 if (_mesh.getMin()[0] < pt[0] && pt[0] < _mesh.getMax()[0]
1450 && _mesh.getMin()[2] < pt[2] && pt[2] < _mesh.getMax()[2]) {
1451 foundQ = true;
1452 }
1453 }
1454 else if (dir[1] < 0 && !foundQ) {
1455 d = _mesh.getMax()[1];
1456 t = (d - origin[1]) / dir[1];
1457 pt[0] = origin[0] + (t + step) * dir[0];
1458 pt[1] = origin[1] + (t + step) * dir[1];
1459 pt[2] = origin[2] + (t + step) * dir[2];
1460 if (_mesh.getMin()[0] < pt[0] && pt[0] < _mesh.getMax()[0]
1461 && _mesh.getMin()[2] < pt[2] && pt[2] < _mesh.getMax()[2]) {
1462 foundQ = true;
1463 }
1464 }
1465
1466 if (dir[2] > 0 && !foundQ) {
1467 d = _mesh.getMin()[2];
1468 t = (d - origin[2]) / dir[2];
1469 pt[0] = origin[0] + (t + step) * dir[0];
1470 pt[1] = origin[1] + (t + step) * dir[1];
1471 pt[2] = origin[2] + (t + step) * dir[2];
1472 if (_mesh.getMin()[0] < pt[0] && pt[0] < _mesh.getMax()[0]
1473 && _mesh.getMin()[1] < pt[1] && pt[1] < _mesh.getMax()[1]) {
1474 foundQ = true;
1475 }
1476 }
1477 else if (dir[2] < 0 && !foundQ) {
1478 d = _mesh.getMax()[2];
1479 t = (d - origin[2]) / dir[2];
1480 pt[0] = origin[0] + (t + step) * dir[0];
1481 pt[1] = origin[1] + (t + step) * dir[1];
1482 pt[2] = origin[2] + (t + step) * dir[2];
1483 if (_mesh.getMin()[0] < pt[0] && pt[0] < _mesh.getMax()[0]
1484 && _mesh.getMin()[1] < pt[1] && pt[1] < _mesh.getMax()[1]) {
1485 foundQ = true;
1486 }
1487 }
1488
1489 if (!foundQ) {
1490 return false;
1491 }
1492 }
1493
1494 while ((util::fabs(pt[0] - center[0]) < extends[0])
1495 && (util::fabs(pt[1] - center[1]) < extends[1])
1496 && (util::fabs(pt[2] - center[2]) < extends[2])) {
1497 node = _tree->find(pt);
1498 if (node->closestIntersection(Vector<T,3>(origin), dir, q, a)) {
1499 Vector<T,3> vek(q - Vector<T,3>(origin));
1500 distance = norm(vek);
1501 return true;
1502 }
1503 else {
1504 Octree<T>* tmpNode = _tree->find(pt);
1505 if (tmpNode) {
1506 tmpNode->intersectRayNode(pt, dir, s);
1507 for (int i = 0; i < 3; i++) {
1508 pt[i] = s[i] + step * dir[i];
1509 }
1510 }
1511 }
1512 }
1513
1514 return false;
1515}
bool distance(T &distance, const Vector< T, 3 > &origin, const Vector< T, 3 > &direction, int iC=-1) override
Computes distance to closest triangle intersection.
platform_constant Fraction s[Q]
Definition mrt.h:65
platform_constant Fraction t[Q]
Definition rtlbm.h:45
constexpr int q() any_platform
Definition functions.h:140
constexpr int d() any_platform
Definition functions.h:127
Expr fabs(Expr x)
Definition expr.cpp:230
constexpr T norm(const ScalarVector< T, D, IMPL > &a) any_platform
Euclidean vector norm.
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:284

References olb::Octree< T >::closestIntersection(), olb::util::fabs(), olb::Octree< T >::find(), olb::Octree< T >::intersectRayNode(), olb::norm(), and olb::normalize().

+ Here is the call graph for this function:

◆ distance() [2/2]

template<typename T >
bool olb::STLreader< T >::distance ( T & distance,
const Vector< T, 3 > & origin,
const Vector< T, 3 > & direction,
int iC = -1 )
override

Computes distance to closest triangle intersection.

◆ distanceToClosestSurfacePoint()

template<typename T >
T olb::STLreader< T >::distanceToClosestSurfacePoint ( Vector< T, 3 > physR)
inline

Definition at line 356 of file stlReader.h.

356 {
357 T closest = std::numeric_limits<T>::max();
358 if (auto tree = _tree->find(physR)) {
359 auto& triangles = tree->getTriangles();
360 for (unsigned int iTriangle : triangles) {
361 auto& triangle = _mesh.getTri(iTriangle);
362 auto closeR = triangle.closestPointTo(physR);
363 auto dist = norm(closeR - physR);
364 if (dist < closest) {
365 closest = dist;
366 }
367 }
368 }
369 return closest;
370 }
T triangle(Vector< T, 2 > p, Vector< T, 2 > a, Vector< T, 2 > b, Vector< T, 2 > c) any_platform
Exact signed distance to the surface of two-dimensional triangle.
Definition sdf.h:152

References olb::norm().

+ Here is the call graph for this function:

◆ getMesh() [1/2]

template<typename T >
STLmesh< T > & olb::STLreader< T >::getMesh ( )
inline

Returns mesh.

Definition at line 439 of file stlReader.h.

440 {
441 return _mesh;
442 };
+ Here is the caller graph for this function:

◆ getMesh() [2/2]

template<typename T >
STLmesh< T > & olb::STLreader< T >::getMesh ( )
inline

Returns mesh.

Definition at line 421 of file STLreaderForSubgridParticleWallContact.h.

422 {
423 return _mesh;
424 };

◆ getTree() [1/2]

template<typename T >
Octree< T > * olb::STLreader< T >::getTree ( ) const
inline

Returns tree.

Definition at line 432 of file stlReader.h.

433 {
434 return _tree;
435 };

◆ getTree() [2/2]

template<typename T >
Octree< T > * olb::STLreader< T >::getTree ( ) const
inline

Returns tree.

Definition at line 414 of file STLreaderForSubgridParticleWallContact.h.

415 {
416 return _tree;
417 };

◆ isInsideRootTree() [1/2]

template<typename T >
bool olb::STLreader< T >::isInsideRootTree ( const T input[])

Returns whether node is inside the top-level octree or not.

Definition at line 1373 of file stlReader.hh.

1374{
1375 T coords = _tree->getRadius();
1376 Vector<T,3> c(_tree->getCenter());
1377 return c[0] - coords < input[0] && input[0] < c[0] + coords && c[1] - coords < input[1]
1378 && input[1] < c[1] + coords && c[2] - coords < input[2] && input[2] < c[2] + coords;
1379}

◆ isInsideRootTree() [2/2]

template<typename T >
bool olb::STLreader< T >::isInsideRootTree ( const T input[])

Returns whether node is inside the top-level octree or not.

◆ normalAtClosestSurfacePoint()

template<typename T >
Vector< T, 3 > olb::STLreader< T >::normalAtClosestSurfacePoint ( Vector< T, 3 > physR)
inline

Definition at line 372 of file stlReader.h.

372 {
373 T closest = std::numeric_limits<T>::max();
374 int iT = -1;
375 if (auto tree = _tree->find(physR)) {
376 auto& triangles = tree->getTriangles();
377 for (unsigned int iTriangle : triangles) {
378 auto& triangle = _mesh.getTri(iTriangle);
379 auto closeR = triangle.closestPointTo(physR);
380 auto dist = norm(closeR - physR);
381 if (dist < closest) {
382 closest = dist;
383 iT = iTriangle;
384 }
385 }
386 }
387 if (iT > 0) {
388 auto& triangle = _mesh.getTri(iT);
389 return triangle.getNormal();
390 } else {
391 return 0;
392 }
393 }

References olb::norm().

+ Here is the call graph for this function:

◆ operator()() [1/2]

template<typename T >
bool olb::STLreader< T >::operator() ( bool output[],
const T input[] )
override

Returns whether node is inside or not.

Definition at line 1361 of file stlReader.hh.

1362{
1363 output[0] = false;
1364 if (isInsideRootTree(input)) {
1365 std::vector<T> tmp(input, input + 3);
1366 output[0] = _tree->find(tmp)->getInside();
1367 }
1368 return true;
1369}
bool isInsideRootTree(const T input[])
Returns whether node is inside the top-level octree or not.

◆ operator()() [2/2]

template<typename T >
bool olb::STLreader< T >::operator() ( bool output[],
const T input[] )
override

Returns whether node is inside or not.

◆ print() [1/2]

template<typename T >
void olb::STLreader< T >::print ( )

Prints console output.

Definition at line 1821 of file stlReader.hh.

1822{
1823 _mesh.print();
1824 _tree->print();
1825 clout << "voxelSize=" << _voxelSize << "; stlSize=" << _stlSize << std::endl;
1826 clout << "minPhysR(VoxelMesh)=(" << this->_myMin[0] << "," << this->_myMin[1]
1827 << "," << this->_myMin[2] << ")";
1828 clout << "; maxPhysR(VoxelMesh)=(" << this->_myMax[0] << ","
1829 << this->_myMax[1] << "," << this->_myMax[2] << ")" << std::endl;
1830}
+ Here is the caller graph for this function:

◆ print() [2/2]

template<typename T >
void olb::STLreader< T >::print ( )

Prints console output.

◆ setBoundaryInsideNodes() [1/2]

template<typename T >
void olb::STLreader< T >::setBoundaryInsideNodes ( )

Every octree leaf intersected by the STL will be part of the inside nodes.

Artificially enlarges all details that would otherwise be cut off by the voxelSize.

Definition at line 1872 of file stlReader.hh.

1873{
1874 std::vector<Octree<T>*> leafs;
1875 _tree->getLeafs(leafs);
1876 for (auto it = leafs.begin(); it != leafs.end(); ++it) {
1877 if ((*it)->getBoundaryNode()) {
1878 (*it)->setInside(true);
1879 }
1880 }
1881}

◆ setBoundaryInsideNodes() [2/2]

template<typename T >
void olb::STLreader< T >::setBoundaryInsideNodes ( )

Every octree leaf intersected by the STL will be part of the inside nodes.

Artificially enlarges all details that would otherwise be cut off by the voxelSize.

◆ setNormalsOutside() [1/2]

template<typename T >
void olb::STLreader< T >::setNormalsOutside ( )

Rearranges normals of triangles to point outside of geometry.

Definition at line 1850 of file stlReader.hh.

1851{
1852 unsigned int noTris = _mesh.triangleSize();
1853 Vector<T,3> center;
1854 //Octree<T>* node = nullptr;
1855 for (unsigned int i = 0; i < noTris; i++) {
1856 center = _mesh.getTri(i).getCenter();
1857 if (_tree->find(
1858 center + _mesh.getTri(i).normal * util::sqrt(3.) * _voxelSize)->getInside()) {
1859 // cout << "Wrong direction" << std::endl;
1860 Vector<T,3> pt(_mesh.getTri(i).point[0]);
1861 _mesh.getTri(i).point[0] = _mesh.getTri(i).point[2];
1862 _mesh.getTri(i).point[2] = pt;
1863 _mesh.getTri(i).init();
1864 // _mesh.getTri(i).getNormal()[0] *= -1.;
1865 // _mesh.getTri(i).getNormal()[1] *= -1.;
1866 // _mesh.getTri(i).getNormal()[2] *= -1.;
1867 }
1868 }
1869}
Expr sqrt(Expr x)
Definition expr.cpp:225

References olb::util::sqrt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setNormalsOutside() [2/2]

template<typename T >
void olb::STLreader< T >::setNormalsOutside ( )

Rearranges normals of triangles to point outside of geometry.

◆ signedDistance() [1/4]

template<typename T >
template<SignMode SIGNMODE>
T olb::STLreader< T >::signedDistance ( const Vector< T, 3 > & input)

Computes signed distance to closest triangle in direction of the surface normal.

Definition at line 1758 of file stlReader.hh.

1759{
1760 T distanceNorm = std::numeric_limits<T>::max();
1761 //Vector<T,3> distVec (std::numeric_limits<T>::max(),std::numeric_limits<T>::max(),std::numeric_limits<T>::max());
1762 T extraDistance{};
1763 //STLtriangle<T> stlT;
1764
1765 const auto evalDistance = [&](const Vector<T,3>& pt) {
1766 iterateOverCloseTriangles(pt, [&](const STLtriangle<T>& triangle) {
1767 const PhysR<T, 3> currPointOnTriangle =
1768 triangle.closestPtPointTriangle(pt);
1769 const Vector<T, 3> currDistance = pt - currPointOnTriangle;
1770 T currDistanceNorm = norm_squared(currDistance);
1771 distanceNorm = util::min(distanceNorm, currDistanceNorm);
1772 /* if(distanceNorm -currDistanceNorm < std::numeric_limits<T>::min())
1773 {distVec = currDistanceNorm;
1774 stlT = triangle;}*/
1775 });
1776 return util::sqrt(distanceNorm);
1777 };
1778
1779 if(!isInsideRootTree(input.data())) {
1780 const PhysR<T,3> ptInsideTree = closestPointInBoundingBox(input);
1781 const T distance = evalDistance(ptInsideTree);
1782 extraDistance = norm(ptInsideTree - input);
1783 return distance + extraDistance;
1784 }
1785 const T distance = evalDistance(input);
1786
1787 return evalSignForSignedDistance<SIGNMODE>(input, distance) * distance;
1788}
Vector< T, 3 > closestPointInBoundingBox(const Vector< T, 3 > &input)
Returns the closest point in the bounding box If input is already inside, then it returns input.
constexpr T norm_squared(const ScalarVector< T, D, IMPL > &a) any_platform
Squared euclidean vector norm.
Vector< T, D > PhysR
Type for spatial (physical) coordinates.

References olb::Vector< T, Size >::data(), olb::util::min(), olb::norm(), olb::norm_squared(), and olb::util::sqrt().

+ Here is the call graph for this function:

◆ signedDistance() [2/4]

template<typename T >
template<SignMode SIGNMODE>
T olb::STLreader< T >::signedDistance ( const Vector< T, 3 > & input)

Computes signed distance to closest triangle in direction of the surface normal.

◆ signedDistance() [3/4]

template<typename T >
T olb::STLreader< T >::signedDistance ( const Vector< T, 3 > & input)
override

Computes signed distance to closest triangle in direction of the surface normal Using the cached information (faster, but less accurate)

Definition at line 1742 of file stlReader.hh.

1743{
1745}
T signedDistance(const Vector< T, 3 > &input) override
Computes signed distance to closest triangle in direction of the surface normal Using the cached info...

◆ signedDistance() [4/4]

template<typename T >
T olb::STLreader< T >::signedDistance ( const Vector< T, 3 > & input)
override

Computes signed distance to closest triangle in direction of the surface normal Using the cached information (faster, but less accurate)

◆ signedDistanceExact() [1/2]

template<typename T >
T olb::STLreader< T >::signedDistanceExact ( const Vector< T, 3 > & input)
override

Computes exact signed distance to closest triangle in direction of the surface normal Much slower, but more accurate.

Definition at line 1748 of file stlReader.hh.

1749{
1750 return signedDistance<SignMode::EXACT>(input);
1751}

◆ signedDistanceExact() [2/2]

template<typename T >
T olb::STLreader< T >::signedDistanceExact ( const Vector< T, 3 > & input)
override

Computes exact signed distance to closest triangle in direction of the surface normal Much slower, but more accurate.

◆ surfaceNormal() [1/4]

template<typename T >
template<SignMode SIGNMODE>
Vector< T, 3 > olb::STLreader< T >::surfaceNormal ( const Vector< T, 3 > & pos,
const T meshSize = 0 )

Finds and returns normal of the closest surface (triangle)

Definition at line 1815 of file stlReader.hh.

1816{
1817 return evalSurfaceNormal<SIGNMODE>(pos);
1818}

◆ surfaceNormal() [2/4]

template<typename T >
template<SignMode SIGNMODE>
Vector< T, 3 > olb::STLreader< T >::surfaceNormal ( const Vector< T, 3 > & pos,
const T meshSize = 0 )

Finds and returns normal of the closest surface (triangle)

◆ surfaceNormal() [3/4]

template<typename T >
Vector< T, 3 > olb::STLreader< T >::surfaceNormal ( const Vector< T, 3 > & pos,
const T meshSize = 0 )
override

Finds and returns normal of the closest surface (triangle) Using the cached information (faster, but less accurate)

Definition at line 1802 of file stlReader.hh.

1803{
1804 return surfaceNormal<SignMode::CACHED>(pos, meshSize);
1805}
Vector< T, 3 > surfaceNormal(const Vector< T, 3 > &pos, const T meshSize=0) override
Finds and returns normal of the closest surface (triangle) Using the cached information (faster,...

◆ surfaceNormal() [4/4]

template<typename T >
Vector< T, 3 > olb::STLreader< T >::surfaceNormal ( const Vector< T, 3 > & pos,
const T meshSize = 0 )
override

Finds and returns normal of the closest surface (triangle) Using the cached information (faster, but less accurate)

◆ surfaceNormalExact() [1/2]

template<typename T >
Vector< T, 3 > olb::STLreader< T >::surfaceNormalExact ( const Vector< T, 3 > & pos,
const T meshSize = 0 )
override

Finds and returns normal of the closest surface (triangle) Much slower, but more accurate.

Definition at line 1808 of file stlReader.hh.

1809{
1810 return surfaceNormal<SignMode::EXACT>(pos, meshSize);
1811}

◆ surfaceNormalExact() [2/2]

template<typename T >
Vector< T, 3 > olb::STLreader< T >::surfaceNormalExact ( const Vector< T, 3 > & pos,
const T meshSize = 0 )
override

Finds and returns normal of the closest surface (triangle) Much slower, but more accurate.

◆ writeOctree() [1/2]

template<typename T >
void olb::STLreader< T >::writeOctree ( )

Writes Octree.

Definition at line 1833 of file stlReader.hh.

1834{
1835 _tree->write(_fName);
1836}

◆ writeOctree() [2/2]

template<typename T >
void olb::STLreader< T >::writeOctree ( )

Writes Octree.

◆ writeSTL() [1/2]

template<typename T >
void olb::STLreader< T >::writeSTL ( std::string stlName = "")

Writes STL mesh in Si units.

Definition at line 1839 of file stlReader.hh.

1840{
1841 if (stlName == "") {
1842 _mesh.write(_fName);
1843 }
1844 else {
1845 _mesh.write(stlName);
1846 }
1847}

◆ writeSTL() [2/2]

template<typename T >
void olb::STLreader< T >::writeSTL ( std::string stlName = "")

Writes STL mesh in Si units.


The documentation for this class was generated from the following files: