MCPcopy Create free account
hub / github.com/Kitware/VTK / TestFieldData

Function TestFieldData

Testing/Core/vtkTestUtilities.cxx:1213–1285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1211//----------------------------------------------------------------------------
1212template <class FieldDataT = void, class ArrayMapperT>
1213bool TestFieldData(vtkFieldData* fd1, vtkFieldData* fd2, ArrayMapperT&& mapper,
1214 double toleranceFactor, bool ignoreNumberOfTuples = false)
1215{
1216 if (!fd1 || !fd2)
1217 {
1218 vtkLog(ERROR, "One of the 2 input vtkFieldData is nullptr.");
1219 return false;
1220 }
1221
1222 vtkIdType numberOfTuples = fd1->GetNumberOfTuples();
1223
1224 std::string fdName =
1225 std::is_same<FieldDataT, void>::value ? fd1->GetClassName() : vtk::TypeName<FieldDataT>();
1226
1227 if (!ignoreNumberOfTuples && numberOfTuples != fd2->GetNumberOfTuples())
1228 {
1229 vtkLog(ERROR,
1230 "Mismatched number of tuples in " << fdName << ", " << numberOfTuples
1231 << " != " << fd2->GetNumberOfTuples() << ".");
1232 return false;
1233 }
1234
1235 vtkUnsignedCharArray* ghosts1 = fd1->GetGhostArray();
1236 vtkUnsignedCharArray* ghosts2 = fd2->GetGhostArray();
1237
1238 unsigned char ghostsToSkip1 = fd1->GetGhostsToSkip();
1239 unsigned char ghostsToSkip2 = fd2->GetGhostsToSkip();
1240
1241 if (!ghosts1 != !ghosts2 || ghostsToSkip1 != ghostsToSkip2)
1242 {
1243 vtkLog(ERROR, "Ghost element status of the 2 input " << fdName << " do not match.");
1244 return false;
1245 }
1246
1247 ArrayMapperT& mapperR = mapper;
1248 for (int id = 0; id < fd1->GetNumberOfArrays(); ++id)
1249 {
1250 vtkAbstractArray* array1 = fd1->GetAbstractArray(id);
1251
1252 vtkAbstractArray* array2 = array1 ? fd2->GetAbstractArray(array1->GetName()) : nullptr;
1253
1254 if (!ArrayErrorHandler(array1, array2))
1255 {
1256 vtkLog(ERROR, "Cannot process arrays.");
1257 return false;
1258 }
1259
1260 // We can skip ghost arrays, we process them separately.
1261 if (array1 == ghosts1)
1262 {
1263 continue;
1264 }
1265
1266 if (ignoreNumberOfTuples)
1267 {
1268 mapperR.Size = array1->GetNumberOfTuples();
1269 }
1270

Callers 5

ExecuteMethod · 0.70
ExecuteMethod · 0.70
ExecuteMethod · 0.70
ExecuteMethod · 0.70
CompareFieldDataMethod · 0.70

Calls 8

ArrayErrorHandlerFunction · 0.85
TestAbstractArrayFunction · 0.85
GetAbstractArrayMethod · 0.80
GetNumberOfTuplesMethod · 0.45
GetClassNameMethod · 0.45
GetGhostArrayMethod · 0.45
GetNumberOfArraysMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected