Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4ClippablePolygon.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 // G4ClippablePolygon
0027 //
0028 // Class description:
0029 //
0030 // Declaration of a utility class of a polygon that can be
0031 // clipped by a voxel.
0032 
0033 // Author: David C. Williams (davidw@scipp.ucsc.edu)
0034 // --------------------------------------------------------------------
0035 #ifndef G4CLIPPABLEPOLYGON_HH
0036 #define G4CLIPPABLEPOLYGON_HH
0037 
0038 #include <vector>
0039 
0040 #include "G4Types.hh"
0041 #include "geomdefs.hh"
0042 #include "G4ThreeVector.hh"
0043 
0044 class G4AffineTransform;
0045 class G4VoxelLimits;
0046 
0047 class G4ClippablePolygon
0048 {
0049   using G4ThreeVectorList = std::vector<G4ThreeVector>;
0050 
0051   public:
0052 
0053     G4ClippablePolygon();
0054     virtual ~G4ClippablePolygon();
0055       // Constructor & virtual destructor.
0056   
0057     virtual void AddVertexInOrder( const G4ThreeVector vertex );
0058     virtual void ClearAllVertices();
0059   
0060     inline void SetNormal( const G4ThreeVector& newNormal );
0061     inline const G4ThreeVector GetNormal() const;
0062   
0063     virtual G4bool Clip( const G4VoxelLimits& voxelLimit );
0064 
0065     virtual G4bool PartialClip( const G4VoxelLimits& voxelLimit,
0066                                 const EAxis IgnoreMe );
0067       // Clip, while ignoring the indicated axis.
0068 
0069     virtual void ClipAlongOneAxis( const G4VoxelLimits& voxelLimit,
0070                                    const EAxis axis );
0071       // Clip along just one axis, as specified in voxelLimit.
0072 
0073     virtual G4bool GetExtent( const EAxis axis, 
0074                                     G4double& min, G4double& max ) const;
0075 
0076     virtual const G4ThreeVector* GetMinPoint( const EAxis axis ) const;
0077       // Returns pointer to minimum point along the specified axis.
0078       // Take care! Do not use pointer after destroying parent polygon.
0079 
0080     virtual const G4ThreeVector* GetMaxPoint( const EAxis axis ) const;
0081       // Returns pointer to maximum point along the specified axis.
0082       // Take care! Do not use pointer after destroying parent polygon.
0083 
0084     inline std::size_t GetNumVertices() const;
0085     inline G4bool Empty() const;
0086   
0087     virtual G4bool InFrontOf(const G4ClippablePolygon& other, EAxis axis) const;
0088       // Decide if the polygon is in "front" of another when
0089       // viewed along the specified axis. For our purposes here,
0090       // it is sufficient to use the minimum extent of the
0091       // polygon along the axis to determine this.
0092 
0093     virtual G4bool BehindOf(const G4ClippablePolygon& other, EAxis axis) const;
0094       // Decide if this polygon is behind another.
0095       // Remarks in method "InFrontOf" are valid here too.
0096 
0097     virtual G4bool GetPlanerExtent( const G4ThreeVector& pointOnPlane, 
0098                                     const G4ThreeVector& planeNormal,
0099                                           G4double& min, G4double& max ) const;
0100       // Get min/max distance in or out of a plane.
0101 
0102     protected:
0103 
0104     void ClipToSimpleLimits( G4ThreeVectorList& pPolygon,
0105                              G4ThreeVectorList& outputPolygon,
0106                        const G4VoxelLimits& pVoxelLimit  );
0107       // pVoxelLimits must be only limited along one axis, and either
0108       // the maximum along the axis must be +kInfinity, or the minimum
0109       // -kInfinity
0110 
0111     protected:
0112 
0113     G4ThreeVectorList vertices;
0114     G4ThreeVector normal;
0115     G4double kCarTolerance;
0116 };
0117 
0118 #include "G4ClippablePolygon.icc"
0119 
0120 #endif