[vtkusers] Isosurface Extraction

r.jamieson at reading.ac.uk r.jamieson at reading.ac.uk
Tue Apr 15 08:10:25 EDT 2008


Hi Bill,

Thanks, i can now generate an isosurface, but it is all the same colour 
even if i change values, what i would like is to set the isosurface to blue 
(min value) and red (max value) with the scalar range that i have. i have 
tried the following like you suggested.

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

//vtkDataSetMapper *isoMapper = vtkDataSetMapper::New();
vtkPolyDataMapper *isoMapper = vtkPolyDataMapper::New();
    isoMapper->SetInputConnection(iso->GetOutputPort());
    //isoMapper->ScalarVisibilityOn();
    isoMapper->ScalarVisibilityOff();

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

ren1->AddActor(isoActor);
// Set up the lighting.
  //
  vtkLight *light = vtkLight::New();
  light->SetFocalPoint(1.875,0.6125,0);
  light->SetPosition(0.875,1.6125,1);
  ren1->AddLight(light);

  // We want to eliminate perspective effects on the apparent lighting.
  // Parallel camera projection will be used. To zoom in parallel projection
  // mode, the ParallelScale is set.
  //
  ren1->GetActiveCamera()->SetFocalPoint(0,0,0);
  ren1->GetActiveCamera()->SetPosition(0,0,1);
  ren1->GetActiveCamera()->SetViewUp(0,1,0);
  ren1->GetActiveCamera()->ParallelProjectionOn();
  ren1->ResetCamera();
  ren1->GetActiveCamera()->SetParallelScale(1.5);

Thanks for any help

Ronan

On Apr 14 2008, Bill Lorensen wrote:

>It should be
>isoMapper->SetScalarRange(-7, 9);
>actually, you don't need to specify anything if you trun
>ScalarVisibilityOff as suggested below.
>
>but also, your isosurface value has to be in that range.
>
>Try something like:
>iso->SetValue(0, 2);
>
>Finally, if you want to control the color of the actor,
>isoMapper->ScalarVisibilityOff();
>otherwise the actor will be colored using the resulting scalar value
>(2 in the case above).
>
>Bill
>
>
>On Mon, Apr 14, 2008 at 5:25 AM, ronan <r.jamieson at reading.ac.uk> wrote:
>> Hi Bill,
>>
>> I must have been having a mad moment yesterday, my scalar range is 
>> between -7 and 9, does this mean that i should have some thing like
>>
>> isoMapper->SetScalarRange(-7, 9);
>>
>> or
>>
>> isoMapper->SetScalarRange(0, 16);
>>
>>
>> Thanks
>>
>> Ronan
>>
>>
>>
>> Bill Lorensen wrote:
>> > 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