Geant4 9.6.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)
 
G4SurfaceVoxelizerGetVoxels ()
 
virtual G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
 
G4double GetMinXExtent () const
 
G4double GetMaxXExtent () const
 
G4double GetMinYExtent () const
 
G4double GetMaxYExtent () const
 
G4double GetMinZExtent () const
 
G4double GetMaxZExtent () const
 
G4ThreeVectorListCreateRotatedVertices (const G4AffineTransform &pT) const
 
virtual G4PolyhedronCreatePolyhedron () const
 
virtual G4PolyhedronGetPolyhedron () const
 
virtual G4NURBSCreateNURBS () 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 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=0, G4ThreeVector *n=0) 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 G4NURBSCreateNURBS () 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)
 

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
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 128 of file G4TessellatedSolid.hh.

Constructor & Destructor Documentation

◆ G4TessellatedSolid() [1/4]

G4TessellatedSolid::G4TessellatedSolid ( )

Definition at line 101 of file G4TessellatedSolid.cc.

101 : G4VSolid("dummy")
102{
103 Initialize();
104}

Referenced by Clone().

◆ ~G4TessellatedSolid()

G4TessellatedSolid::~G4TessellatedSolid ( )
virtual

Definition at line 131 of file G4TessellatedSolid.cc.

132{
133 DeleteObjects ();
134}

◆ G4TessellatedSolid() [2/4]

G4TessellatedSolid::G4TessellatedSolid ( const G4String name)

Definition at line 111 of file G4TessellatedSolid.cc.

112 : G4VSolid(name)
113{
114 Initialize();
115}

◆ G4TessellatedSolid() [3/4]

G4TessellatedSolid::G4TessellatedSolid ( __void__ &  a)

Definition at line 122 of file G4TessellatedSolid.cc.

122 : G4VSolid(a)
123{
124 Initialize();
125 fMinExtent.set(0,0,0);
126 fMaxExtent.set(0,0,0);
127}
void set(double x, double y, double z)

◆ G4TessellatedSolid() [4/4]

G4TessellatedSolid::G4TessellatedSolid ( const G4TessellatedSolid ts)

Definition at line 140 of file G4TessellatedSolid.cc.

141 : G4VSolid(ts), fpPolyhedron(0)
142{
143 Initialize();
144
145 CopyObjects(ts);
146}

Member Function Documentation

◆ AddFacet()

G4bool G4TessellatedSolid::AddFacet ( G4VFacet aFacet)

Definition at line 220 of file G4TessellatedSolid.cc.

221{
222 // Add the facet to the vector.
223 //
224 if (fSolidClosed)
225 {
226 G4Exception("G4TessellatedSolid::AddFacet()", "GeomSolids1002",
227 JustWarning, "Attempt to add facets when solid is closed.");
228 return false;
229 }
230 else if (aFacet->IsDefined())
231 {
232 set<G4VertexInfo,G4VertexComparator>::iterator begin
233 = fFacetList.begin(), end = fFacetList.end(), pos, it;
234 G4ThreeVector p = aFacet->GetCircumcentre();
235 G4VertexInfo value;
236 value.id = fFacetList.size();
237 value.mag2 = p.mag2();
238
239 G4bool found = false;
240 if (!OutsideOfExtent(p, kCarTolerance))
241 {
242 G4double kCarTolerance24 = kCarTolerance * kCarTolerance / 4.0;
243 pos = fFacetList.lower_bound(value);
244
245 it = pos;
246 while (!found && it != end)
247 {
248 G4int id = (*it).id;
249 G4ThreeVector q = fFacets[id]->GetCircumcentre();
250 if ((found = (fFacets[id] == aFacet))) break;
251 G4double dif = q.mag2() - value.mag2;
252 if (dif > kCarTolerance24) break;
253 it++;
254 }
255
256 if (fFacets.size() > 1)
257 {
258 it = pos;
259 while (!found && it != begin)
260 {
261 --it;
262 G4int id = (*it).id;
263 G4ThreeVector q = fFacets[id]->GetCircumcentre();
264 found = (fFacets[id] == aFacet);
265 if (found) break;
266 G4double dif = value.mag2 - q.mag2();
267 if (dif > kCarTolerance24) break;
268 }
269 }
270 }
271
272 if (!found)
273 {
274 fFacets.push_back(aFacet);
275 fFacetList.insert(value);
276 }
277
278 return true;
279 }
280 else
281 {
282 G4Exception("G4TessellatedSolid::AddFacet()", "GeomSolids1002",
283 JustWarning, "Attempt to add facet not properly defined.");
284 aFacet->StreamInfo(G4cout);
285 return false;
286 }
287}
@ JustWarning
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4DLLIMPORT std::ostream G4cout
double mag2() const
virtual G4ThreeVector GetCircumcentre() const =0
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4VFacet.cc:98
virtual G4bool IsDefined() const =0
G4double kCarTolerance
Definition: G4VSolid.hh:307
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

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

