Geant4-11
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4ArrowModel Class Reference

#include <G4ArrowModel.hh>

Inheritance diagram for G4ArrowModel:
G4VModel

Public Member Functions

void DescribeYourselfTo (G4VGraphicsScene &) override
 
 G4ArrowModel (G4double x1, G4double y1, G4double z1, G4double x2, G4double y2, G4double z2, G4double width, const G4Colour &colour, const G4String &description="", G4int lineSegmentsPerCircle=6, const G4Transform3D &transform=G4Transform3D())
 
virtual G4String GetCurrentDescription () const
 
virtual G4String GetCurrentTag () const
 
const G4VisExtentGetExtent () const
 
const G4StringGetGlobalDescription () const
 
const G4StringGetGlobalTag () const
 
const G4ModelingParametersGetModelingParameters () const
 
const G4StringGetType () const
 
void SetExtent (const G4VisExtent &)
 
void SetGlobalDescription (const G4String &)
 
void SetGlobalTag (const G4String &)
 
void SetModelingParameters (const G4ModelingParameters *)
 
void SetType (const G4String &)
 
virtual G4bool Validate (G4bool warn=true)
 
virtual ~G4ArrowModel ()
 

Protected Attributes

G4VisExtent fExtent
 
G4String fGlobalDescription
 
G4String fGlobalTag
 
const G4ModelingParametersfpMP
 
G4String fType
 

Private Member Functions

 G4ArrowModel (const G4ArrowModel &)
 
G4ArrowModeloperator= (const G4ArrowModel &)
 

Private Attributes

G4PolyhedronfpHeadPolyhedron
 
G4PolyhedronfpShaftPolyhedron
 
G4Transform3D fTransform
 

Detailed Description

Definition at line 47 of file G4ArrowModel.hh.

Constructor & Destructor Documentation

◆ G4ArrowModel() [1/2]

G4ArrowModel::G4ArrowModel ( G4double  x1,
G4double  y1,
G4double  z1,
G4double  x2,
G4double  y2,
G4double  z2,
G4double  width,
const G4Colour colour,
const G4String description = "",
G4int  lineSegmentsPerCircle = 6,
const G4Transform3D transform = G4Transform3D() 
)

Definition at line 51 of file G4ArrowModel.cc.

