DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
ThreeVecDimensioner Class Reference

#include <VolumeBuildersUnitTypes.hh>

Collaboration diagram for ThreeVecDimensioner:
[legend]

Public Member Functions

 ThreeVecDimensioner ()=default
 
 ThreeVecDimensioner (const ThreeVecDimensioner &)=delete
 
ThreeVecDimensioneroperator= (const ThreeVecDimensioner &)=delete
 
 ThreeVecDimensioner (Length3Vec v)
 
 ThreeVecDimensioner (G4ThreeVector v, const Length &u)
 
 ThreeVecDimensioner (double x, double y, double z, const Length &u)
 
 ThreeVecDimensioner (double x, double y, double z)
 
 ThreeVecDimensioner (G4ThreeVector v)
 
G4ThreeVector apply_units (const Length dflt_unit) const
 
Length x () const
 
void x (const Length &val)
 
Length y () const
 
void y (const Length &val)
 
Length z () const
 
void z (const Length &val)
 
void CheckValue (const G4String &context) const
 
void CheckUnit (const G4String &context) const
 

Static Public Member Functions

static Length3Vec FromNative (const G4ThreeVector &v)
 
static Length3Vec FromNative (G4ThreeVector native_value)
 
static Length3Vec GetGlobalDefault ()
 

Public Attributes

double x
 
double y
 
double z
 
NativeVectorProxy Native {*this}
 
ScalableProxy< LengthInUnits {*this}
 
DefaultUnitsProxy InDefaultUnits
 

Static Public Attributes

static Length3Vec native
 

Protected Attributes

Length default_length_ {Length::native}
 
std::optional< G4ThreeVector > NativeValue_
 

Detailed Description

A 3D vector that manages unit policy for parameter passing If constructed with a unit, that's it.

If not the user has implicitly requested use of the receiver's units. The receiver is expected to call apply_unit(default) to get the reconciled result.

Stores unit, x, y, z as separate values.

Definition at line 34 of file VolumeBuildersUnitTypes.hh.

Constructor & Destructor Documentation

◆ ThreeVecDimensioner() [1/7]

ThreeVecDimensioner ( )
default

◆ ThreeVecDimensioner() [2/7]

◆ ThreeVecDimensioner() [3/7]

Definition at line 43 of file VolumeBuildersUnitTypes.hh.

44 : Length3Vec(v) { Sync(); }

◆ ThreeVecDimensioner() [4/7]

ThreeVecDimensioner ( G4ThreeVector  v,
const Length u 
)
inline

Definition at line 46 of file VolumeBuildersUnitTypes.hh.

47 : Length3Vec(v, u) { Sync(); }

◆ ThreeVecDimensioner() [5/7]

ThreeVecDimensioner ( double  x,
double  y,
double  z,
const Length u 
)
inline

◆ ThreeVecDimensioner() [6/7]

ThreeVecDimensioner ( double  x,
double  y,
double  z 
)
inline

Definition at line 52 of file VolumeBuildersUnitTypes.hh.

53 is_dimensioned_ = false;
54 Sync();
55 }

◆ ThreeVecDimensioner() [7/7]

ThreeVecDimensioner ( G4ThreeVector  v)
inline

Definition at line 57 of file VolumeBuildersUnitTypes.hh.

58 : ThreeVecDimensioner(v.x(), v.y(), v.z()) {
59 }

Member Function Documentation

◆ apply_units()

G4ThreeVector apply_units ( const Length  dflt_unit) const
inline

Definition at line 61 of file VolumeBuildersUnitTypes.hh.

61 {
62 auto vec = G4ThreeVector(x, y, z);
63 if (!is_dimensioned_) {
64 vec *= dflt_unit.Native;
65 }
66 return vec;
67 }

◆ CheckUnit()

void CheckUnit ( const G4String &  context) const
inlineinherited

Definition at line 271 of file DLG4Units.hh.

271 {
272 CheckValue(context);
273 if (!(NativeValue_ > 0.0)) {
274 G4Exception(context, "InvalidScale", FatalException,
275 "\n Attempted to apply a negative Unit\n");
276 exit(1);
277 }
278 }
void CheckValue(const G4String &context) const
Definition DLG4Units.hh:260

◆ CheckValue()

void CheckValue ( const G4String &  context) const
inlineinherited

Definition at line 260 of file DLG4Units.hh.

260 {
261 // volatile may help with debugging dangling references.
262 volatile bool engagement_flag = NativeValue_.has_value();
263 if (!engagement_flag) {
264 //if (!NativeValue_.has_value()) {
265 G4Exception(context, "InvalidScale", FatalException,
266 "\n Attempted to use a Unit (or measure) before setting it;\n");
267 exit(1);
268 }
269 }
std::optional< G4ThreeVector > NativeValue_
Definition DLG4Units.hh:98

◆ FromNative() [1/2]

static Length3Vec FromNative ( const G4ThreeVector &  v)
inlinestaticinherited

Definition at line 515 of file DLG4Units.hh.

515 {
516 return Length3Vec(v, Length::native);
517 }

◆ FromNative() [2/2]

static Length3Vec FromNative ( G4ThreeVector  native_value)
inlinestaticinherited

Definition at line 232 of file DLG4Units.hh.

232{ return T(native_value); }

◆ GetGlobalDefault()

static Length3Vec GetGlobalDefault ( )
inlinestaticinherited

Definition at line 258 of file DLG4Units.hh.

258{ return T(global_default_unit<T>); }

◆ operator=()

ThreeVecDimensioner & operator= ( const ThreeVecDimensioner )
delete

◆ x() [1/2]

Length x ( ) const
inlineinherited

Definition at line 521 of file DLG4Units.hh.

521 {
522 CheckValue("Length3Vec");
523 return Length::FromNative(NativeValue_.value().x());
524 }
static Length FromNative(G4double native_value)
Definition DLG4Units.hh:232

◆ x() [2/2]

void x ( const Length val)
inlineinherited

Definition at line 536 of file DLG4Units.hh.

536 {
537 val.CheckValue("Length3Vec, x");
538 EnsureInternalVec().setX(val.NativeValue_.value());
539 }

◆ y() [1/2]

Length y ( ) const
inlineinherited

Definition at line 526 of file DLG4Units.hh.

526 {
527 CheckValue("Length3Vec");
528 return Length::FromNative(NativeValue_.value().y());
529 }

◆ y() [2/2]

void y ( const Length val)
inlineinherited

Definition at line 541 of file DLG4Units.hh.

541 {
542 val.CheckValue("Length3Vec, x");
543 EnsureInternalVec().setY(val.NativeValue_.value());
544 }

◆ z() [1/2]

Length z ( ) const
inlineinherited

Definition at line 531 of file DLG4Units.hh.

531 {
532 CheckValue("Length3Vec");
533 return Length::FromNative(NativeValue_.value().z());
534 }

◆ z() [2/2]

void z ( const Length val)
inlineinherited

Definition at line 546 of file DLG4Units.hh.

546 {
547 val.CheckValue("Length3Vec, x");
548 EnsureInternalVec().setZ(val.NativeValue_.value());
549 }

Member Data Documentation

◆ default_length_

Length default_length_ {Length::native}
protectedinherited

Definition at line 559 of file DLG4Units.hh.

◆ InDefaultUnits

DefaultUnitsProxy InDefaultUnits
inherited

Definition at line 228 of file DLG4Units.hh.

228{*this};

◆ InUnits

ScalableProxy<Length> InUnits {*this}
inherited

Definition at line 465 of file DLG4Units.hh.

465{*this};

◆ native

Length3Vec native
inlinestaticinherited

Definition at line 231 of file DLG4Units.hh.

231{1.0};

◆ Native

NativeVectorProxy Native {*this}
inherited

Definition at line 463 of file DLG4Units.hh.

463{*this};

◆ NativeValue_

std::optional<G4ThreeVector > NativeValue_
protectedinherited

Definition at line 98 of file DLG4Units.hh.

◆ x

double x

Definition at line 36 of file VolumeBuildersUnitTypes.hh.

◆ y

double y

Definition at line 36 of file VolumeBuildersUnitTypes.hh.

◆ z

double z

Definition at line 36 of file VolumeBuildersUnitTypes.hh.


The documentation for this class was generated from the following file: