Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TessellatedSolid Class Reference

#include <G4TessellatedSolid.hh>

+ Inheritance diagram for G4TessellatedSolid:

Public Member Functions

 G4TessellatedSolid ()
 
virtual ~G4TessellatedSolid ()
 
 G4TessellatedSolid (const G4String &name)
 
 G4TessellatedSolid (__void__ &)
 
 G4TessellatedSolid (const G4TessellatedSolid &ts)
 
G4TessellatedSolidoperator= (const G4TessellatedSolid &right)
 
G4TessellatedSolidoperator+= (const G4TessellatedSolid &right)
 
G4bool AddFacet (G4VFacet *aFacet)
 
G4VFacetGetFacet (G4int i) const
 
G4int GetNumberOfFacets () const
 
virtual EInside Inside (const G4ThreeVector &p) const
 
virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
virtual G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
virtual G4double DistanceToIn (const G4ThreeVector &p) const
 
virtual G4double DistanceToOut (const G4ThreeVector &p) const
 
virtual G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm, G4bool *validNorm, G4ThreeVector *norm) const
 
virtual G4bool Normal (const G4ThreeVector &p, G4ThreeVector &n) const
 
virtual G4double SafetyFromOutside (const G4ThreeVector &p, G4bool aAccurate=false) const
 
virtual G4double SafetyFromInside (const G4ThreeVector &p, G4bool aAccurate=false) const
 
virtual G4GeometryType GetEntityType () const
 
virtual std::ostream & StreamInfo (std::ostream &os) const
 
virtual G4VSolidClone () const
 
virtual G4ThreeVector GetPointOnSurface () const
 
virtual G4double GetSurfaceArea ()
 
virtual G4double GetCubicVolume ()
 
void SetSolidClosed (const G4bool t)
 
G4bool GetSolidClosed () const
 
void SetMaxVoxels (G4int max)
 
G4VoxelizerGetVoxels ()
 
virtual G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
 
void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
G4double GetMinXExtent () const
 
G4double GetMaxXExtent () const
 
G4double GetMinYExtent () const
 
G4double GetMaxYExtent () const
 
G4double GetMinZExtent () const
 
G4double GetMaxZExtent () const
 
virtual G4PolyhedronCreatePolyhedron () const
 
virtual G4PolyhedronGetPolyhedron () const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
virtual G4VisExtent GetExtent () const
 
G4int AllocatedMemoryWithoutVoxels ()
 
G4int AllocatedMemory ()
 
void DisplayAllocatedMemory ()
 
- Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
 
virtual ~G4VSolid ()
 
G4bool operator== (const G4VSolid &s) const
 
G4String GetName () const
 
void SetName (const G4String &name)
 
G4double GetTolerance () const
 
virtual void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
virtual G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
 
virtual EInside Inside (const G4ThreeVector &p) const =0
 
virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p) const =0
 
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
virtual G4double GetCubicVolume ()
 
virtual G4double GetSurfaceArea ()
 
virtual G4GeometryType GetEntityType () const =0
 
virtual G4ThreeVector GetPointOnSurface () const
 
virtual G4VSolidClone () const
 
virtual std::ostream & StreamInfo (std::ostream &os) const =0
 
void DumpInfo () const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const =0
 
virtual G4VisExtent GetExtent () const
 
virtual G4PolyhedronCreatePolyhedron () const
 
virtual G4PolyhedronGetPolyhedron () const
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 

Protected Attributes

G4double kCarToleranceHalf
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Additional Inherited Members

- Protected Member Functions inherited from G4VSolid
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
 

Detailed Description

Definition at line 127 of file G4TessellatedSolid.hh.

Constructor & Destructor Documentation

◆ G4TessellatedSolid() [1/4]

G4TessellatedSolid::G4TessellatedSolid ( )

Definition at line 86 of file G4TessellatedSolid.cc.

86 : G4VSolid("dummy")
87{
88 Initialize();
89}

Referenced by Clone().

◆ ~G4TessellatedSolid()

G4TessellatedSolid::~G4TessellatedSolid ( )
virtual

Definition at line 116 of file G4TessellatedSolid.cc.

117{
118 DeleteObjects();
119}

◆ G4TessellatedSolid() [2/4]

G4TessellatedSolid::G4TessellatedSolid ( const G4String name)

Definition at line 96 of file G4TessellatedSolid.cc.

97 : G4VSolid(name)
98{
99 Initialize();
100}

◆ G4TessellatedSolid() [3/4]

