Download Geant4 User's Guide for Toolkit Developers
Transcript
Extending Toolkit Functionality
G4VSolid* Clone() const
should be implemented for every solid to provide a way to clone themselves in a new object with same
specifications.
The method:
G4ThreeVector GetPointOnSurface() const
returns a random point located on the surface of the solid. Points returned should not necessarily be uniformly
distributed.
The method:
G4double GetCubicVolume()
should be implemented for every solid in order to cache the computed value (and therefore reuse it for future calls
to the method) and to eventually implement a precise computation of the solid's volume. If the method will not
be overloaded, the default implementation from the base class will be used (estimation through a Monte Carlo
algorithm) and the computed value will not be stored.
The method:
G4double GetSurfaceArea()
should be implemented for every solid in order to cache the computed value (and therefore reuse it for future calls
to the method) and to eventually implement a precise computation of the solid's surface area. If the method will
not be overloaded, the default implementation from the base class will be used (estimation through a Monte Carlo
algorithm) and the computed value will not be stored.
There are a few member functions to be defined for the purpose of visualisation. The first method is mandatory,
and the next four are not.
// Mandatory
virtual void DescribeYourselfTo (G4VGraphicsScene& scene) const = 0;
// Not mandatory
virtual G4VisExtent GetExtent() const;
virtual G4Polyhedron* CreatePolyhedron () const;
virtual G4NURBS*
CreateNURBS
() const;
virtual G4Polyhedron* GetPolyhedron
() const;
What these methods should do and how they should be implemented is described here.
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
This method is required in order to identify the solid to the graphics scene. It is used for the purposes of ``double
dispatch''. All implementations should be similar to the one for G4Box:
void G4Box::DescribeYourselfTo (G4VGraphicsScene& scene) const
{
scene.AddSolid (*this);
}
The method:
47