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

Lorensen, William E (CRD) lorensen at crd.ge.com
Fri Mar 29 07:30:26 EST 2002


I'm guessing you are running on an Intel processor.
 
Try changing
v16->SwapBytesOn();
to
v16->SetDataByteOrderToLittleEndian();
 
This will make the reader decide whether or not to swap the bytes.
 
Bill

-----Original Message-----
From: cly [mailto:clyao at cugb.edu.cn]
Sent: Friday, March 29, 2002 4:53 AM
To: vtkusers at public.kitware.com
Subject: [vtkusers] Fw: What's wrong with the code?


 
----- Original Message ----- 
From: cly <mailto:clyao at cugb.edu.cn>  
To: vtkusers at public.kitware.com <mailto: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 <file://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 <file://create>  the renderer stuff
 vtkRenderer *aRenderer = vtkRenderer::New();
 vtkRenderWindow *renWin = vtkRenderWindow::New();
 renWin->AddRenderer(aRenderer);
 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
 iren->SetRenderWindow(renWin);
  //read <file://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 <file://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 <file://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 <file://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 <file://tell>  the renderer our camera and actors
 aRenderer->AddActor(outline);
 aRenderer->AddActor(skin);
 aRenderer->SetActiveCamera(aCamera);
 aRenderer->ResetCamera();
 aRenderer->SetBackground(1,1,1);
  //interact <file://interact>  with data
 renWin->Render();
 iren->Start();
}





More information about the vtkusers mailing list