//Read transformation in NKI format (Xdr, transposed, cm)
void vvImageReader::ReadNkiImageTransform()
{
- bool bRead=true;
- typedef itk::ImageFileReader< itk::Image< double, 2 > > MatrixReaderType;
- MatrixReaderType::Pointer readerTransfo = MatrixReaderType::New();
- readerTransfo->SetFileName(mInputFilenames[0]+".MACHINEORIENTATION");
- try {
- readerTransfo->Update();
- } catch( itk::ExceptionObject & err ) {
- bRead=false;
- }
-
- if (bRead) {
- //Transpose matrix (NKI format)
- for(int j=0; j<4; j++)
- for(int i=0; i<4; i++)
- mImage->GetTransform()->GetMatrix()->SetElement(j,i,readerTransfo->GetOutput()->GetBufferPointer()[4*i+j]);
-
- //From cm to mm
- for(int i=0; i<3; i++)
- mImage->GetTransform()->GetMatrix()->SetElement(i,3,10*mImage->GetTransform()->GetMatrix()->GetElement(i,3));
-
- mImage->GetTransform()->Inverse();
- mImage->UpdateReslice();
+ bool bRead=false;
+ std::string filename = mInputFilenames[0]+".MACHINEORIENTATION";
+ if(itksys::SystemTools::FileExists(filename.c_str())){
+ typedef itk::ImageFileReader< itk::Image< double, 2 > > MatrixReaderType;
+ MatrixReaderType::Pointer readerTransfo = MatrixReaderType::New();
+ readerTransfo->SetFileName(filename);
+ try {
+ bRead = true;
+ readerTransfo->Update();
+ } catch( itk::ExceptionObject & err ) {
+ bRead=false;
+ std::cerr << "Cannot read " << filename << std::endl
+ << "The error is: " << err << std::endl;
+ }
+
+ if (bRead) {
+ //Transpose matrix (NKI format)
+ for(int j=0; j<4; j++)
+ for(int i=0; i<4; i++)
+ mImage->GetTransform()->GetMatrix()->SetElement(j,i,readerTransfo->GetOutput()->GetBufferPointer()[4*i+j]);
+
+ //From cm to mm
+ for(int i=0; i<3; i++)
+ mImage->GetTransform()->GetMatrix()->SetElement(i,3,10*mImage->GetTransform()->GetMatrix()->GetElement(i,3));
+
+ mImage->GetTransform()->Inverse();
+ mImage->UpdateReslice();
+ }
}
}
//------------------------------------------------------------------------------
m_Output->AddItkImage( reader->GetOutput() );
}
catch ( itk::ExceptionObject & err ) {
- std::cerr << "Error while reading " << filename.toStdString() << std::endl;
+ std::cerr << "Error while reading " << filename.toStdString() << std::endl
+ << "The error is " << err << std::endl;
QString error;
error = QString("Cannot open file %1\n").arg(filename);
QMessageBox::information(this,tr("Reading problem"),error);
float* GetCoordinates(int index);
double GetPixelValue(int index);
std::string GetComments(int index);
- int GetNumberOfPoints() {
- return mLandmarks.size();
- }
+ unsigned int GetNumberOfPoints() { return (unsigned int) mLandmarks.size(); }
//int GetNumberOfSources(){return mText.size();}
vtkPolyData* GetOutput() {
void AddMesh(vtkPolyData* p);
///Removes all meshes in the object
void RemoveMeshes();
- unsigned int GetNumberOfMeshes() { return meshes.size(); }
+ unsigned int GetNumberOfMeshes() { return (unsigned int)meshes.size(); }
vtkImageData* GetMask(unsigned int i) const {return masks[i];}
void AddMask(vtkImageData* im);
void RemoveMasks();
- unsigned int GetNumberOfMasks() { return masks.size(); }
+ unsigned int GetNumberOfMasks() { return (unsigned int)masks.size(); }
///Pretty-print information about the mesh
void Print() const;