geometryBase.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) 2015-2019 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::functionObjects::runTimePostPro::geometryBase
28 
29 Description
30  Base class for surface, text handling etc.
31 
32  Dictionary controls
33  \table
34  Property | Description | Required | Default
35  visible | Display the object | no | yes
36  renderMode | Shading (flat/gouraud/phong) | no | gouraud
37  opacity | Object opacity | no | 1.0
38  parallel | Allow parallel rendering | no | true
39  \endtable
40 
41 SourceFiles
42  geometryBase.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef functionObjects_runTimePostPro_geometryBase_H
47 #define functionObjects_runTimePostPro_geometryBase_H
48 
49 #include "dictionary.H"
50 #include "vector.H"
51 #include "Function1.H"
52 #include "HashPtrTable.H"
53 #include "Enum.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 // Forward Declarations (VTK)
58 class vtkRenderer;
59 class vtkActor;
60 
61 namespace Foam
62 {
63 namespace functionObjects
64 {
65 
66 // Forward Declarations
67 class runTimePostProcessing;
68 
69 namespace runTimePostPro
70 {
71 
72 
73 /*---------------------------------------------------------------------------*\
74  Class geometryBase Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class geometryBase
78 {
79 public:
80 
81  // Public Enumerations
82 
83  //- Surface shading types
84  enum renderModeType
85  {
86  rmFlat,
87  rmGouraud,
88  rmPhong
89  };
90 
91  //- Names for surface shading types
92  static const Enum<renderModeType> renderModeTypeNames;
93 
94 
95 protected:
96 
97  // Protected data
98 
99  //- Reference to the parent function object
100  const runTimePostProcessing& parent_;
101 
102  //- The surface name
103  word name_;
104 
105  //- Visible flag
106  bool visible_;
107 
108  //- Allow parallel rendering
109  bool parallel_;
110 
111  //- Render mode
113 
114  //- Opacity
116 
117  //- Reference to the colours
119 
120 
121  // Protected Functions
122 
123  //- Initialise actor
124  void initialiseActor(vtkActor* actor) const;
125 
126  //- No copy construct
127  geometryBase(const geometryBase&) = delete;
128 
129  //- No copy assignment
130  void operator=(const geometryBase&) = delete;
131 
132 
133 public:
134 
135  //- Debug switch
136  static int debug;
137 
138  // Constructors
139 
140  //- Construct from dictionary
142  (
144  const dictionary& dict,
146  );
147 
148 
149  //- Destructor
150  virtual ~geometryBase();
151 
152 
153  // Member Functions
154 
155  //- Return the reference to the parent function object
156  const runTimePostProcessing& parent() const;
157 
158  //- May need to gather geometry parts to render on single-processor
159  // True when OpenFOAM is running in parallel but VTK is not.
160  bool needsCollective() const;
161 
162  //- Return the name
163  const word& name() const;
164 
165  //- Return the visible flag
166  bool visible() const
167  {
168  return visible_;
169  }
170 
171  //- Allow parallel rendering
172  bool parallel() const
173  {
174  return parallel_;
175  }
176 
177  //- Return the opacity
178  scalar opacity(const scalar position) const;
179 
180  //- Return reference to the colours
181  const HashPtrTable<Function1<vector>>& colours() const;
182 
183 
184  // Scene Interaction
185 
186  //- Add geometry to scene
187  virtual void addGeometryToScene
188  (
189  const scalar position,
190  vtkRenderer* renderer
191  ) = 0;
192 
193  //- Update the actors
194  virtual void updateActors(const scalar position) = 0;
195 
196  //- Clear any files used to create the object(s)
197  virtual bool clear() = 0;
198 };
199 
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 } // End namespace runTimePostPro
204 } // End namespace functionObjects
205 } // End namespace Foam
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #endif
210 
211 // ************************************************************************* //
Foam::functionObjects::runTimePostPro::geometryBase::colours_
const HashPtrTable< Function1< vector > > & colours_
Reference to the colours.
Definition: geometryBase.H:142
Foam::functionObjects::runTimePostPro::geometryBase::renderMode_
renderModeType renderMode_
Render mode.
Definition: geometryBase.H:136
Foam::Enum< renderModeType >
Foam::functionObjects::runTimePostPro::geometryBase::initialiseActor
void initialiseActor(vtkActor *actor) const
Initialise actor.
Definition: geometryBase.C:64
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::functionObjects::runTimePostPro::geometryBase::needsCollective
bool needsCollective() const
May need to gather geometry parts to render on single-processor.
Definition: geometryBase.C:148
Foam::functionObjects::runTimePostPro::geometryBase::opacity_
autoPtr< Function1< scalar > > opacity_
Opacity.
Definition: geometryBase.H:139
Function1.H
Foam::functionObjects::runTimePostPro::geometryBase::updateActors
virtual void updateActors(const scalar position)=0
Update the actors.
Foam::functionObjects::runTimePostPro::geometryBase::geometryBase
geometryBase(const geometryBase &)=delete
No copy construct.
Foam::functionObjects::runTimePostPro::geometryBase::~geometryBase
virtual ~geometryBase()
Destructor.
Definition: geometryBase.C:134
Foam::functionObjects::runTimePostPro::geometryBase::name
const word & name() const
Return the name.
Definition: geometryBase.C:155
Foam::functionObjects::runTimePostPro::geometryBase::visible
bool visible() const
Return the visible flag.
Definition: geometryBase.H:190
Foam::functionObjects::runTimePostPro::geometryBase::addGeometryToScene
virtual void addGeometryToScene(const scalar position, vtkRenderer *renderer)=0
Add geometry to scene.
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:56
Foam::functionObjects::runTimePostPro::geometryBase::clear
virtual bool clear()=0
Clear any files used to create the object(s)
Foam::functionObjects::runTimePostPro::geometryBase::opacity
scalar opacity(const scalar position) const
Return the opacity.
Definition: geometryBase.C:162
Foam::functionObjects::runTimePostProcessing
Generate images during run-time.
Definition: runTimePostProcessing.H:170
Foam::functionObjects::runTimePostPro::geometryBase::rmGouraud
Gouraud shading.
Definition: geometryBase.H:111
Foam::functionObjects::runTimePostPro::geometryBase::parallel_
bool parallel_
Allow parallel rendering.
Definition: geometryBase.H:133
Foam::functionObjects::runTimePostPro::geometryBase::parent
const runTimePostProcessing & parent() const
Return the reference to the parent function object.
Definition: geometryBase.C:141
Foam::functionObjects::runTimePostPro::geometryBase::debug
static int debug
Debug switch.
Definition: geometryBase.H:160
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::functionObjects::runTimePostPro::geometryBase::renderModeTypeNames
static const Enum< renderModeType > renderModeTypeNames
Names for surface shading types.
Definition: geometryBase.H:116
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObjects::runTimePostPro::geometryBase
Base class for surface, text handling etc.
Definition: geometryBase.H:101
Foam::functionObjects::runTimePostPro::geometryBase::parallel
bool parallel() const
Allow parallel rendering.
Definition: geometryBase.H:196
Foam::functionObjects::runTimePostPro::geometryBase::rmFlat
Flat shading.
Definition: geometryBase.H:110
Foam::functionObjects::runTimePostPro::geometryBase::rmPhong
Phong shading.
Definition: geometryBase.H:112
Foam::HashPtrTable
A HashTable of pointers to objects of type <T>.
Definition: HashPtrTable.H:54
Foam::functionObjects::runTimePostPro::geometryBase::visible_
bool visible_
Visible flag.
Definition: geometryBase.H:130
HashPtrTable.H
dictionary.H
Foam::functionObjects::runTimePostPro::geometryBase::name_
word name_
The surface name.
Definition: geometryBase.H:127
vector.H
Foam::functionObjects::runTimePostPro::geometryBase::colours
const HashPtrTable< Function1< vector > > & colours() const
Return reference to the colours.
Definition: geometryBase.C:171
Foam::functionObjects::runTimePostPro::geometryBase::renderModeType
renderModeType
Surface shading types.
Definition: geometryBase.H:108
Foam::functionObjects::runTimePostPro::geometryBase::parent_
const runTimePostProcessing & parent_
Reference to the parent function object.
Definition: geometryBase.H:124
Foam::functionObjects::runTimePostPro::geometryBase::operator=
void operator=(const geometryBase &)=delete
No copy assignment.
Enum.H