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);
62G4UGenericTrap::G4UGenericTrap(__void__& a)
63 : Base_t(a), fVisSubdivisions(0)
72G4UGenericTrap::~G4UGenericTrap() =
default;
79G4UGenericTrap::G4UGenericTrap(
const G4UGenericTrap& source)
80 : Base_t(source), fVisSubdivisions(source.fVisSubdivisions),
81 fVertices(source.fVertices)
91G4UGenericTrap::operator=(
const G4UGenericTrap& source)
93 if (
this == &source)
return *
this;
95 Base_t::operator=( source );
96 fVertices = source.fVertices;
97 fVisSubdivisions = source.fVisSubdivisions;
106G4double G4UGenericTrap::GetZHalfLength()
const
110G4int G4UGenericTrap::GetNofVertices()
const
112 return fVertices.size();
116 return { GetVerticesX()[index], GetVerticesY()[index] };
118const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices()
const
124 return GetTwist(index);
126G4bool G4UGenericTrap::IsTwisted()
const
130G4int G4UGenericTrap::GetVisSubdivisions()
const
132 return fVisSubdivisions;
135void G4UGenericTrap::SetVisSubdivisions(
G4int subdiv)
137 fVisSubdivisions = subdiv;
140void G4UGenericTrap::SetZHalfLength(
G4double halfZ)
145void G4UGenericTrap::Initialise(
const std::vector<G4TwoVector>& v)
147 G4double verticesx[8], verticesy[8];
148 for (
G4int i=0; i<8; ++i)
150 fVertices.push_back(v[i]);
151 verticesx[i] = v[i].x();
152 verticesy[i] = v[i].y();
154 Initialize(verticesx, verticesy, GetZHalfLength());
166 pMin.
set(vmin.x(),vmin.y(),vmin.z());
167 pMax.
set(vmax.x(),vmax.y(),vmax.z());
171 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
173 std::ostringstream message;
174 message <<
"Bad bounding box (min >= max) for solid: "
176 <<
"\npMin = " << pMin
177 <<
"\npMax = " << pMax;
178 G4Exception(
"G4UGenericTrap::BoundingLimits()",
"GeomMgt0001",
189G4UGenericTrap::CalculateExtent(
const EAxis pAxis,
199 BoundingLimits(bmin,bmax);
202 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
204 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
206 return exist = pMin < pMax;
218 for (
G4int i=0; i<4; ++i)
222 baseA[2*i].set(va.
x(),va.
y(),-dz);
223 baseB[2*i].set(vb.
x(),vb.
y(), dz);
225 for (
G4int i=0; i<4; ++i)
227 G4int k1=2*i, k2=(2*i+2)%8;
228 G4double ax = (baseA[k2].x()-baseA[k1].x());
229 G4double ay = (baseA[k2].y()-baseA[k1].y());
230 G4double bx = (baseB[k2].x()-baseB[k1].x());
231 G4double by = (baseB[k2].y()-baseB[k1].y());
233 baseA[k1+1] = (znorm < 0.0) ? baseA[k2] : baseA[k1];
234 baseB[k1+1] = (znorm < 0.0) ? baseB[k1] : baseB[k2];
237 std::vector<const G4ThreeVectorList *> polygons(2);
238 polygons[0] = &baseA;
239 polygons[1] = &baseB;
242 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
256 G4int nVertices, nFacets;
259 G4int subdivisions = 0;
262 if (GetVisSubdivisions() != 0)
264 subdivisions = GetVisSubdivisions();
271 for(
G4int i = 0; i < 4; ++i)
273 if (GetTwistAngle(i) > maxTwist) { maxTwist = GetTwistAngle(i); }
280 BoundingLimits(minVec, maxVec);
281 Dx = 0.5*(maxVec.
x() - minVec.
y());
282 Dy = 0.5*(maxVec.
y() - minVec.
y());
283 if (Dy > Dx) { Dx = Dy; }
285 subdivisions = 8*
G4int(maxTwist/(Dx*Dx*Dx)*fDz);
286 if (subdivisions < 4) { subdivisions = 4; }
287 if (subdivisions > 30) { subdivisions = 30; }
290 G4int sub4 = 4*subdivisions;
291 nVertices = 8 + subdivisions*4;
292 nFacets = 6 + subdivisions*4;
293 G4double cf = 1./(subdivisions + 1);
299 for (
G4int i = 0; i < 4; ++i)
304 for (
G4int i = 0; i < subdivisions; ++i)
306 for (
G4int j = 0; j < 4; ++j)
308 G4TwoVector u = GetVertex(j)+cf*(i+1)*( GetVertex(j+4)-GetVertex(j));
313 for (
G4int i = 4; i < 8; ++i)
322 polyhedron->
SetFacet(++icur, 1, 4, 3, 2);
323 for (
G4int i = 0; i < subdivisions + 1; ++i)
326 polyhedron->
SetFacet(++icur, 5+is, 8+is, 4+is, 1+is);
327 polyhedron->
SetFacet(++icur, 8+is, 7+is, 3+is, 4+is);
328 polyhedron->
SetFacet(++icur, 7+is, 6+is, 2+is, 3+is);
329 polyhedron->
SetFacet(++icur, 6+is, 5+is, 1+is, 2+is);
331 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)
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
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)