◆ AllocatedMemory()

G4int G4TessellatedSolid::AllocatedMemory ( )

Definition at line 1991 of file G4TessellatedSolid.cc.

1992{
1994 G4int sizeInsides = fInsides.GetNbytes();
1995 G4int sizeVoxels = fVoxels.AllocatedMemory();
1996 size += sizeInsides + sizeVoxels;
1997 return size;
1998}
unsigned int GetNbytes() const
Definition: G4SurfBits.hh:102

Referenced by DisplayAllocatedMemory().

◆ AllocatedMemoryWithoutVoxels()

G4int G4TessellatedSolid::AllocatedMemoryWithoutVoxels ( )

Definition at line 1965 of file G4TessellatedSolid.cc.

1966{
1967 G4int base = sizeof(*this);
1968 base += fVertexList.capacity() * sizeof(G4ThreeVector);
1969 base += fRandir.capacity() * sizeof(G4ThreeVector);
1970
1971 G4int limit = fFacets.size();
1972 for (G4int i = 0; i < limit; i++)
1973 {
1974 G4VFacet &facet = *fFacets[i];
1975 base += facet.AllocatedMemory();
1976 }
1977
1978 std::set<G4VFacet *>::const_iterator beg, end, it;
1979 beg = fExtremeFacets.begin();
1980 end = fExtremeFacets.end();
1981 for (it = beg; it != end; it++)
1982 {
1983 G4VFacet &facet = *(*it);
1984 base += facet.AllocatedMemory();
1985 }
1986 return base;
1987}
CLHEP::Hep3Vector G4ThreeVector
virtual G4int AllocatedMemory()=0

Referenced by AllocatedMemory(), and DisplayAllocatedMemory().

◆ CalculateExtent()

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

Implements G4VSolid.

Definition at line 1742 of file G4TessellatedSolid.cc.

1746{
1747 G4ThreeVectorList transVertexList(fVertexList);
1748 G4int size = fVertexList.size();
1749
1750 // Put solid into transformed frame
1751 for (G4int i=0; i < size; ++i)
1752 {
1753 pTransform.ApplyPointTransform(transVertexList[i]);
1754 }
1755
1756 // Find min and max extent in each dimension
1757 G4ThreeVector minExtent(kInfinity, kInfinity, kInfinity);
1758 G4ThreeVector maxExtent(-kInfinity, -kInfinity, -kInfinity);
1759
1760 size = transVertexList.size();
1761 for (G4int i=0; i< size; ++i)
1762 {
1763 for (G4int axis=G4ThreeVector::X; axis < G4ThreeVector::SIZE; ++axis)
1764 {
1765 G4double coordinate = transVertexList[i][axis];
1766 if (coordinate < minExtent[axis])
1767 { minExtent[axis] = coordinate; }
1768 if (coordinate > maxExtent[axis])
1769 { maxExtent[axis] = coordinate; }
1770 }
1771 }
1772
1773 // Check for containment and clamp to voxel boundaries
1774 for (G4int axis=G4ThreeVector::X; axis < G4ThreeVector::SIZE; ++axis)
1775 {
1776 EAxis geomAxis = kXAxis; // U geom classes use different index type
1777 switch(axis)
1778 {
1779 case G4ThreeVector::X: geomAxis = kXAxis; break;
1780 case G4ThreeVector::Y: geomAxis = kYAxis; break;
1781 case G4ThreeVector::Z: geomAxis = kZAxis; break;
1782 }
1783 G4bool isLimited = pVoxelLimit.IsLimited(geomAxis);
1784 G4double voxelMinExtent = pVoxelLimit.GetMinExtent(geomAxis);
1785 G4double voxelMaxExtent = pVoxelLimit.GetMaxExtent(geomAxis);
1786
1787 if (isLimited)
1788 {
1789 if ( minExtent[axis] > voxelMaxExtent+kCarTolerance ||
1790 maxExtent[axis] < voxelMinExtent-kCarTolerance )
1791 {
1792 return false ;
1793 }
1794 else
1795 {
1796 if (minExtent[axis] < voxelMinExtent)
1797 {
1798 minExtent[axis] = voxelMinExtent ;
1799 }
1800 if (maxExtent[axis] > voxelMaxExtent)
1801 {
1802 maxExtent[axis] = voxelMaxExtent;
1803 }
1804 }
1805 }
1806 }
1807
1808 // Convert pAxis into G4ThreeVector index
1809 G4int vecAxis=0;
1810 switch(pAxis)
1811 {
1812 case kXAxis: vecAxis = G4ThreeVector::X; break;
1813 case kYAxis: vecAxis = G4ThreeVector::Y; break;
1814 case kZAxis: vecAxis = G4ThreeVector::Z; break;
1815 default: break;
1816 }
1817
1818 pMin = minExtent[vecAxis] - kCarTolerance;
1819 pMax = maxExtent[vecAxis] + kCarTolerance;
1820
1821 return true;
1822}
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:85
void ApplyPointTransform(G4ThreeVector &vec) const
G4double GetMinExtent(const EAxis pAxis) const
G4double GetMaxExtent(const EAxis pAxis) const
G4bool IsLimited() const
EAxis
Definition: geomdefs.hh:54
@ kYAxis
Definition: geomdefs.hh:54
@ kXAxis
Definition: geomdefs.hh:54
@ kZAxis
Definition: geomdefs.hh:54

