return GetRotationMatrix3D(rotationParameters);
}
+//--------------------------------------------------------------------
+itk::Matrix<double, 4, 4> ReadMatrix3D(std::string fileName)
+{
+ // read input matrix
+ std::ifstream is;
+ openFileForReading(is, fileName);
+ std::vector<double> nb;
+ double x;
+ skipComment(is);
+ is >> x;
+ while (is && !is.eof()) {
+ nb.push_back(x);
+ skipComment(is);
+ is >> x;
+ }
+
+ if(nb.size() != 16)
+ itkGenericExceptionMacro(<< "Could not read 4x4 matrix in " << fileName);
+
+ //copy it to the matrix
+ itk::Matrix<double, 4, 4> matrix;
+ unsigned int index=0;
+ for (unsigned int i=0;i<4;i++)
+ for (unsigned int j=0;j<4;j++)
+ matrix[i][j]=nb[index++];
+ return matrix;
+}
+
}
return matrix;
}
- inline itk::Matrix<double, 4, 4> ReadMatrix3D(std::string fileName)
- {
- // read input matrix
- std::ifstream is;
- openFileForReading(is, fileName);
- std::vector<double> nb;
- double x;
- skipComment(is);
- is >> x;
- while (!is.eof()) {
- nb.push_back(x);
- skipComment(is);
- is >> x;
- }
-
- //copy it to the matrix
- itk::Matrix<double, 4, 4> matrix;
- unsigned int index=0;
- for (unsigned int i=0;i<4;i++)
- for (unsigned int j=0;j<4;j++)
- matrix[i][j]=nb[index++];
- return matrix;
- }
+ itk::Matrix<double, 4, 4> ReadMatrix3D(std::string fileName);
inline vtkMatrix4x4* ReadVTKMatrix3D(std::string fileName) {
// read input matrix
if(f.is_open()) {
f.close();
- itk::Matrix<double, 4, 4> itkMat = clitk::ReadMatrix3D(filename);
+ itk::Matrix<double, 4, 4> itkMat;
+ itkMat.SetIdentity();
+ try {
+ itkMat = clitk::ReadMatrix3D(filename);
+ }
+ catch (itk::ExceptionObject & err) {
+ itkWarningMacro(<< "Found " << filename
+ << " but this is not a 4x4 matrix so it is ignored.");
+ }
vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
matrix->Identity();