13#include <G4Polycone.hh>
14#include <G4Polyhedra.hh>
34 object->MakeSolidFunctionPtr_ = &RZBuilderCore::MakePolycone;
41 auto object =
new RZBuilderCore(name, phi_start, phi_tot, sides);
42 object->MakeSolidFunctionPtr_ = &RZBuilderCore::MakePolyhedra;
47 Length unit,
const G4String &name, G4double endz, G4double h, G4double OR, G4double IR) {
50 object->MakeSolidFunctionPtr_ = &RZBuilderCore::MakePolycone;
56 object->AddPlane(plane);
58 object->AddPlane(plane);
69 RZBuilderCore::RZBuilderCore(
const G4String &name, G4double init_phi_start, G4double init_phi_tot,
72 phi_tot_deg(init_phi_tot) {
73 set_shared_from_this_enabled(
false);
75 set_shared_from_this_enabled(
true);
82 sides_(other.sides_), phi_start_deg_(other.phi_start_deg_), phi_tot_deg(other.phi_tot_deg),
83 num_planes_(other.num_planes_), z_(other.z_), IR_(other.IR_), OR_(other.OR_),
84 MakeSolidFunctionPtr_(other.MakeSolidFunctionPtr_) {
85 set_shared_from_this_enabled(
false);
87 set_shared_from_this_enabled(
true);
93 throw std::runtime_error(
"Error in RZBuilder::FillSolidConfig\"\n"
94 "Cannot fill a solid builder CONFIGURATION, when the solid is already built from it."
95 "Use ForkAndReset(\"new_name\") first to get an unbuilt copy.\n\n");
99 for (
int i = 0; i < num_planes_; i++) {
102 return this->shared_from_this();
108 throw std::runtime_error(
"Error in RZBuilder::ReflectZSolidConfig\"\n"
109 "Cannot flip a solid builder CONFIGURATION, when the solid is already built from it.\n"
110 "Use ReflectZFinalSolidCopy(\"new_name\") instead to copy and flip the solid.\n\n");
113 for (
int i = 0; i < num_planes_; i++) {
114 this->z_[i] = -this->z_[i];
116 return this->shared_from_this();
120 if (MakeSolidFunctionPtr_ == &RZBuilderCore::MakePolyhedra) {
124 "Warning in RZBuilder: Calling SetNumSides() on a builder that makes round things"
125 <<
" might be as clever as giving a balloon to a hedgehog. \n Ignoring call." <<
128 return shared_from_this();
135 if (plane.
IR < 0 || plane.
OR < 0) {
136 throw std::runtime_error(
"Error in RZBuilder::AddPlane()"
137 " for builder " + GetBuilderName() +
".\n"
138 "IR and OR must be non-negative.");
144 return shared_from_this();
148 auto plane =
RZPlane{ IR, OR, z, unit};
149 return AddPlane(plane);
155 return AddPlane(plane);
161 for (
const auto &plane : planes) {
164 return shared_from_this();
169 for (
const auto &plane : planes) {
173 return shared_from_this();
178 for (
const auto &plane : planes) {
179 auto rzplane =
RZPlane{plane.
IR, plane.OR, plane.z, unit};
182 return shared_from_this();
186 G4VSolid *RZBuilderCore::MakePolycone(
const G4String &name) {
187 if (this->solid_ptr_.get() !=
nullptr) {
188 std::string error =
"Error in MakePolycone: A solid was already built\n"
189 "You can copy and rename the builder to reset it and build again.";
190 throw std::runtime_error(error);
193 G4cout <<
"New Polycone:" << GetBuilderName() <<
" phi_start: " << phi_start_deg_ <<
194 " degrees, phi_tot: " << phi_tot_deg
195 <<
" degrees" << G4endl;
196 for (
int i = 0; i < z_.size(); i++) {
197 G4cout <<
"z: " << z_[i] <<
" IR: " << IR_[i] <<
" OR: " << OR_[i] << G4endl;
199 auto retval =
new G4Polycone(
200 name, phi_start_deg_ * CLHEP::deg, phi_tot_deg * CLHEP::deg, num_planes_, z_.data(),
206 G4VSolid *RZBuilderCore::MakePolyhedra(
const G4String &name) {
207 if (this->solid_ptr_.get() !=
nullptr) {
208 std::string error =
"Error in MakePolyhedra: A solid was already built\n"
209 "You can copy and rename the builder to reset it and build again.";
210 throw std::runtime_error(error);
213 G4cout <<
"New Polyhedra:" << GetBuilderName() <<
" with " << sides_ <<
" sides, "
214 <<
" phi_start: " << phi_start_deg_ <<
" degrees, phi_tot: " << phi_tot_deg <<
215 " degrees" << G4endl;
216 for (
int i = 0; i < z_.size(); i++) {
217 G4cout <<
"z: " << z_[i] <<
" IR: " << IR_[i] <<
" OR: " << OR_[i] << G4endl;
219 auto retval =
new G4Polyhedra(
220 name, phi_start_deg_ * CLHEP::deg, phi_tot_deg * CLHEP::deg, sides_, num_planes_,
222 IR_.data(), OR_.data());
Builder class for RZ mult-plane defined solids.
VolumeBuilder: Common functionality for volume builder classes.
G4String GetBuilderName() const
RZBuilder CreatePolyconeBuilder(const G4String &name, G4double phi_start, G4double phi_tot)
Create a builder for associated IR,OR,Z defined object.
RZBuilder CreateCylinderBuilder(Length unit, const G4String &name, G4double endz, G4double h, G4double OR, G4double IR)
Create a simple cylinder builder.
RZBuilder CreatePolyhedraBuilder(const G4String &name, int sides, G4double phi_start, G4double phi_tot)
Create a builder for associated IR,OR,Z defined object.
RZBuilder ReflectZSolidConfig()
Flip Solid Configuration.
virtual RZBuilder SetNumSides(G4double N)
Set number of sides.
RZBuilder AddPlanes(const std::vector< RZPlane > &planes)
Adds multiple RZ planes each defining one unit,IR,OR,Z set in the volume design.
RZBuilder FillSolidConfig()
Modifies a Solid CONFIGURATION to set all inner diameters (IDs) to 0.
RZBuilder AddPlane(const RZPlane &plane)
Adds a plane defining one IR,OR,Z triplet in the volume design.
_internals_::RZBuilder RZBuilder
Shared pointer to _internals_::RZBuilderCore.
DLG4::Units::Length Length
Struct for adding planes to GeantMultiPlane –DSLeonard 2024 Overloads make this not strictly needed.