source: trunk/source/visualization/modeling/src/G4ModelingParameters.cc@ 1270

Last change on this file since 1270 was 1258, checked in by garnier, 16 years ago

cvs update

File size: 7.1 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// $Id: G4ModelingParameters.cc,v 1.16 2010/05/11 11:13:35 allison Exp $
28// GEANT4 tag $Name: $
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 "G4VSolid.hh"
40
41G4ModelingParameters::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 fpSectionSolid (0),
53 fpCutawaySolid (0),
54 fpEvent (0)
55{}
56
57G4ModelingParameters::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 fpSectionSolid (0),
78 fpCutawaySolid (0),
79 fpEvent (0)
80{}
81
82G4ModelingParameters::~G4ModelingParameters ()
83{
84 delete fpSectionSolid;
85 delete fpCutawaySolid;
86}
87
88void 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
105G4int 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
118void G4ModelingParameters::SetSectionSolid
119(G4VSolid* pSectionSolid) {
120 delete fpSectionSolid;
121 fpSectionSolid = pSectionSolid;
122}
123
124void G4ModelingParameters::SetCutawaySolid
125(G4VSolid* pCutawaySolid) {
126 delete fpCutawaySolid;
127 fpCutawaySolid = pCutawaySolid;
128}
129
130std::ostream& operator << (std::ostream& os, const G4ModelingParameters& mp)
131{
132 os << "Modeling parameters (warning ";
133 if (mp.fWarning) os << "true";
134 else os << "false";
135 os << "):";
136
137 const G4VisAttributes* va = mp.fpDefaultVisAttributes;
138 os << "\n Default vis. attributes: ";
139 if (va) os << *va;
140 else os << "none";
141
142 os << "\n Current requested drawing style: ";
143 switch (mp.fDrawingStyle) {
144 case G4ModelingParameters::wf:
145 os << "wireframe"; break;
146 case G4ModelingParameters::hlr:
147 os << "hidden line removal (hlr)"; break;
148 case G4ModelingParameters::hsr:
149 os << "surface (hsr)"; break;
150 case G4ModelingParameters::hlhsr:
151 os << "surface and edges (hlhsr)"; break;
152 default: os << "unrecognised"; break;
153 }
154
155 os << "\n Culling: ";
156 if (mp.fCulling) os << "on";
157 else os << "off";
158
159 os << "\n Culling invisible objects: ";
160 if (mp.fCullInvisible) os << "on";
161 else os << "off";
162
163 os << "\n Density culling: ";
164 if (mp.fDensityCulling) {
165 os << "on - invisible if density less than "
166 << mp.fVisibleDensity / (1. * g / cm3) << " g cm^-3";
167 }
168 else os << "off";
169
170 os << "\n Culling daughters covered by opaque mothers: ";
171 if (mp.fCullCovered) os << "on";
172 else os << "off";
173
174 os << "\n Explode factor: " << mp.fExplodeFactor
175 << " about centre: " << mp.fExplodeCentre;
176
177 os << "\n No. of sides used in circle polygon approximation: "
178 << mp.fNoOfSides;
179
180 os << "\n Section (DCUT) shape (G4VSolid) pointer: ";
181 if (!mp.fpSectionSolid) os << "non-";
182 os << "null";
183
184 os << "\n Cutaway (DCUT) shape (G4VSolid) pointer: ";
185 if (!mp.fpCutawaySolid) os << "non-";
186 os << "null";
187
188 os << "\n Event pointer: " << mp.fpEvent;
189
190 return os;
191}
192
193G4bool G4ModelingParameters::operator !=
194(const G4ModelingParameters& mp) const {
195
196 if (
197 (fWarning != mp.fWarning) ||
198 (*fpDefaultVisAttributes != *mp.fpDefaultVisAttributes) ||
199 (fCulling != mp.fCulling) ||
200 (fCullInvisible != mp.fCullInvisible) ||
201 (fDensityCulling != mp.fDensityCulling) ||
202 (fCullCovered != mp.fCullCovered) ||
203 (fExplodeFactor != mp.fExplodeFactor) ||
204 (fExplodeCentre != mp.fExplodeCentre) ||
205 (fNoOfSides != mp.fNoOfSides) ||
206 (fpSectionSolid != mp.fpSectionSolid) ||
207 (fpCutawaySolid != mp.fpCutawaySolid) ||
208 (fpEvent != mp.fpEvent)
209 )
210 return true;
211
212 if (fDensityCulling &&
213 (fVisibleDensity != mp.fVisibleDensity)) return true;
214
215 return false;
216}
Note: See TracBrowser for help on using the repository browser.