Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4ArrowModel Class Reference

#include <G4ArrowModel.hh>

Inheritance diagram for G4ArrowModel:
G4VModel

Public Member Functions

 G4ArrowModel (G4double x1, G4double y1, G4double z1, G4double x2, G4double y2, G4double z2, G4double width, const G4Colour &colour, const G4String &description="")
 
virtual ~G4ArrowModel ()
 
virtual void DescribeYourselfTo (G4VGraphicsScene &)
 
- Public Member Functions inherited from G4VModel
 G4VModel (const G4Transform3D &modelTransformation=G4Transform3D(), const G4ModelingParameters *=0)
 
virtual ~G4VModel ()
 
const G4ModelingParametersGetModelingParameters () const
 
const G4StringGetType () const
 
virtual G4String GetCurrentDescription () const
 
virtual G4String GetCurrentTag () const
 
const G4VisExtentGetExtent () const
 
const G4StringGetGlobalDescription () const
 
const G4StringGetGlobalTag () const
 
const G4Transform3DGetTransformation () 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 G4ModelingParametersfpMP
 

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 = "" 
)

Definition at line 52 of file G4ArrowModel.cc.

References G4GenericPolycone::CreatePolyhedron(), G4Tubs::CreatePolyhedron(), G4INCL::Math::max(), G4INCL::Math::min(), HepGeom::BasicVector3D< T >::phi(), G4VisAttributes::SetColour(), G4VisAttributes::SetForceSolid(), HepGeom::BasicVector3D< T >::theta(), HepPolyhedron::Transform(), python.hepunit::twopi, HepGeom::BasicVector3D< T >::unit(), and z.

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

References G4VGraphicsScene::AddPrimitive(), G4VGraphicsScene::BeginPrimitives(), and G4VGraphicsScene::EndPrimitives().

Referenced by G4MagneticFieldModel::DescribeYourselfTo().

112 {
113  sceneHandler.BeginPrimitives();
114  sceneHandler.AddPrimitive(*fpShaftPolyhedron);
115  sceneHandler.AddPrimitive(*fpHeadPolyhedron);
116  sceneHandler.EndPrimitives();
117 }
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual void EndPrimitives()=0

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