DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
|
#include <FromG4VSolid.hh>
Public Member Functions | |
FromG4VSolid (const FromG4VSolid &other) | |
FromG4VSolid & | operator= (const FromG4VSolid &other)=delete |
G4VPhysicalVolume * | GetPlacement () final |
DerivedPtr | MakePlacement () |
DerivedPtr | PlaceAndFork () |
G4LogicalVolume * | GetLogicalVolume () final |
G4VSolid * | GetBaseSolid () final |
G4VSolid * | GetFinalSolid () final |
DerivedPtr | MakeLogicalVolume (G4Material *material=nullptr, G4String name=std::string()) |
DerivedPtr | MakeSolid () |
DerivedPtr | SetName (const G4String &name) |
DerivedPtr | AddUnion (const BuilderView &other, const Unit3Vec &offset={CLHEP::mm, 0, 0, 0}, G4RotationMatrix *rotation=nullptr) |
DerivedPtr | AddSubtraction (const BuilderView &other, const Unit3Vec &offset={CLHEP::mm, 0, 0, 0}, G4RotationMatrix *rotation=nullptr) |
DerivedPtr | AddIntersection (const BuilderView &other, const Unit3Vec &offset={CLHEP::mm, 0, 0, 0}, G4RotationMatrix *rotation=nullptr) |
DerivedPtr | AddBoolean (const BuilderView &other, bool is_subtraction=false, bool is_intersection=false, const Unit3Vec &offset={CLHEP::mm, 0, 0, 0}, G4RotationMatrix *rotation=nullptr) |
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 x=true) |
DerivedPtr | SetLogicalVolume (G4LogicalVolume *logical_volume) |
DerivedPtr | SetBooleanName (const G4String &name) |
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 &new_transform) |
G4Transform3D | GetPhysTransform () const final |
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 | ReflectZFinalSolid () |
DerivedPtr | ReflectZBaseSolid () |
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) |
DerivedPtr | CopyPlacementConfigsFrom (const BuilderView &other) |
DerivedPtr | CopyVolumeConfigsFrom (const BuilderView &other) |
DerivedPtr | SetDefaultUnit (G4double unit) |
G4double | GetEffectiveDefaultUnit () const |
DerivedPtr | AddTo (BuilderViewList &list) const |
DerivedPtr | AddTo (StructureViewList &list) const |
DerivedPtr | AddTo (AssemblyPtr &assembly) const |
BuilderView | ToBuilderView () const override |
StructureView | ToStructureView () const 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 | |
SharedPtr< IStructureBuilder > | clone_impl () const override |
Protected Attributes | |
std::atomic< bool > | is_enabled_ {true} |
Friends | |
class | VolumeBuilder< FromG4VSolid > |
class | VolumeBuilderReference |
FromG4VSolidPtr | CreateFromG4VSolidBuider (G4VSolid *solid) |
A solid buider class that just wrap an existing G4VSolid.
// Created by @author Douglas S. Leonard on @date 6/8/25. All rights Reserved. // See related files for license, if any is provided. // // @ brief A stubbed VolumeBuilder Factory to create a builder from Any geant Solid. // Only the out-of-class static Factory CreateFromG4VSolid() is exposed. // Use it to configure logical volume and placement with VolumeBuilder from a standard G4VSolid. ///
Definition at line 35 of file FromG4VSolid.hh.
FromG4VSolid | ( | const FromG4VSolid & | other | ) |
Definition at line 35 of file FromG4VSolid.cc.
|
inherited |
Add a boolean operation.
This does NOT immediately trigger a build on a passed-in builder, just pre-sets the relationship.
other | A VolumeBuilder, G4VSolid, or anything constructable by a VolumeReferencePtr |
is_subtraction | true for subtraction, false for union |
is_intersection | true for intersection, false for union |
offset | Offset applied to solid |
rotation | Applied to solid |
Definition at line 218 of file VolumeBuilder.hpp.
|
inherited |
Define combination another volume with present one, This does NOT immediately trigger a build on a passed-in builder, just pre-sets the relationship.
other | A VolumeBuilder, G4VSolid, or anything constructable by a VolumeReferencePtr |
offset | Offset applied to solid |
rotation | Applied to solid |
Definition at line 202 of file VolumeBuilder.hpp.
|
inherited |
Define combination another volume with present one, This does NOT immediately trigger a build on a passed-in builder, just pre-sets the relationship.
other | A VolumeBuilder, G4VSolid, or anything constructable by a VolumeReferencePtr |
offset | Offset applied to solid |
rotation | Applied to solid |
Definition at line 198 of file VolumeBuilder.hpp.
|
inherited |
Add the builder an assembly geometrically joined manipulation.
assembly | The assembly to add to. |
Definition at line 625 of file VolumeBuilder.hpp.
|
inherited |
Definition at line 607 of file VolumeBuilder.hpp.
|
inherited |
Add the builder a list for group/batch manipulations.
list | The list to add to. |
Definition at line 616 of file VolumeBuilder.hpp.
|
inherited |
Define combination another volume with present one, This does NOT immediately trigger a build on a passed-in builder, just pre-sets the relationship.
other | A VolumeBuilder, G4VSolid, or anything constructable by a VolumeReferencePtr |
offset | Offset applied to solid |
rotation | Applied to solid |
Definition at line 194 of file VolumeBuilder.hpp.
|
overrideprotectedvirtualinherited |
Implements IStructureBuilder.
Definition at line 644 of file VolumeBuilder.hpp.
|
inherited |
This may help if reusing placement configs for a different shape.
Copies the placement configuration (rotation, translation, mother, etc.) from another builder. Does NOT copy any naming, as that would conflict. Also does NOT copy any products. Use CopyPlacement Builder for that. Names will derive from present object, or you can override with Setters as usual.
other | The builder instance to copy placement configuration from. |
Definition at line 560 of file VolumeBuilder.hpp.
|
inherited |
Copies the LogicalVolume configuration (material, VisAttributes, etc.) from another builder.
This DOES NOT include copying any booleans. This is useful for setting up multiple placements with similar configurations.
other | The builder instance to copy placement configuration from. |
Definition at line 571 of file VolumeBuilder.hpp.
|
inherited |
Definition at line 263 of file VolumeBuilder.hpp.
|
virtualinherited |
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.
new_name |
Definition at line 494 of file VolumeBuilder.hpp.
|
inherited |
Calls MakeSolid() and copies builder with products cleared for further construction.
Configurations from ALL stages (including later) are kept.
new_name | The base name for the new builder's Geant products. |
Definition at line 505 of file VolumeBuilder.hpp.
|
inherited |
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
new_name | The base name for the new builder's logical and physical volumes. |
Definition at line 520 of file VolumeBuilder.hpp.
|
inherited |
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.
copy_no | no arguments or std::nullopt to leave as auto. Must set on every use to get manual numbering. |
name_override | An optional name override for the physical volume. Leave blank to use auto controls instead. |
Definition at line 537 of file VolumeBuilder.hpp.
|
finalvirtualinherited |
You probably want GetSolid() instead!!! This Gets a built Solid, BUT NOT final Boolean.
Builds default if not built yet.
Even if you aren't doing boolean now, if you add it later, this method will miss it. GetFinalSolid() is more general.
Implements IVolumeBuilder.
Definition at line 135 of file VolumeBuilder.hpp.
|
inherited |
Definition at line 637 of file VolumeBuilder.hpp.
|
inherited |
Get the builder default unit or global if not set.
Definition at line 597 of file VolumeBuilder.hpp.
|
finalvirtualinherited |
Gets a complete final built Solid, including configured Boolean operaions if any.
Builds default if not built yet.
Implements IVolumeBuilder.
Definition at line 143 of file VolumeBuilder.hpp.
|
finalvirtualinherited |
Gets a built LogicalVolume, builds default if not built yet.
Implements IVolumeBuilder.
Definition at line 123 of file VolumeBuilder.hpp.
|
inlinefinalvirtualinherited |
A helper to get the Physical Volume transform with units applied This is built from rotation and translatin if they were provided, or from a transform if it was provided, with units applied as specified.
Basically allows you to get the unit-multiplied version for use in direct Geant calls.
Implements IVolumeBuilder.
Definition at line 383 of file VolumeBuilder.hh.
|
finalvirtualinherited |
Gets the (last) placed physical volume.
Constructs it if not built yet. Unlike MakePlacement(), this will NOT auto-trigger consecutive placments from copied builders. But you can call it again after MakePlacement() to get those.
Implements IVolumeBuilder.
Definition at line 88 of file VolumeBuilder.hpp.
|
inherited |
Basically never needed now.
Builds the logical volume and returns the builder. GetLogicalVolume(), or passing the builder to any consumer will trigger the build anyway.
material | Pointer to material to use. |
name | Optional explicit name for logical volume. Normally already derived from builder/solid name. |
Definition at line 157 of file VolumeBuilder.hpp.
|
inherited |
Make a placed physical volume.
Retrieve it or make and retrieve with GetPlacement() Fails (throws) if already built. Make a copy first.
Definition at line 98 of file VolumeBuilder.hpp.
|
inherited |
Make the G4VSolid.
Returns the builder. Use GetBaseSolid() to retrieve or make and retrieve it.
Definition at line 165 of file VolumeBuilder.hpp.
|
delete |
|
inherited |
Set the placement name for the volume.
pName | Name for the placement. |
Definition at line 394 of file VolumeBuilder.hpp.
|
inlineinherited |
An alias for MakePlacement and ForkForPlacement Used for one or many unaltered placments in sequence, usually with auto naming and/or numbering.
Definition at line 109 of file VolumeBuilder.hh.
|
inherited |
Configure base solid to be flipped BEFORE applying booleans.
Definition at line 478 of file VolumeBuilder.hpp.
|
inherited |
Configure final solid to be flipped in z.
Definition at line 468 of file VolumeBuilder.hpp.
|
inlineinherited |
Definition at line 60 of file disableable_shared_from_this.hh.
|
inherited |
alpha |
Definition at line 256 of file VolumeBuilder.hpp.
|
inherited |
Enable (disable for false) auto Physical Volume numbering, on by default.
Adds a copy number to every name. By default copy numbers auto increment. Or you can set explicit names and numbers in ClonePlacement.
set | True before setting. |
Definition at line 451 of file VolumeBuilder.hpp.
|
inherited |
Enable auto Physical Volume naming.
Adds a copy number to every name. By default copy numbers auto increment.
This will turn that off. Both makes no sense.
Or you can set explicit names and numbers in ClonePlacement.
set | False before setting. |
Definition at line 438 of file VolumeBuilder.hpp.
|
inherited |
Pre-set base name for logical and physical volumes.
_L and _P will be appended, respectively.
If not set, the builder will take it from the builder name. But this is useful for unions where the starting solid name may be more specific.
name |
Definition at line 299 of file VolumeBuilder.hpp.
|
inherited |
color |
Definition at line 248 of file VolumeBuilder.hpp.
|
inherited |
Definition at line 240 of file VolumeBuilder.hpp.
|
inherited |
Set the copy number for the placement.
pCopyNo | Copy number. |
Definition at line 403 of file VolumeBuilder.hpp.
|
inherited |
Set the per-Builder default unit for all later non-factory offsets.
Use DLG4::VolumeBuilders::SetGlobalDefaultUnit() to set a default for all builders, or fall back to the initial default of CLHEP::mm.
unit | The unit to set, ex: CLHEP::mm |
Definition at line 590 of file VolumeBuilder.hpp.
|
inherited |
Directly Provide a Logical Volume Instead of using the builder.
logical_volume |
Definition at line 288 of file VolumeBuilder.hpp.
|
inherited |
|
inherited |
Set the mother volume with a builder, or G4VPhysicalVolume or G4VLogicalVolume through implicit conversion.
This does NOT immediately force a build the mother builder, just pre-sets the relationship.
mother | olumeReferencePtrparameter accepts a builder or a G4VSolid through implicit ctor |
Definition at line 425 of file VolumeBuilder.hpp.
|
inherited |
SetName Sets name used for solid and derived product names.
name | The name |
Definition at line 172 of file VolumeBuilder.hpp.
|
inherited |
Set the translation vector for placement.
Using Set, rotation applies before translation, regardless of order set, just as in G4PVPlacement() You can pass (unit, x, y, z) or use the default unit with (x, y, z).
Examples: SetPhysOffset({CLHEP::cm, 1, 2, 3}) // 1cm, 2cm, 3cm SetPhysOffset({1, 2, 3}) // Uses default default unit (usually mm) SetDefaultUnit(CLHEP::cm); SetPhysOffset({1, 2, 3}) // 1cm, 2cm, 3cm SetDefaultUnit(1); SetPhysOffset({10*CLHEP::mm, 20*CLHEP::mm, 30*CLHEP::mm}) // Values already have units
offset | Translation vector. See method description for details. |
Definition at line 338 of file VolumeBuilder.hpp.
|
inherited |
Set the rotation matrix for placement.
Using Set, rotation applies before translation, regardless of order set, just as in G4PVPlacement()
rot | Pointer to the rotation matrix. |
Definition at line 308 of file VolumeBuilder.hpp.
|
inherited |
Set the G4Transform3D for placment The tranformation provided is meant to be UNITLESS unless you SetDefaultUnit(1).
Otherwise ex: SetDefaultUnit(CLHEP::cm) and proivde a UNITLESS transform. To supply units for each G4Tranform3D separately, just call SetDefaultUnit(unit) before each call. Will overwite/replace rotation and translation.
new_transform | Translation vector. |
Definition at line 364 of file VolumeBuilder.hpp.
|
inherited |
Set the surface check flag for the placement.
pSurfChk | Boolean flag for surface check. |
Definition at line 411 of file VolumeBuilder.hpp.
|
inherited |
x |
Definition at line 271 of file VolumeBuilder.hpp.
|
inlineinherited |
Definition at line 44 of file disableable_shared_from_this.hh.
|
inlineinherited |
Definition at line 52 of file disableable_shared_from_this.hh.
|
inherited |
Like SetPhysOffset but stacks with previous transformations in order applied.
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.
offset |
Definition at line 349 of file VolumeBuilder.hpp.
|
inherited |
Like SetPhysRotation but stacks with previous transformations in order applied.
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.
stacked_rot |
Definition at line 320 of file VolumeBuilder.hpp.
|
inherited |
Like SetPhysTransform but stacks with previous transformations in order applied.
new_transform |
Definition at line 371 of file VolumeBuilder.hpp.
|
overridevirtualinherited |
Implements IStructureBuilder.
Definition at line 633 of file VolumeBuilder.hpp.
|
overridevirtualinherited |
Implements IStructureBuilder.
Definition at line 635 of file VolumeBuilder.hpp.
|
friend |
|
friend |
Definition at line 35 of file FromG4VSolid.hh.
|
friend |
Definition at line 37 of file FromG4VSolid.hh.
|
protectedinherited |
Definition at line 37 of file disableable_shared_from_this.hh.