Changeset 1340 for trunk/source/geometry/management/src/G4VSolid.cc
- Timestamp:
- Nov 5, 2010, 3:45:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/geometry/management/src/G4VSolid.cc
r1337 r1340 25 25 // 26 26 // 27 // $Id: G4VSolid.cc,v 1. 39 2008/09/23 13:07:41gcosmo Exp $28 // GEANT4 tag $Name: ge ant4-09-04-beta-01$27 // $Id: G4VSolid.cc,v 1.40 2010/10/19 15:19:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geommng-V09-03-05 $ 29 29 // 30 30 // class G4VSolid … … 158 158 JustWarning, "Not implemented for this solid ! Returning origin."); 159 159 return G4ThreeVector(0,0,0); 160 } 161 162 ////////////////////////////////////////////////////////////////////////// 163 // 164 // Dummy implementations ... 165 166 const G4VSolid* G4VSolid::GetConstituentSolid(G4int) const 167 { return 0; } 168 169 G4VSolid* G4VSolid::GetConstituentSolid(G4int) 170 { return 0; } 171 172 const G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr() const 173 { return 0; } 174 175 G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr() 176 { return 0; } 177 178 //////////////////////////////////////////////////////////////// 179 // 180 // Returns an estimation of the solid volume in internal units. 181 // The number of statistics and error accuracy is fixed. 182 // This method may be overloaded by derived classes to compute the 183 // exact geometrical quantity for solids where this is possible. 184 // or anyway to cache the computed value. 185 // This implementation does NOT cache the computed value. 186 187 G4double G4VSolid::GetCubicVolume() 188 { 189 G4int cubVolStatistics = 1000000; 190 G4double cubVolEpsilon = 0.001; 191 return EstimateCubicVolume(cubVolStatistics, cubVolEpsilon); 192 } 193 194 //////////////////////////////////////////////////////////////// 195 // 196 // Calculate cubic volume based on Inside() method. 197 // Accuracy is limited by the second argument or the statistics 198 // expressed by the first argument. 199 // Implementation is courtesy of Vasiliki Despoina Mitsou, 200 // University of Athens. 201 202 G4double G4VSolid::EstimateCubicVolume(G4int nStat, G4double epsilon) const 203 { 204 G4int iInside=0; 205 G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,volume; 206 G4bool yesno; 207 G4ThreeVector p; 208 EInside in; 209 210 // values needed for CalculateExtent signature 211 212 G4VoxelLimits limit; // Unlimited 213 G4AffineTransform origin; 214 215 // min max extents of pSolid along X,Y,Z 216 217 yesno = this->CalculateExtent(kXAxis,limit,origin,minX,maxX); 218 yesno = this->CalculateExtent(kYAxis,limit,origin,minY,maxY); 219 yesno = this->CalculateExtent(kZAxis,limit,origin,minZ,maxZ); 220 221 // limits 222 223 if(nStat < 100) nStat = 100; 224 if(epsilon > 0.01) epsilon = 0.01; 225 226 for(G4int i = 0; i < nStat; i++ ) 227 { 228 px = minX+(maxX-minX)*G4UniformRand(); 229 py = minY+(maxY-minY)*G4UniformRand(); 230 pz = minZ+(maxZ-minZ)*G4UniformRand(); 231 p = G4ThreeVector(px,py,pz); 232 in = this->Inside(p); 233 if(in != kOutside) iInside++; 234 } 235 volume = (maxX-minX)*(maxY-minY)*(maxZ-minZ)*iInside/nStat; 236 return volume; 237 } 238 239 //////////////////////////////////////////////////////////////// 240 // 241 // Returns an estimation of the solid surface area in internal units. 242 // The number of statistics and error accuracy is fixed. 243 // This method may be overloaded by derived classes to compute the 244 // exact geometrical quantity for solids where this is possible. 245 // or anyway to cache the computed value. 246 // This implementation does NOT cache the computed value. 247 248 G4double G4VSolid::GetSurfaceArea() 249 { 250 G4int stat = 1000000; 251 G4double ell = -1.; 252 return EstimateSurfaceArea(stat,ell); 253 } 254 255 //////////////////////////////////////////////////////////////// 256 // 257 // Estimate surface area based on Inside(), DistanceToIn(), and 258 // DistanceToOut() methods. Accuracy is limited by the statistics 259 // defined by the first argument. Implemented by Mikhail Kosov. 260 261 G4double G4VSolid::EstimateSurfaceArea(G4int nStat, G4double ell) const 262 { 263 G4int inside=0; 264 G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,surf; 265 G4bool yesno; 266 G4ThreeVector p; 267 EInside in; 268 269 // values needed for CalculateExtent signature 270 271 G4VoxelLimits limit; // Unlimited 272 G4AffineTransform origin; 273 274 // min max extents of pSolid along X,Y,Z 275 276 yesno = this->CalculateExtent(kXAxis,limit,origin,minX,maxX); 277 yesno = this->CalculateExtent(kYAxis,limit,origin,minY,maxY); 278 yesno = this->CalculateExtent(kZAxis,limit,origin,minZ,maxZ); 279 280 // limits 281 282 if(nStat < 100) { nStat = 100; } 283 284 G4double dX=maxX-minX; 285 G4double dY=maxY-minY; 286 G4double dZ=maxZ-minZ; 287 if(ell<=0.) // Automatic definition of skin thickness 288 { 289 G4double minval=dX; 290 if(dY<dX) { minval=dY; } 291 if(dZ<minval) { minval=dZ; } 292 ell=.01*minval; 293 } 294 295 G4double dd=2*ell; 296 minX-=ell; minY-=ell; minZ-=ell; dX+=dd; dY+=dd; dZ+=dd; 297 298 for(G4int i = 0; i < nStat; i++ ) 299 { 300 px = minX+dX*G4UniformRand(); 301 py = minY+dY*G4UniformRand(); 302 pz = minZ+dZ*G4UniformRand(); 303 p = G4ThreeVector(px,py,pz); 304 in = this->Inside(p); 305 if(in != kOutside) 306 { 307 if (DistanceToOut(p)<ell) { inside++; } 308 } 309 else if(DistanceToIn(p)<ell) { inside++; } 310 } 311 // @@ The conformal correction can be upgraded 312 surf = dX*dY*dZ*inside/dd/nStat; 313 return surf; 314 } 315 316 /////////////////////////////////////////////////////////////////////////// 317 // 318 // Returns a pointer of a dynamically allocated copy of the solid. 319 // Returns NULL pointer with warning in case the concrete solid does not 320 // implement this method. The caller has responsibility for ownership. 321 // 322 323 G4VSolid* G4VSolid::Clone() const 324 { 325 G4String ErrMessage = "Clone() method not implemented for type: " 326 + GetEntityType() + "! Returning NULL pointer!"; 327 G4Exception("G4VSolid::Clone()", "NotImplemented", 328 JustWarning, ErrMessage); 329 return 0; 160 330 } 161 331 … … 447 617 } 448 618 449 const G4VSolid* G4VSolid::GetConstituentSolid(G4int) const450 { return 0; }451 452 G4VSolid* G4VSolid::GetConstituentSolid(G4int)453 { return 0; }454 455 const G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr() const456 { return 0; }457 458 G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr()459 { return 0; }460 461 619 G4VisExtent G4VSolid::GetExtent () const 462 620 { … … 491 649 return 0; 492 650 } 493 494 ////////////////////////////////////////////////////////////////495 //496 // Returns an estimation of the solid volume in internal units.497 // The number of statistics and error accuracy is fixed.498 // This method may be overloaded by derived classes to compute the499 // exact geometrical quantity for solids where this is possible.500 // or anyway to cache the computed value.501 // This implementation does NOT cache the computed value.502 503 G4double G4VSolid::GetCubicVolume()504 {505 G4int cubVolStatistics = 1000000;506 G4double cubVolEpsilon = 0.001;507 return EstimateCubicVolume(cubVolStatistics, cubVolEpsilon);508 }509 510 ////////////////////////////////////////////////////////////////511 //512 // Calculate cubic volume based on Inside() method.513 // Accuracy is limited by the second argument or the statistics514 // expressed by the first argument.515 // Implementation is courtesy of Vasiliki Despoina Mitsou,516 // University of Athens.517 518 G4double G4VSolid::EstimateCubicVolume(G4int nStat, G4double epsilon) const519 {520 G4int iInside=0;521 G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,volume;522 G4bool yesno;523 G4ThreeVector p;524 EInside in;525 526 // values needed for CalculateExtent signature527 528 G4VoxelLimits limit; // Unlimited529 G4AffineTransform origin;530 531 // min max extents of pSolid along X,Y,Z532 533 yesno = this->CalculateExtent(kXAxis,limit,origin,minX,maxX);534 yesno = this->CalculateExtent(kYAxis,limit,origin,minY,maxY);535 yesno = this->CalculateExtent(kZAxis,limit,origin,minZ,maxZ);536 537 // limits538 539 if(nStat < 100) nStat = 100;540 if(epsilon > 0.01) epsilon = 0.01;541 542 for(G4int i = 0; i < nStat; i++ )543 {544 px = minX+(maxX-minX)*G4UniformRand();545 py = minY+(maxY-minY)*G4UniformRand();546 pz = minZ+(maxZ-minZ)*G4UniformRand();547 p = G4ThreeVector(px,py,pz);548 in = this->Inside(p);549 if(in != kOutside) iInside++;550 }551 volume = (maxX-minX)*(maxY-minY)*(maxZ-minZ)*iInside/nStat;552 return volume;553 }554 555 ////////////////////////////////////////////////////////////////556 //557 // Returns an estimation of the solid surface area in internal units.558 // The number of statistics and error accuracy is fixed.559 // This method may be overloaded by derived classes to compute the560 // exact geometrical quantity for solids where this is possible.561 // or anyway to cache the computed value.562 // This implementation does NOT cache the computed value.563 564 G4double G4VSolid::GetSurfaceArea()565 {566 G4int stat = 1000000;567 G4double ell = -1.;568 return EstimateSurfaceArea(stat,ell);569 }570 571 ////////////////////////////////////////////////////////////////572 //573 // Estimate surface area based on Inside(), DistanceToIn(), and574 // DistanceToOut() methods. Accuracy is limited by the statistics575 // defined by the first argument. Implemented by Mikhail Kosov.576 577 G4double G4VSolid::EstimateSurfaceArea(G4int nStat, G4double ell) const578 {579 G4int inside=0;580 G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,surf;581 G4bool yesno;582 G4ThreeVector p;583 EInside in;584 585 // values needed for CalculateExtent signature586 587 G4VoxelLimits limit; // Unlimited588 G4AffineTransform origin;589 590 // min max extents of pSolid along X,Y,Z591 592 yesno = this->CalculateExtent(kXAxis,limit,origin,minX,maxX);593 yesno = this->CalculateExtent(kYAxis,limit,origin,minY,maxY);594 yesno = this->CalculateExtent(kZAxis,limit,origin,minZ,maxZ);595 596 // limits597 598 if(nStat < 100) { nStat = 100; }599 600 G4double dX=maxX-minX;601 G4double dY=maxY-minY;602 G4double dZ=maxZ-minZ;603 if(ell<=0.) // Automatic definition of skin thickness604 {605 G4double minval=dX;606 if(dY<dX) { minval=dY; }607 if(dZ<minval) { minval=dZ; }608 ell=.01*minval;609 }610 611 G4double dd=2*ell;612 minX-=ell; minY-=ell; minZ-=ell; dX+=dd; dY+=dd; dZ+=dd;613 614 for(G4int i = 0; i < nStat; i++ )615 {616 px = minX+dX*G4UniformRand();617 py = minY+dY*G4UniformRand();618 pz = minZ+dZ*G4UniformRand();619 p = G4ThreeVector(px,py,pz);620 in = this->Inside(p);621 if(in != kOutside)622 {623 if (DistanceToOut(p)<ell) { inside++; }624 }625 else if(DistanceToIn(p)<ell) { inside++; }626 }627 // @@ The conformal correction can be upgraded628 surf = dX*dY*dZ*inside/dd/nStat;629 return surf;630 }
Note: See TracChangeset
for help on using the changeset viewer.