58: fpShaftPolyhedron(nullptr)
59, fpHeadPolyhedron(nullptr)
61{
62 fType = "G4ArrowModel";
64 fGlobalDescription = fType + ": " + description;
66 (std::min(x1,x2),
67 std::max(x1,x2),
68 std::min(y1,y2),
69 std::max(y1,y2),
70 std::min(z1,z2),
71 std::max(z1,z2));
72
73 // Force number of line segments per circle (aka number of rotation steps)
75 G4Polyhedron::SetNumberOfRotationSteps(lineSegmentsPerCircle);
76
77 // Make a cylinder slightly shorter than the arrow length so that it
78 // doesn't stick out of the head.
80 G4double shaftLength = std::sqrt
81 (std::pow(x2-x1,2)+std::pow(y2-y1,2)+std::pow(z2-z1,2));
82 if (shaftLength < tolerance) shaftLength = tolerance;
83 G4double shaftRadius = width/2.;
84 if (shaftRadius > shaftLength/100.) shaftRadius = shaftLength/100.;
85 if (shaftRadius < tolerance) shaftRadius = tolerance;
86 const G4double halfShaftLength = shaftLength/2.;
87 const G4double halfReduction = 4.*shaftRadius;
88 G4double halfLength = halfShaftLength - halfReduction;
89 if (halfLength < tolerance) halfLength = tolerance;
90 const G4Tubs shaft("shaft",0.,shaftRadius,halfLength,0.,twopi);
91 fpShaftPolyhedron = shaft.CreatePolyhedron();
92 // Move it a little so that the tail is at z = -halfShaftLength.
94 fpShaftPolyhedron->Transform(G4Translate3D(0,0,-halfReduction));
95
96 // Locate the head at +halfShaftLength.
97 const G4double zHi = halfShaftLength;
98 const G4double zLow = halfShaftLength - 12.*shaftRadius;
99 const G4double rExt = 8. * shaftRadius;
100 const G4double xExt = std::sqrt(3.)*rExt/2.;
101 const G4Tet head("head",
102 G4ThreeVector(0.,0.,zHi),
103 G4ThreeVector(0.,rExt,zLow),
104 G4ThreeVector(xExt,-rExt/2.,zLow),
105 G4ThreeVector(-xExt,-rExt/2.,zLow));
106 fpHeadPolyhedron = head.CreatePolyhedron();
107
108 // Transform to position
109 const G4Vector3D arrowDirection = G4Vector3D(x2-x1,y2-y1,z2-z1).unit();
110 const G4double theta = arrowDirection.theta();
111 const G4double phi = arrowDirection.phi();
112 const G4Point3D arrowCentre(0.5*(x1+x2),0.5*(y1+y2),0.5*(z1+z2));
113 const G4Transform3D tr =
114 G4Translate3D(arrowCentre) * G4RotateZ3D(phi) * G4RotateY3D(theta);
117
119 va.SetColour(colour);
120 va.SetForceSolid(true);
123
124 // Restore number of line segments per circle
126}
static constexpr double twopi
Definition: G4SIunits.hh:56
CLHEP::Hep3Vector G4ThreeVector
HepGeom::RotateZ3D G4RotateZ3D
HepGeom::Translate3D G4Translate3D
HepGeom::RotateY3D G4RotateY3D
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:34
G4Transform3D fTransform
Definition: G4ArrowModel.hh:71
G4Polyhedron * fpShaftPolyhedron
Definition: G4ArrowModel.hh:69
G4Polyhedron * fpHeadPolyhedron
Definition: G4ArrowModel.hh:70
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
Definition: G4Tet.hh:56
Definition: G4Tubs.hh:75
G4VisExtent fExtent
Definition: G4VModel.hh:101
G4String fGlobalDescription
Definition: G4VModel.hh:100
G4String fType
Definition: G4VModel.hh:98
G4String fGlobalTag
Definition: G4VModel.hh:99
void SetColour(const G4Colour &)
void SetForceSolid(G4bool=true)
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:96
BasicVector3D< T > unit() const
static void SetNumberOfRotationSteps(G4int n)
static G4int GetNumberOfRotationSteps()
HepPolyhedron & Transform(const G4Transform3D &t)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4bool transform(G4String &input, const G4String &type)

References G4Tubs::CreatePolyhedron(), G4Tet::CreatePolyhedron(), G4VModel::fExtent, G4VModel::fGlobalDescription, G4VModel::fGlobalTag, fpHeadPolyhedron, fpShaftPolyhedron, G4VModel::fType, G4GeometryTolerance::GetInstance(), HepPolyhedron::GetNumberOfRotationSteps(), G4GeometryTolerance::GetRadialTolerance(), G4INCL::Math::max(), G4INCL::Math::min(), HepGeom::BasicVector3D< T >::phi(), G4VisAttributes::SetColour(), G4VisAttributes::SetForceSolid(), HepPolyhedron::SetNumberOfRotationSteps(), G4Visible::SetVisAttributes(), HepGeom::BasicVector3D< T >::theta(), HepPolyhedron::Transform(), twopi, and HepGeom::BasicVector3D< T >::unit().

◆ ~G4ArrowModel()

G4ArrowModel::~G4ArrowModel ( )
virtual

Definition at line 45 of file G4ArrowModel.cc.

46{
47 delete fpHeadPolyhedron;
48 delete fpShaftPolyhedron;
49}

References fpHeadPolyhedron, and fpShaftPolyhedron.

◆ G4ArrowModel() [2/2]

G4ArrowModel::G4ArrowModel ( const G4ArrowModel )
private

Member Function Documentation

◆ DescribeYourselfTo()

void G4ArrowModel::DescribeYourselfTo ( G4VGraphicsScene sceneHandler)
overridevirtual

Implements G4VModel.

Definition at line 128 of file G4ArrowModel.cc.

