G4ClippablePolygon.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4ClippablePolygon.hh 67011 2013-01-29 16:17:41Z gcosmo $
00028 //
00029 //
00030 // --------------------------------------------------------------------
00031 // GEANT 4 class header file
00032 //
00033 // G4ClippablePolygon
00034 //
00035 // Class description:
00036 //
00037 //   Declaration of a utility class of a polygon that can be
00038 //   clipped by a voxel.
00039 
00040 // Author:
00041 //   David C. Williams (davidw@scipp.ucsc.edu)
00042 // --------------------------------------------------------------------
00043 #ifndef G4ClippablePolygon_hh
00044 #define G4ClippablePolygon_hh
00045 
00046 #include <vector>
00047 
00048 #include "G4Types.hh"
00049 #include "geomdefs.hh"
00050 #include "G4ThreeVector.hh"
00051 
00052 class G4AffineTransform;
00053 class G4VoxelLimits;
00054 
00055 class G4ClippablePolygon
00056 {
00057   typedef std::vector<G4ThreeVector> G4ThreeVectorList;
00058 
00059   public:  // with description
00060 
00061   G4ClippablePolygon();
00062   virtual ~G4ClippablePolygon();
00063     // Constructor & virtual destructor.
00064   
00065   virtual void AddVertexInOrder( const G4ThreeVector vertex );
00066   virtual void ClearAllVertices();
00067   
00068   inline void SetNormal( const G4ThreeVector &newNormal );
00069   inline const G4ThreeVector GetNormal() const;
00070   
00071   virtual G4bool Clip( const G4VoxelLimits &voxelLimit );
00072 
00073   virtual G4bool PartialClip( const G4VoxelLimits &voxelLimit,
00074                               const EAxis IgnoreMe );
00075     // Clip, while ignoring the indicated axis.
00076 
00077   virtual void ClipAlongOneAxis( const G4VoxelLimits &voxelLimit,
00078                                  const EAxis axis );
00079     // Clip along just one axis, as specified in voxelLimit.
00080 
00081   virtual G4bool GetExtent( const EAxis axis, 
00082                                   G4double &min, G4double &max ) const;
00083 
00084   virtual const G4ThreeVector *GetMinPoint( const EAxis axis ) const;
00085     // Returns pointer to minimum point along the specified axis.
00086     // Take care! Do not use pointer after destroying parent polygon.
00087 
00088   virtual const G4ThreeVector *GetMaxPoint( const EAxis axis ) const;
00089     // Returns pointer to maximum point along the specified axis.
00090     // Take care! Do not use pointer after destroying parent polygon.
00091 
00092   inline G4int GetNumVertices() const;
00093   inline G4bool Empty() const;
00094   
00095   virtual G4bool InFrontOf( const G4ClippablePolygon &other, EAxis axis ) const;
00096     // Decide if the polygon is in "front" of another when
00097     // viewed along the specified axis. For our purposes here,
00098     // it is sufficient to use the minimum extent of the
00099     // polygon along the axis to determine this.
00100 
00101   virtual G4bool BehindOf( const G4ClippablePolygon &other, EAxis axis ) const;
00102     // Decide if this polygon is behind another.
00103     // Remarks in method "InFrontOf" are valid here too.
00104 
00105   virtual G4bool GetPlanerExtent( const G4ThreeVector &pointOnPlane, 
00106                                   const G4ThreeVector &planeNormal,
00107                                         G4double &min, G4double &max ) const;
00108     // Get min/max distance in or out of a plane.
00109 
00110   protected:  // with description
00111 
00112   void ClipToSimpleLimits( G4ThreeVectorList& pPolygon,
00113                            G4ThreeVectorList& outputPolygon,
00114                      const G4VoxelLimits& pVoxelLimit  );
00115     // pVoxelLimits must be only limited along one axis, and either
00116     // the maximum along the axis must be +kInfinity, or the minimum
00117     // -kInfinity
00118 
00119   protected:
00120 
00121   G4ThreeVectorList vertices;
00122   G4ThreeVector normal;
00123   G4double kCarTolerance;
00124 };
00125 
00126 #include "G4ClippablePolygon.icc"
00127 
00128 #endif

Generated on Mon May 27 17:47:54 2013 for Geant4 by  doxygen 1.4.7