[vtkusers] Segmentation fault on calling NextCellIterator of vtkGenericDataSet

Ronald Römer rroemer at googlemail.com
Thu Feb 28 10:42:18 EST 2008


Ok thanks for a first replay! Here is my code snip:

#include <vtkDICOMImageReader.h>
#include <vtkImageGaussianSmooth.h>
#include <vtkMarchingCubes.h>
#include <vtkPolyDataConnectivityFilter.h>
#include <vtkTriangleFilter.h>
#include <vtkSmoothPolyDataFilter.h>
#include <vtkDecimatePro.h>
#include <string>
#include <vtkGenericDataSet.h>
#include <vtkGenericCellIterator.h>
#include <iostream>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>

using namespace std;

class CreateIsosurfaceFromDicom {
    string directoryName;
    vtkPolyDataConnectivityFilter *pelvis_model;

    public:
        CreateIsosurfaceFromDicom(string dirname) {
            this->directoryName = dirname;
        }
        ~CreateIsosurfaceFromDicom() {};

    //private:
        vtkDICOMImageReader *reader;
        void readDicomDir() {
            this->reader = vtkDICOMImageReader::New();
            this->reader->SetDirectoryName(this->directoryName.c_str());
            this->reader->Update();
        }
};

int main(int argc, char *argv[]) {
    string test = argv[1];
    CreateIsosurfaceFromDicom foo(test);
    foo.readDicomDir();

    vtkImageGaussianSmooth *gaussBlur = vtkImageGaussianSmooth::New();
    gaussBlur->SetInputConnection(foo.reader->GetOutputPort());
    gaussBlur->SetStandardDeviation(2);

    vtkMarchingCubes *isosurfaces = vtkMarchingCubes::New();
    isosurfaces->SetInputConnection(gaussBlur->GetOutputPort());
    isosurfaces->SetValue(0,-400);
    isosurfaces->ComputeNormalsOff();

    vtkPolyDataConnectivityFilter *outerIsosurface =
vtkPolyDataConnectivityFilter::New();
    outerIsosurface->SetInputConnection(isosurfaces->GetOutputPort());
    outerIsosurface->SetExtractionModeToLargestRegion();

    vtkDecimatePro *deciMesh = vtkDecimatePro::New();
    deciMesh->SetInputConnection(outerIsosurface->GetOutputPort());
    deciMesh->SetTargetReduction(.85);
    deciMesh->AccumulateErrorOn();

    vtkSmoothPolyDataFilter *smoothMesh = vtkSmoothPolyDataFilter::New();
    smoothMesh->SetInputConnection(deciMesh->GetOutputPort());
    smoothMesh->SetRelaxationFactor(0.25);
    smoothMesh->SetNumberOfIterations(50);

    vtkRenderer *rend = vtkRenderer::New();
    vtkRenderWindow *rwin = vtkRenderWindow::New();
    rwin->AddRenderer(rend);
    vtkRenderWindowInteractor *interact = vtkRenderWindowInteractor::New();
    interact->SetRenderWindow(rwin);

    vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
    mapper->SetInputConnection(smoothMesh->GetOutputPort());
    mapper->ScalarVisibilityOff();

    vtkActor *act = vtkActor::New();
    act->SetMapper(mapper);

    rend->AddActor(act);
    rend->SetBackground(1,1,1);

    rwin->SetSize(640,480);

    interact->Initialize();
    interact->Start();

    vtkGenericDataSet *ds;
    vtkGenericCellIterator *cellIter = ds->NewCellIterator(2);
    cellIter->Begin();
}

Sorry for the bad c++, buts it is only for test cases. In additional here is
my cmake file:

project(PelvisImplaAssembly)
find_package(VTK)
if(VTK_FOUND)
    include(${VTK_USE_FILE})
endif(VTK_FOUND)
add_executable(CreateIsosurfaceFromDicom CreateIsosurfaceFromDicom.cpp)
target_link_libraries(CreateIsosurfaceFromDicom
    vtkFiltering
    vtkIO
    vtkCommon
    vtkHybrid
    vtkImaging
    vtksys)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080228/85a7ae97/attachment.htm>


More information about the vtkusers mailing list