34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
47G4UTessellatedSolid::G4UTessellatedSolid()
52G4UTessellatedSolid::G4UTessellatedSolid(
const G4String& name)
61G4UTessellatedSolid::~G4UTessellatedSolid()
63 std::size_t size = fFacets.size();
64 for (std::size_t i = 0; i < size; ++i) {
delete fFacets[i]; }
72G4UTessellatedSolid::G4UTessellatedSolid(
const G4UTessellatedSolid& source)
82G4UTessellatedSolid::operator=(
const G4UTessellatedSolid& source)
84 if (
this == &source)
return *
this;
86 Base_t::operator=( source );
101 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
102 JustWarning,
"Attempt to add facets when solid is closed.");
107 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
108 JustWarning,
"Attempt to add facet not properly defined.");
115 return Base_t::AddTriangularFacet(U3Vector(a3Facet->GetVertex(0).x(),
116 a3Facet->GetVertex(0).y(),
117 a3Facet->GetVertex(0).z()),
118 U3Vector(a3Facet->GetVertex(1).x(),
119 a3Facet->GetVertex(1).y(),
120 a3Facet->GetVertex(1).z()),
121 U3Vector(a3Facet->GetVertex(2).x(),
122 a3Facet->GetVertex(2).y(),
123 a3Facet->GetVertex(2).z()),
129 return Base_t::AddQuadrilateralFacet(U3Vector(a4Facet->GetVertex(0).x(),
130 a4Facet->GetVertex(0).y(),
131 a4Facet->GetVertex(0).z()),
132 U3Vector(a4Facet->GetVertex(1).x(),
133 a4Facet->GetVertex(1).y(),
134 a4Facet->GetVertex(1).z()),
135 U3Vector(a4Facet->GetVertex(2).x(),
136 a4Facet->GetVertex(2).y(),
137 a4Facet->GetVertex(2).z()),
138 U3Vector(a4Facet->GetVertex(3).x(),
139 a4Facet->GetVertex(3).y(),
140 a4Facet->GetVertex(3).z()),
145 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
146 JustWarning,
"Attempt to add facet not properly defined.");
157G4int G4UTessellatedSolid::GetNumberOfFacets()
const
162void G4UTessellatedSolid::SetSolidClosed(
const G4bool t)
164 if (t && !Base_t::IsClosed())
167 std::size_t nVertices = fTessellated.fVertices.size();
168 std::size_t nFacets = fTessellated.fFacets.size();
169 for (std::size_t j = 0; j < nVertices; ++j)
171 U3Vector vt = fTessellated.fVertices[j];
172 fVertexList.emplace_back(vt.x(), vt.y(), vt.z());
174 for (std::size_t i = 0; i < nFacets; ++i)
176 vecgeom::TriangleFacet<G4double>* afacet = Base_t::GetFacet(i);
177 std::vector<G4ThreeVector> v;
178 for (
const auto & vertex : afacet->fVertices)
180 v.emplace_back(vertex.x(),
187 for (
G4int k=0; k<3; ++k)
191 fFacets.push_back(facet);
196G4bool G4UTessellatedSolid::GetSolidClosed()
const
198 return Base_t::IsClosed();
201void G4UTessellatedSolid::SetMaxVoxels(
G4int)
206G4double G4UTessellatedSolid::GetMinXExtent()
const
209 Base_t::Extent(aMin, aMax);
212G4double G4UTessellatedSolid::GetMaxXExtent()
const
215 Base_t::Extent(aMin, aMax);
218G4double G4UTessellatedSolid::GetMinYExtent()
const
221 Base_t::Extent(aMin, aMax);
224G4double G4UTessellatedSolid::GetMaxYExtent()
const
227 Base_t::Extent(aMin, aMax);
230G4double G4UTessellatedSolid::GetMinZExtent()
const
233 Base_t::Extent(aMin, aMax);
236G4double G4UTessellatedSolid::GetMaxZExtent()
const
239 Base_t::Extent(aMin, aMax);
243G4int G4UTessellatedSolid::AllocatedMemoryWithoutVoxels()
245 G4int base =
sizeof(*this);
248 std::size_t limit = fFacets.size();
249 for (std::size_t i = 0; i < limit; ++i)
256G4int G4UTessellatedSolid::AllocatedMemory()
258 return AllocatedMemoryWithoutVoxels();
260void G4UTessellatedSolid::DisplayAllocatedMemory()
262 G4int without = AllocatedMemoryWithoutVoxels();
267 G4cout <<
"G4TessellatedSolid - Allocated memory without voxel overhead "
280 Base_t::Extent(aMin, aMax);
286 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
288 std::ostringstream message;
289 message <<
"Bad bounding box (min >= max) for solid: "
291 <<
"\npMin = " << pMin
292 <<
"\npMax = " << pMax;
293 G4Exception(
"G4UTessellatedSolid::BoundingLimits()",
305G4UTessellatedSolid::CalculateExtent(
const EAxis pAxis,
314 BoundingLimits(bmin,bmax);
319 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
325 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
327 return (pMin < pMax) ? true :
false;
338 std::vector<const G4ThreeVectorList *> pyramid(2);
341 apex[0] = (bmin+bmax)*0.5;
346 for (
G4int i=0; i<GetNumberOfFacets(); ++i)
350 < kCarToleranceHalf)
continue;
356 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
357 if (emin < pMin) pMin = emin;
358 if (emax > pMax) pMax = emax;
359 if (eminlim > pMin && emaxlim < pMax)
break;
361 return (pMin < pMax);
370G4Polyhedron* G4UTessellatedSolid::CreatePolyhedron ()
const
372 auto nVertices = (
G4int)fVertexList.size();
373 auto nFacets = (
G4int)fFacets.size();
375 for (
auto i = 0; i < nVertices; ++i)
377 polyhedron->SetVertex(i+1, fVertexList[i]);
380 for (
auto i = 0; i < nFacets; ++i)
384 for (
auto j = 0; j < 3; ++j)
388 polyhedron->SetFacet(i+1, v[0], v[1], v[2]);
390 polyhedron->SetReferences();
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
G4BoundingEnvelope is a helper class to facilitate calculation of the extent of a solid within the li...
G4QuadrangularFacet defines a facet with 4 vertices, used for the contruction of G4TessellatedSolid....
G4TriangularFacet defines a facet with 3 vertices, used for the contruction of G4TessellatedSolid....
G4VFacet is a base class defining the facets which are components of a G4TessellatedSolid shape.
virtual void SetVertexIndex(G4int i, G4int j)=0
virtual G4int AllocatedMemory()=0
std::ostream & StreamInfo(std::ostream &os) const
virtual G4ThreeVector GetSurfaceNormal() const =0
virtual G4ThreeVector GetVertex(G4int i) const =0
virtual G4int GetNumberOfVertices() const =0
virtual G4int GetVertexIndex(G4int i) const =0
virtual void SetVertices(std::vector< G4ThreeVector > *vertices)=0
virtual G4bool IsDefined() const =0
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
G4double GetMinExtent(const EAxis pAxis) const
G4double GetMaxExtent(const EAxis pAxis) const
const char * name(G4int ptype)