27 #include <itkAffineTransform.h> 28 #include <itkVersorRigid3DTransform.h> 29 #include <itkRigid3DTransform.h> 30 #include <itkCenteredEuler3DTransform.h> 31 #include <itkEuler3DTransform.h> 32 #include <itkTransformFileWriter.h> 36 #include <vtkOBJReader.h> 37 #include <vtkSTLReader.h> 38 #include <vtkSTLWriter.h> 39 #include <vtkPLYReader.h> 40 #include <vtkPLYWriter.h> 41 #include <vtkPolyDataReader.h> 42 #include <vtkUnstructuredGridReader.h> 43 #include <vtkGeometryFilter.h> 44 #include <vtkPolyDataWriter.h> 45 #include <vtkXMLPolyDataReader.h> 46 #include <vtkXMLPolyDataWriter.h> 47 #include <vtkXMLImageDataReader.h> 48 #include <vtkXMLImageDataWriter.h> 49 #include <vtkDelimitedTextReader.h> 50 #include <vtkDelimitedTextWriter.h> 61 itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode);
73 itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode);
74 imageIO->SetFileName(filename.c_str());
77 imageIO->ReadImageInformation();
79 catch( itk::ExceptionObject & err )
81 std::cerr <<
"File Exception caught while reading header!" << std::endl;
82 std::cerr << err << std::endl;
86 pixeltype = imageIO->GetPixelTypeAsString(imageIO->GetPixelType());
87 componentType = imageIO->GetComponentTypeAsString(imageIO->GetComponentType());
88 dimensions = imageIO->GetNumberOfDimensions();
98 std::vector<std::string> extensions;
101 std::list<itk::LightObject::Pointer> allobjects = itk::ObjectFactoryBase::CreateAllInstance(
"itkImageIOBase");
102 for(std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin(); i != allobjects.end(); ++i)
104 itk::ImageIOBase* imageIO =
dynamic_cast<itk::ImageIOBase*
>(i->GetPointer());
107 for(
size_t j = 0; j < imageIO->GetSupportedReadExtensions().size(); j ++)
108 extensions.push_back(imageIO->GetSupportedReadExtensions()[j]);
117 std::vector<std::string> UIDs;
118 typedef itk::GDCMSeriesFileNames GeneratorType;
119 GeneratorType::Pointer nameGenerator = GeneratorType::New();
120 nameGenerator->SetUseSeriesDetails(
true);
122 nameGenerator->RecursiveOn();
123 nameGenerator->AddSeriesRestriction(
"0020|0010");
124 nameGenerator->AddSeriesRestriction(
"0018|0024");
125 nameGenerator->AddSeriesRestriction(
"0018|0086");
126 nameGenerator->AddSeriesRestriction(
"0008|0021");
127 nameGenerator->AddSeriesRestriction(
"0020|0011");
128 nameGenerator->AddSeriesRestriction(
"0020|0012");
131 nameGenerator->SetDirectory(directoryPath.c_str());
132 nameGenerator->AddObserver(itk::ProgressEvent(), ProgressUpdates);
133 #if (ITK_VERSION_MAJOR > 3) 136 nameGenerator->Update();
138 catch (itk::ExceptionObject &excp)
140 std::cerr <<
"File Exception caught while reading filenames in directory!" << std::endl;
141 std::cerr << excp << std::endl;
146 UIDs = nameGenerator->GetSeriesUIDs();
153 std::vector<std::string> filenames;
154 typedef itk::GDCMSeriesFileNames GeneratorType;
155 GeneratorType::Pointer nameGenerator = GeneratorType::New();
156 nameGenerator->SetUseSeriesDetails(
true);
158 nameGenerator->RecursiveOn();
159 nameGenerator->AddSeriesRestriction(
"0020|0010");
160 nameGenerator->AddSeriesRestriction(
"0018|0024");
161 nameGenerator->AddSeriesRestriction(
"0018|0086");
162 nameGenerator->AddSeriesRestriction(
"0008|0021");
163 nameGenerator->AddSeriesRestriction(
"0020|0011");
164 nameGenerator->AddSeriesRestriction(
"0020|0012");
167 nameGenerator->SetDirectory(directoryPath.c_str());
168 nameGenerator->AddObserver(itk::ProgressEvent(), ProgressUpdates);
169 #if (ITK_VERSION_MAJOR > 3) 172 nameGenerator->Update();
174 catch (itk::ExceptionObject &excp)
176 std::cerr <<
"File Exception caught while reading filenames in directory!" << std::endl;
177 std::cerr << excp << std::endl;
182 filenames = nameGenerator->GetFileNames(seriesName);
192 vtkMatrix4x4 * matrix = vtkMatrix4x4::New();
195 typedef itk::TransformFileReader TransformReaderType;
196 typedef TransformReaderType::TransformListType * TransformListType;
197 typedef itk::AffineTransform< double, 3 > AffineTransformType;
198 typedef AffineTransformType::Pointer AffineTransformPointer;
199 typedef itk::VersorRigid3DTransform<double> VersorRigidTransformType;
200 typedef VersorRigidTransformType::Pointer VersorRigidTransformPointer;
201 typedef itk::Rigid3DTransform<double> RigidTransformType;
202 typedef RigidTransformType::Pointer RigidTransformPointer;
203 typedef itk::CenteredEuler3DTransform<double> CenteredEuler3DTransformType;
204 typedef CenteredEuler3DTransformType::Pointer CenteredEuler3DTransformPointer;
205 typedef itk::Euler3DTransform<double> Euler3DTransformType;
206 typedef Euler3DTransformType::Pointer Euler3DTransformPointer;
208 TransformReaderType::Pointer affineReader = TransformReaderType::New();
209 affineReader->SetFileName(filename);
210 affineReader->AddObserver(itk::ProgressEvent(), milx::ProgressUpdates);
213 affineReader->Update();
215 catch(itk::ExceptionObject &ex)
217 PrintError(
"milxFile: Failed reading Transform " + std::string(ex.GetDescription()));
220 TransformListType transforms = affineReader->GetTransformList();
221 TransformReaderType::TransformListType::const_iterator tit = transforms->begin();
222 AffineTransformPointer affineTransform;
223 VersorRigidTransformPointer versorRigidTransform;
224 RigidTransformPointer rigidTransform;
225 CenteredEuler3DTransformPointer centeredEulerTransform;
226 Euler3DTransformPointer euler3DTransform;
228 if( !strcmp((*tit)->GetNameOfClass(),
"AffineTransform") )
230 AffineTransformPointer affine_read =
static_cast<AffineTransformType*
>((*tit).GetPointer());
231 affineTransform =
dynamic_cast< AffineTransformType *
>( affine_read.GetPointer() );
232 if( affineTransform )
234 PrintInfo(
"Successfully Read Affine Transform file.");
238 PrintError(
"milxFile: Transform is not of Affine Transform Type. Returning Identity.");
242 for (
unsigned long i = 0; i < 3; i++)
244 matrix->SetElement(i, 0, affineTransform->GetMatrix()(i,0));
245 matrix->SetElement(i, 1, affineTransform->GetMatrix()(i,1));
246 matrix->SetElement(i, 2, affineTransform->GetMatrix()(i,2));
247 matrix->SetElement(i, 3, affineTransform->GetOffset()[i]);
250 else if( !strcmp((*tit)->GetNameOfClass(),
"VersorRigid3DTransform") )
252 VersorRigidTransformPointer rigid_read =
static_cast<VersorRigidTransformType*
>((*tit).GetPointer());
253 versorRigidTransform =
dynamic_cast< VersorRigidTransformType *
>( rigid_read.GetPointer() );
254 if( versorRigidTransform )
256 PrintInfo(
"Successfully Read Versor Rigid Transform file.");
260 PrintError(
"milxFile: Transform Input is not of Versor Rigid Type. Returning Identity.");
264 for (
unsigned long i = 0; i < 3; i++)
266 matrix->SetElement(i, 0, versorRigidTransform->GetMatrix()(i,0));
267 matrix->SetElement(i, 1, versorRigidTransform->GetMatrix()(i,1));
268 matrix->SetElement(i, 2, versorRigidTransform->GetMatrix()(i,2));
269 matrix->SetElement(i, 3, versorRigidTransform->GetOffset()[i]);
272 else if( !strcmp((*tit)->GetNameOfClass(),
"Rigid3DTransform") )
274 RigidTransformPointer rigid_read =
static_cast<RigidTransformType*
>((*tit).GetPointer());
275 rigidTransform =
dynamic_cast< RigidTransformType *
>( rigid_read.GetPointer() );
278 PrintInfo(
"Successfully Read Rigid Transform file.");
282 PrintError(
"milxFile: Transform Input is not of Rigid Type. Returning Identity.");
286 for (
unsigned long i = 0; i < 3; i++)
288 matrix->SetElement(i, 0, rigidTransform->GetMatrix()(i,0));
289 matrix->SetElement(i, 1, rigidTransform->GetMatrix()(i,1));
290 matrix->SetElement(i, 2, rigidTransform->GetMatrix()(i,2));
291 matrix->SetElement(i, 3, rigidTransform->GetOffset()[i]);
294 else if( !strcmp((*tit)->GetNameOfClass(),
"CenteredEuler3DTransform") )
296 CenteredEuler3DTransformPointer rigid_read =
static_cast<CenteredEuler3DTransformType*
>((*tit).GetPointer());
297 centeredEulerTransform =
dynamic_cast< CenteredEuler3DTransformType *
>( rigid_read.GetPointer() );
298 if( centeredEulerTransform )
300 PrintInfo(
"Successfully Read Centered Euler 3D Transform file.");
304 PrintError(
"milxFile: Transform Input is not of Centered Euler 3D Type. Returning Identity.");
308 for (
unsigned long i = 0; i < 3; i++)
310 matrix->SetElement(i, 0, centeredEulerTransform->GetMatrix()(i,0));
311 matrix->SetElement(i, 1, centeredEulerTransform->GetMatrix()(i,1));
312 matrix->SetElement(i, 2, centeredEulerTransform->GetMatrix()(i,2));
313 matrix->SetElement(i, 3, centeredEulerTransform->GetOffset()[i]);
316 else if( !strcmp((*tit)->GetNameOfClass(),
"Euler3DTransform") )
318 Euler3DTransformPointer rigid_read =
static_cast<Euler3DTransformType*
>((*tit).GetPointer());
319 euler3DTransform =
dynamic_cast< Euler3DTransformType *
>( rigid_read.GetPointer() );
320 if( euler3DTransform )
322 PrintInfo(
"Successfully Read Euler 3D Transform file.");
326 PrintError(
"milxFile: Transform Input is not of Euler 3D Type. Returning Identity.");
330 for (
unsigned long i = 0; i < 3; i++)
332 matrix->SetElement(i, 0, euler3DTransform->GetMatrix()(i,0));
333 matrix->SetElement(i, 1, euler3DTransform->GetMatrix()(i,1));
334 matrix->SetElement(i, 2, euler3DTransform->GetMatrix()(i,2));
335 matrix->SetElement(i, 3, euler3DTransform->GetOffset()[i]);
340 PrintError(
"milxFile: Transform Input is not of known type");
348 vtkMatrix4x4 * matrix = vtkMatrix4x4::New();
350 char * buffer =
new char[512];
351 gzFile fin = ::gzopen( filename.c_str(),
"rb" );
354 cerr <<
"Cannot read " << filename << endl;
357 buffer = ::gzgets (fin, buffer, 512);
360 cerr <<
"File is not a transform file" << endl;
362 buffer = ::gzgets (fin, buffer, 512);
363 if((buffer[0] != 0) && (buffer[1] !=
'8'))
366 cerr << buffer << endl;
367 cerr <<
"File is not a transform file" << endl;
373 for (
unsigned long i = 0; i < 4; i++)
376 buffer = ::gzgets (fin, buffer, 512);
379 sscanf(buffer,
"%s %s %s %s", &str1[0], &str2[0], &str3[0], &str4[0]);
380 matrix->SetElement(i, 0, atof(str1));
381 matrix->SetElement(i, 1, atof(str2));
382 matrix->SetElement(i, 2, atof(str3));
383 matrix->SetElement(i, 3, atof(str4));
384 std::cout << atof(str1) <<
" " << atof(str2) <<
" " << atof(str3) <<
" " << atof(str4) << std::endl;
386 buffer = ::gzgets (fin, buffer, 512);
389 cerr << buffer << endl;
390 cerr <<
"File is not a transform file" << endl;
397 void File::SaveITKTransform(std::string filename,
const vtkMatrix4x4 * matrix)
400 typedef itk::AffineTransform<double,3> TransformType;
401 TransformType::Pointer transform = TransformType::New();
402 TransformType::MatrixType itkmat;
404 for (
size_t i=0; i<3; i++) {
405 for (
size_t j=0; j<3; j++) {
406 itkmat(i,j) = matrix->GetElement(i,j);
409 transform->SetMatrix(itkmat);
411 TransformType::OutputVectorType trans;
412 trans[0] = matrix->GetElement(0,3);
413 trans[1] = matrix->GetElement(1,3);
414 trans[2] = matrix->GetElement(2,3);
415 transform->SetTranslation(trans);
418 typedef itk::TransformFileWriter TransformWriterType;
419 TransformWriterType::Pointer transformWriter = TransformWriterType::New();
420 transformWriter->SetFileName(filename);
421 transformWriter->SetInput(transform);
423 transformWriter->Update();
424 }
catch( itk::ExceptionObject & err) {
425 std::cerr <<
"Exception occurred while writing transform file:\n " << filename << std::endl;
426 std::cerr << err << std::endl;
427 std::cout << err.what() << std::endl;
441 void File::SaveVTKTransform(std::string filename,
const vtkMatrix4x4 * matrix)
447 gzFile fout = ::gzopen( filename.c_str(),
"wb" );
451 cerr <<
"Cannot open for writing: " << filename << endl;
454 ::gzputs(fout,
"(\n08\n");
456 for (
unsigned long i = 0; i < 4; i++)
458 ::gzprintf(fout,
"%- 24.18g %- 24.18g %- 24.18g %- 24.18g\n", matrix->GetElement(i, 0), matrix->GetElement(i, 1), matrix->GetElement(i, 2), matrix->GetElement(i, 3));
461 ::gzputs(fout,
")\n");
466 FILE * fout = ::fopen( filename.c_str(),
"wb" );
470 cerr <<
"Cannot open for writing: " << filename << endl;
473 ::fputs(
"(\n08\n", fout);
475 for (
unsigned long i = 0; i < 4; i++)
477 ::fprintf(fout,
"%- 24.18g %- 24.18g %- 24.18g %- 24.18g\n", matrix->GetElement(i, 0), matrix->GetElement(i, 1), matrix->GetElement(i, 2), matrix->GetElement(i, 3));
480 ::fputs(
")\n", fout);
490 bool legacy =
false, wavefront =
false, stanford =
false, stereoLith =
false;
493 if (extension ==
"vtk")
495 else if (extension ==
"obj")
497 else if (extension ==
"ply")
499 else if(extension ==
"stl")
503 PrintError(
"milxFile: PolyData pointer is not NULL. May get a memory leak.");
505 vtkSmartPointer<vtkErrorWarning> errorObserver = vtkSmartPointer<vtkErrorWarning>::New();
509 vtkSmartPointer<vtkDataReader> dreader = vtkSmartPointer<vtkDataReader>::New();
510 dreader->SetFileName(filename.c_str());
511 dreader->AddObserver(vtkCommand::ErrorEvent, errorObserver);
512 dreader->OpenVTKFile();
513 dreader->ReadHeader();
514 dreader->CloseVTKFile();
516 if(dreader->IsFilePolyData())
519 vtkSmartPointer<vtkPolyDataReader> reader = vtkSmartPointer<vtkPolyDataReader>::New();
520 reader->SetFileName(filename.c_str());
521 reader->AddObserver(vtkCommand::ErrorEvent, errorObserver);
524 if(!errorObserver->ReportsFailure())
526 data = reader->GetOutput();
530 else if(dreader->IsFileUnstructuredGrid())
533 vtkSmartPointer<vtkUnstructuredGridReader> reader = vtkSmartPointer<vtkUnstructuredGridReader>::New();
534 reader->SetFileName(filename.c_str());
535 reader->AddObserver(vtkCommand::ErrorEvent, errorObserver);
538 vtkSmartPointer<vtkGeometryFilter> geometryFilter = vtkSmartPointer<vtkGeometryFilter>::New();
539 geometryFilter->SetInputConnection(reader->GetOutputPort());
540 geometryFilter->Update();
542 if(!errorObserver->ReportsFailure())
544 data = geometryFilter->GetOutput();
550 PrintError(
"VTK Legacy Data Type Not Supported.");
555 vtkSmartPointer<vtkOBJReader> reader = vtkSmartPointer<vtkOBJReader>::New();
556 reader->SetFileName(filename.c_str());
557 reader->AddObserver(vtkCommand::ErrorEvent, errorObserver);
560 if (!errorObserver->ReportsFailure())
562 data = reader->GetOutput();
568 vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
569 reader->SetFileName(filename.c_str());
570 reader->AddObserver(vtkCommand::ErrorEvent, errorObserver);
573 if (!errorObserver->ReportsFailure())
575 data = reader->GetOutput();
581 vtkSmartPointer<vtkSTLReader> reader = vtkSmartPointer<vtkSTLReader>::New();
582 reader->SetFileName(filename.c_str());
583 reader->AddObserver(vtkCommand::ErrorEvent, errorObserver);
586 if (!errorObserver->ReportsFailure())
588 data = reader->GetOutput();
594 vtkSmartPointer<vtkXMLPolyDataReader> reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
595 reader->SetFileName(filename.c_str());
596 reader->AddObserver(vtkCommand::ErrorEvent, errorObserver);
599 if (!errorObserver->ReportsFailure())
601 data = reader->GetOutput();
606 PrintError(
"Reader Encountered the following error.");
613 collection = vtkSmartPointer<vtkPolyDataCollection>::New();
615 for(std::vector<std::string>::iterator name = filenames.begin(); name != filenames.end(); name ++)
617 vtkSmartPointer<vtkPolyData> surface;
622 collection->AddItem( surface );
628 bool File::SaveModel(
const std::string filename, vtkSmartPointer<vtkPolyData> data,
const bool binary)
630 bool legacy =
false, stanford =
false, stereoLith =
false;
633 if (extension ==
"vtk")
635 else if (extension ==
"ply")
637 else if(extension ==
"stl")
642 PrintError(
"PolyData pointer is NULL. Not saving.");
648 vtkSmartPointer<vtkPolyDataWriter> writer = vtkSmartPointer<vtkPolyDataWriter>::New();
649 writer->SetFileName(filename.c_str());
650 #if VTK_MAJOR_VERSION <= 5 651 writer->SetInput(data);
653 writer->SetInputData(data);
659 vtkSmartPointer<vtkPLYWriter> writer = vtkSmartPointer<vtkPLYWriter>::New();
660 writer->SetFileName(filename.c_str());
661 #if VTK_MAJOR_VERSION <= 5 662 writer->SetInput(data);
664 writer->SetInputData(data);
670 vtkSmartPointer<vtkSTLWriter> writer = vtkSmartPointer<vtkSTLWriter>::New();
671 writer->SetFileName(filename.c_str());
672 #if VTK_MAJOR_VERSION <= 5 673 writer->SetInput(data);
675 writer->SetInputData(data);
681 vtkSmartPointer<vtkXMLPolyDataWriter> writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New();
682 writer->SetFileName(filename.c_str());
683 #if VTK_MAJOR_VERSION <= 5 684 writer->SetInput(data);
686 writer->SetInputData(data);
689 writer->SetDataModeToBinary();
690 writer->SetCompressorTypeToZLib();
697 bool File::SaveModelCollection(std::vector<std::string> filenames, vtkSmartPointer<vtkPolyDataCollection> collection,
const bool binary)
699 collection->InitTraversal();
700 for(std::vector<std::string>::iterator name = filenames.begin(); name != filenames.end(); name ++)
713 PrintError(
"Transform pointer is NULL. Not saving.");
718 SaveITKTransform(filename, data->GetMatrix());
720 SaveVTKTransform(filename, data->GetMatrix());
728 collection->InitTraversal();
729 for(std::vector<std::string>::iterator name = filenames.begin(); name != filenames.end(); name ++)
741 vtkSmartPointer<vtkDelimitedTextReader> csv_vert_source = vtkSmartPointer<vtkDelimitedTextReader>::New();
742 csv_vert_source->SetFieldDelimiterCharacters(delimiter.c_str());
743 csv_vert_source->DetectNumericColumnsOn();
744 csv_vert_source->SetHaveHeaders(
true);
745 csv_vert_source->SetFileName(filename.c_str());
746 csv_vert_source->Update();
749 data = csv_vert_source->GetOutput();
757 vtkSmartPointer<vtkDelimitedTextWriter> csv_vert_source = vtkSmartPointer<vtkDelimitedTextWriter>::New();
758 csv_vert_source->SetFieldDelimiter(delimiter.c_str());
759 csv_vert_source->SetFileName(filename.c_str());
760 #if VTK_MAJOR_VERSION <= 5 761 csv_vert_source->SetInput(data);
763 csv_vert_source->SetInputData(data);
765 csv_vert_source->Write();
770 bool File::SaveCamera(
const std::string filename,
const vtkSmartPointer<vtkCamera> camera)
772 if(!camera || filename.empty())
775 ofstream file(filename.c_str(), ios::out);
780 file << camera->GetClippingRange()[0] <<
" " 781 << camera->GetClippingRange()[1] <<
" " 783 << camera->GetFocalPoint()[0] <<
" " 784 << camera->GetFocalPoint()[1] <<
" " 785 << camera->GetFocalPoint()[2] <<
" " 787 << camera->GetPosition()[0] <<
" " 788 << camera->GetPosition()[1] <<
" " 789 << camera->GetPosition()[2] <<
" " 791 << camera->GetViewAngle() <<
" " 793 << camera->GetViewUp()[0] <<
" " 794 << camera->GetViewUp()[1] <<
" " 795 << camera->GetViewUp()[2] <<
" " 802 bool File::LoadCamera(
const std::string filename, vtkSmartPointer<vtkCamera> &camera)
804 if(!camera || filename.empty())
807 double clippingRange[2];
813 ifstream file (filename.c_str());
838 camera->SetClippingRange(clippingRange);
839 camera->SetFocalPoint(focal);
840 camera->SetPosition(pos);
841 camera->SetViewAngle(viewAngle);
842 camera->SetViewUp(up);
void PrintDebug(const std::string msg)
Displays a generic msg to standard error with carriage return if in Debug mode.
static std::vector< std::string > GetSupportedImageFileExtensions()
Determines the supported image file format as file extensions from internal libraries and returns a l...
static vtkMatrix4x4 * OpenVTKTransform(std::string filename)
Opens a VTK transform file and converts it to a VTK transform matrix.
static bool OpenDelimitedText(const std::string filename, vtkSmartPointer< vtkTable > &data, const std::string delimiter=",")
Opens ASCII Delimited text files such as CSV files. Data is loaded into the table.
static std::vector< std::string > GetDICOMSeriesFilenames(const std::string directoryPath, const std::string seriesName, bool recursive=false)
Returns the filenames for a given UID/Series name for a given directory.
void PrintError(const std::string msg)
Displays a generic msg to standard error with carriage return.
static bool SaveDelimitedText(const std::string filename, const vtkSmartPointer< vtkTable > data, const std::string delimiter=",")
Saves table as an ASCII Delimited text files such as a CSV file.
static bool OpenModel(const std::string filename, vtkSmartPointer< vtkPolyData > &data)
Opens a model file, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *...
static bool OpenModelCollection(std::vector< std::string > filenames, vtkSmartPointer< vtkPolyDataCollection > &collection)
Opens model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *...
static vtkMatrix4x4 * OpenITKTransform(std::string filename)
Opens an ITK transform file and converts it to a VTK transform matrix.
static bool SaveTransformCollection(std::vector< std::string > filenames, vtkSmartPointer< vtkTransformCollection > collection, const bool ITK=false)
Saves transform files, which can be VTK .trsf or ITK from a collection.
static bool SaveModelCollection(std::vector< std::string > filenames, vtkSmartPointer< vtkPolyDataCollection > collection, const bool binary=false)
Saves model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *...
static bool SaveTransform(const std::string filename, vtkSmartPointer< vtkTransform > data, const bool ITK=false)
Saves a transform file, which can be VTK .trsf or ITK from a collection.
static bool SaveModel(const std::string filename, vtkSmartPointer< vtkPolyData > data, const bool binary=false)
Saves a model as a file, which can be a VTK XML or Legacy VTK PolyData File (i.e. either a *...
void PrintInfo(const std::string msg)
Displays a generic msg to standard output with carriage return.
std::string NumberToString(double num, unsigned zeroPad=0)
Number to string converter.
static bool ReadImageInformation(const std::string filename, std::string &pixeltype, std::string &componentType, size_t &dimensions)
Reads just the header of an image file (without reading the image data), and writes the info into the...
static std::vector< std::string > GetDICOMSeriesUIDs(const std::string directoryPath, bool recursive=false)
DICOM Related.
static std::string GetFileExtension(const std::string &filename)
Returns the file extension (in lower case) of the given filename.
static bool CanReadImage(const std::string filename)
Checks if the image can be read by supported libraries.