[vtkusers] Topology with StructuredGrid
Chris Bayley
bayley at me.queensu.ca
Mon Sep 24 10:09:01 EDT 2001
Hello Everyone
I am trying to use vtkStructuredGrid to represent the topology of a regular
grid of 3D data. The X and Y directions are regularly spaced while the Z
direction is my height. How do I represent the height using the Structured
Grid? I have tried using vtkScalars but still don't get the surface features to
appear when rendered. Here is a fragment of what I am doing (wrong ???)
Any help would be appreciated
Chris
/*Read in the z data */
fread(&z[0],sizeof(float),NumPoints*Profiles,mod);
fclose(mod);
vtkStructuredPoints *SP = vtkStructuredPoints::New();
SP->SetSpacing(dx,dy,1);
SP->SetOrigin(0,0,0);
SP->SetDimensions(Profiles,NumPoints,1);
vtkScalars *Scalars = vtkScalars::New();
Scalars -> SetNumberOfScalars(NumPoints*Profiles);
for(i=0;i<(NumPoints*Profiles);i++){
Scalars->InsertScalar(i,10*z[i]);
}
SP->GetPointData()->SetScalars(Scalars);
vtkDataSetMapper *SPMapper=vtkDataSetMapper::New();
SPMapper->SetInput(SP);
SPMapper->ScalarVisibilityOff();
vtkActor *Actor=vtkActor::New();
Actor->SetMapper(SPMapper);
Actor->GetProperty()->SetColor(0,0,0);
Actor->GetProperty()->SetRepresentationToWireframe();
vtkRenderer *renderer = vtkRenderer::New();
renderer->SetBackground(1,1,1);
renderer->AddActor(Actor);
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
renWin->SetSize(500,500);
//renWin->SetDesiredUpdateRate(5);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
renWin->Render();
iren->Start();
SPMapper->Delete();
SP->Delete();
free(z);
More information about the vtkusers
mailing list