vtkPV3blockMesh.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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::vtkPV3blockMesh
26 
27 Description
28  Provides a reader interface for OpenFOAM blockMesh to VTK interaction
29 
30 SourceFiles
31  vtkPV3blockMesh.C
32  vtkPV3blockMeshConvert.C
33  vtkPV3blockMeshUpdate.C
34  vtkPV3blockMeshUtils.C
35 
36  // Needed by VTK:
37  vtkDataArrayTemplateImplicit.txx
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef vtkPV3blockMesh_H
42 #define vtkPV3blockMesh_H
43 
44 // do not include legacy strstream headers
45 #ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
46 # define VTK_EXCLUDE_STRSTREAM_HEADERS
47 #endif
48 
49 #include "className.H"
50 #include "fileName.H"
51 #include "stringList.H"
52 #include "wordList.H"
53 
54 #include "primitivePatch.H"
55 
56 // * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
57 
58 class vtkDataArraySelection;
59 class vtkDataSet;
60 class vtkPoints;
61 class vtkPV3blockMeshReader;
62 class vtkRenderer;
63 class vtkTextActor;
64 class vtkMultiBlockDataSet;
65 class vtkPolyData;
66 class vtkUnstructuredGrid;
67 class vtkIndent;
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 
74 // OpenFOAM class forward declarations
75 class argList;
76 class Time;
77 class blockMesh;
78 
79 template<class Type> class List;
80 
81 /*---------------------------------------------------------------------------*\
82  Class vtkPV3blockMesh Declaration
83 \*---------------------------------------------------------------------------*/
84 
85 class vtkPV3blockMesh
86 {
87  // Private classes
88 
89  //- Bookkeeping for GUI checklists and the multi-block organization
90  class arrayRange
91  {
92  const char *name_;
93  int block_;
94  int start_;
95  int size_;
96 
97  public:
98 
99  arrayRange(const char *name, const int blockNo=0)
100  :
101  name_(name),
102  block_(blockNo),
103  start_(0),
104  size_(0)
105  {}
106 
107  //- Return the block holding these datasets
108  int block() const
109  {
110  return block_;
111  }
112 
113  //- Assign block number, return previous value
114  int block(int blockNo)
115  {
116  int prev = block_;
117  block_ = blockNo;
118  return prev;
119  }
120 
121  //- Return block name
122  const char* name() const
123  {
124  return name_;
125  }
126 
127  //- Return array start index
128  int start() const
129  {
130  return start_;
131  }
132 
133  //- Return array end index
134  int end() const
135  {
136  return start_ + size_;
137  }
138 
139  //- Return sublist size
140  int size() const
141  {
142  return size_;
143  }
144 
145  bool empty() const
146  {
147  return !size_;
148  }
149 
150  //- Reset the size to zero and optionally assign a new start
151  void reset(const int startAt = 0)
152  {
153  start_ = startAt;
154  size_ = 0;
155  }
156 
157  //- Increment the size
158  void operator+=(const int n)
159  {
160  size_ += n;
161  }
162  };
163 
164 
165  // Private Data
166 
167  //- Access to the controlling vtkPV3blockMeshReader
168  vtkPV3blockMeshReader* reader_;
169 
170  //- OpenFOAM time control
172 
173  //- OpenFOAM mesh
175 
176  //- The mesh region
178 
179  //- The mesh directory for the region
181 
182  //- Selected geometrical parts
184 
185  //- Selected curved edges
187 
188  //- First instance and size of bleckMesh blocks
189  // used to index into blockStatus_
191 
192  //- First instance and size of CurvedEdges (only partially used)
194 
195  //- First instance and size of block corners (only partially used)
197 
198  //- List of point numbers for rendering to window
200 
201  // Private Member Functions
202 
203  // Convenience method use to convert the readers from VTK 5
204  // multiblock API to the current composite data infrastructure
205  static void AddToBlock
206  (
207  vtkMultiBlockDataSet* output,
208  vtkDataSet* dataset,
209  const arrayRange&,
210  const label datasetNo,
211  const std::string& datasetName
212  );
213 
214  // Convenience method use to convert the readers from VTK 5
215  // multiblock API to the current composite data infrastructure
216  static vtkDataSet* GetDataSetFromBlock
217  (
218  vtkMultiBlockDataSet* output,
219  const arrayRange&,
220  const label datasetNo
221  );
222 
223  // Convenience method use to convert the readers from VTK 5
224  // multiblock API to the current composite data infrastructure
226  (
227  vtkMultiBlockDataSet* output,
228  const arrayRange&
229  );
230 
231  //- Update boolList from GUI selection
232  static void updateBoolListStatus
233  (
234  boolList&,
235  vtkDataArraySelection*
236  );
237 
238  //- Reset data counters
239  void resetCounters();
240 
241  // Update information helper functions
242 
243  //- Internal block info
244  void updateInfoBlocks(vtkDataArraySelection*);
245 
246  //- Block curved edges info
247  void updateInfoEdges(vtkDataArraySelection*);
248 
249  // Update helper functions
250 
251  //- OpenFOAM mesh
252  void updateFoamMesh();
253 
254  // Mesh conversion functions
255 
256  //- Mesh blocks
257  void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo);
258 
259  //- Mesh curved edges
260  void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo);
261 
262  //- Mesh corners
263  void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo);
264 
265 
266  // GUI selection helper functions
267 
268  //- Retrieve the current selections
269  static wordHashSet getSelected(vtkDataArraySelection*);
270 
271  //- Retrieve a sub-list of the current selections
272  static wordHashSet getSelected
273  (
274  vtkDataArraySelection*,
275  const arrayRange&
276  );
277 
278  //- Retrieve the current selections
279  static stringList getSelectedArrayEntries(vtkDataArraySelection*);
280 
281  //- Retrieve a sub-list of the current selections
283  (
284  vtkDataArraySelection*,
285  const arrayRange&
286  );
287 
288  //- Set selection(s)
289  static void setSelectedArrayEntries
290  (
291  vtkDataArraySelection*,
292  const stringList&
293  );
294 
295 
296  //- Disallow default bitwise copy construct
298 
299  //- Disallow default bitwise assignment
300  void operator=(const vtkPV3blockMesh&);
301 
302 
303 public:
304 
305  //- Static data members
306 
307  ClassName("vtkPV3blockMesh");
308 
309 
310  // Constructors
311 
312  //- Construct from components
314  (
315  const char* const FileName,
316  vtkPV3blockMeshReader* reader
317  );
318 
319 
320  //- Destructor
322 
323 
324  // Member Functions
325 
326  //- Update
327  void updateInfo();
328 
329  void Update(vtkMultiBlockDataSet* output);
330 
331  //- Clean any storage
332  void CleanUp();
333 
334  //- Add/remove point numbers to/from the view
335  void renderPointNumbers(vtkRenderer*, const bool show);
336 
337  // Access
338 
339  //- Debug information
340  void PrintSelf(ostream&, vtkIndent) const;
341 
342 };
343 
344 
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346 
347 } // End namespace Foam
348 
349 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350 
351 #endif
352 
353 // ************************************************************************* //
Foam::vtkPV3blockMesh::AddToBlock
static void AddToBlock(vtkMultiBlockDataSet *output, vtkDataSet *dataset, const arrayRange &, const label datasetNo, const std::string &datasetName)
Definition: vtkPV3blockMeshUtils.C:71
Foam::vtkPV3blockMesh::getSelectedArrayEntries
static stringList getSelectedArrayEntries(vtkDataArraySelection *)
Retrieve the current selections.
Definition: vtkPV3blockMeshUtils.C:213
Foam::vtkPV3blockMesh::arrayRange
Bookkeeping for GUI checklists and the multi-block organization.
Definition: vtkPV3blockMesh.H:89
Foam::vtkPV3blockMesh::updateInfo
void updateInfo()
Update.
Foam::vtkPV3blockMesh::meshRegion_
word meshRegion_
The mesh region.
Definition: vtkPV3blockMesh.H:176
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::vtkPV3blockMesh::arrayRange::block_
int block_
Definition: vtkPV3blockMesh.H:92
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::vtkPV3blockMesh::updateBoolListStatus
static void updateBoolListStatus(boolList &, vtkDataArraySelection *)
Update boolList from GUI selection.
Definition: vtkPV3blockMeshUtils.C:317
Foam::vtkPV3blockMesh::operator=
void operator=(const vtkPV3blockMesh &)
Disallow default bitwise assignment.
Foam::vtkPV3blockMesh::resetCounters
void resetCounters()
Reset data counters.
Foam::vtkPV3blockMesh::dbPtr_
autoPtr< Time > dbPtr_
OpenFOAM time control.
Definition: vtkPV3blockMesh.H:170
Foam::vtkPV3blockMesh::GetNumberOfDataSets
static label GetNumberOfDataSets(vtkMultiBlockDataSet *output, const arrayRange &)
Definition: vtkPV3blockMeshUtils.C:153
Foam::vtkPV3blockMesh::meshPtr_
blockMesh * meshPtr_
OpenFOAM mesh.
Definition: vtkPV3blockMesh.H:173
Foam::vtkPV3blockMesh::vtkPV3blockMesh
vtkPV3blockMesh(const vtkPV3blockMesh &)
Disallow default bitwise copy construct.
Foam::vtkPV3blockMesh::updateInfoEdges
void updateInfoEdges(vtkDataArraySelection *)
Block curved edges info.
Foam::vtkPV3blockMesh::CleanUp
void CleanUp()
Clean any storage.
Foam::vtkPV3blockMesh::arrayRange::size_
int size_
Definition: vtkPV3blockMesh.H:94
Foam::vtkPV3blockMesh::updateFoamMesh
void updateFoamMesh()
OpenFOAM mesh.
Foam::vtkPV3blockMesh::updateInfoBlocks
void updateInfoBlocks(vtkDataArraySelection *)
Internal block info.
Foam::vtkPV3blockMesh::getSelected
static wordHashSet getSelected(vtkDataArraySelection *)
Retrieve the current selections.
Definition: vtkPV3blockMeshUtils.C:172
Foam::HashSet
A HashTable with keys but without contents.
Definition: HashSet.H:59
Foam::vtkPV3blockMesh::reader_
vtkPV3blockMeshReader * reader_
Access to the controlling vtkPV3blockMeshReader.
Definition: vtkPV3blockMesh.H:167
Foam::vtkPV3blockMesh::arrayRangeBlocks_
arrayRange arrayRangeBlocks_
First instance and size of bleckMesh blocks.
Definition: vtkPV3blockMesh.H:189
wordList.H
Foam::vtkPV3blockMesh::arrayRange::block
int block(int blockNo)
Assign block number, return previous value.
Definition: vtkPV3blockMesh.H:113
Foam::vtkPV3blockMesh::arrayRange::end
int end() const
Return array end index.
Definition: vtkPV3blockMesh.H:133
Foam::vtkPV3blockMesh::Update
void Update(vtkMultiBlockDataSet *output)
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::vtkPV3blockMesh
Provides a reader interface for OpenFOAM blockMesh to VTK interaction.
Definition: vtkPV3blockMesh.H:84
Foam::vtkPV3blockMesh::arrayRangeCorners_
arrayRange arrayRangeCorners_
First instance and size of block corners (only partially used)
Definition: vtkPV3blockMesh.H:195
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::vtkPV3blockMesh::convertMeshCorners
void convertMeshCorners(vtkMultiBlockDataSet *, int &blockNo)
Mesh corners.
Foam::vtkPV3blockMesh::PrintSelf
void PrintSelf(ostream &, vtkIndent) const
Debug information.
className.H
Macro definitions for declaring ClassName(), NamespaceName(), etc.
fileName.H
Foam::vtkPV3blockMesh::GetDataSetFromBlock
static vtkDataSet * GetDataSetFromBlock(vtkMultiBlockDataSet *output, const arrayRange &, const label datasetNo)
Definition: vtkPV3blockMeshUtils.C:131
Foam::vtkPV3blockMesh::convertMeshBlocks
void convertMeshBlocks(vtkMultiBlockDataSet *, int &blockNo)
Mesh blocks.
Foam::vtkPV3blockMesh::blockStatus_
boolList blockStatus_
Selected geometrical parts.
Definition: vtkPV3blockMesh.H:182
Foam::vtkPV3blockMesh::arrayRange::name_
const char * name_
Definition: vtkPV3blockMesh.H:91
Foam::vtkPV3blockMesh::arrayRange::start_
int start_
Definition: vtkPV3blockMesh.H:93
Foam::vtkPV3blockMesh::~vtkPV3blockMesh
~vtkPV3blockMesh()
Destructor.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::vtkPV3blockMesh::arrayRange::arrayRange
arrayRange(const char *name, const int blockNo=0)
Definition: vtkPV3blockMesh.H:98
Foam::vtkPV3blockMesh::meshDir_
fileName meshDir_
The mesh directory for the region.
Definition: vtkPV3blockMesh.H:179
Foam::vtkPV3blockMesh::arrayRange::start
int start() const
Return array start index.
Definition: vtkPV3blockMesh.H:127
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::vtkPV3blockMesh::renderPointNumbers
void renderPointNumbers(vtkRenderer *, const bool show)
Add/remove point numbers to/from the view.
Foam::vtkPV3blockMesh::arrayRange::operator+=
void operator+=(const int n)
Increment the size.
Definition: vtkPV3blockMesh.H:157
Foam::vtkPV3blockMesh::setSelectedArrayEntries
static void setSelectedArrayEntries(vtkDataArraySelection *, const stringList &)
Set selection(s)
Definition: vtkPV3blockMeshUtils.C:291
Foam::vtkPV3blockMesh::arrayRange::empty
bool empty() const
Definition: vtkPV3blockMesh.H:144
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::vtkPV3blockMesh::arrayRange::block
int block() const
Return the block holding these datasets.
Definition: vtkPV3blockMesh.H:107
List
Definition: Test.C:19
Foam::vtkPV3blockMesh::edgeStatus_
boolList edgeStatus_
Selected curved edges.
Definition: vtkPV3blockMesh.H:185
Foam::vtkPV3blockMesh::pointNumberTextActorsPtrs_
List< vtkTextActor * > pointNumberTextActorsPtrs_
List of point numbers for rendering to window.
Definition: vtkPV3blockMesh.H:198
Foam::vtkPV3blockMesh::arrayRange::reset
void reset(const int startAt=0)
Reset the size to zero and optionally assign a new start.
Definition: vtkPV3blockMesh.H:150
Foam::vtkPV3blockMesh::arrayRangeEdges_
arrayRange arrayRangeEdges_
First instance and size of CurvedEdges (only partially used)
Definition: vtkPV3blockMesh.H:192
stringList.H
Foam::vtkPV3blockMesh::ClassName
ClassName("vtkPV3blockMesh")
Static data members.
Foam::vtkPV3blockMesh::arrayRange::size
int size() const
Return sublist size.
Definition: vtkPV3blockMesh.H:139
Foam::vtkPV3blockMesh::arrayRange::name
const char * name() const
Return block name.
Definition: vtkPV3blockMesh.H:121
Foam::vtkPV3blockMesh::convertMeshEdges
void convertMeshEdges(vtkMultiBlockDataSet *, int &blockNo)
Mesh curved edges.
Foam::blockMesh
A multi-block mesh generator.
Definition: blockMesh.H:58