G4TessellatedSolid::G4TessellatedSolid ( __void__ &  a)

Definition at line 107 of file G4TessellatedSolid.cc.

107 : G4VSolid(a)
108{
109 Initialize();
110 fMinExtent.set(0,0,0);
111 fMaxExtent.set(0,0,0);
112}
void set(double x, double y, double z)

◆ G4TessellatedSolid() [4/4]

G4TessellatedSolid::G4TessellatedSolid ( const G4TessellatedSolid ts)

Definition at line 125 of file G4TessellatedSolid.cc.

126 : G4VSolid(ts)
127{
128 Initialize();
129
130 CopyObjects(ts);
131}

Member Function Documentation

◆ AddFacet()

G4bool G4TessellatedSolid::AddFacet ( G4VFacet aFacet)

Definition at line 207 of file G4TessellatedSolid.cc.

208{
209 // Add the facet to the vector.
210 //
211 if (fSolidClosed)
212 {
213 G4Exception("G4TessellatedSolid::AddFacet()", "GeomSolids1002",
214 JustWarning, "Attempt to add facets when solid is closed.");
215 return false;
216 }
217 else if (aFacet->IsDefined())
218 {
219 set<G4VertexInfo,G4VertexComparator>::iterator begin
220 = fFacetList.begin(), end = fFacetList.end(), pos, it;
221 G4ThreeVector p = aFacet->GetCircumcentre();
222 G4VertexInfo value;
223 value.id = fFacetList.size();
224 value.mag2 = p.x() + p.y() + p.z();
225
226 G4bool found = false;
227 if (!OutsideOfExtent(p, kCarTolerance))
228 {
229 G4double kCarTolerance3 = 3 * kCarTolerance;
230 pos = fFacetList.lower_bound(value);
231
232 it = pos;
233 while (!found && it != end) // Loop checking, 13.08.2015, G.Cosmo
234 {
235 G4int id = (*it).id;
236 G4VFacet *facet = fFacets[id];
237 G4ThreeVector q = facet->GetCircumcentre();
238 if ((found = (facet == aFacet))) break;
239 G4double dif = q.x() + q.y() + q.z() - value.mag2;
240 if (dif > kCarTolerance3) break;
241 it++;
242 }
243
244 if (fFacets.size() > 1)
245 {
246 it = pos;
247 while (!found && it != begin) // Loop checking, 13.08.2015, G.Cosmo
248 {
249 --it;
250 G4int id = (*it).id;
251 G4VFacet *facet = fFacets[id];
252 G4ThreeVector q = facet->GetCircumcentre();
253 found = (facet == aFacet);
254 if (found) break;
255 G4double dif = value.mag2 - (q.x() + q.y() + q.z());
256 if (dif > kCarTolerance3) break;
257 }
258 }
259 }
260
261 if (!found)
262 {
263 fFacets.push_back(aFacet);
264 fFacetList.insert(value);
265 }
266 return true;
267 }
268 else
269 {
270 G4Exception("G4TessellatedSolid::AddFacet()", "GeomSolids1002",
271 JustWarning, "Attempt to add facet not properly defined.");
272 aFacet->StreamInfo(G4cout);
273 return false;
274 }
275}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
double z() const
double x() const
double y() const
virtual G4ThreeVector GetCircumcentre() const =0
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4VFacet.cc:96
virtual G4bool IsDefined() const =0
G4double kCarTolerance
Definition: G4VSolid.hh:302

Referenced by G4tgbVolume::FindOrConstructG4Solid(), operator+=(), and G4GDMLReadSolids::TessellatedRead().

◆ AllocatedMemory()

G4int G4TessellatedSolid::AllocatedMemory ( )

Definition at line 2065 of file G4TessellatedSolid.cc.

2066{
2068 G4int sizeInsides = fInsides.GetNbytes();
2069 G4int sizeVoxels = fVoxels.AllocatedMemory();
2070 size += sizeInsides + sizeVoxels;
2071 return size;
2072}
unsigned int GetNbytes() const
Definition: G4SurfBits.hh:93
G4int AllocatedMemory()

Referenced by DisplayAllocatedMemory().

◆ AllocatedMemoryWithoutVoxels()

G4int G4TessellatedSolid::AllocatedMemoryWithoutVoxels ( )

Definition at line 2042 of file G4TessellatedSolid.cc.

