DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Functions
Builder Copiers

Functions

DerivedPtr ForkForPlacement (std::optional< int > copy_no=std::nullopt, const G4String &name_override="")
 
DerivedPtr ForkForLogicalVolume (const G4String &new_name)
 
virtual DerivedPtr ForkAndReset (const G4String &new_name) const
 
DerivedPtr ForkForFinalSolid (const G4String &new_name)
 
DerivedPtr ForkForLogicalVolume (const G4String &new_name)
 
DerivedPtr ForkForPlacement (std::optional< int > copy_no=std::nullopt, const G4String &name_override="", bool parent_name_was_set=false)
 

Detailed Description

Copy Builders from various build steps.

These allow you to base placement builders on previously constructed solids etc.

Function Documentation

◆ ForkAndReset()

template<typename U >
VolumeBuilder< U >::DerivedPtr ForkAndReset ( const G4String &  new_name) const
virtual

Copy a configured/unbuilt Builder, with a new name.

This is the most generic all-purpose copier, but can result in some duplication of constituent solids, etc.

Copies all configurations. You can modify and rebuild all products. Copying-Transformations are not remembered. Base implementation is in VolumeBuilder, but can be overridden for Solid-Builder specific needs.

Parameters
new_name
Returns

Definition at line 659 of file VolumeBuilder.hpp.

659 {
660 NoNameCheck(new_name, "CopySolidBuilder");
661 DerivedPtr copy = this->Clone();
662 copy->SetName(new_name); // Set base name for derived class
663 copy->SetBooleanName("");
664 return copy;
665 }

◆ ForkForFinalSolid()

template<typename U >
VolumeBuilder< U >::DerivedPtr ForkForFinalSolid ( const G4String &  new_name)

Calls MakeSolid() and copies builder with products cleared for further construction.

Configurations from ALL stages (including later) are kept.

Parameters
new_nameThe base name for the new builder's Geant products.
Returns
A shared pointer to the new builder instance.

Definition at line 668 of file VolumeBuilder.hpp.

668 {
669 NoNameCheck(new_name, "ForkForFinalSolid");
670 if (!solid_ptr_) {
671 MakeSolid();
672 }
673 DerivedPtr copy = this->Clone();
674 copy->SetName(new_name); // Set base name for derived class
675 copy->SetBooleanName("");
676 // all products are cleared by default, (re)build up to Solid
677 copy->solid_ptr_.Link(this->solid_ptr_);
678 return copy;
679 }
DerivedPtr MakeSolid()
Make the G4VSolid.

◆ ForkForLogicalVolume() [1/2]

template<typename U >
DerivedPtr ForkForLogicalVolume ( const G4String &  new_name)

Makes final solid (including booleans) if unbuilt and copies builder with products cleared for further construction.

Configurations from ALL stages (including later) are kept.

This one seems pretty specific, but could be useful for extending a boolean build more easily possibly

Parameters
new_nameThe base name for the new builder's logical and physical volumes.
Returns
A shared pointer to the new builder instance.

◆ ForkForLogicalVolume() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr ForkForLogicalVolume ( const G4String &  new_name)

Makes final solid (including booleans) if unbuilt and copies builder with products cleared for further construction.

Configurations from ALL stages (including later) are kept.

This one seems pretty specific, but could be useful for extending a boolean build more easily possibly

Parameters
new_nameThe base name for the new builder's logical and physical volumes.
Returns
A shared pointer to the new builder instance.

Definition at line 682 of file VolumeBuilder.hpp.

682 {
683 NoNameCheck(new_name, "ForkForLogicalVolume");
684 if (!final_solid_ptr_ && placement_configs_->is_builder) {
685 [[maybe_unused]] auto discard = GetFinalSolid();
686 }
687 DerivedPtr copy = this->Clone();
688 copy->SetName(new_name); // Set base name for derived class
689 copy->SetBooleanName("");
690 // all products are cleared by default, (re)build up to Solid
691 if (solid_ptr_ && placement_configs_->is_builder) {
692 copy->solid_ptr_.Link(this->solid_ptr_);
693 }
694 if (final_solid_ptr_ && placement_configs_->is_builder) {
695 copy->final_solid_ptr_.Link(this->final_solid_ptr_);
696 }
697 return copy;
698 }
G4VSolid * GetFinalSolid() final
Gets a complete final built Solid, including configured Boolean operaions if any.

◆ ForkForPlacement() [1/2]

template<typename U >
DerivedPtr ForkForPlacement ( std::optional< int >  copy_no = std::nullopt,
const G4String &  name_override = "" 
)

Calls MakeLogicalVolume() and creates a new builder instance with a copy of all placement-related configs.


This will be called automatically by consecutive calls to MakePlacement(). All physical volume and (future?) derived products are reset to be rebuilt. Copy_no and placement name can be auto incremented (number only by default) or overridden.

The copy_no will be incremented.

Parameters
copy_nono arguments or std::nullopt to leave as auto. Must set on every use to get manual numbering.
name_overrideAn optional name override for the physical volume. Leave blank to use auto controls instead.
Returns
A shared pointer to the new builder instance.

◆ ForkForPlacement() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr ForkForPlacement ( std::optional< int >  copy_no = std::nullopt,
const G4String &  name_override = "",
bool  parent_name_was_set = false 
)

Calls MakeLogicalVolume() and creates a new builder instance with a copy of all placement-related configs.


This will be called automatically by consecutive calls to MakePlacement(). All physical volume and (future?) derived products are reset to be rebuilt. Copy_no and placement name can be auto incremented (number only by default) or overridden.

The copy_no will be incremented.

Parameters
copy_nono arguments or std::nullopt to leave as auto. Must set on every use to get manual numbering.
name_overrideAn optional name override for the physical volume. Leave blank to use auto controls instead.
Returns
A shared pointer to the new builder instance.

Definition at line 701 of file VolumeBuilder.hpp.

702 {
703 // really a clone of logical volume:
704 if (!logicvol_ptr_ && placement_configs_->is_builder) {
706 }
707 DerivedPtr copy = this->Clone();
708 copy->explicit_copyno_set_ = static_cast<bool>(copy_no);
709 copy->explicit_physical_copy_name_set_ = !name_override.empty() || parent_name_was_set;
710 copy->placement_name_override_ = name_override;
711 // register name and get provisional copy_no:
712 copy->placement_configs_->copy_no = PlacementNameRegistry::IncrementNameCount(
713 GetPlacementBaseName());
714 //Override if copy_no was passed:
715 copy->placement_configs_->copy_no = copy_no.value_or(copy->placement_configs_->copy_no);
716
717 // Restore logical_volume pointer and below
718 copy->solid_ptr_.Link(this->solid_ptr_);
719 copy->final_solid_ptr_.Link(this->final_solid_ptr_);
720 copy->logicvol_ptr_.Link(this->logicvol_ptr_);
721
722 return copy;
723 }
DerivedPtr MakeLogicalVolume(G4Material *material=nullptr, G4String name=std::string())
Basically never needed now.