34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
49G4UTessellatedSolid::G4UTessellatedSolid()
54G4UTessellatedSolid::G4UTessellatedSolid(
const G4String& name)
64G4UTessellatedSolid::G4UTessellatedSolid(__void__& a)
73G4UTessellatedSolid::~G4UTessellatedSolid()
75 G4int size = fFacets.size();
76 for (
G4int i = 0; i < size; ++i) {
delete fFacets[i]; }
84G4UTessellatedSolid::G4UTessellatedSolid(
const G4UTessellatedSolid& source)
94G4UTessellatedSolid::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.");
169G4int G4UTessellatedSolid::GetNumberOfFacets()
const
174void 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;
190 for (
G4int k=0; k<3; ++k)
193 afacet->fVertices[k].y(),
194 afacet->fVertices[k].z()));
199 for (
G4int k=0; k<3; ++k)
203 fFacets.push_back(facet);
208G4bool G4UTessellatedSolid::GetSolidClosed()
const
210 return Base_t::IsClosed();
213void G4UTessellatedSolid::SetMaxVoxels(
G4int)
218G4double G4UTessellatedSolid::GetMinXExtent()
const
221 Base_t::Extent(aMin, aMax);
224G4double G4UTessellatedSolid::GetMaxXExtent()
const
227 Base_t::Extent(aMin, aMax);
230G4double G4UTessellatedSolid::GetMinYExtent()
const
233 Base_t::Extent(aMin, aMax);
236G4double G4UTessellatedSolid::GetMaxYExtent()
const
239 Base_t::Extent(aMin, aMax);
242G4double G4UTessellatedSolid::GetMinZExtent()
const
245 Base_t::Extent(aMin, aMax);
248G4double G4UTessellatedSolid::GetMaxZExtent()
const
251 Base_t::Extent(aMin, aMax);
255G4int G4UTessellatedSolid::AllocatedMemoryWithoutVoxels()
257 G4int base =
sizeof(*this);
260 G4int limit = fFacets.size();
261 for (
G4int i = 0; i < limit; ++i)
268G4int G4UTessellatedSolid::AllocatedMemory()
270 return AllocatedMemoryWithoutVoxels();
272void 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())
300 std::ostringstream message;
301 message <<
"Bad bounding box (min >= max) for solid: "
303 <<
"\npMin = " << pMin
304 <<
"\npMax = " << pMax;
305 G4Exception(
"G4UTessellatedSolid::BoundingLimits()",
317G4UTessellatedSolid::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);
382G4Polyhedron* 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]);
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
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
void AddVertex(const G4ThreeVector &v)
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
const char * name(G4int ptype)