DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
VolumeBuilderConfigs.hh
Go to the documentation of this file.
1#pragma once
2//
3// Created by Douglas S. Leonard on 6/18/25. All rights Reserved
4// See related files for license, if any is provided.
5//
6// Types for VolumeBuilder classes
7
8#ifndef VOLUMEBUILDERCONFIGS_HH
9#define VOLUMEBUILDERCONFIGS_HH
10#include <G4Colour.hh>
11#include <G4ThreeVector.hh>
12#include <G4Types.hh>
13#include <G4VisAttributes.hh>
14#include <memory>
15#include <optional>
16#include <vector>
17#include <CLHEP/Units/SystemOfUnits.h>
18
20#include "i_shared_ptr.hh"
21
22#define ONCE_MUTABLE mutable // for linkable objects
23
24namespace DLG4::VolumeBuilders {
25 class VolumeBuilderReference;
26 template <typename U>
27 class VolumeBuilder;
28 using UnitlessG4Transform3D = G4Transform3D;
29
30 // Configurations for VolumeBuilder
31 struct BooleanSolid {
35 G4ThreeVector offset{};
36 G4RotationMatrix *rotation{};
37 };
38
40 G4String name{}; // initial solid name
41 std::optional<G4double> default_unit;
43 // actually global, but it needs to live somewhere untemplated.
44 static G4double global_default_unit;
45 // Interface pointer for type erased class access (Copied in linking ctor only)
46 // Linkable<ISolidBuilder> isolid_ptr;
47 // Linkable <VolumeBuetilderReference> builder_view;
50 // an internal offset for non-centered solids:
51 G4ThreeVector internal_offset{};
52 };
53
58 inline void SetGlobalDefaultUnit(G4double unit) {
60 }
61
63 std::vector<BooleanSolid> booleans;
64 G4String boolean_name{}; //derived from name if not explicitly provided.
65 bool reflect_z{false};
66 BooleanConfigs() = default;
67 ~BooleanConfigs() = default;
68 };
69
71 // everything defeault copyable, no ctor maintenace needed:
72 G4Colour color{0.5, 0.5, 0.5, 1};
73 bool force_solid{false};
74 bool is_visible{true};
75 G4Material *material{}; //G4 takes ownership
76 G4VisAttributes vis_att{};
77 };
78
80 // the stuff with custom/deep copy
81 // std::shared_ptr<G4VisAttributes> vis_att{}; //G4 copies (when passed by value)
82 // although some items in it are pointers.
83
84 VolumeConfigs() = default;
85 ~VolumeConfigs() = default;
87 VolumeConfigs(const VolumeConfigs &other);
90 // base for copy and =
91 void copyFrom(const VolumeConfigs &other);
92 };
93
94 // Set the default value for the global default unit.
95 // (The default for the default for the default).
96 inline G4double BuilderConfigs::global_default_unit = CLHEP::mm;
97
98 // Placement parameters
100 // the hierarchical assembly elements, if any
101 std::vector<StructureView> children;
102 bool is_builder = true;
103 G4RotationMatrix rotation{}; //G4 takes ownership
104 G4ThreeVector translation = G4ThreeVector(0, 0, 0);
105 G4Transform3D transform{};
106 // for hierarchies
107 G4RotationMatrix parent_rotation{};
108 G4ThreeVector parent_translation = G4ThreeVector(0, 0, 0);
109 // total summed transformation in hierarchy
110 G4RotationMatrix total_rotation{}; //G4 takes ownership
111 G4ThreeVector total_translation = G4ThreeVector(0, 0, 0);
112 // component of name added from parent in hierarchy
113 G4String parent_name = "";
114 //G4 copies
115 BuilderView mother = nullptr; // Alternative mother source if raw is null
116 G4int copy_no = 0; // formal G4 copy_no_
117 G4int copy_count = 0; // used in placement naming if auto_copy_name == true;
118 G4bool surface_check = false;
119 G4bool auto_copyno = true;
120 G4bool auto_copy_name = false;
121
122 ~PlacementConfigs() = default;
123 };
124}
125#endif //VOLUMEBUIDERTYPES_HH
126//TODO Implement auto parent name incrementing?
A wrapper for std::shared_ptr that allows and facilitates many implicit(i) type conversions.
void SetGlobalDefaultUnit(G4double unit)
Set the default unit for all VolumeBuilder methods.
G4Transform3D UnitlessG4Transform3D
void copyFrom(const VolumeConfigs &other)
VolumeConfigs & operator=(const VolumeConfigs &other)
Operator =.