34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
47 const std::vector<G4TwoVector>& polygon,
48 const std::vector<ZSection>& zsections)
51 unsigned int nVertices = polygon.size();
52 unsigned int nSections = zsections.size();
54 vecgeom::XtruVertex2* vertices =
new vecgeom::XtruVertex2[nVertices];
55 vecgeom::XtruSection* sections =
new vecgeom::XtruSection[nSections];
57 for (
unsigned int i = 0; i < nVertices; ++i)
59 vertices[i].x = polygon[i].x();
60 vertices[i].y = polygon[i].y();
62 for (
unsigned int i = 0; i < nSections; ++i)
64 sections[i].fOrigin.Set(zsections[i].fOffset.x(),
65 zsections[i].fOffset.y(),
67 sections[i].fScale = zsections[i].fScale;
75 G4UExtrudedSolid::G4UExtrudedSolid(
const G4String& name,
76 const std::vector<G4TwoVector>& polygon,
82 unsigned int nVertices = polygon.size();
83 unsigned int nSections = 2;
85 vecgeom::XtruVertex2* vertices =
new vecgeom::XtruVertex2[nVertices];
86 vecgeom::XtruSection* sections =
new vecgeom::XtruSection[nSections];
88 for (
unsigned int i = 0; i < nVertices; ++i)
90 vertices[i].x = polygon[i].x();
91 vertices[i].y = polygon[i].y();
93 sections[0].fOrigin.Set(off1.
x(), off1.
y(), -halfZ);
94 sections[0].fScale = scale1;
95 sections[1].fOrigin.Set(off2.
x(), off2.
y(), halfZ);
96 sections[1].fScale = scale2;
107 G4UExtrudedSolid::G4UExtrudedSolid(__void__&
a)
117 G4UExtrudedSolid::~G4UExtrudedSolid()
126 G4UExtrudedSolid::G4UExtrudedSolid(
const G4UExtrudedSolid &source)
137 G4UExtrudedSolid::operator=(
const G4UExtrudedSolid &source)
139 if (
this == &source)
return *
this;
141 Base_t::operator=( source );
151 G4int G4UExtrudedSolid::GetNofVertices()
const
153 return Base_t::GetNVertices();
158 Base_t::GetVertex(i, xx, yy);
161 std::vector<G4TwoVector> G4UExtrudedSolid::GetPolygon()
const
163 std::vector<G4TwoVector> pol;
164 for (
unsigned int i = 0; i < Base_t::GetNVertices(); ++i)
166 pol.push_back(GetVertex(i));
170 G4int G4UExtrudedSolid::GetNofZSections()
const
172 return Base_t::GetNSections();
174 G4UExtrudedSolid::ZSection G4UExtrudedSolid::GetZSection(
G4int i)
const
176 vecgeom::XtruSection sect = Base_t::GetSection(i);
177 return ZSection(sect.fOrigin[2],
181 std::vector<G4UExtrudedSolid::ZSection> G4UExtrudedSolid::GetZSections()
const
183 std::vector<G4UExtrudedSolid::ZSection> sections;
184 for (
unsigned int i = 0; i < Base_t::GetNSections(); ++i)
186 vecgeom::XtruSection sect = Base_t::GetSection(i);
187 sections.push_back(ZSection(sect.fOrigin[2],
202 static G4bool checkBBox =
true;
207 for (
G4int i=0; i<GetNofVertices(); ++i)
211 if (x < xmin0) xmin0 =
x;
212 if (x > xmax0) xmax0 =
x;
214 if (y < ymin0) ymin0 =
y;
215 if (y > ymax0) ymax0 =
y;
221 G4int nsect = GetNofZSections();
222 for (
G4int i=0; i<nsect; ++i)
224 ZSection zsect = GetZSection(i);
228 xmin =
std::min(xmin,xmin0*scale+dx);
229 xmax =
std::max(xmax,xmax0*scale+dx);
230 ymin =
std::min(ymin,ymin0*scale+dy);
231 ymax =
std::max(ymax,ymax0*scale+dy);
235 G4double zmax = GetZSection(nsect-1).fZ;
237 pMin.
set(xmin,ymin,zmin);
238 pMax.
set(xmax,ymax,zmax);
242 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
245 message <<
"Bad bounding box (min >= max) for solid: "
247 <<
"\npMin = " << pMin
248 <<
"\npMax = " <<
pMax;
249 G4Exception(
"G4UExtrudedSolid::BoundingLimits()",
"GeomMgt0001",
259 Base_t::Extent(vmin,vmax);
268 message <<
"Inconsistency in bounding boxes for solid: "
270 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
271 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
272 G4Exception(
"G4UExtrudedSolid::BoundingLimits()",
"GeomMgt0001",
285 G4UExtrudedSolid::CalculateExtent(
const EAxis pAxis,
295 BoundingLimits(bmin,bmax);
298 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
300 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
302 return exist = (pMin <
pMax) ?
true :
false;
318 message <<
"Triangulation of the base polygon has failed for solid: "
320 <<
"\nExtent has been calculated using boundary box";
323 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
327 G4int nsect = GetNofZSections();
328 std::vector<const G4ThreeVectorList *> polygons;
329 polygons.resize(nsect);
335 G4int ntria = triangles.size()/3;
336 for (
G4int i=0; i<ntria; ++i)
341 ZSection zsect = GetZSection(
k);
348 G4ThreeVectorList::iterator iter = ptr->begin();
365 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
366 if (emin < pMin) pMin =
emin;
367 if (emax > pMax) pMax =
emax;
368 if (eminlim > pMin && emaxlim < pMax)
break;
371 for (
G4int k=0;
k<nsect; ++
k) {
delete polygons[
k]; polygons[
k]=0;}
372 return (pMin < pMax);
380 G4Polyhedron* G4UExtrudedSolid::CreatePolyhedron ()
const
382 unsigned int nFacets = Base_t::GetStruct().fTslHelper.fFacets.size();
383 unsigned int nVertices = Base_t::GetStruct().fTslHelper.fVertices.size();
389 for (
unsigned int i = 0; i < nVertices; ++i)
391 U3Vector
v = Base_t::GetStruct().fTslHelper.fVertices[i];
396 for (
unsigned int i = 0; i < nFacets; ++i)
399 G4int i1 = Base_t::GetStruct().fTslHelper.fFacets[i]->fIndices[0] + 1;
400 G4int i2 = Base_t::GetStruct().fTslHelper.fFacets[i]->fIndices[1] + 1;
401 G4int i3 = Base_t::GetStruct().fTslHelper.fFacets[i]->fIndices[2] + 1;
409 #endif // G4GEOM_USE_USOLIDS