Go to the documentation of this file.
22 #ifndef __pointFieldToVTK_hpp__
23 #define __pointFieldToVTK_hpp__
34 template<
typename IncludeMaskType>
38 int32 numActivePoints,
42 template<
typename IncludeMaskType>
46 int32 numActivePoints,
50 template<
typename IncludeMaskType>
54 int32 numActivePoints,
60 std::regex match(
"pointField\\<([A-Za-z1-9_]*)\\,([A-Za-z1-9_]*)\\>");
61 std::smatch search1, search2;
62 if(!std::regex_match(fieldType, search1, match))
return false;
63 if(!std::regex_match(TYPENAME, search2, match))
return false;
64 if(search1.size()!=3)
return false;
65 if(search1.size()!=search2.size())
return false;
66 return search1[1] == search2[1];
69 template<
typename Type>
86 if( !(checkFieldType<int8>(objectType) ||
87 checkFieldType<int16>(objectType) ||
88 checkFieldType<int32>(objectType) ||
89 checkFieldType<int64>(objectType) ||
90 checkFieldType<uint32>(objectType) ||
91 checkFieldType<label>(objectType))
97 auto objField = IOobject::make<int64PointField_H>
101 static_cast<int64>(0)
126 if(!checkFieldType<real>(objectType))
return false;
128 auto objField = IOobject::make<realPointField_H>
137 real* data =
Field.hostVectorAll().data();
156 if(!checkFieldType<realx3>(objectType))
return false;
158 auto objField = IOobject::make<realx3PointField_H>
180 template<
typename IncludeMaskType>
183 int32 numActivePoints,
192 os<<
"DATASET UNSTRUCTURED_GRID\n";
193 os<<
"POINTS "<< numActivePoints <<
" float\n";
195 if(numActivePoints==0)
return true;
197 for(
int32 i=iFirst; i<iLast; ++i)
200 os<< position[i].
x()<<
' '<< position[i].
y()<<
' '<<position[i].
z()<<
'\n';
203 os<<
"CELLS "<< numActivePoints<<
' '<< 2*numActivePoints<<
'\n';
204 for(
int32 i=0; i<numActivePoints; i++)
206 os<< 1 <<
' '<< i<<
'\n';
209 os<<
"CELL_TYPES "<< numActivePoints<<
'\n';
211 for(
int32 i=0; i<numActivePoints; i++)
216 os <<
"POINT_DATA " << numActivePoints <<
endl;
222 template<
typename IncludeMaskType>
226 int32 numActivePoints,
230 if(numActivePoints==0)
return true;
234 os <<
"FIELD FieldData 1\n"<<
235 fieldName <<
" 1 " << numActivePoints <<
" int\n";
236 for(
int32 i=iFirst; i<iLast; ++i)
239 os<< field[i] <<
'\n';
245 template<
typename IncludeMaskType>
249 int32 numActivePoints,
253 if(numActivePoints==0)
return true;
257 os <<
"FIELD FieldData 1\n"<<
258 fieldName <<
" 1 " << numActivePoints <<
" float\n";
259 for(
int32 i=iFirst; i<iLast; ++i)
262 os<< field[i] <<
'\n';
267 template<
typename IncludeMaskType>
271 int32 numActivePoints,
275 if(numActivePoints==0)
return true;
279 os <<
"FIELD FieldData 1\n"<<
280 fieldName <<
" 3 " << numActivePoints <<
" float\n";
281 for(
int32 i=iFirst; i<iLast; ++i)
284 os<< field[i].
x()<<
' '<< field[i].
y()<<
' '<<field[i].
z()<<
'\n';
310 " does not contain any pStructure data file. Skipping this folder . . ."
315 vtkFile vtk(destPath, bName, time);
317 if(!vtk)
return false;
319 auto pStructObjPtr = IOobject::make<pointStructure>(pStructHeader);
325 auto* pos = posVec.data();
338 for(
auto& file:fileList)
381 " does not contain any pStructure data file. Skipping this folder . . ."
386 vtkFile vtk(destPath, bName, time);
388 if(!vtk)
return false;
390 auto pStructObjPtr = IOobject::make<pointStructure>(pStructHeader);
396 auto* pos = posVec.data();
409 for(
auto& fname:fieldsName)
431 " does not exist."<<
endl;
bool convertTimeFolderPointFieldsSelected(fileSystem timeFolder, real time, fileSystem destPath, word bName, wordVector fieldsName, bool mustExist)
const char * pointStructureFile__
bool addRealPointField(iOstream &os, word fieldName, int32 numActivePoints, real *field, IncludeMaskType includeMask)
bool regexCheck(word TYPENAME, word fieldType)
const INLINE_FUNCTION_H auto hostVectorAll() const
bool addRealx3PointField(iOstream &os, word fieldName, int32 numActivePoints, realx3 *field, IncludeMaskType includeMask)
fileSystemList containingFiles(const fileSystem &path)
iOstream & endl(iOstream &os)
FUNCTION_H realx3Field_D & pointPosition()
INLINE_FUNCTION_HD T & y()
bool convertRealx3TypePointField(iOstream &os, const IOfileHeader &header, const pointStructure &pStruct)
#define fatalErrorInFunction
const char * defaultColor
bool convertIntTypesPointField(iOstream &os, const IOfileHeader &header, const pointStructure &pStruct)
bool convertRealTypePointField(iOstream &os, const IOfileHeader &header, const pointStructure &pStruct)
INLINE_FUNCTION_HD T & z()
bool addInt64PointField(iOstream &os, word fieldName, int32 numActivePoints, int64 *field, IncludeMaskType includeMask)
bool checkFieldType(word objectType)
bool convertTimeFolderPointFields(fileSystem timeFolder, real time, fileSystem destPath, word bName)
INLINE_FUNCTION_HD T & x()
bool addUndstrcuturedGridField(iOstream &os, int32 numActivePoints, realx3 *position, IncludeMaskType includeMask)