vtkSurfaceWriter.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 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 "vtkSurfaceWriter.H"
27 #include "OFstream.H"
28 #include "boolList.H"
29 #include "OSspecific.H"
31 #include "vtkWritePolyData.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  makeSurfaceWriterType(vtkSurfaceWriter);
38 }
39 
40 
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 
43 template<class Type>
44 void Foam::vtkSurfaceWriter::Write
45 (
46  const fileName& outputDir,
47  const fileName& surfaceName,
48  const pointField& points,
49  const faceList& faces,
50  const word& fieldName,
51  const Field<Type>& values,
52  const bool isNodeValues
53 ) const
54 {
55  if (!isDir(outputDir))
56  {
57  mkDir(outputDir);
58  }
59 
61  (
62  outputDir/fieldName + '_' + surfaceName + ".vtk",
63  "sampleSurface",
64  writeFormat_ == IOstream::BINARY,
65  points,
66  labelList(),
67  edgeList(),
68  faces,
69  fieldName,
70  isNodeValues,
71  values
72  );
73 }
74 
75 
76 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
77 
79 (
80  const IOstream::streamFormat writeFormat
81 )
82 :
83  surfaceWriter(writeFormat)
84 {}
85 
86 
87 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
88 
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
96 (
97  const fileName& outputDir,
98  const fileName& surfaceName,
99  const pointField& points,
100  const faceList& faces
101 ) const
102 {
103  if (!isDir(outputDir))
104  {
105  mkDir(outputDir);
106  }
107 
109  (
110  outputDir/surfaceName + ".vtk",
111  "sampleSurface",
112  writeFormat_ == IOstream::BINARY,
113  points,
114  labelList(),
115  edgeList(),
116  faces
117  );
118 }
119 
120 
121 // Create write methods
123 
124 
125 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:79
List< face > faceList
Definition: faceListFwd.H:43
virtual ~vtkSurfaceWriter()
Destructor.
virtual void write(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces) const
Write single surface geometry to file.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
List< edge > edgeList
Definition: edgeList.H:38
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
Definition: POSIX.C:539
Convenience macros for instantiating writer methods for surfaceWriter classes.
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
defineSurfaceWriterWriteFields(nastranSurfaceWriter)
List< label > labelList
A List of labels.
Definition: labelList.H:56
void write(const fileName &file, const word &title, const bool binary, const PointField &points, const VertexList &vertices, const LineList &lines, const FaceList &faces, const wordList &fieldNames, const boolList &fieldIsPointValues, const UPtrList< const Field< label >> &fieldLabelValues #define FieldTypeValuesConstArg(Type, nullArg))
Write VTK polygonal data to a file. Takes a PtrList of fields of labels and.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:290
A surfaceWriter for VTK legacy format with support for writing ASCII or binary.
makeSurfaceWriterType(ensightSurfaceWriter)
vtkSurfaceWriter(const IOstream::streamFormat writeFormat)
Construct given write format.
Base class for surface writers.
Definition: surfaceWriter.H:54
Namespace for OpenFOAM.