00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // 00028 // 00029 00030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 00031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 00032 00033 #ifndef MyElementField_h 00034 #define MyElementField_h 1 00035 00036 #include "myglobals.hh" 00037 00038 #include "G4Navigator.hh" 00039 #include "G4TransportationManager.hh" 00040 00041 #include "G4UserLimits.hh" 00042 #include "G4VisAttributes.hh" 00043 00044 // class MyElementField - interface for the EM field of one element 00045 00046 // This is the interface class used by GlobalField to compute the field 00047 // value at a given point[]. 00048 00049 // An element that represents an element with an EM field will 00050 // derive a class from this one and implement the computation for the 00051 // element. The construct() function will add the derived object into 00052 // GlobalField. 00053 00054 class MyElementField { 00055 00056 private: 00057 00058 MyElementField& operator=(const MyElementField&); 00059 00060 public: 00061 00063 MyElementField(const G4ThreeVector, G4LogicalVolume*); 00064 00066 void construct(); 00067 00069 virtual ~MyElementField() { 00070 if (aNavigator) delete aNavigator; 00071 if (boundingBox) delete boundingBox; 00072 } 00073 00074 // Get center of physical field volume 00075 G4ThreeVector getCenter(){return center;} 00076 00077 // Set center of physical field volume 00078 void setCenter(G4ThreeVector); 00079 00080 // Print Bounding Box 00081 G4double const* getBoundingBox(); 00082 00084 void setMaxStep(G4double s) { 00085 maxStep = s; 00086 userLimits->SetMaxAllowedStep(maxStep); 00087 lvolume->SetUserLimits(userLimits); 00088 } 00089 00091 G4double getMaxStep() { return maxStep; } 00092 00094 void setColor(G4String c) { 00095 color = c; 00096 lvolume->SetVisAttributes(getVisAttribute(color)); 00097 } 00098 00100 G4String getColor() { return color; } 00101 00103 static G4VisAttributes* getVisAttribute(G4String color); 00104 00111 void setGlobalPoint(const G4double point[4]) { 00112 if(minX == -DBL_MAX || minX > point[0]) minX = point[0]; 00113 if(minY == -DBL_MAX || minY > point[1]) minY = point[1]; 00114 if(minZ == -DBL_MAX || minZ > point[2]) minZ = point[2]; 00115 if(maxX == DBL_MAX || maxX < point[0]) maxX = point[0]; 00116 if(maxY == DBL_MAX || maxY < point[1]) maxY = point[1]; 00117 if(maxZ == DBL_MAX || maxZ < point[2]) maxZ = point[2]; 00118 } 00119 00122 bool isInBoundingBox(const G4double point[4]) const { 00123 if(point[2] < minZ || point[2] > maxZ) return false; 00124 if(point[0] < minX || point[0] > maxX) return false; 00125 if(point[1] < minY || point[1] > maxY) return false; 00126 return true; 00127 } 00128 00137 virtual void 00138 addFieldValue(const G4double point[4], G4double field[6]) const = 0; 00139 00140 // Get dimensions for the bounding box 00141 virtual G4double getMaxLength() = 0; 00142 virtual G4double getMaxWidth() = 0; 00143 virtual G4double getMaxHeight() = 0; 00144 00145 protected: 00146 00147 G4LogicalVolume* lvolume; 00148 00149 G4AffineTransform global2local; 00150 00151 // MyElementField(const MyElementField&); 00152 00153 private: 00154 00155 static G4Navigator* aNavigator; 00156 00157 G4String color; 00158 00159 G4ThreeVector center; 00160 G4double minX, minY, minZ, maxX, maxY,maxZ; 00161 00162 G4double maxStep; 00163 G4UserLimits* userLimits; 00164 00165 G4double* boundingBox; 00166 }; 00167 #endif