2043{
2044 G4int base = sizeof(*this);
2045 base += fVertexList.capacity() * sizeof(G4ThreeVector);
2046 base += fRandir.capacity() * sizeof(G4ThreeVector);
2047
2048 G4int limit = fFacets.size();
2049 for (G4int i = 0; i < limit; ++i)
2050 {
2051 G4VFacet& facet = *fFacets[i];
2052 base += facet.AllocatedMemory();
2053 }
2054
2055 for (auto it = fExtremeFacets.cbegin(); it != fExtremeFacets.cend(); ++it)
2056 {
2057 G4VFacet &facet = *(*it);
2058 base += facet.AllocatedMemory();
2059 }
2060 return base;
2061}
CLHEP::Hep3Vector G4ThreeVector
virtual G4int AllocatedMemory()=0

Referenced by AllocatedMemory(), and DisplayAllocatedMemory().

◆ BoundingLimits()

void G4TessellatedSolid::BoundingLimits ( G4ThreeVector pMin,
G4ThreeVector pMax 
) const
virtual

Reimplemented from G4VSolid.

Definition at line 1799 of file G4TessellatedSolid.cc.

1801{
1802 pMin = fMinExtent;
1803 pMax = fMaxExtent;
1804
1805 // Check correctness of the bounding box
1806 //
1807 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
1808 {
1809 std::ostringstream message;
1810 message << "Bad bounding box (min >= max) for solid: "
1811 << GetName() << " !"
1812 << "\npMin = " << pMin
1813 << "\npMax = " << pMax;
1814 G4Exception("G4TessellatedSolid::BoundingLimits()",
1815 "GeomMgt0001", JustWarning, message);
1816 DumpInfo();
1817 }
1818}
G4String GetName() const
void DumpInfo() const

Referenced by CalculateExtent().

◆ CalculateExtent()

G4bool G4TessellatedSolid::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pMin,
G4double pMax 
) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1825 of file G4TessellatedSolid.cc.

1829{
1830 G4ThreeVector bmin, bmax;
1831
1832 // Check bounding box (bbox)
1833 //
1834 BoundingLimits(bmin,bmax);
1835 G4BoundingEnvelope bbox(bmin,bmax);
1836
1837 // Use simple bounding-box to help in the case of complex meshes
1838 //
1839 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
1840
1841#if 0
1842 // Precise extent computation (disabled by default for this shape)
1843 //
1844 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
1845 {
1846 return (pMin < pMax) ? true : false;
1847 }
1848
1849 // The extent is calculated as cumulative extent of the pyramids
1850 // formed by facets and the center of the bounding box.
1851 //
1852 G4double eminlim = pVoxelLimit.GetMinExtent(pAxis);
1853 G4double emaxlim = pVoxelLimit.GetMaxExtent(pAxis);
1854
1855 G4ThreeVectorList base;
1856 G4ThreeVectorList apex(1);
1857 std::vector<const G4ThreeVectorList *> pyramid(2);
1858 pyramid[0] = &base;
1859 pyramid[1] = &apex;
1860 apex[0] = (bmin+bmax)*0.5;
1861
1862 // main loop along facets
1863 pMin = kInfinity;
1864 pMax = -kInfinity;
1865 for (G4int i=0; i<GetNumberOfFacets(); ++i)
1866 {
1867 G4VFacet* facet = GetFacet(i);
1868 if (std::abs((facet->GetSurfaceNormal()).dot(facet->GetVertex(0)-apex[0]))
1869 < kCarToleranceHalf) continue;
1870
1871 G4int nv = facet->GetNumberOfVertices();
1872 base.resize(nv);
1873 for (G4int k=0; k<nv; ++k) { base[k] = facet->GetVertex(k); }
1874
1875 G4double emin,emax;
1876 G4BoundingEnvelope benv(pyramid);
1877 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax)) continue;
1878 if (emin < pMin) pMin = emin;
1879 if (emax > pMax) pMax = emax;
1880 if (eminlim > pMin && emaxlim < pMax) break; // max possible extent
1881 }
1882 return (pMin < pMax);
1883#endif
1884}
std::vector< G4ThreeVector > G4ThreeVectorList
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4int GetNumberOfFacets() const
G4VFacet * GetFacet(G4int i) const
virtual G4ThreeVector GetSurfaceNormal() const =0
virtual G4ThreeVector GetVertex(G4int i) const =0
virtual G4int GetNumberOfVertices() const =0
G4double GetMinExtent(const EAxis pAxis) const
G4double GetMaxExtent(const EAxis pAxis) const

