From dcb608183b406cb162c6cd1ca120cecf6abc5b9e Mon Sep 17 00:00:00 2001
From: Marilena Bandieramonte <marilena.bandieramonte@cern.ch>
Date: Wed, 24 Jan 2024 13:22:07 +0100
Subject: [PATCH] Resize world volume functionality

---
 FullSimLight/CMakeLists.txt                   |   1 +
 .../include/FSLDetectorConstruction.hh        |   1 -
 FullSimLight/src/FSLDetectorConstruction.cc   |  40 +----
 GeoModelCore/CMakeLists.txt                   |   1 +
 GeoModelCore/GeoModelFuncSnippets/.DS_Store   | Bin 0 -> 6148 bytes
 .../GeoModelFuncSnippets/CMakeLists.txt       |   4 +-
 .../GeoModelFuncSnippets/FileUtils.h          |   0
 .../GeoModelFuncSnippets/GeoLogVolSorter.h    |   0
 .../GeoModelFuncSnippets/GeoPhysVolSorter.h   |   0
 .../GeoModelFuncSnippets/GeoShapeSorter.h     |   0
 .../GeoModelFuncSnippets/GeoShapeUtils.h      |   0
 .../GeoModelFuncSnippets/StringUtils.h        |   0
 .../GeoModelFuncSnippets/StringUtils.icc      |   0
 .../GeoModelFuncSnippets/TransformSorter.h    |   0
 .../TransformToStringConverter.h              |   0
 .../GeoModelFuncSnippets/defineWorld.h        |   4 +-
 .../getChildNodesWithTrf.h                    |   0
 .../GeoModelFuncSnippets/throwExcept.h        |   0
 .../GeoModelFuncSnippets/src/FileUtils.cxx    |   0
 .../src/GeoLogVolSorter.cxx                   |   0
 .../src/GeoPhysVolSorter.cxx                  |   0
 .../src/GeoShapeSorter.cxx                    |   0
 .../src/GeoShapeUtils.cxx                     |   6 +-
 .../GeoModelFuncSnippets/src/StringUtils.cxx  |   0
 .../src/TransformSorter.cxx                   |   0
 .../src/TransformToStringConverter.cxx        |   0
 .../GeoModelFuncSnippets/src/defineWorld.cxx  | 138 ++++++++++++++++++
 .../src/getChildNodesWithTrf.cxx              |   0
 .../tests/testGeoShapeSet.cxx                 |   0
 .../tests/testStringUtils.cxx                 |   0
 .../tests/testTransformSorter.cxx             |   0
 .../HelloGeoRead2G4/HelloGeoReadG4.cpp        |   2 +-
 GeoModelTools/CMakeLists.txt                  |   1 -
 GeoModelTools/GMCAT/CMakeLists.txt            |   2 +-
 GeoModelTools/GMCAT/src/gmcat.cxx             |  10 +-
 GeoModelTools/GMSTATISTICS/CMakeLists.txt     |   2 +-
 .../GeoModelFuncSnippets/src/defineWorld.cxx  |  41 ------
 .../GeoModelXML/GeoModelXml/CMakeLists.txt    |   2 +-
 38 files changed, 168 insertions(+), 87 deletions(-)
 create mode 100644 GeoModelCore/GeoModelFuncSnippets/.DS_Store
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/CMakeLists.txt (91%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/FileUtils.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoLogVolSorter.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoPhysVolSorter.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeSorter.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeUtils.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.icc (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformSorter.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformToStringConverter.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h (86%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/getChildNodesWithTrf.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/GeoModelFuncSnippets/throwExcept.h (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/src/FileUtils.cxx (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/src/GeoLogVolSorter.cxx (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/src/GeoPhysVolSorter.cxx (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/src/GeoShapeSorter.cxx (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/src/GeoShapeUtils.cxx (99%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/src/StringUtils.cxx (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/src/TransformSorter.cxx (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/src/TransformToStringConverter.cxx (100%)
 create mode 100644 GeoModelCore/GeoModelFuncSnippets/src/defineWorld.cxx
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/src/getChildNodesWithTrf.cxx (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/tests/testGeoShapeSet.cxx (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/tests/testStringUtils.cxx (100%)
 rename {GeoModelTools => GeoModelCore}/GeoModelFuncSnippets/tests/testTransformSorter.cxx (100%)
 delete mode 100644 GeoModelTools/GeoModelFuncSnippets/src/defineWorld.cxx

diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt
index 3ebc8a6c3..a75827819 100644
--- a/FullSimLight/CMakeLists.txt
+++ b/FullSimLight/CMakeLists.txt
@@ -100,6 +100,7 @@ target_link_libraries(FullSimLight_obj
     nlohmann_json::nlohmann_json
     GeoModel2G4
     GeoModelCore::GeoModelKernel
+    GeoModelCore::GeoModelFuncSnippets
     GeoModelIO::GeoModelRead
     GeoModelIO::GeoModelWrite
     ${HEPMC3_LIB}
diff --git a/FullSimLight/include/FSLDetectorConstruction.hh b/FullSimLight/include/FSLDetectorConstruction.hh
index f470a69a2..5c1295b03 100644
--- a/FullSimLight/include/FSLDetectorConstruction.hh
+++ b/FullSimLight/include/FSLDetectorConstruction.hh
@@ -89,7 +89,6 @@ public:
   static G4double GetFieldValue() { return gFieldValue; }
   G4double GetTolerance (){return fTolerance;}
 
-  GeoVPhysVol* CreateTheWorld(GeoVPhysVol* world);
 
   /// Clean the geometry  from Unidentified volumes before dumping it in GDML format
   void PullUnidentifiedVolumes( G4LogicalVolume* v );
diff --git a/FullSimLight/src/FSLDetectorConstruction.cc b/FullSimLight/src/FSLDetectorConstruction.cc
index bcbd24fde..a253ab31a 100644
--- a/FullSimLight/src/FSLDetectorConstruction.cc
+++ b/FullSimLight/src/FSLDetectorConstruction.cc
@@ -31,7 +31,7 @@
 #include "G4GDMLParser.hh"
 //#include "G4LogicalVolumeStore.hh"
 
-
+#include <algorithm>
 // Geant4 steppers
 #if G4VERSION_NUMBER>=1040
 #include "G4BogackiShampine23.hh"
@@ -72,6 +72,8 @@
 #include "GeoModelKernel/GeoVGeometryPlugin.h"
 #include "GeoModelKernel/GeoGeometryPluginLoader.h"
 #include "GeoModelKernel/GeoVolumeCursor.h"
+#include "GeoModelKernel/GeoAlignableTransform.h"
+#include "GeoModelFuncSnippets/defineWorld.h"
 
 // For Sensitive Detector plugins:
 #include "FullSimLight/FSLSensitiveDetectorPlugin.h"
@@ -112,33 +114,6 @@ FSLDetectorConstruction::~FSLDetectorConstruction()
   delete fDetectorMessenger;
 }
 
-GeoVPhysVol*  FSLDetectorConstruction::CreateTheWorld(GeoVPhysVol* world)
-{
-    if (world == nullptr)
-    {
-        // Setup the 'World' volume from which everything else will be suspended
-        // Get the materials that we shall use.
-        // -------------------------------------//
-        GeoMaterial* Air = new GeoMaterial("Air", 1.290*SYSTEM_OF_UNITS::mg/SYSTEM_OF_UNITS::cm3);
-        GeoElement* Oxygen = new GeoElement("Oxygen",  "O", 8.0, 15.9949*SYSTEM_OF_UNITS::g/SYSTEM_OF_UNITS::mole);
-        GeoElement* Nitrogen = new GeoElement("Nitrogen", "N", 7., 14.0031*SYSTEM_OF_UNITS::g/SYSTEM_OF_UNITS::mole);
-        GeoElement* Argon = new GeoElement("Argon", "Ar", 18., 39.9624*SYSTEM_OF_UNITS::g/SYSTEM_OF_UNITS::mole);
-        GeoElement* Hydrogen = new GeoElement("Hydrogen", "H", 1., 1.00782503081372*SYSTEM_OF_UNITS::g/SYSTEM_OF_UNITS::mole);
-
-        Air->add(Nitrogen, 0.7494);
-        Air->add(Oxygen, 0.2369);
-        Air->add(Argon, 0.0129);
-        Air->add(Hydrogen, 0.0008);
-        
-        Air->lock();
-        const GeoBox* worldBox = new GeoBox(2000*SYSTEM_OF_UNITS::cm, 2000*SYSTEM_OF_UNITS::cm, 4000*SYSTEM_OF_UNITS::cm);
-        const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, Air);
-        //const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, Ether);
-        world = new GeoPhysVol(worldLog);
-    }
-    return world;
-}
-
 G4VPhysicalVolume *FSLDetectorConstruction::Construct()
 {
     fTimer.Start();
@@ -156,10 +131,11 @@ G4VPhysicalVolume *FSLDetectorConstruction::Construct()
 
         }
 
-        GeoVPhysVol* worldTmp = CreateTheWorld(nullptr);
+        GeoIntrusivePtr<GeoPhysVol> worldTmp{createGeoWorld()};
         factory->create(worldTmp);
-        world = worldTmp;
-
+        GeoIntrusivePtr<GeoPhysVol> world = resizeGeoWorld(worldTmp);
+        G4cout << "World resized correctly." << G4endl;
+        
         G4cout << "ReadGeoModel::buildGeoModel() done." << G4endl;
         fTimer.Stop();
         G4cout << "First step done. GeoModelTree built from the SQLite file." << G4endl;
@@ -169,7 +145,7 @@ G4VPhysicalVolume *FSLDetectorConstruction::Construct()
 
         fTimer.Start();
         // build the Geant4 geometry and get an hanlde to the world' volume
-        ExtParameterisedVolumeBuilder* builder = new ExtParameterisedVolumeBuilder("ATLAS");
+        ExtParameterisedVolumeBuilder* builder = new ExtParameterisedVolumeBuilder("Detector");
 
         std::cout << "Building G4 geometry."<<std::endl;
         envelope = builder->Build(world);
diff --git a/GeoModelCore/CMakeLists.txt b/GeoModelCore/CMakeLists.txt
index d96b29665..814e20f8d 100644
--- a/GeoModelCore/CMakeLists.txt
+++ b/GeoModelCore/CMakeLists.txt
@@ -8,6 +8,7 @@ project( "GeoModelCore" VERSION ${GeoModel_VERSION} LANGUAGES CXX )
 # Set up the build of the two libraries of the (sub-)project.
 add_subdirectory( GeoGenericFunctions )
 add_subdirectory( GeoModelKernel )
+add_subdirectory( GeoModelFuncSnippets )
 
 # Create and install the version description of the project.
 include( WriteBasicConfigVersionFile )
diff --git a/GeoModelCore/GeoModelFuncSnippets/.DS_Store b/GeoModelCore/GeoModelFuncSnippets/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..ae5c8ecde22999e8b2b13eb4d697826d2742b328
GIT binary patch
literal 6148
zcmeHKy-vem3_Q~gl~_73Fn+JV8+@t?OiX<NMA88%Y7lAnY`iw-A0SoA%7E<3zI+!u
zR&I!E0J1r?cfcCJimr$c4Rh1`>NC3vMp5h;JzDJ1;Q^;v_GLnAZ}7;f9#8b2`U4v5
zaKJ0x_}k-%p&gp;rSCg7!vX`|(M+k!9g<B2Qh`(;6-WhAfvEyIMro^S$Bd~!Dv%0%
zE1=(pLRYMTqoaK~7;FU~E=im5+I9(IQG!?lM@KR=@lv9fN~{>-<>X7`)xgow%OTd8
z&xy_w8;V$W^2O32)iGl#kP4hDu<+wr=l?zZm;L{|C{L+CD)6rqkmYu_-SCxSw$5Ho
wXKkTB)4z<lmd;?Km}sMz2OY(?lf0tWyk7%HM=K|9<;46Wpt_``0)L^vCtZjgBLDyZ

literal 0
HcmV?d00001

diff --git a/GeoModelTools/GeoModelFuncSnippets/CMakeLists.txt b/GeoModelCore/GeoModelFuncSnippets/CMakeLists.txt
similarity index 91%
rename from GeoModelTools/GeoModelFuncSnippets/CMakeLists.txt
rename to GeoModelCore/GeoModelFuncSnippets/CMakeLists.txt
index f7665ef21..e30ae17d9 100644
--- a/GeoModelTools/GeoModelFuncSnippets/CMakeLists.txt
+++ b/GeoModelCore/GeoModelFuncSnippets/CMakeLists.txt
@@ -21,7 +21,7 @@ set_target_properties( GeoModelFuncSnippets PROPERTIES
 
 # Set up an alias with the same name that you would get by "finding" a pre-built
 # version of the library.
-add_library( GeoModelTools::GeoModelFuncSnippets ALIAS GeoModelFuncSnippets )
+add_library( GeoModelCore::GeoModelFuncSnippets ALIAS GeoModelFuncSnippets )
 
 # Install the library.
 install(TARGETS GeoModelFuncSnippets
@@ -52,7 +52,7 @@ foreach(_exeFile ${files})
   endif() 
   
   add_executable(${_theExec} ${_exeFile})
-  target_link_libraries( ${_theExec} GeoModelTools::GeoModelFuncSnippets GeoModelCore::GeoModelKernel)
+  target_link_libraries( ${_theExec} GeoModelCore::GeoModelFuncSnippets GeoModelCore::GeoModelKernel)
   add_test(NAME ${_theExec}
            COMMAND ${_theExec})
 
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/FileUtils.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/FileUtils.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/FileUtils.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/FileUtils.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoLogVolSorter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoLogVolSorter.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoLogVolSorter.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoLogVolSorter.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoPhysVolSorter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoPhysVolSorter.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoPhysVolSorter.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoPhysVolSorter.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeSorter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeSorter.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeSorter.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeSorter.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeUtils.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeUtils.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeUtils.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeUtils.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.icc b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.icc
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.icc
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.icc
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformSorter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformSorter.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformSorter.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformSorter.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformToStringConverter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformToStringConverter.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformToStringConverter.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformToStringConverter.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h
similarity index 86%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h
index 2e32a6459..fbfe4779d 100644
--- a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h
+++ b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h
@@ -20,4 +20,6 @@ GeoIntrusivePtr<GeoPhysVol> createGeoWorld(const double worldBoxX = GeoWorldDim:
                                            const double worldBoxY = GeoWorldDim::worldBoxY,
                                            const double worldBoxZ = GeoWorldDim::worldBoxZ);
 
-#endif
\ No newline at end of file
+/// Resize the world volume to be the needed size
+GeoIntrusivePtr<GeoPhysVol> resizeGeoWorld(GeoIntrusivePtr<GeoPhysVol> world);
+#endif
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/getChildNodesWithTrf.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/getChildNodesWithTrf.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/getChildNodesWithTrf.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/getChildNodesWithTrf.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/throwExcept.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/throwExcept.h
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/throwExcept.h
rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/throwExcept.h
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/FileUtils.cxx b/GeoModelCore/GeoModelFuncSnippets/src/FileUtils.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/src/FileUtils.cxx
rename to GeoModelCore/GeoModelFuncSnippets/src/FileUtils.cxx
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/GeoLogVolSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/GeoLogVolSorter.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/src/GeoLogVolSorter.cxx
rename to GeoModelCore/GeoModelFuncSnippets/src/GeoLogVolSorter.cxx
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/GeoPhysVolSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/GeoPhysVolSorter.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/src/GeoPhysVolSorter.cxx
rename to GeoModelCore/GeoModelFuncSnippets/src/GeoPhysVolSorter.cxx
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/GeoShapeSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/GeoShapeSorter.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/src/GeoShapeSorter.cxx
rename to GeoModelCore/GeoModelFuncSnippets/src/GeoShapeSorter.cxx
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/GeoShapeUtils.cxx b/GeoModelCore/GeoModelFuncSnippets/src/GeoShapeUtils.cxx
similarity index 99%
rename from GeoModelTools/GeoModelFuncSnippets/src/GeoShapeUtils.cxx
rename to GeoModelCore/GeoModelFuncSnippets/src/GeoShapeUtils.cxx
index 741af7666..4ba5bffcb 100644
--- a/GeoModelTools/GeoModelFuncSnippets/src/GeoShapeUtils.cxx
+++ b/GeoModelCore/GeoModelFuncSnippets/src/GeoShapeUtils.cxx
@@ -4,12 +4,12 @@
 #include "GeoModelFuncSnippets/GeoShapeUtils.h"
 #include "GeoModelFuncSnippets/TransformToStringConverter.h"
 
-
 /// Boolean volume shapes
 #include "GeoModelKernel/GeoShapeUnion.h"
 #include "GeoModelKernel/GeoShapeSubtraction.h"
 #include "GeoModelKernel/GeoShapeIntersection.h"
 #include "GeoModelKernel/GeoShapeShift.h"
+#include "GeoModelKernel/GeoShape.h"
 /// Ordinary shapes
 #include "GeoModelKernel/GeoBox.h"
 #include "GeoModelKernel/GeoTrd.h"
@@ -22,6 +22,8 @@
 
 #include "GeoModelKernel/Units.h"
 
+#include <vector>
+
 std::pair<const GeoShape* , const GeoShape*> getOps(const GeoShape* composed) {
     if (composed->typeID() == GeoShapeUnion::getClassTypeID()) {
         const GeoShapeUnion* unionShape = dynamic_cast<const GeoShapeUnion*>(composed);
@@ -136,4 +138,4 @@ std::string printGeoShape(const GeoShape* shape) {
       ostr<<"dPhi="<<torus->getDPhi()*toDeg;
    }
     return ostr.str();
-}
\ No newline at end of file
+}
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/StringUtils.cxx b/GeoModelCore/GeoModelFuncSnippets/src/StringUtils.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/src/StringUtils.cxx
rename to GeoModelCore/GeoModelFuncSnippets/src/StringUtils.cxx
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/TransformSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/TransformSorter.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/src/TransformSorter.cxx
rename to GeoModelCore/GeoModelFuncSnippets/src/TransformSorter.cxx
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/TransformToStringConverter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/TransformToStringConverter.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/src/TransformToStringConverter.cxx
rename to GeoModelCore/GeoModelFuncSnippets/src/TransformToStringConverter.cxx
diff --git a/GeoModelCore/GeoModelFuncSnippets/src/defineWorld.cxx b/GeoModelCore/GeoModelFuncSnippets/src/defineWorld.cxx
new file mode 100644
index 000000000..e5185656f
--- /dev/null
+++ b/GeoModelCore/GeoModelFuncSnippets/src/defineWorld.cxx
@@ -0,0 +1,138 @@
+/*
+  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+*/
+#include "GeoModelFuncSnippets/defineWorld.h"
+#include "GeoModelKernel/GeoElement.h"
+#include "GeoModelKernel/GeoMaterial.h"
+#include "GeoModelKernel/GeoBox.h"
+#include "GeoModelKernel/GeoPhysVol.h"
+#include "GeoModelKernel/GeoFullPhysVol.h"
+#include "GeoModelKernel/GeoVolumeCursor.h"
+#include "GeoModelKernel/GeoAlignableTransform.h"
+#include "GeoModelKernel/Units.h"
+
+GeoIntrusivePtr<GeoPhysVol> createGeoWorld(const double worldBoxX, 
+                                           const double worldBoxY,
+                                           const double worldBoxZ) {
+    
+
+    constexpr double gr =   GeoModelKernelUnits::gram;
+    constexpr double mole = GeoModelKernelUnits::mole;
+    constexpr double cm3 =  GeoModelKernelUnits::cm3;
+
+    // Define the chemical elements
+    GeoIntrusivePtr<GeoElement>  Nitrogen{new GeoElement ("Nitrogen" ,"N"  ,  7.0 ,  14.0031 *gr/mole)};
+    GeoIntrusivePtr<GeoElement>  Oxygen{new GeoElement ("Oxygen"   ,"O"  ,  8.0 ,  15.9949 *gr/mole)};
+    GeoIntrusivePtr<GeoElement>  Argon{new GeoElement ("Argon"    ,"Ar" , 18.0 ,  39.9624  *gr/mole)};
+    GeoIntrusivePtr<GeoElement>  Hydrogen{new GeoElement ("Hydrogen" ,"H"  ,  1.0 ,  1.00782503081372 *gr/mole)};
+
+    constexpr double densityOfAir=0.001290 *gr/cm3;
+    GeoIntrusivePtr<GeoMaterial> air{new GeoMaterial("GeoModelAir", densityOfAir)};
+    air->add(Nitrogen  , 0.7494);
+    air->add(Oxygen, 0.2369);
+    air->add(Argon, 0.0129);
+    air->add(Hydrogen, 0.0008);
+    air->lock();
+
+
+    GeoIntrusivePtr<GeoBox> worldBox{new GeoBox(worldBoxX, worldBoxY, worldBoxZ)};
+    GeoIntrusivePtr<GeoLogVol> worldLog{new GeoLogVol("WorldLog", worldBox, air)};
+    GeoIntrusivePtr<GeoPhysVol> world{new GeoPhysVol(worldLog)};
+
+    return world;    
+}
+
+GeoIntrusivePtr<GeoPhysVol> resizeGeoWorld(GeoIntrusivePtr<GeoPhysVol> world)
+{
+    if (world)
+    {
+        //resize the world volume to the real needed volume
+        
+        // get number of children volumes
+        unsigned int nChild=world->getNChildVols();
+        
+        //Dimensions of the bounding boxes
+        double xmin=0.,ymin=0.,zmin=0.,xmax=0.,ymax=0.,zmax=0.;
+        double xworld=0.,yworld=0.,zworld=0.;
+        
+        // loop over all children volumes
+        for (unsigned int i=0; i<nChild; i++)
+        {
+            PVConstLink nodeLink = world->getChildVol(i);
+            if ( dynamic_cast<const GeoVPhysVol*>( &(*( nodeLink ))) )
+            {
+                const GeoVPhysVol *childVolV = &(*( nodeLink ));
+                
+                if ( dynamic_cast<const GeoPhysVol*>(childVolV) ) {
+                    const GeoPhysVol* childVol = dynamic_cast<const GeoPhysVol*>(childVolV);
+                    childVol->getLogVol()->getShape()->extent(xmin, ymin, zmin, xmax, ymax, zmax);
+                }
+                else if ( dynamic_cast<const GeoFullPhysVol*>(childVolV) ) {
+                    const GeoFullPhysVol* childVol = dynamic_cast<const GeoFullPhysVol*>(childVolV);
+                    childVol->getLogVol()->getShape()->extent(xmin, ymin, zmin, xmax, ymax, zmax);
+                   
+                }
+                xworld=std::max({xworld,std::abs(xmin),std::abs(xmax)});
+                yworld=std::max({yworld,std::abs(ymin),std::abs(ymax)});
+                zworld=std::max({zworld,std::abs(zmin),std::abs(zmax)});
+            }
+        }
+
+        GeoIntrusivePtr<GeoPhysVol> resizedWorld{createGeoWorld(xworld, yworld, zworld)};
+       
+        for (unsigned int i=0; i< world->getNChildNodes(); i++){
+            const GeoGraphNode * node = *(world->getChildNode(i));
+            
+            
+            if (dynamic_cast<const GeoVPhysVol*>( node ))
+            {
+                if ( dynamic_cast<const GeoFullPhysVol*>(node) ){
+                    const GeoFullPhysVol* nodeFullPhysVol = dynamic_cast<const GeoFullPhysVol*>(node);
+                    resizedWorld->add((GeoGraphNode *)nodeFullPhysVol);
+                    
+                }
+                else  if ( dynamic_cast<const GeoPhysVol*>(node) ){
+                    const GeoPhysVol* nodePhysVol = dynamic_cast<const GeoPhysVol*>(node);
+                    resizedWorld->add((GeoGraphNode *)nodePhysVol);
+                    
+                }
+            }
+            else if (dynamic_cast<const GeoNameTag*>( node )){
+                const GeoNameTag* nodeTag = dynamic_cast<const GeoNameTag*>(node);
+                resizedWorld->add((GeoGraphNode *)nodeTag);
+                
+            }
+            
+            else if (dynamic_cast<const GeoAlignableTransform*>( node )){
+                const GeoAlignableTransform* nodeAT = dynamic_cast<const GeoAlignableTransform*>(node);
+                resizedWorld->add((GeoGraphNode *)nodeAT);
+                
+            }
+            
+            else if (dynamic_cast<const GeoSerialTransformer*>( node )){
+                const GeoSerialTransformer* nodeST = dynamic_cast<const GeoSerialTransformer*>(node);
+                resizedWorld->add((GeoGraphNode *)nodeST);
+                
+            }
+            
+            else if (dynamic_cast<const GeoSerialDenominator*>( node )){
+                const GeoSerialDenominator* nodeSD = dynamic_cast<const GeoSerialDenominator*>(node);
+                resizedWorld->add((GeoGraphNode *)nodeSD);
+                
+            }
+            else if (dynamic_cast<const GeoTransform*>( node )){
+                const GeoTransform* nodeTransform = dynamic_cast<const GeoTransform*>(node);
+                resizedWorld->add((GeoGraphNode *)nodeTransform);
+                
+            }else if (dynamic_cast<const GeoIdentifierTag*>( node )){
+                const GeoIdentifierTag* nodeIT = dynamic_cast<const GeoIdentifierTag*>(node);
+                resizedWorld->add((GeoGraphNode *)nodeIT);
+                
+            }
+        }
+
+        return resizedWorld;
+        
+    }
+    return world;
+}
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/getChildNodesWithTrf.cxx b/GeoModelCore/GeoModelFuncSnippets/src/getChildNodesWithTrf.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/src/getChildNodesWithTrf.cxx
rename to GeoModelCore/GeoModelFuncSnippets/src/getChildNodesWithTrf.cxx
diff --git a/GeoModelTools/GeoModelFuncSnippets/tests/testGeoShapeSet.cxx b/GeoModelCore/GeoModelFuncSnippets/tests/testGeoShapeSet.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/tests/testGeoShapeSet.cxx
rename to GeoModelCore/GeoModelFuncSnippets/tests/testGeoShapeSet.cxx
diff --git a/GeoModelTools/GeoModelFuncSnippets/tests/testStringUtils.cxx b/GeoModelCore/GeoModelFuncSnippets/tests/testStringUtils.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/tests/testStringUtils.cxx
rename to GeoModelCore/GeoModelFuncSnippets/tests/testStringUtils.cxx
diff --git a/GeoModelTools/GeoModelFuncSnippets/tests/testTransformSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/tests/testTransformSorter.cxx
similarity index 100%
rename from GeoModelTools/GeoModelFuncSnippets/tests/testTransformSorter.cxx
rename to GeoModelCore/GeoModelFuncSnippets/tests/testTransformSorter.cxx
diff --git a/GeoModelExamples/HelloGeoRead2G4/HelloGeoReadG4.cpp b/GeoModelExamples/HelloGeoRead2G4/HelloGeoReadG4.cpp
index b656e33e3..41a815416 100644
--- a/GeoModelExamples/HelloGeoRead2G4/HelloGeoReadG4.cpp
+++ b/GeoModelExamples/HelloGeoRead2G4/HelloGeoReadG4.cpp
@@ -97,7 +97,7 @@ int main(int argc, char* argv[]) {
     std::cout << "ReadGeoModel set.\n";
 
     /* build the GeoModel geometry */
-    GeoPhysVol* world =
+    const GeoVPhysVol* world =
         readInGeo.buildGeoModel();  // builds the whole GeoModel tree in memory
                                     // and get an handle to the 'world' volume
     std::cout << "ReadGeoModel::buildGeoModel() done.\n";
diff --git a/GeoModelTools/CMakeLists.txt b/GeoModelTools/CMakeLists.txt
index 828183c8a..bed80fb75 100644
--- a/GeoModelTools/CMakeLists.txt
+++ b/GeoModelTools/CMakeLists.txt
@@ -47,7 +47,6 @@ include( GNUInstallDirs )
 
 # Set up the build of the libraries of the project.
 add_subdirectory( GeoModelXML )
-add_subdirectory( GeoModelFuncSnippets )
 add_subdirectory( GeoModelXMLParser )
 add_subdirectory( GeoModelJSONParser )
 add_subdirectory( ExpressionEvaluator )
diff --git a/GeoModelTools/GMCAT/CMakeLists.txt b/GeoModelTools/GMCAT/CMakeLists.txt
index 62f3df273..b3a2ab02c 100644
--- a/GeoModelTools/GMCAT/CMakeLists.txt
+++ b/GeoModelTools/GMCAT/CMakeLists.txt
@@ -3,7 +3,7 @@
 # Declare the package's executable.
 add_executable( gmcat src/gmcat.cxx src/publishMetaData.cpp)
 target_link_libraries( gmcat PRIVATE GeoModelCore::GeoModelKernel
-                                     GeoModelTools::GeoModelFuncSnippets
+                                     GeoModelCore::GeoModelFuncSnippets
                                      GeoModelIO::GeoModelRead 
                                      GeoModelIO::GeoModelWrite
                                      GeoModelIO::GeoModelDBManager )
diff --git a/GeoModelTools/GMCAT/src/gmcat.cxx b/GeoModelTools/GMCAT/src/gmcat.cxx
index a7d9c68b8..467895fa2 100644
--- a/GeoModelTools/GMCAT/src/gmcat.cxx
+++ b/GeoModelTools/GMCAT/src/gmcat.cxx
@@ -115,9 +115,10 @@ int main(int argc, char ** argv) {
 
 
   //
-  // Create elements and materials for the "World" volume, which is the container:
+  // Create the "GeoWorld" volume, which is the container:
   //
-  GeoIntrusivePtr<GeoVPhysVol> world{createGeoWorld()};
+  GeoIntrusivePtr<GeoPhysVol> world{createGeoWorld()};
+  
 
   //
   // Loop over plugins, create the geometry and put it under the world:
@@ -188,9 +189,12 @@ int main(int argc, char ** argv) {
     std::cerr << "gmcat -- Error opening the output file: " << outputFile << std::endl;
     return 7;
   }
+    
+  //resize the world volume to the needed one
+  GeoIntrusivePtr<GeoPhysVol> resizedWorld = resizeGeoWorld(world);
 
   GeoModelIO::WriteGeoModel dumpGeoModelGraph(db);
-  world->exec(&dumpGeoModelGraph);
+  resizedWorld->exec(&dumpGeoModelGraph);
 
   if (vecPluginsPublishers.size() > 0) {
     dumpGeoModelGraph.saveToDB(vecPluginsPublishers);
diff --git a/GeoModelTools/GMSTATISTICS/CMakeLists.txt b/GeoModelTools/GMSTATISTICS/CMakeLists.txt
index cad89c45a..854b50f3a 100644
--- a/GeoModelTools/GMSTATISTICS/CMakeLists.txt
+++ b/GeoModelTools/GMSTATISTICS/CMakeLists.txt
@@ -6,7 +6,7 @@ target_link_libraries( gmstatistics PRIVATE GeoModelCore::GeoModelKernel
                                             GeoModelIO::GeoModelRead 
                                             GeoModelIO::GeoModelWrite
                                             GeoModelIO::GeoModelDBManager
-                                            GeoModelTools::GeoModelFuncSnippets )
+                                            GeoModelCore::GeoModelFuncSnippets )
 
 # Tweak how debug information should be attached to the executable, in Debug
 # builds.
diff --git a/GeoModelTools/GeoModelFuncSnippets/src/defineWorld.cxx b/GeoModelTools/GeoModelFuncSnippets/src/defineWorld.cxx
deleted file mode 100644
index 9c52a18ce..000000000
--- a/GeoModelTools/GeoModelFuncSnippets/src/defineWorld.cxx
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
-*/
-#include "GeoModelFuncSnippets/defineWorld.h"
-#include "GeoModelKernel/GeoElement.h"
-#include "GeoModelKernel/GeoMaterial.h"
-#include "GeoModelKernel/GeoBox.h"
-#include "GeoModelKernel/GeoPhysVol.h"
-#include "GeoModelKernel/Units.h"
-
-GeoIntrusivePtr<GeoPhysVol> createGeoWorld(const double worldBoxX, 
-                                           const double worldBoxY,
-                                           const double worldBoxZ) {
-    
-
-    constexpr double gr =   GeoModelKernelUnits::gram;
-    constexpr double mole = GeoModelKernelUnits::mole;
-    constexpr double cm3 =  GeoModelKernelUnits::cm3;
-
-    // Define the chemical elements
-    GeoIntrusivePtr<GeoElement>  Nitrogen{new GeoElement ("Nitrogen" ,"N"  ,  7.0 ,  14.0067 *gr/mole)};
-    GeoIntrusivePtr<GeoElement>  Oxygen{new GeoElement ("Oxygen"   ,"O"  ,  8.0 ,  15.9995 *gr/mole)};
-    GeoIntrusivePtr<GeoElement>  Argon{new GeoElement ("Argon"    ,"Ar" , 18.0 ,  39.948  *gr/mole)};
-    GeoIntrusivePtr<GeoElement>  Hydrogen{new GeoElement ("Hydrogen" ,"H"  ,  1.0 ,  1.00797 *gr/mole)};
-
-    constexpr double densityOfAir=0.001214 *gr/cm3;
-    GeoIntrusivePtr<GeoMaterial> air{new GeoMaterial("Air", densityOfAir)};
-    air->add(Nitrogen  , 0.7494);
-    air->add(Oxygen, 0.2369);
-    air->add(Argon, 0.0129);
-    air->add(Hydrogen, 0.0008);
-    air->lock();
-
-
-
-    GeoIntrusivePtr<GeoBox> worldBox{new GeoBox(worldBoxX, worldBoxY, worldBoxZ)};
-    GeoIntrusivePtr<GeoLogVol> worldLog{new GeoLogVol("WorldLog", worldBox, air)};
-    GeoIntrusivePtr<GeoPhysVol> world{new GeoPhysVol(worldLog)};
-
-    return world;    
-}
\ No newline at end of file
diff --git a/GeoModelTools/GeoModelXML/GeoModelXml/CMakeLists.txt b/GeoModelTools/GeoModelXML/GeoModelXml/CMakeLists.txt
index 374cc28c8..67c34087f 100644
--- a/GeoModelTools/GeoModelXML/GeoModelXml/CMakeLists.txt
+++ b/GeoModelTools/GeoModelXML/GeoModelXml/CMakeLists.txt
@@ -13,7 +13,7 @@ find_package( ZLIB REQUIRED )
 # Create the library.
 add_library( GeoModelXml SHARED ${HEADERS} ${SOURCES} )
 # link libraries
-target_link_libraries( GeoModelXml PUBLIC GeoModelCore::GeoModelKernel GeoModelTools::GeoModelFuncSnippets GeoModelTools::ExpressionEvaluator XercesC::XercesC PRIVATE ZLIB::ZLIB  )
+target_link_libraries( GeoModelXml PUBLIC GeoModelCore::GeoModelKernel GeoModelCore::GeoModelFuncSnippets GeoModelTools::ExpressionEvaluator XercesC::XercesC PRIVATE ZLIB::ZLIB  )
 target_include_directories( GeoModelXml PUBLIC 
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
    $<INSTALL_INTERFACE:include> )
-- 
GitLab