SHiP Geometry Service
Framework-agnostic C++20 library wrapping the SHiP GeoModel geometry behind a stable interface.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
ship::SHiPGeometryService Class Referencefinal

Concrete implementation of IGeometryService backed by GeoModel. More...

#include <SHiPGeometryService.h>

Inheritance diagram for ship::SHiPGeometryService:
Inheritance graph
[legend]
Collaboration diagram for ship::SHiPGeometryService:
Collaboration graph
[legend]

Public Member Functions

 ~SHiPGeometryService () override=default
 
 SHiPGeometryService (const SHiPGeometryService &)=delete
 
SHiPGeometryServiceoperator= (const SHiPGeometryService &)=delete
 
 SHiPGeometryService (SHiPGeometryService &&)=delete
 
SHiPGeometryServiceoperator= (SHiPGeometryService &&)=delete
 
const GeoVPhysVol * geoModelWorld () const override
 GeoModel world physical volume (const — tree is immutable after build).
 
G4LogicalVolume * geant4WorldLogical () override
 G4LogicalVolume* for the world.
 
G4LogicalVolume * getLogicalVolume (const std::string &name) const override
 Look up a G4LogicalVolume by name within this service's converted tree (depth-first).
 
- Public Member Functions inherited from ship::IGeometryService
virtual ~IGeometryService ()=default
 

Static Public Member Functions

static std::unique_ptr< SHiPGeometryServicefromSource ()
 Build geometry from the C++ SHiPGeometryBuilder.
 
static std::unique_ptr< SHiPGeometryServicefromFile (const std::filesystem::path &dbPath)
 Load geometry from a previously written GeoModel SQLite database.
 
static std::shared_ptr< SHiPGeometryServicesharedFromFile (const std::filesystem::path &dbPath)
 Process-wide shared instance per geometry file, keyed by the canonical path.
 
static std::unique_ptr< SHiPGeometryServicefromWorld (PVConstLink world)
 Wrap an already-built GeoModel world (e.g. a small test geometry).
 

Detailed Description

Concrete implementation of IGeometryService backed by GeoModel.

Four factory functions: SHiPGeometryService::fromSource() — builds via SHiPGeometryBuilder SHiPGeometryService::fromFile(dbPath) — reads from a GeoModel .db file SHiPGeometryService::sharedFromFile(dbPath)— process-wide shared instance SHiPGeometryService::fromWorld(world) — wraps an existing GeoModel tree

Constructor & Destructor Documentation

◆ ~SHiPGeometryService()

ship::SHiPGeometryService::~SHiPGeometryService ( )
overridedefault

◆ SHiPGeometryService() [1/2]

ship::SHiPGeometryService::SHiPGeometryService ( const SHiPGeometryService )
delete

◆ SHiPGeometryService() [2/2]

ship::SHiPGeometryService::SHiPGeometryService ( SHiPGeometryService &&  )
delete

Member Function Documentation

◆ fromFile()

std::unique_ptr< SHiPGeometryService > ship::SHiPGeometryService::fromFile ( const std::filesystem::path &  dbPath)
static

Load geometry from a previously written GeoModel SQLite database.

◆ fromSource()

std::unique_ptr< SHiPGeometryService > ship::SHiPGeometryService::fromSource ( )
static

Build geometry from the C++ SHiPGeometryBuilder.

◆ fromWorld()

std::unique_ptr< SHiPGeometryService > ship::SHiPGeometryService::fromWorld ( PVConstLink  world)
static

Wrap an already-built GeoModel world (e.g. a small test geometry).

◆ geant4WorldLogical()

G4LogicalVolume * ship::SHiPGeometryService::geant4WorldLogical ( )
overridevirtual

G4LogicalVolume* for the world.

Triggers GeoModel2G4 on first call, which must run on the process-wide geometry thread (ship::geometry_thread(), see GeometryThread.h) whenever more than one thread touches Geant4 geometry.

Implements ship::IGeometryService.

◆ geoModelWorld()

const GeoVPhysVol * ship::SHiPGeometryService::geoModelWorld ( ) const
overridevirtual

GeoModel world physical volume (const — tree is immutable after build).

Implements ship::IGeometryService.

◆ getLogicalVolume()

G4LogicalVolume * ship::SHiPGeometryService::getLogicalVolume ( const std::string &  name) const
overridevirtual

Look up a G4LogicalVolume by name within this service's converted tree (depth-first).

Returns nullptr before geant4WorldLogical() has been called or when no such volume exists; rethrows a stored conversion failure instead of masking it as nullptr.

Implements ship::IGeometryService.

◆ operator=() [1/2]

SHiPGeometryService & ship::SHiPGeometryService::operator= ( const SHiPGeometryService )
delete

◆ operator=() [2/2]

SHiPGeometryService & ship::SHiPGeometryService::operator= ( SHiPGeometryService &&  )
delete

◆ sharedFromFile()

std::shared_ptr< SHiPGeometryService > ship::SHiPGeometryService::sharedFromFile ( const std::filesystem::path &  dbPath)
static

Process-wide shared instance per geometry file, keyed by the canonical path.

The first caller loads the file; later callers — from any plugin linking this library — get the same instance, so the GeoModel tree is loaded and converted at most once per process and freed once the last owner releases it.

All conversion and navigation on a shared instance must run on ship::geometry_thread() (see GeometryThread.h): Geant4 permits only one geometry-creating thread per process. Converted GeoModel trees are retained for the process lifetime (see geant4WorldLogical), so reloading a file after a converted instance has expired is safe.


The documentation for this class was generated from the following files: