NLMech  0.1.0
interiorFlags.h
1 // Copyright (c) 2019 Prashant K. Jha
3 // Copyright (c) 2019 Patrick Diehl
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 
9 #ifndef GEOM_INTERIORFLAGS_H
10 #define GEOM_INTERIORFLAGS_H
11 
12 #include "util/point.h" // definition of Point3
13 #include <string>
14 #include <vector>
15 
16 // forward declaration of interior flags deck
17 namespace inp {
18 struct InteriorFlagsDeck;
19 }
20 
21 namespace geometry {
22 
27 class BaseInterior {
28 public:
29 
38  std::pair<std::vector<double>, std::vector<double>> bbox,
39  std::vector<std::pair<std::string, std::vector<double>>> no_fail_regions);
40 
50  virtual bool getInteriorFlag(const size_t &i, const util::Point3 &x);
51 
61  std::string printStr(int nt = 0, int lvl = 0) const;
62 
70  void print(int nt = 0, int lvl = 0) const { std::cout << printStr(nt, lvl); };
71 
72 protected:
77  std::vector<uint8_t> d_intFlags;
78 
80  std::pair<std::vector<double>, std::vector<double>> d_bbox;
81 
83  std::vector<std::pair<std::string, std::vector<double>>> d_noFailRegions;
84 
86  double d_noFailTol;
87 };
88 
95 class ComputeInterior : public BaseInterior {
96 public:
104  std::pair<std::vector<double>, std::vector<double>> bbox,
105  std::vector<std::pair<std::string, std::vector<double>>> no_fail_regions);
106 
116  bool getInteriorFlag(const size_t &i, const util::Point3 &x) override;
117 
127  std::string printStr(int nt = 0, int lvl = 0) const;
128 
136  void print(int nt = 0, int lvl = 0) const { std::cout << printStr(nt, lvl); };
137 };
138 
145 class DataInterior : public BaseInterior {
146 public:
156  const std::vector<util::Point3> *nodes,
157  std::pair<std::vector<double>, std::vector<double>> bbox,
158  std::vector<std::pair<std::string, std::vector<double>>> no_fail_regions);
159 
169  bool getInteriorFlag(const size_t &i, const util::Point3 &x) override;
170 
180  std::string printStr(int nt = 0, int lvl = 0) const;
181 
189  void print(int nt = 0, int lvl = 0) const { std::cout << printStr(nt, lvl); };
190 };
191 
199 
200 public:
209  inp::InteriorFlagsDeck *deck, const std::vector<util::Point3> *nodes,
210  const std::pair<std::vector<double>, std::vector<double>> &bbox);
211 
218  bool getInteriorFlag(const size_t &i, const util::Point3 &x);
219 
229  std::string printStr(int nt = 0, int lvl = 0) const;
230 
238  void print(int nt = 0, int lvl = 0) const { std::cout << printStr(nt, lvl); };
239 
240 private:
243 };
244 
245 } // namespace geometry
246 
247 #endif // GEOM_INTERIORFLAGS_H
An abstraction class to store interior/exterior flags of node.
Definition: interiorFlags.h:27
virtual bool getInteriorFlag(const size_t &i, const util::Point3 &x)
Get interior flag of node.
Definition: interiorFlags.cpp:27
double d_noFailTol
Tolerance to check if the point is in interior/exterior.
Definition: interiorFlags.h:86
BaseInterior(inp::InteriorFlagsDeck *deck, std::pair< std::vector< double >, std::vector< double >> bbox, std::vector< std::pair< std::string, std::vector< double >>> no_fail_regions)
Constructor.
Definition: interiorFlags.cpp:19
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing information about the instance of the object.
Definition: interiorFlags.cpp:32
std::vector< std::pair< std::string, std::vector< double > > > d_noFailRegions
Specify multiple regions in which we set no-fail flag to true.
Definition: interiorFlags.h:83
std::pair< std::vector< double >, std::vector< double > > d_bbox
Bounding box.
Definition: interiorFlags.h:80
void print(int nt=0, int lvl=0) const
Prints the information about the instance of the object.
Definition: interiorFlags.h:70
std::vector< uint8_t > d_intFlags
Interior flags. For given node i the flag is d_intFlags[i%8]. We use 1 bit per node.
Definition: interiorFlags.h:70
A class to check if the node is in interior or exterior.
Definition: interiorFlags.h:95
bool getInteriorFlag(const size_t &i, const util::Point3 &x) override
Returns true if node is in interior, false otherwise.
Definition: interiorFlags.cpp:57
void print(int nt=0, int lvl=0) const
Prints the information about the instance of the object.
Definition: interiorFlags.h:136
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing information about the instance of the object.
Definition: interiorFlags.cpp:102
ComputeInterior(inp::InteriorFlagsDeck *deck, std::pair< std::vector< double >, std::vector< double >> bbox, std::vector< std::pair< std::string, std::vector< double >>> no_fail_regions)
Constructor.
Definition: interiorFlags.cpp:51
A class to check if the node is in interior or exterior.
Definition: interiorFlags.h:145
bool getInteriorFlag(const size_t &i, const util::Point3 &x) override
Returns true if node is in interior, false otherwise.
Definition: interiorFlags.cpp:187
void print(int nt=0, int lvl=0) const
Prints the information about the instance of the object.
Definition: interiorFlags.h:189
DataInterior(inp::InteriorFlagsDeck *deck, const std::vector< util::Point3 > *nodes, std::pair< std::vector< double >, std::vector< double >> bbox, std::vector< std::pair< std::string, std::vector< double >>> no_fail_regions)
Constructor.
Definition: interiorFlags.cpp:121
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing information about the instance of the object.
Definition: interiorFlags.cpp:193
A class to store interior/exterior flags of node.
Definition: interiorFlags.h:198
BaseInterior * d_interior_p
Class providing interior flags and method.
Definition: interiorFlags.h:238
InteriorFlags(inp::InteriorFlagsDeck *deck, const std::vector< util::Point3 > *nodes, const std::pair< std::vector< double >, std::vector< double >> &bbox)
Constructor.
Definition: interiorFlags.cpp:213
void print(int nt=0, int lvl=0) const
Prints the information about the instance of the object.
Definition: interiorFlags.h:238
bool getInteriorFlag(const size_t &i, const util::Point3 &x)
Returns true for all the nodes.
Definition: interiorFlags.cpp:228
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing information about the instance of the object.
Definition: interiorFlags.cpp:233
Collection of methods and data related to geometry.
Definition: DataManager.h:23
Collection of methods and database related to input.
Definition: main.cpp:21
Structure to read and store input data for interior flags (no-fail region)
Definition: interiorFlagsDeck.h:25
A structure to represent 3d vectors.
Definition: point.h:29