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

Function TestSetDataImpl

Common/DataModel/Testing/Cxx/TestCellArrayHelpers.h:471–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469
470template <typename OffsetsArrayType, typename ConnectivityArrayType>
471void TestSetDataImpl(vtkSmartPointer<vtkCellArray> cellArray)
472{
473 vtkLogScopeFunction(INFO);
474 using OffsetsValueType = typename OffsetsArrayType::ValueType;
475 using ConnectivityValueType = typename ConnectivityArrayType::ValueType;
476 constexpr bool FixedSize = std::is_base_of_v<vtkAffineArray<OffsetsValueType>, OffsetsArrayType>;
477 vtkNew<vtkCellArray> test;
478 test->DeepCopy(cellArray); // copy config settings
479
480 vtkNew<OffsetsArrayType> offsets;
481 if (auto countingOffsets = vtkAffineArray<OffsetsValueType>::SafeDownCast(offsets))
482 {
483 countingOffsets->ConstructBackend(GetCellIds<FixedSize>(0)->GetNumberOfIds(), 0);
484 }
485 vtkNew<ConnectivityArrayType> conn;
486 offsets->InsertNextValue(0);
487 for (vtkIdType i = 0; i < 3; ++i)
488 {
489 auto ids = GetCellIds<FixedSize>(i);
490 offsets->InsertNextValue(offsets->GetValue(i) + ids->GetNumberOfIds());
491 for (vtkIdType j = 0; j < ids->GetNumberOfIds(); ++j)
492 {
493 conn->InsertNextValue(ids->GetId(j));
494 }
495 }
496 auto offsetsMTtime = offsets->GetMTime();
497 auto connMTtime = conn->GetMTime();
498 test->SetData(offsets, conn);
499
500 // checkNoCopy and MTime
501 TEST_ASSERT(test->GetOffsetsArray() == offsets && offsets->GetMTime() == offsetsMTtime);
502 TEST_ASSERT(test->GetConnectivityArray() == conn && conn->GetMTime() == connMTtime);
503
504 if (std::is_base_of_v<vtkAOSDataArrayTemplate<OffsetsValueType>, OffsetsArrayType> &&
505 std::is_base_of_v<vtkAOSDataArrayTemplate<ConnectivityValueType>, ConnectivityArrayType> &&
506 std::is_same_v<OffsetsValueType, ConnectivityValueType>)
507 {
508 if (std::is_same_v<OffsetsValueType, vtkTypeInt32>)
509 {
510 TEST_ASSERT(!test->IsStorage64Bit());
511 TEST_ASSERT(test->IsStorage32Bit());
512 TEST_ASSERT(!test->IsStorageFixedSize64Bit());
513 TEST_ASSERT(!test->IsStorageFixedSize32Bit());
514 TEST_ASSERT(!test->IsStorageGeneric());
515 }
516 else if (std::is_same_v<OffsetsValueType, vtkTypeInt64>)
517 {
518 TEST_ASSERT(test->IsStorage64Bit());
519 TEST_ASSERT(!test->IsStorage32Bit());
520 TEST_ASSERT(!test->IsStorageFixedSize64Bit());
521 TEST_ASSERT(!test->IsStorageFixedSize32Bit());
522 TEST_ASSERT(!test->IsStorageGeneric());
523 }
524 else
525 {
526 TEST_ASSERT(!test->IsStorage64Bit());
527 TEST_ASSERT(!test->IsStorage32Bit());
528 TEST_ASSERT(!test->IsStorageFixedSize64Bit());

Callers

nothing calls this directly

Calls 11

GetConnectivityArrayMethod · 0.80
GetNumberOfOffsetsMethod · 0.80
DeepCopyMethod · 0.45
GetNumberOfIdsMethod · 0.45
InsertNextValueMethod · 0.45
GetValueMethod · 0.45
GetIdMethod · 0.45
GetMTimeMethod · 0.45
SetDataMethod · 0.45
GetNumberOfCellsMethod · 0.45

Tested by

no test coverage detected