Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:41

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 //
0027 //
0028 // 
0029 // John Allison  31st December 1997.
0030 //
0031 // Class Description:
0032 //
0033 // Parameters associated with the modeling of GEANT4 objects.
0034 
0035 #ifndef G4MODELINGPARAMETERS_HH
0036 #define G4MODELINGPARAMETERS_HH
0037 
0038 #include "globals.hh"
0039 #include "G4VisExtent.hh"
0040 #include "G4VisAttributes.hh"
0041 #include "G4VPhysicalVolume.hh"
0042 
0043 #include <vector>
0044 #include <utility>
0045 
0046 class G4LogicalVolume;
0047 class G4VisAttributes;
0048 class G4VSolid;
0049 class G4DisplacedSolid;
0050 class G4Event;
0051 
0052 class G4ModelingParameters {
0053 
0054 public: // With description
0055 
0056   // Currently requested drawing style.
0057   enum DrawingStyle {
0058     wf,         // Draw edges    - no hidden line removal (wireframe).
0059     hlr,        // Draw edges    - hidden lines removed.
0060     hsr,        // Draw surfaces - hidden surfaces removed.
0061     hlhsr,      // Draw surfaces and edges - hidden removed.
0062     cloud       // Draw as a cloud of points
0063   };
0064 
0065   enum CutawayMode {
0066     cutawayUnion,       // Union (addition) of result of each cutaway plane.
0067     cutawayIntersection // Intersection (multiplication).
0068   };
0069 
0070   // enums and nested class for communicating a modification to the vis
0071   // attributes for a specfic touchable defined by PVNameCopyNoPath.
0072   enum VisAttributesSignifier {
0073     VASVisibility,
0074     VASDaughtersInvisible,
0075     VASColour,
0076     VASLineStyle,
0077     VASLineWidth,
0078     VASForceWireframe,
0079     VASForceSolid,
0080     VASForceCloud,
0081     VASForceNumberOfCloudPoints,
0082     VASForceAuxEdgeVisible,
0083     VASForceLineSegmentsPerCircle
0084   };
0085 
0086   class PVNameCopyNo {
0087   public:
0088     // Normal constructor
0089     PVNameCopyNo(G4String name, G4int copyNo)
0090     : fName(name), fCopyNo(copyNo) {}
0091     const G4String& GetName() const {return fName;}
0092     G4int GetCopyNo() const {return fCopyNo;}
0093     G4bool operator!=(const PVNameCopyNo&) const;
0094     G4bool operator==(const PVNameCopyNo& rhs) const {return !operator!=(rhs);}
0095   private:
0096     G4String fName;
0097     G4int fCopyNo;
0098   };
0099   typedef std::vector<PVNameCopyNo> PVNameCopyNoPath;
0100   typedef PVNameCopyNoPath::const_iterator PVNameCopyNoPathConstIterator;
0101 
0102   class PVPointerCopyNo {
0103   public:
0104     // Normal constructor
0105     PVPointerCopyNo(G4VPhysicalVolume* pPV, G4int copyNo)
0106     : fpPV(pPV), fCopyNo(copyNo) {}
0107     const G4String& GetName() const;
0108     const G4VPhysicalVolume* GetPVPointer() const {return fpPV;}
0109     G4int GetCopyNo() const {return fCopyNo;}
0110     G4bool operator!=(const PVPointerCopyNo&) const;
0111     G4bool operator==(const PVPointerCopyNo& rhs) const {return !operator!=(rhs);}
0112   private:
0113     G4VPhysicalVolume* fpPV;
0114     G4int fCopyNo;
0115   };
0116   typedef std::vector<PVPointerCopyNo> PVPointerCopyNoPath;
0117   typedef PVPointerCopyNoPath::const_iterator PVPointerCopyNoPathConstIterator;
0118 
0119   class VisAttributesModifier {
0120   public:
0121     VisAttributesModifier
0122     (const G4VisAttributes& visAtts,
0123      VisAttributesSignifier signifier,
0124      const PVNameCopyNoPath& path):
0125     fVisAtts(visAtts), fSignifier(signifier), fPVNameCopyNoPath(path) {}
0126     const G4VisAttributes& GetVisAttributes() const
0127     {return fVisAtts;}
0128     VisAttributesSignifier GetVisAttributesSignifier() const
0129     {return fSignifier;}
0130     const PVNameCopyNoPath& GetPVNameCopyNoPath() const
0131     {return fPVNameCopyNoPath;}
0132     void SetVisAttributes(const G4VisAttributes& visAtts)
0133     {fVisAtts = visAtts;}
0134     void SetVisAttributesSignifier(VisAttributesSignifier signifier)
0135     {fSignifier = signifier;}
0136     void SetPVNameCopyNoPath(const PVNameCopyNoPath& PVNameCopyNoPath)
0137     {fPVNameCopyNoPath = PVNameCopyNoPath;}
0138     G4bool operator!=(const VisAttributesModifier&) const;
0139     G4bool operator==(const VisAttributesModifier& rhs) const
0140     {return !operator!=(rhs);}
0141   private:
0142     G4VisAttributes fVisAtts;
0143     VisAttributesSignifier fSignifier;
0144     PVNameCopyNoPath fPVNameCopyNoPath;
0145   };
0146 
0147   G4ModelingParameters ();
0148 
0149   G4ModelingParameters (const G4VisAttributes* pDefaultVisAttributes,
0150                         DrawingStyle drawingStyle,
0151             G4bool isCulling,
0152             G4bool isCullingInvisible,
0153             G4bool isDensityCulling,
0154             G4double visibleDensity,
0155             G4bool isCullingCovered,
0156             G4int noOfSides);
0157   // Culling and clipping policy for G4PhysicalVolumeModel.
0158 
0159   ~G4ModelingParameters ();
0160 
0161   // Note: uses default assignment operator and copy constructor.
0162 
0163   G4bool operator != (const G4ModelingParameters&) const;
0164 
0165   // Get and Is functions...
0166   G4bool           IsWarning                     () const;
0167   const G4VisAttributes* GetDefaultVisAttributes () const;
0168   DrawingStyle     GetDrawingStyle               () const;
0169   G4int            GetNumberOfCloudPoints        () const;
0170   G4bool           IsCulling                     () const;
0171   G4bool           IsCullingInvisible            () const;
0172   G4bool           IsDensityCulling              () const;
0173   G4double         GetVisibleDensity             () const;
0174   G4bool           IsCullingCovered              () const;
0175   G4int            GetCBDAlgorithmNumber         () const;
0176   const std::vector<G4double>& GetCBDParameters  () const;
0177   G4bool           IsExplode                     () const;
0178   G4double         GetExplodeFactor              () const;
0179   const G4Point3D& GetExplodeCentre              () const;
0180   G4int            GetNoOfSides                  () const;
0181   G4DisplacedSolid* GetSectionSolid              () const;
0182   CutawayMode      GetCutawayMode                () const;
0183   G4DisplacedSolid* GetCutawaySolid              () const;
0184   const G4Event*   GetEvent                      () const;
0185   const std::vector<VisAttributesModifier>& GetVisAttributesModifiers() const;
0186   G4bool           IsSpecialMeshRendering        () const;
0187   const std::vector<PVNameCopyNo>& GetSpecialMeshVolumes() const;
0188 
0189   // Set functions...
0190   void SetWarning              (G4bool);
0191   void SetDefaultVisAttributes (const G4VisAttributes* pDefaultVisAttributes);
0192   void SetDrawingStyle         (DrawingStyle);
0193   void SetNumberOfCloudPoints  (G4int);
0194   void SetCulling              (G4bool);
0195   void SetCullingInvisible     (G4bool);
0196   void SetDensityCulling       (G4bool);
0197   void SetVisibleDensity       (G4double);
0198   void SetCullingCovered       (G4bool);
0199   void SetCBDAlgorithmNumber   (G4int);
0200   void SetCBDParameters        (const std::vector<G4double>&);
0201   void SetExplodeFactor        (G4double explodeFactor);
0202   void SetExplodeCentre        (const G4Point3D& explodeCentre);
0203   G4int SetNoOfSides           (G4int);  // Returns actual number set.
0204   void SetSectionSolid         (G4DisplacedSolid* pSectionSolid);
0205   void SetCutawayMode          (CutawayMode);
0206   void SetCutawaySolid         (G4DisplacedSolid* pCutawaySolid);
0207   void SetEvent                (const G4Event* pEvent);
0208   void SetVisAttributesModifiers(const std::vector<VisAttributesModifier>&);
0209   void SetSpecialMeshRendering (G4bool);
0210   void SetSpecialMeshVolumes   (const std::vector<PVNameCopyNo>&);
0211 
0212   friend std::ostream& operator <<
0213   (std::ostream& os, const G4ModelingParameters&);
0214   
0215   friend std::ostream& operator <<
0216   (std::ostream& os, const PVNameCopyNoPath&);
0217 
0218   friend std::ostream& operator <<
0219   (std::ostream& os, const PVPointerCopyNoPath&);
0220 
0221   friend std::ostream& operator <<
0222   (std::ostream& os,
0223    const std::vector<VisAttributesModifier>&);
0224 
0225 private:
0226 
0227   // Data members...
0228   G4bool       fWarning;         // Print warnings if true.
0229   const G4VisAttributes* fpDefaultVisAttributes;
0230   DrawingStyle fDrawingStyle;    // Drawing style.
0231   G4int        fNumberOfCloudPoints;  // For drawing in cloud style.
0232                                       // <= 0 means use viewer default.
0233   G4bool       fCulling;         // Culling requested.
0234   G4bool       fCullInvisible;   // Cull (don't Draw) invisible objects.
0235   G4bool       fDensityCulling;  // Density culling requested.  If so...
0236   G4double     fVisibleDensity;  // ...density lower than this not drawn.
0237   G4bool       fCullCovered;     // Cull daughters covered by opaque mothers.
0238   G4int        fCBDAlgorithmNumber; // Colour by density algorithm number.
0239   std::vector<G4double> fCBDParameters; // Colour by density parameters.
0240   G4double     fExplodeFactor;   // Explode along radius by this factor...
0241   G4Point3D    fExplodeCentre;   // ...about this centre.
0242   G4int        fNoOfSides;       // ...if polygon approximates circle.
0243   G4DisplacedSolid* fpSectionSolid;  // For generic section (DCUT).
0244   CutawayMode  fCutawayMode;     // Cutaway mode.
0245   G4DisplacedSolid* fpCutawaySolid;  // For generic cutaways.
0246   const G4Event* fpEvent;        // Event being processed.
0247   std::vector<VisAttributesModifier> fVisAttributesModifiers;
0248   G4bool       fSpecialMeshRendering;  // Request special rendering of parameterised volumes
0249   std::vector<PVNameCopyNo> fSpecialMeshVolumes;  // If empty, all meshes.
0250 };
0251 
0252 std::ostream& operator <<
0253 (std::ostream& os, const G4ModelingParameters&);
0254 
0255 std::ostream& operator <<
0256 (std::ostream& os, const G4ModelingParameters::PVNameCopyNoPath&);
0257 
0258 std::ostream& operator <<
0259 (std::ostream& os, const G4ModelingParameters::PVPointerCopyNoPath&);
0260 
0261 std::ostream& operator <<
0262 (std::ostream& os,
0263  const std::vector<G4ModelingParameters::VisAttributesModifier>&);
0264 
0265 #include "G4ModelingParameters.icc"
0266 
0267 #endif