[vtkusers] Fw: What's wrong with the code?

cly clyao at cugb.edu.cn
Fri Mar 29 04:52:30 EST 2002


----- Original Message ----- 
From: cly 
To: vtkusers at public.kitware.com 
Sent: Friday, March 29, 2002 5:50 PM
Subject: What's wrong with the code?


Hi,

The following codes was the exact example in the vtk book(1998), but I got different results, which I think it were wrong, and have attatched as a series pictures. (I failed twice as a whole picture for its size.)
I changed with many values of isosurfaces, tried to find a smooth 'real' skin of the head, but failed at last.

Someone can help.
Many thanks in advance,

Changli, Yao


/* the program in the book ia as these:*/

//include class definitions
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkVolume16Reader.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkOutlineFilter.h"
#include "vtkCamera.h"
#include "../patented/vtkMarchingCubes.h"
void main(void)
{
//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->SwapBytesOn();
 v16->SetFilePrefix("headsq/quarter");
 v16->SetImageRange(1, 93);
 v16->SetDataSpacing(3.2,3.2,1.5);
 //extract the skin
 vtkMarchingCubes *skinExtractor = vtkMarchingCubes::New();
 skinExtractor->SetInput(v16->GetOutput());
 skinExtractor->SetValue(0, 500);//or (0, 5000),(0, 10000),(0, 40000),(0, 50000),(0,60000)
 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(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();
 //tell the renderer our camera and actors
 aRenderer->AddActor(outline);
 aRenderer->AddActor(skin);
 aRenderer->SetActiveCamera(aCamera);
 aRenderer->ResetCamera();
 aRenderer->SetBackground(1,1,1);
 //interact with data
 renWin->Render();
 iren->Start();
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020329/91fddc39/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtk_head_1.jpg
Type: image/jpeg
Size: 16735 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020329/91fddc39/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtk_head_3.jpg
Type: image/jpeg
Size: 24028 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020329/91fddc39/attachment-0001.jpg>


More information about the vtkusers mailing list