Referenced by G4GenericTrap::CalculateExtent().

◆ Clone()

G4VSolid * G4TessellatedSolid::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1564 of file G4TessellatedSolid.cc.

1565{
1566 return new G4TessellatedSolid(*this);
1567}

◆ CreateNURBS()

G4NURBS * G4TessellatedSolid::CreateNURBS ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1714 of file G4TessellatedSolid.cc.

1715{
1716 return 0;
1717}

Referenced by G4GenericTrap::CreateNURBS().

◆ CreatePolyhedron()

G4Polyhedron * G4TessellatedSolid::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1680 of file G4TessellatedSolid.cc.

1681{
1682 G4int nVertices = fVertexList.size();
1683 G4int nFacets = fFacets.size();
1684 G4PolyhedronArbitrary *polyhedron =
1685 new G4PolyhedronArbitrary (nVertices, nFacets);
1686 for (G4ThreeVectorList::const_iterator v= fVertexList.begin();
1687 v!=fVertexList.end(); ++v)
1688 {
1689 polyhedron->AddVertex(*v);
1690 }
1691
1692 G4int size = fFacets.size();
1693 for (G4int i = 0; i < size; ++i)
1694 {
1695 G4VFacet &facet = *fFacets[i];
1696 G4int v[4];
1697 int n = facet.GetNumberOfVertices();
1698 if (n > 4) n = 4;
1699 else if (n == 3) v[3] = 0;
1700 for (G4int j=0; j<n; ++j)
1701 {
1702 G4int k = facet.GetVertexIndex(j);
1703 v[j] = k+1;
1704 }
1705 polyhedron->AddFacet(v[0],v[1],v[2],v[3]);
1706 }
1707 polyhedron->SetReferences();
1708
1709 return (G4Polyhedron*) polyhedron;
1710}
void AddVertex(const G4ThreeVector v)
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)
virtual G4int GetNumberOfVertices() const =0
virtual G4int GetVertexIndex(G4int i) const =0

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

◆ CreateRotatedVertices()

G4ThreeVectorList * G4TessellatedSolid::CreateRotatedVertices ( const G4AffineTransform pT) const

◆ DescribeYourselfTo()

void G4TessellatedSolid::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 1673 of file G4TessellatedSolid.cc.

1674{
1675 scene.AddSolid (*this);
1676}
virtual void AddSolid(const G4Box &)=0

Referenced by G4GenericTrap::DescribeYourselfTo().

◆ DisplayAllocatedMemory()

void G4TessellatedSolid::DisplayAllocatedMemory ( )

Definition at line 549 of file G4TessellatedSolid.cc.

550{
552 G4int with = AllocatedMemory();
553 G4double ratio = (G4double) with / without;
554 G4cout << "G4TessellatedSolid - Allocated memory without voxel overhead "
555 << without << "; with " << with << "; ratio: " << ratio << endl;
556}

