[vtkusers] How do I interpolate scalars along the geometric surface?

Takayoshi Kurachi kurakurara at gmail.com
Mon Feb 16 08:54:19 EST 2009


Hello All,

I'm trying to interpolate scalar values along the geometric
surface and having a very difficult time.

I have a geometric data of a brain in 3DS file and want to set
scalar value (of electroencephalogram) in its 21 locations of
the surface points, and interpolate for the rest of the points
along the surface to show the scalar values in color.

With the code below, I could get the vtkPointData and set
scalar values on some of the points as the dataset attribute,
but it seems that the value is shown in color only within the
cell that contains the point with the attribute value I set.
I want to interpolate the scalar along the entire surface by
the 21 given values.

How can I interpolate scalar values along the surface?

Many thanks in advance.

Taka


// Read geometric data from 3DS file
vtk3DSImporter* importer = vtk3DSImporter::New();
importer->ComputeNormalsOff();
importer->SetFileName("data/brain.3ds");
importer->Read();

// create lookup table (white <-> red)
vtkLookupTable *lut = vtkLookupTable::New();
lut->SetTableRange (0, 1);
lut->SetHueRange (1, 1);
lut->SetSaturationRange (0, 1);
lut->SetValueRange (1, 1);
lut->Build();

// create render window and interactor
vtkRenderWindow* renWin = vtkRenderWindow::New();
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();

// get data from the importer as vtkDataSet
vtkActorCollection* actors = importer->GetRenderer()->GetActors();
actors->InitTraversal();
vtkActor* actor = actors->GetLastActor();
vtkMapper* mapper = actor->GetMapper();
vtkDataSet* data = mapper->GetInput();
vtkPointData* ptData = data->GetPointData();

data->Update();

// get point ids of 4 points for testing (actually i will set 21 points)
double bounds[6];
data->GetBounds(bounds);
vtkIdType id1 = data->FindPoint(0, 0, bounds[5]);
vtkIdType id2 = data->FindPoint(0, 0, bounds[6]);
vtkIdType id3 = data->FindPoint(bounds[0], 0, 0);
vtkIdType id4 = data->FindPoint(bounds[1], 0, 0);

// create array of scalars in vtkFloatArray
vtkFloatArray *scalars = vtkFloatArray::New();
scalars->InsertTuple1(id1, 1.0); // set the value 1.0 for testing
scalars->InsertTuple1(id2, 1.0);
scalars->InsertTuple1(id3, 1.0);
scalars->InsertTuple1(id4, 1.0);
scalars->SetLookupTable(lut);

// set the scalars to the vtkPointData as the dataset attribute
ptData->Initialize();
ptData->SetScalars(scalars);

// ... setting up mapper, actor, camera, etc.





More information about the vtkusers mailing list