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

Functions

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

Detailed Description

Factories for creating VolumeBuilder and StructureBuilder objects.

/**

/**

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.

Factories for creating VolumeBuilder and StructureBuilder objects.

Function Documentation

◆ CreateAssembly()

AssemblyPtr CreateAssembly ( G4String  name)

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

Definition at line 25 of file Assembly.cc.

25 {
26 // Haha... assemblies actually are builders!!!
27 auto object = AssemblyPtr(new Assembly());
28 // ... with is_builder set to false.
29 object->placement_configs_->is_builder = false;
30 //We're storing a pointer to the view in the builder by writing to the builder through that same view!
31 BuilderView builder_view = object->ToBuilderView();
32 builder_view->StoreBuilderView(builder_view);
33 // Then store itself in its new builder (that links to its data).
34 //object->builder_configs_->builder_view->StoreIStructurePtr(IStructurePtr(object.get())); // this is the owning copy.
35 // ... and viewed through a reduced StructureView interface:
36 object->SetName(name);
37 auto return_obj = AssemblyPtr(object);
38 return return_obj;
39
40 // This let's us reuse builder methods!
41 }
SharedPtr< VolumeBuilderReference > BuilderView
Common interface for all volume builder types.
SharedPtr< Assembly > AssemblyPtr

◆ CreateBoxBuilder() [1/2]

BoxBuilderPtr CreateBoxBuilder ( const G4String &  name)

Definition at line 32 of file BoxBuilder.cc.

32 {
33 auto object = BoxBuilderPtr(new BoxBuilder(name));
34 return object;
35 }
SharedPtr< BoxBuilder > BoxBuilderPtr
Definition BoxBuilder.hh:28

◆ CreateBoxBuilder() [2/2]

BoxBuilderPtr CreateBoxBuilder ( const G4String &  name,
G4double  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 37 of file BoxBuilder.cc.

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

◆ CreateCenteredBoxBuilder() [1/2]

BoxBuilderPtr 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 110 of file BoxBuilder.cc.

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

◆ CreateCenteredBoxBuilder() [2/2]

BoxBuilderPtr CreateCenteredBoxBuilder ( G4double  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 96 of file BoxBuilder.cc.

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

◆ CreateCylinderBuilder() [1/2]

RZBuilderPtr 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 60 of file RZBuilder.cc.

61 {
62 return CreateCylinderBuilder(BuilderConfigs::global_default_unit, name, endz, h, OR, IR);
63 }
RZBuilderPtr CreateCylinderBuilder(G4double unit, const G4String &name, G4double endz, G4double height, G4double OR, G4double IR=0)
Create a simple cylinder builder.
Definition RZBuilder.cc:44

◆ CreateCylinderBuilder() [2/2]

RZBuilderPtr CreateCylinderBuilder ( G4double  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 44 of file RZBuilder.cc.

45 {
46 // ReSharper disable once CppDFAMemoryLeak
47 auto object = RZBuilderPtr(new RZBuilder(name));
48 object->MakeSolidFunctionPtr_ = &RZBuilder::MakePolycone;
49 RZPlane plane;
50 plane.unit = unit;
51 plane.z = endz;
52 plane.IR = IR;
53 plane.OR = OR;
54 object->AddPlane(plane);
55 plane.z += h;
56 object->AddPlane(plane);
57 return RZBuilderPtr(object);
58 }
SharedPtr< RZBuilder > RZBuilderPtr
Definition RZBuilder.hh:68

◆ CreateDeltasBoxBuilder() [1/2]

BoxBuilderPtr 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 56 of file BoxBuilder.cc.

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

◆ CreateDeltasBoxBuilder() [2/2]

BoxBuilderPtr CreateDeltasBoxBuilder ( G4double  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 44 of file BoxBuilder.cc.

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

◆ CreateEdgesBoxBuilder() [1/2]

BoxBuilderPtr 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 124 of file BoxBuilder.cc.

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

◆ CreateEdgesBoxBuilder() [2/2]

BoxBuilderPtr CreateEdgesBoxBuilder ( G4double  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 134 of file BoxBuilder.cc.

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

◆ CreateFromG4VSolid()

FromG4VSolidPtr CreateFromG4VSolid ( G4VSolid *  solid)

Constructor to make a builder from an Existing Geant solid.

Parameters
solidG4VSolid pointer
Returns

Definition at line 25 of file FromG4VSolid.cc.

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

◆ CreatePolyconeBuilder()

RZBuilderPtr 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 26 of file RZBuilder.cc.

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

◆ CreatePolyhedraBuilder()

RZBuilderPtr 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 36 of file RZBuilder.cc.

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

◆ CreateZDeltaBoxBuilder() [1/2]

BoxBuilderPtr 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 82 of file BoxBuilder.cc.

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

◆ CreateZDeltaBoxBuilder() [2/2]

BoxBuilderPtr CreateZDeltaBoxBuilder ( G4double  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 67 of file BoxBuilder.cc.

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