36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
49 std::vector<G4TwoVector> polygon,
50 std::vector<ZSection> zsections)
51 : G4USolid(name, new UExtrudedSolid())
53 GetShape()->SetName(name);
54 std::vector<UVector2> pvec;
55 for (
unsigned int i=0; i<polygon.size(); ++i)
57 pvec.push_back(UVector2(polygon[i].
x(), polygon[i].y()));
59 std::vector<UExtrudedSolid::ZSection> svec;
60 for (
unsigned int i=0; i<zsections.size(); ++i)
62 ZSection sec = zsections[i];
63 svec.push_back(UExtrudedSolid::ZSection(sec.fZ,
64 UVector2(sec.fOffset.x(), sec.fOffset.y()), sec.fScale));
66 GetShape()->Initialise(pvec, svec);
70 G4UExtrudedSolid::G4UExtrudedSolid(
const G4String& name,
71 std::vector<G4TwoVector> polygon,
75 : G4USolid(name, new UExtrudedSolid())
77 GetShape()->SetName(name);
78 std::vector<UVector2> pvec;
79 for (
unsigned int i=0; i<polygon.size(); ++i)
81 pvec.push_back(UVector2(polygon[i].
x(), polygon[i].y()));
83 GetShape()->Initialise(pvec, halfZ, UVector2(off1.
x(), off1.
y()), scale1,
84 UVector2(off2.
x(), off2.
y()), scale2);
92 G4UExtrudedSolid::G4UExtrudedSolid(__void__&
a)
102 G4UExtrudedSolid::~G4UExtrudedSolid()
111 G4UExtrudedSolid::G4UExtrudedSolid(
const G4UExtrudedSolid &source)
122 G4UExtrudedSolid::operator=(
const G4UExtrudedSolid &source)
124 if (
this == &source)
return *
this;
126 G4USolid::operator=( source );
136 G4int G4UExtrudedSolid::GetNofVertices()
const
138 return GetShape()->GetNofVertices();
142 UVector2
v = GetShape()->GetVertex(i);
145 std::vector<G4TwoVector> G4UExtrudedSolid::GetPolygon()
const
147 std::vector<UVector2> pol = GetShape()->GetPolygon();
148 std::vector<G4TwoVector>
v;
149 for (
unsigned int i=0; i<pol.size(); ++i)
155 G4int G4UExtrudedSolid::GetNofZSections()
const
157 return GetShape()->GetNofZSections();
159 G4UExtrudedSolid::ZSection G4UExtrudedSolid::GetZSection(
G4int i)
const
161 return ZSection(GetShape()->GetZSection(i));
163 std::vector<G4UExtrudedSolid::ZSection> G4UExtrudedSolid::GetZSections()
const
165 std::vector<UExtrudedSolid::ZSection> sv = GetShape()->GetZSections();
166 std::vector<G4UExtrudedSolid::ZSection> vec;
167 for (
unsigned int i=0; i<sv.size(); ++i)
169 vec.push_back(ZSection(sv[i]));
181 static G4bool checkBBox =
true;
186 for (
G4int i=0; i<GetNofVertices(); ++i)
190 if (x < xmin0) xmin0 =
x;
191 if (x > xmax0) xmax0 =
x;
193 if (y < ymin0) ymin0 = y;
194 if (y > ymax0) ymax0 = y;
200 G4int nsect = GetNofZSections();
201 for (
G4int i=0; i<nsect; ++i)
203 ZSection zsect = GetZSection(i);
207 xmin =
std::min(xmin,xmin0*scale+dx);
208 xmax =
std::max(xmax,xmax0*scale+dx);
209 ymin =
std::min(ymin,ymin0*scale+dy);
210 ymax =
std::max(ymax,ymax0*scale+dy);
214 G4double zmax = GetZSection(nsect-1).fZ;
216 pMin.
set(xmin,ymin,zmin);
217 pMax.
set(xmax,ymax,zmax);
221 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
223 std::ostringstream message;
224 message <<
"Bad bounding box (min >= max) for solid: "
226 <<
"\npMin = " << pMin
227 <<
"\npMax = " << pMax;
228 G4Exception(
"G4UExtrudedSolid::Extent()",
"GeomMgt0001",
238 GetShape()->Extent(vmin,vmax);
246 std::ostringstream message;
247 message <<
"Inconsistency in bounding boxes for solid: "
249 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
250 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
263 G4UExtrudedSolid::CalculateExtent(
const EAxis pAxis,
276 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
278 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
280 return exist = (pMin < pMax) ?
true :
false;
295 std::ostringstream message;
296 message <<
"Triangulation of the base polygon has failed for solid: "
298 <<
"\nExtent has been calculated using boundary box";
301 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
305 G4int nsect = GetNofZSections();
306 std::vector<const G4ThreeVectorList *> polygons;
307 polygons.resize(nsect);
313 G4int ntria = triangles.size()/3;
314 for (
G4int i=0; i<ntria; ++i)
317 for (
G4int k=0; k<nsect; ++k)
319 ZSection zsect = GetZSection(k);
326 G4ThreeVectorList::iterator iter = ptr->begin();
327 G4double x0 = triangles[i3+0].x()*scale+dx;
328 G4double y0 = triangles[i3+0].y()*scale+dy;
331 G4double x1 = triangles[i3+1].x()*scale+dx;
332 G4double y1 = triangles[i3+1].y()*scale+dy;
335 G4double x2 = triangles[i3+2].x()*scale+dx;
336 G4double y2 = triangles[i3+2].y()*scale+dy;
343 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
344 if (emin < pMin) pMin = emin;
345 if (emax > pMax) pMax =
emax;
346 if (eminlim > pMin && emaxlim < pMax)
break;
349 for (
G4int k=0; k<nsect; ++k) {
delete polygons[k]; polygons[k]=0;}
350 return (pMin < pMax);
358 G4Polyhedron* G4UExtrudedSolid::CreatePolyhedron ()
const
360 G4int nFacets = GetShape()->GetNumberOfFacets();
362 for (
G4int l = 0; l<nFacets; ++l)
364 VUFacet* facet = GetShape()->
GetFacet(l);
365 G4int n = facet->GetNumberOfVertices();
372 for (
G4int i = 0; i<nFacets; ++i)
374 VUFacet* facet = GetShape()->GetFacet(i);
376 G4int n = facet->GetNumberOfVertices();
379 UVector3 vtx = facet->GetVertex(
m);
383 else if (n == 3) v[3] = 0;
386 G4int k = facet->GetVertexIndex(j);
389 polyhedron->
AddFacet(v[0],v[1],v[2],v[3]);
396 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
static const G4double kInfinity
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
G4GLOB_DLL std::ostream G4cout
static constexpr double m
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void AddVertex(const G4ThreeVector &v)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static const G4double emax
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
CLHEP::Hep2Vector G4TwoVector
G4double GetMaxExtent(const EAxis pAxis) const
G4double GetMinExtent(const EAxis pAxis) const