◆ Clone()

G4VSolid * G4TessellatedSolid::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1600 of file G4TessellatedSolid.cc.

1601{
1602 return new G4TessellatedSolid(*this);
1603}

◆ CreatePolyhedron()

G4Polyhedron * G4TessellatedSolid::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1745 of file G4TessellatedSolid.cc.

1746{
1747 G4int nVertices = fVertexList.size();
1748 G4int nFacets = fFacets.size();
1749 G4PolyhedronArbitrary* polyhedron =
1750 new G4PolyhedronArbitrary (nVertices, nFacets);
1751 for (auto v= fVertexList.cbegin(); v!=fVertexList.cend(); ++v)
1752 {
1753 polyhedron->AddVertex(*v);
1754 }
1755
1756 G4int size = fFacets.size();
1757 for (G4int i = 0; i < size; ++i)
1758 {
1759 G4VFacet* facet = fFacets[i];
1760 G4int v[4] = {0};
1761 G4int n = facet->GetNumberOfVertices();
1762 if (n > 4) n = 4;
1763 for (G4int j=0; j<n; ++j)
1764 {
1765 G4int k = facet->GetVertexIndex(j);
1766 v[j] = k+1;
1767 }
1768 polyhedron->AddFacet(v[0],v[1],v[2],v[3]);
1769 }
1770 polyhedron->SetReferences();
1771
1772 return (G4Polyhedron*) polyhedron;
1773}
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
void AddVertex(const G4ThreeVector &v)
virtual G4int GetVertexIndex(G4int i) const =0

Referenced by G4GenericTrap::CreatePolyhedron(), and GetPolyhedron().

◆ DescribeYourselfTo()

void G4TessellatedSolid::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 1738 of file G4TessellatedSolid.cc.

1739{
1740 scene.AddSolid (*this);
1741}
virtual void AddSolid(const G4Box &)=0

Referenced by G4GenericTrap::DescribeYourselfTo().

◆ DisplayAllocatedMemory()

void G4TessellatedSolid::DisplayAllocatedMemory ( )

Definition at line 555 of file G4TessellatedSolid.cc.

556{
558 G4int with = AllocatedMemory();
559 G4double ratio = (G4double) with / without;
560 G4cout << "G4TessellatedSolid - Allocated memory without voxel overhead "
561 << without << "; with " << with << "; ratio: " << ratio << G4endl;
562}
#define G4endl
Definition: G4ios.hh:57

Referenced by SetSolidClosed().

◆ DistanceToIn() [1/2]

G4double G4TessellatedSolid::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1646 of file G4TessellatedSolid.cc.

1647{
1648 return SafetyFromOutside(p, false);
1649}
virtual G4double SafetyFromOutside(const G4ThreeVector &p, G4bool aAccurate=false) const

◆ DistanceToIn() [2/2]

G4double G4TessellatedSolid::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1653 of file G4TessellatedSolid.cc.

1655{
1656 G4double dist = DistanceToInCore(p,v,kInfinity);
1657#ifdef G4SPECSDEBUG
1658 if (dist < kInfinity)
1659 {
1660 if (Inside(p + dist*v) != kSurface)
1661 {
1662 std::ostringstream message;
1663 message << "Invalid response from facet in solid '" << GetName() << "',"
1664 << G4endl
1665 << "at point: " << p << "and direction: " << v;
1666 G4Exception("G4TessellatedSolid::DistanceToIn(p,v)",
1667 "GeomSolids1002", JustWarning, message);
1668 }
1669 }
1670#endif
1671 return dist;
1672}
virtual EInside Inside(const G4ThreeVector &p) const
@ kSurface
Definition: geomdefs.hh:69

Referenced by G4ExtrudedSolid::DistanceToIn(), G4GenericTrap::DistanceToIn(), and SafetyFromInside().

◆ DistanceToOut() [1/2]

G4double G4TessellatedSolid::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1681 of file G4TessellatedSolid.cc.

1682{
1683 return SafetyFromInside(p, false);
1684}
virtual G4double SafetyFromInside(const G4ThreeVector &p, G4bool aAccurate=false) const

Referenced by G4ExtrudedSolid::DistanceToOut(), G4GenericTrap::DistanceToOut(), and SafetyFromOutside().

◆ DistanceToOut() [2/2]

G4double G4TessellatedSolid::DistanceToOut ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  calcNorm,
G4bool validNorm,
G4ThreeVector norm 
) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1704 of file G4TessellatedSolid.cc.

