geometryBase.C
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) 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 \*---------------------------------------------------------------------------*/
25 
26 #include "geometryBase.H"
27 #include "runTimePostProcessing.H"
28 #include "Constant.H"
29 
30 #include "vtkActor.h"
31 #include "vtkProperty.h"
32 
33 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  template<>
39  {
40  "flat",
41  "gouraud",
42  "phong"
43  };
44 }
45 
48 
49 
50 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
51 
52 void Foam::geometryBase::initialiseActor(vtkActor* actor) const
53 {
54  actor->GetProperty()->SetSpecular(0);
55  actor->GetProperty()->SetSpecularPower(20);
56 
57  switch (renderMode_)
58  {
59  case rmFlat:
60  {
61  actor->GetProperty()->SetInterpolationToFlat();
62  break;
63  }
64  case rmGouraud:
65  {
66  actor->GetProperty()->SetInterpolationToGouraud();
67  break;
68  }
69  case rmPhong:
70  {
71  actor->GetProperty()->SetInterpolationToPhong();
72  break;
73  }
74  }
75 }
76 
77 
78 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
79 
81 (
82  const runTimePostProcessing& parent,
83  const dictionary& dict,
84  const HashPtrTable<DataEntry<vector>, word>& colours
85 )
86 :
87  parent_(parent),
88  name_(dict.dictName()),
89  visible_(readBool(dict.lookup("visible"))),
90  renderMode_(rmGouraud),
91  opacity_(NULL),
92  colours_(colours)
93 {
94  if (dict.found("renderMode"))
95  {
96  renderMode_ = renderModeTypeNames.read(dict.lookup("renderMode"));
97  }
98 
99  if (dict.found("opacity"))
100  {
101  opacity_.reset(DataEntry<scalar>::New("opacity", dict).ptr());
102  }
103  else
104  {
105  opacity_.reset(new Constant<scalar>("opacity", 1.0));
106  }
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
111 
113 {}
114 
115 
116 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
117 
119 {
120  return parent_;
121 }
122 
123 
125 {
126  return name_;
127 }
128 
129 
131 {
132  return visible_;
133 }
134 
135 
136 Foam::scalar Foam::geometryBase::opacity(const scalar position) const
137 {
138  return opacity_->value(position);
139 }
140 
141 
144 {
145  return colours_;
146 }
147 
148 
149 // ************************************************************************* //
Foam::dictionaryName::dictName
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
Foam::geometryBase::opacity
scalar opacity(const scalar position) const
Return the opacity.
Definition: geometryBase.C:136
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::geometryBase::geometryBase
geometryBase(const geometryBase &)
Disallow default bitwise copy construct.
Foam::geometryBase::rmPhong
@ rmPhong
Definition: geometryBase.H:67
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
geometryBase.H
Foam::geometryBase::visible
bool visible() const
Return the visible flag.
Definition: geometryBase.C:130
Foam::runTimePostProcessing
Function object to generate images during run-time.
Definition: runTimePostProcessing.H:83
Foam::Constant
Templated basic entry that holds a constant value.
Definition: Constant.H:51
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::geometryBase::colours
const HashPtrTable< DataEntry< vector >, word > & colours() const
Return reference to the colours.
Definition: geometryBase.C:143
Foam::geometryBase::renderModeTypeNames
static const NamedEnum< renderModeType, 3 > renderModeTypeNames
Definition: geometryBase.H:70
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::geometryBase::name
const word & name() const
Return the name.
Definition: geometryBase.C:124
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::geometryBase::rmFlat
@ rmFlat
Definition: geometryBase.H:65
Foam::geometryBase::parent
const runTimePostProcessing & parent() const
Return the reference to the parent function object.
Definition: geometryBase.C:118
Foam::geometryBase::rmGouraud
@ rmGouraud
Definition: geometryBase.H:66
runTimePostProcessing.H
Foam::HashPtrTable
A HashTable specialization for hashing pointers.
Definition: HashPtrTable.H:50
Foam::geometryBase::renderMode_
renderModeType renderMode_
Render mode.
Definition: geometryBase.H:98
Foam::geometryBase::~geometryBase
virtual ~geometryBase()
Destructor.
Definition: geometryBase.C:112
Constant.H
Foam::geometryBase::initialiseActor
void initialiseActor(vtkActor *actor) const
Initialse actor.
Definition: geometryBase.C:52
Foam::readBool
bool readBool(Istream &)
Definition: boolIO.C:60
Foam::DataEntry
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: DataEntry.H:52
Foam::NamedEnum
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52