00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef __G4VTWISTEDFACETED__
00047 #define __G4VTWISTEDFACETED__
00048
00049 #include "G4VSolid.hh"
00050 #include "G4TwistTrapAlphaSide.hh"
00051 #include "G4TwistTrapParallelSide.hh"
00052 #include "G4TwistBoxSide.hh"
00053 #include "G4TwistTrapFlatSide.hh"
00054
00055 class G4SolidExtentList;
00056 class G4ClippablePolygon;
00057
00058 class G4VTwistedFaceted: public G4VSolid
00059 {
00060 public:
00061
00062 G4VTwistedFaceted(const G4String &pname,
00063 G4double PhiTwist,
00064 G4double pDz,
00065 G4double pTheta,
00066 G4double pPhi,
00067 G4double pDy1,
00068 G4double pDx1,
00069 G4double pDx2,
00070 G4double pDy2,
00071 G4double pDx3,
00072 G4double pDx4,
00073 G4double pAlph
00074 );
00075
00076 virtual ~G4VTwistedFaceted();
00077
00078 virtual void ComputeDimensions(G4VPVParameterisation*,
00079 const G4int,
00080 const G4VPhysicalVolume* );
00081
00082 virtual G4bool CalculateExtent(const EAxis pAxis,
00083 const G4VoxelLimits &pVoxelLimit,
00084 const G4AffineTransform &pTransform,
00085 G4double &pMin,
00086 G4double &pMax ) const;
00087
00088 virtual G4double DistanceToIn (const G4ThreeVector &p,
00089 const G4ThreeVector &v ) const;
00090
00091 virtual G4double DistanceToIn (const G4ThreeVector &p ) const;
00092
00093 virtual G4double DistanceToOut(const G4ThreeVector &p,
00094 const G4ThreeVector &v,
00095 const G4bool calcnorm = false,
00096 G4bool *validnorm = 0,
00097 G4ThreeVector *n=0 ) const;
00098
00099 virtual G4double DistanceToOut(const G4ThreeVector &p) const;
00100
00101 virtual EInside Inside (const G4ThreeVector &p) const;
00102
00103 virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const;
00104
00105 G4ThreeVector GetPointOnSurface() const;
00106 G4ThreeVector GetPointInSolid(G4double z) const;
00107
00108 virtual inline G4double GetCubicVolume() ;
00109 virtual inline G4double GetSurfaceArea() ;
00110
00111 virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const;
00112 virtual G4Polyhedron *CreatePolyhedron () const ;
00113 virtual G4NURBS *CreateNURBS () const;
00114 virtual G4Polyhedron *GetPolyhedron () const;
00115
00116 virtual std::ostream &StreamInfo(std::ostream& os) const;
00117
00118
00119
00120 inline G4double GetTwistAngle () const { return fPhiTwist; }
00121
00122 inline G4double GetDx1 () const { return fDx1 ; }
00123 inline G4double GetDx2 () const { return fDx2 ; }
00124 inline G4double GetDx3 () const { return fDx3 ; }
00125 inline G4double GetDx4 () const { return fDx4 ; }
00126 inline G4double GetDy1 () const { return fDy1 ; }
00127 inline G4double GetDy2 () const { return fDy2 ; }
00128 inline G4double GetDz () const { return fDz ; }
00129 inline G4double GetPhi () const { return fPhi ; }
00130 inline G4double GetTheta () const { return fTheta ; }
00131 inline G4double GetAlpha () const { return fAlph ; }
00132
00133 inline G4double Xcoef(G4double u,G4double phi, G4double ftg) const ;
00134
00135
00136 inline G4double GetValueA(G4double phi) const;
00137 inline G4double GetValueB(G4double phi) const;
00138 inline G4double GetValueD(G4double phi) const;
00139
00140 virtual G4VisExtent GetExtent () const;
00141 virtual G4GeometryType GetEntityType() const;
00142
00143 public:
00144
00145 G4VTwistedFaceted(__void__&);
00146
00147
00148
00149
00150 G4VTwistedFaceted(const G4VTwistedFaceted& rhs);
00151 G4VTwistedFaceted& operator=(const G4VTwistedFaceted& rhs);
00152
00153
00154 protected:
00155
00156 G4ThreeVectorList*
00157 CreateRotatedVertices(const G4AffineTransform& pTransform) const;
00158
00159
00160
00161 private:
00162
00163 void CreateSurfaces();
00164
00165 private:
00166
00167 G4double fTheta;
00168 G4double fPhi ;
00169
00170 G4double fDy1;
00171 G4double fDx1;
00172 G4double fDx2;
00173
00174 G4double fDy2;
00175 G4double fDx3;
00176 G4double fDx4;
00177
00178 G4double fDz;
00179
00180 G4double fDx ;
00181 G4double fDy ;
00182
00183 G4double fAlph ;
00184 G4double fTAlph ;
00185
00186 G4double fdeltaX ;
00187 G4double fdeltaY ;
00188
00189 G4double fPhiTwist;
00190
00191 G4VTwistSurface *fLowerEndcap ;
00192 G4VTwistSurface *fUpperEndcap ;
00193
00194 G4VTwistSurface *fSide0 ;
00195 G4VTwistSurface *fSide90 ;
00196 G4VTwistSurface *fSide180 ;
00197 G4VTwistSurface *fSide270 ;
00198
00199 G4double fCubicVolume ;
00200 G4double fSurfaceArea ;
00201
00202 mutable G4Polyhedron* fpPolyhedron;
00203
00204 class LastState
00205 {
00206 public:
00207 LastState()
00208 {
00209 p.set(kInfinity,kInfinity,kInfinity); inside = kOutside;
00210 }
00211 ~LastState(){}
00212 LastState(const LastState& r) : p(r.p), inside(r.inside){}
00213 LastState& operator=(const LastState& r)
00214 {
00215 if (this == &r) { return *this; }
00216 p = r.p; inside = r.inside;
00217 return *this;
00218 }
00219 public:
00220 G4ThreeVector p;
00221 EInside inside;
00222 };
00223
00224 class LastVector
00225 {
00226 public:
00227 LastVector()
00228 {
00229 p.set(kInfinity,kInfinity,kInfinity);
00230 vec.set(kInfinity,kInfinity,kInfinity);
00231 surface = new G4VTwistSurface*[1];
00232 }
00233 ~LastVector()
00234 {
00235 delete [] surface;
00236 }
00237 LastVector(const LastVector& r) : p(r.p), vec(r.vec)
00238 {
00239 surface = new G4VTwistSurface*[1];
00240 surface[0] = r.surface[0];
00241 }
00242 LastVector& operator=(const LastVector& r)
00243 {
00244 if (&r == this) { return *this; }
00245 p = r.p; vec = r.vec;
00246 delete [] surface; surface = new G4VTwistSurface*[1];
00247 surface[0] = r.surface[0];
00248 return *this;
00249 }
00250 public:
00251 G4ThreeVector p;
00252 G4ThreeVector vec;
00253 G4VTwistSurface **surface;
00254 };
00255
00256 class LastValue
00257 {
00258 public:
00259 LastValue()
00260 {
00261 p.set(kInfinity,kInfinity,kInfinity);
00262 value = DBL_MAX;
00263 }
00264 ~LastValue(){}
00265 LastValue(const LastValue& r) : p(r.p), value(r.value){}
00266 LastValue& operator=(const LastValue& r)
00267 {
00268 if (this == &r) { return *this; }
00269 p = r.p; value = r.value;
00270 return *this;
00271 }
00272 public:
00273 G4ThreeVector p;
00274 G4double value;
00275 };
00276
00277 class LastValueWithDoubleVector
00278 {
00279 public:
00280 LastValueWithDoubleVector()
00281 {
00282 p.set(kInfinity,kInfinity,kInfinity);
00283 vec.set(kInfinity,kInfinity,kInfinity);
00284 value = DBL_MAX;
00285 }
00286 ~LastValueWithDoubleVector(){}
00287 LastValueWithDoubleVector(const LastValueWithDoubleVector& r)
00288 : p(r.p), vec(r.vec), value(r.value){}
00289 LastValueWithDoubleVector& operator=(const LastValueWithDoubleVector& r)
00290 {
00291 if (this == &r) { return *this; }
00292 p = r.p; vec = r.vec; value = r.value;
00293 return *this;
00294 }
00295 public:
00296 G4ThreeVector p;
00297 G4ThreeVector vec;
00298 G4double value;
00299 };
00300
00301 LastState fLastInside;
00302 LastVector fLastNormal;
00303 LastValue fLastDistanceToIn;
00304 LastValue fLastDistanceToOut;
00305 LastValueWithDoubleVector fLastDistanceToInWithV;
00306 LastValueWithDoubleVector fLastDistanceToOutWithV;
00307
00308 };
00309
00310
00311
00312 inline
00313 G4double G4VTwistedFaceted::GetCubicVolume()
00314 {
00315 if(fCubicVolume != 0.) ;
00316 else fCubicVolume = 2 * fDz
00317 * ( ( fDx1 + fDx2 ) * fDy1 + ( fDx3 + fDx4 ) * fDy2 );
00318 return fCubicVolume;
00319 }
00320
00321 inline
00322 G4double G4VTwistedFaceted::GetSurfaceArea()
00323 {
00324 if(fSurfaceArea != 0.) ;
00325 else fSurfaceArea = G4VSolid::GetSurfaceArea();
00326 return fSurfaceArea;
00327 }
00328
00329 inline
00330 G4double G4VTwistedFaceted::GetValueA(G4double phi) const
00331 {
00332 return ( fDx4 + fDx2 + ( fDx4 - fDx2 ) * ( 2 * phi ) / fPhiTwist ) ;
00333 }
00334
00335 inline
00336 G4double G4VTwistedFaceted::GetValueD(G4double phi) const
00337 {
00338 return ( fDx3 + fDx1 + ( fDx3 - fDx1 ) * ( 2 * phi ) / fPhiTwist ) ;
00339 }
00340
00341 inline
00342 G4double G4VTwistedFaceted::GetValueB(G4double phi) const
00343 {
00344 return ( fDy2 + fDy1 + ( fDy2 - fDy1 ) * ( 2 * phi ) / fPhiTwist ) ;
00345 }
00346
00347 inline
00348 G4double G4VTwistedFaceted::Xcoef(G4double u, G4double phi, G4double ftg) const
00349 {
00350 return GetValueA(phi)/2. + (GetValueD(phi)-GetValueA(phi))/4.
00351 - u*( ( GetValueD(phi)-GetValueA(phi) ) / ( 2 * GetValueB(phi) ) - ftg );
00352 }
00353
00354 #endif