34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
50 const std::vector<G4TwoVector>& vertices)
51 : Base_t(
name), fVisSubdivisions(0)
53 SetZHalfLength(halfZ);
63G4UGenericTrap::G4UGenericTrap(__void__& a)
64 : Base_t(a), fVisSubdivisions(0), fVertices()
73G4UGenericTrap::~G4UGenericTrap()
82G4UGenericTrap::G4UGenericTrap(
const G4UGenericTrap& source)
83 : Base_t(source), fVisSubdivisions(source.fVisSubdivisions),
84 fVertices(source.fVertices)
95G4UGenericTrap::operator=(
const G4UGenericTrap& source)
97 if (
this == &source)
return *
this;
99 Base_t::operator=( source );
100 fVertices = source.fVertices;
101 fVisSubdivisions = source.fVisSubdivisions;
110G4double G4UGenericTrap::GetZHalfLength()
const
114G4int G4UGenericTrap::GetNofVertices()
const
116 return fVertices.size();
120 return G4TwoVector(GetVerticesX()[index], GetVerticesY()[index]);
122const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices()
const
128 return GetTwist(index);
130G4bool G4UGenericTrap::IsTwisted()
const
134G4int G4UGenericTrap::GetVisSubdivisions()
const
136 return fVisSubdivisions;
139void G4UGenericTrap::SetVisSubdivisions(
G4int subdiv)
141 fVisSubdivisions = subdiv;
144void G4UGenericTrap::SetZHalfLength(
G4double halfZ)
149void 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())
177 std::ostringstream message;
178 message <<
"Bad bounding box (min >= max) for solid: "
180 <<
"\npMin = " << pMin
181 <<
"\npMax = " << pMax;
182 G4Exception(
"G4UGenericTrap::BoundingLimits()",
"GeomMgt0001",
193G4UGenericTrap::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)
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); }
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);
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)
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
void AddVertex(const G4ThreeVector &v)
const char * name(G4int ptype)