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 Foam_isoSurfaceParams_H
60 #define Foam_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 
73 /*---------------------------------------------------------------------------*\
74  Class isoSurfaceSelector Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class isoSurfaceParams
78 {
79 public:
80 
81  // Data Types
82 
83  //- The algorithm types
84  enum algorithmType : uint8_t
85  {
86  ALGO_DEFAULT = 0,
87  ALGO_TOPO,
88  ALGO_CELL,
90  };
91 
92  //- The filtering (regularization) to apply
93  enum class filterType : uint8_t
94  {
95  NONE = 0,
96  CELL,
97  DIAGCELL,
98  NONMANIFOLD,
99 
101  PARTIAL = CELL,
103  CLEAN = NONMANIFOLD
104  };
105 
106 
107 private:
108 
109  // Private Data
110 
111  //- Algorithm type
112  algorithmType algo_;
114  //- Filtering for iso-surface faces/points
115  filterType filter_;
117  //- Point snapping enabled
118  bool snap_;
119 
120  //- Merge tolerance for cell/point (default: 1e-6)
121  scalar mergeTol_;
123  //- Optional bounding box for clipping (default: inverted)
124  boundBox clipBounds_;
125 
126 
127 public:
128 
129  // Public Data
130 
131  //- Names for the iso-surface algorithms
132  static const Enum<algorithmType> algorithmNames;
133 
134  //- Names for the filtering types
135  static const Enum<filterType> filterNames;
136 
137 
138  // Static Member Functions
139 
140  //- Get 'isoMethod' or 'isoAlgorithm' as enumeration
142  (
143  const dictionary& dict,
144  const algorithmType deflt
145  );
146 
147  //- Get 'regularise' as bool or enumeration
149  (
150  const dictionary& dict,
151  const filterType deflt
152  );
153 
154 
155  // Constructors
156 
157  //- Default construct, or with specified algorithm
158  explicit isoSurfaceParams
159  (
160  const algorithmType algo = algorithmType::ALGO_DEFAULT,
162  ) noexcept;
163 
164  //- Default construct, setting parameters from dictionary
165  explicit isoSurfaceParams
166  (
167  const dictionary& dict,
168  const isoSurfaceParams& params = isoSurfaceParams()
169  );
170 
171  //- Default construct, setting parameters from dictionary
172  explicit isoSurfaceParams
173  (
174  const dictionary& dict,
175  const algorithmType algo,
177  );
179 
180  // Member Functions
181 
182  //- Get current algorithm
184  {
185  return algo_;
186  }
187 
188  //- Set algorithm
189  void algorithm(algorithmType algo) noexcept
190  {
191  algo_ = algo;
192  }
193 
194  //- Get current filter type
195  filterType filter() const noexcept
196  {
197  return filter_;
198  }
199 
200  //- Set filter type
201  void filter(filterType fltr) noexcept
202  {
203  filter_ = fltr;
204  }
205 
206  //- Get point snapping flag
207  bool snap() const noexcept
208  {
209  return snap_;
210  }
211 
212  //- Set point snapping flag
213  void snap(bool on) noexcept
214  {
215  snap_ = on;
216  }
217 
218  //- Get current merge tolerance
219  scalar mergeTol() const noexcept
220  {
221  return mergeTol_;
222  }
223 
224  //- Set merge tolerance (cell/point algo)
225  void mergeTol(const scalar relTol) noexcept
226  {
227  mergeTol_ = relTol;
228  }
229 
230  //- Get optional clipping bounding box
231  const boundBox& getClipBounds() const noexcept
232  {
233  return clipBounds_;
234  }
235 
236  //- Access optional clipping bounding box
237  boundBox& getClipBounds() noexcept
238  {
239  return clipBounds_;
240  }
241 
242  //- Set optional clipping bounding box
243  void setClipBounds(const boundBox& bb);
244 
245 
246  // Information
247 
248  //- Print information about the settings
249  void print(Ostream& os) const;
250 };
251 
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 } // End namespace Foam
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 #endif
260 
261 // ************************************************************************* //
Remove pyramid edge points, face-diagonals.
dictionary dict
Remove pyramid edge points.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Preferences for controlling iso-surface algorithms.
static filterType getFilterType(const dictionary &dict, const filterType deflt)
Get &#39;regularise&#39; as bool or enumeration.
void print(Ostream &os) const
Print information about the settings.
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
algorithmType
The algorithm types.
void setClipBounds(const boundBox &bb)
Set optional clipping bounding box.
isoSurfaceParams(const algorithmType algo=algorithmType::ALGO_DEFAULT, const filterType filter=filterType::DIAGCELL) noexcept
Default construct, or with specified algorithm.
const boundBox & getClipBounds() const noexcept
Get optional clipping bounding box.
Use current &#39;standard&#39; algorithm.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
algorithmType algorithm() const noexcept
Get current algorithm.
filterType
The filtering (regularization) to apply.
static const Enum< algorithmType > algorithmNames
Names for the iso-surface algorithms.
static const Enum< filterType > filterNames
Names for the filtering types.
static algorithmType getAlgorithmType(const dictionary &dict, const algorithmType deflt)
Get &#39;isoMethod&#39; or &#39;isoAlgorithm&#39; as enumeration.
bool snap() const noexcept
Get point snapping flag.
filterType filter() const noexcept
Get current filter type.
scalar mergeTol() const noexcept
Get current merge tolerance.
Namespace for OpenFOAM.