Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:51:35

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(const 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   struct TimeParameters {
0148     G4double fStartTime = -G4VisAttributes::fVeryLongTime;  // ) Start and end time of drawn range,
0149     G4double fEndTime   =  G4VisAttributes::fVeryLongTime;  // ) e.g., for trajectory steps.
0150     G4double fFadeFactor = 1.;  // 0: no fade; 1: maximum fade with time within range.
0151     G4bool   fDisplayHeadTime      = false; // Display head time (fEndTime) in 2D text.
0152     G4double fDisplayHeadTimeX     =  0.0;  // ) 2D screen coords of head time,
0153     G4double fDisplayHeadTimeY     = -0.9;  // ) bottom-middle of view.
0154     G4double fDisplayHeadTimeSize  =  24.;  // Screen size (pixels) of the head time writing.
0155     G4double fDisplayHeadTimeRed   =   0.;  // )
0156     G4double fDisplayHeadTimeGreen =   1.;  // ) Default colour of head time writing (cyan)
0157     G4double fDisplayHeadTimeBlue  =   1.;  // )
0158     G4bool   fDisplayLightFront    = false; // Display light front at head time originating at...
0159     G4double fDisplayLightFrontX     = 0.;  // )
0160     G4double fDisplayLightFrontY     = 0.;  // ) ...default coordinates and time of origin
0161     G4double fDisplayLightFrontZ     = 0.;  // ) of light front drawing...
0162     G4double fDisplayLightFrontT     = 0.;  // )
0163     G4double fDisplayLightFrontRed   = 0.;  // )
0164     G4double fDisplayLightFrontGreen = 1.;  // ) ...in this default colour (green)
0165     G4double fDisplayLightFrontBlue  = 0.;  // )
0166     G4bool operator != (const TimeParameters& rhs)  const {
0167       if (fStartTime              != rhs.fStartTime              ||
0168           fEndTime                != rhs.fEndTime                ||
0169           fFadeFactor             != rhs.fFadeFactor             ||
0170           fDisplayHeadTime        != rhs.fDisplayHeadTime        ||
0171           fDisplayHeadTimeX       != rhs.fDisplayHeadTimeX       ||
0172           fDisplayHeadTimeY       != rhs.fDisplayHeadTimeY       ||
0173           fDisplayHeadTimeSize    != rhs.fDisplayHeadTimeSize    ||
0174           fDisplayHeadTimeRed     != rhs.fDisplayHeadTimeRed     ||
0175           fDisplayHeadTimeGreen   != rhs.fDisplayHeadTimeGreen   ||
0176           fDisplayHeadTimeBlue    != rhs.fDisplayHeadTimeBlue    ||
0177           fDisplayLightFront      != rhs.fDisplayLightFront      ||
0178           fDisplayLightFrontX     != rhs.fDisplayLightFrontX     ||
0179           fDisplayLightFrontY     != rhs.fDisplayLightFrontY     ||
0180           fDisplayLightFrontZ     != rhs.fDisplayLightFrontZ     ||
0181           fDisplayLightFrontT     != rhs.fDisplayLightFrontT     ||
0182           fDisplayLightFrontRed   != rhs.fDisplayLightFrontRed   ||
0183           fDisplayLightFrontGreen != rhs.fDisplayLightFrontGreen ||
0184           fDisplayLightFrontBlue  != rhs.fDisplayLightFrontBlue
0185           ) return true;
0186       return false;
0187     }
0188   };
0189 
0190   G4ModelingParameters ();
0191 
0192   G4ModelingParameters (const G4VisAttributes* pDefaultVisAttributes,
0193                         DrawingStyle drawingStyle,
0194             G4bool isCulling,
0195             G4bool isCullingInvisible,
0196             G4bool isDensityCulling,
0197             G4double visibleDensity,
0198             G4bool isCullingCovered,
0199             G4int noOfSides);
0200   // Culling and clipping policy for G4PhysicalVolumeModel.
0201 
0202   ~G4ModelingParameters ();
0203 
0204   // Note: uses default assignment operator and copy constructor.
0205 
0206   G4bool operator != (const G4ModelingParameters&) const;
0207 
0208   // Get and Is functions...
0209   G4bool           IsWarning                     () const;
0210   const G4VisAttributes* GetDefaultVisAttributes () const;
0211   DrawingStyle     GetDrawingStyle               () const;
0212   G4int            GetNumberOfCloudPoints        () const;
0213   G4bool           IsCulling                     () const;
0214   G4bool           IsCullingInvisible            () const;
0215   G4bool           IsDensityCulling              () const;
0216   G4double         GetVisibleDensity             () const;
0217   G4bool           IsCullingCovered              () const;
0218   G4int            GetCBDAlgorithmNumber         () const;
0219   const std::vector<G4double>& GetCBDParameters  () const;
0220   G4bool           IsExplode                     () const;
0221   G4double         GetExplodeFactor              () const;
0222   const G4Point3D& GetExplodeCentre              () const;
0223   G4int            GetNoOfSides                  () const;
0224   G4DisplacedSolid* GetSectionSolid              () const;
0225   CutawayMode      GetCutawayMode                () const;
0226   G4DisplacedSolid* GetCutawaySolid              () const;
0227   const G4Event*   GetEvent                      () const;
0228   const std::vector<VisAttributesModifier>& GetVisAttributesModifiers() const;
0229   const TimeParameters& GetTimeParameters        () const;
0230   G4bool           IsSpecialMeshRendering        () const;
0231   const std::vector<PVNameCopyNo>& GetSpecialMeshVolumes () const;
0232   G4double         GetTransparencyByDepth        () const;
0233   G4int            GetTransparencyByDepthOption  () const;
0234 
0235   // Set functions...
0236   void SetWarning              (G4bool);
0237   void SetDefaultVisAttributes (const G4VisAttributes* pDefaultVisAttributes);
0238   void SetDrawingStyle         (DrawingStyle);
0239   void SetNumberOfCloudPoints  (G4int);
0240   void SetCulling              (G4bool);
0241   void SetCullingInvisible     (G4bool);
0242   void SetDensityCulling       (G4bool);
0243   void SetVisibleDensity       (G4double);
0244   void SetCullingCovered       (G4bool);
0245   void SetCBDAlgorithmNumber   (G4int);
0246   void SetCBDParameters        (const std::vector<G4double>&);
0247   void SetExplodeFactor        (G4double explodeFactor);
0248   void SetExplodeCentre        (const G4Point3D& explodeCentre);
0249   G4int SetNoOfSides           (G4int);  // Returns actual number set.
0250   void SetSectionSolid         (G4DisplacedSolid* pSectionSolid);
0251   void SetCutawayMode          (CutawayMode);
0252   void SetCutawaySolid         (G4DisplacedSolid* pCutawaySolid);
0253   void SetEvent                (const G4Event* pEvent);
0254   void SetVisAttributesModifiers(const std::vector<VisAttributesModifier>&);
0255   void SetTimeParameters       (const TimeParameters&);
0256   void SetSpecialMeshRendering (G4bool);
0257   void SetSpecialMeshVolumes   (const std::vector<PVNameCopyNo>&);
0258   void SetTransparencyByDepth  (G4double);
0259   void SetTransparencyByDepthOption(G4int);
0260 
0261   friend std::ostream& operator <<
0262   (std::ostream& os, const G4ModelingParameters&);
0263   
0264   friend std::ostream& operator <<
0265   (std::ostream& os, const PVNameCopyNoPath&);
0266 
0267   friend std::ostream& operator <<
0268   (std::ostream& os, const PVPointerCopyNoPath&);
0269 
0270   friend std::ostream& operator <<
0271   (std::ostream& os,
0272    const std::vector<VisAttributesModifier>&);
0273 
0274 private:
0275 
0276   // Data members...
0277   G4bool       fWarning;         // Print warnings if true.
0278   const G4VisAttributes* fpDefaultVisAttributes;
0279   DrawingStyle fDrawingStyle;    // Drawing style.
0280   G4int        fNumberOfCloudPoints;  // For drawing in cloud style.
0281                                       // <= 0 means use viewer default.
0282   G4bool       fCulling;         // Culling requested.
0283   G4bool       fCullInvisible;   // Cull (don't Draw) invisible objects.
0284   G4bool       fDensityCulling;  // Density culling requested.  If so...
0285   G4double     fVisibleDensity;  // ...density lower than this not drawn.
0286   G4bool       fCullCovered;     // Cull daughters covered by opaque mothers.
0287   G4int        fCBDAlgorithmNumber; // Colour by density algorithm number.
0288   std::vector<G4double> fCBDParameters; // Colour by density parameters.
0289   G4double     fExplodeFactor;   // Explode along radius by this factor...
0290   G4Point3D    fExplodeCentre;   // ...about this centre.
0291   G4int        fNoOfSides;       // ...if polygon approximates circle.
0292   G4DisplacedSolid* fpSectionSolid;  // For generic section (DCUT).
0293   CutawayMode  fCutawayMode;     // Cutaway mode.
0294   G4DisplacedSolid* fpCutawaySolid;  // For generic cutaways.
0295   const G4Event* fpEvent;        // Event being processed.
0296   std::vector<VisAttributesModifier> fVisAttributesModifiers;
0297   TimeParameters fTimeParameters;  // Time parameters (for time-slicing).
0298   G4bool       fSpecialMeshRendering;  // Request special rendering of parameterised volumes
0299   std::vector<PVNameCopyNo> fSpecialMeshVolumes;  // If empty, all meshes.
0300   G4double     fTransparencyByDepth;  // Transparency ~= (geometry depth) - fTransparencyByDepth
0301   G4int        fTransparencyByDepthOption;  // Its option
0302 };
0303 
0304 std::ostream& operator <<
0305 (std::ostream& os, const G4ModelingParameters&);
0306 
0307 std::ostream& operator <<
0308 (std::ostream& os, const G4ModelingParameters::PVNameCopyNoPath&);
0309 
0310 std::ostream& operator <<
0311 (std::ostream& os, const G4ModelingParameters::PVPointerCopyNoPath&);
0312 
0313 std::ostream& operator <<
0314 (std::ostream& os,
0315  const std::vector<G4ModelingParameters::VisAttributesModifier>&);
0316 
0317 #include "G4ModelingParameters.icc"
0318 
0319 #endif