Referenced by SetSolidClosed().

◆ DistanceToIn() [1/2]

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

Implements G4VSolid.

Definition at line 1610 of file G4TessellatedSolid.cc.

1611{
1612 return SafetyFromOutside(p,false);
1613}
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.

Definition at line 1617 of file G4TessellatedSolid.cc.

1619{
1620 return DistanceToInCore(p,v,kInfinity);
1621}

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

◆ DistanceToOut() [1/2]

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

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1630 of file G4TessellatedSolid.cc.

1631{
1632 return SafetyFromInside(p,false);
1633}
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 1653 of file G4TessellatedSolid.cc.

1658{
1660 G4bool valid;
1661
1662 G4double dist = DistanceToOutCore(p, v, n, valid);
1663 if (calcNorm)
1664 {
1665 *norm = n;
1666 *validNorm = valid;
1667 }
1668 return dist;
1669}

◆ GetCubicVolume()

G4double G4TessellatedSolid::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1875 of file G4TessellatedSolid.cc.

1876{
1877 if(fCubicVolume != 0.) {;}
1878 else { fCubicVolume = G4VSolid::GetCubicVolume(); }
1879 return fCubicVolume;
1880}
virtual G4double GetCubicVolume()
Definition: G4VSolid.cc:188

◆ GetEntityType()

G4GeometryType G4TessellatedSolid::GetEntityType ( ) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1535 of file G4TessellatedSolid.cc.

1536{
1537 return fGeometryType;
1538}

◆ GetExtent()

G4VisExtent G4TessellatedSolid::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1868 of file G4TessellatedSolid.cc.

1869{
1870 return G4VisExtent (fMinExtent.x(), fMaxExtent.x(), fMinExtent.y(), fMaxExtent.y(), fMinExtent.z(), fMaxExtent.z());
1871}
double z() const
double x() const
double y() const

Referenced by G4GenericTrap::GetExtent().

◆ GetFacet()

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

Definition at line 303 of file G4TessellatedSolid.hh.

304{
305 return fFacets[i];
306}

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

◆ GetMaxXExtent()

G4double G4TessellatedSolid::GetMaxXExtent ( ) const

Definition at line 1833 of file G4TessellatedSolid.cc.

1834{
1835 return fMaxExtent.x();
1836}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMaxYExtent()

G4double G4TessellatedSolid::GetMaxYExtent ( ) const

Definition at line 1847 of file G4TessellatedSolid.cc.

1848{
1849 return fMaxExtent.y();
1850}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMaxZExtent()

G4double G4TessellatedSolid::GetMaxZExtent ( ) const

Definition at line 1861 of file G4TessellatedSolid.cc.

1862{
1863 return fMaxExtent.z();
1864}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMinXExtent()

G4double G4TessellatedSolid::GetMinXExtent ( ) const

Definition at line 1826 of file G4TessellatedSolid.cc.

1827{
1828 return fMinExtent.x();
1829}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMinYExtent()

G4double G4TessellatedSolid::GetMinYExtent ( ) const

Definition at line 1840 of file G4TessellatedSolid.cc.

1841{
1842 return fMinExtent.y();
1843}

Referenced by G4ExtrudedSolid::Inside().

◆ GetMinZExtent()

G4double G4TessellatedSolid::GetMinZExtent ( ) const

Definition at line 1854 of file G4TessellatedSolid.cc.

1855{
1856 return fMinExtent.z();
1857}

Referenced by G4ExtrudedSolid::Inside().

◆ GetNumberOfFacets()

G4int G4TessellatedSolid::GetNumberOfFacets ( ) const

Definition at line 612 of file G4TessellatedSolid.cc.

613{
614 return fFacets.size();
615}

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

◆ GetPointOnSurface()

G4ThreeVector G4TessellatedSolid::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1899 of file G4TessellatedSolid.cc.

1900{
1901 // Select randomly a facet and return a random point on it
1902
1903 G4int i = (G4int) G4RandFlat::shoot(0., fFacets.size());
1904 return fFacets[i]->GetPointOnFace();
1905}

Referenced by G4GenericTrap::GetPointOnSurface().

◆ GetPolyhedron()

G4Polyhedron * G4TessellatedSolid::GetPolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1723 of file G4TessellatedSolid.cc.

