34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
49 G4UTessellatedSolid::G4UTessellatedSolid()
54 G4UTessellatedSolid::G4UTessellatedSolid(
const G4String&
name)
64 G4UTessellatedSolid::G4UTessellatedSolid(__void__&
a)
73 G4UTessellatedSolid::~G4UTessellatedSolid()
75 G4int size = fFacets.size();
76 for (
G4int i = 0; i < size; ++i) {
delete fFacets[i]; }
84 G4UTessellatedSolid::G4UTessellatedSolid(
const G4UTessellatedSolid& source)
94 G4UTessellatedSolid::operator=(
const G4UTessellatedSolid& source)
96 if (
this == &source)
return *
this;
98 Base_t::operator=( source );
111 if (GetSolidClosed())
113 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
114 JustWarning,
"Attempt to add facets when solid is closed.");
119 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
120 JustWarning,
"Attempt to add facet not properly defined.");
127 return Base_t::AddTriangularFacet(U3Vector(a3Facet->
GetVertex(0).
x(),
141 return Base_t::AddQuadrilateralFacet(U3Vector(a4Facet->
GetVertex(0).
x(),
157 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
158 JustWarning,
"Attempt to add facet not properly defined.");
169 G4int G4UTessellatedSolid::GetNumberOfFacets()
const
174 void G4UTessellatedSolid::SetSolidClosed(
const G4bool t)
176 if (t && !Base_t::IsClosed())
179 G4int nVertices = fTessellated.fVertices.size();
180 G4int nFacets = fTessellated.fFacets.size();
181 for (
G4int j = 0; j < nVertices; ++j)
183 U3Vector vt = fTessellated.fVertices[j];
184 fVertexList.push_back(
G4ThreeVector(vt.x(), vt.y(), vt.z()));
186 for (
G4int i = 0; i < nFacets; ++i)
188 vecgeom::TriangleFacet<G4double>* afacet = Base_t::GetFacet(i);
189 std::vector<G4ThreeVector>
v;
193 afacet->fVertices[
k].y(),
194 afacet->fVertices[
k].z()));
203 fFacets.push_back(facet);
208 G4bool G4UTessellatedSolid::GetSolidClosed()
const
210 return Base_t::IsClosed();
213 void G4UTessellatedSolid::SetMaxVoxels(
G4int)
218 G4double G4UTessellatedSolid::GetMinXExtent()
const
221 Base_t::Extent(aMin, aMax);
224 G4double G4UTessellatedSolid::GetMaxXExtent()
const
227 Base_t::Extent(aMin, aMax);
230 G4double G4UTessellatedSolid::GetMinYExtent()
const
233 Base_t::Extent(aMin, aMax);
236 G4double G4UTessellatedSolid::GetMaxYExtent()
const
239 Base_t::Extent(aMin, aMax);
242 G4double G4UTessellatedSolid::GetMinZExtent()
const
245 Base_t::Extent(aMin, aMax);
248 G4double G4UTessellatedSolid::GetMaxZExtent()
const
251 Base_t::Extent(aMin, aMax);
255 G4int G4UTessellatedSolid::AllocatedMemoryWithoutVoxels()
260 G4int limit = fFacets.size();
261 for (
G4int i = 0; i < limit; ++i)
268 G4int G4UTessellatedSolid::AllocatedMemory()
270 return AllocatedMemoryWithoutVoxels();
272 void G4UTessellatedSolid::DisplayAllocatedMemory()
274 G4int without = AllocatedMemoryWithoutVoxels();
279 G4cout <<
"G4TessellatedSolid - Allocated memory without voxel overhead "
292 Base_t::Extent(aMin, aMax);
298 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
301 message <<
"Bad bounding box (min >= max) for solid: "
303 <<
"\npMin = " << pMin
304 <<
"\npMax = " <<
pMax;
305 G4Exception(
"G4UTessellatedSolid::BoundingLimits()",
317 G4UTessellatedSolid::CalculateExtent(
const EAxis pAxis,
326 BoundingLimits(bmin,bmax);
331 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
337 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
339 return (pMin < pMax) ?
true :
false;
350 std::vector<const G4ThreeVectorList *> pyramid(2);
353 apex[0] = (bmin+bmax)*0.5;
358 for (
G4int i=0; i<GetNumberOfFacets(); ++i)
362 < kCarToleranceHalf)
continue;
368 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
369 if (emin < pMin) pMin =
emin;
370 if (emax > pMax) pMax =
emax;
371 if (eminlim > pMin && emaxlim < pMax)
break;
373 return (pMin < pMax);
382 G4Polyhedron* G4UTessellatedSolid::CreatePolyhedron ()
const
384 G4int nVertices = fVertexList.size();
385 G4int nFacets = fFacets.size();
388 for (
G4int j = 0; j < nVertices; ++j)
393 for (
G4int i = 0; i < nFacets; ++i)
397 for (
G4int j=0; j<3; ++j)
401 polyhedron->
AddFacet(v[0],v[1],v[2]);
408 #endif // G4GEOM_USE_USOLIDS