1709{
1711 G4bool valid;
1712
1713 G4double dist = DistanceToOutCore(p, v, n, valid);
1714 if (calcNorm)
1715 {
1716 *norm = n;
1717 *validNorm = valid;
1718 }
1719#ifdef G4SPECSDEBUG
1720 if (dist < kInfinity)
1721 {
1722 if (Inside(p + dist*v) != kSurface)
1723 {
1724 std::ostringstream message;
1725 message << "Invalid response from facet in solid '" << GetName() << "',"
1726 << G4endl
1727 << "at point: " << p << "and direction: " << v;
1728 G4Exception("G4TessellatedSolid::DistanceToOut(p,v,..)",
1729 "GeomSolids1002", JustWarning, message);
1730 }
1731 }
1732#endif
1733 return dist;
1734}

◆ GetCubicVolume()

G4double G4TessellatedSolid::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1939 of file G4TessellatedSolid.cc.

1940{
1941 if (fCubicVolume != 0.) return fCubicVolume;
1942
1943 // For explanation of the following algorithm see:
1944 // https://en.wikipedia.org/wiki/Polyhedron#Volume
1945 // http://wwwf.imperial.ac.uk/~rn/centroid.pdf
1946
1947 G4int size = fFacets.size();
1948 for (G4int i = 0; i < size; ++i)
1949 {
1950 G4VFacet &facet = *fFacets[i];
1951 G4double area = facet.GetArea();
1952 G4ThreeVector unit_normal = facet.GetSurfaceNormal();
1953 fCubicVolume += area * (facet.GetVertex(0).dot(unit_normal));
1954 }
1955 fCubicVolume /= 3.;
1956 return fCubicVolume;
1957}
double dot(const Hep3Vector &) const
virtual G4double GetArea() const =0

◆ GetEntityType()

G4GeometryType G4TessellatedSolid::GetEntityType ( ) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1570 of file G4TessellatedSolid.cc.

1571{
1572 return fGeometryType;
1573}

◆ GetExtent()

G4VisExtent G4TessellatedSolid::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1930 of file G4TessellatedSolid.cc.

1931{
1932 return G4VisExtent (fMinExtent.x(), fMaxExtent.x(),
1933 fMinExtent.y(), fMaxExtent.y(),
1934 fMinExtent.z(), fMaxExtent.z());
1935}

Referenced by G4GenericTrap::GetExtent().

◆ GetFacet()

G4VFacet * G4TessellatedSolid::GetFacet ( G4int  i) const
inline

Definition at line 302 of file G4TessellatedSolid.hh.

303{
304 return fFacets[i];
305}

Referenced by CalculateExtent(), operator+=(), and G4GDMLWriteSolids::TessellatedWrite().

◆ GetMaxXExtent()

G4double G4TessellatedSolid::GetMaxXExtent ( ) const

Definition at line 1895 of file G4TessellatedSolid.cc.

1896{
1897 return fMaxExtent.x();
1898}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMaxYExtent()

G4double G4TessellatedSolid::GetMaxYExtent ( ) const

Definition at line 1909 of file G4TessellatedSolid.cc.

1910{
1911 return fMaxExtent.y();
1912}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMaxZExtent()

G4double G4TessellatedSolid::GetMaxZExtent ( ) const

Definition at line 1923 of file G4TessellatedSolid.cc.

1924{
1925 return fMaxExtent.z();
1926}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMinXExtent()

G4double G4TessellatedSolid::GetMinXExtent ( ) const

Definition at line 1888 of file G4TessellatedSolid.cc.

1889{
1890 return fMinExtent.x();
1891}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMinYExtent()

G4double G4TessellatedSolid::GetMinYExtent ( ) const

Definition at line 1902 of file G4TessellatedSolid.cc.

1903{
1904 return fMinExtent.y();
1905}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMinZExtent()

G4double G4TessellatedSolid::GetMinZExtent ( ) const

Definition at line 1916 of file G4TessellatedSolid.cc.

1917{
1918 return fMinExtent.z();
1919}

Referenced by G4ExtrudedSolid::Inside().

◆ GetNumberOfFacets()

G4int G4TessellatedSolid::GetNumberOfFacets ( ) const

Definition at line 627 of file G4TessellatedSolid.cc.

628{
629 return fFacets.size();
630}

Referenced by CalculateExtent(), operator+=(), and G4GDMLWriteSolids::TessellatedWrite().

◆ GetPointOnSurface()

