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)
 
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 >
VolumeBuilderBase< U >::DerivedPtr ForkAndReset ( const G4String &  new_name) const

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 656 of file VolumeBuilderBase.hpp.

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

◆ ForkForFinalSolid()

template<typename U >
VolumeBuilderBase< 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 665 of file VolumeBuilderBase.hpp.

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

◆ 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 >
VolumeBuilderBase< 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 679 of file VolumeBuilderBase.hpp.

679 {
680 NoNameCheck(new_name, "ForkForLogicalVolume");
681 if (!final_solid_ptr_ && placement_configs_->is_builder) {
682 [[maybe_unused]] auto discard = GetFinalSolid();
683 }
684 DerivedPtr copy = this->Clone();
685 copy->SetName(new_name); // Set base name for derived class
686 copy->SetBooleanName("");
687 // all products are cleared by default, (re)build up to Solid
688 if (solid_ptr_ && placement_configs_->is_builder) {
689 copy->solid_ptr_.Link(this->solid_ptr_);
690 }
691 if (final_solid_ptr_ && placement_configs_->is_builder) {
692 copy->final_solid_ptr_.Link(this->final_solid_ptr_);
693 }
694 return copy;
695 }
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 >
VolumeBuilderBase< 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 698 of file VolumeBuilderBase.hpp.

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