Ignore:
Timestamp:
Nov 5, 2010, 3:45:55 PM (14 years ago)
Author:
garnier
Message:

update ti head

Location:
trunk/source/geometry/management
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/geometry/management/GNUmakefile

    r831 r1340  
    1 # $Id: GNUmakefile,v 1.5 2004/11/12 09:05:05 gcosmo Exp $
     1# $Id: GNUmakefile,v 1.6 2010/10/19 10:18:01 gcosmo Exp $
    22# -----------------------------------------------------------------------
    33# GNUmakefile for geometry/management library.  Gabriele Cosmo, 16/11/96.
     
    1212include $(G4INSTALL)/config/architecture.gmk
    1313
    14 CPPFLAGS += -DG4GEOM_ALLOC_EXPORT
     14CPPFLAGS += -DG4ALLOC_EXPORT
    1515CPPFLAGS += -I$(G4BASE)/graphics_reps/include \
    1616            -I$(G4BASE)/intercoms/include \
  • trunk/source/geometry/management/History

    r1315 r1340  
    1 $Id: History,v 1.139 2010/02/09 16:50:44 gcosmo Exp $
     1$Id: History,v 1.145 2010/10/19 15:20:33 gcosmo Exp $
    22-------------------------------------------------------------------
    33
     
    1717     * Reverse chronological order (last date on top), please *
    1818     ----------------------------------------------------------
     19
     20October 19, 2010  G.Cosmo                  geommng-V09-03-05
     21- Added Clone() virtual method to G4VSolid, to return a pointer to a
     22  dynamically allocated copy of the solid. To be used by Geant4-MT.
     23- Added copy-ctr and assignment operator to G4ReflectedSolid, now also
     24  implementing the Clone() method.
     25
     26September 6, 2010  G.Cosmo                 geommng-V09-03-04
     27- Fixed false-positive null forward case in G4SmartVoxelHeader.
     28
     29July 16, 2010  G.Cosmo                     geommng-V09-03-03
     30- Fixed compilation errors for code within G4GEOMETRY_VOXELDEBUG flag
     31  in G4GeometryManager and G4SmartVoxelHeader.
     32- Added printout of voxel limits in G4SmartVoxelHeader::Buildnodes() and
     33  removed protection on node width previously introduced.
     34
     35July 13, 2010  G.Cosmo                     geommng-V09-03-02
     36- G4SmartVoxelHeader: added protection against rare cases of zero computed
     37  node width in BuildNodes().
     38
     39July 2, 2010  G.Cosmo                      geommng-V09-03-01
     40- G4LogicalSurface: added missing initialisation for 'theTransRadSurface'
     41  data member. Made virtual destructor and constructors not inline.
     42- G4ErrorTarget: added missing default initialisation of a data member.
     43- G4SmartVoxelHeader: added return statement after exceptions in methods
     44  BuildVoxelsWithinLimits() and BuildNodes(); fixed case of invalid iterator
     45  in deletion of test slices in BuildVoxelsWithinLimits(); added protection
     46  for cases of invalide number of nodes in RefineNodes(), and added return
     47  statement after exceptions.
     48- G4GeometryManager: restore cout precision after printing voxel statistics.
     49- G4LogicalVolume: added return statement after exception in GetMass().
     50- G4ReflectedSolid: moved reserve() statement for 'vertices' within null-check
     51  condition in CalculateExtent() ...
    1952
    2053February 9, 2010  G.Cosmo                  geommng-V09-03-00
  • trunk/source/geometry/management/include/G4LogicalSurface.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4LogicalSurface.hh,v 1.11 2009/04/21 15:18:15 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4LogicalSurface.hh,v 1.12 2010/07/05 09:22:58 gcosmo Exp $
     28// GEANT4 tag $Name: geommng-V09-03-05 $
    2929//
    3030////////////////////////////////////////////////////////////////////////
     
    5353// Data members:
    5454//   G4String                       theName
    55 //   G4SurfaceProperty*              theSurfaceProperty
     55//   G4SurfaceProperty*             theSurfaceProperty
    5656//   G4TransitionRadiationSurface*  theTransRadSurface
    5757
     
    8383 public:  // with description
    8484
    85    G4SurfaceProperty*  GetSurfaceProperty() const;
    86    void    SetSurfaceProperty(G4SurfaceProperty* ptrSurfaceProperty);
     85   inline G4SurfaceProperty*  GetSurfaceProperty() const;
     86   inline void SetSurfaceProperty(G4SurfaceProperty* ptrSurfaceProperty);
    8787
    88    const G4String& GetName() const;
    89    void    SetName(const G4String& name);
     88   inline const G4String& GetName() const;
     89   inline void SetName(const G4String& name);
    9090
    91    G4TransitionRadiationSurface* GetTransitionRadiationSurface() const;
    92    void SetTransitionRadiationSurface(G4TransitionRadiationSurface* tRadSurf);
     91   inline G4TransitionRadiationSurface* GetTransitionRadiationSurface() const;
     92   inline void SetTransitionRadiationSurface(G4TransitionRadiationSurface* tRadSurf);
    9393
    9494 public:  // without description
     
    9696   virtual ~G4LogicalSurface();
    9797
    98    G4int operator==(const G4LogicalSurface &right) const;
    99    G4int operator!=(const G4LogicalSurface &right) const;
     98   inline G4int operator==(const G4LogicalSurface &right) const;
     99   inline G4int operator!=(const G4LogicalSurface &right) const;
    100100
    101101 protected:
     
    103103   // There should be no instances of this class
    104104
    105    G4LogicalSurface(const G4String& name, G4SurfaceProperty* surfaceProperty);
     105   G4LogicalSurface(const G4String& name, G4SurfaceProperty* prop);
    106106     // Is the name more meaningful for the properties or the logical surface ?
    107107
    108  private:
     108 private:  // Copying restricted
    109109
    110    G4LogicalSurface(const G4LogicalSurface &right); // Copying restricted
    111    const G4LogicalSurface& operator=(const G4LogicalSurface& right);
     110   G4LogicalSurface(const G4LogicalSurface &right);
     111   inline const G4LogicalSurface& operator=(const G4LogicalSurface& right);
    112112
    113113 private:
  • trunk/source/geometry/management/include/G4LogicalSurface.icc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4LogicalSurface.icc,v 1.10 2009/04/21 15:18:15 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4LogicalSurface.icc,v 1.11 2010/07/05 09:22:58 gcosmo Exp $
     28// GEANT4 tag $Name: geommng-V09-03-05 $
    2929//
    3030////////////////////////////////////////////////////////////////////////
     
    4242G4LogicalSurface::GetSurfaceProperty() const
    4343{
    44         return theSurfaceProperty;
     44  return theSurfaceProperty;
    4545}
    4646
     
    4848G4LogicalSurface::SetSurfaceProperty(G4SurfaceProperty* ptrSurfaceProperty)
    4949{
    50         theSurfaceProperty = ptrSurfaceProperty;
     50  theSurfaceProperty = ptrSurfaceProperty;
    5151}
    5252
     
    5454G4LogicalSurface::GetName() const
    5555{
    56         return theName;
     56  return theName;
    5757}
    5858
     
    6060G4LogicalSurface::SetName(const G4String& name)
    6161{
    62         theName = name;
     62  theName = name;
    6363}
    6464
     
    6666G4LogicalSurface::GetTransitionRadiationSurface() const
    6767{
    68         return theTransRadSurface;
     68  return theTransRadSurface;
    6969}
    7070
     
    7373                                                transRadSurf )
    7474{
    75         theTransRadSurface= transRadSurf;
     75  theTransRadSurface= transRadSurf;
    7676}
    77 
    7877
    7978  //////////////
     
    8483G4LogicalSurface::operator=(const G4LogicalSurface &right)
    8584{
    86         if (&right == this) return *this;
    87         theName = right.theName;
    88         theSurfaceProperty = right.theSurfaceProperty;
    89         theTransRadSurface = right.theTransRadSurface;
     85  if (&right == this)  { return *this; }
     86  theName = right.theName;
     87  theSurfaceProperty = right.theSurfaceProperty;
     88  theTransRadSurface = right.theTransRadSurface;
    9089       
    91         return *this;
     90  return *this;
    9291}
    9392
     
    9594G4LogicalSurface::operator==(const G4LogicalSurface &right) const
    9695{
    97         return (this == (G4LogicalSurface *) &right);
     96  return (this == (G4LogicalSurface *) &right);
    9897}
    9998
     
    101100G4LogicalSurface::operator!=(const G4LogicalSurface &right) const
    102101{
    103         return (this != (G4LogicalSurface *) &right);
     102  return (this != (G4LogicalSurface *) &right);
    104103}
    105 
    106   /////////////////
    107   // Constructors
    108   /////////////////
    109 
    110 inline G4LogicalSurface::G4LogicalSurface(const G4String&         name,
    111                                          G4SurfaceProperty* surfaceProperty)
    112   : theName(name), theSurfaceProperty(surfaceProperty)
    113 {
    114 }
    115 
    116 inline G4LogicalSurface::G4LogicalSurface(const G4LogicalSurface &right)
    117 {
    118         *this = right;
    119 }
    120 
    121 inline G4LogicalSurface::~G4LogicalSurface()
    122 {
    123 }
  • trunk/source/geometry/management/include/G4ReflectedSolid.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4ReflectedSolid.hh,v 1.5 2006/06/29 18:31:03 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4ReflectedSolid.hh,v 1.6 2010/10/19 15:20:18 gcosmo Exp $
     28// GEANT4 tag $Name: geommng-V09-03-05 $
    2929//
    3030//
     
    9494    G4ThreeVector GetPointOnSurface() const;
    9595
     96    G4VSolid* Clone() const;
     97
    9698  public:  // with description
    9799
     
    114116
    115117  public:  // without description
     118
     119    G4ReflectedSolid(const G4ReflectedSolid& rhs);
     120    G4ReflectedSolid& operator=(const G4ReflectedSolid& rhs);
     121      // Copy constructor and assignment operator.
    116122
    117123    void DescribeYourselfTo ( G4VGraphicsScene& scene ) const ;
     
    149155    mutable G4Polyhedron* fpPolyhedron;  // Caches reflected G4Polyhedron.
    150156
    151   private:
    152 
    153     G4ReflectedSolid(const G4ReflectedSolid&);
    154     G4ReflectedSolid& operator=(const G4ReflectedSolid&);
    155       // Private copy constructor and assignment operator.
    156157} ;
    157158
  • trunk/source/geometry/management/include/G4VSolid.hh

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4VSolid.hh,v 1.29 2008/09/10 13:18:42 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4VSolid.hh,v 1.30 2010/10/19 15:19:37 gcosmo Exp $
     28// GEANT4 tag $Name: geommng-V09-03-05 $
    2929//
    3030//
     
    193193      // Returns a random point located on the surface of the solid.
    194194
     195    virtual G4VSolid* Clone() const;
     196      // Returns a pointer of a dynamically allocated copy of the solid.
     197      // Returns NULL pointer with warning in case the concrete solid does not
     198      // implement this method. The caller has responsibility for ownership.
     199
    195200    virtual std::ostream& StreamInfo(std::ostream& os) const = 0;
    196201      // Dumps contents of the solid to a stream.
  • trunk/source/geometry/management/src/G4ErrorTarget.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4ErrorTarget.cc,v 1.1 2007/05/16 12:50:52 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4ErrorTarget.cc,v 1.2 2010/07/05 09:22:58 gcosmo Exp $
     28// GEANT4 tag $Name: geommng-V09-03-05 $
    2929//
    3030//
     
    3535#include "G4ErrorTarget.hh"
    3636
    37 G4ErrorTarget::G4ErrorTarget(){}
    38 G4ErrorTarget::~G4ErrorTarget(){}
     37G4ErrorTarget::G4ErrorTarget()
     38 : theType(G4ErrorTarget_GeomVolume) {}
     39
     40G4ErrorTarget::~G4ErrorTarget() {}
    3941
    4042G4double G4ErrorTarget::GetDistanceFromPoint( const G4ThreeVector&,
  • trunk/source/geometry/management/src/G4GeometryManager.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4GeometryManager.cc,v 1.22 2008/05/16 13:46:48 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4GeometryManager.cc,v 1.24 2010/07/16 15:52:57 gcosmo Exp $
     28// GEANT4 tag $Name: geommng-V09-03-05 $
    2929//
    3030// class G4GeometryManager
     
    261261#ifdef G4GEOMETRY_VOXELDEBUG
    262262     G4cout << "**** G4GeometryManager::BuildOptimisations" << G4endl
    263             << "     Skipping logical volume name = " << volume->GetName()
     263            << "     Skipping logical volume name = " << tVolume->GetName()
    264264            << G4endl;
    265265#endif
     
    359359         << totalMemory/1024 << " kByte" << G4endl;
    360360  G4cout << "    Total CPU time elapsed for geometry optimisation: "
    361          << std::setprecision(2) << totalCpuTime << " seconds" << G4endl;
     361         << std::setprecision(2) << totalCpuTime << " seconds"
     362         << std::setprecision(6) << G4endl;
    362363 
    363364  //
  • trunk/source/geometry/management/src/G4LogicalVolume.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4LogicalVolume.cc,v 1.34 2009/09/24 13:22:57 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4LogicalVolume.cc,v 1.35 2010/07/05 09:22:58 gcosmo Exp $
     28// GEANT4 tag $Name: geommng-V09-03-05 $
    2929//
    3030//
     
    211211    G4Exception("G4LogicalVolume::GetMass()", "InvalidSetup", FatalException,
    212212                "No material associated to the logical volume !");
     213    return 0;
    213214  }
    214215  if (!fSolid)
     
    219220    G4Exception("G4LogicalVolume::GetMass()", "InvalidSetup", FatalException,
    220221                "No solid associated to the logical volume !");
     222    return 0;
    221223  }
    222224  G4double globalDensity = logMaterial->GetDensity();
  • trunk/source/geometry/management/src/G4ReflectedSolid.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4ReflectedSolid.cc,v 1.11 2006/11/08 09:56:33 gcosmo Exp $
    28 //
    29 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4ReflectedSolid.cc,v 1.13 2010/10/19 15:20:18 gcosmo Exp $
     28//
     29// GEANT4 tag $Name: geommng-V09-03-05 $
    3030//
    3131// Implementation for G4ReflectedSolid class for boolean
     
    9393}
    9494
     95///////////////////////////////////////////////////////////////////
     96//
     97
     98G4ReflectedSolid::G4ReflectedSolid(const G4ReflectedSolid& rhs)
     99  : G4VSolid(rhs), fPtrSolid(rhs.fPtrSolid), fpPolyhedron(0)
     100{
     101  fPtrTransform      = new G4AffineTransform(*rhs.fPtrTransform);
     102  fDirectTransform   = new G4AffineTransform(*rhs.fDirectTransform);
     103  fPtrTransform3D    = new G4Transform3D(*rhs.fPtrTransform3D);
     104  fDirectTransform3D = new G4Transform3D(*rhs.fDirectTransform3D);
     105}
     106
     107///////////////////////////////////////////////////////////////////
     108//
     109
     110G4ReflectedSolid& G4ReflectedSolid::operator=(const G4ReflectedSolid& rhs)
     111{
     112  // Check assignment to self
     113  //
     114  if (this == &rhs)  { return *this; }
     115
     116  // Copy base class data
     117  //
     118  G4VSolid::operator=(rhs);
     119
     120  // Copy data
     121  //
     122  fPtrSolid= rhs.fPtrSolid; fpPolyhedron= 0;
     123  delete fPtrTransform;
     124  fPtrTransform= new G4AffineTransform(*rhs.fPtrTransform);
     125  delete fDirectTransform;
     126  fDirectTransform= new G4AffineTransform(*rhs.fDirectTransform);
     127  delete fPtrTransform3D;
     128  fPtrTransform3D= new G4Transform3D(*rhs.fPtrTransform3D);
     129  delete fDirectTransform3D;
     130  fDirectTransform3D= new G4Transform3D(*rhs.fDirectTransform3D);
     131
     132  return *this;
     133}
     134
     135///////////////////////////////////////////////////////////////////
     136//
     137
    95138G4GeometryType G4ReflectedSolid::GetEntityType() const
    96139{
     
    257300  G4Point3D tmpPoint;
    258301
    259 // Calculate rotated vertex coordinates
     302  // Calculate rotated vertex coordinates
    260303
    261304  G4ThreeVectorList* vertices = new G4ThreeVectorList();
    262   vertices->reserve(8);
    263305
    264306  if (vertices)
    265307  {
     308    vertices->reserve(8);
     309
    266310    G4ThreeVector vertex0(x1,y1,z1) ;
    267311    tmpPoint    = transform3D*G4Point3D(vertex0);
     
    494538{
    495539  DumpInfo();
    496   G4Exception("G4BooleanSolid::ComputeDimensions()",
     540  G4Exception("G4ReflectedSolid::ComputeDimensions()",
    497541               "NotApplicable", FatalException,
    498542               "Method not applicable in this context!");
     
    511555  return G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z());
    512556}
     557
     558//////////////////////////////////////////////////////////////////////////
     559//
     560// Make a clone of this object
     561
     562G4VSolid* G4ReflectedSolid::Clone() const
     563{
     564  return new G4ReflectedSolid(*this);
     565}
     566
    513567
    514568//////////////////////////////////////////////////////////////////////////
  • trunk/source/geometry/management/src/G4SmartVoxelHeader.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4SmartVoxelHeader.cc,v 1.35 2010/02/09 16:50:25 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4SmartVoxelHeader.cc,v 1.39 2010/09/06 09:39:21 gcosmo Exp $
     28// GEANT4 tag $Name: geommng-V09-03-05 $
    2929//
    3030//
     
    148148      }
    149149    }
    150       else
     150    else
    151151    {
    152152      dyingNode = fslices[node]->GetNode();
     
    510510          pTestSlices->pop_back();
    511511          for (G4ProxyVector::iterator i=pTestSlices->begin();
    512                                        i!=pTestSlices->end(); i++)
     512                                       i!=pTestSlices->end(); )
    513513          {
    514514            if (*i==tmpProx)
    515515            {
    516               pTestSlices->erase(i); i--;
     516              i = pTestSlices->erase(i);
     517            }
     518            else
     519            {
     520              ++i;
    517521            }
    518522          }
    519523          if ( tmpProx ) { delete tmpProx; }
    520         } 
     524        }
    521525        delete pTestSlices;
    522526      }
     
    534538                "InvalidSetup", FatalException,
    535539                "Cannot select more than 3 axis for optimisation.");
     540    return;
    536541  }
    537542
     
    548553
    549554#ifdef G4GEOMETRY_VOXELDEBUG
    550   G4cout << G4endl << "     Selected axis = " << faxis << G4endl;
     555  G4cout << G4endl << "     Volume = " << pVolume->GetName()
     556         << G4endl << "     Selected axis = " << faxis << G4endl;
    551557  for (size_t islice=0; islice<fslices.size(); islice++)
    552558  {
     
    808814      G4Exception("G4SmartVoxelHeader::BuildNodes()", "InvalidSetup",
    809815                  FatalException, "Missing parameterisation.");
     816      return 0;
    810817    }
    811818
     
    864871    minExtents[nVol] = targetMinExtent;
    865872    maxExtents[nVol] = targetMaxExtent;
     873
     874#ifdef G4GEOMETRY_VOXELDEBUG
     875   G4cout << "---------------------------------------------------" << G4endl
     876          << "     Volume = " << pDaughter->GetName() << G4endl
     877          << " Min Extent = " << targetMinExtent << G4endl
     878          << " Max Extent = " << targetMaxExtent << G4endl
     879          << "---------------------------------------------------" << G4endl;
     880#endif
    866881
    867882    // Check not entirely outside mother when processing toplevel nodes
     
    960975  G4double nodeWidth = (motherMaxExtent-motherMinExtent)/noNodes;
    961976
    962 // Create G4VoxelNodes. Will Add proxies before setting fslices
    963 //
     977  // Create G4VoxelNodes. Will Add proxies before setting fslices
     978  //
    964979  G4NodeVector* nodeList = new G4NodeVector();
    965   nodeList->reserve(noNodes);
    966980  if (!nodeList)
    967981  {
     
    970984    G4Exception("G4SmartVoxelHeader::BuildNodes()", "FatalError",
    971985                FatalException, "NodeList allocation error.");
    972   }
     986    return 0;
     987  }
     988  nodeList->reserve(noNodes);
     989
    973990  for (nNode=0; nNode<noNodes; nNode++)
    974991  {
     
    981998      G4Exception("G4SmartVoxelHeader::BuildNodes()", "FatalError",
    982999                  FatalException, "Node allocation error.");
     1000      return 0;
    9831001    }
    9841002    nodeList->push_back(pNode);
     
    10261044  //
    10271045  G4ProxyVector* proxyList = new G4ProxyVector();
    1028   proxyList->reserve(noNodes);
    10291046  if (!proxyList)
    10301047  {
     
    10331050    G4Exception("G4SmartVoxelHeader::BuildNodes()", "FatalError",
    10341051                FatalException, "Proxy list allocation error.");
    1035   }
     1052    return 0;
     1053  }
     1054  proxyList->reserve(noNodes);
     1055
    10361056  //
    10371057  // Fill proxy List
     
    10491069      G4Exception("G4SmartVoxelHeader::BuildNodes()", "FatalError",
    10501070                  FatalException, "Proxy node allocation failed.");
     1071      return 0;
    10511072    }
    10521073    proxyList->push_back(pProxyNode);
     
    11961217        noContainedDaughters = targetNode->GetNoContained();
    11971218        targetList = new G4VolumeNosVector();
    1198         targetList->reserve(noContainedDaughters);
    11991219        if (!targetList)
    12001220        {
     
    12051225                      "FatalError", FatalException,
    12061226                      "Target volume node list allocation error.");
    1207         }
     1227          return;
     1228        }
     1229        targetList->reserve(noContainedDaughters);
    12081230        for (i=0; i<noContainedDaughters; i++)
    12091231        {
     
    12181240               << " - " << maxNo << " inclusive" << G4endl;
    12191241#endif
     1242        if (minNo > maxNo)    // Delete node and list to be replaced
     1243        {                     // and avoid further action ...
     1244          delete targetNode;
     1245          delete targetList;
     1246          return;
     1247        }
     1248
    12201249        // Delete node proxies at start of collected sets of nodes/headers
    12211250        //
     
    12461275          G4Exception("G4SmartVoxelHeader::RefineNodes()", "FatalError",
    12471276                      FatalException, "Refined VoxelHeader allocation error.");
     1277          return;
    12481278        }
    12491279        replaceHeader->SetMinEquivalentSliceNo(minNo);
    12501280        replaceHeader->SetMaxEquivalentSliceNo(maxNo);
    12511281        replaceHeaderProxy = new G4SmartVoxelProxy(replaceHeader);
    1252         if (!replaceHeader)
     1282        if (!replaceHeaderProxy)
    12531283        {
    12541284          G4cerr << "ERROR - G4SmartVoxelHeader::RefineNodes()" << G4endl
     
    12561286          G4Exception("G4SmartVoxelHeader::RefineNodes()", "FatalError",
    12571287                      FatalException, "Refined VoxelProxy allocation error.");
     1288          return;
    12581289        }
    12591290        for (replaceNo=minNo; replaceNo<=maxNo; replaceNo++)
  • trunk/source/geometry/management/src/G4VSolid.cc

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