G4ThreeVector G4TessellatedSolid::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1976 of file G4TessellatedSolid.cc.

1977{
1978 // Select randomly a facet and return a random point on it
1979
1980 G4int i = (G4int) G4RandFlat::shoot(0., fFacets.size());
1981 return fFacets[i]->GetPointOnFace();
1982}

Referenced by G4GenericTrap::GetPointOnSurface().

◆ GetPolyhedron()

G4Polyhedron * G4TessellatedSolid::GetPolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1779 of file G4TessellatedSolid.cc.

1780{
1781 if (fpPolyhedron == nullptr ||
1782 fRebuildPolyhedron ||
1784 fpPolyhedron->GetNumberOfRotationSteps())
1785 {
1786 G4AutoLock l(&polyhedronMutex);
1787 delete fpPolyhedron;
1788 fpPolyhedron = CreatePolyhedron();
1789 fRebuildPolyhedron = false;
1790 l.unlock();
1791 }
1792 return fpPolyhedron;
1793}
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
virtual G4Polyhedron * CreatePolyhedron() const
static G4int GetNumberOfRotationSteps()

Referenced by G4GenericTrap::GetPolyhedron().

◆ GetSolidClosed()

G4bool G4TessellatedSolid::GetSolidClosed ( ) const

Definition at line 599 of file G4TessellatedSolid.cc.

600{
601 return fSolidClosed;
602}

◆ GetSurfaceArea()

G4double G4TessellatedSolid::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1961 of file G4TessellatedSolid.cc.

1962{
1963 if (fSurfaceArea != 0.) return fSurfaceArea;
1964
1965 G4int size = fFacets.size();
1966 for (G4int i = 0; i < size; ++i)
1967 {
1968 G4VFacet &facet = *fFacets[i];
1969 fSurfaceArea += facet.GetArea();
1970 }
1971 return fSurfaceArea;
1972}

◆ GetVoxels()

G4Voxelizer & G4TessellatedSolid::GetVoxels ( )
inline

Definition at line 312 of file G4TessellatedSolid.hh.

313{
314 return fVoxels;
315}

◆ Inside()

EInside G4TessellatedSolid::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1615 of file G4TessellatedSolid.cc.

1616{
1617 EInside location;
1618
1619 if (fVoxels.GetCountOfVoxels() > 1)
1620 {
1621 location = InsideVoxels(aPoint);
1622 }
1623 else
1624 {
1625 location = InsideNoVoxels(aPoint);
1626 }
1627 return location;
1628}
long long GetCountOfVoxels() const
EInside
Definition: geomdefs.hh:67

Referenced by DistanceToIn(), DistanceToOut(), G4GenericTrap::Inside(), SafetyFromInside(), and SafetyFromOutside().

◆ Normal()

G4bool G4TessellatedSolid::Normal ( const G4ThreeVector p,
G4ThreeVector n 
) const
virtual

Definition at line 971 of file G4TessellatedSolid.cc.

973{
974 G4double minDist;
975 G4VFacet* facet = nullptr;
976
977 if (fVoxels.GetCountOfVoxels() > 1)
978 {
979 vector<G4int> curVoxel(3);
980 fVoxels.GetVoxel(curVoxel, p);
981 const vector<G4int> &candidates = fVoxels.GetCandidates(curVoxel);
982 // fVoxels.GetCandidatesVoxelArray(p, candidates, 0);
983
984 if (G4int limit = candidates.size())
985 {
986 minDist = kInfinity;
987 for(G4int i = 0 ; i < limit ; ++i)
988 {
989 G4int candidate = candidates[i];
990 G4VFacet &fct = *fFacets[candidate];
991 G4double dist = fct.Distance(p,minDist);
992 if (dist < minDist) minDist = dist;
993 if (dist <= kCarToleranceHalf)
994 {
995 aNormal = fct.GetSurfaceNormal();
996 return true;
997 }
998 }
999 }
1000 minDist = MinDistanceFacet(p, true, facet);
1001 }
1002 else
1003 {
1004 minDist = kInfinity;
1005 G4int size = fFacets.size();
1006 for (G4int i = 0; i < size; ++i)
1007 {
1008 G4VFacet& f = *fFacets[i];
1009 G4double dist = f.Distance(p, minDist);
1010 if (dist < minDist)
1011 {
1012 minDist = dist;
1013 facet = &f;
1014 }
1015 }
1016 }
1017
1018 if (minDist != kInfinity)
1019 {
1020 if (facet) { aNormal = facet->GetSurfaceNormal(); }
1021 return minDist <= kCarToleranceHalf;
1022 }
1023 else
1024 {
1025#ifdef G4VERBOSE
1026 std::ostringstream message;
1027 message << "Point p is not on surface !?" << G4endl
1028 << " No facets found for point: " << p << " !" << G4endl
1029 << " Returning approximated value for normal.";
1030
1031 G4Exception("G4TessellatedSolid::SurfaceNormal(p)",
1032 "GeomSolids1002", JustWarning, message );
1033#endif
1034 aNormal = (p.z() > 0 ? G4ThreeVector(0,0,1) : G4ThreeVector(0,0,-1));
1035 return false;
1036 }
1037}
virtual G4double Distance(const G4ThreeVector &, G4double)=0
void GetVoxel(std::vector< G4int > &curVoxel, const G4ThreeVector &point) const
const std::vector< G4int > & GetCandidates(std::vector< G4int > &curVoxel) const

