DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Functions
Volume/Structure Builder Factories

Functions

BoxBuilder CreateBoxBuilder (const G4String &name)
 
BoxBuilder CreateBoxBuilder (const G4String &name, Length unit)
 
BoxBuilder CreateCenteredBoxBuilder (const G4String &name, G4double x_full_size, G4double y_full_size, G4double z_full_size)
 
BoxBuilder CreateCenteredBoxBuilder (Length unit, const G4String &name, G4double x_full_size, G4double y_full_size, G4double z_full_size)
 
BoxBuilder CreateZDeltaBoxBuilder (const G4String &name, G4double x_full_size, G4double y_full_size, G4double edge_z, G4double z_delta)
 
BoxBuilder CreateZDeltaBoxBuilder (Length unit, const G4String &name, G4double x_full_size, G4double y_full_size, G4double edge_z, G4double z_delta)
 
BoxBuilder CreateDeltasBoxBuilder (const G4String &name, G4double edge_x, G4double x_delta, G4double edge_y, G4double y_delta, G4double edge_z, G4double z_delta)
 
BoxBuilder CreateDeltasBoxBuilder (Length unit, const G4String &name, G4double edge_x, G4double x_delta, G4double edge_y, G4double y_delta, G4double edge_z, G4double z_delta)
 
BoxBuilder CreateEdgesBoxBuilder (const G4String &name, G4double x_edge1, G4double x_edge2, G4double y_edge1, G4double y_edge2, G4double z_edge1, G4double z_edge2)
 
BoxBuilder CreateEdgesBoxBuilder (Length unit, const G4String &name, G4double x_edge1, G4double x_edge2, G4double y_edge1, G4double y_edge2, G4double z_edge1, G4double z_edge2)
 
Assembly CreateAssembly (G4String name)
 
FromG4VSolid CreateFromG4VSolid (G4VSolid *solid)
 
RZBuilder CreatePolyhedraBuilder (const G4String &name, int sides, G4double phi_start=0., G4double phi_tot=360)
 
RZBuilder CreatePolyconeBuilder (const G4String &name, G4double phi_start=0., G4double phi_tot=360)
 
RZBuilder CreateCylinderBuilder (Length unit, const G4String &name, G4double endz, G4double height, G4double OR, G4double IR=0)
 
RZBuilder CreateCylinderBuilder (const G4String &name, G4double endz, G4double height, G4double OR, G4double IR=0)
 

Detailed Description

Factories for creating VolumeBuilder and StructureBuilder objects.

Factories for creating VolumeBuilder and StructureBuilder objects.

Function Documentation

◆ CreateAssembly()

Assembly CreateAssembly ( G4String  name)

Assembly of strucures, ie builders and/or other assemblies.

Definition at line 18 of file AssemblyCore.cc.

18 {
19 // Haha... assemblies actually are builders!!!
20 auto object = Assembly(new AssemblyCore());
21 // ... with is_builder set to false.
22 object->placement_configs_->is_builder = false;
23 //We're storing a pointer to the view in the builder by writing to the builder through that same view!
24 BuilderView builder_view = object->ToVolumeBuilder();
25 builder_view->StoreBuilderView(builder_view);
26 // Then store itself in its new builder (that links to its data).
27 //object->builder_configs_->builder_view->StoreIStructurePtr(IStructurePtr(object.get())); // this is the owning copy.
28 // ... and viewed through a reduced StructureView interface:
29 object->SetName(name);
30 auto return_obj = Assembly(object);
31 return return_obj;
32
33 // This let's us reuse builder methods!
34 }
A type-erased (data shared view) view of a builder or assembly, ie a "structure.".
SharedPtr< AssemblyCore > Assembly
Pointer to Assembly type to hold Structures, ie other assemblies or buidlers.

◆ CreateBoxBuilder() [1/2]

BoxBuilder CreateBoxBuilder ( const G4String &  name)

Create an unconfigured Box Solid, for use with SetXEdges() etc... Uses the global default unit unless you call SetDefaultUnit() before setting sizes.

Parameters
nameBase name to derive geometry object names from.
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 33 of file BoxBuilderCore.cc.

33 {
34 auto object = BoxBuilder(new BoxBuilderCore(name));
35 return object;
36 }
Builder class for simple Box solids.
SharedPtr< BoxBuilderCore > BoxBuilder
Shared pointer to _internals_::BoxBuilderCore.

◆ CreateBoxBuilder() [2/2]

BoxBuilder CreateBoxBuilder ( const G4String &  name,
Length  unit 
)

Create an unconfigured Box Solid, for use with SetXEdges() etc...

Parameters
nameBase name to derive geometry object names from.
unitunit for this call only (ex: CLHEP::mm)
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 38 of file BoxBuilderCore.cc.

38 {
39 auto object = BoxBuilder(new BoxBuilderCore(name));
40 object->SetDefaultUnit(unit);
41 return object;
42 }

◆ CreateCenteredBoxBuilder() [1/2]

BoxBuilder CreateCenteredBoxBuilder ( const G4String &  name,
G4double  x_full_size,
G4double  y_full_size,
G4double  z_full_size 
)

Create a Box solid.

Uses the global default unit

Parameters
nameBase name to derive geometry object names from.
x_full_sizeFULL X size
y_full_sizeFULL Y size
z_full_sizeFULL Z size
name
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 111 of file BoxBuilderCore.cc.

113 {
114 if (x_full_size <= 0 || y_full_size <= 0 || z_full_size <= 0) {
115 throw std::invalid_argument("Error in CreateCenteredBoxBuilder(): for volume " + name
116 + ": Sizes provided must be positive.\n");
117 }
118 auto object = BoxBuilder(new BoxBuilderCore(name));
119 object->SetXSize(x_full_size)
120 ->SetYSize(y_full_size)
121 ->SetZSize(z_full_size);
122 return object;
123 }

◆ CreateCenteredBoxBuilder() [2/2]

BoxBuilder CreateCenteredBoxBuilder ( Length  unit,
const G4String &  name,
G4double  x_full_size,
G4double  y_full_size,
G4double  z_full_size 
)

Create a Box solid.

Parameters
unitThe unit to use for this call only (ex: CLHEP::mm)
nameBase name to derive geometry object names from.
x_full_sizeFULL X size
y_full_sizeFULL Y size
z_full_sizeFULL Z size
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 97 of file BoxBuilderCore.cc.

99 {
100 if (x_full_size <= 0 || y_full_size <= 0 || z_full_size <= 0) {
101 throw std::invalid_argument("Error in CreateCenteredBoxBuilder(): for volume " + name
102 + ": Sizes provided must be positive.\n");
103 }
104 auto object = BoxBuilder(new BoxBuilderCore(name));
105 object->SetXSize(unit, x_full_size)
106 ->SetYSize(unit, y_full_size)
107 ->SetZSize(unit, z_full_size);
108 return object;
109 }

◆ CreateCylinderBuilder() [1/2]

RZBuilder CreateCylinderBuilder ( const G4String &  name,
G4double  endz,
G4double  height,
G4double  OR,
G4double  IR = 0 
)

Create a simple cylinder builder using global default unit.

Parameters
nameName used to derive all product names.
endzThe z reference of one end (either one)
heightHeight, can be positive or negative (from z reference)
OROuter radius.
IROptional inner radius. Default=0
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 62 of file RZBuilderCore.cc.

63 {
64 return CreateCylinderBuilder(Length(), name, endz, h, OR, IR);
65 }
RZBuilder CreateCylinderBuilder(Length unit, const G4String &name, G4double endz, G4double h, G4double OR, G4double IR)
Create a simple cylinder builder.

◆ CreateCylinderBuilder() [2/2]

RZBuilder CreateCylinderBuilder ( Length  unit,
const G4String &  name,
G4double  endz,
G4double  height,
G4double  OR,
G4double  IR = 0 
)

Create a simple cylinder builder.

Parameters
nameName used to derive all product names.
unitUnit applied to all values.
endzThe z reference of one end (either one)
heightHeight, can be positive or negative (from z reference)
OROuter radius.
IROptional inner radius. Default=0
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 46 of file RZBuilderCore.cc.

47 {
48 // ReSharper disable once CppDFAMemoryLeak
49 auto object = RZBuilder(new RZBuilderCore(name));
50 object->MakeSolidFunctionPtr_ = &RZBuilderCore::MakePolycone;
51 RZPlane plane;
52 plane.unit = unit;
53 plane.z = endz;
54 plane.IR = IR;
55 plane.OR = OR;
56 object->AddPlane(plane);
57 plane.z += h;
58 object->AddPlane(plane);
59 return RZBuilder(object);
60 }
Builder class for RZ mult-plane defined solids.
SharedPtr< RZBuilderCore > RZBuilder
Shared pointer to _internals_::RZBuilderCore.
Struct for adding planes to GeantMultiPlane –DSLeonard 2024 Overloads make this not strictly needed.

◆ CreateDeltasBoxBuilder() [1/2]

BoxBuilder CreateDeltasBoxBuilder ( const G4String &  name,
G4double  edge_x,
G4double  x_delta,
G4double  edge_y,
G4double  y_delta,
G4double  edge_z,
G4double  z_delta 
)

Create a Box solid.

Uses the global default unit

Parameters
nameBase name to derive geometry object names from.
edge_xThe x reference of one end (either one)
x_deltaFULL X size, + or - from end_x.
edge_yThe y reference of one end (either one)
y_deltaFULL Y size. + or - from end_y.
edge_zThe z reference of one end (either one)
z_deltaHeight, can be positive or negative (from z reference)
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 57 of file BoxBuilderCore.cc.

60 {
61 auto object = BoxBuilder(new BoxBuilderCore(name));
62 object->SetXEdgeDelta(edge_x, x_delta)
63 ->SetYEdgeDelta(edge_y, y_delta)
64 ->SetZEdgeDelta(edge_z, z_delta);
65 return object;
66 }

◆ CreateDeltasBoxBuilder() [2/2]

BoxBuilder CreateDeltasBoxBuilder ( Length  unit,
const G4String &  name,
G4double  edge_x,
G4double  x_delta,
G4double  edge_y,
G4double  y_delta,
G4double  edge_z,
G4double  z_delta 
)

Create a Box solid.

Parameters
unitThe unit to use for this call only (ex: CLHEP::mm)
nameBase name to derive geometry object names from.
edge_xThe x reference of one end (either one)
x_deltaFULL X size, + or - from end_x.
edge_yThe y reference of one end (either one)
y_deltaFULL Y size. + or - from end_y.
edge_zThe z reference of one end (either one)
z_deltaHeight, can be positive or negative (from z reference)
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 45 of file BoxBuilderCore.cc.

49 {
50 auto object = BoxBuilder(new BoxBuilderCore(name));
51 object->SetXEdgeDelta(unit, edge_x, x_delta)
52 ->SetYEdgeDelta(unit, edge_y, y_delta)
53 ->SetZEdgeDelta(unit, edge_z, z_delta);
54 return object;
55 }

◆ CreateEdgesBoxBuilder() [1/2]

BoxBuilder CreateEdgesBoxBuilder ( const G4String &  name,
G4double  x_edge1,
G4double  x_edge2,
G4double  y_edge1,
G4double  y_edge2,
G4double  z_edge1,
G4double  z_edge2 
)

Create a Box solid from edge coordinates.

Uses the global default unit

Parameters
nameBase name to derive geometry object names from.
x_edge1One end of the box in the x-dimension.
x_edge2The other end of the box in the x-dimension.
y_edge1One end of the box in the y-dimension.
y_edge2The other end of the box in the y-dimension.
z_edge1One end of the box in the z-dimension.
z_edge2The other end of the box in the z-dimension.
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 125 of file BoxBuilderCore.cc.

127 {
128 auto object = BoxBuilder(new BoxBuilderCore(name));
129 object->SetXEdges(x_edge1, x_edge2)
130 ->SetYEdges(y_edge1, y_edge2)
131 ->SetZEdges(z_edge1, z_edge2);
132 return object;
133 }

◆ CreateEdgesBoxBuilder() [2/2]

BoxBuilder CreateEdgesBoxBuilder ( Length  unit,
const G4String &  name,
G4double  x_edge1,
G4double  x_edge2,
G4double  y_edge1,
G4double  y_edge2,
G4double  z_edge1,
G4double  z_edge2 
)

Create a Box solid from edge coordinates using a specified unit.

Parameters
unitThe unit to use for this call only (ex: CLHEP::mm)
nameBase name to derive geometry object names from.
x_edge1One end of the box in the x-dimension.
x_edge2The other end of the box in the x-dimension.
y_edge1One end of the box in the y-dimension.
y_edge2The other end of the box in the y-dimension.
z_edge1One end of the box in the z-dimension.
z_edge2The other end of the box in the z-dimension.
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 135 of file BoxBuilderCore.cc.

138 {
139 auto object = BoxBuilder(new BoxBuilderCore(name));
140 object->SetXEdges(unit, x_edge1, x_edge2)
141 ->SetYEdges(unit, y_edge1, y_edge2)
142 ->SetZEdges(unit, z_edge1, z_edge2);
143 return object;
144 }

◆ CreateFromG4VSolid()

