I am trying to get a version of the example surface extraction code running. I had problems with the CMakeLists.txt file, but that has been resolved. My problem now is that I am getting a segmentation fault at the line "meshSource->Update()". I tried using .ima files, and .dcm files located in the same directory
as my .cxx and CMakeLists files. I added a try/catch block around this line as Luis suggested and re-built the example, but the program still faults out at that location. I am running the executable with the
command "SurfaceExtraction CT0001.dcm 400". <br><br>The relevant .cxx file code is as follows:<br><br>//Surface Extraction code modified from ITK Surface Extraction Example included in ITK build<br>#if defined(_MSC_VER)
<br>#pragma warning ( disable : 4786 )<br>#endif<br><br>#ifdef __BORLANDC__<br>#define ITK_LEAN_AND_MEAN<br>#endif<br><br>#include "itkImageFileReader.h"<br>#include "itkBinaryMask3DMeshSource.h"<br>#include "
itkImage.h"<br>#include "itkMesh.h"<br>#include <iostream><br>using namespace std;<br><br>int main(int argc, char * argv[] ) <br>{<br><br> if( argc < 3 )<br> {<br> std::cerr << "Usage: IsoSurfaceExtraction inputImageFile objectValue " << std::endl;
<br> return EXIT_FAILURE;<br> }<br><br> const unsigned int Dimension = 3;<br> typedef unsigned char PixelType;<br><br> typedef itk::Image< PixelType, Dimension > ImageType;<br> typedef itk::ImageFileReader< ImageType > ReaderType;
<br> ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName( argv[1] );<br><br> try<br> {<br> reader->Update();<br> }<br> catch( itk::ExceptionObject & exp )<br> {<br> std::cerr << "Exception thrown while reading the input file " << std::endl;
<br> std::cerr << exp << std::endl;<br> return EXIT_FAILURE;<br> }<br><br> typedef itk::Mesh<double> MeshType;<br> typedef itk::BinaryMask3DMeshSource< ImageType, MeshType > MeshSourceType;
<br> MeshSourceType::Pointer meshSource = MeshSourceType::New();<br><br> const PixelType objectValue = static_cast<PixelType>( atof( argv[2] ) );<br><br> meshSource->SetObjectValue( objectValue );<br><br> cout << "Before meshSource input set." << endl;
<br> try<br> {<br> meshSource->SetInput( reader->GetOutput() );<br> }<br> catch( itk::ExceptionObject & exp )<br> {<br> std::cerr << "Exception thrown during setting mesh input() " << std::endl;
<br> std::cerr << exp << std::endl;<br> return EXIT_FAILURE;<br> }<br><br> cout << "Before meshSource update" << endl;<br> try<br> {<br> meshSource->Update(); //--------------------------SEGMENTATION FAULT HERE--------------------------------------------
<br> }<br> catch( itk::ExceptionObject & exp )<br> {<br> cerr << "Exception thrown during Update() " << std::endl;<br> cerr << exp << std::endl;<br> return EXIT_FAILURE;
<br> }<br><br> cout << "Nodes = " << meshSource->GetNumberOfNodes() << std::endl;<br> cout << "Cells = " << meshSource->GetNumberOfCells() << std::endl;<br>
<br> return EXIT_SUCCESS;<br>}<br><br>Does anyone have any suggestions?<br><br>Thanks,<br>Catherine<br><br>