1724{
1725 if (!fpPolyhedron ||
1727 fpPolyhedron->GetNumberOfRotationSteps())
1728 {
1729 delete fpPolyhedron;
1730 fpPolyhedron = CreatePolyhedron();
1731 }
1732 return fpPolyhedron;
1733}
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
virtual G4Polyhedron * CreatePolyhedron() const
static G4int GetNumberOfRotationSteps()

Referenced by G4GenericTrap::GetPolyhedron().

◆ GetSolidClosed()

G4bool G4TessellatedSolid::GetSolidClosed ( ) const

Definition at line 584 of file G4TessellatedSolid.cc.

585{
586 return fSolidClosed;
587}

◆ GetSurfaceArea()

G4double G4TessellatedSolid::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1884 of file G4TessellatedSolid.cc.

1885{
1886 if (fSurfaceArea != 0.) return fSurfaceArea;
1887
1888 G4int size = fFacets.size();
1889 for (G4int i = 0; i < size; ++i)
1890 {
1891 G4VFacet &facet = *fFacets[i];
1892 fSurfaceArea += facet.GetArea();
1893 }
1894 return fSurfaceArea;
1895}
virtual G4double GetArea()=0

◆ GetVoxels()

G4SurfaceVoxelizer & G4TessellatedSolid::GetVoxels ( )
inline

Definition at line 313 of file G4TessellatedSolid.hh.

314{
315 return fVoxels;
316}

◆ Inside()

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

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1579 of file G4TessellatedSolid.cc.

1580{
1581 EInside location;
1582
1583 if (fVoxels.GetCountOfVoxels() > 1)
1584 {
1585 location = InsideVoxels(aPoint);
1586 }
1587 else
1588 {
1589 location = InsideNoVoxels(aPoint);
1590 }
1591 return location;
1592}
long long GetCountOfVoxels() const
EInside
Definition: geomdefs.hh:58

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

◆ Normal()

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

Definition at line 956 of file G4TessellatedSolid.cc.

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

Referenced by SurfaceNormal().

◆ operator+=()

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

Definition at line 599 of file G4TessellatedSolid.cc.

600{
601 G4int size = right.GetNumberOfFacets();
602 for (G4int i = 0; i < size; ++i)
603 AddFacet(right.GetFacet(i)->GetClone());
604
605 return *this;
606}
G4bool AddFacet(G4VFacet *aFacet)
G4int GetNumberOfFacets() const
G4VFacet * GetFacet(G4int i) const
virtual G4VFacet * GetClone()=0

◆ operator=()

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

Definition at line 153 of file G4TessellatedSolid.cc.

154{
155 if (&ts == this) return *this;
156
157 // Copy base class data
159
160 DeleteObjects ();
161
162 Initialize();
163
164 CopyObjects (ts);
165
166 return *this;
167}
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:110

Referenced by G4ExtrudedSolid::operator=().

◆ SafetyFromInside()

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

Definition at line 1486 of file G4TessellatedSolid.cc.

1487{
1488#if G4SPECSDEBUG
1489 if ( Inside(p) == kOutside )
1490 {
1491 std::ostringstream message;
1492 G4int oldprc = message.precision(16) ;
1493 message << "Point p is already outside!?" << endl
1494 << "Position:" << endl << endl
1495 << "p.x() = " << p.x()/mm << " mm" << endl
1496 << "p.y() = " << p.y()/mm << " mm" << endl
1497 << "p.z() = " << p.z()/mm << " mm" << endl
1498 << "DistanceToIn(p) == " << DistanceToIn(p);
1499 message.precision(oldprc) ;
1500 G4Exception("G4TriangularFacet::DistanceToOut(p)",
1501 "GeomSolids1002", JustWarning, message);
1502 }
1503#endif
1504
1505 G4double minDist;
1506
1507 if (OutsideOfExtent(p, kCarTolerance)) return 0.0;
1508
1509 if (fVoxels.GetCountOfVoxels() > 1)
1510 {
1511 G4VFacet *facet;
1512 minDist = MinDistanceFacet(p, true, facet);
1513 }
1514 else
1515 {
1516 minDist = kInfinity;
1517 G4double dist = 0.0;
1518 G4int size = fFacets.size();
1519 for (G4int i = 0; i < size; ++i)
1520 {
1521 G4VFacet &facet = *fFacets[i];
1522 dist = facet.Distance(p,minDist);
1523 if (dist < minDist) minDist = dist;
1524 }
1525 }
1526 return minDist;
1527}
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
virtual EInside Inside(const G4ThreeVector &p) const
@ kOutside
Definition: geomdefs.hh:58

