31 template<
class Type,
class DataType>
38 const UPtrList<
const Field<Type>>& fieldTypeValues,
39 const bool writePointValues
46 fieldIsPointValues[fieldi] == writePointValues
47 && fieldTypeValues.set(fieldi)
50 const label nCmpt = pTraits<Type>::nComponents;
52 os << fieldNames[fieldi] << ' ' << pTraits<Type>::nComponents
53 <<
' ' << fieldTypeValues[fieldi].size() <<
' '
54 << (std::is_integral<DataType>::value ?
"int" :
"float") <<
nl;
56 List<DataType> data(nCmpt*fieldTypeValues[fieldi].size());
58 forAll(fieldTypeValues[fieldi], fieldValuei)
60 for (
direction cmpt = 0; cmpt < nCmpt; ++ cmpt)
67 fieldTypeValues[fieldi][fieldValuei],
80 template<
class Po
intField,
class VertexList,
class LineList,
class FaceList>
88 const LineList& lines,
89 const FaceList& faces,
92 const UPtrList<
const Field<label>>& fieldLabelValues
94 ,
const UPtrList<
const Field<Type>>& field##Type##Values
100 std::ofstream os(file, std::ios::binary);
104 os <<
"DATASET POLYDATA" <<
nl;
109 List<floatScalar> coordinates(
points.
size()*3);
130 data[2*vertexi + 1] =
vertices[vertexi];
138 label nLineNodes = 0;
141 nLineNodes += lines[facei].size();
143 os <<
"LINES " << lines.size() <<
' '
144 << lines.size() + nLineNodes <<
nl;
145 labelList data(lines.size() + nLineNodes);
149 data[i ++] = lines[linei].size();
150 forAll(lines[linei], linePointi)
152 data[i ++] = lines[linei][linePointi];
161 label nFaceNodes = 0;
164 nFaceNodes += faces[facei].size();
166 os <<
"POLYGONS " << faces.size() <<
' '
167 << faces.size() + nFaceNodes <<
nl;
168 labelList data(faces.size() + nFaceNodes);
172 data[i ++] = faces[facei].size();
173 forAll(faces[facei], facePointi)
175 data[i ++] = faces[facei][facePointi];
182 const label nPointFields =
count(fieldIsPointValues,
true);
183 const label nFaceFields =
count(fieldIsPointValues,
false);
184 if (nPointFields > 0)
187 <<
"FIELD attributes " << nPointFields <<
nl;
188 writeFieldTypeValues<label, label>
197 #define WriteFieldTypeValues(Type, nullArg) \
198 writeFieldTypeValues<Type, floatScalar> \
203 fieldIsPointValues, \
204 field##Type##Values, \
208 #undef WriteFieldTypeValues
214 <<
"FIELD attributes " << nFaceFields <<
nl;
215 writeFieldTypeValues<label, label>
224 #define WriteFieldTypeValues(Type, nullArg) \
225 writeFieldTypeValues<Type, floatScalar> \
230 fieldIsPointValues, \
231 field##Type##Values, \
235 #undef WriteFieldTypeValues
250 const fileName& file,
255 const LineList& lines,
256 const FaceList& faces,
260 const label nFields =
sizeof...(Args)/3;
263 boolList fieldIsPointValues(nFields);
264 UPtrList<const Field<label>> fieldLabelValues(nFields);
265 #define DeclareFieldTypeValues(Type, nullArg) \
266 UPtrList<const Field<Type>> field##Type##Values(nFields);
268 #undef DeclareFieldTypeValues
#define forAll(list, i)
Loop across all elements in list.
void size(const label)
Override size to be inconsistent with allocated storage.
static List< word > fieldNames
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
label cast(const label &x)
Cast an integer to the corresponding VTK write type. Does nothing.
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.
void writeFieldTypeValues(std::ostream &os, const bool binary, const wordList &fieldNames, const boolList &fieldIsPointValues, const UPtrList< const Field< Type >> &fieldTypeValues, const bool writePointValues)
Write the field values out for a type.
void unpackFieldTypeValues(wordList &fieldNames, boolList &fieldIsPointValues, UPtrList< const Field< label >> &fieldLabelValues #define FieldTypeValuesNonConstArg(Type, nullArg))
Helper for templated write.
List< word > wordList
A List of words.
pointField vertices(const blockVertexList &bvl)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
List< bool > boolList
Bool container classes.
vector point
Point is a vector.
GeometricField< Type, pointPatchField, pointMesh > PointField
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
Foam::argList args(argc, argv)
#define FieldTypeValuesConstArg(Type, nullArg)
#define FieldTypeValuesParameter(Type, nullArg)
#define WriteFieldTypeValues(Type, nullArg)
#define DeclareFieldTypeValues(Type, nullArg)