36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
49 std::vector<G4TwoVector> polygon,
50 std::vector<ZSection> zsections)
53 unsigned int nVertices = polygon.size();
54 unsigned int nSections = zsections.size();
56 vecgeom::XtruVertex2* vertices =
new vecgeom::XtruVertex2[nVertices];
57 vecgeom::XtruSection* sections =
new vecgeom::XtruSection[nSections];
59 for (
unsigned int i = 0; i < nVertices; ++i)
61 vertices[i].x = polygon[i].x();
62 vertices[i].y = polygon[i].y();
64 for (
unsigned int i = 0; i < nSections; ++i)
66 sections[i].fOrigin.Set(zsections[i].fOffset.x(),
67 zsections[i].fOffset.y(),
69 sections[i].fScale = zsections[i].fScale;
77 G4UExtrudedSolid::G4UExtrudedSolid(
const G4String& name,
78 std::vector<G4TwoVector> polygon,
84 unsigned int nVertices = polygon.size();
85 unsigned int nSections = 2;
87 vecgeom::XtruVertex2* vertices =
new vecgeom::XtruVertex2[nVertices];
88 vecgeom::XtruSection* sections =
new vecgeom::XtruSection[nSections];
90 for (
unsigned int i = 0; i < nVertices; ++i)
92 vertices[i].x = polygon[i].x();
93 vertices[i].y = polygon[i].y();
95 sections[0].fOrigin.Set(off1.
x(), off1.
y(), -halfZ);
96 sections[0].fScale = scale1;
97 sections[1].fOrigin.Set(off2.
x(), off2.
y(), halfZ);
98 sections[1].fScale = scale2;
109 G4UExtrudedSolid::G4UExtrudedSolid(__void__&
a)
119 G4UExtrudedSolid::~G4UExtrudedSolid()
128 G4UExtrudedSolid::G4UExtrudedSolid(
const G4UExtrudedSolid &source)
139 G4UExtrudedSolid::operator=(
const G4UExtrudedSolid &source)
141 if (
this == &source)
return *
this;
143 Base_t::operator=( source );
153 G4int G4UExtrudedSolid::GetNofVertices()
const
155 return Base_t::GetNVertices();
160 Base_t::GetVertex(i, xx, yy);
163 std::vector<G4TwoVector> G4UExtrudedSolid::GetPolygon()
const
165 std::vector<G4TwoVector> pol;
166 for (
unsigned int i = 0; i < Base_t::GetNVertices(); ++i)
168 pol.push_back(GetVertex(i));
172 G4int G4UExtrudedSolid::GetNofZSections()
const
174 return Base_t::GetNSections();
176 G4UExtrudedSolid::ZSection G4UExtrudedSolid::GetZSection(
G4int i)
const
178 vecgeom::XtruSection sect = Base_t::GetSection(i);
179 return ZSection(sect.fOrigin[2],
183 std::vector<G4UExtrudedSolid::ZSection> G4UExtrudedSolid::GetZSections()
const
185 std::vector<G4UExtrudedSolid::ZSection> sections;
186 for (
unsigned int i = 0; i < Base_t::GetNSections(); ++i)
188 vecgeom::XtruSection sect = Base_t::GetSection(i);
189 sections.push_back(ZSection(sect.fOrigin[2],
204 static G4bool checkBBox =
true;
209 for (
G4int i=0; i<GetNofVertices(); ++i)
213 if (x < xmin0) xmin0 =
x;
214 if (x > xmax0) xmax0 =
x;
216 if (y < ymin0) ymin0 =
y;
217 if (y > ymax0) ymax0 =
y;
223 G4int nsect = GetNofZSections();
224 for (
G4int i=0; i<nsect; ++i)
226 ZSection zsect = GetZSection(i);
230 xmin =
std::min(xmin,xmin0*scale+dx);
231 xmax =
std::max(xmax,xmax0*scale+dx);
232 ymin =
std::min(ymin,ymin0*scale+dy);
233 ymax =
std::max(ymax,ymax0*scale+dy);
237 G4double zmax = GetZSection(nsect-1).fZ;
239 pMin.
set(xmin,ymin,zmin);
240 pMax.
set(xmax,ymax,zmax);
244 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
247 message <<
"Bad bounding box (min >= max) for solid: "
249 <<
"\npMin = " << pMin
250 <<
"\npMax = " << pMax;
251 G4Exception(
"G4UExtrudedSolid::BoundingLimits()",
"GeomMgt0001",
261 Base_t::Extent(vmin,vmax);
270 message <<
"Inconsistency in bounding boxes for solid: "
272 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
273 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
274 G4Exception(
"G4UExtrudedSolid::BoundingLimits()",
"GeomMgt0001",
287 G4UExtrudedSolid::CalculateExtent(
const EAxis pAxis,
297 BoundingLimits(bmin,bmax);
300 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
302 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
304 return exist = (pMin < pMax) ?
true :
false;
320 message <<
"Triangulation of the base polygon has failed for solid: "
322 <<
"\nExtent has been calculated using boundary box";
325 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
329 G4int nsect = GetNofZSections();
330 std::vector<const G4ThreeVectorList *> polygons;
331 polygons.resize(nsect);
337 G4int ntria = triangles.size()/3;
338 for (
G4int i=0; i<ntria; ++i)
341 for (
G4int k=0; k<nsect; ++k)
343 ZSection zsect = GetZSection(k);
350 G4ThreeVectorList::iterator iter = ptr->begin();
351 G4double x0 = triangles[i3+0].x()*scale+dx;
352 G4double y0 = triangles[i3+0].y()*scale+dy;
367 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
368 if (emin < pMin) pMin = emin;
369 if (emax > pMax) pMax =
emax;
370 if (eminlim > pMin && emaxlim < pMax)
break;
373 for (
G4int k=0; k<nsect; ++k) {
delete polygons[k]; polygons[k]=0;}
374 return (pMin < pMax);
382 G4Polyhedron* G4UExtrudedSolid::CreatePolyhedron ()
const
384 unsigned int nFacets = Base_t::GetStruct().fTslHelper.fFacets.size();
385 unsigned int fVertices = 3*nFacets;
390 for (
unsigned int i = 0; i < nFacets; ++i)
393 for (
unsigned int j = 0; j < 3; ++j)
395 UVector3 vtx = Base_t::GetStruct().fTslHelper.fFacets[i]->fVertices[j];
397 v[j] = Base_t::GetStruct().fTslHelper.fFacets[i]->fIndices[j]+1;
399 polyhedron->
AddFacet(v[0],v[1],v[2],0);
406 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
CLHEP::Hep3Vector G4ThreeVector
G4double GetMaxExtent(const EAxis pAxis) const
std::vector< ExP01TrackerHit * > a
static const G4double kInfinity
Float_t y1[n_points_granero]
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
void AddVertex(const G4ThreeVector &v)
Float_t x1[n_points_granero]
CLHEP::Hep2Vector G4TwoVector
void message(RunManager *runmanager)
static const G4double emax
const G4double kCarTolerance
Float_t y2[n_points_geant4]
std::vector< G4ThreeVector > G4ThreeVectorList
G4double GetMinExtent(const EAxis pAxis) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
Float_t x2[n_points_geant4]
T min(const T t1, const T t2)
brief Return the smallest of the two arguments