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)
65 fieldTypeValues[fieldi][fieldValuei],
77 template<
class Po
intField,
class VertexList,
class LineList,
class FaceList>
83 const PointField& points,
84 const VertexList& vertices,
85 const LineList& lines,
86 const FaceList& faces,
89 const UPtrList<
const Field<label>>& fieldLabelValues
91 ,
const UPtrList<
const Field<Type>>&
field##Type##Values
93 #undef FieldTypeValuesConstArg
97 std::ofstream os(file, std::ios::binary);
101 os <<
"DATASET POLYDATA" <<
nl;
105 os <<
"POINTS " << points.size() <<
" float" <<
nl;
106 List<floatScalar> coordinates(points.size()*3);
109 const point&
p = points[pointi];
112 coordinates[3*pointi + i] = float(p[i]);
121 os <<
"VERTICES " << vertices.size() <<
' ' 122 << 2*vertices.size() <<
nl;
127 data[2*vertexi + 1] = vertices[vertexi];
135 label nLineNodes = 0;
138 nLineNodes += lines[facei].size();
140 os <<
"LINES " << lines.size() <<
' ' 141 << lines.size() + nLineNodes <<
nl;
142 labelList data(lines.size() + nLineNodes);
146 data[i ++] = lines[linei].size();
147 forAll(lines[linei], linePointi)
149 data[i ++] = lines[linei][linePointi];
158 label nFaceNodes = 0;
161 nFaceNodes += faces[facei].size();
163 os <<
"POLYGONS " << faces.size() <<
' ' 164 << faces.size() + nFaceNodes <<
nl;
165 labelList data(faces.size() + nFaceNodes);
169 data[i ++] = faces[facei].size();
170 forAll(faces[facei], facePointi)
172 data[i ++] = faces[facei][facePointi];
179 const label nPointFields =
count(fieldIsPointValues,
true);
180 const label nFaceFields =
count(fieldIsPointValues,
false);
181 if (nPointFields > 0)
183 os <<
"POINT_DATA " << points.size() << nl
184 <<
"FIELD attributes " << nPointFields <<
nl;
185 writeFieldTypeValues<label, label>
194 #define WriteFieldTypeValues(Type, nullArg) \ 195 writeFieldTypeValues<Type, floatScalar> \ 200 fieldIsPointValues, \ 201 field##Type##Values, \ 205 #undef WriteFieldTypeValues 210 << vertices.size() + lines.size() + faces.size() << nl
211 <<
"FIELD attributes " << nFaceFields <<
nl;
212 writeFieldTypeValues<label, label>
221 #define WriteFieldTypeValues(Type, nullArg) \ 222 writeFieldTypeValues<Type, floatScalar> \ 227 fieldIsPointValues, \ 228 field##Type##Values, \ 232 #undef WriteFieldTypeValues 247 const fileName& file,
250 const PointField& points,
251 const VertexList& vertices,
252 const LineList& lines,
253 const FaceList& faces,
257 const label nFields =
sizeof...(Args)/3;
260 boolList fieldIsPointValues(nFields);
261 UPtrList<const Field<label>> fieldLabelValues(nFields);
262 #define DeclareFieldTypeValues(Type, nullArg) \ 263 UPtrList<const Field<Type>> field##Type##Values(nFields); 265 #undef DeclareFieldTypeValues #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.
void unpackFieldTypeValues(wordList &fieldNames, boolList &fieldIsPointValues, UPtrList< const Field< label >> &fieldLabelValues #define FieldTypeValuesNonConstArg(Type, nullArg))
Helper for templated write.
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.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
#define FOR_ALL_FIELD_TYPES(Macro,...)
static List< word > fieldNames
List< bool > boolList
Bool container classes.
#define DeclareFieldTypeValues(Type, nullArg)
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
GeometricField< Type, pointPatchField, pointMesh > PointField
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
List< label > labelList
A List of labels.
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.
#define WriteFieldTypeValues(Type, nullArg)
List< word > wordList
A List of words.
vector point
Point is a vector.
#define FieldTypeValuesConstArg(Type, nullArg)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
#define FieldTypeValuesParameter(Type, nullArg)