DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
StructureBuilder< U > Class Template Referenceabstract

#include <StructureBuilder.hh>

Collaboration diagram for StructureBuilder< U >:
[legend]

Public Member Functions

DerivedPtr MakePlacement ()
 
DerivedPtr ForkForPlacement (std::optional< int > copy_no=std::nullopt, const G4String &name_override="")
 
DerivedPtr ForkForLogicalVolume (const G4String &new_name)
 
DerivedPtr PlaceAndFork ()
 
DerivedPtr SetName (const G4String &name)
 
DerivedPtr SetMaterial (G4Material *material)
 
DerivedPtr SetColor (double r=0.5, double g=0.5, double b=0.5, double alpha=1.0)
 
DerivedPtr SetColor (const G4Colour &color)
 
DerivedPtr SetAlpha (G4double alpha)
 
DerivedPtr ForceSolid (bool x=true)
 
DerivedPtr SetVisibility (bool is_visible=true)
 
DerivedPtr SetPhysRotation (const G4RotationMatrix &rot)
 
DerivedPtr StackPhysRotation (const G4RotationMatrix &stacked_rot)
 
DerivedPtr SetPhysOffset (const Unit3Vec &offset={CLHEP::mm, 0, 0, 0})
 
DerivedPtr StackPhysOffset (const Unit3Vec &offset={CLHEP::mm, 0, 0, 0})
 
DerivedPtr SetPhysTransform (const UnitlessG4Transform3D &new_transform)
 
DerivedPtr StackPhysTransform (const UnitlessG4Transform3D &stacked_transform)
 
G4Transform3D GetPhysTransform () const
 
DerivedPtr OverridePlacementName (const G4String &pName)
 
DerivedPtr SetCopyNo (G4int pCopyNo)
 
DerivedPtr SetSurfaceCheck (G4bool pSurfChk)
 
DerivedPtr SetMother (const BuilderView &mother)
 
DerivedPtr SetAutoPlacementNaming (bool set)
 
DerivedPtr SetAutoCopyNo (bool set)
 
DerivedPtr CopyPlacementConfigsFrom (const BuilderView &other)
 
DerivedPtr SetDefaultUnit (G4double unit)
 
G4double GetEffectiveDefaultUnit () const
 
 ~StructureBuilder () override
 
G4String GetBuilderName () const
 
std::shared_ptr< T > shared_from_this ()
 
std::shared_ptr< const T > shared_from_this () const
 
void set_shared_from_this_enabled (bool enabled)
 

Protected Member Functions

G4VSolid * SolidConstructor (const G4String &name) override=0
 

Protected Attributes

std::atomic< bool > is_enabled_ {true}
 

Friends

template<typename >
class VolumeBuilder
 
class StructureBuilderReference
 
class Assembly
 
template<typename >
class StructureBuilder
 
class i_shared_ptr< StructureBuilder< U > >
 
class RZBuilder
 
class FromG4VSolid
 
AssemblyPtr CreateAssembly (G4String name)
 

Detailed Description

template<typename U>
class DLG4::VolumeBuilders::StructureBuilder< U >

A type-erased (data shared view) view of a builder or assembly, ie a "structure.".

*@class StructureBuilder

Can hold other structures, creating placement hierarchies. Behaves like a buidler, but only for logical volume properties and placement related commands. You can set VisAtt on a structure, and can set offsets and rotations of the whole structure for placement.

While this base view only supports limited methods, it is fully polymorphic and builder objects internally can trigger their full build chain.

This derived clas really exists for parallelism with VolumeBuilderReference.

See also
VolumeBuilder for inherited methods.

Definition at line 59 of file StructureBuilder.hh.

Constructor & Destructor Documentation

◆ ~StructureBuilder()

template<typename U >
~StructureBuilder ( )
override

Destructor Normally does not delete volume objects.

Geant takes care of that.

Member Function Documentation

◆ GetBuilderName()

template<typename U >
G4String GetBuilderName ( ) const

◆ GetEffectiveDefaultUnit()

template<typename U >
G4double GetEffectiveDefaultUnit ( ) const

Get the structure default unit or global if not set.

Returns
The active default unit.

◆ MakePlacement()

template<typename U >
DerivedPtr MakePlacement ( )

Make a placed physical volume.

Retrieve it or make and retrieve with GetPlacement() Fails (throws) if already built. Make a copy first.

Returns
The builder

◆ set_shared_from_this_enabled()

template<typename T >
void set_shared_from_this_enabled ( bool  enabled)
inlineinherited

Definition at line 60 of file disableable_shared_from_this.hh.

60 {
61 is_enabled_ = enabled;
62 }

◆ SetName()

template<typename U >
DerivedPtr SetName ( const G4String &  name)

SetName Sets name used for solid and derived product names.

Parameters
nameThe name
Returns
The builder

◆ shared_from_this() [1/2]

template<typename T >
std::shared_ptr< T > shared_from_this ( )
inlineinherited

Definition at line 44 of file disableable_shared_from_this.hh.

44 {
45 if (is_enabled_) {
46 return std::enable_shared_from_this<T>::shared_from_this();
47 } else {
48 return nullptr;
49 }
50 }

◆ shared_from_this() [2/2]

template<typename T >
std::shared_ptr< const T > shared_from_this ( ) const
inlineinherited

Definition at line 52 of file disableable_shared_from_this.hh.

52 {
53 if (is_enabled_) {
54 return std::enable_shared_from_this<T>::shared_from_this();
55 } else {
56 return nullptr;
57 }
58 }

◆ SolidConstructor()

template<typename U >
G4VSolid * SolidConstructor ( const G4String &  name)
overrideprotectedpure virtual

polymorphic access to solid construction

Implements IStructureBuilder.

◆ StackPhysOffset()

template<typename U >
DerivedPtr StackPhysOffset ( const Unit3Vec offset = {CLHEP::mm, 0, 0, 0})

Like SetPhysOffset but stacks with previous transformations in order applied.

Note: Structures/Assebnlies stack transformations hierarchichicaly automatically.
This method is for manual hierarchical stacking calculations. It's probably redundant on assemblies in 99% of caases
Unlike with G4Transform multiplication, stacking is done in a way that allows mutiple objects to move together. The first transformations can set individual objects, and a uniform transformation can be applied to them all to create a rigid motion of the collection.

Parameters
offset
Returns
The builder

◆ StackPhysRotation()

template<typename U >
DerivedPtr StackPhysRotation ( const G4RotationMatrix &  stacked_rot)

Like SetPhysRotation but stacks with previous transformations in order applied.

Note: Structures/Assebnlies stack transformations hierarchichicaly automatically.
This method is for manual hierarchical stacking calculations. It's probably redundant on assemblies in 99% of caases
Unlike with G4Transform multiplication, stacking is done in a way that allows mutiple objects to move together. The first transformations can set individual objects, and a uniform transformation can be applied to them all to create a rigid motion of the collection.

Parameters
stacked_rot
Returns
The builder

◆ StackPhysTransform()

template<typename U >
DerivedPtr StackPhysTransform ( const UnitlessG4Transform3D stacked_transform)

Like SetPhysTransform but stacks with previous transformations in order applied.

Note: Structures/Assebnlies stack transformations hierarchichicaly automatically.
This method is for manual hierarchical stacking calculations. It's probably redundant on assemblies in 99% of caases

Parameters
stacked_transform
Returns
The builder

Friends And Related Symbol Documentation

◆ Assembly

template<typename U >
friend class Assembly
friend

Definition at line 66 of file StructureBuilder.hh.

◆ CreateAssembly

template<typename U >
AssemblyPtr CreateAssembly ( G4String  name)
friend

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

◆ FromG4VSolid

template<typename U >
friend class FromG4VSolid
friend

Definition at line 423 of file StructureBuilder.hh.

◆ i_shared_ptr< StructureBuilder< U > >

template<typename U >
friend class i_shared_ptr< StructureBuilder< U > >
friend

Definition at line 69 of file StructureBuilder.hh.

◆ RZBuilder

template<typename U >
friend class RZBuilder
friend

Definition at line 421 of file StructureBuilder.hh.

◆ StructureBuilder

template<typename U >
template<typename >
friend class StructureBuilder
friend

Definition at line 69 of file StructureBuilder.hh.

◆ StructureBuilderReference

template<typename U >
StructureBuilderReference
friend

Definition at line 65 of file StructureBuilder.hh.

◆ VolumeBuilder

template<typename U >
template<typename >
friend class VolumeBuilder
friend

Definition at line 64 of file StructureBuilder.hh.

Member Data Documentation

◆ is_enabled_

template<typename T >
std::atomic<bool> is_enabled_ {true}
protectedinherited

Definition at line 37 of file disableable_shared_from_this.hh.

37{true};

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