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

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 48 of file G4ArrowModel.cc.

References G4Polycone::CreatePolyhedron(), G4Tubs::CreatePolyhedron(), G4VisAttributes::SetColour(), and G4VisAttributes::SetForceSolid().

00052 {
00053   fType = "G4ArrowModel";
00054   fGlobalTag = fType;
00055   fGlobalDescription = fType + ": " + description;
00056   fExtent = G4VisExtent
00057     (std::min(x1,x2),
00058      std::max(x1,x2),
00059      std::min(y1,y2),
00060      std::max(y1,y2),
00061      std::min(z1,z2),
00062      std::max(z1,z2));
00063 
00064   // Make a cylinder slightly shorter than the arrow length so that it
00065   // doesn't stick out of the head.
00066   const G4double shaftLength = std::sqrt
00067     (std::pow(x2-x1,2)+std::pow(y2-y1,2)+std::pow(z2-z1,2));
00068   G4double shaftRadius = width/2.;
00069   // Limit the radius
00070   if (shaftRadius > shaftLength/100.) shaftRadius = shaftLength/100.;
00071   const G4double halfShaftLength = shaftLength/2.;
00072   const G4double halfReduction = 4.*shaftRadius;
00073   const G4double halfLength = halfShaftLength-halfReduction;
00074   G4Tubs shaft("shaft",0.,shaftRadius,halfLength,0.,twopi);
00075   fpShaftPolyhedron = shaft.CreatePolyhedron();
00076   // Move it a little so that the tail is at z = -halfShaftLength.
00077   fpShaftPolyhedron->Transform(G4Translate3D(0,0,-halfReduction));
00078 
00079   // Locate the head at +halfShaftLength.
00080   const G4int numRZ = 3;
00081   G4double r[] = {0,4,0};
00082   G4double z[] = {0,-6,-4};
00083   for (G4int i = 0; i < numRZ; i++) {
00084     r[i] *= 2.*shaftRadius;
00085     z[i] = halfShaftLength + z[i] * 2.*shaftRadius;
00086   }
00087   G4Polycone head("head",0,twopi,numRZ,r,z);
00088   fpHeadPolyhedron = head.CreatePolyhedron();
00089 
00090   // Transform to position
00091   const G4Vector3D arrowDirection = G4Vector3D(x2-x1,y2-y1,z2-z1).unit();
00092   const G4double theta = arrowDirection.theta();
00093   const G4double phi = arrowDirection.phi();
00094   const G4Point3D arrowCentre(0.5*(x1+x2),0.5*(y1+y2),0.5*(z1+z2));
00095   const G4Transform3D tr =
00096     G4Translate3D(arrowCentre) * G4RotateZ3D(phi) * G4RotateY3D(theta);
00097   fpShaftPolyhedron->Transform(tr);
00098   fpHeadPolyhedron->Transform(tr);
00099 
00100   G4VisAttributes va;
00101   va.SetColour(colour);
00102   va.SetForceSolid(true);
00103   fpShaftPolyhedron->SetVisAttributes(va);
00104   fpHeadPolyhedron->SetVisAttributes(va);
00105 }

G4ArrowModel::~G4ArrowModel (  )  [virtual]

Definition at line 45 of file G4ArrowModel.cc.

00045 {}


Member Function Documentation

void G4ArrowModel::DescribeYourselfTo ( G4VGraphicsScene  )  [virtual]

Implements G4VModel.

Definition at line 107 of file G4ArrowModel.cc.

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

00108 {
00109   sceneHandler.BeginPrimitives();
00110   sceneHandler.AddPrimitive(*fpShaftPolyhedron);
00111   sceneHandler.AddPrimitive(*fpHeadPolyhedron);
00112   sceneHandler.EndPrimitives();
00113 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:51:28 2013 for Geant4 by  doxygen 1.4.7