42 void Foam::vtkSurfaceWriter::writeGeometry
53 os <<
"DATASET POLYDATA" <<
nl;
56 os <<
"POINTS " << points.size() <<
" float" <<
nl;
58 List<floatScalar> po(points.size()*3);
62 const point& pt = points[pointi];
65 po[ind++] = float(pt[cmpt]);
74 nNodes += faces[facei].size();
77 os <<
"POLYGONS " << faces.size() <<
' ' 78 << faces.size() + nNodes <<
nl;
80 labelList polygons(faces.size() + nNodes);
84 const face&
f = faces[facei];
85 polygons[ind++] = f.
size();
88 polygons[ind++] = f[fp];
96 void Foam::vtkSurfaceWriter::Write
98 const fileName& outputDir,
99 const fileName& surfaceName,
102 const word& fieldName,
103 const Field<Type>& values,
104 const bool isNodeValues
109 if (!
isDir(outputDir))
114 const word filePath = outputDir/fieldName +
'_' + surfaceName +
".vtk";
116 ofstream os(filePath, std::ios::binary);
120 Info<<
"Writing field " << fieldName <<
" to " << filePath <<
endl;
123 writeGeometry(os, points, faces);
135 os << values.size() << nl
136 <<
"FIELD attributes 1" << nl
139 const label nComp = pTraits<Type>::nComponents;
141 os << nComp <<
" " << values.size() <<
" float" <<
nl;
143 List<floatScalar> vals(values.size()*nComp);
147 for (
direction cmpt=0; cmpt < nComp; ++cmpt)
149 vals[ind++] =
component(values[elemI], cmpt);
184 if (!
isDir(outputDir))
189 word filePath = outputDir/surfaceName +
".vtk";
190 ofstream os(filePath, std::ios::binary);
194 Info<<
"Writing geometry to " << filePath <<
endl;
197 writeGeometry(os, points, faces);
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
A class for handling words, derived from string.
Convenience macros for instantiating writer methods for surfaceWriter classes.
streamFormat
Enumeration for the format of data in the stream.
defineSurfaceWriterWriteFields(nastranSurfaceWriter)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
List< label > labelList
A List of labels.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
vector point
Point is a vector.
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.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)