Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4TessellatedSolid Class Reference

#include <G4TessellatedSolid.hh>

Inheritance diagram for G4TessellatedSolid:
Collaboration diagram for G4TessellatedSolid:

Public Member Functions

 G4TessellatedSolid ()
 
virtual ~G4TessellatedSolid ()
 
 G4TessellatedSolid (const G4String &name)
 
 G4TessellatedSolid (__void__ &)
 
 G4TessellatedSolid (const G4TessellatedSolid &ts)
 
G4TessellatedSolid & operator= (const G4TessellatedSolid &right)
 
G4TessellatedSolid & operator+= (const G4TessellatedSolid &right)
 
G4bool AddFacet (G4VFacet *aFacet)
 
G4VFacet * GetFacet (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 G4VSolid * Clone () const
 
virtual G4ThreeVector GetPointOnSurface () const
 
virtual G4double GetSurfaceArea ()
 
virtual G4double GetCubicVolume ()
 
void SetSolidClosed (const G4bool t)
 
G4bool GetSolidClosed () const
 
void SetMaxVoxels (G4int max)
 
G4SurfaceVoxelizer & GetVoxels ()
 
virtual G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
 
void Extent (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
G4double GetMinXExtent () const
 
G4double GetMaxXExtent () const
 
G4double GetMinYExtent () const
 
G4double GetMaxYExtent () const
 
G4double GetMinZExtent () const
 
G4double GetMaxZExtent () const
 
virtual G4Polyhedron * CreatePolyhedron () const
 
virtual G4Polyhedron * GetPolyhedron () 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 ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
void DumpInfo () const
 
virtual const G4VSolid * GetConstituentSolid (G4int no) const
 
virtual G4VSolid * GetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolid * GetDisplacedSolidPtr () const
 
virtual G4DisplacedSolid * GetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolid & operator= (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 128 of file G4TessellatedSolid.hh.

Constructor & Destructor Documentation

G4TessellatedSolid::G4TessellatedSolid ( )

Definition at line 112 of file G4TessellatedSolid.cc.

112  : G4VSolid("dummy")
113 {
114  Initialize();
115 }
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:61

Here is the caller graph for this function:

G4TessellatedSolid::~G4TessellatedSolid ( )
virtual

Definition at line 142 of file G4TessellatedSolid.cc.

143 {
144  DeleteObjects ();
145 }
G4TessellatedSolid::G4TessellatedSolid ( const G4String &  name)

Definition at line 122 of file G4TessellatedSolid.cc.

123  : G4VSolid(name)
124 {
125  Initialize();
126 }
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:61
G4TessellatedSolid::G4TessellatedSolid ( __void__ &  a)

Definition at line 133 of file G4TessellatedSolid.cc.

133  : G4VSolid(a)
134 {
135  Initialize();
136  fMinExtent.set(0,0,0);
137  fMaxExtent.set(0,0,0);
138 }
void set(double x, double y, double z)
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:61

Here is the call graph for this function:

G4TessellatedSolid::G4TessellatedSolid ( const G4TessellatedSolid &  ts)

Definition at line 151 of file G4TessellatedSolid.cc.

152  : G4VSolid(ts), fpPolyhedron(0)
153 {
154  Initialize();
155 
156  CopyObjects(ts);
157 }
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:61

Member Function Documentation

G4bool G4TessellatedSolid::AddFacet ( G4VFacet *  aFacet)

Definition at line 233 of file G4TessellatedSolid.cc.

234 {
235  // Add the facet to the vector.
236  //
237  if (fSolidClosed)
238  {
239  G4Exception("G4TessellatedSolid::AddFacet()", "GeomSolids1002",
240  JustWarning, "Attempt to add facets when solid is closed.");
241  return false;
242  }
243  else if (aFacet->IsDefined())
244  {
245  set<G4VertexInfo,G4VertexComparator>::iterator begin
246  = fFacetList.begin(), end = fFacetList.end(), pos, it;
247  G4ThreeVector p = aFacet->GetCircumcentre();
249  value.id = fFacetList.size();
250  value.mag2 = p.x() + p.y() + p.z();
251 
252  G4bool found = false;
253  if (!OutsideOfExtent(p, kCarTolerance))
254  {
255  G4double kCarTolerance3 = 3 * kCarTolerance;
256  pos = fFacetList.lower_bound(value);
257 
258  it = pos;
259  while (!found && it != end) // Loop checking, 13.08.2015, G.Cosmo
260  {
261  G4int id = (*it).id;
262  G4VFacet *facet = fFacets[id];
263  G4ThreeVector q = facet->GetCircumcentre();
264  if ((found = (facet == aFacet))) break;
265  G4double dif = q.x() + q.y() + q.z() - value.mag2;
266  if (dif > kCarTolerance3) break;
267  it++;
268  }
269 
270  if (fFacets.size() > 1)
271  {
272  it = pos;
273  while (!found && it != begin) // Loop checking, 13.08.2015, G.Cosmo
274  {
275  --it;
276  G4int id = (*it).id;
277  G4VFacet *facet = fFacets[id];
278  G4ThreeVector q = facet->GetCircumcentre();
279  found = (facet == aFacet);
280  if (found) break;
281  G4double dif = value.mag2 - (q.x() + q.y() + q.z());
282  if (dif > kCarTolerance3) break;
283  }
284  }
285  }
286 
287  if (!found)
288  {
289  fFacets.push_back(aFacet);
290  fFacetList.insert(value);
291  }
292 
293  return true;
294  }
295  else
296  {
297  G4Exception("G4TessellatedSolid::AddFacet()", "GeomSolids1002",
298  JustWarning, "Attempt to add facet not properly defined.");
299  aFacet->StreamInfo(G4cout);
300  return false;
301  }
302 }
double x() const
const char * p
Definition: xmltok.h:285
virtual G4ThreeVector GetCircumcentre() const =0
int G4int
Definition: G4Types.hh:78
double z() const
G4GLOB_DLL std::ostream G4cout
const XML_Char int const XML_Char * value
Definition: expat.h:331
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double y() const
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4VFacet.cc:98
G4double kCarTolerance
Definition: G4VSolid.hh:307
double G4double
Definition: G4Types.hh:76
static const G4double pos
virtual G4bool IsDefined() const =0

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4TessellatedSolid::AllocatedMemory ( )

Definition at line 2091 of file G4TessellatedSolid.cc.

2092 {
2094  G4int sizeInsides = fInsides.GetNbytes();
2095  G4int sizeVoxels = fVoxels.AllocatedMemory();
2096  size += sizeInsides + sizeVoxels;
2097  return size;
2098 }
int G4int
Definition: G4Types.hh:78
unsigned int GetNbytes() const
Definition: G4SurfBits.hh:102

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4TessellatedSolid::AllocatedMemoryWithoutVoxels ( )

Definition at line 2065 of file G4TessellatedSolid.cc.

2066 {
2067  G4int base = sizeof(*this);
2068  base += fVertexList.capacity() * sizeof(G4ThreeVector);
2069  base += fRandir.capacity() * sizeof(G4ThreeVector);
2070 
2071  G4int limit = fFacets.size();
2072  for (G4int i = 0; i < limit; i++)
2073  {
2074  G4VFacet &facet = *fFacets[i];
2075  base += facet.AllocatedMemory();
2076  }
2077 
2078  std::set<G4VFacet *>::const_iterator beg, end, it;
2079  beg = fExtremeFacets.begin();
2080  end = fExtremeFacets.end();
2081  for (it = beg; it != end; it++)
2082  {
2083  G4VFacet &facet = *(*it);
2084  base += facet.AllocatedMemory();
2085  }
2086  return base;
2087 }
CLHEP::Hep3Vector G4ThreeVector
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
int G4int
Definition: G4Types.hh:78
virtual G4int AllocatedMemory()=0

Here is the call graph for this function:

Here is the caller graph for this function:

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 1853 of file G4TessellatedSolid.cc.

1857 {
1858  G4ThreeVector bmin, bmax;
1859  G4bool exist;
1860 
1861  // Check bounding box (bbox)
1862  //
1863  Extent(bmin,bmax);
1864  G4BoundingEnvelope bbox(bmin,bmax);
1865 #ifdef G4BBOX_EXTENT
1866  if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
1867 #endif
1868  if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
1869  {
1870  return exist = (pMin < pMax) ? true : false;
1871  }
1872 
1873  // The extent is calculated as cumulative extent of the pyramids
1874  // formed by facets and the center of the bounding box.
1875  //
1876  G4double eminlim = pVoxelLimit.GetMinExtent(pAxis);
1877  G4double emaxlim = pVoxelLimit.GetMaxExtent(pAxis);
1878 
1880  G4ThreeVectorList apex(1);
1881  std::vector<const G4ThreeVectorList *> pyramid(2);
1882  pyramid[0] = &base;
1883  pyramid[1] = &apex;
1884  apex[0] = (bmin+bmax)*0.5;
1885 
1886  // main loop along facets
1887  pMin = kInfinity;
1888  pMax = -kInfinity;
1889  for (G4int i=0; i<GetNumberOfFacets(); ++i)
1890  {
1891  G4VFacet* facet = GetFacet(i);
1892  if (std::abs((facet->GetSurfaceNormal()).dot(facet->GetVertex(0)-apex[0]))
1893  < kCarToleranceHalf) continue;
1894 
1895  G4int nv = facet->GetNumberOfVertices();
1896  base.resize(nv);
1897  for (G4int k=0; k<nv; ++k) { base[k] = facet->GetVertex(k); }
1898 
1899  G4double emin,emax;
1900  G4BoundingEnvelope benv(pyramid);
1901  if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax)) continue;
1902  if (emin < pMin) pMin = emin;
1903  if (emax > pMax) pMax = emax;
1904  if (eminlim > pMin && emaxlim < pMax) break; // max possible extent
1905  }
1906  return (pMin < pMax);
1907 }
static const G4double kInfinity
Definition: geomdefs.hh:42
virtual G4int GetNumberOfVertices() const =0
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
int G4int
Definition: G4Types.hh:78
G4VFacet * GetFacet(G4int i) const
virtual G4ThreeVector GetSurfaceNormal() const =0
bool G4bool
Definition: G4Types.hh:79
std::vector< G4ThreeVector > G4ThreeVectorList
static const G4double emax
G4int GetNumberOfFacets() const
double G4double
Definition: G4Types.hh:76
G4double GetMaxExtent(const EAxis pAxis) const
virtual G4ThreeVector GetVertex(G4int i) const =0
G4double GetMinExtent(const EAxis pAxis) const
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const

Here is the call graph for this function:

G4VSolid * G4TessellatedSolid::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1627 of file G4TessellatedSolid.cc.

1628 {
1629  return new G4TessellatedSolid(*this);
1630 }

Here is the call graph for this function:

G4Polyhedron * G4TessellatedSolid::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1772 of file G4TessellatedSolid.cc.

1773 {
1774  G4int nVertices = fVertexList.size();
1775  G4int nFacets = fFacets.size();
1776  G4PolyhedronArbitrary *polyhedron =
1777  new G4PolyhedronArbitrary (nVertices, nFacets);
1778  for (G4ThreeVectorList::const_iterator v= fVertexList.begin();
1779  v!=fVertexList.end(); ++v)
1780  {
1781  polyhedron->AddVertex(*v);
1782  }
1783 
1784  G4int size = fFacets.size();
1785  for (G4int i = 0; i < size; ++i)
1786  {
1787  G4VFacet &facet = *fFacets[i];
1788  G4int v[4];
1789  G4int n = facet.GetNumberOfVertices();
1790  if (n > 4) n = 4;
1791  else if (n == 3) v[3] = 0;
1792  for (G4int j=0; j<n; ++j)
1793  {
1794  G4int k = facet.GetVertexIndex(j);
1795  v[j] = k+1;
1796  }
1797  polyhedron->AddFacet(v[0],v[1],v[2],v[3]);
1798  }
1799  polyhedron->SetReferences();
1800 
1801  return (G4Polyhedron*) polyhedron;
1802 }
virtual G4int GetNumberOfVertices() const =0
int G4int
Definition: G4Types.hh:78
void AddVertex(const G4ThreeVector &v)
virtual G4int GetVertexIndex(G4int i) const =0
void AddFacet(const G4int iv1, const G4int iv2, const G4int iv3, const G4int iv4=0)

Here is the call graph for this function:

Here is the caller graph for this function:

void G4TessellatedSolid::DescribeYourselfTo ( G4VGraphicsScene &  scene) const
virtual

Implements G4VSolid.

Definition at line 1765 of file G4TessellatedSolid.cc.

1766 {
1767  scene.AddSolid (*this);
1768 }
virtual void AddSolid(const G4Box &)=0

Here is the call graph for this function:

Here is the caller graph for this function:

void G4TessellatedSolid::DisplayAllocatedMemory ( )

Definition at line 583 of file G4TessellatedSolid.cc.

584 {
586  G4int with = AllocatedMemory();
587  G4double ratio = (G4double) with / without;
588  G4cout << "G4TessellatedSolid - Allocated memory without voxel overhead "
589  << without << "; with " << with << "; ratio: " << ratio << G4endl;
590 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements G4VSolid.

Definition at line 1680 of file G4TessellatedSolid.cc.

1682 {
1683  G4double dist = DistanceToInCore(p,v,kInfinity);
1684 #ifdef G4SPECSDEBUG
1685  if (dist < kInfinity)
1686  {
1687  if (Inside(p + dist*v) != kSurface)
1688  {
1689  std::ostringstream message;
1690  message << "Invalid response from facet in solid '" << GetName() << "',"
1691  << G4endl
1692  << "at point: " << p << "and direction: " << v;
1693  G4Exception("G4TessellatedSolid::DistanceToIn(p,v)",
1694  "GeomSolids1002", JustWarning, message);
1695  }
1696  }
1697 #endif
1698  return dist;
1699 }
G4String GetName() const
static const G4double kInfinity
Definition: geomdefs.hh:42
virtual EInside Inside(const G4ThreeVector &p) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements G4VSolid.

Definition at line 1673 of file G4TessellatedSolid.cc.

1674 {
1675  return SafetyFromOutside(p,false);
1676 }
virtual G4double SafetyFromOutside(const G4ThreeVector &p, G4bool aAccurate=false) const

Here is the call graph for this function:

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

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1708 of file G4TessellatedSolid.cc.

1709 {
1710  return SafetyFromInside(p,false);
1711 }
virtual G4double SafetyFromInside(const G4ThreeVector &p, G4bool aAccurate=false) const

Here is the call graph for this function:

Here is the caller graph for this function:

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 1731 of file G4TessellatedSolid.cc.

1736 {
1737  G4ThreeVector n;
1738  G4bool valid;
1739 
1740  G4double dist = DistanceToOutCore(p, v, n, valid);
1741  if (calcNorm)
1742  {
1743  *norm = n;
1744  *validNorm = valid;
1745  }
1746 #ifdef G4SPECSDEBUG
1747  if (dist < kInfinity)
1748  {
1749  if (Inside(p + dist*v) != kSurface)
1750  {
1751  std::ostringstream message;
1752  message << "Invalid response from facet in solid '" << GetName() << "',"
1753  << G4endl
1754  << "at point: " << p << "and direction: " << v;
1755  G4Exception("G4TessellatedSolid::DistanceToOut(p,v,..)",
1756  "GeomSolids1002", JustWarning, message);
1757  }
1758  }
1759 #endif
1760  return dist;
1761 }
G4String GetName() const
static const G4double kInfinity
Definition: geomdefs.hh:42
virtual EInside Inside(const G4ThreeVector &p) const
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

void G4TessellatedSolid::Extent ( G4ThreeVector &  pMin,
G4ThreeVector &  pMax 
) const
virtual

Reimplemented from G4VSolid.

Definition at line 1828 of file G4TessellatedSolid.cc.

1829 {
1830  pMin = fMinExtent;
1831  pMax = fMaxExtent;
1832 
1833  // Check correctness of the bounding box
1834  //
1835  if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
1836  {
1837  std::ostringstream message;
1838  message << "Bad bounding box (min >= max) for solid: "
1839  << GetName() << " !"
1840  << "\npMin = " << pMin
1841  << "\npMax = " << pMax;
1842  G4Exception("G4TessellatedSolid::Extent()",
1843  "GeomMgt0001", JustWarning, message);
1844  DumpInfo();
1845  }
1846 }
G4String GetName() const
double x() const
double z() const
void DumpInfo() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double y() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4TessellatedSolid::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1962 of file G4TessellatedSolid.cc.

1963 {
1964  if (fCubicVolume != 0.) return fCubicVolume;
1965 
1966  // For explanation of the following algorithm see:
1967  // https://en.wikipedia.org/wiki/Polyhedron#Volume
1968  // http://wwwf.imperial.ac.uk/~rn/centroid.pdf
1969 
1970  G4int size = fFacets.size();
1971  for (G4int i = 0; i < size; ++i)
1972  {
1973  G4VFacet &facet = *fFacets[i];
1974  G4double area = facet.GetArea();
1975  G4ThreeVector unit_normal = facet.GetSurfaceNormal();
1976  fCubicVolume += area * (facet.GetVertex(0).dot(unit_normal));
1977  }
1978  fCubicVolume /= 3.;
1979  return fCubicVolume;
1980 }
double dot(const Hep3Vector &) const
int G4int
Definition: G4Types.hh:78
virtual G4ThreeVector GetSurfaceNormal() const =0
virtual G4double GetArea() const =0
double G4double
Definition: G4Types.hh:76
virtual G4ThreeVector GetVertex(G4int i) const =0

Here is the call graph for this function:

G4GeometryType G4TessellatedSolid::GetEntityType ( ) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1598 of file G4TessellatedSolid.cc.

1599 {
1600  return fGeometryType;
1601 }
G4VisExtent G4TessellatedSolid::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1953 of file G4TessellatedSolid.cc.

1954 {
1955  return G4VisExtent (fMinExtent.x(), fMaxExtent.x(),
1956  fMinExtent.y(), fMaxExtent.y(),
1957  fMinExtent.z(), fMaxExtent.z());
1958 }
double x() const
double z() const
double y() const

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 303 of file G4TessellatedSolid.hh.

304 {
305  return fFacets[i];
306 }

Here is the caller graph for this function:

G4double G4TessellatedSolid::GetMaxXExtent ( ) const

Definition at line 1918 of file G4TessellatedSolid.cc.

1919 {
1920  return fMaxExtent.x();
1921 }
double x() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4TessellatedSolid::GetMaxYExtent ( ) const

Definition at line 1932 of file G4TessellatedSolid.cc.

1933 {
1934  return fMaxExtent.y();
1935 }
double y() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4TessellatedSolid::GetMaxZExtent ( ) const

Definition at line 1946 of file G4TessellatedSolid.cc.

1947 {
1948  return fMaxExtent.z();
1949 }
double z() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4TessellatedSolid::GetMinXExtent ( ) const

Definition at line 1911 of file G4TessellatedSolid.cc.

1912 {
1913  return fMinExtent.x();
1914 }
double x() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4TessellatedSolid::GetMinYExtent ( ) const

Definition at line 1925 of file G4TessellatedSolid.cc.

1926 {
1927  return fMinExtent.y();
1928 }
double y() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4TessellatedSolid::GetMinZExtent ( ) const

Definition at line 1939 of file G4TessellatedSolid.cc.

1940 {
1941  return fMinExtent.z();
1942 }
double z() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4TessellatedSolid::GetNumberOfFacets ( ) const

Definition at line 655 of file G4TessellatedSolid.cc.

656 {
657  return fFacets.size();
658 }

Here is the caller graph for this function:

G4ThreeVector G4TessellatedSolid::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1999 of file G4TessellatedSolid.cc.

2000 {
2001  // Select randomly a facet and return a random point on it
2002 
2003  G4int i = (G4int) G4RandFlat::shoot(0., fFacets.size());
2004  return fFacets[i]->GetPointOnFace();
2005 }
ThreeVector shoot(const G4int Ap, const G4int Af)
int G4int
Definition: G4Types.hh:78

Here is the call graph for this function:

Here is the caller graph for this function:

G4Polyhedron * G4TessellatedSolid::GetPolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1808 of file G4TessellatedSolid.cc.

1809 {
1810  if (!fpPolyhedron ||
1811  fRebuildPolyhedron ||
1812  fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
1813  fpPolyhedron->GetNumberOfRotationSteps())
1814  {
1815  G4AutoLock l(&polyhedronMutex);
1816  delete fpPolyhedron;
1817  fpPolyhedron = CreatePolyhedron();
1818  fRebuildPolyhedron = false;
1819  l.unlock();
1820  }
1821  return fpPolyhedron;
1822 }
virtual G4Polyhedron * CreatePolyhedron() const
static G4int GetNumberOfRotationSteps()
G4int GetNumberOfRotationStepsAtTimeOfCreation() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4TessellatedSolid::GetSolidClosed ( ) const

Definition at line 627 of file G4TessellatedSolid.cc.

628 {
629  return fSolidClosed;
630 }
G4double G4TessellatedSolid::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1984 of file G4TessellatedSolid.cc.

1985 {
1986  if (fSurfaceArea != 0.) return fSurfaceArea;
1987 
1988  G4int size = fFacets.size();
1989  for (G4int i = 0; i < size; ++i)
1990  {
1991  G4VFacet &facet = *fFacets[i];
1992  fSurfaceArea += facet.GetArea();
1993  }
1994  return fSurfaceArea;
1995 }
int G4int
Definition: G4Types.hh:78
virtual G4double GetArea() const =0

Here is the call graph for this function:

G4SurfaceVoxelizer & G4TessellatedSolid::GetVoxels ( )
inline

Definition at line 313 of file G4TessellatedSolid.hh.

314 {
315  return fVoxels;
316 }
EInside G4TessellatedSolid::Inside ( const G4ThreeVector &  p) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1642 of file G4TessellatedSolid.cc.

1643 {
1644  EInside location;
1645 
1646  if (fVoxels.GetCountOfVoxels() > 1)
1647  {
1648  location = InsideVoxels(aPoint);
1649  }
1650  else
1651  {
1652  location = InsideNoVoxels(aPoint);
1653  }
1654  return location;
1655 }
EInside
Definition: geomdefs.hh:58
long long GetCountOfVoxels() const

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 999 of file G4TessellatedSolid.cc.

1001 {
1002  G4double minDist;
1003  G4VFacet *facet = 0;
1004 
1005  if (fVoxels.GetCountOfVoxels() > 1)
1006  {
1007  vector<G4int> curVoxel(3);
1008  fVoxels.GetVoxel(curVoxel, p);
1009  const vector<G4int> &candidates = fVoxels.GetCandidates(curVoxel);
1010  // fVoxels.GetCandidatesVoxelArray(p, candidates, 0);
1011 
1012  if (G4int limit = candidates.size())
1013  {
1014  minDist = kInfinity;
1015  for(G4int i = 0 ; i < limit ; ++i)
1016  {
1017  G4int candidate = candidates[i];
1018  G4VFacet &fct = *fFacets[candidate];
1019  G4double dist = fct.Distance(p,minDist);
1020  if (dist < minDist) minDist = dist;
1021  if (dist <= kCarToleranceHalf)
1022  {
1023  aNormal = fct.GetSurfaceNormal();
1024  return true;
1025  }
1026  }
1027  }
1028  minDist = MinDistanceFacet(p, true, facet);
1029  }
1030  else
1031  {
1032  minDist = kInfinity;
1033  G4int size = fFacets.size();
1034  for (G4int i = 0; i < size; ++i)
1035  {
1036  G4VFacet &f = *fFacets[i];
1037  G4double dist = f.Distance(p, minDist);
1038  if (dist < minDist)
1039  {
1040  minDist = dist;
1041  facet = &f;
1042  }
1043  }
1044  }
1045 
1046  if (minDist != kInfinity)
1047  {
1048  if (facet) { aNormal = facet->GetSurfaceNormal(); }
1049  return minDist <= kCarToleranceHalf;
1050  }
1051  else
1052  {
1053 #ifdef G4VERBOSE
1054  std::ostringstream message;
1055  message << "Point p is not on surface !?" << G4endl
1056  << " No facets found for point: " << p << " !" << G4endl
1057  << " Returning approximated value for normal.";
1058 
1059  G4Exception("G4TessellatedSolid::SurfaceNormal(p)",
1060  "GeomSolids1002", JustWarning, message );
1061 #endif
1062  aNormal = (p.z() > 0 ? G4ThreeVector(0,0,1) : G4ThreeVector(0,0,-1));
1063  return false;
1064  }
1065 }
static const G4double kInfinity
Definition: geomdefs.hh:42
CLHEP::Hep3Vector G4ThreeVector
virtual G4double Distance(const G4ThreeVector &, G4double)=0
int G4int
Definition: G4Types.hh:78
double z() const
virtual G4ThreeVector GetSurfaceNormal() const =0
void GetVoxel(std::vector< G4int > &curVoxel, const G4ThreeVector &point) const
const std::vector< G4int > & GetCandidates(std::vector< G4int > &curVoxel) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
long long GetCountOfVoxels() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 642 of file G4TessellatedSolid.cc.

643 {
644  G4int size = right.GetNumberOfFacets();
645  for (G4int i = 0; i < size; ++i)
646  AddFacet(right.GetFacet(i)->GetClone());
647 
648  return *this;
649 }
int G4int
Definition: G4Types.hh:78
G4VFacet * GetFacet(G4int i) const
G4bool AddFacet(G4VFacet *aFacet)
G4int GetNumberOfFacets() const
virtual G4VFacet * GetClone()=0

Here is the call graph for this function:

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

Definition at line 164 of file G4TessellatedSolid.cc.

165 {
166  if (&ts == this) return *this;
167 
168  // Copy base class data
170 
171  DeleteObjects ();
172 
173  Initialize();
174 
175  CopyObjects (ts);
176 
177  return *this;
178 }
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:111

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1549 of file G4TessellatedSolid.cc.

1550 {
1551 #if G4SPECSDEBUG
1552  if ( Inside(p) == kOutside )
1553  {
1554  std::ostringstream message;
1555  G4int oldprc = message.precision(16) ;
1556  message << "Point p is already outside!?" << G4endl
1557  << "Position:" << G4endl << G4endl
1558  << "p.x() = " << p.x()/mm << " mm" << G4endl
1559  << "p.y() = " << p.y()/mm << " mm" << G4endl
1560  << "p.z() = " << p.z()/mm << " mm" << G4endl
1561  << "DistanceToIn(p) == " << DistanceToIn(p);
1562  message.precision(oldprc) ;
1563  G4Exception("G4TriangularFacet::DistanceToOut(p)",
1564  "GeomSolids1002", JustWarning, message);
1565  }
1566 #endif
1567 
1568  G4double minDist;
1569 
1570  if (OutsideOfExtent(p, kCarTolerance)) return 0.0;
1571 
1572  if (fVoxels.GetCountOfVoxels() > 1)
1573  {
1574  G4VFacet *facet;
1575  minDist = MinDistanceFacet(p, true, facet);
1576  }
1577  else
1578  {
1579  minDist = kInfinity;
1580  G4double dist = 0.0;
1581  G4int size = fFacets.size();
1582  for (G4int i = 0; i < size; ++i)
1583  {
1584  G4VFacet &facet = *fFacets[i];
1585  dist = facet.Distance(p,minDist);
1586  if (dist < minDist) minDist = dist;
1587  }
1588  }
1589  return minDist;
1590 }
static constexpr double mm
Definition: G4SIunits.hh:115
static const G4double kInfinity
Definition: geomdefs.hh:42
double x() const
virtual G4double Distance(const G4ThreeVector &, G4double)=0
int G4int
Definition: G4Types.hh:78
double z() const
virtual EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double y() const
long long GetCountOfVoxels() const
#define G4endl
Definition: G4ios.hh:61
G4double kCarTolerance
Definition: G4VSolid.hh:307
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1490 of file G4TessellatedSolid.cc.

1492 {
1493 #if G4SPECSDEBUG
1494  if ( Inside(p) == kInside )
1495  {
1496  std::ostringstream message;
1497  G4int oldprc = message.precision(16) ;
1498  message << "Point p is already inside!?" << G4endl
1499  << "Position:" << G4endl << G4endl
1500  << "p.x() = " << p.x()/mm << " mm" << G4endl
1501  << "p.y() = " << p.y()/mm << " mm" << G4endl
1502  << "p.z() = " << p.z()/mm << " mm" << G4endl
1503  << "DistanceToOut(p) == " << DistanceToOut(p);
1504  message.precision(oldprc) ;
1505  G4Exception("G4TriangularFacet::DistanceToIn(p)",
1506  "GeomSolids1002", JustWarning, message);
1507  }
1508 #endif
1509 
1510  G4double minDist;
1511 
1512  if (fVoxels.GetCountOfVoxels() > 1)
1513  {
1514  if (!aAccurate)
1515  return fVoxels.DistanceToBoundingBox(p);
1516 
1517  if (!OutsideOfExtent(p, kCarTolerance))
1518  {
1519  vector<G4int> startingVoxel(3);
1520  fVoxels.GetVoxel(startingVoxel, p);
1521  const vector<G4int> &candidates = fVoxels.GetCandidates(startingVoxel);
1522  if (candidates.size() == 0 && fInsides.GetNbits())
1523  {
1524  G4int index = fVoxels.GetPointIndex(p);
1525  if (fInsides[index]) return 0.;
1526  }
1527  }
1528 
1529  G4VFacet *facet;
1530  minDist = MinDistanceFacet(p, true, facet);
1531  }
1532  else
1533  {
1534  minDist = kInfinity;
1535  G4int size = fFacets.size();
1536  for (G4int i = 0; i < size; ++i)
1537  {
1538  G4VFacet &facet = *fFacets[i];
1539  G4double dist = facet.Distance(p,minDist);
1540  if (dist < minDist) minDist = dist;
1541  }
1542  }
1543  return minDist;
1544 }
unsigned int GetNbits() const
Definition: G4SurfBits.hh:101
static constexpr double mm
Definition: G4SIunits.hh:115
static const G4double kInfinity
Definition: geomdefs.hh:42
double x() const
G4double DistanceToBoundingBox(const G4ThreeVector &point) const
virtual G4double Distance(const G4ThreeVector &, G4double)=0
int G4int
Definition: G4Types.hh:78
double z() const
G4int GetPointIndex(const G4ThreeVector &p) const
virtual G4double DistanceToOut(const G4ThreeVector &p) const
void GetVoxel(std::vector< G4int > &curVoxel, const G4ThreeVector &point) const
virtual EInside Inside(const G4ThreeVector &p) const
const std::vector< G4int > & GetCandidates(std::vector< G4int > &curVoxel) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double y() const
long long GetCountOfVoxels() const
#define G4endl
Definition: G4ios.hh:61
G4double kCarTolerance
Definition: G4VSolid.hh:307
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

void G4TessellatedSolid::SetMaxVoxels ( G4int  max)
inline

Definition at line 308 of file G4TessellatedSolid.hh.

309 {
310  fVoxels.SetMaxVoxels(max);
311 }
void SetMaxVoxels(G4int max)
T max(const T t1, const T t2)
brief Return the largest of the two arguments

Here is the call graph for this function:

void G4TessellatedSolid::SetSolidClosed ( const G4bool  t)

Definition at line 594 of file G4TessellatedSolid.cc.

595 {
596  if (t)
597  {
598 #ifdef G4SPECSDEBUG
599  G4cout << "Creating vertex list..." << G4endl;
600 #endif
601  CreateVertexList();
602 
603 #ifdef G4SPECSDEBUG
604  G4cout << "Setting extreme facets..." << G4endl;
605 #endif
606  SetExtremeFacets();
607 
608 #ifdef G4SPECSDEBUG
609  G4cout << "Voxelizing..." << G4endl;
610 #endif
611  Voxelize();
612 
613 #ifdef G4SPECSDEBUG
615 #endif
616 
617  }
618  fSolidClosed = t;
619 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1605 of file G4TessellatedSolid.cc.

1606 {
1607  os << G4endl;
1608  os << "Geometry Type = " << fGeometryType << G4endl;
1609  os << "Number of facets = " << fFacets.size() << G4endl;
1610 
1611  G4int size = fFacets.size();
1612  for (G4int i = 0; i < size; ++i)
1613  {
1614  os << "FACET # = " << i + 1 << G4endl;
1615  G4VFacet &facet = *fFacets[i];
1616  facet.StreamInfo(os);
1617  }
1618  os << G4endl;
1619 
1620  return os;
1621 }
int G4int
Definition: G4Types.hh:78
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4VFacet.cc:98
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

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

Implements G4VSolid.

Definition at line 1659 of file G4TessellatedSolid.cc.

1660 {
1661  G4ThreeVector n;
1662  Normal(p, n);
1663  return n;
1664 }
virtual G4bool Normal(const G4ThreeVector &p, G4ThreeVector &n) const

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

G4double G4TessellatedSolid::kCarToleranceHalf
protected

Definition at line 267 of file G4TessellatedSolid.hh.


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