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), fVertices()
72G4UGenericTrap::~G4UGenericTrap()
81G4UGenericTrap::G4UGenericTrap(
const G4UGenericTrap& source)
82 : Base_t(source), fVisSubdivisions(source.fVisSubdivisions),
83 fVertices(source.fVertices)
94G4UGenericTrap::operator=(
const G4UGenericTrap& source)
96 if (
this == &source)
return *
this;
98 Base_t::operator=( source );
99 fVertices = source.fVertices;
100 fVisSubdivisions = source.fVisSubdivisions;
109G4double G4UGenericTrap::GetZHalfLength()
const
113G4int G4UGenericTrap::GetNofVertices()
const
115 return fVertices.size();
119 return G4TwoVector(GetVerticesX()[index], GetVerticesY()[index]);
121const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices()
const
127 return GetTwist(index);
129G4bool G4UGenericTrap::IsTwisted()
const
133G4int G4UGenericTrap::GetVisSubdivisions()
const
135 return fVisSubdivisions;
138void G4UGenericTrap::SetVisSubdivisions(
G4int subdiv)
140 fVisSubdivisions = subdiv;
143void G4UGenericTrap::SetZHalfLength(
G4double halfZ)
148void G4UGenericTrap::Initialise(
const std::vector<G4TwoVector>& v)
150 G4double verticesx[8], verticesy[8];
151 for (
G4int i=0; i<8; ++i)
153 fVertices.push_back(v[i]);
154 verticesx[i] = v[i].x();
155 verticesy[i] = v[i].y();
157 Initialize(verticesx, verticesy, GetZHalfLength());
169 pMin.
set(vmin.x(),vmin.y(),vmin.z());
170 pMax.
set(vmax.x(),vmax.y(),vmax.z());
174 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
176 std::ostringstream message;
177 message <<
"Bad bounding box (min >= max) for solid: "
179 <<
"\npMin = " << pMin
180 <<
"\npMax = " << pMax;
181 G4Exception(
"G4UGenericTrap::BoundingLimits()",
"GeomMgt0001",
192G4UGenericTrap::CalculateExtent(
const EAxis pAxis,
202 BoundingLimits(bmin,bmax);
205 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
207 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
209 return exist = (pMin < pMax) ?
true :
false;
221 for (
G4int i=0; i<4; ++i)
225 baseA[2*i].set(va.
x(),va.
y(),-dz);
226 baseB[2*i].set(vb.
x(),vb.
y(), dz);
228 for (
G4int i=0; i<4; ++i)
230 G4int k1=2*i, k2=(2*i+2)%8;
231 G4double ax = (baseA[k2].x()-baseA[k1].x());
232 G4double ay = (baseA[k2].y()-baseA[k1].y());
233 G4double bx = (baseB[k2].x()-baseB[k1].x());
234 G4double by = (baseB[k2].y()-baseB[k1].y());
236 baseA[k1+1] = (znorm < 0.0) ? baseA[k2] : baseA[k1];
237 baseB[k1+1] = (znorm < 0.0) ? baseB[k1] : baseB[k2];
240 std::vector<const G4ThreeVectorList *> polygons(2);
241 polygons[0] = &baseA;
242 polygons[1] = &baseB;
245 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
259 G4int nVertices, nFacets;
262 G4int subdivisions = 0;
265 if (GetVisSubdivisions() != 0)
267 subdivisions = GetVisSubdivisions();
274 for(
G4int i = 0; i < 4; ++i)
276 if (GetTwistAngle(i) > maxTwist) { maxTwist = GetTwistAngle(i); }
283 BoundingLimits(minVec, maxVec);
284 Dx = 0.5*(maxVec.
x() - minVec.
y());
285 Dy = 0.5*(maxVec.
y() - minVec.
y());
286 if (Dy > Dx) { Dx = Dy; }
288 subdivisions = 8*
G4int(maxTwist/(Dx*Dx*Dx)*fDz);
289 if (subdivisions < 4) { subdivisions = 4; }
290 if (subdivisions > 30) { subdivisions = 30; }
293 G4int sub4 = 4*subdivisions;
294 nVertices = 8 + subdivisions*4;
295 nFacets = 6 + subdivisions*4;
296 G4double cf = 1./(subdivisions + 1);
302 for (
G4int i = 0; i < 4; ++i)
307 for (
G4int i = 0; i < subdivisions; ++i)
309 for (
G4int j = 0; j < 4; ++j)
311 G4TwoVector u = GetVertex(j)+cf*(i+1)*( GetVertex(j+4)-GetVertex(j));
316 for (
G4int i = 4; i < 8; ++i)
325 polyhedron->
SetFacet(++icur, 1, 4, 3, 2);
326 for (
G4int i = 0; i < subdivisions + 1; ++i)
329 polyhedron->
SetFacet(++icur, 5+is, 8+is, 4+is, 1+is);
330 polyhedron->
SetFacet(++icur, 8+is, 7+is, 3+is, 4+is);
331 polyhedron->
SetFacet(++icur, 7+is, 6+is, 2+is, 3+is);
332 polyhedron->
SetFacet(++icur, 6+is, 5+is, 1+is, 2+is);
334 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::Hep2Vector G4TwoVector
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)