34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
49 const std::vector<G4TwoVector>& vertices)
50 : Base_t(
name), fVisSubdivisions(0)
52 SetZHalfLength(halfZ);
61G4UGenericTrap::G4UGenericTrap(
const G4UGenericTrap& source)
62 : Base_t(source), fVisSubdivisions(source.fVisSubdivisions),
63 fVertices(source.fVertices)
73G4UGenericTrap::operator=(
const G4UGenericTrap& source)
75 if (
this == &source)
return *
this;
77 Base_t::operator=( source );
78 fVertices = source.fVertices;
79 fVisSubdivisions = source.fVisSubdivisions;
88G4double G4UGenericTrap::GetZHalfLength()
const
92G4int G4UGenericTrap::GetNofVertices()
const
94 return fVertices.size();
98 return { vecgeom::UnplacedGenTrap::GetVertex(index).x(), vecgeom::UnplacedGenTrap::GetVertex(index).y() };
100const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices()
const
106 return GetTwist(index);
108G4bool G4UGenericTrap::IsTwisted()
const
112G4int G4UGenericTrap::GetVisSubdivisions()
const
114 return fVisSubdivisions;
117void G4UGenericTrap::SetVisSubdivisions(
G4int subdiv)
119 fVisSubdivisions = subdiv;
122void G4UGenericTrap::SetZHalfLength(
G4double halfZ)
127void G4UGenericTrap::Initialise(
const std::vector<G4TwoVector>& v)
129 G4double verticesx[8], verticesy[8];
130 for (
G4int i=0; i<8; ++i)
132 fVertices.push_back(v[i]);
133 verticesx[i] = v[i].x();
134 verticesy[i] = v[i].y();
136 Initialize(verticesx, verticesy, GetZHalfLength());
148 pMin.
set(vmin.x(),vmin.y(),vmin.z());
149 pMax.
set(vmax.x(),vmax.y(),vmax.z());
153 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
155 std::ostringstream message;
156 message <<
"Bad bounding box (min >= max) for solid: "
158 <<
"\npMin = " << pMin
159 <<
"\npMax = " << pMax;
160 G4Exception(
"G4UGenericTrap::BoundingLimits()",
"GeomMgt0001",
171G4UGenericTrap::CalculateExtent(
const EAxis pAxis,
181 BoundingLimits(bmin,bmax);
184 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
186 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
188 return exist = pMin < pMax;
200 for (
G4int i=0; i<4; ++i)
204 baseA[2*i].set(va.
x(),va.
y(),-dz);
205 baseB[2*i].set(vb.
x(),vb.
y(), dz);
207 for (
G4int i=0; i<4; ++i)
209 G4int k1=2*i, k2=(2*i+2)%8;
210 G4double ax = (baseA[k2].x()-baseA[k1].x());
211 G4double ay = (baseA[k2].y()-baseA[k1].y());
212 G4double bx = (baseB[k2].x()-baseB[k1].x());
213 G4double by = (baseB[k2].y()-baseB[k1].y());
215 baseA[k1+1] = (znorm < 0.0) ? baseA[k2] : baseA[k1];
216 baseB[k1+1] = (znorm < 0.0) ? baseB[k1] : baseB[k2];
219 std::vector<const G4ThreeVectorList *> polygons(2);
220 polygons[0] = &baseA;
221 polygons[1] = &baseB;
224 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
238 G4int nVertices, nFacets;
241 G4int subdivisions = 0;
244 if (GetVisSubdivisions() != 0)
246 subdivisions = GetVisSubdivisions();
253 for(
G4int i = 0; i < 4; ++i)
255 if (GetTwistAngle(i) > maxTwist) { maxTwist = GetTwistAngle(i); }
262 BoundingLimits(minVec, maxVec);
263 Dx = 0.5*(maxVec.
x() - minVec.
y());
264 Dy = 0.5*(maxVec.
y() - minVec.
y());
265 if (Dy > Dx) { Dx = Dy; }
267 subdivisions = 8*
G4int(maxTwist/(Dx*Dx*Dx)*fDz);
268 if (subdivisions < 4) { subdivisions = 4; }
269 if (subdivisions > 30) { subdivisions = 30; }
272 G4int sub4 = 4*subdivisions;
273 nVertices = 8 + subdivisions*4;
274 nFacets = 6 + subdivisions*4;
275 G4double cf = 1./(subdivisions + 1);
281 for (
G4int i = 0; i < 4; ++i)
286 for (
G4int i = 0; i < subdivisions; ++i)
288 for (
G4int j = 0; j < 4; ++j)
290 G4TwoVector u = GetVertex(j)+cf*(i+1)*( GetVertex(j+4)-GetVertex(j));
295 for (
G4int i = 4; i < 8; ++i)
304 polyhedron->
SetFacet(++icur, 1, 4, 3, 2);
305 for (
G4int i = 0; i < subdivisions + 1; ++i)
308 polyhedron->
SetFacet(++icur, 5+is, 8+is, 4+is, 1+is);
309 polyhedron->
SetFacet(++icur, 8+is, 7+is, 3+is, 4+is);
310 polyhedron->
SetFacet(++icur, 7+is, 6+is, 2+is, 3+is);
311 polyhedron->
SetFacet(++icur, 6+is, 5+is, 1+is, 2+is);
313 polyhedron->
SetFacet(++icur, 5+sub4, 6+sub4, 7+sub4, 8+sub4);
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
CLHEP::Hep2Vector G4TwoVector
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4BoundingEnvelope is a helper class to facilitate calculation of the extent of a solid within the li...
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
void SetVertex(G4int index, const G4Point3D &v)
void SetFacet(G4int index, G4int iv1, G4int iv2, G4int iv3, G4int iv4=0)
const char * name(G4int ptype)