[vtkusers] about vtkMarchingCubes

Vetria Byrd byrdv at cis.uab.edu
Tue Apr 27 13:20:42 EDT 2004


Here's the code (please see note after code):

 

vtkRenderer *ren = vtkRenderer::New();

  vtkRenderWindow *renWin = vtkRenderWindow::New();

    renWin->AddRenderer(ren);

  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

    iren->SetRenderWindow(renWin);

 

  vtkImageReader2 *volReader = vtkImageReader2::New();

      volReader->SetDataOrigin(0.0,0.0,0.0);

    volReader->SetDataExtent(0,6,0,5,0,5);

      volReader->SetDataByteOrderToLittleEndian();

      volReader->SetFilePrefix("C:/src/VolumeData/slice");

 

    volReader->SetDataSpacing(1,1,1);

    volReader->Update();

 

  vtkMarchingCubes *iso = vtkMarchingCubes::New();

     iso->SetInput(volReader->GetOutput() );

       iso->SetValue(0,0.5);

 

  vtkContourFilter *objExtractor = vtkContourFilter::New();

    objExtractor->SetInput((vtkDataSet *) volReader->GetOutput() );

      objExtractor->SetValue(0,0.5);

       

  vtkPolyDataNormals *isoNormals = vtkPolyDataNormals::New();

    isoNormals->SetInput(iso->GetOutput());

    isoNormals->SetFeatureAngle(60.0);

 

  vtkStripper *objStripper = vtkStripper::New();

    objStripper->SetInput(isoNormals->GetOutput());

      

  vtkPolyDataMapper *isoMapper = vtkPolyDataMapper::New();

      isoMapper->SetInput(objStripper->GetOutput() );

        //isoMapper->SetInput(isoNormals->GetOutput() );

      isoMapper->ScalarVisibilityOff();

 

  vtkActor *isoActor = vtkActor::New();

      isoActor->SetMapper(isoMapper);

  

  // An outline provides context around the data.

  vtkOutlineFilter *outlineData = vtkOutlineFilter::New();

    outlineData->SetInput((vtkDataSet *) volReader->GetOutput());

  vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();

    mapOutline->SetInput(outlineData->GetOutput());

  vtkActor *outline = vtkActor::New();

    outline->SetMapper(mapOutline);

    outline->GetProperty()->SetColor(0,0,0);

        

   // Add the actors to the renderer, set the background and size

   ren->AddActor(outline);

   ren->AddActor(isoActor);

   

   ren->SetBackground(1,1,1);  

   renWin->SetSize(450,450);

   

   iren->Initialize();

   

   // render the image

   iren->Start();

 

 

Note:  when I change volReader->SetDataExtent(0,6,0,5,0,5); to 

volReader->SetDataExtent(0,5,0,5,0,5); 

I get this:



 

-----Original Message-----
From: Mathieu Malaterre [mailto:mathieu.malaterre at kitware.com] 
Sent: Tuesday, April 27, 2004 11:54 AM
To: byrdv at cis.uab.edu
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] about vtkMarchingCubes

 

Vetria,

 

      Could you send us the c++ demo file you are using, I suspect you are 

reading your file improperly (data extent is wrong).

 

Thanks

Mathieu

 

Vetria Byrd wrote:

>  

> 

> In the data files slices 0,1,3,4 and 5 contain all zero's.

> 

> In slice 2, cell [2][2][2] = 1 all other cell values are zero's.

> 

>  

> 

> Vetria

> 

>  

> 

> -----Original Message-----

> From: Mathieu Malaterre [mailto:mathieu.malaterre at kitware.com]

> Sent: Tuesday, April 27, 2004 10:50 AM

> To: byrdv at cis.uab.edu

> Cc: vtkusers at vtk.org

> Subject: Re: [vtkusers] about vtkMarchingCubes

> 

>  

> 

> Vetria,

> 

>  

> 

>       Can you send us a screenshot of your problem ?

> 

>  

> 

> Thanks

> 

> Mathieu

> 

>  

> 

> Vetria Byrd wrote:

> 

>>  The dataset consists of 5 files/slices, all containing zero's and one's.

> 

>>  The goal is to take a 5x5x5 volume that contains an object in the center

> 

>>  cell and extract that object. 

> 

>>

> 

>>  Data Spacing is set to:  volReader->SetDataSpacing(1,1,1);

> 

>>

> 

>>  Thanks,

> 

>>  Vetria

> 

>>

> 

>>  -----Original Message-----

> 

>>  From: Mathieu Malaterre [mailto:mathieu.malaterre at kitware.com]

> 

>>  Sent: Monday, April 26, 2004 5:26 PM

> 

>>  To: Vetria Byrd

> 

>>  Cc: vtkusers at vtk.org

> 

>>  Subject: Re: [vtkusers] about vtkMarchingCubes

> 

>>

> 

>>  Vetria,

> 

>>

> 

>>      What type of image are you reading ? Is it possible that you have a

> 

>>  negative spacing ? You might to avoid this.

> 

>>

> 

>>  HTH

> 

>>  Mathieu

> 

>>

> 

>>

> 

>>  Vetria Byrd wrote:

> 

>>

> 

>> >I am having a similiar problem with vtkMarchingCubes as posted at

> 

>> >http://public.kitware.com/pipermail/vtkusers/2003-March/017033.html

> 

>> >but I have not been able to find the reply or answer to the problem.

> 

>> >

> 

>> >I am reading several data files and using vtkMarchingCubes to display
the

> 

>> >reconstructed object, but the positioning of the rendered object seems
to

> 

>> >be off.  It shoud be centered within the view but no matter what I do
it's

> 

>> >always off center.

> 

>> >

> 

>> >Can anyone give me an idea of what could be causing this?

> 

>> >

> 

>> >Thank you,

> 

>> >Vetria

> 

>> >

> 

>> >

> 

>> >

> 

>> >_______________________________________________

> 

>> >This is the private VTK discussion list.

> 

>> >Please keep messages on-topic. Check the FAQ at:

> 

>>

> 

>>  <http://public.kitware.com/cgi-bin/vtkfaq>

> 

>>

> 

>> >Follow this link to subscribe/unsubscribe:

> 

>> >http://www.vtk.org/mailman/listinfo/vtkusers

> 

>> >

> 

>>

> 

>>

> 

>>

> 

>>

> 

>  

> 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040427/70aa1bab/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 3936 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040427/70aa1bab/attachment.jpeg>


More information about the vtkusers mailing list