G4ExtrudedSolid.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: G4ExtrudedSolid.hh 67011 2013-01-29 16:17:41Z gcosmo $
00028 //
00029 // 
00030 // --------------------------------------------------------------------
00031 // GEANT 4 class header file
00032 //
00033 //
00034 // G4ExtrudedSolid
00035 //
00036 // Class description:
00037 //
00038 // G4ExtrudedSolid is a solid which represents the extrusion of an arbitrary
00039 // polygon with fixed outline in the defined Z sections.
00040 // The z-sides of the solid are the scaled versions of the same polygon.
00041 // The solid is implemented as a specification of G4TessellatedSolid.
00042 //  
00043 // Parameters in the constructor:
00044 // const G4String& pName             - solid name
00045 // std::vector<G4TwoVector> polygon  - the vertices of the outlined polygon
00046 //                                     defined in clockwise or anti-clockwise order     
00047 // std::vector<ZSection>             - the z-sections defined by
00048 //                                     z position, offset and scale
00049 //                                     in increasing z-position order
00050 //
00051 // Parameters in the special constructor (for solid with 2 z-sections:
00052 // G4double halfZ                    - the solid half length in Z
00053 // G4TwoVector off1                  - offset of the side in -halfZ
00054 // G4double scale1                   - scale of the side in -halfZ
00055 // G4TwoVector off2                  - offset of the side in +halfZ
00056 // G4double scale2                   - scale of the side in -halfZ
00057 
00058 // Author:
00059 //   Ivana Hrivnacova, IPN Orsay
00060 // --------------------------------------------------------------------
00061 
00062 #ifndef G4ExtrudedSolid_HH
00063 #define G4ExtrudedSolid_HH
00064 
00065 #include <vector>
00066 
00067 #include "G4TwoVector.hh"
00068 
00069 #include "G4TessellatedSolid.hh"
00070 
00071 class G4VFacet;
00072 
00073 class G4ExtrudedSolid : public G4TessellatedSolid
00074 {
00075 
00076   public:  // without description
00077 
00078     struct ZSection
00079     {
00080       ZSection(G4double z, G4TwoVector offset, G4double scale)
00081         : fZ(z), fOffset(offset), fScale(scale) {}
00082 
00083       G4double    fZ;
00084       G4TwoVector fOffset;
00085       G4double    fScale;
00086     };
00087 
00088   public:  // with description
00089 
00090      G4ExtrudedSolid( const G4String&                 pName,
00091                             std::vector<G4TwoVector>  polygon,
00092                             std::vector<ZSection>     zsections);
00093        // General constructor
00094 
00095      G4ExtrudedSolid( const G4String&                 pName,
00096                             std::vector<G4TwoVector>  polygon,
00097                             G4double                  halfZ,
00098                             G4TwoVector off1, G4double scale1,
00099                             G4TwoVector off2, G4double scale2 );
00100        // Special constructor for solid with 2 z-sections
00101 
00102      virtual ~G4ExtrudedSolid();
00103        // Destructor
00104 
00105     // Accessors
00106 
00107     inline G4int       GetNofVertices() const;
00108     inline G4TwoVector GetVertex(G4int index) const;
00109     inline std::vector<G4TwoVector> GetPolygon() const;
00110 
00111     inline G4int       GetNofZSections() const;
00112     inline ZSection    GetZSection(G4int index) const;
00113     inline std::vector<ZSection> GetZSections() const;
00114 
00115     // Solid methods                                
00116 
00117     EInside  Inside (const G4ThreeVector &p) const;
00118     G4double DistanceToOut(const G4ThreeVector &p,
00119                            const G4ThreeVector &v,
00120                            const G4bool calcNorm=false,
00121                                  G4bool *validNorm=0, G4ThreeVector *n=0) const;
00122     G4double DistanceToOut (const G4ThreeVector &p) const;
00123     G4GeometryType GetEntityType () const;
00124     G4VSolid* Clone() const;
00125 
00126     std::ostream& StreamInfo(std::ostream &os) const;
00127 
00128   public:  // without description
00129 
00130     G4ExtrudedSolid(__void__&);
00131       // Fake default constructor for usage restricted to direct object
00132       // persistency for clients requiring preallocation of memory for
00133       // persistifiable objects.
00134 
00135     G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
00136     G4ExtrudedSolid& operator=(const G4ExtrudedSolid& rhs); 
00137       // Copy constructor and assignment operator.
00138 
00139   private:
00140 
00141     void ComputeProjectionParameters();
00142     
00143     G4ThreeVector GetVertex(G4int iz, G4int ind) const;
00144     G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
00145 
00146     G4bool IsSameLine(G4TwoVector p,
00147                       G4TwoVector l1, G4TwoVector l2) const;
00148     G4bool IsSameLineSegment(G4TwoVector p,
00149                       G4TwoVector l1, G4TwoVector l2) const;
00150     G4bool IsSameSide(G4TwoVector p1, G4TwoVector p2, 
00151                       G4TwoVector l1, G4TwoVector l2) const;
00152     G4bool IsPointInside(G4TwoVector a, G4TwoVector b, G4TwoVector c, 
00153                       G4TwoVector p) const;
00154     G4double GetAngle(G4TwoVector p0, G4TwoVector pa, G4TwoVector pb) const;                      
00155       
00156     G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;      
00157     G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;      
00158 
00159     G4bool AddGeneralPolygonFacets();
00160     G4bool MakeFacets();
00161     G4bool IsConvex() const;
00162 
00163 
00164   private:
00165 
00166     G4int       fNv;
00167     G4int       fNz;
00168     std::vector<G4TwoVector> fPolygon;
00169     std::vector<ZSection>    fZSections;
00170     std::vector< std::vector<G4int> > fTriangles;
00171     G4bool          fIsConvex;
00172     G4GeometryType  fGeometryType;
00173 
00174     std::vector<G4double>      fKScales;
00175     std::vector<G4double>      fScale0s;
00176     std::vector<G4TwoVector>   fKOffsets;
00177     std::vector<G4TwoVector>   fOffset0s;
00178 };    
00179 
00180 #include "G4ExtrudedSolid.icc"
00181 
00182 #endif

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