FromG4VSolid CreateFromG4VSolid ( G4VSolid *  solid)

Constructor to make a builder from an Existing Geant solid.

Parameters
solidG4VSolid pointer
Returns

Definition at line 25 of file FromG4VSolidCore.cc.

25 {
26 auto object = FromG4VSolid();
27 object.get()->SetSolid(solid);
28 object.get()->SetName(solid->GetName());
29 return FromG4VSolid(object);
30 }

◆ CreatePolyconeBuilder()

RZBuilder CreatePolyconeBuilder ( const G4String &  name,
G4double  phi_start = 0.,
G4double  phi_tot = 360 
)

Create a builder for associated IR,OR,Z defined object.

Parameters
nameBase name to derive geometry object names from.
phi_startOptional Start angle
phi_totOptional Total degrees
sidesOptional number of sides, for CreatePoyhedra only, (can set it later, dflt = 4 )
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 28 of file RZBuilderCore.cc.

28 {
29 // We could actually construct these as RZBuilder without using new, vis i_shared_ptr constructor.
30 // But maybe we can unfriend i_shared_ptr in the future if we use new here, and avoid exposing
31 // a backdoor to the general ctor, which doesn't select a MakeSolidFunctionPtr.
32 // ReSharper disable once CppDFAMemoryLeak
33 auto object = RZBuilder(new RZBuilderCore(name, phi_start, phi_tot, 0));
34 object->MakeSolidFunctionPtr_ = &RZBuilderCore::MakePolycone;
35 return RZBuilder(object);
36 }

◆ CreatePolyhedraBuilder()

RZBuilder CreatePolyhedraBuilder ( const G4String &  name,
int  sides,
G4double  phi_start = 0.,
G4double  phi_tot = 360 
)

Create a builder for associated IR,OR,Z defined object.

Parameters
nameBase name to derive geometry object names from.
phi_startOptional Start angle
phi_totOptional Total degrees
sidesOptional number of sides, for CreatePoyhedra only, (can set it later, dflt = 4 )
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 38 of file RZBuilderCore.cc.

39 {
40 // ReSharper disable once CppDFAMemoryLeak
41 auto object = new RZBuilderCore(name, phi_start, phi_tot, sides);
42 object->MakeSolidFunctionPtr_ = &RZBuilderCore::MakePolyhedra;
43 return RZBuilder(object);
44 }

◆ CreateZDeltaBoxBuilder() [1/2]

BoxBuilder CreateZDeltaBoxBuilder ( const G4String &  name,
G4double  x_full_size,
G4double  y_full_size,
G4double  edge_z,
G4double  z_delta 
)

Create a Box solid.

Uses the global default unit.

Parameters
nameBase name to derive geometry object names from.
x_full_sizeFULL X size
y_full_sizeFULL Y size
edge_zFull Z size
z_deltaFull Z size
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 83 of file BoxBuilderCore.cc.

85 {
86 if (x_full_size <= 0 || y_full_size <= 0) {
87 throw std::invalid_argument("Error in CreateZDeltaBoxBuilder(): for volume " + name
88 + ": Sizes provided without end offsets must be positive.\n");
89 }
90 auto object = BoxBuilder(new BoxBuilderCore(name));
91 object->SetXSize(x_full_size)
92 ->SetYSize(y_full_size)
93 ->SetZEdgeDelta(edge_z, z_delta);
94 return object;
95 }

◆ CreateZDeltaBoxBuilder() [2/2]

BoxBuilder CreateZDeltaBoxBuilder ( Length  unit,
const G4String &  name,
G4double  x_full_size,
G4double  y_full_size,
G4double  edge_z,
G4double  z_delta 
)

Create a Box solid.

Parameters
unitThe unit to use for this call only (ex: CLHEP::mm)
nameBase name to derive geometry object names from.
x_full_sizeFULL X size
y_full_sizeFULL Y size
edge_zFull Z size
z_deltaFull Z size
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 68 of file BoxBuilderCore.cc.

71 {
72 if (x_full_size <= 0 || y_full_size <= 0) {
73 throw std::invalid_argument("Error in CreateZDeltaBoxBuilder(): for volume " + name
74 + ": Sizes provided without end offsets must be positive.\n");
75 }
76 auto object = BoxBuilder(new BoxBuilderCore(name));
77 object->SetXSize(unit, x_full_size)
78 ->SetYSize(unit, y_full_size)
79 ->SetZEdgeDelta(unit, edge_z, z_delta);
80 return object;
81 }