DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Public Member Functions | 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 (Unit3Vec 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
 
Unit3Vec FromNative (const G4ThreeVector &v)
 
Length x () const
 
void x (const Length &val)
 
Length y () const
 
void y (const Length &val)
 
Length z () const
 
void z (const Length &val)
 
G4ThreeVector InUnits () const
 
G4ThreeVector InUnits (const Length &u) const
 
G4ThreeVector Native () const
 

Public Attributes

double x
 
double y
 
double z
 

Protected Attributes

std::optional< G4ThreeVector > NativeVec_
 
Length default_length_
 

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 : Unit3Vec(v) { Sync(); }

◆ ThreeVecDimensioner() [4/7]

ThreeVecDimensioner ( G4ThreeVector  v,
const Length u 
)
inline

Definition at line 46 of file VolumeBuildersUnitTypes.hh.

47 : Unit3Vec(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.

52 {
53 NativeVec_ = G4ThreeVector(x, y, z);
54 is_dimensioned_ = false;
55 Sync();
56 }
std::optional< G4ThreeVector > NativeVec_
Definition DLG4Units.hh:516

◆ ThreeVecDimensioner() [7/7]

ThreeVecDimensioner ( G4ThreeVector  v)
inline

Definition at line 58 of file VolumeBuildersUnitTypes.hh.

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

Member Function Documentation

◆ apply_units()

G4ThreeVector apply_units ( const Length  dflt_unit) const
inline

Definition at line 62 of file VolumeBuildersUnitTypes.hh.

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

◆ FromNative()

Unit3Vec FromNative ( const G4ThreeVector &  v)
inlineinherited

Definition at line 479 of file DLG4Units.hh.

479 {
480 return Unit3Vec(v, Length::native);
481 }

◆ InUnits() [1/2]

G4ThreeVector InUnits ( ) const
inlineinherited

Definition at line 496 of file DLG4Units.hh.

496{ return InUnits(default_length_); }
G4ThreeVector InUnits() const
Definition DLG4Units.hh:496

◆ InUnits() [2/2]

G4ThreeVector InUnits ( const Length u) const
inlineinherited

Definition at line 498 of file DLG4Units.hh.

498 {
499 if (!NativeVec_.has_value()) {
500 G4Exception("Unit3Vec::InUnits", "Uninitialized", FatalException,
501 "Attempted to read Unit3Vec before setting it.");
502 }
503 return (*NativeVec_) / u.Native;
504 }

◆ Native()

G4ThreeVector Native ( ) const
inlineinherited

Definition at line 507 of file DLG4Units.hh.

507 {
508 if (!NativeVec_.has_value()) {
509 G4Exception("Unit3Vec::GetRaw", "Uninitialized", FatalException,
510 "Attempted to read Unit3Vec before setting it.");
511 }
512 return *NativeVec_;
513 }

◆ operator=()

ThreeVecDimensioner & operator= ( const ThreeVecDimensioner )
delete

◆ x() [1/2]

Length x ( ) const
inlineinherited

Definition at line 484 of file DLG4Units.hh.

484{ return Length::FromNative(Native().x()); }
Length x() const
Definition DLG4Units.hh:484
G4ThreeVector Native() const
Definition DLG4Units.hh:507
static Length FromNative(G4double)
Definition DLG4Units.hh:253

◆ x() [2/2]

void x ( const Length val)
inlineinherited

Definition at line 488 of file DLG4Units.hh.

488{ EnsureInternalVec().setX(val.Native); }

◆ y() [1/2]

Length y ( ) const
inlineinherited

Definition at line 485 of file DLG4Units.hh.

485{ return Length::FromNative(Native().y()); }
Length y() const
Definition DLG4Units.hh:485

◆ y() [2/2]

void y ( const Length val)
inlineinherited

Definition at line 489 of file DLG4Units.hh.

489{ EnsureInternalVec().setY(val.Native); }

◆ z() [1/2]

Length z ( ) const
inlineinherited

Definition at line 486 of file DLG4Units.hh.

486{ return Length::FromNative(Native().z()); }
Length z() const
Definition DLG4Units.hh:486

◆ z() [2/2]

void z ( const Length val)
inlineinherited

Definition at line 490 of file DLG4Units.hh.

490{ EnsureInternalVec().setZ(val.Native); }

Member Data Documentation

◆ default_length_

Length default_length_
protectedinherited

Definition at line 517 of file DLG4Units.hh.

◆ NativeVec_

std::optional<G4ThreeVector> NativeVec_
protectedinherited

Definition at line 516 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: