36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
47 using namespace CLHEP;
54 const std::vector<G4TwoVector>& vertices)
55 : G4USolid(name, new UGenericTrap())
57 SetZHalfLength(halfZ);
58 std::vector<UVector2> v;
59 for (
size_t n=0;
n<vertices.size(); ++
n)
61 v.push_back(UVector2(vertices[
n].x(),vertices[
n].y()));
63 GetShape()->SetName(name);
64 GetShape()->Initialise(v);
73 G4UGenericTrap::G4UGenericTrap(__void__&
a)
83 G4UGenericTrap::~G4UGenericTrap()
92 G4UGenericTrap::G4UGenericTrap(
const G4UGenericTrap &source)
103 G4UGenericTrap::operator=(
const G4UGenericTrap &source)
105 if (
this == &source)
return *
this;
107 G4USolid::operator=( source );
116 G4double G4UGenericTrap::GetZHalfLength()
const
118 return GetShape()->GetZHalfLength();
120 G4int G4UGenericTrap::GetNofVertices()
const
122 return GetShape()->GetNofVertices();
126 UVector2 v = GetShape()->GetVertex(index);
129 const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices()
const
132 std::vector<UVector2> v = GetShape()->GetVertices();
133 static std::vector<G4TwoVector> vertices; vertices.clear();
134 for (
size_t n=0;
n<v.size(); ++
n)
142 return GetShape()->GetTwistAngle(index);
144 G4bool G4UGenericTrap::IsTwisted()
const
146 return GetShape()->IsTwisted();
148 G4int G4UGenericTrap::GetVisSubdivisions()
const
150 return GetShape()->GetVisSubdivisions();
153 void G4UGenericTrap::SetVisSubdivisions(
G4int subdiv)
155 GetShape()->SetVisSubdivisions(subdiv);
158 void G4UGenericTrap::SetZHalfLength(
G4double halfZ)
160 GetShape()->SetZHalfLength(halfZ);
170 GetShape()->Extent(vmin,vmax);
171 pMin.set(vmin.x(),vmin.y(),vmin.z());
172 pMax.set(vmax.x(),vmax.y(),vmax.z());
176 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
178 std::ostringstream message;
179 message <<
"Bad bounding box (min >= max) for solid: "
181 <<
"\npMin = " << pMin
182 <<
"\npMax = " << pMax;
193 G4UGenericTrap::CalculateExtent(
const EAxis pAxis,
206 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
208 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
210 return exist = (pMin < pMax) ?
true :
false;
222 for (
G4int i=0; i<4; ++i)
226 baseA[2*i].set(va.x(),va.y(),-dz);
227 baseB[2*i].set(vb.x(),vb.y(), dz);
229 for (
G4int i=0; i<4; ++i)
231 G4int k1=2*i, k2=(2*i+2)%8;
232 G4double ax = (baseA[k2].x()-baseA[k1].x());
233 G4double ay = (baseA[k2].y()-baseA[k1].y());
234 G4double bx = (baseB[k2].x()-baseB[k1].x());
235 G4double by = (baseB[k2].y()-baseB[k1].y());
237 baseA[k1+1] = (znorm < 0.0) ? baseA[k2] : baseA[k1];
238 baseB[k1+1] = (znorm < 0.0) ? baseB[k1] : baseB[k2];
241 std::vector<const G4ThreeVectorList *> polygons(2);
242 polygons[0] = &baseA;
243 polygons[1] = &baseB;
246 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
260 size_t nVertices, nFacets;
263 G4int subdivisions=0;
267 if ( GetVisSubdivisions()!= 0 )
269 subdivisions=GetVisSubdivisions();
278 if(GetTwistAngle(i)>maxTwist) { maxTwist=GetTwistAngle(i); }
284 UVector3 minBox = GetShape()->GetMinimumBBox();
285 UVector3 maxBox = GetShape()->GetMaximumBBox();
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
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
const char * name(G4int ptype)
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
std::vector< G4ThreeVector > G4ThreeVectorList
void AddVertex(const G4ThreeVector &v)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
CLHEP::Hep2Vector G4TwoVector