2#ifndef STRUCTUREBUILDER_HH
3#define STRUCTUREBUILDER_HH
8#include <G4Transform3D.hh>
32#include "G4VPhysicalVolume.hh"
33#include <G4ThreeVector.hh>
103 std::optional<int> copy_no = std::nullopt
104 ,
const G4String &name_override =
"");
291 return {placement_configs_->rotation, placement_configs_->translation};
431 auto retval = i_dynamic_pointer_cast<U>(base_cloned_ptr);
442 template <
typename T,
typename std::enable_if_t<std::is_base_of_v<IStructureBuilder, T>,
452 G4VSolid *GetSolidPtr()
const {
458 ONCE_MUTABLE Linkable<BooleanConfigs> boolean_configs_{BooleanConfigs{}};
459 ONCE_MUTABLE Linkable<VolumeConfigs> lv_configs_{VolumeConfigs{}};
460 ONCE_MUTABLE Linkable<PlacementConfigs> placement_configs_{PlacementConfigs{}};
467 bool was_placed_ =
false;
473 bool explicit_copyno_set_ =
false;
474 bool explicit_physical_copy_name_set_ =
false;
475 G4String placement_name_override_ =
"";
480 static constexpr bool has_ownership_{
false};
481 static constexpr bool enable_full_lazy_builds{
true};
486 [[nodiscard]] G4String GetLogicVolName()
const;
488 void ValidateForPVBuild(std::string
const &site = std::string());
489 void ValidatePlacementNotBuilt(
const std::string &operation)
const;
495 static void NoNameCheck(
const std::string &name,
const std::string &site) {
497 throw std::runtime_error(
"Error in " + site +
" ,"
498 "for builder named: " + name +
"\n"
499 " Must provide a new name");
A type-erased (data shared view) view of a builder or assembly, ie a "structure.".
A solid buider class that just wrap an existing G4VSolid.
a non-fluent polymorphic class to access the derived solid-builder from a base reference: This gets u...
Builder class for RZ mult-plane defined solids.
A type-erased (data shared view) view of a builder or assembly, ie a "structure.".
A type-erased (data shared view) view of a builder or assembly, ie a "structure.".
G4double GetEffectiveDefaultUnit() const
Get the structure default unit or global if not set.
friend class StructureBuilder
DerivedPtr StackPhysTransform(const UnitlessG4Transform3D &stacked_transform)
Like SetPhysTransform but stacks with previous transformations in order applied.
G4VSolid * SolidConstructor(const G4String &name) override=0
polymorphic access to solid construction
~StructureBuilder() override
Destructor Normally does not delete volume objects.
friend AssemblyPtr CreateAssembly(G4String name)
Assembly of strucures, ie builders and/or other assemblies.
DerivedPtr StackPhysRotation(const G4RotationMatrix &stacked_rot)
Like SetPhysRotation but stacks with previous transformations in order applied.
DerivedPtr StackPhysOffset(const Unit3Vec &offset={CLHEP::mm, 0, 0, 0})
Like SetPhysOffset but stacks with previous transformations in order applied.
DerivedPtr SetName(const G4String &name)
SetName Sets name used for solid and derived product names.
G4String GetBuilderName() const
DerivedPtr MakePlacement()
Make a placed physical volume.
A 3D vector that carries its own unit information.
VolumeBuilder: Common functionality for volume builder classes.
A wrapper for std::shared_ptr that allows and facilitates many implicit(i) type conversions.
DerivedPtr CopyPlacementConfigsFrom(const BuilderView &other)
This may help if reusing placement configs for a different structure.
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 con...
DerivedPtr ForkForLogicalVolume(const G4String &new_name)
Makes final solid (including booleans) if unbuilt and copies builder with products cleared for furthe...
DerivedPtr SetColor(const G4Colour &color)
DerivedPtr SetColor(double r=0.5, double g=0.5, double b=0.5, double alpha=1.0)
DerivedPtr SetVisibility(bool is_visible=true)
DerivedPtr SetMaterial(G4Material *material)
DerivedPtr SetAlpha(G4double alpha)
DerivedPtr ForceSolid(bool x=true)
G4Transform3D GetPhysTransform() const
A helper to get the Physical Volume transform with units applied This is built from rotation and tran...
DerivedPtr SetMother(const BuilderView &mother)
Set the mother volume with a builder, or G4VPhysicalVolume or G4VLogicalVolume through implicit conve...
DerivedPtr SetAutoCopyNo(bool set)
Enable (disable for false) auto Physical Volume numbering, on by default.
DerivedPtr SetPhysOffset(const Unit3Vec &offset={CLHEP::mm, 0, 0, 0})
Set the translation vector for placement.
DerivedPtr SetAutoPlacementNaming(bool set)
Enable auto Physical Volume naming.
DerivedPtr SetCopyNo(G4int pCopyNo)
Set the copy number for the placement.
DerivedPtr SetPhysRotation(const G4RotationMatrix &rot)
Set the rotation matrix for placement.
DerivedPtr SetPhysTransform(const UnitlessG4Transform3D &new_transform)
Set the G4Transform3D for placment The tranformation provided is meant to be UNITLESS unless you SetD...
DerivedPtr OverridePlacementName(const G4String &pName)
Set the placement name for the volume.
DerivedPtr PlaceAndFork()
An alias for MakePlacement and ClonePlacement Used for one or many unaltered placments in sequence,...
DerivedPtr SetSurfaceCheck(G4bool pSurfChk)
Set the surface check flag for the placement.
DerivedPtr SetDefaultUnit(G4double unit)
Set the per-Structure default unit for all later non-factory offsets.
G4Transform3D UnitlessG4Transform3D