[vtkusers] Isosurface Extraction

ronan r.jamieson at reading.ac.uk
Sun Apr 13 09:34:36 EDT 2008


Hi,

I am trying to get my head around isosurfaces extraction and i have 
tried to write a c++ program to do a simple extraction, but i cannot see 
any isosurfaces, i have got a wireframe box around the space...but no 
isosurface, i have attached my code

I would be greatful if some one could point out where i have gone wrong.

Thanks in advance

Ronan

int main()
{

char *c1;
// Setup standard rendering

vtkRenderer *ren1 = vtkRenderer::New();
    ren1->SetBackground(0.8,0.8,0.8);

vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren1);
    renWin->SetSize(400,300);

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
 iren->SetRenderWindow(renWin);

//Read data from office simulation data file

vtkDataSetReader *dataSource = vtkDataSetReader::New();
    dataSource->SetFileName("/home/ronan/Develop/Data/office.vtk");
    dataSource->DebugOn();
    dataSource->SetScalarsName(c1);
    dataSource->Update();

// Create and initialize a dataset outline
// The outline of the data puts the data in context.

vtkOutlineFilter *outline = vtkOutlineFilter::New();
    outline->SetInputConnection(dataSource->GetOutputPort());

vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();
    outlineMapper->SetInputConnection(outline->GetOutputPort());

vtkActor *outlineActor = vtkActor::New();
    outlineActor->SetMapper(outlineMapper);
    outlineActor->GetProperty()->SetColor(0, 0, 0);

ren1->AddActor(outlineActor);

//Create an iso-surface using Marching Cubes
vtkContourFilter *iso = vtkContourFilter::New();
    iso->SetInputConnection(dataSource->GetOutputPort());
    iso->ComputeScalarsOn();
    iso->SetValue(0, 14);
    iso->Update();

//vtkDataSetMapper *isoMapper = vtkDataSetMapper::New();
vtkPolyDataMapper *isoMapper = vtkPolyDataMapper::New();
    isoMapper->SetInputConnection(iso->GetOutputPort());
    isoMapper->ScalarVisibilityOn();
    isoMapper->SetScalarModeToUsePointFieldData();
    isoMapper->SetScalarRange(0, 1200);

vtkActor *isoActor = vtkActor::New();
    isoActor->SetMapper(isoMapper);
    isoActor->GetProperty()->SetColor(0.9804, 0.9216, 0.8431);

ren1->AddActor(isoActor);

renWin->Render();
   iren->Start();



More information about the vtkusers mailing list