Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 65 additions & 16 deletions CMake/UseITK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,24 @@ macro(ADD_FACTORY_REGISTRATION _registration_list_var _names_list_var _module_na
endif()
endmacro()

# _set_module_and_factory_names(<factory_type> <module_name_prefix> <factory_name_suffix>)
#
# Set default factory and module names associated with the <factory_type> 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
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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
#-----------------------------------------------------------------------------
Expand All @@ -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}")
Expand Down
59 changes: 59 additions & 0 deletions CMake/itkMeshIOFactoryRegisterManager.h.in
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef itkTestDriverIncludeRequiredIOFactories_h
#define itkTestDriverIncludeRequiredIOFactories_h

// ImageIO
#include "itkGDCMImageIOFactory.h"
#include "itkMetaImageIOFactory.h"
#include "itkJPEGImageIOFactory.h"
Expand All @@ -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"

Expand All @@ -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() );
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Modules/Core/TestKernel/itk-module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ itk_module(ITKTestKernel
ITKIOPNG
ITKIOTIFF
ITKIOVTK
ITKIOMesh
PRIVATE_DEPENDS
ITKCommon
COMPILE_DEPENDS
Expand Down
7 changes: 3 additions & 4 deletions Modules/IO/Mesh/itk-module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
4 changes: 0 additions & 4 deletions Modules/IO/Mesh/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
set(ITKIOMesh_SRC
itkMeshFileReaderException.cxx
itkMeshFileWriterException.cxx
itkBYUMeshIO.cxx
itkBYUMeshIOFactory.cxx
itkFreeSurferAsciiMeshIO.cxx
Expand All @@ -9,8 +7,6 @@ set(ITKIOMesh_SRC
itkFreeSurferBinaryMeshIOFactory.cxx
itkGiftiMeshIO.cxx
itkGiftiMeshIOFactory.cxx
itkMeshIOBase.cxx
itkMeshIOFactory.cxx
itkOBJMeshIO.cxx
itkOBJMeshIOFactory.cxx
itkOFFMeshIO.cxx
Expand Down
15 changes: 15 additions & 0 deletions Modules/IO/Mesh/src/itkBYUMeshIOFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* limitations under the License.
*
*=========================================================================*/
#include "ITKIOMeshExport.h"

#include "itkBYUMeshIOFactory.h"
#include "itkBYUMeshIO.h"
#include "itkVersion.h"
Expand Down Expand Up @@ -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
15 changes: 15 additions & 0 deletions Modules/IO/Mesh/src/itkFreeSurferAsciiMeshIOFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*
*=========================================================================*/
#include "ITKIOMeshExport.h"

#include "itkFreeSurferAsciiMeshIO.h"
#include "itkFreeSurferAsciiMeshIOFactory.h"
Expand Down Expand Up @@ -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
15 changes: 15 additions & 0 deletions Modules/IO/Mesh/src/itkFreeSurferBinaryMeshIOFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*
*=========================================================================*/
#include "ITKIOMeshExport.h"

#include "itkFreeSurferBinaryMeshIO.h"
#include "itkFreeSurferBinaryMeshIOFactory.h"
Expand Down Expand Up @@ -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
15 changes: 15 additions & 0 deletions Modules/IO/Mesh/src/itkGiftiMeshIOFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*
*=========================================================================*/
#include "ITKIOMeshExport.h"

#include "itkGiftiMeshIO.h"
#include "itkGiftiMeshIOFactory.h"
Expand Down Expand Up @@ -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
15 changes: 15 additions & 0 deletions Modules/IO/Mesh/src/itkOBJMeshIOFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*
*=========================================================================*/
#include "ITKIOMeshExport.h"

#include "itkOBJMeshIO.h"
#include "itkOBJMeshIOFactory.h"
Expand Down Expand Up @@ -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
Loading