Skip to content

Commit 6ad1085

Browse files
AlexyPellegrinikwrobot
authored andcommitted
Merge topic 'abstractarray-getvariantvalue-bit'
c90fed7 Add support of VTK_BIT type in vtkAbstractArray::GetVariantValue Acked-by: Kitware Robot <[email protected]> Tested-by: buildbot <[email protected]> Reviewed-by: Nicolas Vuaille <[email protected]> Merge-request: !11987
2 parents f573109 + c90fed7 commit 6ad1085

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Common/Core/Testing/Cxx/TestBitArray.cxx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "vtkNew.h"
77

8+
#include <array>
89
#include <bitset>
910
#include <string>
1011

@@ -77,5 +78,27 @@ int TestBitArray(int, char*[])
7778
return EXIT_FAILURE;
7879
}
7980

81+
// Test GetVariantValue accessor
82+
array->Resize(4);
83+
array->SetValue(0, 0);
84+
array->SetValue(1, 1);
85+
array->SetValue(2, 1);
86+
array->SetValue(3, 0);
87+
88+
std::array<int, 4> variantValues = {
89+
array->GetVariantValue(0).ToInt(),
90+
array->GetVariantValue(1).ToInt(),
91+
array->GetVariantValue(2).ToInt(),
92+
array->GetVariantValue(3).ToInt(),
93+
};
94+
95+
if (variantValues != std::array<int, 4>{ 0, 1, 1, 0 })
96+
{
97+
std::cerr << "GetVariantValue return invalid data \"{" << variantValues[0] << ", "
98+
<< variantValues[1] << ", " << variantValues[2] << ", " << variantValues[3]
99+
<< "}\", it should be \"{0, 1, 1, 0}\"" << std::endl;
100+
return EXIT_FAILURE;
101+
}
102+
80103
return EXIT_SUCCESS;
81104
}

Common/Core/vtkAbstractArray.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,8 @@ vtkVariant vtkAbstractArray::GetVariantValue(vtkIdType valueIdx)
528528
{
529529
vtkExtraExtendedTemplateMacro(val = vtkAbstractArrayGetVariantValue(
530530
static_cast<VTK_TT*>(this->GetVoidPointer(0)), valueIdx));
531+
vtkTemplateMacroCase(
532+
VTK_BIT, int, val = static_cast<VTK_TT>(static_cast<vtkBitArray*>(this)->GetValue(valueIdx)));
531533
}
532534
return val;
533535
}

0 commit comments

Comments
 (0)