From 2fabb66b31e011358e52d9ba22457eab6e6c07e8 Mon Sep 17 00:00:00 2001 From: hugtalbot Date: Mon, 10 Nov 2025 10:05:39 +0100 Subject: [PATCH 01/10] Apply new factory registration mechanism --- .../image/CollisionToCarvingEngine.cpp | 94 +++++++++---------- .../plugins/image/DepthMapToMeshEngine.cpp | 32 ++++--- applications/plugins/image/GenerateImage.cpp | 30 +++--- .../image/ImageCoordValuesFromPositions.cpp | 11 ++- .../plugins/image/ImageDataDisplay.cpp | 12 ++- applications/plugins/image/ImageExporter.cpp | 29 +++--- applications/plugins/image/ImageFilter.cpp | 70 +++++++------- applications/plugins/image/ImageOperation.cpp | 29 +++--- applications/plugins/image/ImageSampler.cpp | 29 +++--- .../plugins/image/ImageToRigidMassEngine.cpp | 33 ++----- applications/plugins/image/ImageTransform.cpp | 31 +++--- .../plugins/image/ImageTransformEngine.cpp | 8 +- applications/plugins/image/ImageTypes.cpp | 33 ++++--- .../image/ImageValuesFromPositions.cpp | 29 +++--- .../plugins/image/MarchingCubesEngine.cpp | 29 +++--- applications/plugins/image/MergeImages.cpp | 29 +++--- .../plugins/image/MeshToImageEngine.cpp | 15 +-- .../plugins/image/TransferFunction.cpp | 64 ++++++------- .../plugins/image/VoronoiToMeshEngine.cpp | 15 +-- applications/plugins/image/config.h.in | 4 +- applications/plugins/image/initImage.cpp | 63 +++++++++++-- 21 files changed, 381 insertions(+), 308 deletions(-) diff --git a/applications/plugins/image/CollisionToCarvingEngine.cpp b/applications/plugins/image/CollisionToCarvingEngine.cpp index 90441fddb5f..f0584b3c09d 100644 --- a/applications/plugins/image/CollisionToCarvingEngine.cpp +++ b/applications/plugins/image/CollisionToCarvingEngine.cpp @@ -35,49 +35,47 @@ namespace engine using namespace defaulttype; -int CollisionToCarvingEngineClass = core::RegisterObject("Filter an image") - .add >(true) - .add >() - - .add >() - - .add >() - .add >() -#if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - - .add >() - .add >() - .add >() - .add >() +void registerCollisionToCarvingEngine(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Filter an image") + .add >(true) + .add >() + .add >() + .add >() + .add >() + #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + + .add >() + .add >() + .add >() + .add >() #endif // PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - ; - - -template class SOFA_IMAGE_API CollisionToCarvingEngine; -template class SOFA_IMAGE_API CollisionToCarvingEngine; - -template class SOFA_IMAGE_API CollisionToCarvingEngine; + ); +} -template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; template class SOFA_IMAGE_API CollisionToCarvingEngine; #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL @@ -93,18 +91,18 @@ template class SOFA_IMAGE_API CollisionToCarvingEngine; template class SOFA_IMAGE_API CollisionToCarvingEngine; template class SOFA_IMAGE_API CollisionToCarvingEngine; -template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; template class SOFA_IMAGE_API CollisionToCarvingEngine; -template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; template class SOFA_IMAGE_API CollisionToCarvingEngine; -template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; template class SOFA_IMAGE_API CollisionToCarvingEngine; template class SOFA_IMAGE_API CollisionToCarvingEngine; -template class SOFA_IMAGE_API CollisionToCarvingEngine; -template class SOFA_IMAGE_API CollisionToCarvingEngine; -template class SOFA_IMAGE_API CollisionToCarvingEngine; -template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; +template class SOFA_IMAGE_API CollisionToCarvingEngine; #endif // PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL } // diff --git a/applications/plugins/image/DepthMapToMeshEngine.cpp b/applications/plugins/image/DepthMapToMeshEngine.cpp index 2f852a9fa06..56b26a1d1f0 100644 --- a/applications/plugins/image/DepthMapToMeshEngine.cpp +++ b/applications/plugins/image/DepthMapToMeshEngine.cpp @@ -35,21 +35,25 @@ namespace engine using namespace defaulttype; -int DepthMapToMeshEngineClass = core::RegisterObject("Compute a mesh from a depth map image ") - .add >(true) - .add >() - .add >() +void registerDepthMapToMeshEngine(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Compute a mesh from a depth map image") + .add >(true) + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() -#endif - ; + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() +#endif + ); +} + template class SOFA_IMAGE_API DepthMapToMeshEngine; template class SOFA_IMAGE_API DepthMapToMeshEngine; diff --git a/applications/plugins/image/GenerateImage.cpp b/applications/plugins/image/GenerateImage.cpp index 1eea30cfbc6..0a6ac6c677a 100644 --- a/applications/plugins/image/GenerateImage.cpp +++ b/applications/plugins/image/GenerateImage.cpp @@ -35,21 +35,25 @@ namespace engine using namespace defaulttype; -int GenerateImageClass = core::RegisterObject("Create an image with custom dimensions") - .add >(true) - .add >() - .add >() +void registerGenerateImage(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Create an image with custom dimensions") + .add >(true) + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - ; + ); +} + template class SOFA_IMAGE_API GenerateImage; template class SOFA_IMAGE_API GenerateImage; diff --git a/applications/plugins/image/ImageCoordValuesFromPositions.cpp b/applications/plugins/image/ImageCoordValuesFromPositions.cpp index 1773b59c1e3..75a69ca1c43 100644 --- a/applications/plugins/image/ImageCoordValuesFromPositions.cpp +++ b/applications/plugins/image/ImageCoordValuesFromPositions.cpp @@ -35,10 +35,13 @@ namespace engine using namespace defaulttype; -int ImageCoordValuesFromPositionsClass = core::RegisterObject("Get interpolated coordinates at sample locations in an image with 3 channels") - .add >(true) - .add >() - ; +void registerImageCoordValuesFromPositions(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Get interpolated coordinates at sample locations in an image with 3 channels") + .add >(true) + .add >()); +} + template class SOFA_IMAGE_API ImageCoordValuesFromPositions; template class SOFA_IMAGE_API ImageCoordValuesFromPositions; diff --git a/applications/plugins/image/ImageDataDisplay.cpp b/applications/plugins/image/ImageDataDisplay.cpp index 4bfc873420d..5869f38374a 100644 --- a/applications/plugins/image/ImageDataDisplay.cpp +++ b/applications/plugins/image/ImageDataDisplay.cpp @@ -35,11 +35,13 @@ namespace engine using namespace defaulttype; -int ImageDataDisplayClass = core::RegisterObject("Store custom data in an image. A template input image with non zero voxels (where data will be stored) has to be provided") - .add >(true) - .add >() - .add >() - ; +void registerImageDataDisplay(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Store custom data in an image. A template input image with non zero voxels (where data will be stored) has to be provided") + .add >(true) + .add >() + .add >()); +} template class SOFA_IMAGE_API ImageDataDisplay; template class SOFA_IMAGE_API ImageDataDisplay; diff --git a/applications/plugins/image/ImageExporter.cpp b/applications/plugins/image/ImageExporter.cpp index 93b2aef2e65..750896d4f9b 100644 --- a/applications/plugins/image/ImageExporter.cpp +++ b/applications/plugins/image/ImageExporter.cpp @@ -37,21 +37,24 @@ namespace misc using namespace defaulttype; -int ImageExporterClass = core::RegisterObject("Save an image") - .add >(true) - .add >() - .add >() +void registerImageExporter(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Save an image") + .add >(true) + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - ; + ); +} template class SOFA_IMAGE_API ImageExporter; template class SOFA_IMAGE_API ImageExporter; diff --git a/applications/plugins/image/ImageFilter.cpp b/applications/plugins/image/ImageFilter.cpp index a91bf08cae4..bfb339d950d 100644 --- a/applications/plugins/image/ImageFilter.cpp +++ b/applications/plugins/image/ImageFilter.cpp @@ -35,44 +35,44 @@ namespace engine using namespace defaulttype; -int ImageFilterClass = core::RegisterObject("Filter an image") - .add >(true) - .add >() - - .add >() - - .add >() - .add >() - .add >() - .add >() +void registerImageFilter(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Filter an image") + .add >(true) + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - ; + ); +} + template class SOFA_IMAGE_API ImageFilter; template class SOFA_IMAGE_API ImageFilter; diff --git a/applications/plugins/image/ImageOperation.cpp b/applications/plugins/image/ImageOperation.cpp index 24c74e39e06..124dbc35466 100644 --- a/applications/plugins/image/ImageOperation.cpp +++ b/applications/plugins/image/ImageOperation.cpp @@ -35,21 +35,24 @@ namespace engine using namespace defaulttype; -int ImageOperationClass = core::RegisterObject("This class computes an image as an operation between two images") - .add >(true) - .add >() - .add >() +void registerImageOperation(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("This class computes an image as an operation between two images") + .add >(true) + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - ; + ); +} template class SOFA_IMAGE_API ImageOperation; template class SOFA_IMAGE_API ImageOperation; diff --git a/applications/plugins/image/ImageSampler.cpp b/applications/plugins/image/ImageSampler.cpp index d0ceee3f822..8d5152d6506 100644 --- a/applications/plugins/image/ImageSampler.cpp +++ b/applications/plugins/image/ImageSampler.cpp @@ -35,21 +35,24 @@ namespace engine using namespace defaulttype; -int ImageSamplerClass = core::RegisterObject("Samples an object represented by an image") - .add >(true) - .add >() - .add >() +void registerImageSampler(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Samples an object represented by an image") + .add >(true) + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL -.add >() -.add >() -.add >() -.add >() -.add >() -.add >() -.add >() -.add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - ; + ); +} template class SOFA_IMAGE_API ImageSampler; template class SOFA_IMAGE_API ImageSampler; diff --git a/applications/plugins/image/ImageToRigidMassEngine.cpp b/applications/plugins/image/ImageToRigidMassEngine.cpp index d67f872a642..54b935a6945 100644 --- a/applications/plugins/image/ImageToRigidMassEngine.cpp +++ b/applications/plugins/image/ImageToRigidMassEngine.cpp @@ -35,35 +35,18 @@ namespace engine using namespace defaulttype; -int ImageToRigidMassEngineClass = core::RegisterObject("Compute rigid mass from a density image") - .add >(true) - .add >() - .add >() -#if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL -// .add >() -// .add >() -// .add >() -// .add >() -// .add >() -// .add >() -// .add >() -// .add >() -#endif - ; +void registerImageToRigidMassEngine(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Compute rigid mass from a density image") + .add >(true) + .add >() + .add >() + ); +} template class SOFA_IMAGE_API ImageToRigidMassEngine; template class SOFA_IMAGE_API ImageToRigidMassEngine; template class SOFA_IMAGE_API ImageToRigidMassEngine; -#if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL -//template class SOFA_IMAGE_API ImageToRigidMassEngine; -//template class SOFA_IMAGE_API ImageToRigidMassEngine; -//template class SOFA_IMAGE_API ImageToRigidMassEngine; -//template class SOFA_IMAGE_API ImageToRigidMassEngine; -//template class SOFA_IMAGE_API ImageToRigidMassEngine; -//template class SOFA_IMAGE_API ImageToRigidMassEngine; -//template class SOFA_IMAGE_API ImageToRigidMassEngine; -//template class SOFA_IMAGE_API ImageToRigidMassEngine; -#endif } // diff --git a/applications/plugins/image/ImageTransform.cpp b/applications/plugins/image/ImageTransform.cpp index ed941d92555..f13a95a290a 100644 --- a/applications/plugins/image/ImageTransform.cpp +++ b/applications/plugins/image/ImageTransform.cpp @@ -33,21 +33,24 @@ namespace engine using namespace defaulttype; -int ImageTransformClass = core::RegisterObject("Read data from ImageContainer") - .add >(true) - .add >() - .add >() +void registerImageTransform(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Read data from ImageContainer") + .add >(true) + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() -#endif - ; + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() +#endif + ); +} template class SOFA_IMAGE_API ImageTransform; template class SOFA_IMAGE_API ImageTransform; diff --git a/applications/plugins/image/ImageTransformEngine.cpp b/applications/plugins/image/ImageTransformEngine.cpp index 39d117a1d13..dd49af95089 100644 --- a/applications/plugins/image/ImageTransformEngine.cpp +++ b/applications/plugins/image/ImageTransformEngine.cpp @@ -35,9 +35,11 @@ namespace engine using namespace defaulttype; -int ImageTransformEngineClass = core::RegisterObject("Apply a transform to the data 'transform'") - .add(true) - ; +void registerImageTransformEngine(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Apply a transform to the data 'transform") + .add(true)); +} } // } // namespace component diff --git a/applications/plugins/image/ImageTypes.cpp b/applications/plugins/image/ImageTypes.cpp index 8164c3d3fd3..11b8dd45997 100644 --- a/applications/plugins/image/ImageTypes.cpp +++ b/applications/plugins/image/ImageTypes.cpp @@ -17,21 +17,26 @@ static RegisterTemplateAlias ImageRAlias("ImageR", "ImageD"); #if IMAGE_HAVE_MULTITHREADING -// Register in the Factory using sofa::core::DataExchange; -int DataExchangeClass = core::RegisterObject("DataExchange") -.add< DataExchange>() -.add< DataExchange>() -.add< DataExchange>() -.add< DataExchange>() -.add< DataExchange>() -.add< DataExchange>() -.add< DataExchange>() -.add< DataExchange>() -.add< DataExchange>() -.add< DataExchange>() -.add< DataExchange>() -; + +// Register in the Factory +void registerDataExchange(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("DataExchange") + .add< DataExchange>() + .add< DataExchange>() + .add< DataExchange>() + .add< DataExchange>() + .add< DataExchange>() + .add< DataExchange>() + .add< DataExchange>() + .add< DataExchange>() + .add< DataExchange>() + .add< DataExchange>() + .add< DataExchange>() + ); +} + } // namespace defaulttype namespace core diff --git a/applications/plugins/image/ImageValuesFromPositions.cpp b/applications/plugins/image/ImageValuesFromPositions.cpp index 9ca726b9d07..58d2083a912 100644 --- a/applications/plugins/image/ImageValuesFromPositions.cpp +++ b/applications/plugins/image/ImageValuesFromPositions.cpp @@ -35,21 +35,24 @@ namespace engine using namespace defaulttype; -int ImageValuesFromPositionsClass = core::RegisterObject("Get image intensities at sample locations") - .add >(true) - .add >() - .add >() +void registerImageValuesFromPositions(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Get image intensities at sample locations") + .add >(true) + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - ; + ); +} template class SOFA_IMAGE_API ImageValuesFromPositions; template class SOFA_IMAGE_API ImageValuesFromPositions; diff --git a/applications/plugins/image/MarchingCubesEngine.cpp b/applications/plugins/image/MarchingCubesEngine.cpp index c486bb6f07f..57230c105ce 100644 --- a/applications/plugins/image/MarchingCubesEngine.cpp +++ b/applications/plugins/image/MarchingCubesEngine.cpp @@ -35,21 +35,24 @@ namespace engine using namespace defaulttype; -int MarchingCubesEngineClass = core::RegisterObject("Compute an isosurface from an image using marching cubes algorithm") - .add >(true) - .add >() - .add >() +void registerMarchingCubesEngine(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Compute an isosurface from an image using marching cubes algorithm") + .add >(true) + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - ; + ); +} template class SOFA_IMAGE_API MarchingCubesEngine; template class SOFA_IMAGE_API MarchingCubesEngine; diff --git a/applications/plugins/image/MergeImages.cpp b/applications/plugins/image/MergeImages.cpp index 8257b73813a..ec03c560bec 100644 --- a/applications/plugins/image/MergeImages.cpp +++ b/applications/plugins/image/MergeImages.cpp @@ -35,21 +35,24 @@ namespace engine using namespace defaulttype; -int MergeImagesClass = core::RegisterObject("Merge images") - .add >(true) - .add >() - .add >() +void registerMergeImages(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Merge images") + .add >(true) + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - ; + ); +} template class SOFA_IMAGE_API MergeImages; template class SOFA_IMAGE_API MergeImages; diff --git a/applications/plugins/image/MeshToImageEngine.cpp b/applications/plugins/image/MeshToImageEngine.cpp index 99b1a64d250..b7bf0f54f72 100644 --- a/applications/plugins/image/MeshToImageEngine.cpp +++ b/applications/plugins/image/MeshToImageEngine.cpp @@ -35,12 +35,15 @@ namespace engine using namespace defaulttype; -int MeshToImageEngineClass = core::RegisterObject("Compute a rasterization image from several meshes") - .add >(true) - .add >() - .add >() - .add >() - ; +void registerMeshToImageEngine(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Compute a rasterization image from several meshes") + .add >(true) + .add >() + .add >() + .add >() + ); +} template class SOFA_IMAGE_API MeshToImageEngine; template class SOFA_IMAGE_API MeshToImageEngine; diff --git a/applications/plugins/image/TransferFunction.cpp b/applications/plugins/image/TransferFunction.cpp index bd9d4c4d178..e8a548ccc40 100644 --- a/applications/plugins/image/TransferFunction.cpp +++ b/applications/plugins/image/TransferFunction.cpp @@ -33,45 +33,45 @@ namespace engine using namespace defaulttype; -int TransferFunctionClass = core::RegisterObject("Transforms pixel intensities") - .add >(true) - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() +void registerTransferFunction(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Transforms pixel intensities") + .add >(true) + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - ; + ); +} template class SOFA_IMAGE_API TransferFunction; template class SOFA_IMAGE_API TransferFunction; - template class SOFA_IMAGE_API TransferFunction; - template class SOFA_IMAGE_API TransferFunction; template class SOFA_IMAGE_API TransferFunction; template class SOFA_IMAGE_API TransferFunction; diff --git a/applications/plugins/image/VoronoiToMeshEngine.cpp b/applications/plugins/image/VoronoiToMeshEngine.cpp index 2f341b9ce34..24bc9093f21 100644 --- a/applications/plugins/image/VoronoiToMeshEngine.cpp +++ b/applications/plugins/image/VoronoiToMeshEngine.cpp @@ -35,14 +35,17 @@ namespace engine using namespace defaulttype; -int VoronoiToMeshEngineClass = core::RegisterObject("Generate flat faces between adjacent regions of an image") - .add >(true) - .add >() +void registerVoronoiToMeshEngine(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Generate flat faces between adjacent regions of an image") + .add >(true) + .add >() #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() + .add >() + .add >() #endif - ; + ); +} template class SOFA_IMAGE_API VoronoiToMeshEngine; template class SOFA_IMAGE_API VoronoiToMeshEngine; diff --git a/applications/plugins/image/config.h.in b/applications/plugins/image/config.h.in index d92d9a85673..cf2d9e40b83 100644 --- a/applications/plugins/image/config.h.in +++ b/applications/plugins/image/config.h.in @@ -19,8 +19,7 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#ifndef IMAGE_CONFIG_H -#define IMAGE_CONFIG_H +#pragma once #include @@ -54,4 +53,3 @@ namespace image constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@"; } // namespace image -#endif diff --git a/applications/plugins/image/initImage.cpp b/applications/plugins/image/initImage.cpp index a1a83e3cbc0..1b8f0488afa 100644 --- a/applications/plugins/image/initImage.cpp +++ b/applications/plugins/image/initImage.cpp @@ -20,6 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #include +#include #include #include @@ -28,12 +29,39 @@ #include "python/Binding_ImageData.h" #endif +namespace sofa::defaulttype +{ + extern void registerDataExchange(sofa::core::ObjectFactory* factory); +} + +namespace sofa::component +{ -namespace sofa +namespace misc { + extern void registerImageExporter(sofa::core::ObjectFactory* factory); +} -namespace component +namespace engine { + extern void registerVoronoiToMeshEngine(sofa::core::ObjectFactory* factory); + extern void registerTransferFunction(sofa::core::ObjectFactory* factory); + extern void registerMeshToImageEngine(sofa::core::ObjectFactory* factory); + extern void registerMergeImages(sofa::core::ObjectFactory* factory); + extern void registerMarchingCubesEngine(sofa::core::ObjectFactory* factory); + extern void registerImageValuesFromPositions(sofa::core::ObjectFactory* factory); + extern void registerImageTransformEngine(sofa::core::ObjectFactory* factory); + extern void registerImageTransform(sofa::core::ObjectFactory* factory); + extern void registerImageToRigidMassEngine(sofa::core::ObjectFactory* factory); + extern void registerImageSampler(sofa::core::ObjectFactory* factory); + extern void registerImageOperation(sofa::core::ObjectFactory* factory); + extern void registerImageFilter(sofa::core::ObjectFactory* factory); + extern void registerImageDataDisplay(sofa::core::ObjectFactory* factory); + extern void registerImageCoordValuesFromPositions(sofa::core::ObjectFactory* factory); + extern void registerGenerateImage(sofa::core::ObjectFactory* factory); + extern void registerDepthMapToMeshEngine(sofa::core::ObjectFactory* factory); + extern void registerCollisionToCarvingEngine(sofa::core::ObjectFactory* factory); +} //Here are just several convenient functions to help user to know what contains the plugin @@ -43,7 +71,7 @@ extern "C" { SOFA_IMAGE_API const char* getModuleVersion(); SOFA_IMAGE_API const char* getModuleLicense(); SOFA_IMAGE_API const char* getModuleDescription(); - SOFA_IMAGE_API const char* getModuleComponentList(); + SOFA_IMAGE_API void registerObjects(sofa::core::ObjectFactory* factory); } void initExternalModule() @@ -51,6 +79,9 @@ void initExternalModule() static bool first = true; if (first) { + // make sure that this plugin is registered into the PluginManager + sofa::helper::system::PluginManager::getInstance().registerPlugin(image::MODULE_NAME); + first = false; #if IMAGE_HAVE_SOFAPYTHON @@ -106,12 +137,28 @@ const char* getModuleDescription() return "Image support in SOFA"; } -const char* getModuleComponentList() +void registerObjects(sofa::core::ObjectFactory* factory) { - return "ImageContainer,ImageExporter,ImageViewer,ImageFilter,ImageToMeshEngine"; + sofa::defaulttype::registerDataExchange(factory); + sofa::component::misc::registerImageExporter(factory); + sofa::component::engine::registerVoronoiToMeshEngine(factory); + sofa::component::engine::registerTransferFunction(factory); + sofa::component::engine::registerMeshToImageEngine(factory); + sofa::component::engine::registerMergeImages(factory); + sofa::component::engine::registerMarchingCubesEngine(factory); + sofa::component::engine::registerImageValuesFromPositions(factory); + sofa::component::engine::registerImageTransformEngine(factory); + sofa::component::engine::registerImageTransform(factory); + sofa::component::engine::registerImageToRigidMassEngine(factory); + sofa::component::engine::registerImageSampler(factory); + sofa::component::engine::registerImageOperation(factory); + sofa::component::engine::registerImageFilter(factory); + sofa::component::engine::registerImageDataDisplay(factory); + sofa::component::engine::registerImageCoordValuesFromPositions(factory); + sofa::component::engine::registerGenerateImage(factory); + sofa::component::engine::registerDepthMapToMeshEngine(factory); + sofa::component::engine::registerCollisionToCarvingEngine(factory); } -} // namespace image - -} // namespace sofa +} // namespace sofa::component From 19e91fb88b53d455ddd03eeb21b94f99f7df499f Mon Sep 17 00:00:00 2001 From: hugtalbot Date: Tue, 11 Nov 2025 13:20:33 +0100 Subject: [PATCH 02/10] Add test and toolbox from image plugin --- applications/plugins/image/config.h.in | 3 ++ .../image/image_test/TestImageEngine.cpp | 9 +++-- .../contour/contourimagetoolbox.cpp | 8 +++-- .../depth/averagecatchallvector.cpp | 11 +++---- .../imagetoolbox/depth/catchallvector.cpp | 14 ++++---- .../imagetoolbox/depth/depthimagetoolbox.cpp | 12 ++++--- .../depth/mergedcatchallvector.cpp | 11 +++---- .../labelbox/labelboximagetoolbox.cpp | 12 ++++--- .../labelgrid/labelgridimagetoolbox.cpp | 30 +++++++++-------- .../labelpoint/labelpointimagetoolbox.cpp | 12 ++++--- .../labelpointsbysectionimagetoolbox.cpp | 12 ++++--- .../distancezoneimagetoolbox.cpp | 33 ++++++++++--------- .../zonegeneratorimagetoolbox.cpp | 33 +++++++++++-------- applications/plugins/image/initImage.cpp | 25 ++++++++++++++ 14 files changed, 142 insertions(+), 83 deletions(-) diff --git a/applications/plugins/image/config.h.in b/applications/plugins/image/config.h.in index cf2d9e40b83..dbd14024e87 100644 --- a/applications/plugins/image/config.h.in +++ b/applications/plugins/image/config.h.in @@ -32,6 +32,9 @@ #cmakedefine01 IMAGE_HAVE_FREENECT #cmakedefine01 IMAGE_HAVE_SOFA_GL +#cmakedefine SOFA_BUILD_TESTS +#cmakedefine PLUGIN_IMAGE_COMPILE_GUI + #define PLUGIN_IMAGE_COMPILE_SET_NONE 0 #define PLUGIN_IMAGE_COMPILE_SET_STANDARD 1 #define PLUGIN_IMAGE_COMPILE_SET_FULL 2 diff --git a/applications/plugins/image/image_test/TestImageEngine.cpp b/applications/plugins/image/image_test/TestImageEngine.cpp index 35073a797a6..b298686d6de 100644 --- a/applications/plugins/image/image_test/TestImageEngine.cpp +++ b/applications/plugins/image/image_test/TestImageEngine.cpp @@ -33,8 +33,9 @@ namespace engine { using namespace sofa::defaulttype; -int TestImageEngineClass = core::RegisterObject("TestImageEngine to test engine with data image") - +void registerTestImageEngine(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("TestImageEngine to test engine with data image") .add >(true) .add >() #ifdef BUILD_ALL_IMAGE_TYPES @@ -48,7 +49,9 @@ int TestImageEngineClass = core::RegisterObject("TestImageEngine to test engine .add >() .add >() #endif - ; + ); +} + template class TestImageEngine; template class TestImageEngine; diff --git a/applications/plugins/image/imagetoolbox/contour/contourimagetoolbox.cpp b/applications/plugins/image/imagetoolbox/contour/contourimagetoolbox.cpp index 4f27df34ef2..ac890e5823b 100644 --- a/applications/plugins/image/imagetoolbox/contour/contourimagetoolbox.cpp +++ b/applications/plugins/image/imagetoolbox/contour/contourimagetoolbox.cpp @@ -16,7 +16,9 @@ namespace component namespace engine { -int ContourImageToolBox_Class = core::RegisterObject("ContourImageToolBox") +void registerContourImageToolBox(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("ContourImageToolBox") .add >() .add >(true) #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL @@ -31,7 +33,9 @@ int ContourImageToolBox_Class = core::RegisterObject("ContourImageToolBox") .add >() #endif .addLicense("LGPL") - .addAuthor("Vincent Majorczyk"); + .addAuthor("Vincent Majorczyk") + ); +} template class SOFA_IMAGE_GUI_API ContourImageToolBox; template class SOFA_IMAGE_GUI_API ContourImageToolBox; diff --git a/applications/plugins/image/imagetoolbox/depth/averagecatchallvector.cpp b/applications/plugins/image/imagetoolbox/depth/averagecatchallvector.cpp index bf2c49d03fd..5bbb6c0a355 100644 --- a/applications/plugins/image/imagetoolbox/depth/averagecatchallvector.cpp +++ b/applications/plugins/image/imagetoolbox/depth/averagecatchallvector.cpp @@ -33,30 +33,29 @@ namespace engine using namespace defaulttype; -int AverageCatchAllVectorClass = core::RegisterObject("AverageCatchAllVector") +void registerAverageCatchAllVector(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("AverageCatchAllVector") .add >(true) - //.add >() .add >() .add >() .add >() .add >() .add >() - //.add >() .add >() .add >() .add >() .add >() .add >() - ; + ); +} template class SOFA_IMAGE_GUI_API AverageCatchAllVector; -//template class SOFA_IMAGE_API AverageCatchAllVector; template class SOFA_IMAGE_GUI_API AverageCatchAllVector; template class SOFA_IMAGE_GUI_API AverageCatchAllVector; template class SOFA_IMAGE_GUI_API AverageCatchAllVector; template class SOFA_IMAGE_GUI_API AverageCatchAllVector; template class SOFA_IMAGE_GUI_API AverageCatchAllVector; -//template class SOFA_IMAGE_API AverageCatchAllVector; template class SOFA_IMAGE_GUI_API AverageCatchAllVector; template class SOFA_IMAGE_GUI_API AverageCatchAllVector; template class SOFA_IMAGE_GUI_API AverageCatchAllVector; diff --git a/applications/plugins/image/imagetoolbox/depth/catchallvector.cpp b/applications/plugins/image/imagetoolbox/depth/catchallvector.cpp index 1ec2a45517d..b38fdaf2b61 100644 --- a/applications/plugins/image/imagetoolbox/depth/catchallvector.cpp +++ b/applications/plugins/image/imagetoolbox/depth/catchallvector.cpp @@ -34,30 +34,30 @@ namespace engine using namespace defaulttype; -int CatchAllVectorClass = core::RegisterObject("CatchAllVector") +void registerCatchAllVector(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("CatchAllVector") .add >(true) - //.add >() .add >() .add >() .add >() .add >() .add >() - //.add >() .add >() .add >() .add >() .add >() .add >() - ; + ); +} + template class SOFA_IMAGE_GUI_API CatchAllVector; -//template class SOFA_IMAGE_GUI_API CatchAllVector; template class SOFA_IMAGE_GUI_API CatchAllVector; template class SOFA_IMAGE_GUI_API CatchAllVector; template class SOFA_IMAGE_GUI_API CatchAllVector; template class SOFA_IMAGE_GUI_API CatchAllVector; template class SOFA_IMAGE_GUI_API CatchAllVector; -//template class SOFA_IMAGE_GUI_API CatchAllVector; template class SOFA_IMAGE_GUI_API CatchAllVector; template class SOFA_IMAGE_GUI_API CatchAllVector; template class SOFA_IMAGE_GUI_API CatchAllVector; @@ -65,8 +65,6 @@ template class SOFA_IMAGE_GUI_API CatchAllVector; template class SOFA_IMAGE_GUI_API CatchAllVector; - - } // } // namespace component } // namespace sofa diff --git a/applications/plugins/image/imagetoolbox/depth/depthimagetoolbox.cpp b/applications/plugins/image/imagetoolbox/depth/depthimagetoolbox.cpp index 9153b2cc9d7..ee7af3d9d85 100644 --- a/applications/plugins/image/imagetoolbox/depth/depthimagetoolbox.cpp +++ b/applications/plugins/image/imagetoolbox/depth/depthimagetoolbox.cpp @@ -18,10 +18,14 @@ namespace component namespace engine { -int DepthImageToolBox_Class = core::RegisterObject("DepthImageToolBox") -.add< DepthImageToolBox >() -.addLicense("LGPL") -.addAuthor("Vincent Majorczyk"); +void registerDepthImageToolBox(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("DepthImageToolBox") + .add< DepthImageToolBox >() + .addLicense("LGPL") + .addAuthor("Vincent Majorczyk") + ); +} }}} diff --git a/applications/plugins/image/imagetoolbox/depth/mergedcatchallvector.cpp b/applications/plugins/image/imagetoolbox/depth/mergedcatchallvector.cpp index 380c985f336..880ea608e31 100644 --- a/applications/plugins/image/imagetoolbox/depth/mergedcatchallvector.cpp +++ b/applications/plugins/image/imagetoolbox/depth/mergedcatchallvector.cpp @@ -34,30 +34,29 @@ namespace engine using namespace defaulttype; -int MergedCatchAllVectorClass = core::RegisterObject("MergedCatchAllVector") +void registerMergedCatchAllVector(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("MergedCatchAllVector") .add >(true) - //.add >() .add >() .add >() .add >() .add >() .add >() - //.add >() .add >() .add >() .add >() .add >() .add >() - ; + ); +} template class SOFA_IMAGE_GUI_API MergedCatchAllVector; -//template class SOFA_IMAGE_GUI_API MergedCatchAllVector; template class SOFA_IMAGE_GUI_API MergedCatchAllVector; template class SOFA_IMAGE_GUI_API MergedCatchAllVector; template class SOFA_IMAGE_GUI_API MergedCatchAllVector; template class SOFA_IMAGE_GUI_API MergedCatchAllVector; template class SOFA_IMAGE_GUI_API MergedCatchAllVector; -//template class SOFA_IMAGE_GUI_API MergedCatchAllVector; template class SOFA_IMAGE_GUI_API MergedCatchAllVector; template class SOFA_IMAGE_GUI_API MergedCatchAllVector; template class SOFA_IMAGE_GUI_API MergedCatchAllVector; diff --git a/applications/plugins/image/imagetoolbox/labelbox/labelboximagetoolbox.cpp b/applications/plugins/image/imagetoolbox/labelbox/labelboximagetoolbox.cpp index 1f4321c6a7d..942aff22a02 100644 --- a/applications/plugins/image/imagetoolbox/labelbox/labelboximagetoolbox.cpp +++ b/applications/plugins/image/imagetoolbox/labelbox/labelboximagetoolbox.cpp @@ -13,10 +13,14 @@ namespace component namespace engine { -int LabelBoxImageToolBox_Class = core::RegisterObject("LabelBoxImageToolBox") -.add< LabelBoxImageToolBox >() -.addLicense("LGPL") -.addAuthor("Vincent Majorczyk"); +void registerLabelBoxImageToolBox(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("LabelBoxImageToolBox") + .add< LabelBoxImageToolBox >() + .addLicense("LGPL") + .addAuthor("Vincent Majorczyk") + ); +} }}} diff --git a/applications/plugins/image/imagetoolbox/labelgrid/labelgridimagetoolbox.cpp b/applications/plugins/image/imagetoolbox/labelgrid/labelgridimagetoolbox.cpp index 45bcd406d6e..f223f7a6651 100644 --- a/applications/plugins/image/imagetoolbox/labelgrid/labelgridimagetoolbox.cpp +++ b/applications/plugins/image/imagetoolbox/labelgrid/labelgridimagetoolbox.cpp @@ -19,22 +19,26 @@ namespace engine using namespace sofa::defaulttype; -int LabelGridImageToolBox_Class = core::RegisterObject("LabelGridImageToolBox") - .add >() - .add >(true) +void registerLabelGridImageToolBox(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("LabelGridImageToolBox") + .add >() + .add >(true) #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif .addLicense("LGPL") - .addAuthor("Vincent Majorczyk"); + .addAuthor("Vincent Majorczyk") + ); +} template class SOFA_IMAGE_GUI_API LabelGridImageToolBox; template class SOFA_IMAGE_GUI_API LabelGridImageToolBox; diff --git a/applications/plugins/image/imagetoolbox/labelpoint/labelpointimagetoolbox.cpp b/applications/plugins/image/imagetoolbox/labelpoint/labelpointimagetoolbox.cpp index 3d6b2baa283..42b7f917837 100644 --- a/applications/plugins/image/imagetoolbox/labelpoint/labelpointimagetoolbox.cpp +++ b/applications/plugins/image/imagetoolbox/labelpoint/labelpointimagetoolbox.cpp @@ -13,10 +13,14 @@ namespace component namespace engine { -int LabelPointImageToolBox_Class = core::RegisterObject("LabelPointImageToolBox") -.add< LabelPointImageToolBox >() -.addLicense("LGPL") -.addAuthor("Vincent Majorczyk"); +void registerLabelPointImageToolBox(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("LabelPointImageToolBox") + .add< LabelPointImageToolBox >() + .addLicense("LGPL") + .addAuthor("Vincent Majorczyk") + ); +} }}} diff --git a/applications/plugins/image/imagetoolbox/labelpointsbysection/labelpointsbysectionimagetoolbox.cpp b/applications/plugins/image/imagetoolbox/labelpointsbysection/labelpointsbysectionimagetoolbox.cpp index dca408071ed..c03e67ab670 100644 --- a/applications/plugins/image/imagetoolbox/labelpointsbysection/labelpointsbysectionimagetoolbox.cpp +++ b/applications/plugins/image/imagetoolbox/labelpointsbysection/labelpointsbysectionimagetoolbox.cpp @@ -13,10 +13,14 @@ namespace component namespace engine { -int LabelPointsBySectionImageToolBox_Class = core::RegisterObject("LabelPointsBySectionImageToolBox") -.add< LabelPointsBySectionImageToolBox >() -.addLicense("LGPL") -.addAuthor("Vincent Majorczyk"); +void registerLabelPointsBySectionImageToolBox(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("LabelPointsBySectionImageToolBox") + .add< LabelPointsBySectionImageToolBox >() + .addLicense("LGPL") + .addAuthor("Vincent Majorczyk") + ); +} }}} diff --git a/applications/plugins/image/imagetoolbox/zonegenerator/distancezoneimagetoolbox.cpp b/applications/plugins/image/imagetoolbox/zonegenerator/distancezoneimagetoolbox.cpp index ba195f7d81d..03cb0ba0fd9 100644 --- a/applications/plugins/image/imagetoolbox/zonegenerator/distancezoneimagetoolbox.cpp +++ b/applications/plugins/image/imagetoolbox/zonegenerator/distancezoneimagetoolbox.cpp @@ -15,23 +15,26 @@ namespace component namespace engine { -int DistanceZoneImageToolBox_Class = core::RegisterObject("DistanceZoneImageToolBox") - .add >() - .add >(true) +void registerDistanceZoneImageToolBox(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("DistanceZoneImageToolBox") + .add >() + .add >(true) #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - .addLicense("LGPL") - .addAuthor("Vincent Majorczyk"); - + .addLicense("LGPL") + .addAuthor("Vincent Majorczyk") + ); +} diff --git a/applications/plugins/image/imagetoolbox/zonegenerator/zonegeneratorimagetoolbox.cpp b/applications/plugins/image/imagetoolbox/zonegenerator/zonegeneratorimagetoolbox.cpp index 82903105c5c..4584e7ff72c 100644 --- a/applications/plugins/image/imagetoolbox/zonegenerator/zonegeneratorimagetoolbox.cpp +++ b/applications/plugins/image/imagetoolbox/zonegenerator/zonegeneratorimagetoolbox.cpp @@ -15,22 +15,27 @@ namespace component namespace engine { -int ZoneGeneratorImageToolBox_Class = core::RegisterObject("ZoneGeneratorImageToolBox") - .add >() - .add >(true) +void registerZoneGeneratorImageToolBox(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("ZoneGeneratorImageToolBox") + .add >() + .add >(true) #if PLUGIN_IMAGE_COMPILE_SET == PLUGIN_IMAGE_COMPILE_SET_FULL - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() - .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() + .add >() #endif - .addLicense("LGPL") - .addAuthor("Vincent Majorczyk"); + .addLicense("LGPL") + .addAuthor("Vincent Majorczyk") + ); +} + template<> double ZoneGeneratorImageToolBox::color(int index,int max) diff --git a/applications/plugins/image/initImage.cpp b/applications/plugins/image/initImage.cpp index 1b8f0488afa..80a5d87a671 100644 --- a/applications/plugins/image/initImage.cpp +++ b/applications/plugins/image/initImage.cpp @@ -61,6 +61,24 @@ namespace engine extern void registerGenerateImage(sofa::core::ObjectFactory* factory); extern void registerDepthMapToMeshEngine(sofa::core::ObjectFactory* factory); extern void registerCollisionToCarvingEngine(sofa::core::ObjectFactory* factory); + +#if SOFA_BUILD_TESTS + extern void registerTestImageEngine(sofa::core::ObjectFactory* factory); +#endif + +#if PLUGIN_IMAGE_COMPILE_GUI + extern void registerContourImageToolBox(sofa::core::ObjectFactory* factory); + extern void registerAverageCatchAllVector(sofa::core::ObjectFactory* factory); + extern void registerCatchAllVector(sofa::core::ObjectFactory* factory); + extern void registerDepthImageToolBox(sofa::core::ObjectFactory* factory); + extern void registerMergedCatchAllVector(sofa::core::ObjectFactory* factory); + extern void registerLabelBoxImageToolBox(sofa::core::ObjectFactory* factory); + extern void registerLabelGridImageToolBox(sofa::core::ObjectFactory* factory); + extern void registerLabelPointImageToolBox(sofa::core::ObjectFactory* factory); + extern void registerLabelPointsBySectionImageToolBox(sofa::core::ObjectFactory* factory); + extern void registerDistanceZoneImageToolBox(sofa::core::ObjectFactory* factory); + extern void registerZoneGeneratorImageToolBox(sofa::core::ObjectFactory* factory); +#endif } //Here are just several convenient functions to help user to know what contains the plugin @@ -158,6 +176,13 @@ void registerObjects(sofa::core::ObjectFactory* factory) sofa::component::engine::registerGenerateImage(factory); sofa::component::engine::registerDepthMapToMeshEngine(factory); sofa::component::engine::registerCollisionToCarvingEngine(factory); + +#if SOFA_BUILD_TESTS + sofa::component::engine::registerTestImageEngine(factory); +#endif + +#if PLUGIN_IMAGE_COMPILE_GUI +#endif } } // namespace sofa::component From ea646b869b5bdb51655a2adb9f304e13f472bad8 Mon Sep 17 00:00:00 2001 From: hugtalbot Date: Thu, 13 Nov 2025 16:59:49 +0100 Subject: [PATCH 03/10] Fix #if into #ifdef in initImage --- applications/plugins/image/initImage.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/plugins/image/initImage.cpp b/applications/plugins/image/initImage.cpp index 80a5d87a671..a8d27b2966e 100644 --- a/applications/plugins/image/initImage.cpp +++ b/applications/plugins/image/initImage.cpp @@ -62,11 +62,11 @@ namespace engine extern void registerDepthMapToMeshEngine(sofa::core::ObjectFactory* factory); extern void registerCollisionToCarvingEngine(sofa::core::ObjectFactory* factory); -#if SOFA_BUILD_TESTS +#ifdef SOFA_BUILD_TESTS extern void registerTestImageEngine(sofa::core::ObjectFactory* factory); #endif -#if PLUGIN_IMAGE_COMPILE_GUI +#ifdef PLUGIN_IMAGE_COMPILE_GUI extern void registerContourImageToolBox(sofa::core::ObjectFactory* factory); extern void registerAverageCatchAllVector(sofa::core::ObjectFactory* factory); extern void registerCatchAllVector(sofa::core::ObjectFactory* factory); @@ -102,7 +102,7 @@ void initExternalModule() first = false; -#if IMAGE_HAVE_SOFAPYTHON +#ifdef IMAGE_HAVE_SOFAPYTHON if( PythonFactory::s_sofaPythonModule ) // add the module only if the Sofa module exists (SofaPython is loaded) { simulation::PythonEnvironment::gil lock(__func__); @@ -177,11 +177,11 @@ void registerObjects(sofa::core::ObjectFactory* factory) sofa::component::engine::registerDepthMapToMeshEngine(factory); sofa::component::engine::registerCollisionToCarvingEngine(factory); -#if SOFA_BUILD_TESTS +#ifdef SOFA_BUILD_TESTS sofa::component::engine::registerTestImageEngine(factory); #endif -#if PLUGIN_IMAGE_COMPILE_GUI +#ifdef PLUGIN_IMAGE_COMPILE_GUI #endif } From 36044beb55c56430bc6331a131c960272de750f3 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 13 Nov 2025 17:10:52 +0100 Subject: [PATCH 04/10] Apply suggestions from code review --- applications/plugins/image/initImage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/plugins/image/initImage.cpp b/applications/plugins/image/initImage.cpp index a8d27b2966e..42904687728 100644 --- a/applications/plugins/image/initImage.cpp +++ b/applications/plugins/image/initImage.cpp @@ -102,7 +102,7 @@ void initExternalModule() first = false; -#ifdef IMAGE_HAVE_SOFAPYTHON +#if IMAGE_HAVE_SOFAPYTHON if( PythonFactory::s_sofaPythonModule ) // add the module only if the Sofa module exists (SofaPython is loaded) { simulation::PythonEnvironment::gil lock(__func__); From db93cc28737b8dc056fb1256ea8268de1097df8d Mon Sep 17 00:00:00 2001 From: Hugo Date: Fri, 14 Nov 2025 15:21:54 +0100 Subject: [PATCH 05/10] Apply suggestions from code review --- applications/plugins/image/initImage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/plugins/image/initImage.cpp b/applications/plugins/image/initImage.cpp index 42904687728..0699a08af06 100644 --- a/applications/plugins/image/initImage.cpp +++ b/applications/plugins/image/initImage.cpp @@ -62,7 +62,7 @@ namespace engine extern void registerDepthMapToMeshEngine(sofa::core::ObjectFactory* factory); extern void registerCollisionToCarvingEngine(sofa::core::ObjectFactory* factory); -#ifdef SOFA_BUILD_TESTS +#if SOFA_BUILD_TESTS extern void registerTestImageEngine(sofa::core::ObjectFactory* factory); #endif @@ -177,7 +177,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) sofa::component::engine::registerDepthMapToMeshEngine(factory); sofa::component::engine::registerCollisionToCarvingEngine(factory); -#ifdef SOFA_BUILD_TESTS +#if SOFA_BUILD_TESTS sofa::component::engine::registerTestImageEngine(factory); #endif From c5b8958d11612ed29e5da84cde5e8c682b6a13ff Mon Sep 17 00:00:00 2001 From: hugtalbot Date: Mon, 17 Nov 2025 09:55:25 +0100 Subject: [PATCH 06/10] add == 1 condition --- applications/plugins/image/initImage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/plugins/image/initImage.cpp b/applications/plugins/image/initImage.cpp index 0699a08af06..00a08e15909 100644 --- a/applications/plugins/image/initImage.cpp +++ b/applications/plugins/image/initImage.cpp @@ -62,7 +62,7 @@ namespace engine extern void registerDepthMapToMeshEngine(sofa::core::ObjectFactory* factory); extern void registerCollisionToCarvingEngine(sofa::core::ObjectFactory* factory); -#if SOFA_BUILD_TESTS +#if SOFA_BUILD_TESTS == 1 extern void registerTestImageEngine(sofa::core::ObjectFactory* factory); #endif @@ -177,7 +177,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) sofa::component::engine::registerDepthMapToMeshEngine(factory); sofa::component::engine::registerCollisionToCarvingEngine(factory); -#if SOFA_BUILD_TESTS +#if SOFA_BUILD_TESTS == 1 sofa::component::engine::registerTestImageEngine(factory); #endif From b90f75afaaf189b0cedb3d68843c881499a81db9 Mon Sep 17 00:00:00 2001 From: hugtalbot Date: Mon, 17 Nov 2025 12:30:55 +0100 Subject: [PATCH 07/10] add aanother if --- applications/plugins/image/initImage.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/applications/plugins/image/initImage.cpp b/applications/plugins/image/initImage.cpp index 00a08e15909..7f12ea0c5a8 100644 --- a/applications/plugins/image/initImage.cpp +++ b/applications/plugins/image/initImage.cpp @@ -62,8 +62,10 @@ namespace engine extern void registerDepthMapToMeshEngine(sofa::core::ObjectFactory* factory); extern void registerCollisionToCarvingEngine(sofa::core::ObjectFactory* factory); -#if SOFA_BUILD_TESTS == 1 +#ifdef SOFA_BUILD_TESTS + #if SOFA_BUILD_TESTS == 1 extern void registerTestImageEngine(sofa::core::ObjectFactory* factory); + #endif #endif #ifdef PLUGIN_IMAGE_COMPILE_GUI @@ -177,8 +179,10 @@ void registerObjects(sofa::core::ObjectFactory* factory) sofa::component::engine::registerDepthMapToMeshEngine(factory); sofa::component::engine::registerCollisionToCarvingEngine(factory); -#if SOFA_BUILD_TESTS == 1 - sofa::component::engine::registerTestImageEngine(factory); +#ifdef SOFA_BUILD_TESTS + #if SOFA_BUILD_TESTS == 1 + sofa::component::engine::registerTestImageEngine(factory); + #endif #endif #ifdef PLUGIN_IMAGE_COMPILE_GUI From 791ec3942db893757cf0163a080360a39cd1c8dd Mon Sep 17 00:00:00 2001 From: hugtalbot Date: Wed, 19 Nov 2025 16:06:56 +0100 Subject: [PATCH 08/10] keep only ifdef SOFA_BUILD_TESTS --- applications/plugins/image/initImage.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/applications/plugins/image/initImage.cpp b/applications/plugins/image/initImage.cpp index 7f12ea0c5a8..42904687728 100644 --- a/applications/plugins/image/initImage.cpp +++ b/applications/plugins/image/initImage.cpp @@ -63,9 +63,7 @@ namespace engine extern void registerCollisionToCarvingEngine(sofa::core::ObjectFactory* factory); #ifdef SOFA_BUILD_TESTS - #if SOFA_BUILD_TESTS == 1 extern void registerTestImageEngine(sofa::core::ObjectFactory* factory); - #endif #endif #ifdef PLUGIN_IMAGE_COMPILE_GUI @@ -180,9 +178,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) sofa::component::engine::registerCollisionToCarvingEngine(factory); #ifdef SOFA_BUILD_TESTS - #if SOFA_BUILD_TESTS == 1 - sofa::component::engine::registerTestImageEngine(factory); - #endif + sofa::component::engine::registerTestImageEngine(factory); #endif #ifdef PLUGIN_IMAGE_COMPILE_GUI From 02d250a217a0aa440f24d393b0f13dde51bfd133 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 20 Nov 2025 10:20:35 +0900 Subject: [PATCH 09/10] fix compilation of image with eigenv5 --- applications/plugins/image/MeshToImageEngine.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/applications/plugins/image/MeshToImageEngine.h b/applications/plugins/image/MeshToImageEngine.h index e5ff3738f50..76fc1e16dff 100644 --- a/applications/plugins/image/MeshToImageEngine.h +++ b/applications/plugins/image/MeshToImageEngine.h @@ -322,8 +322,7 @@ class MeshToImageEngine : public core::DataEngine M/=(Real)nbpTotal; // get eigen vectors of the covariance matrix - Eigen::Matrix e; - e.resize(3, 3); + Eigen::Matrix e; e.setZero(); for (size_t j = 0; j < 3; j++) { @@ -334,7 +333,7 @@ class MeshToImageEngine : public core::DataEngine } //compute eigenvalues and eigenvectors - Eigen::JacobiSVD svd(e, Eigen::ComputeThinU | Eigen::ComputeThinV); + Eigen::JacobiSVD> svd(e, Eigen::ComputeThinU | Eigen::ComputeThinV); auto V = svd.matrixV(); for(size_t j=0; j<3; j++) for(size_t k=0; k<3; k++) M[j][k]=V(j,k); From d68cf6f937c19cd8a7ba594f8b04f46f1062bd16 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 20 Nov 2025 10:21:24 +0900 Subject: [PATCH 10/10] call registation when executing image_test --- .../image/image_test/TestImageEngine.cpp | 34 +++++++++---------- applications/plugins/image/initImage.cpp | 11 ------ 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/applications/plugins/image/image_test/TestImageEngine.cpp b/applications/plugins/image/image_test/TestImageEngine.cpp index b298686d6de..2959fa144bb 100644 --- a/applications/plugins/image/image_test/TestImageEngine.cpp +++ b/applications/plugins/image/image_test/TestImageEngine.cpp @@ -33,9 +33,23 @@ namespace engine { using namespace sofa::defaulttype; -void registerTestImageEngine(sofa::core::ObjectFactory* factory) -{ - factory->registerObjects(sofa::core::ObjectRegistrationData("TestImageEngine to test engine with data image") +template class TestImageEngine; +template class TestImageEngine; +#ifdef BUILD_ALL_IMAGE_TYPES +template class TestImageEngine; +template class TestImageEngine; +template class TestImageEngine; +template class TestImageEngine; +template class TestImageEngine; +template class TestImageEngine; +template class TestImageEngine; +template class TestImageEngine; +template class TestImageEngine; +#endif + +// register effectively TestImageEngine in the registry +// it is done statically as it will be executed into the image_test executable +bool res = sofa::core::ObjectFactory::getInstance()->registerObjects(sofa::core::ObjectRegistrationData("TestImageEngine to test engine with data image") .add >(true) .add >() #ifdef BUILD_ALL_IMAGE_TYPES @@ -50,22 +64,8 @@ void registerTestImageEngine(sofa::core::ObjectFactory* factory) .add >() #endif ); -} -template class TestImageEngine; -template class TestImageEngine; -#ifdef BUILD_ALL_IMAGE_TYPES -template class TestImageEngine; -template class TestImageEngine; -template class TestImageEngine; -template class TestImageEngine; -template class TestImageEngine; -template class TestImageEngine; -template class TestImageEngine; -template class TestImageEngine; -template class TestImageEngine; -#endif } // namespace constraint } // namespace component diff --git a/applications/plugins/image/initImage.cpp b/applications/plugins/image/initImage.cpp index 42904687728..fa1c3739e39 100644 --- a/applications/plugins/image/initImage.cpp +++ b/applications/plugins/image/initImage.cpp @@ -62,10 +62,6 @@ namespace engine extern void registerDepthMapToMeshEngine(sofa::core::ObjectFactory* factory); extern void registerCollisionToCarvingEngine(sofa::core::ObjectFactory* factory); -#ifdef SOFA_BUILD_TESTS - extern void registerTestImageEngine(sofa::core::ObjectFactory* factory); -#endif - #ifdef PLUGIN_IMAGE_COMPILE_GUI extern void registerContourImageToolBox(sofa::core::ObjectFactory* factory); extern void registerAverageCatchAllVector(sofa::core::ObjectFactory* factory); @@ -176,13 +172,6 @@ void registerObjects(sofa::core::ObjectFactory* factory) sofa::component::engine::registerGenerateImage(factory); sofa::component::engine::registerDepthMapToMeshEngine(factory); sofa::component::engine::registerCollisionToCarvingEngine(factory); - -#ifdef SOFA_BUILD_TESTS - sofa::component::engine::registerTestImageEngine(factory); -#endif - -#ifdef PLUGIN_IMAGE_COMPILE_GUI -#endif } } // namespace sofa::component