34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
43 using namespace CLHEP;
50 const std::vector<G4TwoVector>& vertices)
51 : Base_t(name), fVisSubdivisions(0)
53 SetZHalfLength(halfZ);
63 G4UGenericTrap::G4UGenericTrap(__void__&
a)
64 : Base_t(a), fVisSubdivisions(0), fVertices()
73 G4UGenericTrap::~G4UGenericTrap()
82 G4UGenericTrap::G4UGenericTrap(
const G4UGenericTrap& source)
83 : Base_t(source), fVisSubdivisions(source.fVisSubdivisions),
84 fVertices(source.fVertices)
95 G4UGenericTrap::operator=(
const G4UGenericTrap& source)
97 if (
this == &source)
return *
this;
99 Base_t::operator=( source );
100 fVertices = source.fVertices;
101 fVisSubdivisions = source.fVisSubdivisions;
110 G4double G4UGenericTrap::GetZHalfLength()
const
114 G4int G4UGenericTrap::GetNofVertices()
const
116 return fVertices.size();
120 return G4TwoVector(GetVerticesX()[index], GetVerticesY()[index]);
122 const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices()
const
128 return GetTwist(index);
130 G4bool G4UGenericTrap::IsTwisted()
const
134 G4int G4UGenericTrap::GetVisSubdivisions()
const
136 return fVisSubdivisions;
139 void G4UGenericTrap::SetVisSubdivisions(
G4int subdiv)
141 fVisSubdivisions = subdiv;
144 void G4UGenericTrap::SetZHalfLength(
G4double halfZ)
149 void G4UGenericTrap::Initialise(
const std::vector<G4TwoVector>&
v)
151 G4double verticesx[8], verticesy[8];
152 for (
G4int i=0; i<8; ++i)
154 fVertices.push_back(v[i]);
155 verticesx[i] = v[i].x();
156 verticesy[i] = v[i].y();
158 Initialize(verticesx, verticesy, GetZHalfLength());
170 pMin.
set(vmin.x(),vmin.y(),vmin.z());
171 pMax.
set(vmax.x(),vmax.y(),vmax.z());
175 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
178 message <<
"Bad bounding box (min >= max) for solid: "
180 <<
"\npMin = " << pMin
181 <<
"\npMax = " <<
pMax;
182 G4Exception(
"G4UGenericTrap::BoundingLimits()",
"GeomMgt0001",
193 G4UGenericTrap::CalculateExtent(
const EAxis pAxis,
203 BoundingLimits(bmin,bmax);
206 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)
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); }
285 BoundingLimits(minVec,maxVec);
286 Dx = 0.5*(maxVec.
x()- minVec.
y());
287 Dy = 0.5*(maxVec.
y()- minVec.
y());
288 if (Dy > Dx) { Dx=
Dy; }
290 subdivisions=8*
G4int(maxTwist/(Dx*Dx*Dx)*fDz);
291 if (subdivisions<4) { subdivisions=4; }
292 if (subdivisions>30) { subdivisions=30; }
295 G4int sub4=4*subdivisions;
296 nVertices = 8+subdivisions*4;
297 nFacets = 6+subdivisions*4;
306 GetVertex(i).
y(),-fDz));
308 for(i=0; i<subdivisions; ++i)
310 for(
G4int j=0; j<4 ; ++j)
312 G4TwoVector u=GetVertex(j)+cf*(i+1)*( GetVertex(j+4)-GetVertex(j));
319 GetVertex(i).
y(),fDz));
325 for (i=0; i<subdivisions+1; ++i)
328 polyhedron->
AddFacet(5+is,8+is,4+is,1+is);
329 polyhedron->
AddFacet(8+is,7+is,3+is,4+is);
330 polyhedron->
AddFacet(7+is,6+is,2+is,3+is);
331 polyhedron->
AddFacet(6+is,5+is,1+is,2+is);
333 polyhedron->
AddFacet(5+sub4,6+sub4,7+sub4,8+sub4);
341 #endif // G4GEOM_USE_USOLIDS