[vtkusers] SetScalars of vtkDataSetAttribute in vtk4.0
Oliver Fleig
Oliver.Fleig at univ-rennes1.fr
Tue Dec 4 03:30:32 EST 2001
On Monday 31 December 2001 14:25, zhangzhijun wrote:
> I have a program using the following code
> vtkstructuredpoints *points=vtkStructuredPoints::New();
> vtkScalars *s =vtkScalars::New();
> points->GetPointData()->SetScalars(s);
>
> this works well in vtk3.2 but in vtk4.0 the setscalars method of the
> vtkDataSetAttribute
> is redefined and the parameter of this function must be vtkDataArray, so
> the former code will
> not right compiled. How to change this?
Hello!
I hope this example code helps.
vtkFloatArray* newScalars = vtkFloatArray::New();
newScalars->SetNumberOfComponents(1);
newScalars->SetNumberOfTuples(numPts);
newScalars->SetName("TRE Scalar");
for (vtkIdType id=0; id<numPts; id++) {
float TRE;
TRE= this->TargetRegistration->GetTREatPoint(input->GetPoint(id));
newScalars->SetComponent(id,0,TRE);
}
output->GetPointData()->SetScalars(newScalars);
Somewhere in the CVS tree there is an Upgrade.zip, containing some perl
scripts to help upgrade old sources (not sure if the script addresses this
particular problem).
Cheers
Oliver
--
Oliver Fleig - Laboratoire IDM (fka SIM)
mailto:Oliver.Fleig at univ-rennes1.fr
+33 2 99 33 68 63 - http://idm.univ-rennes1.fr/users/fleig
PGP fingerprint = 9E 33 AC 7D 82 1A AE CC 9C 2B 71 BB CA B7 23 06
More information about the vtkusers
mailing list