[vtkusers] To create a 3D model of scapula using Marching Cubes

Gulshan Sharma baasho2003 at yahoo.com
Mon Mar 15 16:57:31 EST 2004


Hello to all,
 
I am trying to create a 3D model of a scapula. I am having the CT images 178 slices of the bone. I have been able to convert the slices into a single .mha file and then I have cropped it, and thresholded it to select the bone. Now I have written the binary image as a .mha file.
 
I tried to look at the examples in vtk to make the marching cubes model but could not understand it very well. I tried to apply it to the following code and got some errors
 
The code I used is

#include "vtkRenderer.h"

#include "vtkRenderWindow.h"

#include "vtkRenderWindowInteractor.h"

//#include "vtkVolume16Reader.h"

#include "vtkMetaImageReader.h"

#include "vtkPolyDataMapper.h"

#include "vtkActor.h"

#include "vtkOutlineFilter.h"

#include "vtkCamera.h"

#include "vtkMarchingCubes.h"

void main( int argc, char *argv[] )

{

// create the renderer stuff

vtkRenderer *aRenderer = vtkRenderer::New();

vtkRenderWindow *renWin = vtkRenderWindow::New();

renWin->AddRenderer(aRenderer);

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

iren->SetRenderWindow(renWin);

/*// read the volume

vtkVolume16Reader *v16 = vtkVolume16Reader::New();

v16->SetDataDimensions(64,64);

v16->SetDataByteOrderToLittleEndian();

v16->SetFilePrefix ("E:/Methods in Image Analysis/itk_vtk_fltk/VTK/headsq/quater");

v16->SetImageRange(1, 93);

v16->SetDataSpacing (3.2, 3.2, 1.5);*/

/** Meta Image Reader */

vtkMetaImageReader *v16 = vtkMetaImageReader::New();

v16->SetFileName("Scapula_binary.mha");

v16->Update();

// extract the skin

vtkMarchingCubes *skinExtractor = vtkMarchingCubes::New();

skinExtractor->SetInput(v16->GetOutput());

skinExtractor->SetValue(0, 1);

vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();

skinMapper->SetInput(skinExtractor->GetOutput());

skinMapper->ScalarVisibilityOff();

vtkActor *skin = vtkActor::New();

skin->SetMapper(skinMapper);

// get an outline

vtkOutlineFilter *outlineData = vtkOutlineFilter::New();

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

vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();

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

vtkActor *outline = vtkActor::New();

outline->SetMapper(mapOutline);

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

// create a camera with the correct view up

vtkCamera *aCamera = vtkCamera::New();

aCamera->SetViewUp (0, 0, -1);

aCamera->SetPosition (0, 1, 0);

aCamera->SetFocalPoint (0, 0, 0);

aCamera->ComputeViewPlaneNormal();

// now, tell the renderer our actors

aRenderer->AddActor(outline);

aRenderer->AddActor(skin);

aRenderer->SetActiveCamera(aCamera);

aRenderer->ResetCamera ();

aCamera->Dolly(1.5);

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

aRenderer->ResetCameraClippingRange();



// interact with data

renWin->SetSize( 300, 300);

renWin->Render();

iren->Start(); 

}

 

The errors I am getting are

e:\Methods in Image Analysis\Testing VTK code\Test Marching Cubes\TestMarchingCubes.cxx(51): 

error C2027: use of undefined type 'vtkProperty'


e:\Methods in Image Analysis\Testing VTK code\Test Marching Cubes\TestMarchingCubes.cxx(51):

 error C2227: left of '->SetColor' must point to class/struct/union

 

Can anyone please help me?

 

Thanks

Gulshan


 

 

 

 

 

 

Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040315/2cf82222/attachment.htm>


More information about the vtkusers mailing list