Referenced by DistanceToOut().

◆ SafetyFromOutside()

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

Definition at line 1427 of file G4TessellatedSolid.cc.

1429{
1430#if G4SPECSDEBUG
1431 if ( Inside(p) == kInside )
1432 {
1433 std::ostringstream message;
1434 G4int oldprc = message.precision(16) ;
1435 message << "Point p is already inside!?" << endl
1436 << "Position:" << endl << endl
1437 << "p.x() = " << p.x()/mm << " mm" << endl
1438 << "p.y() = " << p.y()/mm << " mm" << endl
1439 << "p.z() = " << p.z()/mm << " mm" << endl
1440 << "DistanceToOut(p) == " << DistanceToOut(p);
1441 message.precision(oldprc) ;
1442 G4Exception("G4TriangularFacet::DistanceToIn(p)",
1443 "GeomSolids1002", JustWarning, message);
1444 }
1445#endif
1446
1447 G4double minDist;
1448
1449 if (!aAccurate)
1450 return fVoxels.DistanceToBoundingBox(p);
1451
1452 if (fVoxels.GetCountOfVoxels() > 1)
1453 {
1454 if (!OutsideOfExtent(p, kCarTolerance))
1455 {
1456 vector<G4int> startingVoxel(3);
1457 fVoxels.GetVoxel(startingVoxel, p);
1458 const vector<G4int> &candidates = fVoxels.GetCandidates(startingVoxel);
1459 if (candidates.size() == 0 && fInsides.GetNbits())
1460 {
1461 G4int index = fVoxels.GetPointIndex(p);
1462 if (fInsides[index]) return 0.;
1463 }
1464 }
1465
1466 G4VFacet *facet;
1467 minDist = MinDistanceFacet(p, true, facet);
1468 }
1469 else
1470 {
1471 minDist = kInfinity;
1472 G4int size = fFacets.size();
1473 for (G4int i = 0; i < size; ++i)
1474 {
1475 G4VFacet &facet = *fFacets[i];
1476 G4double dist = facet.Distance(p,minDist);
1477 if (dist < minDist) minDist = dist;
1478 }
1479 }
1480 return minDist;
1481}
unsigned int GetNbits() const
Definition: G4SurfBits.hh:101
G4int GetPointIndex(const G4ThreeVector &p) const
G4double DistanceToBoundingBox(const G4ThreeVector &point) const
virtual G4double DistanceToOut(const G4ThreeVector &p) const
@ kInside
Definition: geomdefs.hh:58

Referenced by DistanceToIn().

◆ SetMaxVoxels()

void G4TessellatedSolid::SetMaxVoxels ( G4int  max)
inline

Definition at line 308 of file G4TessellatedSolid.hh.

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

◆ SetSolidClosed()

void G4TessellatedSolid::SetSolidClosed ( const G4bool  t)

Definition at line 560 of file G4TessellatedSolid.cc.

561{
562 if (t)
563 {
564 CreateVertexList();
565
566 SetExtremeFacets();
567
568 Voxelize();
569
570#ifdef G4SPECSDEBUG
572#endif
573
574 }
575 fSolidClosed = t;
576}

Referenced by G4GDMLReadSolids::TessellatedRead().

◆ StreamInfo()

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

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1542 of file G4TessellatedSolid.cc.

1543{
1544 os << endl;
1545 os << "Geometry Type = " << fGeometryType << endl;
1546 os << "Number of facets = " << fFacets.size() << endl;
1547
1548 G4int size = fFacets.size();
1549 for (G4int i = 0; i < size; ++i)
1550 {
1551 os << "FACET # = " << i + 1 << endl;
1552 G4VFacet &facet = *fFacets[i];
1553 facet.StreamInfo(os);
1554 }
1555 os << endl;
1556
1557 return os;
1558}

◆ SurfaceNormal()

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

Implements G4VSolid.

Definition at line 1596 of file G4TessellatedSolid.cc.

1597{
1599 Normal(p, n);
1600 return n;
1601}
virtual G4bool Normal(const G4ThreeVector &p, G4ThreeVector &n) const

Referenced by G4GenericTrap::SurfaceNormal().


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