G4GenericTrap.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: G4GenericTrap.hh 67011 2013-01-29 16:17:41Z gcosmo $
00028 //
00029 // 
00030 // --------------------------------------------------------------------
00031 // GEANT 4 class header file
00032 //
00033 //
00034 // G4GenericTrap
00035 //
00036 // Class description:
00037 //
00038 // G4GenericTrap is a solid which represents an arbitrary trapezoid with 
00039 // up to 8 vertices standing on two parallel planes perpendicular to Z axis.
00040 // 
00041 // Parameters in the constructor:
00042 // - name               - solid name
00043 // - halfZ              - the solid half length in Z
00044 // - vertices           - the (x,y) coordinates of vertices:
00045 //                        o first four points: vertices[i], i<4 
00046 //                          are the vertices sitting on the -halfZ plane;
00047 //                        o last four points: vertices[i], i>=4
00048 //                          are the vertices sitting on the +halfZ plane.
00049 //
00050 //   The order of defining the vertices of the solid is the following:
00051 //      - point 0 is connected with points 1,3,4
00052 //      - point 1 is connected with points 0,2,5
00053 //      - point 2 is connected with points 1,3,6
00054 //      - point 3 is connected with points 0,2,7
00055 //      - point 4 is connected with points 0,5,7
00056 //      - point 5 is connected with points 1,4,6
00057 //      - point 6 is connected with points 2,5,7
00058 //      - point 7 is connected with points 3,4,6
00059 // Points can be identical in order to create shapes with less than
00060 // 8 vertices.
00061 
00062 // Authors:
00063 //   Tatiana Nikitina, CERN; Ivana Hrivnacova, IPN Orsay
00064 //   Adapted from Root Arb8 implementation, author Andrea Gheata, CERN
00065 // -------------------------------------------------------------------
00066 
00067 #ifndef G4GenericTrap_HH
00068 #define G4GenericTrap_HH
00069 
00070 #include <vector>
00071 
00072 #include "G4TwoVector.hh"
00073 #include "G4VSolid.hh"
00074 #include "globals.hh"
00075 
00076 class G4VFacet;
00077 class G4TessellatedSolid;
00078 
00079 class G4GenericTrap : public G4VSolid
00080 {
00081   public:  // with description
00082 
00083      G4GenericTrap( const G4String& name, G4double halfZ,
00084                     const std::vector<G4TwoVector>& vertices );
00085        // Constructor
00086 
00087      ~G4GenericTrap();
00088        // Destructor
00089 
00090     // Accessors
00091 
00092     inline G4double    GetZHalfLength() const;
00093     inline G4int       GetNofVertices() const;
00094     inline G4TwoVector GetVertex(G4int index) const;
00095     inline const std::vector<G4TwoVector>& GetVertices() const;
00096     inline G4double    GetTwistAngle(G4int index) const;
00097     inline G4bool      IsTwisted() const;
00098     inline G4int       GetVisSubdivisions() const;
00099     inline void        SetVisSubdivisions(G4int subdiv);
00100 
00101     // Solid methods                                
00102 
00103     EInside Inside(const G4ThreeVector& p) const;
00104     G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
00105     G4double DistanceToIn(const G4ThreeVector& p,
00106                           const G4ThreeVector& v) const;
00107     G4double DistanceToIn(const G4ThreeVector& p) const;
00108     G4double DistanceToOut(const G4ThreeVector& p,
00109                            const G4ThreeVector& v,
00110                            const G4bool calcNorm = false,
00111                                  G4bool *validNorm = 0,
00112                                  G4ThreeVector *n = 0) const;
00113     G4double DistanceToOut(const G4ThreeVector& p) const;
00114     G4bool CalculateExtent(const EAxis pAxis,
00115                            const G4VoxelLimits& pVoxelLimit,
00116                            const G4AffineTransform& pTransform,
00117                                  G4double& pmin, G4double& pmax) const;
00118 
00119     G4GeometryType GetEntityType() const;
00120 
00121     G4VSolid* Clone() const;
00122 
00123     std::ostream& StreamInfo(std::ostream& os) const;
00124 
00125     G4ThreeVector GetPointOnSurface() const ;
00126 
00127     G4double GetCubicVolume();
00128     G4double GetSurfaceArea();
00129 
00130     // Visualisation functions
00131   
00132     G4Polyhedron* GetPolyhedron () const;
00133     void DescribeYourselfTo(G4VGraphicsScene& scene) const;
00134     G4VisExtent   GetExtent() const;
00135     G4Polyhedron* CreatePolyhedron() const;
00136     G4NURBS*      CreateNURBS() const;
00137        
00138   public:  // without description
00139 
00140     G4GenericTrap(__void__&);
00141       // Fake default constructor for usage restricted to direct object
00142       // persistency for clients requiring preallocation of memory for
00143       // persistifiable objects.
00144 
00145     G4GenericTrap(const G4GenericTrap& rhs);
00146     G4GenericTrap& operator=(const G4GenericTrap& rhs); 
00147       // Copy constructor and assignment operator.
00148 
00149   private:
00150 
00151     // Internal methods
00152 
00153     inline void SetTwistAngle(G4int index, G4double twist);
00154     G4bool  ComputeIsTwisted() ;
00155     G4bool  CheckOrder(const std::vector<G4TwoVector>& vertices) const;
00156     G4bool  IsSegCrossing(const G4TwoVector& a, const G4TwoVector& b, 
00157                           const G4TwoVector& c, const G4TwoVector& d) const;
00158     G4bool  IsSegCrossingZ(const G4TwoVector& a, const G4TwoVector& b, 
00159                            const G4TwoVector& c, const G4TwoVector& d) const;
00160     G4ThreeVectorList* CreateRotatedVertices(const 
00161                          G4AffineTransform& pTransform) const;
00162     void ReorderVertices(std::vector<G4ThreeVector>& vertices) const;
00163     void ComputeBBox();
00164     inline G4ThreeVector GetMinimumBBox() const;
00165     inline G4ThreeVector GetMaximumBBox() const;
00166       
00167     G4VFacet* MakeDownFacet(const std::vector<G4ThreeVector>& fromVertices, 
00168                             G4int ind1, G4int ind2, G4int ind3) const;
00169     G4VFacet* MakeUpFacet(const std::vector<G4ThreeVector>& fromVertices, 
00170                             G4int ind1, G4int ind2, G4int ind3) const;      
00171     G4VFacet* MakeSideFacet(const G4ThreeVector& downVertex0, 
00172                             const G4ThreeVector& downVertex1,
00173                             const G4ThreeVector& upVertex1,
00174                             const G4ThreeVector& upVertex0) const;
00175     G4TessellatedSolid* CreateTessellatedSolid() const;
00176      
00177     EInside InsidePolygone(const G4ThreeVector& p,
00178                            const std::vector<G4TwoVector>& poly) const;
00179     G4double DistToPlane(const G4ThreeVector& p,
00180                          const G4ThreeVector& v, const G4int ipl) const ;
00181     G4double DistToTriangle(const G4ThreeVector& p,
00182                             const G4ThreeVector& v, const G4int ipl) const;
00183     G4ThreeVector NormalToPlane(const G4ThreeVector& p,
00184                                 const G4int ipl) const;
00185     G4double SafetyToFace(const G4ThreeVector& p, const G4int iseg) const;
00186     G4double GetFaceSurfaceArea(const G4ThreeVector& p0,
00187                                 const G4ThreeVector& p1,
00188                                 const G4ThreeVector& p2,
00189                                 const G4ThreeVector& p3) const;
00190   protected:
00191 
00192      mutable G4Polyhedron*   fpPolyhedron;
00193 
00194   private:
00195 
00196     // static data members
00197 
00198     static const G4int       fgkNofVertices;
00199     static const G4double    fgkTolerance;
00200 
00201     // data members
00202 
00203     G4double                 fDz;
00204     std::vector<G4TwoVector> fVertices;
00205     G4bool                   fIsTwisted;
00206     G4double                 fTwist[4];
00207     G4TessellatedSolid*      fTessellatedSolid;
00208     G4ThreeVector            fMinBBoxVector;
00209     G4ThreeVector            fMaxBBoxVector;
00210     G4int                    fVisSubdivisions;
00211 
00212     enum ESide {kUndefined,kXY0,kXY1,kXY2,kXY3,kMZ,kPZ};
00213       // Codes for faces (kXY[num]=num of lateral face,kMZ= minus z face etc)
00214 
00215     G4double                 fSurfaceArea;
00216     G4double                 fCubicVolume;
00217       // Surface and Volume
00218 };    
00219 
00220 #include "G4GenericTrap.icc"
00221 
00222 #endif

Generated on Mon May 27 17:48:21 2013 for Geant4 by  doxygen 1.4.7