[vtkusers] surfacique representation
medamine
miladimedamine at yahoo.fr
Mon Apr 30 10:23:50 EDT 2007
Hi,i m using this pipline to get surfacique reconstruction:
vtkvolume16reader--->vtkextractVoi---->vtkmarchingcube.
My probleme is that i get the volume represented with parallel plans and not
a surfacique representation as it should been.
For exemple if slices are circle i get cylindre represented with
perpenducular plans.
there is an exempleof result: http://www.nabble.com/file/8157/exemple.JPG
exemple.JPG
This is my code bellow:
#include "stdafx.h"
#include "vtkCellArray.h"
#include "vtkFloatArray.h"
#include "vtkPointData.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkProperty.h"
#include "vtkVolume16Reader.h"
#include "vtkCell.h"
#include "vtkMarchingCubes.h"
#include "vtkImageData.h"
#include "vtkExtractVOI.h"
#include "vtkDecimate.h"
#include "vtkTransformPolyDataFilter.h"
int main(int argc, char * argv[])
{
//first convert series slices of image into volume data
vtkVolume16Reader *m_reader=vtkVolume16Reader::New();
m_reader->SetDataDimensions(96,96);
m_reader->SetImageRange(1,22);
m_reader->SetDataByteOrderToLittleEndian();
m_reader->SetFilePrefix("C:\\test3\\EpicardeSegmente00");
m_reader->SetFilePattern("%s%.d.bmp");
m_reader->SetDataSpacing(1,1,2.5);
m_reader->Update();
float *range=m_reader->GetOutput()->GetScalarRange();
printf("%f\t%f\n",range[0],range[1]);
//second Extract a Volume of Interest
vtkExtractVOI *extractor=vtkExtractVOI::New();
extractor->SetInput(m_reader->GetOutput());
extractor->SetVOI(10,40,0,80,0,100);
//extractor->SetSampleRate(10,200,00);
//third execute the vtkmarching cube
vtkMarchingCubes *m_cube = vtkMarchingCubes::New();
vtkPolyData *m_polydata = vtkPolyData::New();
m_cube->SetValue(0,60000);
m_cube->ComputeNormalsOn();
m_cube->ComputeGradientsOn();
m_cube->ComputeScalarsOn();
m_cube->CreateDefaultLocator();
m_cube->SetInput(extractor->GetOutput());
m_cube->Update();
//Decimate The Triangles
vtkDecimate *decimator=vtkDecimate::New();
decimator->SetInput(m_cube->GetOutput());
decimator->SetInitialFeatureAngle(20);
decimator->SetMaximumIterations(1000);
decimator->SetMaximumSubIterations(0);
decimator->PreserveEdgesOn();
decimator->SetMaximumError(1);
decimator->SetTargetReduction(100);
decimator->SetInitialError(200);
decimator->SetErrorIncrement(100);
m_polydata= m_cube->GetOutput();
m_polydata->Update();
vtkPolyDataMapper *m_polydataMapper = vtkPolyDataMapper::New();
m_polydataMapper->SetInput(m_polydata);
m_polydataMapper->SetScalarRange(1,18);
vtkActor *m_Actor = vtkActor::New();
m_Actor->AddOrientation(90,200,50);
//m_Actor->GetProperty()->SetRepresentationToWireframe();
m_Actor->SetMapper(m_polydataMapper);
vtkRenderer *m_renderer = vtkRenderer::New();
vtkRenderWindow *m_renWin = vtkRenderWindow::New();
m_renWin->AddRenderer(m_renderer);
vtkRenderWindowInteractor *m_iren = vtkRenderWindowInteractor::New();
m_iren->SetRenderWindow(m_renWin);
vtkInteractorStyleTrackballCamera *m_style
=vtkInteractorStyleTrackballCamera::New();
m_iren->SetInteractorStyle(m_style);
m_renderer->AddActor(m_Actor);
m_renderer->SetBackground(0.1, 0.2, 0.4);
m_renWin->SetSize(300,300);
m_renWin->Render();
m_iren->Start();
m_cube->Delete();
m_polydata->Delete();
m_polydataMapper->Delete();
m_Actor->Delete();
m_renderer->Delete();
m_renWin->Delete();
m_iren->Delete();
return 0;
}
--
View this message in context: http://www.nabble.com/surfacique-representation-tf3669874.html#a10254245
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list