[vtkusers] about vtkMarchingCubes

Vetria Byrd byrdv at cis.uab.edu
Thu Apr 29 11:53:07 EDT 2004


I want to show which vertices are found to be inside and outside the object
by displaying those vertices and edges in different colors:  red (inside)
and blue (outside).

How do I do this?

Thanks,
Vetria

-----Original Message-----
From: vtkusers-admin at vtk.org [mailto:vtkusers-admin at vtk.org] On Behalf Of
Vetria Byrd
Sent: Wednesday, April 28, 2004 8:49 AM
To: 'Mathieu Malaterre'
Cc: vtkusers at vtk.org
Subject: RE: [vtkusers] about vtkMarchingCubes

Mathieu,

Thanks for all of your help.
Vetria

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

Vetria,

	Your code is /almost/ perfect, so the problem comes from your files.

When using vtkImageReader2 you should use

	SetDataExtent(0,5,0,5,0,5);

Otherwise your extent will be different...obviously, as you want a 5x5x5 
picture. Anyway I included a c++ code that show you how to achieve what 
you are looking for. You can play with this code and write the 
vtkIamgeData using vtkImageWriter and then load that file again using 
vtkImageReader2 + proper SetDataExtent and you'll see it will work.

HTH
Mathieu
Ps: For god sake, please avoid static cast like:

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

instead do #include "vtkDataSet.h" top of your c++ file.


Vetria Byrd wrote:
> 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
> 
>>
> 
>> > >
> 
>>
> 
>> >
> 
>>
> 
>> >
> 
>>
> 
>> >
> 
>>
> 
>> >
> 
>>
> 
>> 
> 
>>
> 
>  
> 


_______________________________________________
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




More information about the vtkusers mailing list