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>
18//#include <CLHEP/Units/SystemOfUnits.h>
19
21#include "i_shared_ptr.hh"
22
23#define ONCE_MUTABLE mutable // for linkable objects
24
26 class VolumeBuilderCore;
27 template <typename U>
28 class VolumeBuilderBase;
29 using UnitlessG4Transform3D = G4Transform3D;
30
31 // Configurations for VolumeBuilder
32 struct BooleanSolid {
36 G4ThreeVector offset{};
37 G4RotationMatrix *rotation{};
38 };
39
40
42 G4String name{}; // initial solid name
43 std::optional<G4double> 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
54
56 std::vector<BooleanSolid> booleans;
57 G4String boolean_name{}; //derived from name if not explicitly provided.
58 bool reflect_z{false};
59 BooleanConfigs() = default;
60 ~BooleanConfigs() = default;
61 };
62
64 // everything defeault copyable, no ctor maintenace needed:
65 G4Colour color{0.5, 0.5, 0.5, 1};
66 bool force_solid{false};
67 bool is_visible{true};
68 G4Material *material{}; //G4 takes ownership
69 G4VisAttributes vis_att{};
70 };
71
73 // the stuff with custom/deep copy
74 // std::shared_ptr<G4VisAttributes> vis_att{}; //G4 copies (when passed by value)
75 // although some items in it are pointers.
76
77 VolumeConfigs() = default;
78 ~VolumeConfigs() = default;
80 VolumeConfigs(const VolumeConfigs &other);
83 // base for copy and =
84 void copyFrom(const VolumeConfigs &other);
85 };
86
87
88 // Placement parameters
90 // the hierarchical assembly elements, if any
91 std::vector<StructureBuilder> children;
92 bool is_builder = true;
93 G4RotationMatrix rotation{}; //G4 takes ownership
94 G4ThreeVector translation = G4ThreeVector(0, 0, 0);
95 G4Transform3D transform{};
96 // for hierarchies
97 G4RotationMatrix parent_rotation{};
98 G4ThreeVector parent_translation = G4ThreeVector(0, 0, 0);
99 // total summed transformation in hierarchy
100 G4RotationMatrix total_rotation{}; //G4 takes ownership
101 G4ThreeVector total_translation = G4ThreeVector(0, 0, 0);
102 // component of name added from parent in hierarchy
103 G4String parent_name = "";
104 //G4 copies
105 VolumeBuilder mother = nullptr; // Alternative mother source if raw is null
106 G4int copy_no = 0; // formal G4 copy_no_
107 G4int copy_count = 0; // used in placement naming if auto_copy_name == true;
108 G4bool surface_check = false;
109 G4bool auto_copyno = true;
110 G4bool auto_copy_name = false;
111
112 ~PlacementConfigs() = default;
113 };
114}
115
116#endif //VOLUMEBUIDERTYPES_HH
117//TODO Implement auto parent name incrementing?
VolumeConfigs & operator=(const VolumeConfigs &other)
Operator =.