Changeset 1315 for trunk/source/geometry/solids/specific/src
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (15 years ago)
- Location:
- trunk/source/geometry/solids/specific/src
- Files:
-
- 6 edited
-
G4ExtrudedSolid.cc (modified) (9 diffs)
-
G4PolyconeSide.cc (modified) (6 diffs)
-
G4PolyhedraSide.cc (modified) (7 diffs)
-
G4SolidExtentList.cc (modified) (3 diffs)
-
G4TessellatedSolid.cc (modified) (3 diffs)
-
G4TriangularFacet.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 //
Note:
See TracChangeset
for help on using the changeset viewer.