Referenced by SurfaceNormal().

◆ operator+=()

G4TessellatedSolid & G4TessellatedSolid::operator+= ( const G4TessellatedSolid right)

Definition at line 614 of file G4TessellatedSolid.cc.

615{
616 G4int size = right.GetNumberOfFacets();
617 for (G4int i = 0; i < size; ++i)
618 AddFacet(right.GetFacet(i)->GetClone());
619
620 return *this;
621}
G4bool AddFacet(G4VFacet *aFacet)
virtual G4VFacet * GetClone()=0

◆ operator=()

G4TessellatedSolid & G4TessellatedSolid::operator= ( const G4TessellatedSolid right)

Definition at line 138 of file G4TessellatedSolid.cc.

139{
140 if (&ts == this) return *this;
141
142 // Copy base class data
144
145 DeleteObjects ();
146
147 Initialize();
148
149 CopyObjects (ts);
150
151 return *this;
152}
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:98

Referenced by G4ExtrudedSolid::operator=().

◆ SafetyFromInside()

G4double G4TessellatedSolid::SafetyFromInside ( const G4ThreeVector p,
G4bool  aAccurate = false 
) const
virtual

Definition at line 1521 of file G4TessellatedSolid.cc.

1522{
1523#if G4SPECSDEBUG
1524 if ( Inside(p) == kOutside )
1525 {
1526 std::ostringstream message;
1527 G4int oldprc = message.precision(16) ;
1528 message << "Point p is already outside!?" << G4endl
1529 << "Position:" << G4endl << G4endl
1530 << "p.x() = " << p.x()/mm << " mm" << G4endl
1531 << "p.y() = " << p.y()/mm << " mm" << G4endl
1532 << "p.z() = " << p.z()/mm << " mm" << G4endl
1533 << "DistanceToIn(p) == " << DistanceToIn(p);
1534 message.precision(oldprc) ;
1535 G4Exception("G4TriangularFacet::DistanceToOut(p)",
1536 "GeomSolids1002", JustWarning, message);
1537 }
1538#endif
1539
1540 G4double minDist;
1541
1542 if (OutsideOfExtent(p, kCarTolerance)) return 0.0;
1543
1544 if (fVoxels.GetCountOfVoxels() > 1)
1545 {
1546 G4VFacet* facet;
1547 minDist = MinDistanceFacet(p, true, facet);
1548 }
1549 else
1550 {
1551 minDist = kInfinity;
1552 G4double dist = 0.0;
1553 G4int size = fFacets.size();
1554 for (G4int i = 0; i < size; ++i)
1555 {
1556 G4VFacet& facet = *fFacets[i];
1557 dist = facet.Distance(p,minDist);
1558 if (dist < minDist) minDist = dist;
1559 }
1560 }
1561 return minDist;
1562}
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
@ kOutside
Definition: geomdefs.hh:68

Referenced by DistanceToOut().

◆ SafetyFromOutside()

G4double G4TessellatedSolid::SafetyFromOutside ( const G4ThreeVector p,
G4bool  aAccurate = false 
) const
virtual

Definition at line 1462 of file G4TessellatedSolid.cc.

