34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
47G4UTessellatedSolid::G4UTessellatedSolid()
52G4UTessellatedSolid::G4UTessellatedSolid(
const G4String& name)
62G4UTessellatedSolid::G4UTessellatedSolid(__void__& a)
71G4UTessellatedSolid::~G4UTessellatedSolid()
73 std::size_t size = fFacets.size();
74 for (std::size_t i = 0; i < size; ++i) {
delete fFacets[i]; }
82G4UTessellatedSolid::G4UTessellatedSolid(
const G4UTessellatedSolid& source)
92G4UTessellatedSolid::operator=(
const G4UTessellatedSolid& source)
94 if (
this == &source)
return *
this;
96 Base_t::operator=( source );
109 if (GetSolidClosed())
111 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
112 JustWarning,
"Attempt to add facets when solid is closed.");
117 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
118 JustWarning,
"Attempt to add facet not properly defined.");
125 return Base_t::AddTriangularFacet(U3Vector(a3Facet->
GetVertex(0).
x(),
139 return Base_t::AddQuadrilateralFacet(U3Vector(a4Facet->
GetVertex(0).
x(),
155 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
156 JustWarning,
"Attempt to add facet not properly defined.");
167G4int G4UTessellatedSolid::GetNumberOfFacets()
const
172void G4UTessellatedSolid::SetSolidClosed(
const G4bool t)
174 if (t && !Base_t::IsClosed())
177 std::size_t nVertices = fTessellated.fVertices.size();
178 std::size_t nFacets = fTessellated.fFacets.size();
179 for (std::size_t j = 0; j < nVertices; ++j)
181 U3Vector vt = fTessellated.fVertices[j];
182 fVertexList.push_back(
G4ThreeVector(vt.x(), vt.y(), vt.z()));
184 for (std::size_t i = 0; i < nFacets; ++i)
186 vecgeom::TriangleFacet<G4double>* afacet = Base_t::GetFacet(i);
187 std::vector<G4ThreeVector> v;
188 for (
G4int k=0; k<3; ++k)
191 afacet->fVertices[k].y(),
192 afacet->fVertices[k].z()));
197 for (
G4int k=0; k<3; ++k)
201 fFacets.push_back(facet);
206G4bool G4UTessellatedSolid::GetSolidClosed()
const
208 return Base_t::IsClosed();
211void G4UTessellatedSolid::SetMaxVoxels(
G4int)
216G4double G4UTessellatedSolid::GetMinXExtent()
const
219 Base_t::Extent(aMin, aMax);
222G4double G4UTessellatedSolid::GetMaxXExtent()
const
225 Base_t::Extent(aMin, aMax);
228G4double G4UTessellatedSolid::GetMinYExtent()
const
231 Base_t::Extent(aMin, aMax);
234G4double G4UTessellatedSolid::GetMaxYExtent()
const
237 Base_t::Extent(aMin, aMax);
240G4double G4UTessellatedSolid::GetMinZExtent()
const
243 Base_t::Extent(aMin, aMax);
246G4double G4UTessellatedSolid::GetMaxZExtent()
const
249 Base_t::Extent(aMin, aMax);
253G4int G4UTessellatedSolid::AllocatedMemoryWithoutVoxels()
255 G4int base =
sizeof(*this);
258 std::size_t limit = fFacets.size();
259 for (std::size_t i = 0; i < limit; ++i)
266G4int G4UTessellatedSolid::AllocatedMemory()
268 return AllocatedMemoryWithoutVoxels();
270void G4UTessellatedSolid::DisplayAllocatedMemory()
272 G4int without = AllocatedMemoryWithoutVoxels();
277 G4cout <<
"G4TessellatedSolid - Allocated memory without voxel overhead "
290 Base_t::Extent(aMin, aMax);
296 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
298 std::ostringstream message;
299 message <<
"Bad bounding box (min >= max) for solid: "
301 <<
"\npMin = " << pMin
302 <<
"\npMax = " << pMax;
303 G4Exception(
"G4UTessellatedSolid::BoundingLimits()",
315G4UTessellatedSolid::CalculateExtent(
const EAxis pAxis,
324 BoundingLimits(bmin,bmax);
329 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
335 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
337 return (pMin < pMax) ? true :
false;
348 std::vector<const G4ThreeVectorList *> pyramid(2);
351 apex[0] = (bmin+bmax)*0.5;
356 for (
G4int i=0; i<GetNumberOfFacets(); ++i)
360 < kCarToleranceHalf)
continue;
366 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
367 if (emin < pMin) pMin = emin;
368 if (emax > pMax) pMax = emax;
369 if (eminlim > pMin && emaxlim < pMax)
break;
371 return (pMin < pMax);
380G4Polyhedron* G4UTessellatedSolid::CreatePolyhedron ()
const
385 for (
auto i = 0; i < nVertices; ++i)
387 polyhedron->
SetVertex(i+1, fVertexList[i]);
390 for (
auto i = 0; i < nFacets; ++i)
394 for (
auto j = 0; j < 3; ++j)
398 polyhedron->
SetFacet(i+1, v[0], v[1], v[2]);
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
G4ThreeVector GetVertex(G4int i) const
G4ThreeVector GetVertex(G4int i) const
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
G4double GetMinExtent(const EAxis pAxis) const
G4double GetMaxExtent(const EAxis pAxis) const
void SetVertex(G4int index, const G4Point3D &v)
void SetFacet(G4int index, G4int iv1, G4int iv2, G4int iv3, G4int iv4=0)
const char * name(G4int ptype)