Changeset 1315 for trunk/source/geometry
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (15 years ago)
- Location:
- trunk/source/geometry
- Files:
-
- 31 edited
-
magneticfield/History (modified) (2 diffs)
-
magneticfield/src/G4MagIntegratorDriver.cc (modified) (6 diffs)
-
management/History (modified) (2 diffs)
-
management/src/G4SmartVoxelHeader.cc (modified) (2 diffs)
-
navigation/History (modified) (2 diffs)
-
navigation/src/G4PropagatorInField.cc (modified) (11 diffs)
-
solids/Boolean/History (modified) (2 diffs)
-
solids/Boolean/include/G4BooleanSolid.hh (modified) (3 diffs)
-
solids/Boolean/src/G4BooleanSolid.cc (modified) (3 diffs)
-
solids/Boolean/src/G4IntersectionSolid.cc (modified) (3 diffs)
-
solids/Boolean/src/G4SubtractionSolid.cc (modified) (3 diffs)
-
solids/Boolean/src/G4UnionSolid.cc (modified) (3 diffs)
-
solids/CSG/History (modified) (2 diffs)
-
solids/CSG/include/G4Box.hh (modified) (3 diffs)
-
solids/CSG/src/G4Box.cc (modified) (41 diffs)
-
solids/CSG/src/G4Orb.cc (modified) (9 diffs)
-
solids/specific/History (modified) (2 diffs)
-
solids/specific/include/G4ExtrudedSolid.hh (modified) (2 diffs)
-
solids/specific/include/G4PolyconeSide.hh (modified) (3 diffs)
-
solids/specific/include/G4PolyhedraSide.hh (modified) (3 diffs)
-
solids/specific/src/G4ExtrudedSolid.cc (modified) (9 diffs)
-
solids/specific/src/G4PolyconeSide.cc (modified) (6 diffs)
-
solids/specific/src/G4PolyhedraSide.cc (modified) (7 diffs)
-
solids/specific/src/G4SolidExtentList.cc (modified) (3 diffs)
-
solids/specific/src/G4TessellatedSolid.cc (modified) (3 diffs)
-
solids/specific/src/G4TriangularFacet.cc (modified) (5 diffs)
-
volumes/History (modified) (2 diffs)
-
volumes/include/G4NavigationHistory.hh (modified) (3 diffs)
-
volumes/include/G4ReflectionFactory.hh (modified) (2 diffs)
-
volumes/src/G4NavigationHistory.cc (modified) (3 diffs)
-
volumes/src/G4ReflectionFactory.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/geometry/magneticfield/History
r1231 r1315 1 $Id: History,v 1.14 7 2009/11/12 18:45:02japost Exp $1 $Id: History,v 1.146 2009/11/12 15:05:49 japost Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 18 18 ---------------------------------------------------------- 19 19 20 Nov 12th, 2009 J.Apostolakis - field-V09-02-0921 -----------------------------22 - G4MagIntegratorDriver: Activate Peter Gumplinger's check on integration23 error for spin.24 25 20 Nov 12th, 2009 J.Apostolakis - field-V09-02-08 26 ----------------------------- (fix only)21 ----------------------------- 27 22 - G4Nystrom: Corrected interface method getField: array now has explicit dimension[4] 28 23 (Problem found by gcc 4.3 - it checked indices used in inline method! ) -
trunk/source/geometry/magneticfield/src/G4MagIntegratorDriver.cc
r1231 r1315 25 25 // 26 26 // 27 // $Id: G4MagIntegratorDriver.cc,v 1.5 6 2009/11/12 18:41:03 japost Exp $28 // GEANT4 tag $Name: $27 // $Id: G4MagIntegratorDriver.cc,v 1.53 2009/11/05 22:31:43 japost Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 208 208 209 209 #ifdef G4DEBUG_FIELD 210 G4double xSubStepStart= x;211 210 for (i=0;i<nvar;i++) { ySubStepStart[i] = y[i]; } 212 211 yFldTrkStart.LoadFromArray(y, fNoIntegrationVariables); … … 228 227 lastStepSucceeded= (hdid == h); 229 228 #ifdef G4DEBUG_FIELD 230 if (dbg>2) { 231 PrintStatus( ySubStepStart, xSubStepStart, y, x, h, nstp); // Only 229 if (dbg>2) 230 { 231 PrintStatus( ySubStepStart, xSubStart, y, x, h, nstp); // Only 232 232 } 233 233 #endif … … 291 291 { 292 292 if( nstp==nStpPr ) { G4cout << "***** Many steps ****" << G4endl; } 293 G4cout << "MagIntDrv: " ;294 293 G4cout << "hdid=" << std::setw(12) << hdid << " " 295 << "hnext=" << std::setw(12) << hnext << " " 296 << "hstep=" << std::setw(12) << hstep << " (requested) " 297 << G4endl; 294 << "hnext=" << std::setw(12) << hnext << " " << G4endl; 298 295 PrintStatus( ystart, x1, y, x, h, (nstp==nStpPr) ? -nstp: nstp); 299 296 } … … 372 369 lastStep = true; 373 370 #ifdef G4DEBUG_FIELD 374 if (dbg >2)371 if (dbg) 375 372 { 376 int prec= G4cout.precision(12);377 373 G4cout << "Warning: G4MagIntegratorDriver::AccurateAdvance" 378 374 << G4endl 379 375 << " Integration step 'h' became " 380 << h << " due to roundoff. " << G4endl 381 << " Calculated as difference of x2= "<< x2 << " and x=" << x 376 << h << " due to roundoff " << G4endl 382 377 << " Forcing termination of advance." << G4endl; 383 G4cout.precision(prec);384 378 } 385 379 #endif … … 587 581 / ( sqr(y[9]) + sqr(y[10]) + sqr(y[11]) ); 588 582 errspin_sq *= inv_eps_vel_sq; 589 errmax_sq = std::max( errmax_sq, errspin_sq ); 590 } 583 } 591 584 592 585 if ( errmax_sq <= 1.0 ) { break; } // Step succeeded. -
trunk/source/geometry/management/History
r1228 r1315 1 $Id: History,v 1.13 8 2009/11/27 16:34:53gcosmo Exp $1 $Id: History,v 1.139 2010/02/09 16:50:44 gcosmo Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 17 17 * Reverse chronological order (last date on top), please * 18 18 ---------------------------------------------------------- 19 20 February 9, 2010 G.Cosmo geommng-V09-03-00 21 - Fixed initialisation of min/max extent for mother and target volumes in 22 method BuildNodes() of G4SmartVoxelHeader. 19 23 20 24 November 27, 2009 G.Cosmo geommng-V09-02-05 -
trunk/source/geometry/management/src/G4SmartVoxelHeader.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4SmartVoxelHeader.cc,v 1.3 4 2009/10/30 14:05:47gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4SmartVoxelHeader.cc,v 1.35 2010/02/09 16:50:25 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 761 761 EAxis pAxis) 762 762 { 763 G4double motherMinExtent, motherMaxExtent, targetMinExtent, targetMaxExtent; 763 G4double motherMinExtent= kInfinity, motherMaxExtent= -kInfinity, 764 targetMinExtent= kInfinity, targetMaxExtent= -kInfinity; 764 765 G4VPhysicalVolume *pDaughter=0; 765 766 G4VPVParameterisation *pParam=0; -
trunk/source/geometry/navigation/History
r1228 r1315 1 $Id: History,v 1.13 8 2009/12/11 05:48:53 japostExp $1 $Id: History,v 1.139 2010/03/08 13:57:48 gcosmo Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 17 17 * Reverse chronological order (last date on top), please * 18 18 ---------------------------------------------------------- 19 Dec 11th, 2009 - J.Apostolakis (geomnav-V09-02-11) 20 ------------------------------ 21 - G4PropagatorInField 22 * Implementation field by Region 23 - with extra checking of logical volume 24 25 Nov 30th, 2009 - J.Apostolakis (geomnav-V09-02-10) 26 ------------------------------ 27 - G4VIntersectionLocator 28 * Fix problem in ReEstimateEndPoint() behaviour for very small steps. 29 30 * Corrected constructor to ensure that it initialises all data members. 31 * Labelled the methods (in header) to make noticable those that 32 must changed at every step. 33 ( attributes: ChordFinder, EpsilonStep, Navigator ) 19 20 March 8th, 2010 - G.Cosmo (geomnav-V09-03-00) 21 ------------------------- 22 - Avoid unnecessary creation of string for debug purposes in G4PropagatorInField. 23 Courtesy of P.Elmer (CMS). 24 - Some printout formatting... 25 26 December 11th, 2009 - J.Apostolakis (geomnav-V09-02-11) 27 ----------------------------------- 28 - Implemented field by region in G4PropagatorInField, with extra checking of 29 logical volume. 30 31 November 30th, 2009 - J.Apostolakis (geomnav-V09-02-10) 32 ----------------------------------- 33 - Fixes in G4VIntersectionLocator: 34 * Fixed problem in ReEstimateEndPoint() behaviour for very small steps. 35 * Corrected constructor to ensure that it initialises all data members. 36 * Labelled the methods (in header) to make noticable those that must change 37 at every step (attributes: 'ChordFinder', 'EpsilonStep', 'Navigator'). 34 38 35 39 Nov 23rd, 2009 - J.Apostolakis 36 40 ------------------------------ 37 - Fixed G4PropagatorInField.cc: 38 * Revise condition for flagging ZeroStep to avoid fake triggering. 39 Small proposed steps (from Physics) could trigger the previous 40 simple condition for Tiny/Zero Problem steps. 41 [ This was first commited on branch geomnav-V09-02-08_branch 42 and tagged geomnav-V09-02-80 ] 43 44 Nov 12th, 2009 - J.Apostolakis (geomnav-V09-02-09) 45 ------------------------------ 46 - G4PropagatorInField: cleanup of minor methods: 47 Added new method RefreshIntersectionLocator to update the state of 48 Use this method to synchronise with IntersectionLocator. 49 Deleted long obsolete methods: SetAccuraciesWithDeltaOneStep 50 SetDeltaIntersection, SetDeltaOneStep 51 Revised implementation to avoid using the older methods 52 GetDeltaIntersection GetDeltaOneStep 53 54 Nov 12th, 2009 - J.Apostolakis (geomnav-V09-02-08) 55 ------------------------------ 41 - Fixes in G4PropagatorInField.cc: 42 * Revised condition for flagging ZeroStep to avoid fake triggering. Small 43 proposed steps (from Physics) could trigger the previous simple condition 44 for Tiny/Zero Problem steps. 45 46 November 12th, 2009 - J.Apostolakis (geomnav-V09-02-09) 47 ----------------------------------- 48 - Cleanup of minor methods in G4PropagatorInField: 49 * Added new method RefreshIntersectionLocator() to update the state of locator. 50 It is used to synchronise with G4IntersectionLocator. 51 * Deleted long obsolete methods: SetAccuraciesWithDeltaOneStep(), 52 SetDeltaIntersection() and SetDeltaOneStep(). 53 * Revised implementation to avoid using the older methods GetDeltaIntersection() 54 and GetDeltaOneStep(). 55 56 November 12th, 2009 - J.Apostolakis (geomnav-V09-02-08) 57 ----------------------------------- 56 58 - Refined G4PropagatorInField.cc: 57 59 * Changed parameters for treating consecutive tiny/zero steps: 58 60 - the value of default decrease factor to 0.25 (from 0.1), 59 - the value is not used when the step size falls below a certain threshold .s60 This threshold is changed. It is expressed as a multiple of fZeroStepThreshold 61 instead of kCarTolerance. The reasons are:62 * the threshold were meant to refer to the ZeroStepThreshold (it was kCarTolerance) 63 * the values were now much larger than this ZeroStepThreshold.64 - The value given to the decrease factor after the first such thresholds is changed to 0.3565 instead of 0.25, 0.5.61 - the value is not used when the step size falls below a certain thresholds 62 This threshold is changed. It is expressed as a multiple of fZeroStepThreshold 63 instead of kCarTolerance. This, since the thresholds were meant to refer to 64 the ZeroStepThreshold (it was kCarTolerance), and the values were now much 65 larger than 'ZeroStepThreshold'. 66 - The value given to the decrease factor after the first such thresholds is 67 changed to 0.35 instead of 0.25, 0.5. 66 68 * Improved printing of Diagnostic message. 67 69 68 Nov 3rd, 2009 - J.Apostolakis (geomnav-V09-02-07)69 ------------------------------ 70 November 3rd, 2009 - J.Apostolakis (geomnav-V09-02-07) 71 ---------------------------------- 70 72 - Refined G4PropagatorInField.cc: 71 * Added new member fZeroStepThreshold, to enable tuning of threshold for Tiny/Zero steps. 73 * Added new member fZeroStepThreshold, to enable tuning of threshold for 74 Tiny/Zero steps. 72 75 * Changed default value from 0.5 * kCarTolerance 73 to max (100,000 * kCarTolerance, 0.1 * micron ) 74 * This is first revision to address problem seen at boundary of volumes (Reports of Atlas) . 76 to max (100,000 * kCarTolerance, 0.1 * micron ) 77 * This is first revision to address problem seen at boundary of volumes 78 (Reports of ATLAS). 75 79 76 80 June 2nd, 2009 - J.Apostolakis (geomnav-V09-02-06) -
trunk/source/geometry/navigation/src/G4PropagatorInField.cc
r1228 r1315 36 36 // 17.03.97 John Apostolakis, renaming new set functions being added 37 37 // 38 // $Id: G4PropagatorInField.cc,v 1.5 0 2009/12/10 08:41:54 japostExp $38 // $Id: G4PropagatorInField.cc,v 1.51 2010/03/08 13:57:34 gcosmo Exp $ 39 39 // GEANT4 tag $ Name: $ 40 40 // --------------------------------------------------------------------------- … … 129 129 G4double& currentSafety, // IN/OUT 130 130 G4VPhysicalVolume* pPhysVol) 131 { 132 const G4String MethodName("G4PropagatorInField::ComputeStep"); 133 131 { 134 132 // If CurrentProposedStepLength is too small for finding Chords 135 133 // then return with no action (for now - TODO: some action) … … 238 236 239 237 #ifdef G4DEBUG_FIELD 240 G4cout << MethodName << ": "241 << " Decreasing step - "238 G4cout << " G4PropagatorInField::ComputeStep(): " << G4endl 239 << " Decreasing step - " 242 240 << " decreaseFactor= " << std::setw(8) << decreaseFactor 243 241 << " stepTrial = " << std::setw(18) << stepTrial << " " … … 248 246 if( stepTrial == 0.0 ) // Change to make it < 0.1 * kCarTolerance ?? 249 247 { 250 G4cout << " G4PropagatorInField::ComputeStep "251 << " Particle abandoned due to lack of progress in field."248 G4cout << " G4PropagatorInField::ComputeStep(): " << G4endl 249 << " Particle abandoned due to lack of progress in field." 252 250 << G4endl 253 << " Properties : " << pFieldTrack << " "251 << " Properties : " << pFieldTrack << " " 254 252 << G4endl; 255 G4cerr << " G4PropagatorInField::ComputeStep "256 << " ERROR : attempting a zero step= " << stepTrial << G4endl257 << " while attempting to progress after " << fNoZeroStep258 << " trial steps. Will abandon step." << G4endl;253 G4cerr << " G4PropagatorInField::ComputeStep() - ERROR " << G4endl 254 << " Attempting a zero step = " << stepTrial << G4endl 255 << " while attempting to progress after " << fNoZeroStep 256 << " trial steps. Will abandon step." << G4endl; 259 257 fParticleIsLooping= true; 260 258 return 0; // = stepTrial; … … 351 349 if( (fVerboseLevel > 1) && (do_loop_count > fMax_loop_count-10 )) { 352 350 if( do_loop_count == fMax_loop_count-9 ){ 353 G4cout << " G4PropagatorInField::ComputeStep "354 << " Difficult track - taking many sub steps." << G4endl;351 G4cout << " G4PropagatorInField::ComputeStep(): " << G4endl 352 << " Difficult track - taking many sub steps." << G4endl; 355 353 } 356 354 printStatus( SubStepStartState, CurrentState, CurrentProposedStepLength, … … 369 367 fParticleIsLooping = true; 370 368 371 if ( fVerboseLevel > 0 ){ 372 G4cout << "G4PropagateInField: Killing looping particle " 369 if ( fVerboseLevel > 0 ) 370 { 371 G4cout << " G4PropagateInField::ComputeStep(): " << G4endl 372 << " Killing looping particle " 373 373 // << " of " << energy << " energy " 374 374 << " after " << do_loop_count << " field substeps " 375 375 << " totaling " << StepTaken / mm << " mm " ; 376 376 if( pPhysVol ) 377 G4cout << " in thevolume " << pPhysVol->GetName() ;377 G4cout << " in volume " << pPhysVol->GetName() ; 378 378 else 379 379 G4cout << " in unknown or null volume. " ; … … 401 401 - End_PointAndTangent.GetCurveLength()) > 3.e-4 * TruePathLength ) 402 402 { 403 G4cerr << " ERROR - G4PropagatorInField::ComputeStep():" << G4endl404 << " Curve length mis-match, is advancement wrong ? " << G4endl;405 G4cerr << " The curve length of the endpoint should be: "403 G4cerr << " G4PropagatorInField::ComputeStep() - ERROR" << G4endl 404 << " Curve length mis-match, is advancement wrong ? " << G4endl; 405 G4cerr << " The curve length of the endpoint should be: " 406 406 << OriginalState.GetCurveLength() + TruePathLength << G4endl 407 << " and it is instead: "407 << " and it is instead: " 408 408 << End_PointAndTangent.GetCurveLength() << "." << G4endl 409 << " A difference of: "409 << " A difference of: " 410 410 << OriginalState.GetCurveLength() + TruePathLength 411 411 - End_PointAndTangent.GetCurveLength() << G4endl; 412 G4cerr << " Original state= " << OriginalState << G4endl413 << " Proposed state= " << End_PointAndTangent << G4endl;414 G4Exception("G4PropagatorInField::ComputeStep()", "IncorrectProposedEndPoint",415 FatalException,412 G4cerr << " Original state = " << OriginalState << G4endl 413 << " Proposed state = " << End_PointAndTangent << G4endl; 414 G4Exception("G4PropagatorInField::ComputeStep()", 415 "IncorrectProposedEndPoint", FatalException, 416 416 "Curve length mis-match between original state and proposed endpoint of propagation."); 417 417 } … … 434 434 } 435 435 436 if( fNoZeroStep > fAbandonThreshold_NoZeroSteps ) { 436 if( fNoZeroStep > fAbandonThreshold_NoZeroSteps ) 437 { 437 438 fParticleIsLooping = true; 438 G4cout << " WARNING - G4PropagatorInField::ComputeStep():" << G4endl439 << " Zero progress for " << fNoZeroStep << " attempted steps."439 G4cout << " G4PropagatorInField::ComputeStep() - WARNING" << G4endl 440 << " Zero progress for " << fNoZeroStep << " attempted steps." 440 441 << G4endl; 441 G4cout << "Proposed Step is "<<CurrentProposedStepLength <<" but Step Taken is "<< fFull_CurveLen_of_LastAttempt <<G4endl; 442 G4cout << "For Particle with Charge ="<<fCharge 443 << " Momentum="<< fInitialMomentumModulus<<" Mass="<< fMass<<G4endl; 442 G4cout << " Proposed Step is " << CurrentProposedStepLength 443 << " but Step Taken is "<< fFull_CurveLen_of_LastAttempt << G4endl; 444 G4cout << " For Particle with Charge = " << fCharge 445 << " Momentum = "<< fInitialMomentumModulus 446 << " Mass = " << fMass << G4endl; 444 447 if( pPhysVol ) 445 G4cout << " in thevolume " << pPhysVol->GetName() ;448 G4cout << " in volume " << pPhysVol->GetName() ; 446 449 else 447 450 G4cout << " in unknown or null volume. " ; 448 451 G4cout << G4endl; 449 452 if ( fVerboseLevel > 2 ) 450 G4cout << " Particle that is stuckwill be killed." << G4endl;453 G4cout << " Particle is stuck; it will be killed." << G4endl; 451 454 fNoZeroStep = 0; 452 455 } … … 558 561 559 562 G4cout << "Step taken was " << step_len 560 << " out of PhysicalStep = " << requestStep << G4endl;563 << " out of PhysicalStep = " << requestStep << G4endl; 561 564 G4cout << "Final safety is: " << safety << G4endl; 562 565 … … 579 582 { 580 583 #if 0 581 G4cout << " PiF: NoZeroStep = " << fNoZeroStep582 << " CurrentProposedStepLength = " << CurrentProposedStepLength583 << " Full_curvelen_last =" << fFull_CurveLen_of_LastAttempt584 << " last proposed step-length = " << fLast_ProposedStepLength584 G4cout << " PiF: NoZeroStep = " << fNoZeroStep 585 << " CurrentProposedStepLength = " << CurrentProposedStepLength 586 << " Full_curvelen_last =" << fFull_CurveLen_of_LastAttempt 587 << " last proposed step-length = " << fLast_ProposedStepLength 585 588 << " decrease factor = " << decreaseFactor 586 589 << " step trial = " << stepTrial … … 698 701 // 699 702 G4MagInt_Driver* integrDriver= GetChordFinder()->GetIntegrationDriver(); 700 integrDriver->SetVerboseLevel( fVerboseLevel - 2 ); 703 integrDriver->SetVerboseLevel( fVerboseLevel - 2 ); 701 704 G4cout << "Set Driver verbosity to " << fVerboseLevel - 2 << G4endl; 702 705 -
trunk/source/geometry/solids/Boolean/History
r831 r1315 1 1 2 $Id: History,v 1.6 2 2007/10/24 08:19:11 gcosmo Exp $2 $Id: History,v 1.64 2010/05/11 15:04:01 gcosmo Exp $ 3 3 ------------------------------------------------------------------- 4 4 … … 20 20 * Reverse chronological order (last date on top), please * 21 21 ---------------------------------------------------------- 22 23 May 11, 2010 J.Allison geom-bool-V09-03-00 24 - Introduced recursive algorithm in CreatePolyhedron(): it uses 25 HepPolyhedronProcessor from 'graphics_reps', which tries small shifts 26 in an attempt to avoid numerical problems in the calculation of the 27 polyhedron in BooleanProcessor. Recursion allows HepPolyhedronProcessor 28 to try all permutations, also for Booleans of Booleans. 29 Helps in reducing the number of cases of "Error in Boolean processor" for 30 visualization, but still some stubborn cases are left. 22 31 23 32 Oct 24, 2007 V.Grichine geom-bool-V09-00-00 -
trunk/source/geometry/solids/Boolean/include/G4BooleanSolid.hh
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4BooleanSolid.hh,v 1.1 5 2006/10/19 15:34:49gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4BooleanSolid.hh,v 1.17 2010/05/11 15:03:45 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 50 50 #include "G4Transform3D.hh" 51 51 52 class G4VSolid;52 class HepPolyhedronProcessor; 53 53 54 54 class G4BooleanSolid : public G4VSolid … … 111 111 G4VSolid* fPtrSolidB; 112 112 113 G4Polyhedron* StackPolyhedron(HepPolyhedronProcessor&, 114 const G4VSolid*) const; 115 // Stack polyhedra for processing. Return top polyhedron. 116 113 117 private: 114 118 -
trunk/source/geometry/solids/Boolean/src/G4BooleanSolid.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4BooleanSolid.cc,v 1.2 1 2006/10/19 15:34:49gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4BooleanSolid.cc,v 1.23 2010/05/11 15:03:45 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // Implementation for the abstract base class for solids created by boolean … … 40 40 #include "G4VSolid.hh" 41 41 #include "G4Polyhedron.hh" 42 #include "HepPolyhedronProcessor.h" 42 43 #include "Randomize.hh" 43 44 … … 231 232 return fpPolyhedron; 232 233 } 234 235 ////////////////////////////////////////////////////////////////////////// 236 // 237 // Stacks polyhedra for processing. Returns top polyhedron. 238 239 G4Polyhedron* 240 G4BooleanSolid::StackPolyhedron(HepPolyhedronProcessor& processor, 241 const G4VSolid* solid) const 242 { 243 HepPolyhedronProcessor::Operation operation; 244 const G4String& type = solid->GetEntityType(); 245 if (type == "G4UnionSolid") 246 { operation = HepPolyhedronProcessor::UNION; } 247 else if (type == "G4IntersectionSolid") 248 { operation = HepPolyhedronProcessor::INTERSECTION; } 249 else if (type == "G4SubtractionSolid") 250 { operation = HepPolyhedronProcessor::SUBTRACTION; } 251 else 252 { 253 std::ostringstream oss; 254 oss << "Solid - " << solid->GetName() 255 << " - Unrecognised composite solid" 256 << "\n Returning NULL !"; 257 G4Exception("StackPolyhedron()", "InvalidSetup", 258 JustWarning, oss.str().c_str()); 259 return 0; 260 } 261 262 G4Polyhedron* top = 0; 263 const G4VSolid* solidA = solid->GetConstituentSolid(0); 264 const G4VSolid* solidB = solid->GetConstituentSolid(1); 265 266 if (solidA->GetConstituentSolid(0)) 267 { 268 top = StackPolyhedron(processor, solidA); 269 } 270 else 271 { 272 top = solidA->GetPolyhedron(); 273 } 274 G4Polyhedron* operand = solidB->GetPolyhedron(); 275 processor.push_back (operation, *operand); 276 277 return top; 278 } -
trunk/source/geometry/solids/Boolean/src/G4IntersectionSolid.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4IntersectionSolid.cc,v 1.3 0 2006/11/08 09:37:41gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4IntersectionSolid.cc,v 1.32 2010/05/11 15:03:45 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // Implementation of methods for the class G4IntersectionSolid … … 50 50 #include "G4VGraphicsScene.hh" 51 51 #include "G4Polyhedron.hh" 52 #include "HepPolyhedronProcessor.h" 52 53 #include "G4NURBS.hh" 53 54 // #include "G4NURBSbox.hh" … … 502 503 G4IntersectionSolid::CreatePolyhedron () const 503 504 { 504 G4Polyhedron* pA = fPtrSolidA->GetPolyhedron(); 505 G4Polyhedron* pB = fPtrSolidB->GetPolyhedron(); 506 if (pA && pB) 507 { 508 G4Polyhedron* resultant = new G4Polyhedron (pA->intersect(*pB)); 509 return resultant; 510 } 511 else 512 { 513 std::ostringstream oss; 514 oss << "Solid - " << GetName() 515 << " - one of the Boolean components has no" << G4endl 516 << " corresponding polyhedron. Returning NULL !"; 517 G4Exception("G4IntersectionSolid::CreatePolyhedron()", "InvalidSetup", 518 JustWarning, oss.str().c_str()); 519 return 0; 520 } 505 HepPolyhedronProcessor processor; 506 // Stack components and components of components recursively 507 // See G4BooleanSolid::StackPolyhedron 508 G4Polyhedron* top = StackPolyhedron(processor, this); 509 G4Polyhedron* result = new G4Polyhedron(*top); 510 if (processor.execute(*result)) { return result; } 511 else { return 0; } 521 512 } 522 513 -
trunk/source/geometry/solids/Boolean/src/G4SubtractionSolid.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4SubtractionSolid.cc,v 1.3 1 2007/10/23 14:42:31 grichineExp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4SubtractionSolid.cc,v 1.33 2010/05/11 15:03:45 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // Implementation of methods for the class G4IntersectionSolid … … 48 48 #include "G4VGraphicsScene.hh" 49 49 #include "G4Polyhedron.hh" 50 #include "HepPolyhedronProcessor.h" 50 51 #include "G4NURBS.hh" 51 52 // #include "G4NURBSbox.hh" … … 463 464 G4SubtractionSolid::CreatePolyhedron () const 464 465 { 465 G4Polyhedron* pA = fPtrSolidA->GetPolyhedron(); 466 G4Polyhedron* pB = fPtrSolidB->GetPolyhedron(); 467 if (pA && pB) 468 { 469 G4Polyhedron* resultant = new G4Polyhedron (pA->subtract(*pB)); 470 return resultant; 471 } 472 else 473 { 474 std::ostringstream oss; 475 oss << "Solid - " << GetName() 476 << " - one of the Boolean components has no" << G4endl 477 << " corresponding polyhedron. Returning NULL !"; 478 G4Exception("G4SubtractionSolid::CreatePolyhedron()", "InvalidSetup", 479 JustWarning, oss.str().c_str()); 480 return 0; 481 } 466 HepPolyhedronProcessor processor; 467 // Stack components and components of components recursively 468 // See G4BooleanSolid::StackPolyhedron 469 G4Polyhedron* top = StackPolyhedron(processor, this); 470 G4Polyhedron* result = new G4Polyhedron(*top); 471 if (processor.execute(*result)) { return result; } 472 else { return 0; } 482 473 } 483 474 -
trunk/source/geometry/solids/Boolean/src/G4UnionSolid.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4UnionSolid.cc,v 1.3 5 2007/10/23 14:42:31 grichineExp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4UnionSolid.cc,v 1.37 2010/05/11 15:03:45 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // Implementation of methods for the class G4IntersectionSolid … … 49 49 #include "G4VGraphicsScene.hh" 50 50 #include "G4Polyhedron.hh" 51 #include "HepPolyhedronProcessor.h" 51 52 #include "G4NURBS.hh" 52 53 // #include "G4NURBSbox.hh" … … 454 455 G4UnionSolid::CreatePolyhedron () const 455 456 { 456 G4Polyhedron* pA = fPtrSolidA->GetPolyhedron(); 457 G4Polyhedron* pB = fPtrSolidB->GetPolyhedron(); 458 if (pA && pB) { 459 G4Polyhedron* resultant = new G4Polyhedron (pA->add(*pB)); 460 return resultant; 461 } else { 462 std::ostringstream oss; 463 oss << GetName() << 464 ": one of the Boolean components has no corresponding polyhedron."; 465 G4Exception("G4UnionSolid::CreatePolyhedron", 466 "", JustWarning, oss.str().c_str()); 467 return 0; 468 } 457 HepPolyhedronProcessor processor; 458 // Stack components and components of components recursively 459 // See G4BooleanSolid::StackPolyhedron 460 G4Polyhedron* top = StackPolyhedron(processor, this); 461 G4Polyhedron* result = new G4Polyhedron(*top); 462 if (processor.execute(*result)) { return result; } 463 else { return 0; } 469 464 } 470 465 -
trunk/source/geometry/solids/CSG/History
r1228 r1315 1 $Id: History,v 1.1 19 2009/11/30 10:20:53gcosmo Exp $1 $Id: History,v 1.121 2010/05/25 09:19:02 gcosmo Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 17 17 * Reverse chronological order (last date on top), please * 18 18 ---------------------------------------------------------- 19 20 May 25, 2010 G.Cosmo geom-csg-V09-03-01 21 - G4Box: more minor fixes in coding style, following code review discussion. 22 23 May 18, 2010 G.Cosmo geom-csg-V09-03-00 24 - G4Box: first implementation of speed improvements and corrections from joint 25 code review of G4Box class: introduced half-tolerance constants and better 26 logic in some conditional statements. 27 - Some code cleanup. 28 29 Dec 04, 2009 V.Grichine 30 - G4Orb: modified DistanceToIn(p,v) to be more consistent with Inside(p). 19 31 20 32 Nov 30, 2009 V.Grichine geom-csg-V09-02-08 -
trunk/source/geometry/solids/CSG/include/G4Box.hh
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4Box.hh,v 1.1 7 2006/10/19 15:33:37gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4Box.hh,v 1.18 2010/05/18 10:07:52 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // -------------------------------------------------------------------- … … 101 101 std::ostream& StreamInfo(std::ostream& os) const; 102 102 103 // Functions for visualization103 // Utilities for visualization 104 104 105 105 void DescribeYourselfTo (G4VGraphicsScene& scene) const; … … 125 125 126 126 enum ESide {kUndefined,kPX,kMX,kPY,kMY,kPZ,kMZ}; 127 // Codes for faces (kPX= plus x face,kMY= minus y face etc)127 // Codes for faces (kPX= +x face, kMY= -y face, etc...) 128 128 129 129 private: -
trunk/source/geometry/solids/CSG/src/G4Box.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4Box.cc,v 1.4 4 2006/10/19 15:33:37gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4Box.cc,v 1.49 2010/05/25 10:14:41 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 32 32 // Implementation for G4Box class 33 33 // 34 // 24.06.98 - V. Grichine: insideEdge in DistanceToIn(p,v)34 // 24.06.98 - V.Grichine: insideEdge in DistanceToIn(p,v) 35 35 // 20.09.98 - V.Grichine: new algorithm of DistanceToIn(p,v) 36 36 // 07.05.00 - V.Grichine: d= DistanceToIn(p,v), if d<e/2, d=0 … … 67 67 if ( (pX > 2*kCarTolerance) 68 68 && (pY > 2*kCarTolerance) 69 && (pZ > 2*kCarTolerance) ) 69 && (pZ > 2*kCarTolerance) ) // limit to thickness of surfaces 70 70 { 71 71 fDx = pX ; … … 105 105 void G4Box::SetXHalfLength(G4double dx) 106 106 { 107 if(dx > 2*kCarTolerance) 107 if(dx > 2*kCarTolerance) // limit to thickness of surfaces 108 { 108 109 fDx = dx; 110 } 109 111 else 110 112 { … … 122 124 void G4Box::SetYHalfLength(G4double dy) 123 125 { 124 if(dy > 2*kCarTolerance) 126 if(dy > 2*kCarTolerance) // limit to thickness of surfaces 127 { 125 128 fDy = dy; 129 } 126 130 else 127 131 { … … 139 143 void G4Box::SetZHalfLength(G4double dz) 140 144 { 141 if(dz > 2*kCarTolerance) 145 if(dz > 2*kCarTolerance) // limit to thickness of surfaces 146 { 142 147 fDz = dz; 148 } 143 149 else 144 150 { … … 153 159 fpPolyhedron = 0; 154 160 } 155 156 157 161 158 162 //////////////////////////////////////////////////////////////////////// … … 193 197 if (pVoxelLimit.IsXLimited()) 194 198 { 195 if ( xMin > pVoxelLimit.GetMaxXExtent()+kCarTolerance||196 xMax < pVoxelLimit.GetMinXExtent()-kCarTolerance ) return false ;199 if ((xMin > pVoxelLimit.GetMaxXExtent()+kCarTolerance) || 200 (xMax < pVoxelLimit.GetMinXExtent()-kCarTolerance)) { return false ; } 197 201 else 198 202 { 199 if (xMin < pVoxelLimit.GetMinXExtent()) 200 { 201 xMin = pVoxelLimit.GetMinXExtent() ; 202 } 203 if (xMax > pVoxelLimit.GetMaxXExtent()) 204 { 205 xMax = pVoxelLimit.GetMaxXExtent() ; 206 } 203 xMin = std::max(xMin, pVoxelLimit.GetMinXExtent()); 204 xMax = std::min(xMax, pVoxelLimit.GetMaxXExtent()); 207 205 } 208 206 } … … 213 211 if (pVoxelLimit.IsYLimited()) 214 212 { 215 if ( yMin > pVoxelLimit.GetMaxYExtent()+kCarTolerance||216 yMax < pVoxelLimit.GetMinYExtent()-kCarTolerance ) return false ;213 if ((yMin > pVoxelLimit.GetMaxYExtent()+kCarTolerance) || 214 (yMax < pVoxelLimit.GetMinYExtent()-kCarTolerance)) { return false ; } 217 215 else 218 216 { 219 if (yMin < pVoxelLimit.GetMinYExtent()) 220 { 221 yMin = pVoxelLimit.GetMinYExtent() ; 222 } 223 if (yMax > pVoxelLimit.GetMaxYExtent()) 224 { 225 yMax = pVoxelLimit.GetMaxYExtent() ; 226 } 217 yMin = std::max(yMin, pVoxelLimit.GetMinYExtent()); 218 yMax = std::min(yMax, pVoxelLimit.GetMaxYExtent()); 227 219 } 228 220 } … … 233 225 if (pVoxelLimit.IsZLimited()) 234 226 { 235 if ( zMin > pVoxelLimit.GetMaxZExtent()+kCarTolerance||236 zMax < pVoxelLimit.GetMinZExtent()-kCarTolerance ) return false ;227 if ((zMin > pVoxelLimit.GetMaxZExtent()+kCarTolerance) || 228 (zMax < pVoxelLimit.GetMinZExtent()-kCarTolerance)) { return false ; } 237 229 else 238 230 { 239 if (zMin < pVoxelLimit.GetMinZExtent()) 240 { 241 zMin = pVoxelLimit.GetMinZExtent() ; 242 } 243 if (zMax > pVoxelLimit.GetMaxZExtent()) 244 { 245 zMax = pVoxelLimit.GetMaxZExtent() ; 246 } 231 zMin = std::max(zMin, pVoxelLimit.GetMinZExtent()); 232 zMax = std::min(zMax, pVoxelLimit.GetMaxZExtent()); 247 233 } 248 234 } … … 286 272 if (pVoxelLimit.IsLimited(pAxis) == false) 287 273 { 288 if ( pMin != kInfinity || pMax != -kInfinity)274 if ( (pMin != kInfinity) || (pMax != -kInfinity) ) 289 275 { 290 276 existsAfterClip = true ; … … 292 278 // Add 2*tolerance to avoid precision troubles 293 279 294 pMin -= kCarTolerance;295 pMax += kCarTolerance;280 pMin -= kCarTolerance; 281 pMax += kCarTolerance; 296 282 } 297 283 } … … 303 289 ( pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5); 304 290 305 if ( pMin != kInfinity || pMax != -kInfinity)291 if ( (pMin != kInfinity) || (pMax != -kInfinity) ) 306 292 { 307 293 existsAfterClip = true ; … … 356 342 EInside G4Box::Inside(const G4ThreeVector& p) const 357 343 { 344 static const G4double delta=0.5*kCarTolerance; 358 345 EInside in = kOutside ; 359 360 if ( std::fabs(p.x()) <= fDx - kCarTolerance*0.5 ) 361 { 362 if (std::fabs(p.y()) <= fDy - kCarTolerance*0.5 ) 363 { 364 if (std::fabs(p.z()) <= fDz - kCarTolerance*0.5 ) in = kInside ; 365 else if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5 ) in = kSurface ; 366 } 367 else if (std::fabs(p.y()) <= fDy + kCarTolerance*0.5 ) 368 { 369 if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5 ) in = kSurface ; 370 } 371 } 372 else if (std::fabs(p.x()) <= fDx + kCarTolerance*0.5 ) 373 { 374 if (std::fabs(p.y()) <= fDy + kCarTolerance*0.5 ) 375 { 376 if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5) in = kSurface ; 346 G4ThreeVector q(std::fabs(p.x()), std::fabs(p.y()), std::fabs(p.z())); 347 348 if ( q.x() <= (fDx - delta) ) 349 { 350 if (q.y() <= (fDy - delta) ) 351 { 352 if ( q.z() <= (fDz - delta) ) { in = kInside ; } 353 else if ( q.z() <= (fDz + delta) ) { in = kSurface ; } 354 } 355 else if ( q.y() <= (fDy + delta) ) 356 { 357 if ( q.z() <= (fDz + delta) ) { in = kSurface ; } 358 } 359 } 360 else if ( q.x() <= (fDx + delta) ) 361 { 362 if ( q.y() <= (fDy + delta) ) 363 { 364 if ( q.z() <= (fDz + delta) ) { in = kSurface ; } 377 365 } 378 366 } … … 389 377 { 390 378 G4double distx, disty, distz ; 391 G4ThreeVector norm ;379 G4ThreeVector norm(0.,0.,0.); 392 380 393 381 // Calculate distances as if in 1st octant … … 400 388 // normals 401 389 402 const G4double delta = 0.5*kCarTolerance;390 static const G4double delta = 0.5*kCarTolerance; 403 391 const G4ThreeVector nX = G4ThreeVector( 1.0, 0,0 ); 404 392 const G4ThreeVector nmX = G4ThreeVector(-1.0, 0,0 ); … … 415 403 { 416 404 noSurfaces ++; 417 if ( p.x() >= 0.){ // on +X surface 418 normX= nX ; // G4ThreeVector( 1.0, 0., 0. ); 419 }else{ 420 normX= nmX; // G4ThreeVector(-1.0, 0., 0. ); 421 } 405 if ( p.x() >= 0. ) { normX= nX ; } // on +X surface : (1,0,0) 406 else { normX= nmX; } // (-1,0,0) 422 407 sumnorm= normX; 423 408 } … … 426 411 { 427 412 noSurfaces ++; 428 if ( p.y() >= 0.){ // on +Y surface 429 normY= nY; 430 }else{ 431 normY = nmY; 432 } 413 if ( p.y() >= 0. ) { normY= nY; } // on +Y surface 414 else { normY= nmY; } 433 415 sumnorm += normY; 434 416 } … … 437 419 { 438 420 noSurfaces ++; 439 if ( p.z() >= 0.){ // on +Z surface 440 normZ= nZ; 441 }else{ 442 normZ = nmZ; 443 } 444 sumnorm += normZ; 445 } 446 447 // sumnorm= normX + normY + normZ; 448 const G4double invSqrt2 = 1.0 / std::sqrt( 2.0); 449 const G4double invSqrt3 = 1.0 / std::sqrt( 3.0); 450 451 norm= G4ThreeVector( 0., 0., 0.); 421 if ( p.z() >= 0. ) { normZ= nZ; } // on +Z surface 422 else { normZ= nmZ; } 423 sumnorm += normZ; 424 } 425 426 static const G4double invSqrt2 = 1.0 / std::sqrt(2.0); 427 static const G4double invSqrt3 = 1.0 / std::sqrt(3.0); 428 452 429 if( noSurfaces > 0 ) 453 430 { 454 if( noSurfaces == 1 ){ 431 if( noSurfaces == 1 ) 432 { 455 433 norm= sumnorm; 456 }else{ 434 } 435 else 436 { 457 437 // norm = sumnorm . unit(); 458 if( noSurfaces == 2 ) { 438 if( noSurfaces == 2 ) 439 { 459 440 // 2 surfaces -> on edge 460 441 norm = invSqrt2 * sumnorm; 461 } else { 442 } 443 else 444 { 462 445 // 3 surfaces (on corner) 463 446 norm = invSqrt3 * sumnorm; 464 447 } 465 448 } 466 }else{ 449 } 450 else 451 { 467 452 #ifdef G4CSGDEBUG 468 453 G4Exception("G4Box::SurfaceNormal(p)", "Notification", JustWarning, … … 483 468 { 484 469 G4double distx, disty, distz ; 485 G4ThreeVector norm ;470 G4ThreeVector norm(0.,0.,0.); 486 471 487 472 // Calculate distances as if in 1st octant … … 495 480 if ( distx <= distz ) // Closest to X 496 481 { 497 if ( p.x() < 0 ) norm = G4ThreeVector(-1.0,0,0) ;498 else norm = G4ThreeVector( 1.0,0,0) ;482 if ( p.x() < 0 ) { norm = G4ThreeVector(-1.0,0,0) ; } 483 else { norm = G4ThreeVector( 1.0,0,0) ; } 499 484 } 500 485 else // Closest to Z 501 486 { 502 if ( p.z() < 0 ) norm = G4ThreeVector(0,0,-1.0) ;503 else norm = G4ThreeVector(0,0, 1.0) ;487 if ( p.z() < 0 ) { norm = G4ThreeVector(0,0,-1.0) ; } 488 else { norm = G4ThreeVector(0,0, 1.0) ; } 504 489 } 505 490 } … … 508 493 if ( disty <= distz ) // Closest to Y 509 494 { 510 if ( p.y() < 0 ) norm = G4ThreeVector(0,-1.0,0) ;511 else norm = G4ThreeVector(0, 1.0,0) ;495 if ( p.y() < 0 ) { norm = G4ThreeVector(0,-1.0,0) ; } 496 else { norm = G4ThreeVector(0, 1.0,0) ; } 512 497 } 513 498 else // Closest to Z 514 499 { 515 if ( p.z() < 0 ) norm = G4ThreeVector(0,0,-1.0) ;516 else norm = G4ThreeVector(0,0, 1.0) ;500 if ( p.z() < 0 ) { norm = G4ThreeVector(0,0,-1.0) ; } 501 else { norm = G4ThreeVector(0,0, 1.0) ; } 517 502 } 518 503 } … … 541 526 // shape. 542 527 543 G4double G4Box::DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const 528 G4double G4Box::DistanceToIn(const G4ThreeVector& p, 529 const G4ThreeVector& v) const 544 530 { 545 531 G4double safx, safy, safz ; … … 549 535 G4double sOut=kInfinity, sOuty=kInfinity, sOutz=kInfinity ; 550 536 537 static const G4double delta = 0.5*kCarTolerance; 538 551 539 safx = std::fabs(p.x()) - fDx ; // minimum distance to x surface of shape 552 540 safy = std::fabs(p.y()) - fDy ; … … 558 546 // travel is in a direction away from the shape. 559 547 560 if ( ((p.x()*v.x() >= 0.0) && safx > -kCarTolerance*0.5)561 || ((p.y()*v.y() >= 0.0) && safy > -kCarTolerance*0.5)562 || ((p.z()*v.z() >= 0.0) && safz > -kCarTolerance*0.5) )548 if ( ((p.x()*v.x() >= 0.0) && (safx > -delta)) 549 || ((p.y()*v.y() >= 0.0) && (safy > -delta)) 550 || ((p.z()*v.z() >= 0.0) && (safz > -delta)) ) 563 551 { 564 552 return kInfinity ; // travel away or parallel within tolerance … … 568 556 // X Planes 569 557 570 if ( v.x() )558 if ( v.x() ) // != 0 571 559 { 572 560 stmp = 1.0/std::fabs(v.x()) ; … … 579 567 else 580 568 { 581 if (v.x() > 0) sOut = (fDx - p.x())*stmp ;582 if (v.x() < 0) sOut = (fDx + p.x())*stmp ;569 if (v.x() < 0) { sOut = (fDx + p.x())*stmp ; } 570 else { sOut = (fDx - p.x())*stmp ; } 583 571 } 584 572 } … … 586 574 // Y Planes 587 575 588 if ( v.y() )576 if ( v.y() ) // != 0 589 577 { 590 578 stmp = 1.0/std::fabs(v.y()) ; … … 595 583 smaxy = (fDy+std::fabs(p.y()))*stmp ; 596 584 597 if (sminy > smin) smin=sminy ;598 if (smaxy < smax) smax=smaxy ;599 600 if (smin >= smax-kCarTolerance*0.5)585 if (sminy > smin) { smin=sminy ; } 586 if (smaxy < smax) { smax=smaxy ; } 587 588 if (smin >= (smax-delta)) 601 589 { 602 590 return kInfinity ; // touch XY corner … … 605 593 else 606 594 { 607 if (v.y() > 0) sOuty = (fDy - p.y())*stmp ;608 if (v.y() < 0) sOuty = (fDy + p.y())*stmp ;609 if( sOuty < sOut ) sOut = sOuty ;595 if (v.y() < 0) { sOuty = (fDy + p.y())*stmp ; } 596 else { sOuty = (fDy - p.y())*stmp ; } 597 if( sOuty < sOut ) { sOut = sOuty ; } 610 598 } 611 599 } … … 613 601 // Z planes 614 602 615 if ( v.z() ) 603 if ( v.z() ) // != 0 616 604 { 617 605 stmp = 1.0/std::fabs(v.z()) ; 618 606 619 if ( safz >= 0.0 )607 if ( safz >= 0.0 ) 620 608 { 621 609 sminz = safz*stmp ; 622 610 smaxz = (fDz+std::fabs(p.z()))*stmp ; 623 611 624 if (sminz > smin) smin = sminz ;625 if (smaxz < smax) smax = smaxz ;626 627 if (smin >= smax-kCarTolerance*0.5)612 if (sminz > smin) { smin = sminz ; } 613 if (smaxz < smax) { smax = smaxz ; } 614 615 if (smin >= (smax-delta)) 628 616 { 629 617 return kInfinity ; // touch ZX or ZY corners … … 632 620 else 633 621 { 634 if (v.z() > 0) sOutz = (fDz - p.z())*stmp ;635 if (v.z() < 0) sOutz = (fDz + p.z())*stmp ;636 if( sOutz < sOut ) sOut = sOutz ;637 } 638 } 639 640 if ( sOut <= smin + 0.5*kCarTolerance) // travel over edge622 if (v.z() < 0) { sOutz = (fDz + p.z())*stmp ; } 623 else { sOutz = (fDz - p.z())*stmp ; } 624 if( sOutz < sOut ) { sOut = sOutz ; } 625 } 626 } 627 628 if (sOut <= (smin + delta)) // travel over edge 641 629 { 642 630 return kInfinity ; 643 631 } 644 if (smin < 0.5*kCarTolerance) smin = 0.0 ;632 if (smin < delta) { smin = 0.0 ; } 645 633 646 634 return smin ; … … 662 650 safez = std::fabs(p.z()) - fDz ; 663 651 664 if (safex > safe) safe = safex ;665 if (safey > safe) safe = safey ;666 if (safez > safe) safe = safez ;652 if (safex > safe) { safe = safex ; } 653 if (safey > safe) { safe = safey ; } 654 if (safez > safe) { safe = safez ; } 667 655 668 656 return safe ; … … 671 659 ///////////////////////////////////////////////////////////////////////// 672 660 // 673 // Calc luate distance to surface of box from inside661 // Calculate distance to surface of box from inside 674 662 // by calculating distances to box's x/y/z planes. 675 663 // Smallest distance is exact distance to exiting. … … 682 670 { 683 671 ESide side = kUndefined ; 684 G4double pdist,stmp,snxt; 685 686 if (calcNorm) *validNorm = true ; // All normals are valid 687 688 if (v.x() > 0) // X planes 672 G4double pdist,stmp,snxt=kInfinity; 673 674 static const G4double delta = 0.5*kCarTolerance; 675 676 if (calcNorm) { *validNorm = true ; } // All normals are valid 677 678 if (v.x() > 0) // X planes 689 679 { 690 680 pdist = fDx - p.x() ; 691 681 692 if (pdist > kCarTolerance*0.5)682 if (pdist > delta) 693 683 { 694 684 snxt = pdist/v.x() ; … … 697 687 else 698 688 { 699 if (calcNorm) *n = G4ThreeVector(1,0,0) ;700 return snxt = 0 ;701 } 702 } 703 else if (v.x() < 0) 689 if (calcNorm) { *n = G4ThreeVector(1,0,0) ; } 690 return snxt = 0 ; 691 } 692 } 693 else if (v.x() < 0) 704 694 { 705 695 pdist = fDx + p.x() ; 706 696 707 if (pdist > kCarTolerance*0.5)697 if (pdist > delta) 708 698 { 709 699 snxt = -pdist/v.x() ; … … 712 702 else 713 703 { 714 if (calcNorm) *n = G4ThreeVector(-1,0,0) ;704 if (calcNorm) { *n = G4ThreeVector(-1,0,0) ; } 715 705 return snxt = 0 ; 716 706 } 717 707 } 718 else snxt = kInfinity ; 719 720 if ( v.y() > 0 ) // Y planes 721 { 722 pdist=fDy-p.y(); 723 724 if (pdist>kCarTolerance*0.5) 725 { 726 stmp=pdist/v.y(); 727 728 if (stmp<snxt) 729 { 730 snxt=stmp; 731 side=kPY; 732 } 733 } 734 else 735 { 736 if (calcNorm) *n = G4ThreeVector(0,1,0) ; 737 return snxt = 0 ; 738 } 739 } 740 else if ( v.y() < 0 ) 741 { 742 pdist = fDy + p.y() ; 743 744 if (pdist > kCarTolerance*0.5) 745 { 746 stmp=-pdist/v.y(); 747 748 if (stmp<snxt) 749 { 750 snxt=stmp; 751 side=kMY; 752 } 753 } 754 else 755 { 756 if (calcNorm) *n = G4ThreeVector(0,-1,0) ; 757 return snxt = 0 ; 758 } 759 } 760 if (v.z()>0) // Z planes 761 { 762 pdist=fDz-p.z(); 763 764 if (pdist > kCarTolerance*0.5) 765 { 766 stmp=pdist/v.z(); 708 709 if (v.y() > 0) // Y planes 710 { 711 pdist = fDy-p.y(); 712 713 if (pdist > delta) 714 { 715 stmp = pdist/v.y(); 767 716 768 717 if (stmp < snxt) 769 718 { 770 snxt =stmp;771 side =kPZ;719 snxt = stmp; 720 side = kPY; 772 721 } 773 722 } 774 723 else 775 724 { 776 if (calcNorm) *n = G4ThreeVector(0,0,1) ;777 return snxt = 0 ;778 } 779 } 780 else if (v. z()<0)781 { 782 pdist = fD z + p.z() ;783 784 if (pdist > kCarTolerance*0.5)785 { 786 stmp =-pdist/v.z();787 788 if ( stmp < snxt)725 if (calcNorm) { *n = G4ThreeVector(0,1,0) ; } 726 return snxt = 0 ; 727 } 728 } 729 else if (v.y() < 0) 730 { 731 pdist = fDy + p.y() ; 732 733 if (pdist > delta) 734 { 735 stmp = -pdist/v.y(); 736 737 if ( stmp < snxt ) 789 738 { 790 snxt =stmp;791 side =kMZ;739 snxt = stmp; 740 side = kMY; 792 741 } 793 742 } 794 743 else 795 744 { 796 if (calcNorm) *n = G4ThreeVector(0,0,-1) ; 797 return snxt = 0 ; 798 } 799 } 745 if (calcNorm) { *n = G4ThreeVector(0,-1,0) ; } 746 return snxt = 0 ; 747 } 748 } 749 750 if (v.z() > 0) // Z planes 751 { 752 pdist = fDz-p.z(); 753 754 if ( pdist > delta ) 755 { 756 stmp = pdist/v.z(); 757 758 if ( stmp < snxt ) 759 { 760 snxt = stmp; 761 side = kPZ; 762 } 763 } 764 else 765 { 766 if (calcNorm) { *n = G4ThreeVector(0,0,1) ; } 767 return snxt = 0 ; 768 } 769 } 770 else if (v.z() < 0) 771 { 772 pdist = fDz + p.z(); 773 774 if ( pdist > delta ) 775 { 776 stmp = -pdist/v.z(); 777 778 if ( stmp < snxt ) 779 { 780 snxt = stmp; 781 side = kMZ; 782 } 783 } 784 else 785 { 786 if (calcNorm) { *n = G4ThreeVector(0,0,-1) ; } 787 return snxt = 0 ; 788 } 789 } 790 800 791 if (calcNorm) 801 792 { … … 875 866 // shortest Dist to any boundary now MIN(safx1,safx2,safy1..) 876 867 877 if (safx2 < safx1) safe = safx2 ;878 else safe = safx1 ;879 if (safy1 < safe) safe = safy1 ;880 if (safy2 < safe) safe = safy2 ;881 if (safz1 < safe) safe = safz1 ;882 if (safz2 < safe) safe = safz2 ;883 884 if (safe < 0) safe = 0 ;868 if (safx2 < safx1) { safe = safx2; } 869 else { safe = safx1; } 870 if (safy1 < safe) { safe = safy1; } 871 if (safy2 < safe) { safe = safy2; } 872 if (safz1 < safe) { safe = safz1; } 873 if (safz2 < safe) { safe = safz2; } 874 875 if (safe < 0) { safe = 0 ; } 885 876 return safe ; 886 877 } … … 979 970 py = -fDy +2*fDy*G4UniformRand(); 980 971 981 if(G4UniformRand() > 0.5) pz = fDz;982 else pz = -fDz;972 if(G4UniformRand() > 0.5) { pz = fDz; } 973 else { pz = -fDz; } 983 974 } 984 975 else if ( ( select - Sxy ) < Sxz ) … … 987 978 pz = -fDz +2*fDz*G4UniformRand(); 988 979 989 if(G4UniformRand() > 0.5) py = fDy;990 else py = -fDy;980 if(G4UniformRand() > 0.5) { py = fDy; } 981 else { py = -fDy; } 991 982 } 992 983 else … … 995 986 pz = -fDz +2*fDz*G4UniformRand(); 996 987 997 if(G4UniformRand() > 0.5) px = fDx;998 else px = -fDx;988 if(G4UniformRand() > 0.5) { px = fDx; } 989 else { px = -fDx; } 999 990 } 1000 991 return G4ThreeVector(px,py,pz); -
trunk/source/geometry/solids/CSG/src/G4Orb.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4Orb.cc,v 1.3 0 2009/11/30 10:20:38 gcosmoExp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4Orb.cc,v 1.31 2009/12/04 15:39:56 grichine Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // class G4Orb … … 296 296 297 297 298 rad2 = p.x()*p.x()+p.y()*p.y()+p.z()*p.z() ;298 rad2 = p.x()*p.x()+p.y()*p.y()+p.z()*p.z(); 299 299 300 300 G4double rad = std::sqrt(rad2); … … 304 304 // sets `in' 305 305 306 tolRMax = fRmax - fRmaxTolerance*0.5 ;306 tolRMax = fRmax - fRmaxTolerance*0.5; 307 307 308 if ( rad <= tolRMax ) { in = kInside ; }308 if ( rad <= tolRMax ) { in = kInside; } 309 309 else 310 310 { 311 tolRMax = fRmax + fRmaxTolerance*0.5 ;312 if ( rad <= tolRMax ) { in = kSurface ; }313 else { in = kOutside ; }311 tolRMax = fRmax + fRmaxTolerance*0.5; 312 if ( rad <= tolRMax ) { in = kSurface; } 313 else { in = kOutside; } 314 314 } 315 315 return in; … … 357 357 const G4ThreeVector& v ) const 358 358 { 359 G4double snxt = kInfinity ; // snxt = default return value360 361 G4double rad 2, pDotV3d, tolORMax2, tolIRMax2;362 G4double c, d2, s = kInfinity ;359 G4double snxt = kInfinity; // snxt = default return value 360 361 G4double rad, pDotV3d; // , tolORMax2, tolIRMax2; 362 G4double c, d2, s = kInfinity; 363 363 364 364 const G4double dRmax = 100.*fRmax; … … 366 366 // General Precalcs 367 367 368 rad 2 = p.x()*p.x() + p.y()*p.y() + p.z()*p.z();369 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z() ;368 rad = std::sqrt(p.x()*p.x() + p.y()*p.y() + p.z()*p.z()); 369 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z(); 370 370 371 371 // Radial Precalcs 372 372 373 tolORMax2 = (fRmax+fRmaxTolerance*0.5)*(fRmax+fRmaxTolerance*0.5);374 tolIRMax2 = (fRmax-fRmaxTolerance*0.5)*(fRmax-fRmaxTolerance*0.5);373 // tolORMax2 = (fRmax+fRmaxTolerance*0.5)*(fRmax+fRmaxTolerance*0.5); 374 // tolIRMax2 = (fRmax-fRmaxTolerance*0.5)*(fRmax-fRmaxTolerance*0.5); 375 375 376 376 // Outer spherical shell intersection … … 388 388 // => s=-pDotV3d+-std::sqrt(pDotV3d^2-(rad2-R^2)) 389 389 390 391 G4double rad = std::sqrt(rad2);392 390 c = (rad - fRmax)*(rad + fRmax); 393 391 394 if ( c > fRmaxTolerance*fRmax ) 395 { 396 // If outside tolerant boundary of outer G4Orb 397 // [ should be std::sqrt(rad2) - fRmax > fRmaxTolerance*0.5 ] 398 399 d2 = pDotV3d*pDotV3d - c ; 400 401 if ( d2 >= 0 ) 402 { 403 s = -pDotV3d - std::sqrt(d2) ; 404 if ( s >= 0 ) 405 { 406 if ( s>dRmax ) // Avoid rounding errors due to precision issues seen on 407 { // 64 bits systems. Split long distances and recompute 408 G4double fTerm = s-std::fmod(s,dRmax); 409 s = fTerm + DistanceToIn(p+fTerm*v,v); 410 } 411 return snxt = s; 412 } 413 } 414 else // No intersection with G4Orb 415 { 416 return snxt = kInfinity; 417 } 418 } 419 else 420 { 421 if ( c > -fRmaxTolerance*fRmax ) // on surface 422 { 423 d2 = pDotV3d*pDotV3d - c ; 424 if ( (d2 < fRmaxTolerance*fRmax) || (pDotV3d >= 0) ) 392 if( rad > fRmax-fRmaxTolerance*0.5 ) // not inside in terms of Inside(p) 393 { 394 if ( c > fRmaxTolerance*fRmax ) 395 { 396 // If outside tolerant boundary of outer G4Orb in terms of c 397 // [ should be std::sqrt(rad2) - fRmax > fRmaxTolerance*0.5 ] 398 399 d2 = pDotV3d*pDotV3d - c; 400 401 if ( d2 >= 0 ) 402 { 403 s = -pDotV3d - std::sqrt(d2); 404 if ( s >= 0 ) 405 { 406 if ( s > dRmax ) // Avoid rounding errors due to precision issues seen on 407 { // 64 bits systems. Split long distances and recompute 408 G4double fTerm = s - std::fmod(s,dRmax); 409 s = fTerm + DistanceToIn(p+fTerm*v,v); 410 } 411 return snxt = s; 412 } 413 } 414 else // No intersection with G4Orb 425 415 { 426 416 return snxt = kInfinity; 427 417 } 428 else 429 { 430 return snxt = 0.; 431 } 432 } 418 } 419 else // not outside in terms of c 420 { 421 if ( c > -fRmaxTolerance*fRmax ) // on surface 422 { 423 d2 = pDotV3d*pDotV3d - c; 424 if ( (d2 < fRmaxTolerance*fRmax) || (pDotV3d >= 0) ) 425 { 426 return snxt = kInfinity; 427 } 428 else 429 { 430 return snxt = 0.; 431 } 432 } 433 } 434 } 433 435 #ifdef G4CSGDEBUG 434 else // inside ???435 {436 else // inside ??? 437 { 436 438 G4Exception("G4Orb::DistanceToIn(p,v)", "Notification", 437 439 JustWarning, "Point p is inside !?"); 438 }440 } 439 441 #endif 440 } 442 441 443 return snxt; 442 444 } … … 520 522 if(calcNorm) 521 523 { 522 *validNorm = true ;523 *n = G4ThreeVector(p.x()/fRmax,p.y()/fRmax,p.z()/fRmax) ;524 *validNorm = true; 525 *n = G4ThreeVector(p.x()/fRmax,p.y()/fRmax,p.z()/fRmax); 524 526 } 525 527 return snxt = 0; … … 528 530 { 529 531 snxt = -pDotV3d + std::sqrt(d2); // second root since inside Rmax 530 side = kRMax ;532 side = kRMax; 531 533 } 532 534 } … … 596 598 if( Inside(p) == kOutside ) 597 599 { 598 G4cout.precision(16) ;599 G4cout << G4endl ;600 G4cout.precision(16); 601 G4cout << G4endl; 600 602 DumpInfo(); 601 G4cout << "Position:" << G4endl << G4endl ;602 G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;603 G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;604 G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;603 G4cout << "Position:" << G4endl << G4endl; 604 G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl; 605 G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl; 606 G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl; 605 607 G4Exception("G4Orb::DistanceToOut(p)", "Notification", JustWarning, 606 608 "Point p is outside !?" ); -
trunk/source/geometry/solids/specific/History
r1228 r1315 1 $Id: History,v 1.1 60 2009/11/11 12:25:46gcosmo Exp $1 $Id: History,v 1.170 2010/06/11 09:42:59 gcosmo Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 17 17 * Reverse chronological order (last date on top), please * 18 18 ---------------------------------------------------------- 19 20 11-Jun-2010 T.Nikitina (geom-specific-V09-03-07) 21 - G4GenericTrap: fixed cases of zero dToIn/sToOut when vertices are collapsed 22 to triangle, line or point. Added new methods handling those specific cases. 23 - Added unit test for G4GenericTrap. 24 25 10-Jun-2010 I.Hrivnacova 26 - G4GenericTrap: fixed parameter names in CalculateExtent() for the test 27 case construction through tessellated facets. 28 29 09-Jun-2010 G.Cosmo 30 - G4GenericTrap: moved internal methods to private section and reordered 31 in source file. Added missing implementation for IsTwisted() method. 32 33 03-Jun-2010 T.Nikitina, G.Cosmo (geom-specific-V09-03-06) 34 - G4GenericTrap: 35 o Fixed initialization of fSurfaceArea and fCubicVolume and 36 calculation of surface area. 37 o Fixed error in Inside(p) function, and corrected use std::fabs() instead 38 of std::abs() for floating point values. 39 o Added missing initialisation of fpPolyhedron pointer. 40 o More corrected signatures for use of non-const references for vectors 41 passed as arguments to functions. 42 43 02-Jun-2010 G.Cosmo (geom-specific-V09-03-05) 44 - G4GenericTrap: use const reference for vector of vertices passed as argument 45 in constructor and accessor. 46 47 27-May-2010 T.Nikitina (geom-specific-V09-03-04) 48 - First implementation of G4GenericTrap shape, a new solid representing an 49 arbitrary trapezoid with up to 8 vertices standing on two parallel planes 50 perpendicular to the Z axis. 51 52 28-Apr-2010 P.R.Truscott (geom-specific-V09-03-03) 53 - Fix in G4TriangularFacet and G4TessellatedSolid to correct treatment of 54 optical photon transport related to internal reflection at surface. 55 Addresses problem report #1103. 56 57 15-Apr-2010 I.Hrivnacova (geom-specific-V09-03-02) 58 - G4ExtrudedSolid: eliminated requirement for clockwise ordering of polygon 59 vertices. Added a check for vertices ordering; if vertices are defined 60 anti-clockwise their ordering is reverted. 61 Fix in polygon facet triangularization for consequent concave vertices. 62 63 24-Feb-2010 G.Cosmo (geom-specific-V09-03-01) 64 - Adopt caching of Phi in G4PolyconeSide and G4PolyhedraSide to avoid 65 unnecessary consecutive computations on the same point. 66 67 10-Feb-2010 G.Cosmo (geom-specific-V09-03-00) 68 - Use kInfinity for initialising minimum and maximum allowed extent for 69 G4SolidExtentList of faceted solids. 19 70 20 71 11-Nov-2009 G.Cosmo (geom-specific-V09-02-08) -
trunk/source/geometry/solids/specific/include/G4ExtrudedSolid.hh
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4ExtrudedSolid.hh,v 1. 7 2008/02/27 12:32:48ivana Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4ExtrudedSolid.hh,v 1.8 2010/04/15 10:23:34 ivana Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 45 45 // const G4String& pName - solid name 46 46 // std::vector<G4TwoVector> polygon - the vertices of the outlined polygon 47 // defined in clock -wise order47 // defined in clockwise or anti-clockwise order 48 48 // std::vector<ZSection> - the z-sections defined by 49 49 // z position, offset and scale -
trunk/source/geometry/solids/specific/include/G4PolyconeSide.hh
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4PolyconeSide.hh,v 1.1 2 2008/05/15 11:41:58gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4PolyconeSide.hh,v 1.13 2010/02/24 11:18:25 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 114 114 protected: 115 115 116 G4double DistanceAway( const G4ThreeVector &p, G4bool opposite, 117 G4double &distOutside2, G4double *rzNorm=0 ); 118 119 G4bool PointOnCone( const G4ThreeVector &hit, G4double normSign, 120 const G4ThreeVector &p, 121 const G4ThreeVector &v, G4ThreeVector &normal ); 122 123 void CopyStuff( const G4PolyconeSide &source ); 124 125 static void FindLineIntersect( G4double x1, G4double y1, 126 G4double tx1, G4double ty1, 127 G4double x2, G4double y2, 128 G4double tx2, G4double ty2, 129 G4double &x, G4double &y ); 130 131 G4double GetPhi( const G4ThreeVector& p ); 132 133 protected: 134 116 135 G4double r[2], z[2]; // r, z parameters, in specified order 117 136 G4double startPhi, // Start phi (0 to 2pi), if phiIsOpen … … 136 155 G4ThreeVector *corners; // The coordinates of the corners (if phiIsOpen) 137 156 138 G4double DistanceAway( const G4ThreeVector &p, G4bool opposite,139 G4double &distOutside2, G4double *rzNorm=0 );140 141 G4bool PointOnCone( const G4ThreeVector &hit, G4double normSign,142 const G4ThreeVector &p,143 const G4ThreeVector &v, G4ThreeVector &normal );144 145 void CopyStuff( const G4PolyconeSide &source );146 147 static void FindLineIntersect( G4double x1, G4double y1,148 G4double tx1, G4double ty1,149 G4double x2, G4double y2,150 G4double tx2, G4double ty2,151 G4double &x, G4double &y );152 157 private: 153 158 159 std::pair<G4ThreeVector, G4double> fPhi; // Cached value for phi 154 160 G4double kCarTolerance; // Geometrical surface thickness 155 161 G4double fSurfaceArea; // Used for surface calculation -
trunk/source/geometry/solids/specific/include/G4PolyhedraSide.hh
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4PolyhedraSide.hh,v 1.1 1 2008/05/15 11:41:59gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4PolyhedraSide.hh,v 1.12 2010/02/24 11:18:25 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 166 166 167 167 G4int PhiSegment( G4double phi ); 168 168 169 G4double GetPhi( const G4ThreeVector& p ); 170 169 171 G4double DistanceToOneSide( const G4ThreeVector &p, 170 172 const G4PolyhedraSideVec &vec, … … 197 199 private: 198 200 201 std::pair<G4ThreeVector, G4double> fPhi; // Cached value for phi 199 202 G4double kCarTolerance; // Geometrical surface thickness 200 203 G4double fSurfaceArea; // Surface Area -
trunk/source/geometry/solids/specific/src/G4ExtrudedSolid.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4ExtrudedSolid.cc,v 1.1 8 2008/10/30 11:47:45ivana Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4ExtrudedSolid.cc,v 1.19 2010/04/15 10:23:34 ivana Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 40 40 #include <algorithm> 41 41 #include <cmath> 42 #include <iomanip> 42 43 43 44 #include "G4ExtrudedSolid.hh" … … 94 95 "Z-sections with the same z position are not supported."); 95 96 } 96 } 97 97 } 98 99 // Check if polygon vertices are defined clockwise 100 // (the area is positive if polygon vertices are defined anti-clockwise) 101 // 102 G4double area = 0.; 103 for ( G4int i=0; i<fNv; ++i ) { 104 G4int j = i+1; 105 if ( j == fNv ) j = 0; 106 area += 0.5 * ( polygon[i].x()*polygon[j].y() - polygon[j].x()*polygon[i].y()); 107 } 108 98 109 // Copy polygon 99 110 // 100 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); } 111 if ( area < 0. ) { 112 // Polygon vertices are defined clockwise, we just copy the polygon 113 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); } 114 } 115 else { 116 // Polygon vertices are defined anti-clockwise, we revert them 117 //G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", errorDescription, 118 // JustWarning, 119 // "Polygon vertices defined anti-clockwise, reverting polygon"); 120 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[fNv-i-1]); } 121 } 122 101 123 102 124 // Copy z-sections … … 148 170 } 149 171 172 // Check if polygon vertices are defined clockwise 173 // (the area is positive if polygon vertices are defined anti-clockwise) 174 175 G4double area = 0.; 176 for ( G4int i=0; i<fNv; ++i ) { 177 G4int j = i+1; 178 if ( j == fNv ) j = 0; 179 area += 0.5 * ( polygon[i].x()*polygon[j].y() - polygon[j].x()*polygon[i].y()); 180 } 181 150 182 // Copy polygon 151 183 // 152 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); } 184 if ( area < 0. ) { 185 // Polygon vertices are defined clockwise, we just copy the polygon 186 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); } 187 } 188 else { 189 // Polygon vertices are defined anti-clockwise, we revert them 190 //G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", errorDescription, 191 // JustWarning, 192 // "Polygon vertices defined anti-clockwise, reverting polygon"); 193 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[fNv-i-1]); } 194 } 153 195 154 196 // Copy z-sections … … 453 495 // 454 496 G4double angle = GetAngle(c2->first, c3->first, c1->first); 455 456 if ( angle > pi ) 497 //G4cout << "angle " << angle << G4endl; 498 499 G4int counter = 0; 500 while ( angle > pi ) 457 501 { 458 502 // G4cout << "Skipping concave vertex " << c2->second << G4endl; … … 467 511 // G4cout << "Looking at triangle : " 468 512 // << c1->second << " " << c2->second 469 // << " " << c3->second << G4endl; 470 513 // << " " << c3->second << G4endl; 514 515 angle = GetAngle(c2->first, c3->first, c1->first); 516 //G4cout << "angle " << angle << G4endl; 517 518 counter++; 519 520 if ( counter > fNv) { 521 G4Exception("G4ExtrudedSolid::AddGeneralPolygonFacets", "InvalidSetup" , 522 FatalException, "Triangularisation has failed."); 523 break; 524 } 471 525 } 472 526 … … 734 788 } 735 789 736 737 790 //_____________________________________________________________________________ 738 791 … … 751 804 for ( G4int i=0; i<fNv; ++i ) 752 805 { 753 os << " vx = " << fPolygon[i].x()/mm << " mm" 806 os << std::setw(5) << "#" << i 807 << " vx = " << fPolygon[i].x()/mm << " mm" 754 808 << " vy = " << fPolygon[i].y()/mm << " mm" << G4endl; 755 809 } … … 764 818 } 765 819 820 /* 821 // Triangles (for debogging) 822 os << G4endl; 823 os << " Triangles:" << G4endl; 824 os << " Triangle # vertex1 vertex2 vertex3" << G4endl; 825 826 G4int counter = 0; 827 std::vector< std::vector<G4int> >::const_iterator it; 828 for ( it = fTriangles.begin(); it != fTriangles.end(); it++ ) { 829 std::vector<G4int> triangle = *it; 830 os << std::setw(10) << counter++ 831 << std::setw(10) << triangle[0] << std::setw(10) << triangle[1] << std::setw(10) << triangle[2] 832 << G4endl; 833 } 834 */ 766 835 return os; 767 836 } -
trunk/source/geometry/solids/specific/src/G4PolyconeSide.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4PolyconeSide.cc,v 1.2 2 2009/11/11 12:23:37gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4PolyconeSide.cc,v 1.24 2010/02/24 11:31:49 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 67 67 kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance(); 68 68 fSurfaceArea = 0.0; 69 fPhi.first = G4ThreeVector(0,0,0); 70 fPhi.second= 0.0; 69 71 70 72 // … … 492 494 if (phiIsOpen) 493 495 { 494 G4double phi = axis.phi();496 G4double phi = GetPhi(axis); 495 497 while( phi < startPhi ) phi += twopi; 496 498 … … 853 855 } 854 856 857 // 858 // GetPhi 859 // 860 // Calculate Phi for a given 3-vector (point), if not already cached for the 861 // same point, in the attempt to avoid consecutive computation of the same 862 // quantity 863 // 864 G4double G4PolyconeSide::GetPhi( const G4ThreeVector& p ) 865 { 866 G4double val=0.; 867 868 if (fPhi.first != p) 869 { 870 val = p.phi(); 871 fPhi.first = p; 872 fPhi.second = val; 873 } 874 else 875 { 876 val = fPhi.second; 877 } 878 return val; 879 } 855 880 856 881 // … … 922 947 // Finally, check phi 923 948 // 924 G4double phi = p.phi();949 G4double phi = GetPhi(p); 925 950 while( phi < startPhi ) phi += twopi; 926 951 … … 978 1003 // PolyPhiFace. See PolyPhiFace::InsideEdgesExact 979 1004 // 980 G4double phi = hit.phi();1005 G4double phi = GetPhi(hit); 981 1006 while( phi < startPhi-phiTolerant ) phi += twopi; 982 1007 -
trunk/source/geometry/solids/specific/src/G4PolyhedraSide.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4PolyhedraSide.cc,v 1.1 5 2008/05/15 11:41:59 gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4PolyhedraSide.cc,v 1.17 2010/02/24 11:31:49 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 64 64 G4bool isAllBehind ) 65 65 { 66 67 66 kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance(); 68 67 fSurfaceArea=0.; 68 fPhi.first = G4ThreeVector(0,0,0); 69 fPhi.second= 0.0; 70 69 71 // 70 72 // Record values … … 561 563 // Try the closest phi segment first 562 564 // 563 G4int iPhi = ClosestPhiSegment( p.phi() );565 G4int iPhi = ClosestPhiSegment( GetPhi(p) ); 564 566 565 567 G4ThreeVector pdotc = p - vecs[iPhi].center; … … 594 596 // Which phi segment is closest to this point? 595 597 // 596 G4int iPhi = ClosestPhiSegment( p.phi() );598 G4int iPhi = ClosestPhiSegment( GetPhi(p) ); 597 599 598 600 G4double norm; … … 624 626 // Which phi segment is closest to this point? 625 627 // 626 G4int iPhi = ClosestPhiSegment( p.phi() );628 G4int iPhi = ClosestPhiSegment( GetPhi(p) ); 627 629 628 630 // … … 656 658 // Which phi segment, if any, does the axis belong to 657 659 // 658 iPhi = PhiSegment( axis.phi() );660 iPhi = PhiSegment( GetPhi(axis) ); 659 661 660 662 if (iPhi < 0) … … 971 973 972 974 // 975 // GetPhi 976 // 977 // Calculate Phi for a given 3-vector (point), if not already cached for the 978 // same point, in the attempt to avoid consecutive computation of the same 979 // quantity 980 // 981 G4double G4PolyhedraSide::GetPhi( const G4ThreeVector& p ) 982 { 983 G4double val=0.; 984 985 if (fPhi.first != p) 986 { 987 val = p.phi(); 988 fPhi.first = p; 989 fPhi.second = val; 990 } 991 else 992 { 993 val = fPhi.second; 994 } 995 return val; 996 } 997 998 999 // 973 1000 // DistanceToOneSide 974 1001 // -
trunk/source/geometry/solids/specific/src/G4SolidExtentList.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4SolidExtentList.cc,v 1. 5 2007/05/11 13:54:29gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4SolidExtentList.cc,v 1.6 2010/02/10 16:38:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 51 51 axis = kZAxis; 52 52 limited = false; 53 minLimit = - DBL_MAX;54 maxLimit = + DBL_MAX;53 minLimit = -kInfinity; 54 maxLimit = +kInfinity; 55 55 } 56 56 … … 72 72 else 73 73 { 74 minLimit = - DBL_MAX;75 maxLimit = + DBL_MAX;74 minLimit = -kInfinity; 75 maxLimit = +kInfinity; 76 76 } 77 77 } -
trunk/source/geometry/solids/specific/src/G4TessellatedSolid.cc
r1228 r1315 25 25 // ******************************************************************** 26 26 // 27 // $Id: G4TessellatedSolid.cc,v 1. 19 2009/04/27 08:06:27 gcosmoExp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4TessellatedSolid.cc,v 1.20 2010/04/28 16:21:21 flei Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 42 42 // CHANGE HISTORY 43 43 // -------------- 44 // 45 // 12 April 2010 P R Truscott, QinetiQ, bug fixes to treat optical 46 // photon transport, in particular internal reflection 47 // at surface. 44 48 // 45 49 // 14 November 2007 P R Truscott, QinetiQ & Stan Seibert, U Texas … … 670 674 if ((*f)->Intersect(p,v,false,dist,distFromSurface,normal)) 671 675 { 676 // 677 // 678 // Set minDist to the new distance to current facet if distFromSurface is in 679 // positive direction and point is not at surface. If the point is within 680 // 0.5*kCarTolerance of the surface, then force distance to be zero and 681 // leave member function immediately (for efficiency), as proposed by & credit 682 // to Akira Okumura. 683 // 672 684 if (distFromSurface > 0.5*kCarTolerance && dist >= 0.0 && dist < minDist) 673 685 { 674 686 minDist = dist; 687 } 688 else if (-0.5*kCarTolerance <= dist && dist <= 0.5*kCarTolerance) 689 { 690 return 0.0; 675 691 } 676 692 } -
trunk/source/geometry/solids/specific/src/G4TriangularFacet.cc
r1228 r1315 25 25 // ******************************************************************** 26 26 // 27 // $Id: G4TriangularFacet.cc,v 1.1 2 2008/11/13 08:25:07 gcosmoExp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4TriangularFacet.cc,v 1.13 2010/04/28 16:21:21 flei Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 56 56 // plane of the triangle. 57 57 // 58 // 12 April 2010 P R Truscott, QinetiQ, bug fixes to treat optical 59 // photon transport, in particular internal reflection 60 // at surface. 58 61 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 59 62 … … 350 353 // 351 354 // 352 // Do a heck for rounding errors in the distance-squared. 355 // Do a check for rounding errors in the distance-squared. It appears that 356 // the conventional methods for calculating sqrDist breaks down when very near 357 // to or at the surface (as required by transport). We'll therefore also use 358 // the magnitude-squared of the vector displacement. (Note that I've also 359 // tried to get around this problem by using the existing equations for 360 // 361 // sqrDist = function(a,b,c,d,s,t) 362 // 363 // and use a more accurate addition process which minimises errors and 364 // breakdown of cummutitivity [where (A+B)+C != A+(B+C)] but this still 365 // doesn't work. 366 // Calculation from u = D + s*E[0] + t*E[1] is less efficient, but appears 367 // more robust. 353 368 // 354 369 if (sqrDist < 0.0) { sqrDist = 0.0; } 355 356 return D + s*E[0] + t*E[1]; 370 G4ThreeVector u = D + s*E[0] + t*E[1]; 371 G4double u2 = u.mag2(); 372 // 373 // 374 // The following (part of the roundoff error check) is from Oliver Merle's 375 // updates. 376 // 377 if ( sqrDist > u2 ) sqrDist = u2; 378 379 return u; 357 380 } 358 381 … … 542 565 // we intersect. 543 566 // 544 distance = -0.5*kCarTolerance; 567 // distance = -0.5*kCarTolerance; 568 distance = 0.0; 545 569 normal = surfaceNormal; 546 570 return true; … … 728 752 return area; 729 753 } 754 //////////////////////////////////////////////////////////////////////// 755 // -
trunk/source/geometry/volumes/History
r1228 r1315 1 $Id: History,v 1.1 63 2009/11/06 11:35:03gcosmo Exp $1 $Id: History,v 1.170 2010/04/23 10:27:49 gcosmo Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 17 17 * Reverse chronological order (last date on top), please * 18 18 ---------------------------------------------------------- 19 20 Apr 23rd, 2010 G.Cosmo - geomvol-V09-03-06 21 - Corrected initialisation of dummy copy-ctor in G4EnhancedVecAllocator, 22 fixing compilation problem on WIN32-VC. 23 24 Apr 22nd, 2010 G.Cosmo - geomvol-V09-03-05 25 - Make use of specialized allocator for handling internal vector in 26 G4NavigatorHistory, globally controlling the memory pool. 27 Measured ~2% average run-time speed-up. 28 29 Apr 15th, 2010 G.Cosmo - geomvol-V09-03-04 30 - Combine use of G4Allocator for vectors in G4NavigationHistory with use 31 of assign(). 32 33 Apr 13th, 2010 G.Cosmo - geomvol-V09-03-03 34 - Added Reset() method to G4ReflectionFactory for clearing maps of 35 constituent and reflected volumes. 36 37 Apr 9th, 2010 G.Cosmo - geomvol-V09-03-02 38 - Use more elegant solution in G4NavigationHistory copy-ctor. Adopt assign(). 39 40 Mar 31th, 2010 G.Cosmo - geomvol-V09-03-01 41 - Restore original vector allocation, but adopt simple loop copy within 42 copy-constructor. Should provide slight performance improvement and keep 43 locality. 44 45 Dec 11th, 2009 G.Cosmo - geomvol-V09-03-00 46 - Use G4Allocator for vectors in G4NavigationHistory, to optimise memory 47 management and reduce fragmentation. 19 48 20 49 Nov 6th, 2009 G.Cosmo - geomvol-V09-02-04 -
trunk/source/geometry/volumes/include/G4NavigationHistory.hh
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4NavigationHistory.hh,v 1.1 4 2009/11/03 09:15:51gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4NavigationHistory.hh,v 1.18 2010/04/22 09:06:50 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // class G4NavigationHistory … … 47 47 #include "geomdefs.hh" 48 48 49 //#include "G4Allocator.hh"50 49 #include "G4AffineTransform.hh" 51 50 #include "G4VPhysicalVolume.hh" 52 51 #include "G4NavigationLevel.hh" 52 #include "G4EnhancedVecAllocator.hh" 53 53 54 54 #include <vector> … … 142 142 private: 143 143 144 std::vector<G4NavigationLevel> fNavHistory; 145 //std::vector<G4NavigationLevel, G4Allocator<G4NavigationLevel> > fNavHistory; 144 std::vector<G4NavigationLevel, 145 G4EnhancedVecAllocator<G4NavigationLevel> > fNavHistory; 146 // The geometrical tree; uses specialized allocator to optimize 147 // memory handling and reduce possible fragmentation 146 148 147 149 G4int fStackDepth; -
trunk/source/geometry/volumes/include/G4ReflectionFactory.hh
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4ReflectionFactory.hh,v 1. 4 2008/11/13 09:33:20gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4ReflectionFactory.hh,v 1.5 2010/04/13 07:19:01 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 181 181 // been reflected, after that placement or replication is performed. 182 182 183 void Reset(); 184 // Resets maps of constituent and reflected volumes. 185 // To be used exclusively when volumes are removed from the stores. 186 183 187 protected: 184 188 -
trunk/source/geometry/volumes/src/G4NavigationHistory.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4NavigationHistory.cc,v 1.1 1 2009/08/03 16:27:37gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4NavigationHistory.cc,v 1.15 2010/04/22 09:06:50 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 38 38 #include "G4ios.hh" 39 39 40 // Initialise static data for the specialized memory pool 41 // for the internal STL vector of histories ... 42 // 43 G4ChunkIndexType* G4AllocStats::allocStat = 0; 44 G4int G4AllocStats::totSpace = 0; 45 G4int G4AllocStats::numCat = 0; 46 40 47 G4NavigationHistory::G4NavigationHistory() 41 48 : fNavHistory(kHistoryMax), fStackDepth(0) … … 45 52 46 53 G4NavigationHistory::G4NavigationHistory(const G4NavigationHistory &h) 47 : f NavHistory(h.fNavHistory), fStackDepth(h.fStackDepth)54 : fStackDepth(h.fStackDepth) 48 55 { 56 fNavHistory.assign(h.fNavHistory.begin(),h.fNavHistory.end()); 49 57 } 50 58 -
trunk/source/geometry/volumes/src/G4ReflectionFactory.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4ReflectionFactory.cc,v 1. 9 2008/11/13 09:33:20gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 3$27 // $Id: G4ReflectionFactory.cc,v 1.10 2010/04/13 07:19:01 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 761 761 //_____________________________________________________________________________ 762 762 763 void 764 G4ReflectionFactory::Reset() 765 { 766 fConstituentLVMap.~map(); 767 fReflectedLVMap.~map(); 768 } 769 770 //_____________________________________________________________________________ 771 763 772 void G4ReflectionFactory::PrintConstituentLVMap() 764 773 {
Note:
See TracChangeset
for help on using the changeset viewer.
