[vtkusers] Isosurface Extraction

Bill Lorensen bill.lorensen at gmail.com
Sun Apr 13 11:13:02 EDT 2008


What is the scalar range of your input?

Bill

On Sun, Apr 13, 2008 at 9:34 AM, ronan <r.jamieson at reading.ac.uk> wrote:
> 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();
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list