[834] | 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 | // $Id: G4ModelingParameters.cc,v 1.15 2006/11/14 14:42:08 allison Exp $ |
---|
[954] | 28 | // GEANT4 tag $Name: $ |
---|
[834] | 29 | // |
---|
| 30 | // |
---|
| 31 | // John Allison 31st December 1997. |
---|
| 32 | // Parameters associated with the modeling of GEANT4 objects. |
---|
| 33 | |
---|
| 34 | #include "G4ModelingParameters.hh" |
---|
| 35 | |
---|
| 36 | #include "G4ios.hh" |
---|
| 37 | #include "G4VisAttributes.hh" |
---|
| 38 | #include "G4ExceptionSeverity.hh" |
---|
| 39 | #include "G4Polyhedron.hh" |
---|
| 40 | |
---|
| 41 | G4ModelingParameters::G4ModelingParameters (): |
---|
| 42 | fWarning (true), |
---|
| 43 | fpDefaultVisAttributes (0), |
---|
| 44 | fDrawingStyle (wf), |
---|
| 45 | fCulling (false), |
---|
| 46 | fCullInvisible (false), |
---|
| 47 | fDensityCulling (false), |
---|
| 48 | fVisibleDensity (0.01 * g / cm3), |
---|
| 49 | fCullCovered (false), |
---|
| 50 | fExplodeFactor (1.), |
---|
| 51 | fNoOfSides (24), |
---|
| 52 | fpSectionPolyhedron (0), |
---|
| 53 | fpCutawayPolyhedron (0), |
---|
| 54 | fpEvent (0) |
---|
| 55 | {} |
---|
| 56 | |
---|
| 57 | G4ModelingParameters::G4ModelingParameters |
---|
| 58 | (const G4VisAttributes* pDefaultVisAttributes, |
---|
| 59 | G4ModelingParameters::DrawingStyle drawingStyle, |
---|
| 60 | G4bool isCulling, |
---|
| 61 | G4bool isCullingInvisible, |
---|
| 62 | G4bool isDensityCulling, |
---|
| 63 | G4double visibleDensity, |
---|
| 64 | G4bool isCullingCovered, |
---|
| 65 | G4int noOfSides |
---|
| 66 | ): |
---|
| 67 | fWarning (true), |
---|
| 68 | fpDefaultVisAttributes (pDefaultVisAttributes), |
---|
| 69 | fDrawingStyle (drawingStyle), |
---|
| 70 | fCulling (isCulling), |
---|
| 71 | fCullInvisible (isCullingInvisible), |
---|
| 72 | fDensityCulling (isDensityCulling), |
---|
| 73 | fVisibleDensity (visibleDensity), |
---|
| 74 | fCullCovered (isCullingCovered), |
---|
| 75 | fExplodeFactor (1.), |
---|
| 76 | fNoOfSides (noOfSides), |
---|
| 77 | fpSectionPolyhedron (0), |
---|
| 78 | fpCutawayPolyhedron (0), |
---|
| 79 | fpEvent (0) |
---|
| 80 | {} |
---|
| 81 | |
---|
| 82 | G4ModelingParameters::~G4ModelingParameters () |
---|
| 83 | { |
---|
| 84 | delete fpSectionPolyhedron; |
---|
| 85 | delete fpCutawayPolyhedron; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | void G4ModelingParameters::SetVisibleDensity (G4double visibleDensity) { |
---|
| 89 | const G4double reasonableMaximum = 10.0 * g / cm3; |
---|
| 90 | if (visibleDensity < 0 && fWarning) { |
---|
| 91 | G4cout << "G4ModelingParameters::SetVisibleDensity: attempt to set negative " |
---|
| 92 | "density - ignored." << G4endl; |
---|
| 93 | } |
---|
| 94 | else { |
---|
| 95 | if (fVisibleDensity > reasonableMaximum && fWarning) { |
---|
| 96 | G4cout << "G4ModelingParameters::SetVisibleDensity: density > " |
---|
| 97 | << reasonableMaximum |
---|
| 98 | << " g / cm3 - did you mean this?" |
---|
| 99 | << G4endl; |
---|
| 100 | } |
---|
| 101 | fVisibleDensity = visibleDensity; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | G4int G4ModelingParameters::SetNoOfSides (G4int nSides) { |
---|
| 106 | const G4int nSidesMin = 12; |
---|
| 107 | if (nSides < nSidesMin) { |
---|
| 108 | nSides = nSidesMin; |
---|
| 109 | if (fWarning) |
---|
| 110 | G4cout << "G4ModelingParameters::SetNoOfSides: attempt to set the" |
---|
| 111 | "\nnumber of sides per circle < " << nSidesMin |
---|
| 112 | << "; forced to" << nSides << G4endl; |
---|
| 113 | } |
---|
| 114 | fNoOfSides = nSides; |
---|
| 115 | return fNoOfSides; |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | std::ostream& operator << (std::ostream& os, const G4ModelingParameters& mp) |
---|
| 119 | { |
---|
| 120 | os << "Modeling parameters (warning "; |
---|
| 121 | if (mp.fWarning) os << "true"; |
---|
| 122 | else os << "false"; |
---|
| 123 | os << "):"; |
---|
| 124 | |
---|
| 125 | const G4VisAttributes* va = mp.fpDefaultVisAttributes; |
---|
| 126 | os << "\n Default vis. attributes: "; |
---|
| 127 | if (va) os << *va; |
---|
| 128 | else os << "none"; |
---|
| 129 | |
---|
| 130 | os << "\n Current requested drawing style: "; |
---|
| 131 | switch (mp.fDrawingStyle) { |
---|
| 132 | case G4ModelingParameters::wf: |
---|
| 133 | os << "wireframe"; break; |
---|
| 134 | case G4ModelingParameters::hlr: |
---|
| 135 | os << "hidden line removal (hlr)"; break; |
---|
| 136 | case G4ModelingParameters::hsr: |
---|
| 137 | os << "surface (hsr)"; break; |
---|
| 138 | case G4ModelingParameters::hlhsr: |
---|
| 139 | os << "surface and edges (hlhsr)"; break; |
---|
| 140 | default: os << "unrecognised"; break; |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | os << "\n Culling: "; |
---|
| 144 | if (mp.fCulling) os << "on"; |
---|
| 145 | else os << "off"; |
---|
| 146 | |
---|
| 147 | os << "\n Culling invisible objects: "; |
---|
| 148 | if (mp.fCullInvisible) os << "on"; |
---|
| 149 | else os << "off"; |
---|
| 150 | |
---|
| 151 | os << "\n Density culling: "; |
---|
| 152 | if (mp.fDensityCulling) { |
---|
| 153 | os << "on - invisible if density less than " |
---|
| 154 | << mp.fVisibleDensity / (1. * g / cm3) << " g cm^-3"; |
---|
| 155 | } |
---|
| 156 | else os << "off"; |
---|
| 157 | |
---|
| 158 | os << "\n Culling daughters covered by opaque mothers: "; |
---|
| 159 | if (mp.fCullCovered) os << "on"; |
---|
| 160 | else os << "off"; |
---|
| 161 | |
---|
| 162 | os << "\n Explode factor: " << mp.fExplodeFactor |
---|
| 163 | << " about centre: " << mp.fExplodeCentre; |
---|
| 164 | |
---|
| 165 | os << "\n No. of sides used in circle polygon approximation: " |
---|
| 166 | << mp.fNoOfSides; |
---|
| 167 | |
---|
| 168 | os << "\n Section (DCUT) polyhedron pointer: "; |
---|
| 169 | if (!mp.fpSectionPolyhedron) os << "non-"; |
---|
| 170 | os << "null"; |
---|
| 171 | |
---|
| 172 | os << "\n Cutaway (DCUT) polyhedron pointer: "; |
---|
| 173 | if (!mp.fpCutawayPolyhedron) os << "non-"; |
---|
| 174 | os << "null"; |
---|
| 175 | |
---|
| 176 | os << "\n Event pointer: " << mp.fpEvent; |
---|
| 177 | |
---|
| 178 | return os; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | G4bool G4ModelingParameters::operator != |
---|
| 182 | (const G4ModelingParameters& mp) const { |
---|
| 183 | |
---|
| 184 | if ( |
---|
| 185 | (fWarning != mp.fWarning) || |
---|
| 186 | (*fpDefaultVisAttributes != *mp.fpDefaultVisAttributes) || |
---|
| 187 | (fCulling != mp.fCulling) || |
---|
| 188 | (fCullInvisible != mp.fCullInvisible) || |
---|
| 189 | (fDensityCulling != mp.fDensityCulling) || |
---|
| 190 | (fCullCovered != mp.fCullCovered) || |
---|
| 191 | (fExplodeFactor != mp.fExplodeFactor) || |
---|
| 192 | (fExplodeCentre != mp.fExplodeCentre) || |
---|
| 193 | (fNoOfSides != mp.fNoOfSides) || |
---|
| 194 | (fpSectionPolyhedron != mp.fpSectionPolyhedron) || |
---|
| 195 | (fpCutawayPolyhedron != mp.fpCutawayPolyhedron) || |
---|
| 196 | (fpEvent != mp.fpEvent) |
---|
| 197 | ) |
---|
| 198 | return true; |
---|
| 199 | |
---|
| 200 | if (fDensityCulling && |
---|
| 201 | (fVisibleDensity != mp.fVisibleDensity)) return true; |
---|
| 202 | |
---|
| 203 | return false; |
---|
| 204 | } |
---|