36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
51 G4UTessellatedSolid::G4UTessellatedSolid()
57 G4UTessellatedSolid::G4UTessellatedSolid(
const G4String&
name)
67 G4UTessellatedSolid::G4UTessellatedSolid(__void__&
a)
77 G4UTessellatedSolid::~G4UTessellatedSolid()
79 G4int size = fFacets.size();
80 for (
G4int i = 0; i < size; ++i) {
delete fFacets[i]; }
89 G4UTessellatedSolid::G4UTessellatedSolid(
const G4UTessellatedSolid& source)
100 G4UTessellatedSolid::operator=(
const G4UTessellatedSolid& source)
102 if (
this == &source)
return *
this;
104 Base_t::operator=( source );
118 if (GetSolidClosed())
120 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
121 JustWarning,
"Attempt to add facets when solid is closed.");
126 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
127 JustWarning,
"Attempt to add facet not properly defined.");
134 return Base_t::AddTriangularFacet(UVector3(a3Facet->
GetVertex(0).
x(),
148 return Base_t::AddQuadrilateralFacet(UVector3(a4Facet->
GetVertex(0).
x(),
164 G4Exception(
"G4UTessellatedSolid::AddFacet()",
"GeomSolids1002",
165 JustWarning,
"Attempt to add facet not properly defined.");
176 G4int G4UTessellatedSolid::GetNumberOfFacets()
const
181 void G4UTessellatedSolid::SetSolidClosed(
const G4bool t)
183 if (t && !Base_t::IsClosed())
186 G4int nVertices = fTessellated.fVertices.size();
187 G4int nFacets = fTessellated.fFacets.size();
188 for (
G4int j = 0; j < nVertices; ++j)
190 UVector3 vt = fTessellated.fVertices[j];
191 fVertexList.push_back(
G4ThreeVector(vt.x(), vt.y(), vt.z()));
193 for (
G4int i = 0; i < nFacets; ++i)
195 vecgeom::TriangleFacet<G4double>* afacet = Base_t::GetFacet(i);
196 std::vector<G4ThreeVector> v;
197 for (
G4int k=0; k<3; ++k)
200 afacet->fVertices[k].y(),
201 afacet->fVertices[k].z()));
206 for (
G4int k=0; k<3; ++k)
210 fFacets.push_back(facet);
215 G4bool G4UTessellatedSolid::GetSolidClosed()
const
217 return Base_t::IsClosed();
220 void G4UTessellatedSolid::SetMaxVoxels(
G4int)
225 G4double G4UTessellatedSolid::GetMinXExtent()
const
228 Base_t::Extent(aMin, aMax);
231 G4double G4UTessellatedSolid::GetMaxXExtent()
const
234 Base_t::Extent(aMin, aMax);
237 G4double G4UTessellatedSolid::GetMinYExtent()
const
240 Base_t::Extent(aMin, aMax);
243 G4double G4UTessellatedSolid::GetMaxYExtent()
const
246 Base_t::Extent(aMin, aMax);
249 G4double G4UTessellatedSolid::GetMinZExtent()
const
252 Base_t::Extent(aMin, aMax);
255 G4double G4UTessellatedSolid::GetMaxZExtent()
const
258 Base_t::Extent(aMin, aMax);
262 G4int G4UTessellatedSolid::AllocatedMemoryWithoutVoxels()
267 G4int limit = fFacets.size();
268 for (
G4int i = 0; i < limit; i++)
275 G4int G4UTessellatedSolid::AllocatedMemory()
277 return AllocatedMemoryWithoutVoxels();
279 void G4UTessellatedSolid::DisplayAllocatedMemory()
281 G4int without = AllocatedMemoryWithoutVoxels();
286 G4cout <<
"G4TessellatedSolid - Allocated memory without voxel overhead "
295 void G4UTessellatedSolid::BoundingLimits(
G4ThreeVector& pMin,
299 Base_t::Extent(aMin, aMax);
305 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
308 message <<
"Bad bounding box (min >= max) for solid: "
310 <<
"\npMin = " << pMin
311 <<
"\npMax = " << pMax;
312 G4Exception(
"G4UTessellatedSolid::BoundingLimits()",
324 G4UTessellatedSolid::CalculateExtent(
const EAxis pAxis,
335 BoundingLimits(bmin,bmax);
338 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
340 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
342 return exist = (pMin < pMax) ?
true :
false;
353 std::vector<const G4ThreeVectorList *> pyramid(2);
356 apex[0] = (bmin+bmax)*0.5;
361 for (
G4int i=0; i<GetNumberOfFacets(); ++i)
365 < kCarToleranceHalf)
continue;
371 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
372 if (emin < pMin) pMin = emin;
373 if (emax > pMax) pMax =
emax;
374 if (eminlim > pMin && emaxlim < pMax)
break;
376 return (pMin < pMax);
384 G4Polyhedron* G4UTessellatedSolid::CreatePolyhedron ()
const
386 G4int nVertices = fVertexList.size();
387 G4int nFacets = fFacets.size();
390 for (
G4int j = 0; j < nVertices; ++j)
395 for (
G4int i = 0; i < nFacets; ++i)
399 for (
G4int j=0; j<3; ++j)
403 polyhedron->
AddFacet(v[0],v[1],v[2]);
410 #endif // G4GEOM_USE_USOLIDS
virtual G4int GetVertexIndex(G4int i) const =0
virtual G4ThreeVector GetSurfaceNormal() const =0
CLHEP::Hep3Vector G4ThreeVector
G4double GetMaxExtent(const EAxis pAxis) const
std::vector< ExP01TrackerHit * > a
static const G4double kInfinity
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
void AddVertex(const G4ThreeVector &v)
std::ostream & StreamInfo(std::ostream &os) const
void message(RunManager *runmanager)
static const G4double emax
const G4double kCarTolerance
virtual void SetVertexIndex(G4int i, G4int j)=0
virtual G4ThreeVector GetVertex(G4int i) const =0
const XML_Char int const XML_Char int const XML_Char * base
std::vector< G4ThreeVector > G4ThreeVectorList
G4double GetMinExtent(const EAxis pAxis) const
virtual G4bool IsDefined() const =0
virtual G4int GetNumberOfVertices() const =0
G4ThreeVector GetVertex(G4int i) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
G4ThreeVector GetVertex(G4int i) const
virtual void SetVertices(std::vector< G4ThreeVector > *vertices)=0
virtual G4int AllocatedMemory()=0