[831] | 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,v 1.11 2007/05/11 13:54:28 gcosmo Exp $ |
---|
[1337] | 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[831] | 29 | // |
---|
| 30 | // |
---|
| 31 | // -------------------------------------------------------------------- |
---|
| 32 | // GEANT 4 class header file |
---|
| 33 | // |
---|
| 34 | // G4ClippablePolygon |
---|
| 35 | // |
---|
| 36 | // Class description: |
---|
| 37 | // |
---|
| 38 | // Declaration of a utility class of a polygon that can be |
---|
| 39 | // clipped by a voxel. |
---|
| 40 | |
---|
| 41 | // Author: |
---|
| 42 | // David C. Williams (davidw@scipp.ucsc.edu) |
---|
| 43 | // -------------------------------------------------------------------- |
---|
| 44 | #ifndef G4ClippablePolygon_hh |
---|
| 45 | #define G4ClippablePolygon_hh |
---|
| 46 | |
---|
| 47 | #include <vector> |
---|
| 48 | |
---|
| 49 | #include "G4Types.hh" |
---|
| 50 | #include "geomdefs.hh" |
---|
| 51 | #include "G4ThreeVector.hh" |
---|
| 52 | |
---|
| 53 | class G4AffineTransform; |
---|
| 54 | class G4VoxelLimits; |
---|
| 55 | |
---|
| 56 | class G4ClippablePolygon |
---|
| 57 | { |
---|
| 58 | typedef std::vector<G4ThreeVector> G4ThreeVectorList; |
---|
| 59 | |
---|
| 60 | public: // with description |
---|
| 61 | |
---|
| 62 | G4ClippablePolygon(); |
---|
| 63 | virtual ~G4ClippablePolygon(); |
---|
| 64 | // Constructor & virtual destructor. |
---|
| 65 | |
---|
| 66 | virtual void AddVertexInOrder( const G4ThreeVector vertex ); |
---|
| 67 | virtual void ClearAllVertices(); |
---|
| 68 | |
---|
| 69 | inline void SetNormal( const G4ThreeVector &newNormal ); |
---|
| 70 | inline const G4ThreeVector GetNormal() const; |
---|
| 71 | |
---|
| 72 | virtual G4bool Clip( const G4VoxelLimits &voxelLimit ); |
---|
| 73 | |
---|
| 74 | virtual G4bool PartialClip( const G4VoxelLimits &voxelLimit, |
---|
| 75 | const EAxis IgnoreMe ); |
---|
| 76 | // Clip, while ignoring the indicated axis. |
---|
| 77 | |
---|
| 78 | virtual void ClipAlongOneAxis( const G4VoxelLimits &voxelLimit, |
---|
| 79 | const EAxis axis ); |
---|
| 80 | // Clip along just one axis, as specified in voxelLimit. |
---|
| 81 | |
---|
| 82 | virtual G4bool GetExtent( const EAxis axis, |
---|
| 83 | G4double &min, G4double &max ) const; |
---|
| 84 | |
---|
| 85 | virtual const G4ThreeVector *GetMinPoint( const EAxis axis ) const; |
---|
| 86 | // Returns pointer to minimum point along the specified axis. |
---|
| 87 | // Take care! Do not use pointer after destroying parent polygon. |
---|
| 88 | |
---|
| 89 | virtual const G4ThreeVector *GetMaxPoint( const EAxis axis ) const; |
---|
| 90 | // Returns pointer to maximum point along the specified axis. |
---|
| 91 | // Take care! Do not use pointer after destroying parent polygon. |
---|
| 92 | |
---|
| 93 | inline G4int GetNumVertices() const; |
---|
| 94 | inline G4bool Empty() const; |
---|
| 95 | |
---|
| 96 | virtual G4bool InFrontOf( const G4ClippablePolygon &other, EAxis axis ) const; |
---|
| 97 | // Decide if the polygon is in "front" of another when |
---|
| 98 | // viewed along the specified axis. For our purposes here, |
---|
| 99 | // it is sufficient to use the minimum extent of the |
---|
| 100 | // polygon along the axis to determine this. |
---|
| 101 | |
---|
| 102 | virtual G4bool BehindOf( const G4ClippablePolygon &other, EAxis axis ) const; |
---|
| 103 | // Decide if this polygon is behind another. |
---|
| 104 | // Remarks in method "InFrontOf" are valid here too. |
---|
| 105 | |
---|
| 106 | virtual G4bool GetPlanerExtent( const G4ThreeVector &pointOnPlane, |
---|
| 107 | const G4ThreeVector &planeNormal, |
---|
| 108 | G4double &min, G4double &max ) const; |
---|
| 109 | // Get min/max distance in or out of a plane. |
---|
| 110 | |
---|
| 111 | protected: // with description |
---|
| 112 | |
---|
| 113 | void ClipToSimpleLimits( G4ThreeVectorList& pPolygon, |
---|
| 114 | G4ThreeVectorList& outputPolygon, |
---|
| 115 | const G4VoxelLimits& pVoxelLimit ); |
---|
| 116 | // pVoxelLimits must be only limited along one axis, and either |
---|
| 117 | // the maximum along the axis must be +kInfinity, or the minimum |
---|
| 118 | // -kInfinity |
---|
| 119 | |
---|
| 120 | protected: |
---|
| 121 | |
---|
| 122 | G4ThreeVectorList vertices; |
---|
| 123 | G4ThreeVector normal; |
---|
| 124 | G4double kCarTolerance; |
---|
| 125 | }; |
---|
| 126 | |
---|
| 127 | #include "G4ClippablePolygon.icc" |
---|
| 128 | |
---|
| 129 | #endif |
---|