129{
131 sceneHandler.BeginPrimitives(fTransform);
132 sceneHandler.AddPrimitive(*fpShaftPolyhedron);
133 sceneHandler.AddPrimitive(*fpHeadPolyhedron);
134 sceneHandler.EndPrimitives();
135 }
136}
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual void EndPrimitives()=0

References G4VGraphicsScene::AddPrimitive(), G4VGraphicsScene::BeginPrimitives(), G4VGraphicsScene::EndPrimitives(), fpHeadPolyhedron, fpShaftPolyhedron, and fTransform.

Referenced by G4VFieldModel::DescribeYourselfTo().

◆ GetCurrentDescription()

G4String G4VModel::GetCurrentDescription ( ) const
virtualinherited

Reimplemented in G4GPSModel, and G4PhysicalVolumeModel.

Definition at line 51 of file G4VModel.cc.

51 {
52 // Override in concrete class if concept of "current" is meaningful.
53 return fGlobalDescription;
54}

References G4VModel::fGlobalDescription.

Referenced by G4OpenGLStoredQtSceneHandler::ExtraPOProcessing().

◆ GetCurrentTag()

G4String G4VModel::GetCurrentTag ( ) const
virtualinherited

Reimplemented in G4GPSModel, and G4PhysicalVolumeModel.

Definition at line 46 of file G4VModel.cc.

46 {
47 // Override in concrete class if concept of "current" is meaningful.
48 return fGlobalTag;
49}

References G4VModel::fGlobalTag.

Referenced by G4Qt3DSceneHandler::AddPrimitive(), and G4ToolsSGSceneHandler::AddPrimitive().

◆ GetExtent()

const G4VisExtent & G4VModel::GetExtent ( ) const
inherited

◆ GetGlobalDescription()

const G4String & G4VModel::GetGlobalDescription ( ) const
inherited

◆ GetGlobalTag()

const G4String & G4VModel::GetGlobalTag ( ) const
inherited

◆ GetModelingParameters()

const G4ModelingParameters * G4VModel::GetModelingParameters ( ) const
inherited

◆ GetType()

const G4String & G4VModel::GetType ( ) const
inherited

◆ operator=()

G4ArrowModel & G4ArrowModel::operator= ( const G4ArrowModel )
private

◆ SetExtent()

void G4VModel::SetExtent ( const G4VisExtent )
inherited

◆ SetGlobalDescription()

void G4VModel::SetGlobalDescription ( const G4String )
inherited

◆ SetGlobalTag()

void G4VModel::SetGlobalTag ( const G4String )
inherited

◆ SetModelingParameters()

void G4VModel::SetModelingParameters ( const G4ModelingParameters )
inherited

◆ SetType()

void G4VModel::SetType ( const G4String )
inherited

◆ Validate()

G4bool G4VModel::Validate ( G4bool  warn = true)
virtualinherited

Reimplemented in G4PhysicalVolumeModel, and G4LogicalVolumeModel.

Definition at line 56 of file G4VModel.cc.

56 {
57 return true;
58}

Field Documentation

◆ fExtent

G4VisExtent G4VModel::fExtent
protectedinherited

◆ fGlobalDescription

G4String G4VModel::fGlobalDescription
protectedinherited

◆ fGlobalTag

G4String G4VModel::fGlobalTag
protectedinherited

◆ fpHeadPolyhedron

G4Polyhedron* G4ArrowModel::fpHeadPolyhedron
private

Definition at line 70 of file G4ArrowModel.hh.

Referenced by DescribeYourselfTo(), G4ArrowModel(), and ~G4ArrowModel().

◆ fpMP

const G4ModelingParameters* G4VModel::fpMP
protectedinherited

◆ fpShaftPolyhedron

G4Polyhedron* G4ArrowModel::fpShaftPolyhedron
private

Definition at line 69 of file G4ArrowModel.hh.

Referenced by DescribeYourselfTo(), G4ArrowModel(), and ~G4ArrowModel().

◆ fTransform

G4Transform3D G4ArrowModel::fTransform
private

Definition at line 71 of file G4ArrowModel.hh.

Referenced by DescribeYourselfTo().

◆ fType

G4String G4VModel::fType
protectedinherited

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