| 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: G4GenericTrap.hh,v 1.9 2010/06/11 09:42:28 gcosmo Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // --------------------------------------------------------------------
|
|---|
| 32 | // GEANT 4 class header file
|
|---|
| 33 | //
|
|---|
| 34 | //
|
|---|
| 35 | // G4GenericTrap
|
|---|
| 36 | //
|
|---|
| 37 | // Class description:
|
|---|
| 38 | //
|
|---|
| 39 | // G4GenericTrap is a solid which represents an arbitrary trapezoid with
|
|---|
| 40 | // up to 8 vertices standing on two parallel planes perpendicular to Z axis.
|
|---|
| 41 | //
|
|---|
| 42 | // Parameters in the constructor:
|
|---|
| 43 | // - name - solid name
|
|---|
| 44 | // - hz - the solid half length in Z
|
|---|
| 45 | // - vertices - the (x,y) coordinates of vertices:
|
|---|
| 46 | // o first four points: vertices[i], i<4
|
|---|
| 47 | // are the vertices sitting on the -hz plane;
|
|---|
| 48 | // o last four points: vertices[i], i>=4
|
|---|
| 49 | // are the vertices sitting on the +hz plane.
|
|---|
| 50 | //
|
|---|
| 51 | // The order of defining the vertices of the solid is the following:
|
|---|
| 52 | // - point 0 is connected with points 1,3,4
|
|---|
| 53 | // - point 1 is connected with points 0,2,5
|
|---|
| 54 | // - point 2 is connected with points 1,3,6
|
|---|
| 55 | // - point 3 is connected with points 0,2,7
|
|---|
| 56 | // - point 4 is connected with points 0,5,7
|
|---|
| 57 | // - point 5 is connected with points 1,4,6
|
|---|
| 58 | // - point 6 is connected with points 2,5,7
|
|---|
| 59 | // - point 7 is connected with points 3,4,6
|
|---|
| 60 | // Points can be identical in order to create shapes with less than
|
|---|
| 61 | // 8 vertices.
|
|---|
| 62 |
|
|---|
| 63 | // Authors:
|
|---|
| 64 | // Tatiana Nikitina, CERN; Ivana Hrivnacova, IPN Orsay
|
|---|
| 65 | // Adapted from Root Arb8 implementation, author Andrea Gheata, CERN
|
|---|
| 66 | // -------------------------------------------------------------------
|
|---|
| 67 |
|
|---|
| 68 | #ifndef G4GenericTrap_HH
|
|---|
| 69 | #define G4GenericTrap_HH
|
|---|
| 70 |
|
|---|
| 71 | #include <vector>
|
|---|
| 72 |
|
|---|
| 73 | #include "G4TwoVector.hh"
|
|---|
| 74 | #include "G4VSolid.hh"
|
|---|
| 75 | #include "globals.hh"
|
|---|
| 76 |
|
|---|
| 77 | class G4VFacet;
|
|---|
| 78 | class G4TessellatedSolid;
|
|---|
| 79 |
|
|---|
| 80 | class G4GenericTrap : public G4VSolid
|
|---|
| 81 | {
|
|---|
| 82 | public: // with description
|
|---|
| 83 |
|
|---|
| 84 | G4GenericTrap( const G4String& name, G4double hz,
|
|---|
| 85 | const std::vector<G4TwoVector>& vertices );
|
|---|
| 86 | // Constructor
|
|---|
| 87 |
|
|---|
| 88 | ~G4GenericTrap();
|
|---|
| 89 | // Destructor
|
|---|
| 90 |
|
|---|
| 91 | // Accessors
|
|---|
| 92 |
|
|---|
| 93 | inline G4double GetZHalfLength() const;
|
|---|
| 94 | inline G4int GetNofVertices() const;
|
|---|
| 95 | inline G4TwoVector GetVertex(G4int index) const;
|
|---|
| 96 | inline const std::vector<G4TwoVector>& GetVertices() const;
|
|---|
| 97 | inline G4double GetTwistAngle(G4int index) const;
|
|---|
| 98 | inline G4bool IsTwisted() const;
|
|---|
| 99 | inline G4int GetVisSubdivisions() const;
|
|---|
| 100 | inline void SetVisSubdivisions(G4int subdiv);
|
|---|
| 101 |
|
|---|
| 102 | // Solid methods
|
|---|
| 103 |
|
|---|
| 104 | EInside Inside(const G4ThreeVector& p) const;
|
|---|
| 105 | G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
|
|---|
| 106 | G4double DistanceToIn(const G4ThreeVector& p,
|
|---|
| 107 | const G4ThreeVector& v) const;
|
|---|
| 108 | G4double DistanceToIn(const G4ThreeVector& p) const;
|
|---|
| 109 | G4double DistanceToOut(const G4ThreeVector& p,
|
|---|
| 110 | const G4ThreeVector& v,
|
|---|
| 111 | const G4bool calcNorm = false,
|
|---|
| 112 | G4bool *validNorm = 0,
|
|---|
| 113 | G4ThreeVector *n = 0) const;
|
|---|
| 114 | G4double DistanceToOut(const G4ThreeVector& p) const;
|
|---|
| 115 | G4bool CalculateExtent(const EAxis pAxis,
|
|---|
| 116 | const G4VoxelLimits& pVoxelLimit,
|
|---|
| 117 | const G4AffineTransform& pTransform,
|
|---|
| 118 | G4double& pmin, G4double& pmax) const;
|
|---|
| 119 |
|
|---|
| 120 | inline G4GeometryType GetEntityType() const;
|
|---|
| 121 |
|
|---|
| 122 | std::ostream& StreamInfo(std::ostream& os) const;
|
|---|
| 123 |
|
|---|
| 124 | G4ThreeVector GetPointOnSurface() const ;
|
|---|
| 125 |
|
|---|
| 126 | inline G4double GetCubicVolume();
|
|---|
| 127 | G4double GetSurfaceArea();
|
|---|
| 128 |
|
|---|
| 129 | // Visualisation functions
|
|---|
| 130 |
|
|---|
| 131 | G4Polyhedron* GetPolyhedron () const;
|
|---|
| 132 | void DescribeYourselfTo(G4VGraphicsScene& scene) const;
|
|---|
| 133 | G4VisExtent GetExtent() const;
|
|---|
| 134 | G4Polyhedron* CreatePolyhedron() const;
|
|---|
| 135 | G4NURBS* CreateNURBS() const;
|
|---|
| 136 |
|
|---|
| 137 | public: // without description
|
|---|
| 138 |
|
|---|
| 139 | G4GenericTrap(__void__&);
|
|---|
| 140 | // Fake default constructor for usage restricted to direct object
|
|---|
| 141 | // persistency for clients requiring preallocation of memory for
|
|---|
| 142 | // persistifiable objects.
|
|---|
| 143 |
|
|---|
| 144 | private:
|
|---|
| 145 |
|
|---|
| 146 | // Internal methods
|
|---|
| 147 |
|
|---|
| 148 | inline void SetTwistAngle(G4int index, G4double twist);
|
|---|
| 149 | G4bool ComputeIsTwisted() ;
|
|---|
| 150 | G4bool CheckOrder(const std::vector<G4TwoVector>& vertices) const;
|
|---|
| 151 | G4bool IsSegCrossing(const G4TwoVector& a, const G4TwoVector& b,
|
|---|
| 152 | const G4TwoVector& c, const G4TwoVector& d) const;
|
|---|
| 153 | G4ThreeVectorList* CreateRotatedVertices(const
|
|---|
| 154 | G4AffineTransform& pTransform) const;
|
|---|
| 155 | void ReorderVertices(std::vector<G4ThreeVector>& vertices) const;
|
|---|
| 156 | void ComputeBBox();
|
|---|
| 157 | inline G4ThreeVector GetMinimumBBox() const;
|
|---|
| 158 | inline G4ThreeVector GetMaximumBBox() const;
|
|---|
| 159 |
|
|---|
| 160 | G4VFacet* MakeDownFacet(const std::vector<G4ThreeVector>& fromVertices,
|
|---|
| 161 | G4int ind1, G4int ind2, G4int ind3) const;
|
|---|
| 162 | G4VFacet* MakeUpFacet(const std::vector<G4ThreeVector>& fromVertices,
|
|---|
| 163 | G4int ind1, G4int ind2, G4int ind3) const;
|
|---|
| 164 | G4VFacet* MakeSideFacet(const G4ThreeVector& downVertex0,
|
|---|
| 165 | const G4ThreeVector& downVertex1,
|
|---|
| 166 | const G4ThreeVector& upVertex1,
|
|---|
| 167 | const G4ThreeVector& upVertex0) const;
|
|---|
| 168 | G4TessellatedSolid* CreateTessellatedSolid() const;
|
|---|
| 169 |
|
|---|
| 170 | EInside InsidePolygone(const G4ThreeVector& p,
|
|---|
| 171 | const std::vector<G4TwoVector>& poly) const;
|
|---|
| 172 | G4double DistToPlane(const G4ThreeVector& p,
|
|---|
| 173 | const G4ThreeVector& v, const G4int ipl) const ;
|
|---|
| 174 | G4double DistToTriangle(const G4ThreeVector& p,
|
|---|
| 175 | const G4ThreeVector& v, const G4int ipl) const;
|
|---|
| 176 | G4ThreeVector NormalToPlane(const G4ThreeVector& p,
|
|---|
| 177 | const G4int ipl) const;
|
|---|
| 178 | G4double SafetyToFace(const G4ThreeVector& p, const G4int iseg) const;
|
|---|
| 179 | G4double GetFaceSurfaceArea(const G4ThreeVector& p0,
|
|---|
| 180 | const G4ThreeVector& p1,
|
|---|
| 181 | const G4ThreeVector& p2,
|
|---|
| 182 | const G4ThreeVector& p3) const;
|
|---|
| 183 | protected:
|
|---|
| 184 |
|
|---|
| 185 | mutable G4Polyhedron* fpPolyhedron;
|
|---|
| 186 |
|
|---|
| 187 | private:
|
|---|
| 188 |
|
|---|
| 189 | // static data members
|
|---|
| 190 |
|
|---|
| 191 | static const G4int fgkNofVertices;
|
|---|
| 192 | static const G4double fgkTolerance;
|
|---|
| 193 |
|
|---|
| 194 | // data members
|
|---|
| 195 |
|
|---|
| 196 | G4double fDz;
|
|---|
| 197 | std::vector<G4TwoVector> fVertices;
|
|---|
| 198 | G4bool fIsTwisted;
|
|---|
| 199 | G4double fTwist[4];
|
|---|
| 200 | G4TessellatedSolid* fTessellatedSolid;
|
|---|
| 201 | G4ThreeVector fMinBBoxVector;
|
|---|
| 202 | G4ThreeVector fMaxBBoxVector;
|
|---|
| 203 | G4int fVisSubdivisions;
|
|---|
| 204 |
|
|---|
| 205 | enum ESide {kUndefined,kXY0,kXY1,kXY2,kXY3,kMZ,kPZ};
|
|---|
| 206 | // Codes for faces (kXY[num]=num of lateral face,kMZ= minus z face etc)
|
|---|
| 207 |
|
|---|
| 208 | G4double fSurfaceArea;
|
|---|
| 209 | G4double fCubicVolume;
|
|---|
| 210 | // Surface and Volume
|
|---|
| 211 | };
|
|---|
| 212 |
|
|---|
| 213 | #include "G4GenericTrap.icc"
|
|---|
| 214 |
|
|---|
| 215 | #endif
|
|---|