BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / utilities / postProcessing / graphics / PV3FoamReader / vtkPV3Foam / vtkPV3FoamPatchField.H
blob2aa4cde91176dff3e620d91ef2d7407534893334
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 InClass
26     vtkPV3Foam
28 \*---------------------------------------------------------------------------*/
30 #ifndef vtkPV3FoamPatchField_H
31 #define vtkPV3FoamPatchField_H
33 // VTK includes
34 #include "vtkCellData.h"
35 #include "vtkFloatArray.h"
36 #include "vtkMultiBlockDataSet.h"
37 #include "vtkPointData.h"
38 #include "vtkPolyData.h"
40 #include "vtkOpenFOAMTupleRemap.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 template<class Type>
45 void Foam::vtkPV3Foam::convertPatchField
47     const word& name,
48     const Field<Type>& ptf,
49     vtkMultiBlockDataSet* output,
50     const partInfo& selector,
51     const label datasetNo
54     const label nComp = pTraits<Type>::nComponents;
56     vtkFloatArray* cellData = vtkFloatArray::New();
57     cellData->SetNumberOfTuples( ptf.size() );
58     cellData->SetNumberOfComponents( nComp );
59     cellData->Allocate( nComp*ptf.size() );
60     cellData->SetName( name.c_str() );
62     float vec[nComp];
63     forAll(ptf, i)
64     {
65         const Type& t = ptf[i];
66         for (direction d=0; d<nComp; d++)
67         {
68             vec[d] = component(t, d);
69         }
70         vtkOpenFOAMTupleRemap<Type>(vec);
72         cellData->InsertTuple(i, vec);
73     }
75     vtkPolyData::SafeDownCast
76     (
77         GetDataSetFromBlock(output, selector, datasetNo)
78     )   ->GetCellData()
79         ->AddArray(cellData);
81     cellData->Delete();
85 // as above, but with PointData()
86 template<class Type>
87 void Foam::vtkPV3Foam::convertPatchPointField
89     const word& name,
90     const Field<Type>& pptf,
91     vtkMultiBlockDataSet* output,
92     const partInfo& selector,
93     const label datasetNo
96     const label nComp = pTraits<Type>::nComponents;
98     vtkFloatArray *pointData = vtkFloatArray::New();
99     pointData->SetNumberOfTuples( pptf.size() );
100     pointData->SetNumberOfComponents( nComp );
101     pointData->Allocate( nComp*pptf.size() );
102     pointData->SetName( name.c_str() );
104     float vec[nComp];
105     forAll(pptf, i)
106     {
107         const Type& t = pptf[i];
108         for (direction d=0; d<nComp; d++)
109         {
110             vec[d] = component(t, d);
111         }
112         vtkOpenFOAMTupleRemap<Type>(vec);
114         pointData->InsertTuple(i, vec);
115     }
117     vtkPolyData::SafeDownCast
118     (
119         GetDataSetFromBlock(output, selector, datasetNo)
120     )   ->GetPointData()
121         ->AddArray(pointData);
123     pointData->Delete();
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 #endif
130 // ************************************************************************* //