Geant4  10.01.p03
G4ClippablePolygon.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4ClippablePolygon.hh 66356 2012-12-18 09:02:32Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // G4ClippablePolygon
34 //
35 // Class description:
36 //
37 // Declaration of a utility class of a polygon that can be
38 // clipped by a voxel.
39 
40 // Author:
41 // David C. Williams (davidw@scipp.ucsc.edu)
42 // --------------------------------------------------------------------
43 #ifndef G4ClippablePolygon_hh
44 #define G4ClippablePolygon_hh
45 
46 #include <vector>
47 
48 #include "G4Types.hh"
49 #include "geomdefs.hh"
50 #include "G4ThreeVector.hh"
51 
52 class G4AffineTransform;
53 class G4VoxelLimits;
54 
56 {
57  typedef std::vector<G4ThreeVector> G4ThreeVectorList;
58 
59  public: // with description
60 
62  virtual ~G4ClippablePolygon();
63  // Constructor & virtual destructor.
64 
65  virtual void AddVertexInOrder( const G4ThreeVector vertex );
66  virtual void ClearAllVertices();
67 
68  inline void SetNormal( const G4ThreeVector &newNormal );
69  inline const G4ThreeVector GetNormal() const;
70 
71  virtual G4bool Clip( const G4VoxelLimits &voxelLimit );
72 
73  virtual G4bool PartialClip( const G4VoxelLimits &voxelLimit,
74  const EAxis IgnoreMe );
75  // Clip, while ignoring the indicated axis.
76 
77  virtual void ClipAlongOneAxis( const G4VoxelLimits &voxelLimit,
78  const EAxis axis );
79  // Clip along just one axis, as specified in voxelLimit.
80 
81  virtual G4bool GetExtent( const EAxis axis,
82  G4double &min, G4double &max ) const;
83 
84  virtual const G4ThreeVector *GetMinPoint( const EAxis axis ) const;
85  // Returns pointer to minimum point along the specified axis.
86  // Take care! Do not use pointer after destroying parent polygon.
87 
88  virtual const G4ThreeVector *GetMaxPoint( const EAxis axis ) const;
89  // Returns pointer to maximum point along the specified axis.
90  // Take care! Do not use pointer after destroying parent polygon.
91 
92  inline G4int GetNumVertices() const;
93  inline G4bool Empty() const;
94 
95  virtual G4bool InFrontOf( const G4ClippablePolygon &other, EAxis axis ) const;
96  // Decide if the polygon is in "front" of another when
97  // viewed along the specified axis. For our purposes here,
98  // it is sufficient to use the minimum extent of the
99  // polygon along the axis to determine this.
100 
101  virtual G4bool BehindOf( const G4ClippablePolygon &other, EAxis axis ) const;
102  // Decide if this polygon is behind another.
103  // Remarks in method "InFrontOf" are valid here too.
104 
105  virtual G4bool GetPlanerExtent( const G4ThreeVector &pointOnPlane,
106  const G4ThreeVector &planeNormal,
107  G4double &min, G4double &max ) const;
108  // Get min/max distance in or out of a plane.
109 
110  protected: // with description
111 
112  void ClipToSimpleLimits( G4ThreeVectorList& pPolygon,
113  G4ThreeVectorList& outputPolygon,
114  const G4VoxelLimits& pVoxelLimit );
115  // pVoxelLimits must be only limited along one axis, and either
116  // the maximum along the axis must be +kInfinity, or the minimum
117  // -kInfinity
118 
119  protected:
120 
121  G4ThreeVectorList vertices;
124 };
125 
126 #include "G4ClippablePolygon.icc"
127 
128 #endif
virtual G4bool InFrontOf(const G4ClippablePolygon &other, EAxis axis) const
CLHEP::Hep3Vector G4ThreeVector
virtual void ClipAlongOneAxis(const G4VoxelLimits &voxelLimit, const EAxis axis)
virtual G4bool GetPlanerExtent(const G4ThreeVector &pointOnPlane, const G4ThreeVector &planeNormal, G4double &min, G4double &max) const
void SetNormal(const G4ThreeVector &newNormal)
virtual G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
virtual void AddVertexInOrder(const G4ThreeVector vertex)
virtual void ClearAllVertices()
virtual const G4ThreeVector * GetMinPoint(const EAxis axis) const
int G4int
Definition: G4Types.hh:78
virtual G4bool BehindOf(const G4ClippablePolygon &other, EAxis axis) const
const G4ThreeVector GetNormal() const
virtual G4bool GetExtent(const EAxis axis, G4double &min, G4double &max) const
G4int GetNumVertices() const
virtual const G4ThreeVector * GetMaxPoint(const EAxis axis) const
virtual G4bool Clip(const G4VoxelLimits &voxelLimit)
std::vector< G4ThreeVector > G4ThreeVectorList
G4ThreeVectorList vertices
bool G4bool
Definition: G4Types.hh:79
T max(const T t1, const T t2)
brief Return the largest of the two arguments
EAxis
Definition: geomdefs.hh:54
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void ClipToSimpleLimits(G4ThreeVectorList &pPolygon, G4ThreeVectorList &outputPolygon, const G4VoxelLimits &pVoxelLimit)
G4bool Empty() const
double G4double
Definition: G4Types.hh:76