source: trunk/examples/extended/field/field04/include/F04ElementField.hh @ 1292

Last change on this file since 1292 was 807, checked in by garnier, 16 years ago

update

File size: 5.6 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27//
28//
29
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
32
33#ifndef F04ElementField_h
34#define F04ElementField_h 1
35
36#include "globals.hh"
37
38#include "G4Navigator.hh"
39#include "G4TransportationManager.hh"
40
41#include "G4UserLimits.hh"
42#include "G4VisAttributes.hh"
43
44//  class F04ElementField - interface for the EM field of one element
45
46//  This is the interface class used by GlobalField to compute the field
47//  value at a given point[].
48
49//  An element that represents an element with an EM field will
50//  derive a class from this one and implement the computation for the
51//  element. The construct() function will add the derived object into
52//  GlobalField.
53
54class F04ElementField 
55{
56
57  private:
58
59    F04ElementField& operator=(const F04ElementField&);
60
61  public:
62
63    ///  Constructor.
64    F04ElementField(const G4ThreeVector, G4LogicalVolume*);
65
66    /// the actual implementation constructs the F04ElementField
67    void construct();
68
69    ///  Destructor.
70    virtual ~F04ElementField() { if (aNavigator) delete aNavigator; }
71
72    /// setMaxStep(G4double) sets the max. step size
73    void setMaxStep(G4double s)
74    {
75      maxStep = s;
76      userLimits->SetMaxAllowedStep(maxStep);
77      lvolume->SetUserLimits(userLimits);
78    }
79
80    /// getMaxStep() returns the max. step size
81    G4double getMaxStep() { return maxStep; }
82
83    /// setColor(G4String) sets the color
84    void setColor(G4String c)
85    { 
86      color = c;
87      lvolume->SetVisAttributes(getVisAttribute(color));
88    }
89
90    /// getColor() returns the color
91    G4String getColor() { return color; }
92
93    ///  getVisAttribute() returns the appropriate G4VisAttributes.
94    static G4VisAttributes* getVisAttribute(G4String color);
95
96    ///  setGlobalPoint() ensures that the point is within the global
97    ///  bounding box of this ElementField's global coordinates.
98    ///  Normally called 8 times for the corners of the local bounding
99    ///  box, after a local->global coordinate transform.
100    ///  If never called, the global bounding box is infinite.
101    ///  BEWARE: if called only once, the bounding box is just a point.
102    void setGlobalPoint(const G4double point[4])
103    {
104      if(minX == -DBL_MAX || minX > point[0]) minX = point[0];
105      if(minY == -DBL_MAX || minY > point[1]) minY = point[1];
106      if(minZ == -DBL_MAX || minZ > point[2]) minZ = point[2];
107      if(maxX ==  DBL_MAX || maxX < point[0]) maxX = point[0];
108      if(maxY ==  DBL_MAX || maxY < point[1]) maxY = point[1];
109      if(maxZ ==  DBL_MAX || maxZ < point[2]) maxZ = point[2];
110    }
111
112    ///  isInBoundingBox() returns true if the point is within the
113    ///  global bounding box - global coordinates.
114    bool isInBoundingBox(const G4double point[4]) const
115    {
116      if(point[2] < minZ || point[2] > maxZ) return false;
117      if(point[0] < minX || point[0] > maxX) return false;
118      if(point[1] < minY || point[1] > maxY) return false;
119      return true;
120    }
121
122    ///  addFieldValue() will add the field value for this element to field[].
123    ///  Implementations must be sure to verify that point[] is within
124    ///  the field region, and do nothing if not.
125    ///  point[] is in global coordinates and geant4 units; x,y,z,t.
126    ///  field[] is in geant4 units; Bx,By,Bz,Ex,Ey,Ez.
127    ///  For efficiency, the caller may (but need not) call
128    ///  isInBoundingBox(point), and only call this function if that
129    ///  returns true.
130    virtual void 
131        addFieldValue(const G4double point[4], G4double field[6]) const = 0;
132
133    virtual G4double getLength() = 0;
134    virtual G4double getWidth()  = 0;
135    virtual G4double getHeight() = 0;
136
137  protected:
138
139    G4LogicalVolume* lvolume;
140
141    G4AffineTransform global2local;
142
143//    F04ElementField(const F04ElementField&);
144
145  private:
146
147    static G4Navigator* aNavigator;
148
149    G4String color;
150
151    G4ThreeVector center;
152    G4double minX, minY, minZ, maxX, maxY,maxZ;
153
154    G4double maxStep;
155    G4UserLimits* userLimits;
156
157};
158
159#endif
Note: See TracBrowser for help on using the repository browser.