diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp index e947dc211a..c0abbdd204 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp @@ -1,427 +1,349 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ Version: $Revision: 18127 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkFiberBundleReader.h" #include #include #include #include #include #include #include #include #include #include #include #include #include const char* mitk::FiberBundleReader::XML_GEOMETRY = "geometry"; const char* mitk::FiberBundleReader::XML_MATRIX_XX = "xx"; const char* mitk::FiberBundleReader::XML_MATRIX_XY = "xy"; const char* mitk::FiberBundleReader::XML_MATRIX_XZ = "xz"; const char* mitk::FiberBundleReader::XML_MATRIX_YX = "yx"; const char* mitk::FiberBundleReader::XML_MATRIX_YY = "yy"; const char* mitk::FiberBundleReader::XML_MATRIX_YZ = "yz"; const char* mitk::FiberBundleReader::XML_MATRIX_ZX = "zx"; const char* mitk::FiberBundleReader::XML_MATRIX_ZY = "zy"; const char* mitk::FiberBundleReader::XML_MATRIX_ZZ = "zz"; const char* mitk::FiberBundleReader::XML_ORIGIN_X = "origin_x"; const char* mitk::FiberBundleReader::XML_ORIGIN_Y = "origin_y"; const char* mitk::FiberBundleReader::XML_ORIGIN_Z = "origin_z"; const char* mitk::FiberBundleReader::XML_SPACING_X = "spacing_x"; const char* mitk::FiberBundleReader::XML_SPACING_Y = "spacing_y"; const char* mitk::FiberBundleReader::XML_SPACING_Z = "spacing_z"; const char* mitk::FiberBundleReader::XML_SIZE_X = "size_x"; const char* mitk::FiberBundleReader::XML_SIZE_Y = "size_y"; const char* mitk::FiberBundleReader::XML_SIZE_Z = "size_z"; const char* mitk::FiberBundleReader::XML_FIBER_BUNDLE = "fiber_bundle"; const char* mitk::FiberBundleReader::XML_FIBER = "fiber"; const char* mitk::FiberBundleReader::XML_PARTICLE = "particle"; const char* mitk::FiberBundleReader::XML_ID = "id"; const char* mitk::FiberBundleReader::XML_POS_X = "pos_x"; const char* mitk::FiberBundleReader::XML_POS_Y = "pos_y"; const char* mitk::FiberBundleReader::XML_POS_Z = "pos_z"; const char* mitk::FiberBundleReader::XML_NUM_FIBERS = "num_fibers"; const char* mitk::FiberBundleReader::XML_NUM_PARTICLES = "num_particles"; const char* mitk::FiberBundleReader::XML_FIBER_BUNDLE_FILE = "fiber_bundle_file" ; const char* mitk::FiberBundleReader::XML_FILE_VERSION = "file_version" ; const char* mitk::FiberBundleReader::VERSION_STRING = "0.1" ; namespace mitk { void FiberBundleReader ::GenerateData() { MITK_INFO << "Reading fiber bundle"; if ( ( ! m_OutputCache ) ) { Superclass::SetNumberOfRequiredOutputs(0); this->GenerateOutputInformation(); } if (!m_OutputCache) { itkWarningMacro("Tree cache is empty!"); } Superclass::SetNumberOfRequiredOutputs(1); Superclass::SetNthOutput(0, m_OutputCache.GetPointer()); } void FiberBundleReader::GenerateOutputInformation() { m_OutputCache = OutputType::New(); std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); ext = itksys::SystemTools::LowerCase(ext); const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, NULL ); if ( locale.compare(currLocale)!=0 ) { try { setlocale(LC_ALL, locale.c_str()); } catch(...) { MITK_INFO << "Could not set locale " << locale; } } if ( m_FileName == "") { } - else if (ext == ".fib") + else if (ext == ".fib_deprecated") { try { TiXmlDocument doc( m_FileName ); doc.LoadFile(); TiXmlHandle hDoc(&doc); TiXmlElement* pElem; TiXmlHandle hRoot(0); pElem = hDoc.FirstChildElement().Element(); // save this for later hRoot = TiXmlHandle(pElem); pElem = hRoot.FirstChildElement(FiberBundleReader::XML_GEOMETRY).Element(); // read geometry mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); // read origin mitk::Point3D origin; double temp = 0; pElem->Attribute(FiberBundleReader::XML_ORIGIN_X, &temp); origin[0] = temp; pElem->Attribute(FiberBundleReader::XML_ORIGIN_Y, &temp); origin[1] = temp; pElem->Attribute(FiberBundleReader::XML_ORIGIN_Z, &temp); origin[2] = temp; geometry->SetOrigin(origin); // read spacing float spacing[3]; pElem->Attribute(FiberBundleReader::XML_SPACING_X, &temp); spacing[0] = temp; pElem->Attribute(FiberBundleReader::XML_SPACING_Y, &temp); spacing[1] = temp; pElem->Attribute(FiberBundleReader::XML_SPACING_Z, &temp); spacing[2] = temp; geometry->SetSpacing(spacing); // read transform vtkMatrix4x4* m = vtkMatrix4x4::New(); pElem->Attribute(FiberBundleReader::XML_MATRIX_XX, &temp); m->SetElement(0,0,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_XY, &temp); m->SetElement(1,0,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_XZ, &temp); m->SetElement(2,0,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_YX, &temp); m->SetElement(0,1,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_YY, &temp); m->SetElement(1,1,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_YZ, &temp); m->SetElement(2,1,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_ZX, &temp); m->SetElement(0,2,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_ZY, &temp); m->SetElement(1,2,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_ZZ, &temp); m->SetElement(2,2,temp); m->SetElement(0,3,origin[0]); m->SetElement(1,3,origin[1]); m->SetElement(2,3,origin[2]); m->SetElement(3,3,1); geometry->SetIndexToWorldTransformByVtkMatrix(m); // read bounds float bounds[] = {0, 0, 0, 0, 0, 0}; pElem->Attribute(FiberBundleReader::XML_SIZE_X, &temp); bounds[1] = temp; pElem->Attribute(FiberBundleReader::XML_SIZE_Y, &temp); bounds[3] = temp; pElem->Attribute(FiberBundleReader::XML_SIZE_Z, &temp); bounds[5] = temp; geometry->SetFloatBounds(bounds); // read bounds float bounds2[] = {0, 0, 0}; bounds2[0] = bounds[1]; bounds2[1] = bounds[3]; bounds2[2] = bounds[5]; m_OutputCache->SetBounds(bounds2); geometry->SetImageGeometry(true); m_OutputCache->SetGeometry(geometry); // generate tract container ContainerType::Pointer tractContainer = ContainerType::New(); int fiberID = 0; pElem = hRoot.FirstChildElement(FiberBundleReader::XML_FIBER_BUNDLE).FirstChild().Element(); for( pElem; pElem; pElem=pElem->NextSiblingElement()) { TiXmlElement* pElem2 = pElem->FirstChildElement(); ContainerTractType::Pointer tract = ContainerTractType::New(); for( pElem2; pElem2; pElem2=pElem2->NextSiblingElement()) { ContainerPointType point; pElem2->Attribute(FiberBundleReader::XML_POS_X, &temp); point[0] = temp; pElem2->Attribute(FiberBundleReader::XML_POS_Y, &temp); point[1] = temp; pElem2->Attribute(FiberBundleReader::XML_POS_Z, &temp); point[2] = temp; tract->InsertElement(tract->Size(), point); } pElem->Attribute(FiberBundleReader::XML_ID, &fiberID); tractContainer->CreateIndex(fiberID); tractContainer->SetElement(fiberID, tract); } m_OutputCache->addTractContainer(tractContainer); m_OutputCache->initFiberGroup(); MITK_INFO << "Fiber bundle read"; } catch(...) { MITK_INFO << "Could not read file "; } - } - else if (ext == ".vfib") - { - // generate tract container - ContainerType::Pointer tractContainer = ContainerType::New(); - mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); - - ///We create a Generic Reader to test de .vtk/ - vtkDataReader *chooser=vtkDataReader::New(); - chooser->SetFileName(m_FileName.c_str() ); - if( chooser->IsFilePolyData()) - { - vtkPolyDataReader *reader = vtkPolyDataReader::New(); - reader->SetFileName( m_FileName.c_str() ); - reader->Update(); - - if ( reader->GetOutput() != NULL ) - { - vtkPolyData* output = reader->GetOutput(); - double* center = output->GetCenter(); - MITK_INFO << "center: " << center[0] << ", " << center[1] << ", " << center[2]; - - float min = itk::NumericTraits::min(); - float max = itk::NumericTraits::max(); - float b[] = {max, min, max, min, max, min}; - vtkCellArray* cells = output->GetLines(); - cells->InitTraversal(); - for (int i=0; iGetNumberOfCells(); i++) - { - ContainerTractType::Pointer tract = ContainerTractType::New(); - vtkCell* cell = output->GetCell(i); - int p = cell->GetNumberOfPoints(); - vtkPoints* points = cell->GetPoints(); - for (int j=0; jGetPoint(j, p); - ContainerPointType point; - point[0] = p[0]; - point[1] = p[1]; - point[2] = p[2]; - - if (point[0]b[1]) - b[1]=point[0]; - - if (point[1]b[3]) - b[3]=point[1]; - - if (point[2]b[5]) - b[5]=point[2]; - - tract->InsertElement(tract->Size(), point); - } - tractContainer->InsertElement(i, tract); - } - - float bounds[] = {0, 0, 0}; - bounds[0] = b[1]; - bounds[1] = b[3]; - bounds[2] = b[5]; - m_OutputCache->SetBounds(bounds); - - geometry->SetImageGeometry(true); - geometry->SetFloatBounds(b); - m_OutputCache->SetGeometry(geometry); - } - reader->Delete(); - } - chooser->Delete(); - - m_OutputCache->addTractContainer(tractContainer); - m_OutputCache->initFiberGroup(); MITK_INFO << "Fiber bundle read"; } try { setlocale(LC_ALL, currLocale.c_str()); } catch(...) { MITK_INFO << "Could not reset locale " << currLocale; } } void FiberBundleReader::Update() { this->GenerateData(); } const char* FiberBundleReader ::GetFileName() const { return m_FileName.c_str(); } void FiberBundleReader ::SetFileName(const char* aFileName) { m_FileName = aFileName; } const char* FiberBundleReader ::GetFilePrefix() const { return m_FilePrefix.c_str(); } void FiberBundleReader ::SetFilePrefix(const char* aFilePrefix) { m_FilePrefix = aFilePrefix; } const char* FiberBundleReader ::GetFilePattern() const { return m_FilePattern.c_str(); } void FiberBundleReader ::SetFilePattern(const char* aFilePattern) { m_FilePattern = aFilePattern; } bool FiberBundleReader ::CanReadFile(const std::string filename, const std::string /*filePrefix*/, const std::string /*filePattern*/) { // First check the extension if( filename == "" ) { return false; } std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); ext = itksys::SystemTools::LowerCase(ext); -// if (ext == ".fib" || ext == ".vfib") -// { -// return true; -// } + if (ext == ".fib_deprecated") + { + return true; + } return false; } } //namespace MITK diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp index b8b40c8feb..cac2bca968 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp @@ -1,260 +1,259 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-12-10 18:05:13 +0100 (Mi, 10 Dez 2008) $ Version: $Revision: 15922 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkFiberBundleWriter.h" #include const char* mitk::FiberBundleWriter::XML_GEOMETRY = "geometry"; const char* mitk::FiberBundleWriter::XML_MATRIX_XX = "xx"; const char* mitk::FiberBundleWriter::XML_MATRIX_XY = "xy"; const char* mitk::FiberBundleWriter::XML_MATRIX_XZ = "xz"; const char* mitk::FiberBundleWriter::XML_MATRIX_YX = "yx"; const char* mitk::FiberBundleWriter::XML_MATRIX_YY = "yy"; const char* mitk::FiberBundleWriter::XML_MATRIX_YZ = "yz"; const char* mitk::FiberBundleWriter::XML_MATRIX_ZX = "zx"; const char* mitk::FiberBundleWriter::XML_MATRIX_ZY = "zy"; const char* mitk::FiberBundleWriter::XML_MATRIX_ZZ = "zz"; const char* mitk::FiberBundleWriter::XML_ORIGIN_X = "origin_x"; const char* mitk::FiberBundleWriter::XML_ORIGIN_Y = "origin_y"; const char* mitk::FiberBundleWriter::XML_ORIGIN_Z = "origin_z"; const char* mitk::FiberBundleWriter::XML_SPACING_X = "spacing_x"; const char* mitk::FiberBundleWriter::XML_SPACING_Y = "spacing_y"; const char* mitk::FiberBundleWriter::XML_SPACING_Z = "spacing_z"; const char* mitk::FiberBundleWriter::XML_SIZE_X = "size_x"; const char* mitk::FiberBundleWriter::XML_SIZE_Y = "size_y"; const char* mitk::FiberBundleWriter::XML_SIZE_Z = "size_z"; const char* mitk::FiberBundleWriter::XML_FIBER_BUNDLE = "fiber_bundle"; const char* mitk::FiberBundleWriter::XML_FIBER = "fiber"; const char* mitk::FiberBundleWriter::XML_PARTICLE = "particle"; const char* mitk::FiberBundleWriter::XML_ID = "id"; const char* mitk::FiberBundleWriter::XML_POS_X = "pos_x"; const char* mitk::FiberBundleWriter::XML_POS_Y = "pos_y"; const char* mitk::FiberBundleWriter::XML_POS_Z = "pos_z"; const char* mitk::FiberBundleWriter::XML_NUM_FIBERS = "num_fibers"; const char* mitk::FiberBundleWriter::XML_NUM_PARTICLES = "num_particles"; const char* mitk::FiberBundleWriter::XML_FIBER_BUNDLE_FILE = "fiber_bundle_file" ; const char* mitk::FiberBundleWriter::XML_FILE_VERSION = "file_version" ; const char* mitk::FiberBundleWriter::VERSION_STRING = "0.1" ; const char* mitk::FiberBundleWriter::ASCII_FILE = "ascii_file" ; const char* mitk::FiberBundleWriter::FILE_NAME = "file_name" ; mitk::FiberBundleWriter::FiberBundleWriter() : m_FileName(""), m_FilePrefix(""), m_FilePattern(""), m_Success(false) { this->SetNumberOfRequiredInputs( 1 ); } mitk::FiberBundleWriter::~FiberBundleWriter() {} void mitk::FiberBundleWriter::GenerateData() { try { MITK_INFO << "Writing fiber bundle"; m_Success = false; InputType* input = this->GetInput(); if (input == NULL) { itkWarningMacro(<<"Sorry, input to FiberBundleWriter is NULL!"); return; } if ( m_FileName == "" ) { itkWarningMacro( << "Sorry, filename has not been set!" ); return ; } const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, NULL ); if ( locale.compare(currLocale)!=0 ) { try { setlocale(LC_ALL, locale.c_str()); } catch(...) { MITK_INFO << "Could not set locale " << locale; } } std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); ext = itksys::SystemTools::LowerCase(ext); - if (ext == ".fib") + if (ext == ".fib_deprecated") { /* direct linked includes of mitkFiberBundle DataStructure */ typedef mitk::FiberBundle::ContainerPointType ContainerPointType; typedef mitk::FiberBundle::ContainerTractType ContainerTractType; typedef mitk::FiberBundle::ContainerType ContainerType; ContainerType::Pointer tractContainer = input->GetTractContainer(); mitk::Geometry3D* geometry = input->GetGeometry(); TiXmlDocument documentXML; TiXmlDeclaration* declXML = new TiXmlDeclaration( "1.0", "", "" ); // TODO what to write here? encoding? etc.... documentXML.LinkEndChild( declXML ); TiXmlElement* mainXML = new TiXmlElement(mitk::FiberBundleWriter::XML_FIBER_BUNDLE_FILE); mainXML->SetAttribute(mitk::FiberBundleWriter::XML_FILE_VERSION, mitk::FiberBundleWriter::VERSION_STRING); documentXML.LinkEndChild(mainXML); TiXmlElement* geometryXML = new TiXmlElement(mitk::FiberBundleWriter::XML_GEOMETRY); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_XX, geometry->GetMatrixColumn(0)[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_XY, geometry->GetMatrixColumn(0)[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_XZ, geometry->GetMatrixColumn(0)[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_YX, geometry->GetMatrixColumn(1)[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_YY, geometry->GetMatrixColumn(1)[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_YZ, geometry->GetMatrixColumn(1)[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_ZX, geometry->GetMatrixColumn(2)[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_ZY, geometry->GetMatrixColumn(2)[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_ZZ, geometry->GetMatrixColumn(2)[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_ORIGIN_X, geometry->GetOrigin()[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_ORIGIN_Y, geometry->GetOrigin()[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_ORIGIN_Z, geometry->GetOrigin()[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SPACING_X, geometry->GetSpacing()[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SPACING_Y, geometry->GetSpacing()[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SPACING_Z, geometry->GetSpacing()[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SIZE_X, input->GetBounds()[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SIZE_Y, input->GetBounds()[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SIZE_Z, input->GetBounds()[2]); mainXML->LinkEndChild(geometryXML); TiXmlElement* fiberBundleXML = new TiXmlElement(mitk::FiberBundleWriter::XML_FIBER_BUNDLE); fiberBundleXML->SetAttribute(mitk::FiberBundleWriter::XML_NUM_FIBERS, tractContainer->size()); int numParticles = 0; for (int i=0; iSize(); i++) { ContainerTractType::Pointer tract = tractContainer->GetElement(i); TiXmlElement* fiberXML = new TiXmlElement(mitk::FiberBundleWriter::XML_FIBER); fiberXML->SetAttribute(mitk::FiberBundleWriter::XML_ID, i); fiberXML->SetAttribute(mitk::FiberBundleWriter::XML_NUM_PARTICLES, tract->Size()); numParticles += tract->Size(); for (int j=0; jSize(); j++) { TiXmlElement* particleXML = new TiXmlElement(mitk::FiberBundleWriter::XML_PARTICLE); ContainerPointType p = tract->GetElement(j); particleXML->SetAttribute(mitk::FiberBundleWriter::XML_ID, j); particleXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_POS_X, p[0]); particleXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_POS_Y, p[1]); particleXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_POS_Z, p[2]); fiberXML->LinkEndChild(particleXML); } fiberBundleXML->LinkEndChild(fiberXML); } fiberBundleXML->SetAttribute(mitk::FiberBundleWriter::XML_NUM_PARTICLES, numParticles); mainXML->LinkEndChild(fiberBundleXML); documentXML.SaveFile( m_FileName ); m_Success = true; MITK_INFO << "Fiber bundle written"; - }else if (ext == ".vfib" || ext == ".vtk") { + }else if (ext == ".fib" || ext == ".vtk") { vtkPolyDataWriter* writer = vtkPolyDataWriter::New(); writer->SetInput(input->GeneratePolydata()); writer->SetFileName(m_FileName.c_str()); writer->SetFileTypeToASCII(); writer->Write(); m_Success = true; MITK_INFO << "Fiber bundle written as polydata"; } try { setlocale(LC_ALL, currLocale.c_str()); } catch(...) { MITK_INFO << "Could not reset locale " << currLocale; } } catch(...) { throw; } } void mitk::FiberBundleWriter::SetInputFiberBundle( InputType* diffVolumes ) { this->ProcessObject::SetNthInput( 0, diffVolumes ); } mitk::FiberBundle* mitk::FiberBundleWriter::GetInput() { if ( this->GetNumberOfInputs() < 1 ) { return NULL; } else { return dynamic_cast ( this->ProcessObject::GetInput( 0 ) ); } } std::vector mitk::FiberBundleWriter::GetPossibleFileExtensions() { std::vector possibleFileExtensions; -// possibleFileExtensions.push_back(".fib"); -// possibleFileExtensions.push_back(".vfib"); -// possibleFileExtensions.push_back(".vtk"); + possibleFileExtensions.push_back(".fib"); + possibleFileExtensions.push_back(".vtk"); return possibleFileExtensions; } diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h index da7bef49c7..bd09c568a3 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h @@ -1,216 +1,216 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-08-27 17:18:46 +0200 (Mi, 27 Aug 2008) $ Version: $Revision: 15096 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __mitkFiberBundleWriter_h #define __mitkFiberBundleWriter_h #include #include #include "mitkFiberBundle.h" #include namespace mitk { /** * Writes fiber bundles to a file * @ingroup Process */ class FiberBundleWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( FiberBundleWriter, mitk::FileWriterWithInformation ); //mitkWriterMacro; virtual void Write() { if ( this->GetInput() == NULL ) { itkExceptionMacro(<<"Write:Please specify an input!"); return; } /* Fill in image information.*/ this->UpdateOutputInformation(); (*(this->GetInputs().begin()))->SetRequestedRegionToLargestPossibleRegion(); this->PropagateRequestedRegion(NULL); this->UpdateOutputData(NULL); } virtual void Update() { Write(); } itkNewMacro( Self ); typedef mitk::FiberBundle InputType; /** * Sets the filename of the file to write. * @param FileName the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the input object for the filter. * @param input the diffusion volumes to write to file. */ void SetInputFiberBundle( InputType* input ); /** * @returns the 0'th input object of the filter. */ InputType* GetInput(); /** * Returns false if an error happened during writing */ itkGetMacro( Success, bool ); /** * @return possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); // FileWriterWithInformation methods virtual const char * GetDefaultFilename() { return "FiberBundle.fib"; } - virtual const char * GetFileDialogPattern() { return "Fiber Bundle (*.fib *.vfib *.vtk)"; } + virtual const char * GetFileDialogPattern() { return "Fiber Bundle (*.fib *.vtk)"; } virtual const char * GetDefaultExtension() { return ".fib"; } virtual bool CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; virtual void DoWrite(BaseData::Pointer data) { if (CanWriteBaseDataType(data)) { this->SetInputFiberBundle(dynamic_cast(data.GetPointer())); this->Update(); } }; static const char* XML_GEOMETRY; static const char* XML_MATRIX_XX; static const char* XML_MATRIX_XY; static const char* XML_MATRIX_XZ; static const char* XML_MATRIX_YX; static const char* XML_MATRIX_YY; static const char* XML_MATRIX_YZ; static const char* XML_MATRIX_ZX; static const char* XML_MATRIX_ZY; static const char* XML_MATRIX_ZZ; static const char* XML_ORIGIN_X; static const char* XML_ORIGIN_Y; static const char* XML_ORIGIN_Z; static const char* XML_SPACING_X; static const char* XML_SPACING_Y; static const char* XML_SPACING_Z; static const char* XML_SIZE_X; static const char* XML_SIZE_Y; static const char* XML_SIZE_Z; static const char* XML_FIBER_BUNDLE; static const char* XML_FIBER; static const char* XML_PARTICLE; static const char* XML_ID; static const char* XML_POS_X; static const char* XML_POS_Y; static const char* XML_POS_Z; static const char* VERSION_STRING; static const char* XML_FIBER_BUNDLE_FILE; static const char* XML_FILE_VERSION; static const char* XML_NUM_FIBERS; static const char* XML_NUM_PARTICLES; static const char* ASCII_FILE; static const char* FILE_NAME; protected: FiberBundleWriter(); virtual ~FiberBundleWriter(); virtual void GenerateData(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } // end of namespace mitk #endif //__mitkFiberBundleWriter_h