1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: otherFieldData.cxx,v $
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkDebugLeaks.h"
#include "vtkFieldData.h"
#include "vtkFloatArray.h"
#include "vtkIdList.h"
int otherFieldData(int,char *[])
{
int i;
vtkFieldData* fd = vtkFieldData::New();
vtkFloatArray* fa;
char name[128];
for(i=0; i<5; i++)
{
sprintf(name, "Array%d", i);
fa = vtkFloatArray::New();
fa->SetName(name);
// the tuples must be set before being read to avoid a UMR
// this must have been a UMR in the past that was suppressed
fa->Allocate(20);
fa->SetTuple1(0,0.0);
fa->SetTuple1(2,0.0);
fd->AddArray(fa);
fa->Delete();
}
// Coverage
vtkFieldData::Iterator it(fd);
vtkFieldData::Iterator it2(it);
it = it;
it2 = it;
fd->Allocate(20);
fd->CopyFieldOff("Array0");
fd->CopyFieldOff("Array1");
vtkFieldData* fd2 = fd->NewInstance();
fd2->CopyStructure(fd);
fd2->ShallowCopy(fd);
fd2->DeepCopy(fd);
vtkIdList* ptIds = vtkIdList::New();
ptIds->InsertNextId(0);
ptIds->InsertNextId(2);
fd->GetField(ptIds, fd2);
ptIds->Delete();
int arrayComp;
int a = fd->GetArrayContainingComponent(1, arrayComp);
if (a != 1)
{
return 1;
}
double tuple[10];
// initialize tuple before using it to set something
for (i = 0; i < 10; i++)
{
tuple[i] = i;
}
fd->GetTuple(2);
fd->SetTuple(2, tuple);
fd->InsertTuple(2, tuple);
fd->InsertNextTuple(tuple);
fd->SetComponent(0,0, 1.0);
fd->InsertComponent(0,0, 1.0);
fd2->Reset();
fd->Delete();
fd2->Delete();
return 0;
}
|