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

Method SetTuple

Common/Core/vtkVariantArray.cxx:216–258  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

214
215//------------------------------------------------------------------------------
216void vtkVariantArray::SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source)
217{
218 if (source->IsA("vtkVariantArray"))
219 {
220 vtkVariantArray* a = vtkArrayDownCast<vtkVariantArray>(source);
221 vtkIdType loci = i * this->NumberOfComponents;
222 vtkIdType locj = j * a->GetNumberOfComponents();
223 for (vtkIdType cur = 0; cur < this->NumberOfComponents; cur++)
224 {
225 this->SetValue(loci + cur, a->GetValue(locj + cur));
226 }
227 }
228 else if (source->IsA("vtkDataArray"))
229 {
230 vtkDataArray* a = vtkArrayDownCast<vtkDataArray>(source);
231 vtkIdType loci = i * this->NumberOfComponents;
232 vtkIdType locj = j * a->GetNumberOfComponents();
233 for (vtkIdType cur = 0; cur < this->NumberOfComponents; cur++)
234 {
235 // TODO : This just makes a double variant by default.
236 // We really should make the appropriate type of variant
237 // based on the subclass of vtkDataArray.
238 vtkIdType tuple = (locj + cur) / a->GetNumberOfComponents();
239 int component = static_cast<int>((locj + cur) % a->GetNumberOfComponents());
240 this->SetValue(loci + cur, ValueType(a->GetComponent(tuple, component)));
241 }
242 }
243 else if (source->IsA("vtkStringArray"))
244 {
245 vtkStringArray* a = vtkArrayDownCast<vtkStringArray>(source);
246 vtkIdType loci = i * this->NumberOfComponents;
247 vtkIdType locj = j * a->GetNumberOfComponents();
248 for (vtkIdType cur = 0; cur < this->NumberOfComponents; cur++)
249 {
250 this->SetValue(loci + cur, ValueType(a->GetValue(locj + cur)));
251 }
252 }
253 else
254 {
255 vtkWarningMacro("Unrecognized type is incompatible with vtkVariantArray.");
256 }
257 this->DataChanged();
258}
259
260//------------------------------------------------------------------------------
261void vtkVariantArray::InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source)

Callers

nothing calls this directly

Calls 7

SetValueMethod · 0.95
DataChangedMethod · 0.95
IsAMethod · 0.80
ValueTypeEnum · 0.50
GetNumberOfComponentsMethod · 0.45
GetValueMethod · 0.45
GetComponentMethod · 0.45

Tested by

no test coverage detected