diff --git a/CMake/UseITK.cmake b/CMake/UseITK.cmake index 522e6743f17..969cf28a91b 100644 --- a/CMake/UseITK.cmake +++ b/CMake/UseITK.cmake @@ -207,6 +207,24 @@ macro(ADD_FACTORY_REGISTRATION _registration_list_var _names_list_var _module_na endif() endmacro() +# _set_module_and_factory_names( ) +# +# Set default factory and module names associated with the formats +# while considering exceptions already set. +# +macro(_set_module_and_factory_names factory_type module_name_prefix factory_name_suffix) + string(TOUPPER ${factory_type} _qualifier_uc) + string(TOLOWER ${factory_type} _qualifier_lc) + foreach(format ${LIST_OF_${_qualifier_uc}IO_FORMATS}) + if (NOT ${format}_${_qualifier_lc}_module_name ) + set(${format}_${_qualifier_lc}_module_name ${module_name_prefix}${format}) + endif() + if (NOT ${format}_${_qualifier_lc}_factory_name) + set(${format}_${_qualifier_lc}_factory_name ${format}${factory_name_suffix}) + endif() + endforeach() +endmacro() + #----------------------------------------------------------------------------- # ImageIO #----------------------------------------------------------------------------- @@ -238,19 +256,56 @@ set(SCIFIO_image_module_name SCIFIO) set(FDF_image_module_name IOFDF) -foreach(ImageFormat ${LIST_OF_IMAGEIO_FORMATS}) - if (NOT ${ImageFormat}_image_module_name ) - set(${ImageFormat}_image_module_name ITKIO${ImageFormat}) - endif() - if (NOT ${ImageFormat}_image_factory_name) - set(${ImageFormat}_image_factory_name ${ImageFormat}ImageIO) - endif() -endforeach() +_set_module_and_factory_names("Image" "ITKIO" "ImageIO") if(NOT ITK_NO_IO_FACTORY_REGISTER_MANAGER) _configure_IOFactoryRegisterManager("Image" "${LIST_OF_IMAGEIO_FORMATS}") endif() +#----------------------------------------------------------------------------- +# MeshIO +#----------------------------------------------------------------------------- + +# a list of mesh IOs to be registered when the corresponding modules are enabled +set(LIST_OF_MESHIO_FORMATS + BYU + FreeSurferAscii + FreeSurferBinary + Gifti + OBJ + OFF + VTKPolyData + ) + +# Exceptions: + +set(BYU_mesh_module_name ITKIOMesh) +set(BYU_mesh_factory_name BYUMeshIO) + +set(FreeSurferAscii_mesh_module_name ITKIOMesh) +set(FreeSurferAscii_mesh_factory_name FreeSurferAsciiMeshIO) + +set(FreeSurferBinary_mesh_module_name ITKIOMesh) +set(FreeSurferBinary_mesh_factory_name FreeSurferBinaryMeshIO) + +set(Gifti_mesh_module_name ITKIOMesh) +set(Gifti_mesh_factory_name GiftiMeshIO) + +set(OBJ_mesh_module_name ITKIOMesh) +set(OBJ_mesh_factory_name OBJMeshIO) + +set(OFF_mesh_module_name ITKIOMesh) +set(OFF_mesh_factory_name OFFMeshIO) + +set(VTKPolyData_mesh_module_name ITKIOMesh) +set(VTKPolyData_mesh_factory_name VTKPolyDataMeshIO) + +_set_module_and_factory_names("Mesh" "ITKIOMesh" "MeshIO") + +if(NOT ITK_NO_IO_FACTORY_REGISTER_MANAGER) + _configure_IOFactoryRegisterManager("Mesh" "${LIST_OF_MESHIO_FORMATS}") +endif() + #----------------------------------------------------------------------------- # TransformIO #----------------------------------------------------------------------------- @@ -268,14 +323,8 @@ set(LIST_OF_TRANSFORMIO_FORMATS set(Txt_transform_module_name ITKIOTransformInsightLegacy) set(Txt_transform_factory_name TxtTransformIO) -foreach(TransformFormat ${LIST_OF_TRANSFORMIO_FORMATS}) - if (NOT ${TransformFormat}_transform_module_name ) - set(${TransformFormat}_transform_module_name ITKIOTransform${TransformFormat}) - endif() - if (NOT ${TransformFormat}_transform_factory_name) - set(${TransformFormat}_transform_factory_name ${TransformFormat}TransformIO) - endif() -endforeach() + +_set_module_and_factory_names("Transform" "ITKIOTransform" "TransformIO") if(NOT ITK_NO_IO_FACTORY_REGISTER_MANAGER) _configure_IOFactoryRegisterManager("Transform" "${LIST_OF_TRANSFORMIO_FORMATS}") diff --git a/CMake/itkMeshIOFactoryRegisterManager.h.in b/CMake/itkMeshIOFactoryRegisterManager.h.in new file mode 100644 index 00000000000..28ce3c30230 --- /dev/null +++ b/CMake/itkMeshIOFactoryRegisterManager.h.in @@ -0,0 +1,59 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#ifndef itkMeshIOFactoryRegisterManager_h +#define itkMeshIOFactoryRegisterManager_h + +namespace itk { + +class MeshIOFactoryRegisterManager +{ + public: + MeshIOFactoryRegisterManager(void (*list[])(void)) + { + for(;*list; ++list) + { + (*list)(); + } + } +}; + + +// +// The following code is intended to be expanded at the end of the +// itkMeshFileReader.h and itkMeshFileWriter.h files. +// +@LIST_OF_FACTORIES_REGISTRATION@ + +// +// The code below registers available IO helpers using static initialization in +// application translation units. Note that this code will be expanded in the +// ITK-based applications and not in ITK itself. +// +namespace { + + void (*MeshIOFactoryRegisterRegisterList[])(void) = { + @LIST_OF_FACTORY_NAMES@ + 0}; + MeshIOFactoryRegisterManager MeshIOFactoryRegisterManagerInstance(MeshIOFactoryRegisterRegisterList); + +} + +} + +#endif diff --git a/Modules/Core/TestKernel/include/itkTestDriverIncludeRequiredIOFactories.h b/Modules/Core/TestKernel/include/itkTestDriverIncludeRequiredIOFactories.h index 3728880d73e..1d0dbf8c268 100644 --- a/Modules/Core/TestKernel/include/itkTestDriverIncludeRequiredIOFactories.h +++ b/Modules/Core/TestKernel/include/itkTestDriverIncludeRequiredIOFactories.h @@ -18,6 +18,7 @@ #ifndef itkTestDriverIncludeRequiredIOFactories_h #define itkTestDriverIncludeRequiredIOFactories_h +// ImageIO #include "itkGDCMImageIOFactory.h" #include "itkMetaImageIOFactory.h" #include "itkJPEGImageIOFactory.h" @@ -28,6 +29,16 @@ #include "itkNrrdImageIOFactory.h" #include "itkGiplImageIOFactory.h" #include "itkNiftiImageIOFactory.h" + +// MeshIO +#include "itkBYUMeshIOFactory.h" +#include "itkFreeSurferAsciiMeshIOFactory.h" +#include "itkFreeSurferBinaryMeshIOFactory.h" +#include "itkGiftiMeshIOFactory.h" +#include "itkOBJMeshIOFactory.h" +#include "itkOFFMeshIOFactory.h" +#include "itkVTKPolyDataMeshIOFactory.h" + #include "itkTestDriverInclude.h" #include "itkObjectFactoryBase.h" @@ -38,6 +49,7 @@ void RegisterRequiredFactories() { + // ImageIO itk::ObjectFactoryBase::RegisterFactory( itk::MetaImageIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( itk::GDCMImageIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( itk::JPEGImageIOFactory::New() ); @@ -48,6 +60,14 @@ RegisterRequiredFactories() itk::ObjectFactoryBase::RegisterFactory( itk::NrrdImageIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( itk::GiplImageIOFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( itk::NiftiImageIOFactory::New() ); + // MeshIO + itk::ObjectFactoryBase::RegisterFactory( itk::BYUMeshIOFactory::New() ); + itk::ObjectFactoryBase::RegisterFactory( itk::FreeSurferAsciiMeshIOFactory::New() ); + itk::ObjectFactoryBase::RegisterFactory( itk::FreeSurferBinaryMeshIOFactory::New() ); + itk::ObjectFactoryBase::RegisterFactory( itk::GiftiMeshIOFactory::New() ); + itk::ObjectFactoryBase::RegisterFactory( itk::OBJMeshIOFactory::New() ); + itk::ObjectFactoryBase::RegisterFactory( itk::OFFMeshIOFactory::New() ); + itk::ObjectFactoryBase::RegisterFactory( itk::VTKPolyDataMeshIOFactory::New() ); } void diff --git a/Modules/Core/TestKernel/itk-module.cmake b/Modules/Core/TestKernel/itk-module.cmake index fd220adce96..7bbf2225d5f 100644 --- a/Modules/Core/TestKernel/itk-module.cmake +++ b/Modules/Core/TestKernel/itk-module.cmake @@ -16,6 +16,7 @@ itk_module(ITKTestKernel ITKIOPNG ITKIOTIFF ITKIOVTK + ITKIOMesh PRIVATE_DEPENDS ITKCommon COMPILE_DEPENDS diff --git a/Modules/IO/Mesh/itk-module.cmake b/Modules/IO/Mesh/itk-module.cmake index 53750fcfe64..d31c7c2312f 100644 --- a/Modules/IO/Mesh/itk-module.cmake +++ b/Modules/IO/Mesh/itk-module.cmake @@ -2,15 +2,14 @@ set(DOCUMENTATION "This module contains classes for reading and writing Meshes as opposed to general images.") itk_module(ITKIOMesh ENABLE_SHARED + DEPENDS + ITKCommon + ITKIOMeshBase PRIVATE_DEPENDS - ITKIOImageBase ITKDoubleConversion ITKGIFTI - COMPILE_DEPENDS - ITKMesh TEST_DEPENDS ITKTestKernel - ITKQuadEdgeMesh DESCRIPTION "${DOCUMENTATION}" ) diff --git a/Modules/IO/Mesh/src/CMakeLists.txt b/Modules/IO/Mesh/src/CMakeLists.txt index b97b21ae3ef..5d4522735dd 100644 --- a/Modules/IO/Mesh/src/CMakeLists.txt +++ b/Modules/IO/Mesh/src/CMakeLists.txt @@ -1,6 +1,4 @@ set(ITKIOMesh_SRC - itkMeshFileReaderException.cxx - itkMeshFileWriterException.cxx itkBYUMeshIO.cxx itkBYUMeshIOFactory.cxx itkFreeSurferAsciiMeshIO.cxx @@ -9,8 +7,6 @@ set(ITKIOMesh_SRC itkFreeSurferBinaryMeshIOFactory.cxx itkGiftiMeshIO.cxx itkGiftiMeshIOFactory.cxx - itkMeshIOBase.cxx - itkMeshIOFactory.cxx itkOBJMeshIO.cxx itkOBJMeshIOFactory.cxx itkOFFMeshIO.cxx diff --git a/Modules/IO/Mesh/src/itkBYUMeshIOFactory.cxx b/Modules/IO/Mesh/src/itkBYUMeshIOFactory.cxx index 20c8e763d78..f885bfcac90 100644 --- a/Modules/IO/Mesh/src/itkBYUMeshIOFactory.cxx +++ b/Modules/IO/Mesh/src/itkBYUMeshIOFactory.cxx @@ -15,6 +15,8 @@ * limitations under the License. * *=========================================================================*/ +#include "ITKIOMeshExport.h" + #include "itkBYUMeshIOFactory.h" #include "itkBYUMeshIO.h" #include "itkVersion.h" @@ -58,5 +60,18 @@ ::GetDescription() const return "BYU Mesh IO Factory, allows the loading of BYU mesh into insight"; } +// Undocumented API used to register during static initialization. +// DO NOT CALL DIRECTLY. +static bool BYUMeshIOFactoryHasBeenRegistered; + +void ITKIOMesh_EXPORT BYUMeshIOFactoryRegister__Private(void) +{ + if( ! BYUMeshIOFactoryHasBeenRegistered ) + { + BYUMeshIOFactoryHasBeenRegistered = true; + BYUMeshIOFactory::RegisterOneFactory(); + } +} + // ///////////////////////////////////////////////////////////////////// } // end namespace itk diff --git a/Modules/IO/Mesh/src/itkFreeSurferAsciiMeshIOFactory.cxx b/Modules/IO/Mesh/src/itkFreeSurferAsciiMeshIOFactory.cxx index ac0c7af5ad9..8793ed826b0 100644 --- a/Modules/IO/Mesh/src/itkFreeSurferAsciiMeshIOFactory.cxx +++ b/Modules/IO/Mesh/src/itkFreeSurferAsciiMeshIOFactory.cxx @@ -15,6 +15,7 @@ * limitations under the License. * *=========================================================================*/ +#include "ITKIOMeshExport.h" #include "itkFreeSurferAsciiMeshIO.h" #include "itkFreeSurferAsciiMeshIOFactory.h" @@ -54,4 +55,18 @@ ::GetDescription() const { return "FreeSurfer ASCII Mesh IO Factory, allows the loading of FreeSurfer Ascii mesh into insight"; } + +// Undocumented API used to register during static initialization. +// DO NOT CALL DIRECTLY. +static bool FreeSurferAsciiMeshIOFactoryHasBeenRegistered; + +void ITKIOMesh_EXPORT FreeSurferAsciiMeshIOFactoryRegister__Private(void) +{ + if( ! FreeSurferAsciiMeshIOFactoryHasBeenRegistered ) + { + FreeSurferAsciiMeshIOFactoryHasBeenRegistered = true; + FreeSurferAsciiMeshIOFactory::RegisterOneFactory(); + } +} + } // end namespace itk diff --git a/Modules/IO/Mesh/src/itkFreeSurferBinaryMeshIOFactory.cxx b/Modules/IO/Mesh/src/itkFreeSurferBinaryMeshIOFactory.cxx index 62259d23ffe..375f8282656 100644 --- a/Modules/IO/Mesh/src/itkFreeSurferBinaryMeshIOFactory.cxx +++ b/Modules/IO/Mesh/src/itkFreeSurferBinaryMeshIOFactory.cxx @@ -15,6 +15,7 @@ * limitations under the License. * *=========================================================================*/ +#include "ITKIOMeshExport.h" #include "itkFreeSurferBinaryMeshIO.h" #include "itkFreeSurferBinaryMeshIOFactory.h" @@ -54,4 +55,18 @@ ::GetDescription() const { return "FreeSurfer BINARY Mesh IO Factory, allows the loading of FreeSurfer Binary mesh into insight"; } + +// Undocumented API used to register during static initialization. +// DO NOT CALL DIRECTLY. +static bool FreeSurferBinaryMeshIOFactoryHasBeenRegistered; + +void ITKIOMesh_EXPORT FreeSurferBinaryMeshIOFactoryRegister__Private(void) +{ + if( ! FreeSurferBinaryMeshIOFactoryHasBeenRegistered ) + { + FreeSurferBinaryMeshIOFactoryHasBeenRegistered = true; + FreeSurferBinaryMeshIOFactory::RegisterOneFactory(); + } +} + } // end namespace itk diff --git a/Modules/IO/Mesh/src/itkGiftiMeshIOFactory.cxx b/Modules/IO/Mesh/src/itkGiftiMeshIOFactory.cxx index cd12b8d7911..051a307db22 100644 --- a/Modules/IO/Mesh/src/itkGiftiMeshIOFactory.cxx +++ b/Modules/IO/Mesh/src/itkGiftiMeshIOFactory.cxx @@ -15,6 +15,7 @@ * limitations under the License. * *=========================================================================*/ +#include "ITKIOMeshExport.h" #include "itkGiftiMeshIO.h" #include "itkGiftiMeshIOFactory.h" @@ -54,4 +55,18 @@ ::GetDescription() const { return "Gifti MeshIO Factory, allows the loading of Gifti meshs into insight"; } + +// Undocumented API used to register during static initialization. +// DO NOT CALL DIRECTLY. +static bool GiftiMeshIOFactoryHasBeenRegistered; + +void ITKIOMesh_EXPORT GiftiMeshIOFactoryRegister__Private(void) +{ + if( ! GiftiMeshIOFactoryHasBeenRegistered ) + { + GiftiMeshIOFactoryHasBeenRegistered = true; + GiftiMeshIOFactory::RegisterOneFactory(); + } +} + } // end namespace itk diff --git a/Modules/IO/Mesh/src/itkOBJMeshIOFactory.cxx b/Modules/IO/Mesh/src/itkOBJMeshIOFactory.cxx index 8a5b5f11619..cb0fde90a17 100644 --- a/Modules/IO/Mesh/src/itkOBJMeshIOFactory.cxx +++ b/Modules/IO/Mesh/src/itkOBJMeshIOFactory.cxx @@ -15,6 +15,7 @@ * limitations under the License. * *=========================================================================*/ +#include "ITKIOMeshExport.h" #include "itkOBJMeshIO.h" #include "itkOBJMeshIOFactory.h" @@ -54,4 +55,18 @@ ::GetDescription() const { return "OBJ Mesh IO Factory, allows the loading of OBJ mesh into insight"; } + +// Undocumented API used to register during static initialization. +// DO NOT CALL DIRECTLY. +static bool OBJMeshIOFactoryHasBeenRegistered; + +void ITKIOMesh_EXPORT OBJMeshIOFactoryRegister__Private(void) +{ + if( ! OBJMeshIOFactoryHasBeenRegistered ) + { + OBJMeshIOFactoryHasBeenRegistered = true; + OBJMeshIOFactory::RegisterOneFactory(); + } +} + } // end namespace itk diff --git a/Modules/IO/Mesh/src/itkOFFMeshIOFactory.cxx b/Modules/IO/Mesh/src/itkOFFMeshIOFactory.cxx index 8173236d383..b69d9bc8b9a 100644 --- a/Modules/IO/Mesh/src/itkOFFMeshIOFactory.cxx +++ b/Modules/IO/Mesh/src/itkOFFMeshIOFactory.cxx @@ -15,6 +15,7 @@ * limitations under the License. * *=========================================================================*/ +#include "ITKIOMeshExport.h" #include "itkOFFMeshIO.h" #include "itkOFFMeshIOFactory.h" @@ -54,4 +55,18 @@ ::GetDescription() const { return "OFF Mesh IO Factory, allows the loading of OFF mesh into insight"; } + +// Undocumented API used to register during static initialization. +// DO NOT CALL DIRECTLY. +static bool OFFMeshIOFactoryHasBeenRegistered; + +void ITKIOMesh_EXPORT OFFMeshIOFactoryRegister__Private(void) +{ + if( ! OFFMeshIOFactoryHasBeenRegistered ) + { + OFFMeshIOFactoryHasBeenRegistered = true; + OFFMeshIOFactory::RegisterOneFactory(); + } +} + } // end namespace itk diff --git a/Modules/IO/Mesh/src/itkVTKPolyDataMeshIOFactory.cxx b/Modules/IO/Mesh/src/itkVTKPolyDataMeshIOFactory.cxx index 5dd2a0d3a9b..bc86c52873d 100644 --- a/Modules/IO/Mesh/src/itkVTKPolyDataMeshIOFactory.cxx +++ b/Modules/IO/Mesh/src/itkVTKPolyDataMeshIOFactory.cxx @@ -15,6 +15,7 @@ * limitations under the License. * *=========================================================================*/ +#include "ITKIOMeshExport.h" #include "itkVTKPolyDataMeshIO.h" #include "itkVTKPolyDataMeshIOFactory.h" @@ -54,4 +55,18 @@ ::GetDescription() const { return "VTK MeshIO Factory, allows the loading of VTK polydata into insight"; } + +// Undocumented API used to register during static initialization. +// DO NOT CALL DIRECTLY. +static bool VTKPolyDataMeshIOFactoryHasBeenRegistered; + +void ITKIOMesh_EXPORT VTKPolyDataMeshIOFactoryRegister__Private(void) +{ + if( ! VTKPolyDataMeshIOFactoryHasBeenRegistered ) + { + VTKPolyDataMeshIOFactoryHasBeenRegistered = true; + VTKPolyDataMeshIOFactory::RegisterOneFactory(); + } +} + } // end namespace itk diff --git a/Modules/IO/MeshBase/CMakeLists.txt b/Modules/IO/MeshBase/CMakeLists.txt new file mode 100644 index 00000000000..b815fdc1e1f --- /dev/null +++ b/Modules/IO/MeshBase/CMakeLists.txt @@ -0,0 +1,4 @@ +project(ITKIOMeshBase) + +set(ITKIOMeshBase_LIBRARIES ITKIOMeshBase) +itk_module_impl() diff --git a/Modules/IO/Mesh/include/itkConvertArrayPixelBuffer.h b/Modules/IO/MeshBase/include/itkConvertArrayPixelBuffer.h similarity index 98% rename from Modules/IO/Mesh/include/itkConvertArrayPixelBuffer.h rename to Modules/IO/MeshBase/include/itkConvertArrayPixelBuffer.h index d2d44eb830b..5ec16d08fde 100644 --- a/Modules/IO/Mesh/include/itkConvertArrayPixelBuffer.h +++ b/Modules/IO/MeshBase/include/itkConvertArrayPixelBuffer.h @@ -29,7 +29,7 @@ namespace itk * * Derived from ConvertPixelBuffer has a static method Convert(). It is used * to work with pixel type as Array type. - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase */ template class ConvertPixelBuffer, OutputConvertTraits> diff --git a/Modules/IO/Mesh/include/itkConvertArrayPixelBuffer.hxx b/Modules/IO/MeshBase/include/itkConvertArrayPixelBuffer.hxx similarity index 100% rename from Modules/IO/Mesh/include/itkConvertArrayPixelBuffer.hxx rename to Modules/IO/MeshBase/include/itkConvertArrayPixelBuffer.hxx diff --git a/Modules/IO/Mesh/include/itkConvertVariableLengthVectorPixelBuffer.h b/Modules/IO/MeshBase/include/itkConvertVariableLengthVectorPixelBuffer.h similarity index 98% rename from Modules/IO/Mesh/include/itkConvertVariableLengthVectorPixelBuffer.h rename to Modules/IO/MeshBase/include/itkConvertVariableLengthVectorPixelBuffer.h index 7b1cd4c9754..c5ac2fb00c4 100644 --- a/Modules/IO/Mesh/include/itkConvertVariableLengthVectorPixelBuffer.h +++ b/Modules/IO/MeshBase/include/itkConvertVariableLengthVectorPixelBuffer.h @@ -29,7 +29,7 @@ namespace itk * * Derived from ConvertPixelBuffer has a static method Convert(). It is used * to work with pixel type as VariableLengthVector type. - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase */ template class ConvertPixelBuffer, OutputConvertTraits> diff --git a/Modules/IO/Mesh/include/itkConvertVariableLengthVectorPixelBuffer.hxx b/Modules/IO/MeshBase/include/itkConvertVariableLengthVectorPixelBuffer.hxx similarity index 100% rename from Modules/IO/Mesh/include/itkConvertVariableLengthVectorPixelBuffer.hxx rename to Modules/IO/MeshBase/include/itkConvertVariableLengthVectorPixelBuffer.hxx diff --git a/Modules/IO/Mesh/include/itkMeshConvertPixelTraits.h b/Modules/IO/MeshBase/include/itkMeshConvertPixelTraits.h similarity index 99% rename from Modules/IO/Mesh/include/itkMeshConvertPixelTraits.h rename to Modules/IO/MeshBase/include/itkMeshConvertPixelTraits.h index d1b2abba4be..19bf381d7a5 100644 --- a/Modules/IO/Mesh/include/itkMeshConvertPixelTraits.h +++ b/Modules/IO/MeshBase/include/itkMeshConvertPixelTraits.h @@ -39,7 +39,7 @@ namespace itk * This implementaion, does a simple assignment operator, so if you are * going from from a higher bit representation to a lower bit one (int to * char), you may want to specialize and add some sort of transfer function. - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase */ template class MeshConvertPixelTraits diff --git a/Modules/IO/Mesh/include/itkMeshFileReader.h b/Modules/IO/MeshBase/include/itkMeshFileReader.h similarity index 89% rename from Modules/IO/Mesh/include/itkMeshFileReader.h rename to Modules/IO/MeshBase/include/itkMeshFileReader.h index 10cc96f39c3..16f4e875216 100644 --- a/Modules/IO/Mesh/include/itkMeshFileReader.h +++ b/Modules/IO/MeshBase/include/itkMeshFileReader.h @@ -17,7 +17,6 @@ *=========================================================================*/ #ifndef itkMeshFileReader_h #define itkMeshFileReader_h -#include "ITKIOMeshExport.h" #include "itkMeshFileReaderException.h" #include "itkMacro.h" @@ -65,7 +64,7 @@ namespace itk * \sa MeshIOBase * * \ingroup IOFilters - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase * * \author Wanlin Zhu. Uviversity of New South Wales, Australia. */ @@ -142,7 +141,7 @@ class MeshFileReader:public MeshSource< TOutputMesh > protected: MeshFileReader(); - ~MeshFileReader(){} + virtual ~MeshFileReader(); void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE; /** Convert a block of pixels from one type to another. */ @@ -172,10 +171,32 @@ class MeshFileReader:public MeshSource< TOutputMesh > std::string m_ExceptionMessage; }; + } // namespace ITK -#ifndef ITK_MANUAL_INSTANTIATION -#include "itkMeshFileReader.hxx" +/** Explicit instantiations */ +#ifndef ITK_TEMPLATE_EXPLICIT_MeshIOInstantiation +// Explicit instantiation is required to ensure correct dynamic_cast +// behavior across shared libraries. +# if defined( ITKIOMeshBase_EXPORTS ) +// We are building this library +# define ITKIOMeshBase_EXPORT_EXPLICIT +# else +// We are using this library +# define ITKIOMeshBase_EXPORT_EXPLICIT ITKIOMeshBase_EXPORT +# endif + +# define ITKMeshIOInstantiation_IO_TYPE MeshFileReader +# include "itkMeshIOInstantiation.inc" +# undef ITKMeshIOInstantiation_IO_TYPE + +# undef ITKIOMeshBase_EXPORT_EXPLICIT +#endif + +// Note: Explicit instantiation is done in itkMeshFileReader.cxx + +#ifdef ITK_IO_FACTORY_REGISTER_MANAGER +#include "itkMeshIOFactoryRegisterManager.h" #endif #endif diff --git a/Modules/IO/Mesh/include/itkMeshFileReader.hxx b/Modules/IO/MeshBase/include/itkMeshFileReader.hxx similarity index 99% rename from Modules/IO/Mesh/include/itkMeshFileReader.hxx rename to Modules/IO/MeshBase/include/itkMeshFileReader.hxx index f04de762de5..1e192c0a544 100644 --- a/Modules/IO/Mesh/include/itkMeshFileReader.hxx +++ b/Modules/IO/MeshBase/include/itkMeshFileReader.hxx @@ -39,6 +39,13 @@ MeshFileReader< TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits > m_MeshIO = ITK_NULLPTR; m_FileName = ""; m_UserSpecifiedMeshIO = false; + +} + +template< typename TOutputMesh, typename ConvertPointPixelTraits, typename ConvertCellPixelTraits > +MeshFileReader< TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits > +::~MeshFileReader() +{ } template< typename TOutputMesh, typename ConvertPointPixelTraits, typename ConvertCellPixelTraits > diff --git a/Modules/IO/Mesh/include/itkMeshFileReaderException.h b/Modules/IO/MeshBase/include/itkMeshFileReaderException.h similarity index 92% rename from Modules/IO/Mesh/include/itkMeshFileReaderException.h rename to Modules/IO/MeshBase/include/itkMeshFileReaderException.h index 7254abbf288..7f6f6ecf82a 100644 --- a/Modules/IO/Mesh/include/itkMeshFileReaderException.h +++ b/Modules/IO/MeshBase/include/itkMeshFileReaderException.h @@ -17,7 +17,7 @@ *=========================================================================*/ #ifndef itkMeshFileReaderException_h #define itkMeshFileReaderException_h -#include "ITKIOMeshExport.h" +#include "ITKIOMeshBaseExport.h" #include "itkMacro.h" #include "itkExceptionObject.h" @@ -27,9 +27,9 @@ namespace itk /** \class MeshFileReaderException * * \brief Base exception class for IO conflicts. - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase */ -class ITKIOMesh_EXPORT MeshFileReaderException:public ExceptionObject +class ITKIOMeshBase_EXPORT MeshFileReaderException:public ExceptionObject { public: /** Has to have empty throw(). */ diff --git a/Modules/IO/Mesh/include/itkMeshFileWriter.h b/Modules/IO/MeshBase/include/itkMeshFileWriter.h similarity index 86% rename from Modules/IO/Mesh/include/itkMeshFileWriter.h rename to Modules/IO/MeshBase/include/itkMeshFileWriter.h index 92ee2eec55a..b19b1ca67f6 100644 --- a/Modules/IO/Mesh/include/itkMeshFileWriter.h +++ b/Modules/IO/MeshBase/include/itkMeshFileWriter.h @@ -17,7 +17,7 @@ *=========================================================================*/ #ifndef itkMeshFileWriter_h #define itkMeshFileWriter_h -#include "ITKIOMeshExport.h" +#include "ITKIOMeshBaseExport.h" #include "itkMeshFileWriterException.h" #include "itkProcessObject.h" @@ -46,10 +46,10 @@ namespace itk * \sa MeshIOBase * * \ingroup IOFilters - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase */ template< typename TInputMesh > -class ITKIOMesh_HIDDEN MeshFileWriter:public ProcessObject +class MeshFileWriter:public ProcessObject { public: /** Standard class typedefs. */ @@ -127,7 +127,7 @@ class ITKIOMesh_HIDDEN MeshFileWriter:public ProcessObject protected: MeshFileWriter(); - ~MeshFileWriter(); + virtual ~MeshFileWriter(); virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE; template< typename Output > @@ -162,10 +162,32 @@ class ITKIOMesh_HIDDEN MeshFileWriter:public ProcessObject bool m_UseCompression; bool m_FileTypeIsBINARY; }; + } // end namespace itk -#ifndef ITK_MANUAL_INSTANTIATION -#include "itkMeshFileWriter.hxx" +/** Explicit instantiations */ +#ifndef ITK_TEMPLATE_EXPLICIT_MeshIOInstantiation +// Explicit instantiation is required to ensure correct dynamic_cast +// behavior across shared libraries. +# if defined( ITKIOMeshBase_EXPORTS ) +// We are building this library +# define ITKIOMeshBase_EXPORT_EXPLICIT +# else +// We are using this library +# define ITKIOMeshBase_EXPORT_EXPLICIT ITKIOMeshBase_EXPORT +# endif + +# define ITKMeshIOInstantiation_IO_TYPE MeshFileWriter +# include "itkMeshIOInstantiation.inc" +# undef ITKMeshIOInstantiation_IO_TYPE + +# undef ITKIOMeshBase_EXPORT_EXPLICIT +#endif + +// Note: Explicit instantiation is done in itkMeshFileWriter.cxx + +#ifdef ITK_IO_FACTORY_REGISTER_MANAGER +#include "itkMeshIOFactoryRegisterManager.h" #endif #endif // itkMeshFileWriter_h diff --git a/Modules/IO/Mesh/include/itkMeshFileWriter.hxx b/Modules/IO/MeshBase/include/itkMeshFileWriter.hxx similarity index 100% rename from Modules/IO/Mesh/include/itkMeshFileWriter.hxx rename to Modules/IO/MeshBase/include/itkMeshFileWriter.hxx diff --git a/Modules/IO/Mesh/include/itkMeshFileWriterException.h b/Modules/IO/MeshBase/include/itkMeshFileWriterException.h similarity index 92% rename from Modules/IO/Mesh/include/itkMeshFileWriterException.h rename to Modules/IO/MeshBase/include/itkMeshFileWriterException.h index 2f8d837ce7e..f8d781f3f09 100644 --- a/Modules/IO/Mesh/include/itkMeshFileWriterException.h +++ b/Modules/IO/MeshBase/include/itkMeshFileWriterException.h @@ -17,7 +17,7 @@ *=========================================================================*/ #ifndef itkMeshFileWriterException_h #define itkMeshFileWriterException_h -#include "ITKIOMeshExport.h" +#include "ITKIOMeshBaseExport.h" #include "itkMacro.h" #include "itkExceptionObject.h" @@ -27,9 +27,9 @@ namespace itk /** \class MeshFileWriterException. * \brief Base exception class for IO problems during writing. * - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase */ -class ITKIOMesh_EXPORT MeshFileWriterException:public ExceptionObject +class ITKIOMeshBase_EXPORT MeshFileWriterException:public ExceptionObject { public: /** Has to have empty throw(). */ diff --git a/Modules/IO/Mesh/include/itkMeshIOBase.h b/Modules/IO/MeshBase/include/itkMeshIOBase.h similarity index 99% rename from Modules/IO/Mesh/include/itkMeshIOBase.h rename to Modules/IO/MeshBase/include/itkMeshIOBase.h index e1c81c26afe..271eb26cf04 100644 --- a/Modules/IO/Mesh/include/itkMeshIOBase.h +++ b/Modules/IO/MeshBase/include/itkMeshIOBase.h @@ -17,7 +17,7 @@ *=========================================================================*/ #ifndef itkMeshIOBase_h #define itkMeshIOBase_h -#include "ITKIOMeshExport.h" +#include "ITKIOMeshBaseExport.h" #include "itkByteSwapper.h" #include "itkCellInterface.h" @@ -62,11 +62,11 @@ namespace itk * \sa MeshFileReader * * \ingroup IOFilters - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase * */ -class ITKIOMesh_EXPORT MeshIOBase:public LightProcessObject +class ITKIOMeshBase_EXPORT MeshIOBase:public LightProcessObject { public: /** Standard class typedefs. */ @@ -86,7 +86,7 @@ class ITKIOMesh_EXPORT MeshIOBase:public LightProcessObject /** * \class UnknownType * Used to return information when types are unknown. - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase */ class UnknownType {}; diff --git a/Modules/IO/Mesh/include/itkMeshIOFactory.h b/Modules/IO/MeshBase/include/itkMeshIOFactory.h similarity index 89% rename from Modules/IO/Mesh/include/itkMeshIOFactory.h rename to Modules/IO/MeshBase/include/itkMeshIOFactory.h index ca5dc2ec2d5..2c2598ff6de 100644 --- a/Modules/IO/Mesh/include/itkMeshIOFactory.h +++ b/Modules/IO/MeshBase/include/itkMeshIOFactory.h @@ -17,7 +17,7 @@ *=========================================================================*/ #ifndef itkMeshIOFactory_h #define itkMeshIOFactory_h -#include "ITKIOMeshExport.h" +#include "ITKIOMeshBaseExport.h" #include "itkObject.h" #include "itkMeshIOBase.h" @@ -35,9 +35,9 @@ namespace itk * Object file format (*.obj) * VTK legacy file format (*.vtk) * - * \ingroup ITKIOMesh + * \ingroup ITKIOMeshBase */ -class ITKIOMesh_EXPORT MeshIOFactory:public Object +class ITKIOMeshBase_EXPORT MeshIOFactory:public Object { public: /** Standard class typedefs. */ @@ -61,7 +61,12 @@ class ITKIOMesh_EXPORT MeshIOFactory:public Object /** Create the appropriate MeshIO depending on the particulars of the file. */ static MeshIOBasePointer CreateMeshIO(const char *path, FileModeType mode); - /** Register Built-in factories */ + /** + * \sa deprecated + * This method is deprecated, MeshIO factories are registered during + * static initialization. + * \sa RegisterFactories() + */ static void RegisterBuiltInFactories(); protected: diff --git a/Modules/IO/MeshBase/include/itkMeshIOInstantiation.inc b/Modules/IO/MeshBase/include/itkMeshIOInstantiation.inc new file mode 100644 index 00000000000..1cfc904712f --- /dev/null +++ b/Modules/IO/MeshBase/include/itkMeshIOInstantiation.inc @@ -0,0 +1,105 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +// Mesh Types +#include "itkMesh.h" +#include "itkQuadEdgeMesh.h" +#include "itkSimplexMesh.h" +#include "itkVoronoiDiagram2D.h" + +// Pixel Types +#include "itkCovariantVector.h" +#include "itkSymmetricSecondRankTensor.h" +#include "itkVariableLengthVector.h" + +// Traits types +#include "itkQuadEdgeMeshExtendedTraits.h" +#include "itkQuadEdgeMeshTraits.h" + +#ifndef ITKMeshIOInstantiation_IO_TYPE +# error "ITKMeshIOInstantiation_IO_TYPE macro is expected to set to either MeshFileReader or MeshFileWriter" +#endif + +#ifndef ITK_TEMPLATE_EXPLICIT_MeshIOInstantiation +# define MeshIO_TEMPLATE_EXPORT ITKIOMeshBase_EXPORT_EXPLICIT +# define MeshIO_TEMPLATE_EXTERN extern +#else +# define MeshIO_TEMPLATE_EXPORT ITKIOMeshBase_EXPORT +# define MeshIO_TEMPLATE_EXTERN +#endif + +#define MeshIO_DefaultTraits_TRAITS(PIXEL_TYPE, DIMENSION) + +#define MeshIO_QuadEdgeMeshTraits_TRAITS(PIXEL_TYPE, DIMENSION) \ + , QuadEdgeMeshTraits< PIXEL_TYPE, DIMENSION, bool, bool> + +#define MeshIO_QuadEdgeMeshExtendedTraits_TRAITS(PIXEL_TYPE, DIMENSION) \ + , QuadEdgeMeshExtendedTraits< PIXEL_TYPE, DIMENSION, 2, CoordType, CoordType, PIXEL_TYPE, bool, bool> + +#define MeshIO_INSTANTIATE(MESH_TYPE, PIXEL_TYPE, DIMENSION, TRAITS) \ + MeshIO_TEMPLATE_EXTERN template class MeshIO_TEMPLATE_EXPORT ITKMeshIOInstantiation_IO_TYPE< \ + MESH_TYPE \ + >; + +#define MeshIO_INSTANTIATE_FOR_PIXEL_TYPES(MESH_TYPE, DIMENSION, TRAITS) \ + MeshIO_INSTANTIATE(MESH_TYPE, float, DIMENSION, TRAITS) \ + MeshIO_INSTANTIATE(MESH_TYPE, double, DIMENSION, TRAITS) + +namespace itk +{ + +typedef double CoordType; + +typedef CovariantVector< float, 3 > CovariantVector_float_3; +typedef SymmetricSecondRankTensor< float, 2 > SymmetricSecondRankTensor_float_2; +typedef SymmetricSecondRankTensor< float, 3 > SymmetricSecondRankTensor_float_3; +typedef VariableLengthVector< float > VariableLengthVector_float_3; + +MeshIO_INSTANTIATE_FOR_PIXEL_TYPES(Mesh, 2, DefaultTraits) +MeshIO_INSTANTIATE_FOR_PIXEL_TYPES(Mesh, 3, DefaultTraits) + +MeshIO_INSTANTIATE_FOR_PIXEL_TYPES(QuadEdgeMesh, 3, QuadEdgeMeshExtendedTraits) +MeshIO_INSTANTIATE_FOR_PIXEL_TYPES(QuadEdgeMesh, 3, QuadEdgeMeshTraits) + +MeshIO_INSTANTIATE_FOR_PIXEL_TYPES(SimplexMesh, 2, DefaultTraits) +MeshIO_INSTANTIATE_FOR_PIXEL_TYPES(SimplexMesh, 3, DefaultTraits) + +// Required by ITKIOMesh itkMeshFileReadWriteVectorAttributeTest +MeshIO_INSTANTIATE(Mesh, CovariantVector_float_3, 3, DefaultTraits) +MeshIO_INSTANTIATE(QuadEdgeMesh, CovariantVector_float_3, 3, QuadEdgeMeshTraits) + +// Required by ITKIOMesh itkMeshFileWriteReadTensorTest +MeshIO_INSTANTIATE(Mesh, SymmetricSecondRankTensor_float_2, 2, DefaultTraits) +MeshIO_INSTANTIATE(Mesh, SymmetricSecondRankTensor_float_3, 3, DefaultTraits) + +// Required by ITKIOMesh itkPolylineReadWriteTest +MeshIO_INSTANTIATE(Mesh, VariableLengthVector_float_3, 3, DefaultTraits) + +// Required by ITKVoronoi itkVoronoiDiagram2DTest +MeshIO_TEMPLATE_EXTERN template class MeshIO_TEMPLATE_EXPORT + ITKMeshIOInstantiation_IO_TYPE< VoronoiDiagram2D< double > >; + +} // end namespace itk + +#undef MeshIO_TEMPLATE_EXPORT +#undef MeshIO_TEMPLATE_EXTERN +#undef MeshIO_DefaultTraits_TRAITS +#undef MeshIO_QuadEdgeMeshTraits_TRAITS +#undef MeshIO_QuadEdgeMeshExtendedTraits_TRAITS +#undef MeshIO_INSTANTIATE +#undef MeshIO_INSTANTIATE_FOR_PIXEL_TYPES diff --git a/Modules/IO/MeshBase/itk-module.cmake b/Modules/IO/MeshBase/itk-module.cmake new file mode 100644 index 00000000000..9530b4970ba --- /dev/null +++ b/Modules/IO/MeshBase/itk-module.cmake @@ -0,0 +1,18 @@ +set(DOCUMENTATION "This module contains base classes for IO, helper classes for +IO, and classes that function as an MeshSource in an ITK pipeline. Classes for +specific file formats, found in other modules in the IO group, should inherit +from MeshIOBase. For a mesh source or sink in the ITK +pipeline that handles all available file formats, see MeshFileReader, +or MeshFileWriter.") + +itk_module(ITKIOMeshBase + ENABLE_SHARED + DEPENDS + ITKCommon + ITKIOImageBase + ITKQuadEdgeMesh + ITKMesh + ITKVoronoi + DESCRIPTION + "${DOCUMENTATION}" +) diff --git a/Modules/IO/MeshBase/src/CMakeLists.txt b/Modules/IO/MeshBase/src/CMakeLists.txt new file mode 100644 index 00000000000..02828c279c6 --- /dev/null +++ b/Modules/IO/MeshBase/src/CMakeLists.txt @@ -0,0 +1,12 @@ +set(ITKIOMeshBase_SRC + itkMeshFileReader.cxx + itkMeshFileReaderException.cxx + itkMeshFileWriter.cxx + itkMeshFileWriterException.cxx + itkMeshIOBase.cxx + itkMeshIOFactory.cxx +) + +add_library(ITKIOMeshBase ${ITK_LIBRARY_BUILD_TYPE} ${ITKIOMeshBase_SRC}) +itk_module_link_dependencies() +itk_module_target(ITKIOMeshBase) diff --git a/Modules/IO/MeshBase/src/itkMeshFileReader.cxx b/Modules/IO/MeshBase/src/itkMeshFileReader.cxx new file mode 100644 index 00000000000..00ef0360790 --- /dev/null +++ b/Modules/IO/MeshBase/src/itkMeshFileReader.cxx @@ -0,0 +1,35 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#define ITK_TEMPLATE_EXPLICIT_MeshIOInstantiation +#include "itkMeshFileReader.h" +#include "itkMeshFileReader.hxx" + +#ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP + ITK_GCC_PRAGMA_DIAG_PUSH() +#endif +ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes") + +#define ITKMeshIOInstantiation_IO_TYPE MeshFileReader +#include "itkMeshIOInstantiation.inc" + +#ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP + ITK_GCC_PRAGMA_DIAG_POP() +#else + ITK_GCC_PRAGMA_DIAG(warning "-Wattributes") +#endif diff --git a/Modules/IO/Mesh/src/itkMeshFileReaderException.cxx b/Modules/IO/MeshBase/src/itkMeshFileReaderException.cxx similarity index 100% rename from Modules/IO/Mesh/src/itkMeshFileReaderException.cxx rename to Modules/IO/MeshBase/src/itkMeshFileReaderException.cxx diff --git a/Modules/IO/MeshBase/src/itkMeshFileWriter.cxx b/Modules/IO/MeshBase/src/itkMeshFileWriter.cxx new file mode 100644 index 00000000000..e067071a9ba --- /dev/null +++ b/Modules/IO/MeshBase/src/itkMeshFileWriter.cxx @@ -0,0 +1,35 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#define ITK_TEMPLATE_EXPLICIT_MeshIOInstantiation +#include "itkMeshFileWriter.h" +#include "itkMeshFileWriter.hxx" + +#ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP + ITK_GCC_PRAGMA_DIAG_PUSH() +#endif +ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes") + +#define ITKMeshIOInstantiation_IO_TYPE MeshFileWriter +#include "itkMeshIOInstantiation.inc" + +#ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP + ITK_GCC_PRAGMA_DIAG_POP() +#else + ITK_GCC_PRAGMA_DIAG(warning "-Wattributes") +#endif diff --git a/Modules/IO/Mesh/src/itkMeshFileWriterException.cxx b/Modules/IO/MeshBase/src/itkMeshFileWriterException.cxx similarity index 100% rename from Modules/IO/Mesh/src/itkMeshFileWriterException.cxx rename to Modules/IO/MeshBase/src/itkMeshFileWriterException.cxx diff --git a/Modules/IO/Mesh/src/itkMeshIOBase.cxx b/Modules/IO/MeshBase/src/itkMeshIOBase.cxx similarity index 100% rename from Modules/IO/Mesh/src/itkMeshIOBase.cxx rename to Modules/IO/MeshBase/src/itkMeshIOBase.cxx diff --git a/Modules/IO/Mesh/src/itkMeshIOFactory.cxx b/Modules/IO/MeshBase/src/itkMeshIOFactory.cxx similarity index 63% rename from Modules/IO/Mesh/src/itkMeshIOFactory.cxx rename to Modules/IO/MeshBase/src/itkMeshIOFactory.cxx index 0b189a630b1..1f698a7ba06 100644 --- a/Modules/IO/Mesh/src/itkMeshIOFactory.cxx +++ b/Modules/IO/MeshBase/src/itkMeshIOFactory.cxx @@ -16,16 +16,7 @@ * *=========================================================================*/ -#include "itkBYUMeshIOFactory.h" -#include "itkFreeSurferAsciiMeshIOFactory.h" -#include "itkFreeSurferBinaryMeshIOFactory.h" -#include "itkGiftiMeshIOFactory.h" #include "itkMeshIOFactory.h" -#include "itkOBJMeshIOFactory.h" -#include "itkOFFMeshIOFactory.h" -#include "itkMutexLock.h" -#include "itkMutexLockHolder.h" -#include "itkVTKPolyDataMeshIOFactory.h" namespace itk { @@ -45,8 +36,6 @@ MeshIOBase::Pointer MeshIOFactory ::CreateMeshIO(const char *path, FileModeType mode) { - RegisterBuiltInFactories(); - std::list< MeshIOBase::Pointer > possibleMeshIO; std::list< LightObject::Pointer > allobjects = ObjectFactoryBase::CreateAllInstance("itkMeshIOBase"); @@ -87,32 +76,11 @@ ::CreateMeshIO(const char *path, FileModeType mode) return ITK_NULLPTR; } - void MeshIOFactory ::RegisterBuiltInFactories() { - static SimpleMutexLock mutex; - - { - static bool firstTime = true; - // This helper class makes sure the Mutex is unlocked - // in the event an exception is thrown. - MutexLockHolder< SimpleMutexLock > mutexHolder(mutex); - if ( firstTime ) - { - ObjectFactoryBase::RegisterFactory( BYUMeshIOFactory::New() ); - ObjectFactoryBase::RegisterFactory( FreeSurferAsciiMeshIOFactory::New() ); - ObjectFactoryBase::RegisterFactory( FreeSurferBinaryMeshIOFactory::New() ); - ObjectFactoryBase::RegisterFactory( GiftiMeshIOFactory::New() ); - ObjectFactoryBase::RegisterFactory( OBJMeshIOFactory::New() ); - ObjectFactoryBase::RegisterFactory( OFFMeshIOFactory::New() ); - ObjectFactoryBase::RegisterFactory( VTKPolyDataMeshIOFactory::New() ); - - firstTime = false; - } - } + // deprecated } - } // end namespace itk