[vtkusers] marching cubes output
Vetria Byrd
byrdv at cis.uab.edu
Wed Apr 7 16:05:07 EDT 2004
I have written a program to extract data from 2D slices of data files.
Five data files were manually created. Each of the data files look like
this:
0 0 0 0 0
0 0 0 0 0
0 0 1 0 0
0 0 1 0 0
0 0 0 0 0
0 0 0 0 0
Where the 0's indicate the object is outside the cube and 1 indicates the
object is inside the cube.
When I run the program (which compiles and runs with no problems) I expected
to get a solid object representing the center of the 5x5x5 rendered object
since only the center values of the data (input) show that the object is
inside but what I get is shown in the 1st figure. Viewing the wire frame
display (2nd figure) shows the 5x5x5 grid with an unexpected dip in the top
row.
I am missing something, I just don't know what that "something" is.
What I want the algorithm to do is render the object based on which values
of the data indicate the object is present.
Here's the code:
//
// This example reads a volume dataset, extracts an isosurface and displays
it.
//
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkVolumeReader.h"
#include "vtkImageReader2.h"
#include "vtkMarchingCubes.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkOutlineFilter.h"
#include "vtkCamera.h"
#include "vtkProperty.h"
#include "vtkPolyDataNormals.h"
#include "vtkContourFilter.h"
int main ()
{
vtkRenderer *ren = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkImageReader2 *volReader = vtkImageReader2::New();
volReader->SetDataExtent(0,5,0,5,0,5);
volReader->SetFilePrefix("C:/data/cube/slice");
volReader->SetDataSpacing(1,1,1);
volReader->Update();
// An isosurface, or contour value of 1 is known to correspond to the
// object
vtkMarchingCubes *iso =vtkMarchingCubes::New();
iso->SetInput(volReader->GetOutput() );
iso->SetValue(0,1);
vtkPolyDataMapper *isoMapper = vtkPolyDataMapper::New();
isoMapper->SetInput(iso->GetOutput() );
vtkActor *isoActor = vtkActor::New();
isoActor->SetMapper(isoMapper);
vtkOutlineFilter *outline = vtkOutlineFilter::New();
outline->SetInput( (vtkDataSet *) volReader->GetOutput() );
vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();
outlineMapper->SetInput(outline->GetOutput() );
vtkActor *outlineActor = vtkActor::New();
outlineActor->SetMapper(outlineMapper);
outlineActor->VisibilityOff();
//
// Add the actors to the renderer, set the background and size
//
ren->AddActor(outlineActor);
ren->AddActor(isoActor);
ren->SetBackground(0.2,0.3,0.4);
renWin->SetSize(450,450);
ren->GetActiveCamera()->Elevation(90);
ren->GetActiveCamera()->SetViewUp(0,0,-1);
iren->Initialize();
// render the image
iren->Start();
return 0;
}
Thanks.
_______________
Vetria L. Byrd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040407/e6204e01/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 9033 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040407/e6204e01/attachment.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 15856 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040407/e6204e01/attachment-0001.jpeg>
More information about the vtkusers
mailing list