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