Ok thanks for a first replay! Here is my code snip:<br><br>#include <vtkDICOMImageReader.h><br>#include <vtkImageGaussianSmooth.h><br>#include <vtkMarchingCubes.h><br>#include <vtkPolyDataConnectivityFilter.h><br>
#include <vtkTriangleFilter.h><br>#include <vtkSmoothPolyDataFilter.h><br>#include <vtkDecimatePro.h><br>#include <string><br>#include <vtkGenericDataSet.h><br>#include <vtkGenericCellIterator.h><br>
#include <iostream><br>#include <vtkRenderer.h><br>#include <vtkRenderWindow.h><br>#include <vtkRenderWindowInteractor.h><br>#include <vtkPolyDataMapper.h><br>#include <vtkActor.h><br><br>
using namespace std;<br><br>class CreateIsosurfaceFromDicom {<br> string directoryName;<br> vtkPolyDataConnectivityFilter *pelvis_model;<br> <br> public:<br> CreateIsosurfaceFromDicom(string dirname) {<br>
this->directoryName = dirname;<br> }<br> ~CreateIsosurfaceFromDicom() {};<br> <br> //private:<br> vtkDICOMImageReader *reader;<br> void readDicomDir() {<br> this->reader = vtkDICOMImageReader::New();<br>
this->reader->SetDirectoryName(this->directoryName.c_str());<br> this->reader->Update();<br> }<br>};<br><br>int main(int argc, char *argv[]) { <br> string test = argv[1];<br>
CreateIsosurfaceFromDicom foo(test);<br> foo.readDicomDir();<br> <br> vtkImageGaussianSmooth *gaussBlur = vtkImageGaussianSmooth::New();<br> gaussBlur->SetInputConnection(foo.reader->GetOutputPort());<br>
gaussBlur->SetStandardDeviation(2);<br> <br> vtkMarchingCubes *isosurfaces = vtkMarchingCubes::New();<br> isosurfaces->SetInputConnection(gaussBlur->GetOutputPort());<br> isosurfaces->SetValue(0,-400);<br>
isosurfaces->ComputeNormalsOff();<br> <br> vtkPolyDataConnectivityFilter *outerIsosurface = vtkPolyDataConnectivityFilter::New();<br> outerIsosurface->SetInputConnection(isosurfaces->GetOutputPort());<br>
outerIsosurface->SetExtractionModeToLargestRegion();<br> <br> vtkDecimatePro *deciMesh = vtkDecimatePro::New();<br> deciMesh->SetInputConnection(outerIsosurface->GetOutputPort());<br> deciMesh->SetTargetReduction(.85);<br>
deciMesh->AccumulateErrorOn();<br> <br> vtkSmoothPolyDataFilter *smoothMesh = vtkSmoothPolyDataFilter::New();<br> smoothMesh->SetInputConnection(deciMesh->GetOutputPort());<br> smoothMesh->SetRelaxationFactor(0.25);<br>
smoothMesh->SetNumberOfIterations(50);<br> <br> vtkRenderer *rend = vtkRenderer::New();<br> vtkRenderWindow *rwin = vtkRenderWindow::New();<br> rwin->AddRenderer(rend);<br> vtkRenderWindowInteractor *interact = vtkRenderWindowInteractor::New();<br>
interact->SetRenderWindow(rwin);<br> <br> vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br> mapper->SetInputConnection(smoothMesh->GetOutputPort());<br> mapper->ScalarVisibilityOff();<br>
<br> vtkActor *act = vtkActor::New();<br> act->SetMapper(mapper);<br> <br> rend->AddActor(act);<br> rend->SetBackground(1,1,1);<br> <br> rwin->SetSize(640,480);<br> <br> interact->Initialize();<br>
interact->Start();<br> <br> vtkGenericDataSet *ds;<br> vtkGenericCellIterator *cellIter = ds->NewCellIterator(2);<br> cellIter->Begin();<br>}<br><br>Sorry for the bad c++, buts it is only for test cases. In additional here is my cmake file:<br>
<br>project(PelvisImplaAssembly)<br>find_package(VTK)<br>if(VTK_FOUND)<br> include(${VTK_USE_FILE})<br>endif(VTK_FOUND)<br>add_executable(CreateIsosurfaceFromDicom CreateIsosurfaceFromDicom.cpp)<br>target_link_libraries(CreateIsosurfaceFromDicom<br>
vtkFiltering<br> vtkIO<br> vtkCommon<br> vtkHybrid<br> vtkImaging<br> vtksys)<br><br>