Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ArrowModel Class Reference

#include <G4ArrowModel.hh>

Inheritance diagram for G4ArrowModel:
Collaboration diagram for G4ArrowModel:

Public Member Functions

 G4ArrowModel (G4double x1, G4double y1, G4double z1, G4double x2, G4double y2, G4double z2, G4double width, const G4Colour &colour, const G4String &description="", G4int lineSegmentsPerCircle=6)
 
virtual ~G4ArrowModel ()
 
virtual void DescribeYourselfTo (G4VGraphicsScene &)
 
- Public Member Functions inherited from G4VModel
 G4VModel (const G4Transform3D &modelTransformation=G4Transform3D(), const G4ModelingParameters *=0)
 
virtual ~G4VModel ()
 
const G4ModelingParameters * GetModelingParameters () const
 
const G4String & GetType () const
 
virtual G4String GetCurrentDescription () const
 
virtual G4String GetCurrentTag () const
 
const G4VisExtent & GetExtent () const
 
const G4String & GetGlobalDescription () const
 
const G4String & GetGlobalTag () const
 
const G4Transform3D & GetTransformation () const
 
void SetModelingParameters (const G4ModelingParameters *)
 
void SetExtent (const G4VisExtent &)
 
void SetType (const G4String &)
 
void SetGlobalDescription (const G4String &)
 
void SetGlobalTag (const G4String &)
 
void SetTransformation (const G4Transform3D &)
 
virtual G4bool Validate (G4bool warn=true)
 

Additional Inherited Members

- Protected Attributes inherited from G4VModel
G4String fType
 
G4String fGlobalTag
 
G4String fGlobalDescription
 
G4VisExtent fExtent
 
G4Transform3D fTransform
 
const G4ModelingParameters * fpMP
 

Detailed Description

Definition at line 48 of file G4ArrowModel.hh.

Constructor & Destructor Documentation

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 
)

Definition at line 52 of file G4ArrowModel.cc.

57 {
58  fType = "G4ArrowModel";
59  fGlobalTag = fType;
60  fGlobalDescription = fType + ": " + description;
62  (std::min(x1,x2),
63  std::max(x1,x2),
64  std::min(y1,y2),
65  std::max(y1,y2),
66  std::min(z1,z2),
67  std::max(z1,z2));
68 
69  // Force number of line segments per circle (aka number of rotation steps)
71  G4Polyhedron::SetNumberOfRotationSteps(lineSegmentsPerCircle);
72 
73  // Make a cylinder slightly shorter than the arrow length so that it
74  // doesn't stick out of the head.
75  const G4double shaftLength = std::sqrt
76  (std::pow(x2-x1,2)+std::pow(y2-y1,2)+std::pow(z2-z1,2));
77  G4double shaftRadius = width/2.;
78  // Limit the radius
79  if (shaftRadius > shaftLength/100.) shaftRadius = shaftLength/100.;
80  const G4double halfShaftLength = shaftLength/2.;
81  const G4double halfReduction = 4.*shaftRadius;
82  const G4double halfLength = halfShaftLength-halfReduction;
83  G4Tubs shaft("shaft",0.,shaftRadius,halfLength,0.,twopi);
84  fpShaftPolyhedron = shaft.CreatePolyhedron();
85  // Move it a little so that the tail is at z = -halfShaftLength.
86  fpShaftPolyhedron->Transform(G4Translate3D(0,0,-halfReduction));
87 
88  // Locate the head at +halfShaftLength.
89  const G4int numRZ = 3;
90  G4double r[] = {0,4,0};
91  G4double z[] = {0,-6,-4};
92  for (G4int i = 0; i < numRZ; i++) {
93  r[i] *= 2.*shaftRadius;
94  z[i] = halfShaftLength + z[i] * 2.*shaftRadius;
95  }
96  G4GenericPolycone head("head",0,twopi,numRZ,r,z);
97  fpHeadPolyhedron = head.CreatePolyhedron();
98 
99  // Transform to position
100  const G4Vector3D arrowDirection = G4Vector3D(x2-x1,y2-y1,z2-z1).unit();
101  const G4double theta = arrowDirection.theta();
102  const G4double phi = arrowDirection.phi();
103  const G4Point3D arrowCentre(0.5*(x1+x2),0.5*(y1+y2),0.5*(z1+z2));
104  const G4Transform3D tr =
105  G4Translate3D(arrowCentre) * G4RotateZ3D(phi) * G4RotateY3D(theta);
106  fpShaftPolyhedron->Transform(tr);
107  fpHeadPolyhedron->Transform(tr);
108 
109  G4VisAttributes va;
110  va.SetColour(colour);
111  va.SetForceSolid(true);
112  fpShaftPolyhedron->SetVisAttributes(va);
113  fpHeadPolyhedron->SetVisAttributes(va);
114 
115  // Restore number of line segments per circle
117 }
void SetColour(const G4Colour &)
HepGeom::RotateY3D G4RotateY3D
G4String fType
Definition: G4VModel.hh:108
BasicVector3D< T > unit() const
Definition: G4Tubs.hh:85
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35
HepPolyhedron & Transform(const G4Transform3D &t)
int G4int
Definition: G4Types.hh:78
HepGeom::RotateZ3D G4RotateZ3D
void SetForceSolid(G4bool=true)
static constexpr double twopi
Definition: G4SIunits.hh:76
G4String fGlobalTag
Definition: G4VModel.hh:109
G4String fGlobalDescription
Definition: G4VModel.hh:110
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:80
static G4int GetNumberOfRotationSteps()
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
HepGeom::Translate3D G4Translate3D
static void SetNumberOfRotationSteps(G4int n)
G4VisExtent fExtent
Definition: G4VModel.hh:111
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4ArrowModel::~G4ArrowModel ( )
virtual

Definition at line 45 of file G4ArrowModel.cc.

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

Member Function Documentation

void G4ArrowModel::DescribeYourselfTo ( G4VGraphicsScene &  sceneHandler)
virtual

Implements G4VModel.

Definition at line 119 of file G4ArrowModel.cc.

120 {
121  sceneHandler.BeginPrimitives();
122  sceneHandler.AddPrimitive(*fpShaftPolyhedron);
123  sceneHandler.AddPrimitive(*fpHeadPolyhedron);
124  sceneHandler.EndPrimitives();
125 }
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual void EndPrimitives()=0

Here is the call graph for this function:

Here is the caller graph for this function:


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