Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:59

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4BooleanSolid
0027 //
0028 // Class description:
0029 //
0030 // Abstract base class for solids created by boolean operations
0031 // between other solids.
0032 
0033 // 10.09.98 V.Grichine - created
0034 // --------------------------------------------------------------------
0035 #ifndef G4BOOLEANSOLID_HH
0036 #define G4BOOLEANSOLID_HH
0037 
0038 #include "G4DisplacedSolid.hh"
0039 
0040 #include "G4ThreeVector.hh"
0041 #include "G4RotationMatrix.hh"
0042 #include "G4Transform3D.hh"
0043 
0044 #include "G4VBooleanProcessor.hh"
0045 
0046 class HepPolyhedronProcessor;
0047 
0048 
0049 class G4BooleanSolid : public G4VSolid
0050 {
0051   public:
0052  
0053     G4BooleanSolid( const G4String& pName,
0054                           G4VSolid* pSolidA ,
0055                           G4VSolid* pSolidB   );
0056 
0057     G4BooleanSolid( const G4String& pName,
0058                           G4VSolid* pSolidA ,
0059                           G4VSolid* pSolidB,
0060                           G4RotationMatrix* rotMatrix,
0061                     const G4ThreeVector& transVector    );
0062 
0063     G4BooleanSolid( const G4String& pName,
0064                           G4VSolid* pSolidA ,
0065                           G4VSolid* pSolidB , 
0066                     const G4Transform3D& transform   );
0067 
0068     ~G4BooleanSolid() override;
0069 
0070     const G4VSolid* GetConstituentSolid(G4int no) const override;
0071           G4VSolid* GetConstituentSolid(G4int no) override;
0072       // If Solid is made up from a Boolean operation of two solids,
0073       // return the corresponding solid (for no=0 and 1).
0074       // If the solid is not a "Boolean", return 0.
0075 
0076     G4double GetCubicVolume() override;
0077     inline G4double GetSurfaceArea() override;
0078 
0079     G4GeometryType  GetEntityType() const override;
0080     G4Polyhedron* GetPolyhedron () const override;
0081 
0082     std::ostream& StreamInfo(std::ostream& os) const override;
0083 
0084     inline G4int GetCubVolStatistics() const;
0085     inline G4double GetCubVolEpsilon() const;
0086     inline void SetCubVolStatistics(G4int st);
0087     inline void SetCubVolEpsilon(G4double ep);
0088    
0089     inline G4int GetAreaStatistics() const;
0090     inline G4double GetAreaAccuracy() const;
0091     inline void SetAreaStatistics(G4int st);
0092     inline void SetAreaAccuracy(G4double ep);
0093    
0094     G4ThreeVector GetPointOnSurface() const override;
0095 
0096     G4BooleanSolid(__void__&);
0097       // Fake default constructor for usage restricted to direct object
0098       // persistency for clients requiring preallocation of memory for
0099       // persistifiable objects.
0100 
0101     G4BooleanSolid(const G4BooleanSolid& rhs);
0102     G4BooleanSolid& operator=(const G4BooleanSolid& rhs);
0103       // Copy constructor and assignment operator.
0104 
0105     static void SetExternalBooleanProcessor(G4VBooleanProcessor* extProcessor);
0106       // Set Boolean processor to replace default processor.
0107     static G4VBooleanProcessor* GetExternalBooleanProcessor();
0108       // Get Boolean processor needed for G4MultiUnion.
0109 
0110   protected:
0111   
0112     void GetListOfPrimitives(std::vector<std::pair<G4VSolid *,G4Transform3D>>&,
0113                              const G4Transform3D&) const;
0114       // Get list of constituent primitives of the solid and their placements.
0115 
0116     G4Polyhedron* StackPolyhedron(HepPolyhedronProcessor&,
0117                                   const G4VSolid*) const;
0118       // Stack polyhedra for processing. Return top polyhedron.
0119 
0120   protected:
0121   
0122     G4VSolid* fPtrSolidA = nullptr;
0123     G4VSolid* fPtrSolidB = nullptr;
0124 
0125     G4double fCubicVolume = -1.0;
0126       // Cached value of fCubicVolume 
0127     G4double fSurfaceArea = -1.0;
0128       // Cached value of Surface Area
0129 
0130     static G4VBooleanProcessor* fExternalBoolProcessor;
0131       // External Boolean processor
0132 
0133   private:
0134 
0135     G4int    fCubVolStatistics = 1000000;
0136     G4int    fAreaStatistics = 1000000;
0137     G4double fCubVolEpsilon = 0.001;
0138     G4double fAreaAccuracy = -1;
0139 
0140     mutable G4bool fRebuildPolyhedron = false;
0141     mutable G4Polyhedron* fpPolyhedron = nullptr;
0142 
0143     mutable std::vector<std::pair<G4VSolid *,G4Transform3D>> fPrimitives;
0144     mutable G4double fPrimitivesSurfaceArea = 0.0;
0145 
0146     G4bool  createdDisplacedSolid = false;
0147       // If & only if this object created it, it must delete it
0148 };
0149 
0150 #include "G4BooleanSolid.icc"
0151 
0152 #endif