36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
45 using namespace CLHEP;
52 const std::vector<G4TwoVector>& vertices)
53 : Base_t(name), fVisSubdivisions(0)
55 SetZHalfLength(halfZ);
65 G4UGenericTrap::G4UGenericTrap(__void__&
a)
66 : Base_t(a), fVisSubdivisions(0), fVertices()
75 G4UGenericTrap::~G4UGenericTrap()
84 G4UGenericTrap::G4UGenericTrap(
const G4UGenericTrap &source)
85 : Base_t(source), fVisSubdivisions(source.fVisSubdivisions),
86 fVertices(source.fVertices)
97 G4UGenericTrap::operator=(
const G4UGenericTrap &source)
99 if (
this == &source)
return *
this;
101 Base_t::operator=( source );
102 fVertices = source.fVertices;
103 fVisSubdivisions = source.fVisSubdivisions;
112 G4double G4UGenericTrap::GetZHalfLength()
const
116 G4int G4UGenericTrap::GetNofVertices()
const
118 return fVertices.size();
122 return G4TwoVector(GetVerticesX()[index], GetVerticesY()[index]);
124 const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices()
const
130 return GetTwist(index);
132 G4bool G4UGenericTrap::IsTwisted()
const
136 G4int G4UGenericTrap::GetVisSubdivisions()
const
138 return fVisSubdivisions;
141 void G4UGenericTrap::SetVisSubdivisions(
G4int subdiv)
143 fVisSubdivisions = subdiv;
146 void G4UGenericTrap::SetZHalfLength(
G4double halfZ)
151 void G4UGenericTrap::Initialise(
const std::vector<G4TwoVector>& v)
153 G4double verticesx[8], verticesy[8];
154 for (
G4int i=0; i<8; ++i)
156 fVertices.push_back(v[i]);
157 verticesx[i] = v[i].x();
158 verticesy[i] = v[i].y();
160 Initialize(verticesx, verticesy, GetZHalfLength());
172 pMin.
set(vmin.x(),vmin.y(),vmin.z());
173 pMax.
set(vmax.x(),vmax.y(),vmax.z());
177 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
180 message <<
"Bad bounding box (min >= max) for solid: "
182 <<
"\npMin = " << pMin
183 <<
"\npMax = " << pMax;
184 G4Exception(
"G4UGenericTrap::BoundingLimits()",
"GeomMgt0001",
195 G4UGenericTrap::CalculateExtent(
const EAxis pAxis,
205 BoundingLimits(bmin,bmax);
208 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
210 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
212 return exist = (pMin < pMax) ?
true :
false;
224 for (
G4int i=0; i<4; ++i)
228 baseA[2*i].set(va.
x(),va.
y(),-dz);
229 baseB[2*i].set(vb.
x(),vb.
y(), dz);
231 for (
G4int i=0; i<4; ++i)
233 G4int k1=2*i, k2=(2*i+2)%8;
234 G4double ax = (baseA[k2].x()-baseA[k1].x());
235 G4double ay = (baseA[k2].y()-baseA[k1].y());
236 G4double bx = (baseB[k2].x()-baseB[k1].x());
237 G4double by = (baseB[k2].y()-baseB[k1].y());
239 baseA[k1+1] = (znorm < 0.0) ? baseA[k2] : baseA[k1];
240 baseB[k1+1] = (znorm < 0.0) ? baseB[k1] : baseB[k2];
243 std::vector<const G4ThreeVectorList *> polygons(2);
244 polygons[0] = &baseA;
245 polygons[1] = &baseB;
248 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
262 size_t nVertices, nFacets;
265 G4int subdivisions=0;
269 if ( GetVisSubdivisions()!= 0 )
271 subdivisions=GetVisSubdivisions();
280 if(GetTwistAngle(i)>maxTwist) { maxTwist=GetTwistAngle(i); }
287 BoundingLimits(minVec,maxVec);
288 Dx = 0.5*(maxVec.
x()- minVec.
y());
289 Dy = 0.5*(maxVec.
y()- minVec.
y());
290 if (Dy > Dx) { Dx=Dy; }
292 subdivisions=8*
G4int(maxTwist/(Dx*Dx*Dx)*fDz);
293 if (subdivisions<4) { subdivisions=4; }
294 if (subdivisions>30) { subdivisions=30; }
297 G4int sub4=4*subdivisions;
298 nVertices = 8+subdivisions*4;
299 nFacets = 6+subdivisions*4;
308 GetVertex(i).
y(),-fDz));
310 for( i=0;i<subdivisions;i++)
312 for(
G4int j=0;j<4;j++)
314 G4TwoVector u=GetVertex(j)+cf*(i+1)*( GetVertex(j+4)-GetVertex(j));
321 GetVertex(i).
y(),fDz));
327 for (i=0;i<subdivisions+1;i++)
330 polyhedron->
AddFacet(5+is,8+is,4+is,1+is);
331 polyhedron->
AddFacet(8+is,7+is,3+is,4+is);
332 polyhedron->
AddFacet(7+is,6+is,2+is,3+is);
333 polyhedron->
AddFacet(6+is,5+is,1+is,2+is);
335 polyhedron->
AddFacet(5+sub4,6+sub4,7+sub4,8+sub4);
343 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
void AddVertex(const G4ThreeVector &v)
CLHEP::Hep2Vector G4TwoVector
void message(RunManager *runmanager)
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout