fieldVisualisationBase.H 5.17 KB
Newer Older
1 2 3 4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
5
    \\  /    A nd           | Copyright (C) 2015-2016 OpenCFD Ltd.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
25
    Foam::functionObjects::fieldVisualisationBase
26 27

Description
28
    Base class for scene objects
29 30 31 32 33 34

SourceFiles
    fieldVisualisationBase.C

\*---------------------------------------------------------------------------*/

35 36
#ifndef functionObjects_fieldVisualisationBase_H
#define functionObjects_fieldVisualisationBase_H
37 38 39 40 41 42

#include "dictionary.H"
#include "Tuple2.H"
#include "NamedEnum.H"
#include "vector.H"
#include "HashPtrTable.H"
43
#include "Function1.H"
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

#include "vtkSmartPointer.h"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

class vtkActor;
class vtkLookupTable;
class vtkPolyData;
class vtkPolyDataMapper;
class vtkRenderer;


class vtkMapper;

namespace Foam
{
60 61
namespace functionObjects
{
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120

class runTimePostProcessing;

/*---------------------------------------------------------------------------*\
                   Class fieldVisualisationBase Declaration
\*---------------------------------------------------------------------------*/

class fieldVisualisationBase
{
public:

    // Public enumerations

        enum colourByType
        {
            cbColour,
            cbField
        };

        static const NamedEnum<colourByType, 2> colourByTypeNames;

        enum colourMapType
        {
            cmRainbow,
            cmBlueWhiteRed,
            cmFire,
            cmGreyscale
        };

        static const NamedEnum<colourMapType, 4> colourMapTypeNames;


private:

    // Private Member Functions

        //- Disallow default bitwise copy construct
        fieldVisualisationBase(const fieldVisualisationBase&);

        //- Disallow default bitwise assignment
        void operator=(const fieldVisualisationBase&);


protected:

    // Protected data

        struct scalarBar
        {
            bool visible_;
            bool vertical_;
            Tuple2<scalar, scalar> position_;
            string title_;
            label fontSize_;
            string labelFormat_;
            label numberOfLabels_;
        };

        //- Colours
121
        const HashPtrTable<Function1<vector>, word>& colours_;
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157

        //- Field name
        word fieldName_;

        //- Colour by type
        colourByType colourBy_;

        //- Colour map type
        colourMapType colourMap_;

        //- Range of values
        Tuple2<scalar, scalar> range_;

        //- Scalar bar
        scalarBar scalarBar_;


    // Protected Member Functions

        //- Set the colour map
        void setColourMap(vtkLookupTable* lut) const;

        //- Add scalar bar to renderer
        void addScalarBar
        (
            const scalar position,
            vtkRenderer* renderer,
            vtkLookupTable* lut
        ) const;

        //- Set field/configure mapper, add scalar bar
        void setField
        (
            const scalar position,
            const word& colourFieldName,
            vtkPolyDataMapper* mapper,
158 159
            vtkRenderer* renderer,
            vtkPolyData* pData
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
        ) const;

        //- Add glyphs
        void addGlyphs
        (
            const scalar position,
            const word& scaleFieldName,
            const word& colourFieldName,
            const scalar maxGlyphLength,
            vtkPolyData* data,
            vtkActor* actor,
            vtkRenderer* renderer
        ) const;


public:

    // Constructors

        //- Construct from dictionary
        fieldVisualisationBase
        (
            const dictionary& dict,
183
            const HashPtrTable<Function1<vector>, word>& colours
184 185 186 187 188 189 190 191 192 193 194 195
        );


    //- Destructor
    virtual ~fieldVisualisationBase();


    // Member Functions

        // Access

            //- Return the colours
196
            const HashPtrTable<Function1<vector>, word>& colours() const;
197 198 199 200 201 202 203 204

            //- Return the field name
            const word& fieldName() const;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

205
} // End namespace functionObjects
206 207 208 209 210 211 212 213 214
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //