isoSurfaceParams.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2020-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::isoSurfaceParams
28 
29 Description
30  Preferences for controlling iso-surface algorithms.
31 
32  Some common dictionary properties:
33  \table
34  Property | Description | Required | Default
35  isoMethod | Algorithm (cell/topo/point/default) | no | default
36  regularise | Face simplification (enum or bool) | no | true
37  mergeTol | Point merge tolerance (cell/point) | no | 1e-6
38  snap | Point snapping (topo) | no | true
39  bounds | Optional clip bounds | no | inverted
40  \endtable
41 
42  The default algorithm denotes the use of the current \em standard
43  algorithm.
44 
45 Filtering types (for topological iso-surface)
46  - \c none : leave tet cuts untouched
47  - \c partial , \c cell : Combine intra-cell faces
48  - \c full , \c diagcell : Perform \c partial and remove face-diagonal
49  points
50  - \c clean : Perform \c full and eliminate open edges as well.
51  (<b>May cause excessive erosion!</b>)
52  .
53 
54 SourceFiles
55  isoSurfaceParams.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef isoSurfaceParams_H
60 #define isoSurfaceParams_H
61 
62 #include "boundBox.H"
63 #include "Enum.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 // Forward Declarations
71 class dictionary;
72 class Ostream;
73 
74 /*---------------------------------------------------------------------------*\
75  Class isoSurfaceSelector Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 class isoSurfaceParams
79 {
80 public:
81 
82  // Data Types
83 
84  //- The algorithm types
85  enum algorithmType : uint8_t
86  {
87  ALGO_DEFAULT = 0,
88  ALGO_TOPO,
89  ALGO_CELL,
91  };
92 
93  //- The filtering (regularization) to apply
94  enum class filterType : uint8_t
95  {
96  NONE = 0,
97  CELL,
98  DIAGCELL,
99  NONMANIFOLD,
100 
102  PARTIAL = CELL,
103  FULL = DIAGCELL,
104  CLEAN = NONMANIFOLD
105  };
106 
107 
108 private:
109 
110  // Private Data
111 
112  //- Algorithm type
113  algorithmType algo_;
114 
115  //- Filtering for iso-surface faces/points
116  filterType filter_;
117 
118  //- Point snapping enabled
119  bool snap_;
120 
121  //- Merge tolerance for cell/point (default: 1e-6)
122  scalar mergeTol_;
123 
124  //- Optional bounding box for clipping (default: inverted)
125  boundBox clipBounds_;
126 
127 
128 public:
129 
130  // Public Data
131 
132  //- Names for the iso-surface algorithms
133  static const Enum<algorithmType> algorithmNames;
134 
135  //- Names for the filtering types
136  static const Enum<filterType> filterNames;
137 
138 
139  // Static Member Functions
140 
141  //- Get 'isoMethod' or 'isoAlgorithm' as enumeration
143  (
144  const dictionary& dict,
145  const algorithmType deflt
146  );
147 
148  //- Get 'regularise' as bool or enumeration
150  (
151  const dictionary& dict,
152  const filterType deflt
153  );
154 
155 
156  // Constructors
157 
158  //- Default construct, or with specified algorithm
159  explicit isoSurfaceParams
160  (
161  const algorithmType algo = algorithmType::ALGO_DEFAULT,
163  ) noexcept;
164 
165  //- Default construct, setting parameters from dictionary
166  explicit isoSurfaceParams
167  (
168  const dictionary& dict,
169  const isoSurfaceParams& params = isoSurfaceParams()
170  );
171 
172  //- Default construct, setting parameters from dictionary
173  explicit isoSurfaceParams
174  (
175  const dictionary& dict,
176  const algorithmType algo,
178  );
179 
180 
181  // Member Functions
182 
183  //- Get current algorithm
184  algorithmType algorithm() const noexcept
185  {
186  return algo_;
187  }
188 
189  //- Set algorithm
190  void algorithm(algorithmType algo) noexcept
191  {
192  algo_ = algo;
193  }
194 
195  //- Get current filter type
196  filterType filter() const noexcept
197  {
198  return filter_;
199  }
200 
201  //- Set filter type
202  void filter(filterType fltr) noexcept
203  {
204  filter_ = fltr;
205  }
206 
207  //- Get point snapping flag
208  bool snap() const noexcept
209  {
210  return snap_;
211  }
212 
213  //- Set point snapping flag
214  void snap(bool on) noexcept
215  {
216  snap_ = on;
217  }
218 
219  //- Get current merge tolerance
220  scalar mergeTol() const noexcept
221  {
222  return mergeTol_;
223  }
224 
225  //- Set merge tolerance (cell/point algo)
226  void mergeTol(const scalar relTol) noexcept
227  {
228  mergeTol_ = relTol;
229  }
230 
231  //- Get optional clipping bounding box
232  const boundBox& getClipBounds() const noexcept
233  {
234  return clipBounds_;
235  }
236 
237  //- Access optional clipping bounding box
238  boundBox& getClipBounds() noexcept
239  {
240  return clipBounds_;
241  }
242 
243  //- Set optional clipping bounding box
244  void setClipBounds(const boundBox& bb);
245 
246 
247  // Information
248 
249  //- Print information about the settings
250  void print(Ostream& os) const;
251 };
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #endif
261 
262 // ************************************************************************* //
Foam::isoSurfaceParams::mergeTol
void mergeTol(const scalar relTol) noexcept
Set merge tolerance (cell/point algo)
Definition: isoSurfaceParams.H:255
Foam::isoSurfaceParams::filterType::DIAGCELL
Remove pyramid edge points, face-diagonals.
Foam::isoSurfaceParams::filterType::CLEAN
Same as NONMANIFOLD.
Foam::Enum< algorithmType >
Foam::isoSurfaceParams::getFilterType
static filterType getFilterType(const dictionary &dict, const filterType deflt)
Get 'regularise' as bool or enumeration.
Definition: isoSurfaceParams.C:100
Foam::isoSurfaceParams::snap
void snap(bool on) noexcept
Set point snapping flag.
Definition: isoSurfaceParams.H:243
Foam::isoSurfaceParams::algorithm
algorithmType algorithm() const noexcept
Get current algorithm.
Definition: isoSurfaceParams.H:213
Foam::isoSurfaceParams::algorithmType
algorithmType
The algorithm types.
Definition: isoSurfaceParams.H:114
Foam::isoSurfaceParams::getClipBounds
boundBox & getClipBounds() noexcept
Access optional clipping bounding box.
Definition: isoSurfaceParams.H:267
Foam::isoSurfaceParams::filterType::FULL
Same as DIAGCELL.
Foam::isoSurfaceParams::filter
void filter(filterType fltr) noexcept
Set filter type.
Definition: isoSurfaceParams.H:231
Foam::isoSurfaceParams::algorithmNames
static const Enum< algorithmType > algorithmNames
Names for the iso-surface algorithms.
Definition: isoSurfaceParams.H:162
Foam::isoSurfaceParams::filterType::NONE
No filtering.
Foam::isoSurfaceParams::filter
filterType filter() const noexcept
Get current filter type.
Definition: isoSurfaceParams.H:225
Foam::isoSurfaceParams::filterType::PARTIAL
Same as CELL.
Foam::isoSurfaceParams::isoSurfaceParams
isoSurfaceParams(const algorithmType algo=algorithmType::ALGO_DEFAULT, const filterType filter=filterType::DIAGCELL) noexcept
Default construct, or with specified algorithm.
Definition: isoSurfaceParams.C:135
Foam::isoSurfaceParams::getClipBounds
const boundBox & getClipBounds() const noexcept
Get optional clipping bounding box.
Definition: isoSurfaceParams.H:261
Foam::isoSurfaceParams::ALGO_DEFAULT
Use current 'standard' algorithm.
Definition: isoSurfaceParams.H:116
Foam::isoSurfaceParams::print
void print(Ostream &os) const
Print information about the settings.
Definition: isoSurfaceParams.C:183
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::isoSurfaceParams::algorithm
void algorithm(algorithmType algo) noexcept
Set algorithm.
Definition: isoSurfaceParams.H:219
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::isoSurfaceParams
Preferences for controlling iso-surface algorithms.
Definition: isoSurfaceParams.H:107
os
OBJstream os(runTime.globalPath()/outputName)
Foam::isoSurfaceParams::ALGO_POINT
Definition: isoSurfaceParams.H:119
Foam::isoSurfaceParams::setClipBounds
void setClipBounds(const boundBox &bb)
Set optional clipping bounding box.
Definition: isoSurfaceParams.C:177
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::isoSurfaceParams::getAlgorithmType
static algorithmType getAlgorithmType(const dictionary &dict, const algorithmType deflt)
Get 'isoMethod' or 'isoAlgorithm' as enumeration.
Definition: isoSurfaceParams.C:68
Foam::isoSurfaceParams::ALGO_TOPO
Definition: isoSurfaceParams.H:117
boundBox.H
Foam::isoSurfaceParams::ALGO_CELL
Definition: isoSurfaceParams.H:118
Foam::isoSurfaceParams::filterType::NONMANIFOLD
Foam::isoSurfaceParams::snap
bool snap() const noexcept
Get point snapping flag.
Definition: isoSurfaceParams.H:237
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::isoSurfaceParams::filterNames
static const Enum< filterType > filterNames
Names for the filtering types.
Definition: isoSurfaceParams.H:165
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::isoSurfaceParams::mergeTol
scalar mergeTol() const noexcept
Get current merge tolerance.
Definition: isoSurfaceParams.H:249
Foam::isoSurfaceParams::filterType::CELL
Remove pyramid edge points.
Foam::isoSurfaceParams::filterType
filterType
The filtering (regularization) to apply.
Definition: isoSurfaceParams.H:123
Enum.H