1464{
1465#if G4SPECSDEBUG
1466 if ( Inside(p) == kInside )
1467 {
1468 std::ostringstream message;
1469 G4int oldprc = message.precision(16) ;
1470 message << "Point p is already inside!?" << G4endl
1471 << "Position:" << G4endl << G4endl
1472 << "p.x() = " << p.x()/mm << " mm" << G4endl
1473 << "p.y() = " << p.y()/mm << " mm" << G4endl
1474 << "p.z() = " << p.z()/mm << " mm" << G4endl
1475 << "DistanceToOut(p) == " << DistanceToOut(p);
1476 message.precision(oldprc) ;
1477 G4Exception("G4TriangularFacet::DistanceToIn(p)",
1478 "GeomSolids1002", JustWarning, message);
1479 }
1480#endif
1481
1482 G4double minDist;
1483
1484 if (fVoxels.GetCountOfVoxels() > 1)
1485 {
1486 if (!aAccurate)
1487 return fVoxels.DistanceToBoundingBox(p);
1488
1489 if (!OutsideOfExtent(p, kCarTolerance))
1490 {
1491 vector<G4int> startingVoxel(3);
1492 fVoxels.GetVoxel(startingVoxel, p);
1493 const vector<G4int> &candidates = fVoxels.GetCandidates(startingVoxel);
1494 if (candidates.size() == 0 && fInsides.GetNbits())
1495 {
1496 G4int index = fVoxels.GetPointIndex(p);
1497 if (fInsides[index]) return 0.;
1498 }
1499 }
1500
1501 G4VFacet* facet;
1502 minDist = MinDistanceFacet(p, true, facet);
1503 }
1504 else
1505 {
1506 minDist = kInfinity;
1507 G4int size = fFacets.size();
1508 for (G4int i = 0; i < size; ++i)
1509 {
1510 G4VFacet& facet = *fFacets[i];
1511 G4double dist = facet.Distance(p,minDist);
1512 if (dist < minDist) minDist = dist;
1513 }
1514 }
1515 return minDist;
1516}
unsigned int GetNbits() const
Definition: G4SurfBits.hh:92
virtual G4double DistanceToOut(const G4ThreeVector &p) const
G4double DistanceToBoundingBox(const G4ThreeVector &point) const
G4int GetPointIndex(const G4ThreeVector &p) const
@ kInside
Definition: geomdefs.hh:70

Referenced by DistanceToIn().

◆ SetMaxVoxels()

void G4TessellatedSolid::SetMaxVoxels ( G4int  max)
inline

Definition at line 307 of file G4TessellatedSolid.hh.

308{
309 fVoxels.SetMaxVoxels(max);
310}
void SetMaxVoxels(G4int max)

◆ SetSolidClosed()

void G4TessellatedSolid::SetSolidClosed ( const G4bool  t)

Definition at line 566 of file G4TessellatedSolid.cc.

567{
568 if (t)
569 {
570#ifdef G4SPECSDEBUG
571 G4cout << "Creating vertex list..." << G4endl;
572#endif
573 CreateVertexList();
574
575#ifdef G4SPECSDEBUG
576 G4cout << "Setting extreme facets..." << G4endl;
577#endif
578 SetExtremeFacets();
579
580#ifdef G4SPECSDEBUG
581 G4cout << "Voxelizing..." << G4endl;
582#endif
583 Voxelize();
584
585#ifdef G4SPECSDEBUG
587#endif
588
589 }
590 fSolidClosed = t;
591}

Referenced by G4GDMLReadSolids::TessellatedRead().

◆ StreamInfo()

std::ostream & G4TessellatedSolid::StreamInfo ( std::ostream &  os) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1577 of file G4TessellatedSolid.cc.

1578{
1579 os << G4endl;
1580 os << "Solid name = " << GetName() << G4endl;
1581 os << "Geometry Type = " << fGeometryType << G4endl;
1582 os << "Number of facets = " << fFacets.size() << G4endl;
1583
1584 G4int size = fFacets.size();
1585 for (G4int i = 0; i < size; ++i)
1586 {
1587 os << "FACET # = " << i + 1 << G4endl;
1588 G4VFacet &facet = *fFacets[i];
1589 facet.StreamInfo(os);
1590 }
1591 os << G4endl;
1592
1593 return os;
1594}

◆ SurfaceNormal()

G4ThreeVector G4TessellatedSolid::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1632 of file G4TessellatedSolid.cc.

1633{
1635 Normal(p, n);
1636 return n;
1637}
virtual G4bool Normal(const G4ThreeVector &p, G4ThreeVector &n) const

Referenced by G4ExtrudedSolid::SurfaceNormal(), and G4GenericTrap::SurfaceNormal().

Member Data Documentation

◆ kCarToleranceHalf


The documentation for this class was generated from the following files: