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

#include <DLG4Units.hh>

Collaboration diagram for Length3Vec:
[legend]

Public Member Functions

 Length3Vec ()
 
 Length3Vec (const Length3Vec &other)
 
 Length3Vec (Length3Vec &&other) noexcept
 
Length3Vecoperator= (const Length3Vec &other)
 
Length3Vecoperator= (Length3Vec &&other) noexcept
 
 Length3Vec (double x, double y, double z, const Length &u)
 
 Length3Vec (const G4ThreeVector &v, const Length &u)
 
Length x () const
 
Length y () const
 
Length z () const
 
void x (const Length &val)
 
void y (const Length &val)
 
void z (const Length &val)
 
 Length3Vec (const Length &x, const Length &y, const Length &z)
 
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

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 3 vector that is scalable with/to Units.

Definition at line 430 of file DLG4Units.hh.

Constructor & Destructor Documentation

◆ Length3Vec() [1/6]

Length3Vec ( )
inline

Definition at line 467 of file DLG4Units.hh.

468 : Native{*this} {
469 }
NativeVectorProxy Native
Definition DLG4Units.hh:463

◆ Length3Vec() [2/6]

Length3Vec ( const Length3Vec other)
inline

Definition at line 472 of file DLG4Units.hh.

473 : UnitBase(other),
474 Native{*this},
475 InUnits{*this},
476 default_length_(other.default_length_) {
477 }
ScalableProxy< Length > InUnits
Definition DLG4Units.hh:465

◆ Length3Vec() [3/6]

Length3Vec ( Length3Vec &&  other)
inlinenoexcept

Definition at line 480 of file DLG4Units.hh.

481 : UnitBase(std::move(other)),
482 Native{*this},
483 InUnits{*this},
484 default_length_(std::move(other.default_length_)) {
485 }

◆ Length3Vec() [4/6]

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

Definition at line 505 of file DLG4Units.hh.

505 {
506 u.CheckUnit("Length3Vec(x,y,z,u)");
507 NativeValue_ = G4ThreeVector(x, y, z) * u.NativeValue_.value();
508 }
std::optional< G4ThreeVector > NativeValue_
Definition DLG4Units.hh:98

◆ Length3Vec() [5/6]

Length3Vec ( const G4ThreeVector &  v,
const Length u 
)
inline

Definition at line 510 of file DLG4Units.hh.

510 {
511 u.CheckUnit("Length3Vec(x,y,z,u)");
512 NativeValue_ = v * u.NativeValue_.value();
513 }

◆ Length3Vec() [6/6]

Length3Vec ( const Length x,
const Length y,
const Length z 
)
inline

Definition at line 551 of file DLG4Units.hh.

551 {
552 x.CheckValue("Length3Vec");
553 y.CheckValue("Length3Vec");
554 z.CheckValue("Length3Vec");
555 NativeValue_ = G4ThreeVector(x.NativeValue_.value(), y.NativeValue_.value(), z.NativeValue_.value());
556 }
void CheckValue(const G4String &context) const
Definition DLG4Units.hh:260

Member Function Documentation

◆ 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 }

◆ 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 }

◆ FromNative() [1/2]

static Length3Vec FromNative ( const G4ThreeVector &  v)
inlinestatic

Definition at line 515 of file DLG4Units.hh.

◆ 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=() [1/2]

Length3Vec & operator= ( const Length3Vec other)
inline

Definition at line 488 of file DLG4Units.hh.

488 {
489 if (this != &other) {
490 UnitBase::operator=(other); // Safely copies the unified base NativeValue_
491 this->default_length_ = other.default_length_;
492 }
493 return *this;
494 }
UnitBase & operator=(const UnitBase &other)
Definition DLG4Units.hh:250

◆ operator=() [2/2]

Length3Vec & operator= ( Length3Vec &&  other)
inlinenoexcept

Definition at line 497 of file DLG4Units.hh.

497 {
498 if (this != &other) {
499 UnitBase::operator=(std::move(other)); // Safely moves the unified base NativeValue_
500 this->default_length_ = std::move(other.default_length_);
501 }
502 return *this;
503 }

◆ x() [1/2]

Length x ( ) const
inline

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)
inline

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
inline

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)
inline

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
inline

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)
inline

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}
protected

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}

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}

Definition at line 463 of file DLG4Units.hh.

463{*this};

◆ NativeValue_

std::optional<G4ThreeVector > NativeValue_
protectedinherited

Definition at line 98 of file DLG4Units.hh.


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