Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4TessellatedSolid Class Reference

#include <G4TessellatedSolid.hh>

Inheritance diagram for G4TessellatedSolid:
G4VSolid G4ExtrudedSolid

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
 
G4double GetMinXExtent () const
 
G4double GetMaxXExtent () const
 
G4double GetMinYExtent () const
 
G4double GetMaxYExtent () const
 
G4double GetMinZExtent () const
 
G4double GetMaxZExtent () const
 
G4ThreeVectorList * CreateRotatedVertices (const G4AffineTransform &pT) 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)
 

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::G4TessellatedSolid ( )

Definition at line 101 of file G4TessellatedSolid.cc.

Referenced by Clone().

101  : G4VSolid("dummy")
102 {
103  Initialize();
104 }
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
G4TessellatedSolid::~G4TessellatedSolid ( )
virtual

Definition at line 131 of file G4TessellatedSolid.cc.

132 {
133  DeleteObjects ();
134 }
G4TessellatedSolid::G4TessellatedSolid ( const G4String &  name)

Definition at line 111 of file G4TessellatedSolid.cc.

112  : G4VSolid(name)
113 {
114  Initialize();
115 }
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
G4TessellatedSolid::G4TessellatedSolid ( __void__ &  a)

Definition at line 122 of file G4TessellatedSolid.cc.

References CLHEP::Hep3Vector::set().

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)
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
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 }
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60

Member Function Documentation

G4bool G4TessellatedSolid::AddFacet ( G4VFacet *  aFacet)

Definition at line 220 of file G4TessellatedSolid.cc.

References G4cout, G4Exception(), G4VFacet::GetCircumcentre(), G4VertexInfo::id, G4VFacet::IsDefined(), JustWarning, G4VSolid::kCarTolerance, G4VertexInfo::mag2, G4VFacet::StreamInfo(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

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

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();
236  value.id = fFacetList.size();
237  value.mag2 = p.x() + p.y() + p.z();
238 
239  G4bool found = false;
240  if (!OutsideOfExtent(p, kCarTolerance))
241  {
242  G4double kCarTolerance3 = 3 * kCarTolerance;
243  pos = fFacetList.lower_bound(value);
244 
245  it = pos;
246  while (!found && it != end)
247  {
248  G4int id = (*it).id;
249  G4VFacet *facet = fFacets[id];
250  G4ThreeVector q = facet->GetCircumcentre();
251  if ((found = (facet == aFacet))) break;
252  G4double dif = q.x() + q.y() + q.z() - value.mag2;
253  if (dif > kCarTolerance3) break;
254  it++;
255  }
256 
257  if (fFacets.size() > 1)
258  {
259  it = pos;
260  while (!found && it != begin)
261  {
262  --it;
263  G4int id = (*it).id;
264  G4VFacet *facet = fFacets[id];
265  G4ThreeVector q = facet->GetCircumcentre();
266  found = (facet == aFacet);
267  if (found) break;
268  G4double dif = value.mag2 - (q.x() + q.y() + q.z());
269  if (dif > kCarTolerance3) break;
270  }
271  }
272  }
273 
274  if (!found)
275  {
276  fFacets.push_back(aFacet);
277  fFacetList.insert(value);
278  }
279 
280  return true;
281  }
282  else
283  {
284  G4Exception("G4TessellatedSolid::AddFacet()", "GeomSolids1002",
285  JustWarning, "Attempt to add facet not properly defined.");
286  aFacet->StreamInfo(G4cout);
287  return false;
288  }
289 }
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
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
const XML_Char int const XML_Char * value
G4double kCarTolerance
Definition: G4VSolid.hh:305
double G4double
Definition: G4Types.hh:76
virtual G4bool IsDefined() const =0
G4int G4TessellatedSolid::AllocatedMemory ( )

Definition at line 2031 of file G4TessellatedSolid.cc.

References G4SurfaceVoxelizer::AllocatedMemory(), AllocatedMemoryWithoutVoxels(), and G4SurfBits::GetNbytes().

Referenced by DisplayAllocatedMemory().

2032 {
2034  G4int sizeInsides = fInsides.GetNbytes();
2035  G4int sizeVoxels = fVoxels.AllocatedMemory();
2036  size += sizeInsides + sizeVoxels;
2037  return size;
2038 }
int G4int
Definition: G4Types.hh:78
unsigned int GetNbytes() const
Definition: G4SurfBits.hh:102
G4int G4TessellatedSolid::AllocatedMemoryWithoutVoxels ( )

Definition at line 2005 of file G4TessellatedSolid.cc.

References G4VFacet::AllocatedMemory().

Referenced by AllocatedMemory(), and DisplayAllocatedMemory().

2006 {
2007  G4int base = sizeof(*this);
2008  base += fVertexList.capacity() * sizeof(G4ThreeVector);
2009  base += fRandir.capacity() * sizeof(G4ThreeVector);
2010 
2011  G4int limit = fFacets.size();
2012  for (G4int i = 0; i < limit; i++)
2013  {
2014  G4VFacet &facet = *fFacets[i];
2015  base += facet.AllocatedMemory();
2016  }
2017 
2018  std::set<G4VFacet *>::const_iterator beg, end, it;
2019  beg = fExtremeFacets.begin();
2020  end = fExtremeFacets.end();
2021  for (it = beg; it != end; it++)
2022  {
2023  G4VFacet &facet = *(*it);
2024  base += facet.AllocatedMemory();
2025  }
2026  return base;
2027 }
CLHEP::Hep3Vector G4ThreeVector
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char int const XML_Char * base
virtual G4int AllocatedMemory()=0
G4bool G4TessellatedSolid::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits &  pVoxelLimit,
const G4AffineTransform &  pTransform,
G4double &  pMin,
G4double &  pMax 
) const
virtual

Implements G4VSolid.

Definition at line 1782 of file G4TessellatedSolid.cc.

References G4AffineTransform::ApplyPointTransform(), G4VoxelLimits::GetMaxExtent(), G4VoxelLimits::GetMinExtent(), G4VoxelLimits::IsLimited(), G4VSolid::kCarTolerance, kXAxis, kYAxis, kZAxis, CLHEP::Hep3Vector::SIZE, CLHEP::Hep3Vector::X, CLHEP::Hep3Vector::Y, and CLHEP::Hep3Vector::Z.

Referenced by G4GenericTrap::CalculateExtent().

1786 {
1787  G4ThreeVectorList transVertexList(fVertexList);
1788  G4int size = fVertexList.size();
1789 
1790  // Put solid into transformed frame
1791  for (G4int i=0; i < size; ++i)
1792  {
1793  pTransform.ApplyPointTransform(transVertexList[i]);
1794  }
1795 
1796  // Find min and max extent in each dimension
1797  G4ThreeVector minExtent(kInfinity, kInfinity, kInfinity);
1798  G4ThreeVector maxExtent(-kInfinity, -kInfinity, -kInfinity);
1799 
1800  size = transVertexList.size();
1801  for (G4int i=0; i< size; ++i)
1802  {
1803  for (G4int axis=G4ThreeVector::X; axis < G4ThreeVector::SIZE; ++axis)
1804  {
1805  G4double coordinate = transVertexList[i][axis];
1806  if (coordinate < minExtent[axis])
1807  { minExtent[axis] = coordinate; }
1808  if (coordinate > maxExtent[axis])
1809  { maxExtent[axis] = coordinate; }
1810  }
1811  }
1812 
1813  // Check for containment and clamp to voxel boundaries
1814  for (G4int axis=G4ThreeVector::X; axis < G4ThreeVector::SIZE; ++axis)
1815  {
1816  EAxis geomAxis = kXAxis; // U geom classes use different index type
1817  switch(axis)
1818  {
1819  case G4ThreeVector::X: geomAxis = kXAxis; break;
1820  case G4ThreeVector::Y: geomAxis = kYAxis; break;
1821  case G4ThreeVector::Z: geomAxis = kZAxis; break;
1822  }
1823  G4bool isLimited = pVoxelLimit.IsLimited(geomAxis);
1824  G4double voxelMinExtent = pVoxelLimit.GetMinExtent(geomAxis);
1825  G4double voxelMaxExtent = pVoxelLimit.GetMaxExtent(geomAxis);
1826 
1827  if (isLimited)
1828  {
1829  if ( minExtent[axis] > voxelMaxExtent+kCarTolerance ||
1830  maxExtent[axis] < voxelMinExtent-kCarTolerance )
1831  {
1832  return false ;
1833  }
1834  else
1835  {
1836  if (minExtent[axis] < voxelMinExtent)
1837  {
1838  minExtent[axis] = voxelMinExtent ;
1839  }
1840  if (maxExtent[axis] > voxelMaxExtent)
1841  {
1842  maxExtent[axis] = voxelMaxExtent;
1843  }
1844  }
1845  }
1846  }
1847 
1848  // Convert pAxis into G4ThreeVector index
1849  G4int vecAxis=0;
1850  switch(pAxis)
1851  {
1852  case kXAxis: vecAxis = G4ThreeVector::X; break;
1853  case kYAxis: vecAxis = G4ThreeVector::Y; break;
1854  case kZAxis: vecAxis = G4ThreeVector::Z; break;
1855  default: break;
1856  }
1857 
1858  pMin = minExtent[vecAxis] - kCarTolerance;
1859  pMax = maxExtent[vecAxis] + kCarTolerance;
1860 
1861  return true;
1862 }
int G4int
Definition: G4Types.hh:78
G4bool IsLimited() const
bool G4bool
Definition: G4Types.hh:79
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
EAxis
Definition: geomdefs.hh:54
G4double kCarTolerance
Definition: G4VSolid.hh:305
double G4double
Definition: G4Types.hh:76
G4double GetMaxExtent(const EAxis pAxis) const
G4double GetMinExtent(const EAxis pAxis) const
void ApplyPointTransform(G4ThreeVector &vec) const
G4VSolid * G4TessellatedSolid::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1611 of file G4TessellatedSolid.cc.

References G4TessellatedSolid().

1612 {
1613  return new G4TessellatedSolid(*this);
1614 }
G4Polyhedron * G4TessellatedSolid::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1727 of file G4TessellatedSolid.cc.

References G4PolyhedronArbitrary::AddFacet(), G4PolyhedronArbitrary::AddVertex(), G4VFacet::GetNumberOfVertices(), G4VFacet::GetVertexIndex(), n, G4PolyhedronArbitrary::SetReferences(), and test::v.

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

1728 {
1729  G4int nVertices = fVertexList.size();
1730  G4int nFacets = fFacets.size();
1731  G4PolyhedronArbitrary *polyhedron =
1732  new G4PolyhedronArbitrary (nVertices, nFacets);
1733  for (G4ThreeVectorList::const_iterator v= fVertexList.begin();
1734  v!=fVertexList.end(); ++v)
1735  {
1736  polyhedron->AddVertex(*v);
1737  }
1738 
1739  G4int size = fFacets.size();
1740  for (G4int i = 0; i < size; ++i)
1741  {
1742  G4VFacet &facet = *fFacets[i];
1743  G4int v[4];
1744  G4int n = facet.GetNumberOfVertices();
1745  if (n > 4) n = 4;
1746  else if (n == 3) v[3] = 0;
1747  for (G4int j=0; j<n; ++j)
1748  {
1749  G4int k = facet.GetVertexIndex(j);
1750  v[j] = k+1;
1751  }
1752  polyhedron->AddFacet(v[0],v[1],v[2],v[3]);
1753  }
1754  polyhedron->SetReferences();
1755 
1756  return (G4Polyhedron*) polyhedron;
1757 }
virtual G4int GetNumberOfVertices() const =0
int G4int
Definition: G4Types.hh:78
const G4int n
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)
G4ThreeVectorList* G4TessellatedSolid::CreateRotatedVertices ( const G4AffineTransform &  pT) const
void G4TessellatedSolid::DescribeYourselfTo ( G4VGraphicsScene &  scene) const
virtual

Implements G4VSolid.

Definition at line 1720 of file G4TessellatedSolid.cc.

References G4VGraphicsScene::AddSolid().

Referenced by G4GenericTrap::DescribeYourselfTo().

1721 {
1722  scene.AddSolid (*this);
1723 }
virtual void AddSolid(const G4Box &)=0
void G4TessellatedSolid::DisplayAllocatedMemory ( )

Definition at line 567 of file G4TessellatedSolid.cc.

References AllocatedMemory(), AllocatedMemoryWithoutVoxels(), G4cout, and G4endl.

Referenced by SetSolidClosed().

568 {
570  G4int with = AllocatedMemory();
571  G4double ratio = (G4double) with / without;
572  G4cout << "G4TessellatedSolid - Allocated memory without voxel overhead "
573  << without << "; with " << with << "; ratio: " << ratio << G4endl;
574 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double G4TessellatedSolid::DistanceToIn ( const G4ThreeVector &  p,
const G4ThreeVector &  v 
) const
virtual

Implements G4VSolid.

Definition at line 1664 of file G4TessellatedSolid.cc.

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

1666 {
1667  return DistanceToInCore(p,v,kInfinity);
1668 }
G4double G4TessellatedSolid::DistanceToIn ( const G4ThreeVector &  p) const
virtual

Implements G4VSolid.

Definition at line 1657 of file G4TessellatedSolid.cc.

References SafetyFromOutside().

1658 {
1659  return SafetyFromOutside(p,false);
1660 }
virtual G4double SafetyFromOutside(const G4ThreeVector &p, G4bool aAccurate=false) const
G4double G4TessellatedSolid::DistanceToOut ( const G4ThreeVector &  p) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1677 of file G4TessellatedSolid.cc.

References SafetyFromInside().

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

1678 {
1679  return SafetyFromInside(p,false);
1680 }
virtual G4double SafetyFromInside(const G4ThreeVector &p, G4bool aAccurate=false) const
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 1700 of file G4TessellatedSolid.cc.

References n.

1705 {
1706  G4ThreeVector n;
1707  G4bool valid;
1708 
1709  G4double dist = DistanceToOutCore(p, v, n, valid);
1710  if (calcNorm)
1711  {
1712  *norm = n;
1713  *validNorm = valid;
1714  }
1715  return dist;
1716 }
bool G4bool
Definition: G4Types.hh:79
const G4int n
double G4double
Definition: G4Types.hh:76
G4double G4TessellatedSolid::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1915 of file G4TessellatedSolid.cc.

References G4VSolid::GetCubicVolume().

1916 {
1917  if(fCubicVolume != 0.) {;}
1918  else { fCubicVolume = G4VSolid::GetCubicVolume(); }
1919  return fCubicVolume;
1920 }
virtual G4double GetCubicVolume()
Definition: G4VSolid.cc:188
G4GeometryType G4TessellatedSolid::GetEntityType ( ) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1582 of file G4TessellatedSolid.cc.

1583 {
1584  return fGeometryType;
1585 }
G4VisExtent G4TessellatedSolid::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1908 of file G4TessellatedSolid.cc.

References CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by G4GenericTrap::GetExtent().

1909 {
1910  return G4VisExtent (fMinExtent.x(), fMaxExtent.x(), fMinExtent.y(), fMaxExtent.y(), fMinExtent.z(), fMaxExtent.z());
1911 }
double x() const
double z() const
double y() const
G4VFacet * G4TessellatedSolid::GetFacet ( G4int  i) const
inline

Definition at line 302 of file G4TessellatedSolid.hh.

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

303 {
304  return fFacets[i];
305 }
G4double G4TessellatedSolid::GetMaxXExtent ( ) const

Definition at line 1873 of file G4TessellatedSolid.cc.

References CLHEP::Hep3Vector::x().

Referenced by G4ExtrudedSolid::Inside().

1874 {
1875  return fMaxExtent.x();
1876 }
double x() const
G4double G4TessellatedSolid::GetMaxYExtent ( ) const

Definition at line 1887 of file G4TessellatedSolid.cc.

References CLHEP::Hep3Vector::y().

Referenced by G4ExtrudedSolid::Inside().

1888 {
1889  return fMaxExtent.y();
1890 }
double y() const
G4double G4TessellatedSolid::GetMaxZExtent ( ) const

Definition at line 1901 of file G4TessellatedSolid.cc.

References CLHEP::Hep3Vector::z().

Referenced by G4ExtrudedSolid::Inside().

1902 {
1903  return fMaxExtent.z();
1904 }
double z() const
G4double G4TessellatedSolid::GetMinXExtent ( ) const

Definition at line 1866 of file G4TessellatedSolid.cc.

References CLHEP::Hep3Vector::x().

Referenced by G4ExtrudedSolid::Inside().

1867 {
1868  return fMinExtent.x();
1869 }
double x() const
G4double G4TessellatedSolid::GetMinYExtent ( ) const

Definition at line 1880 of file G4TessellatedSolid.cc.

References CLHEP::Hep3Vector::y().

Referenced by G4ExtrudedSolid::Inside().

1881 {
1882  return fMinExtent.y();
1883 }
double y() const
G4double G4TessellatedSolid::GetMinZExtent ( ) const

Definition at line 1894 of file G4TessellatedSolid.cc.

References CLHEP::Hep3Vector::z().

Referenced by G4ExtrudedSolid::Inside().

1895 {
1896  return fMinExtent.z();
1897 }
double z() const
G4int G4TessellatedSolid::GetNumberOfFacets ( ) const

Definition at line 639 of file G4TessellatedSolid.cc.

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

640 {
641  return fFacets.size();
642 }
G4ThreeVector G4TessellatedSolid::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1939 of file G4TessellatedSolid.cc.

References G4INCL::DeJongSpin::shoot().

Referenced by G4GenericTrap::GetPointOnSurface().

1940 {
1941  // Select randomly a facet and return a random point on it
1942 
1943  G4int i = (G4int) G4RandFlat::shoot(0., fFacets.size());
1944  return fFacets[i]->GetPointOnFace();
1945 }
ThreeVector shoot(const G4int Ap, const G4int Af)
int G4int
Definition: G4Types.hh:78
G4Polyhedron * G4TessellatedSolid::GetPolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1763 of file G4TessellatedSolid.cc.

References CreatePolyhedron(), HepPolyhedron::GetNumberOfRotationSteps(), and G4Polyhedron::GetNumberOfRotationStepsAtTimeOfCreation().

Referenced by G4GenericTrap::GetPolyhedron().

1764 {
1765  if (!fpPolyhedron ||
1766  fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
1767  fpPolyhedron->GetNumberOfRotationSteps())
1768  {
1769  delete fpPolyhedron;
1770  fpPolyhedron = CreatePolyhedron();
1771  }
1772  return fpPolyhedron;
1773 }
virtual G4Polyhedron * CreatePolyhedron() const
static G4int GetNumberOfRotationSteps()
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4bool G4TessellatedSolid::GetSolidClosed ( ) const

Definition at line 611 of file G4TessellatedSolid.cc.

612 {
613  return fSolidClosed;
614 }
G4double G4TessellatedSolid::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1924 of file G4TessellatedSolid.cc.

References G4VFacet::GetArea().

1925 {
1926  if (fSurfaceArea != 0.) return fSurfaceArea;
1927 
1928  G4int size = fFacets.size();
1929  for (G4int i = 0; i < size; ++i)
1930  {
1931  G4VFacet &facet = *fFacets[i];
1932  fSurfaceArea += facet.GetArea();
1933  }
1934  return fSurfaceArea;
1935 }
virtual G4double GetArea()=0
int G4int
Definition: G4Types.hh:78
G4SurfaceVoxelizer & G4TessellatedSolid::GetVoxels ( )
inline

Definition at line 312 of file G4TessellatedSolid.hh.

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

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1626 of file G4TessellatedSolid.cc.

References G4SurfaceVoxelizer::GetCountOfVoxels().

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

1627 {
1628  EInside location;
1629 
1630  if (fVoxels.GetCountOfVoxels() > 1)
1631  {
1632  location = InsideVoxels(aPoint);
1633  }
1634  else
1635  {
1636  location = InsideNoVoxels(aPoint);
1637  }
1638  return location;
1639 }
EInside
Definition: geomdefs.hh:58
long long GetCountOfVoxels() const
G4bool G4TessellatedSolid::Normal ( const G4ThreeVector &  p,
G4ThreeVector &  n 
) const
virtual

Definition at line 983 of file G4TessellatedSolid.cc.

References G4VFacet::Distance(), G4Exception(), G4SurfaceVoxelizer::GetCandidates(), G4SurfaceVoxelizer::GetCountOfVoxels(), G4VFacet::GetSurfaceNormal(), G4SurfaceVoxelizer::GetVoxel(), JustWarning, and CLHEP::Hep3Vector::z().

Referenced by SurfaceNormal().

985 {
986  G4double minDist;
987  G4VFacet *facet = 0;
988 
989  if (fVoxels.GetCountOfVoxels() > 1)
990  {
991  vector<G4int> curVoxel(3);
992  fVoxels.GetVoxel(curVoxel, p);
993  const vector<G4int> &candidates = fVoxels.GetCandidates(curVoxel);
994  // fVoxels.GetCandidatesVoxelArray(p, candidates, 0);
995 
996  if (G4int limit = candidates.size())
997  {
998  minDist = kInfinity;
999  for(G4int i = 0 ; i < limit ; ++i)
1000  {
1001  G4int candidate = candidates[i];
1002  G4VFacet &fct = *fFacets[candidate];
1003  G4double dist = fct.Distance(p,minDist);
1004  if (dist < minDist) minDist = dist;
1005  if (dist <= kCarToleranceHalf)
1006  {
1007  aNormal = fct.GetSurfaceNormal();
1008  return true;
1009  }
1010  }
1011  }
1012  minDist = MinDistanceFacet(p, true, facet);
1013  }
1014  else
1015  {
1016  minDist = kInfinity;
1017  G4int size = fFacets.size();
1018  for (G4int i = 0; i < size; ++i)
1019  {
1020  G4VFacet &f = *fFacets[i];
1021  G4double dist = f.Distance(p, minDist);
1022  if (dist < minDist)
1023  {
1024  minDist = dist;
1025  facet = &f;
1026  }
1027  }
1028  }
1029 
1030  if (minDist != kInfinity)
1031  {
1032  if (facet) { aNormal = facet->GetSurfaceNormal(); }
1033  return minDist <= kCarToleranceHalf;
1034  }
1035  else
1036  {
1037 #ifdef G4VERBOSE
1038  std::ostringstream message;
1039  message << "Point p is not on surface !?" << G4endl
1040  << " No facets found for point: " << p << " !" << G4endl
1041  << " Returning approximated value for normal.";
1042 
1043  G4Exception("G4TessellatedSolid::SurfaceNormal(p)",
1044  "GeomSolids1002", JustWarning, message );
1045 #endif
1046  aNormal = (p.z() > 0 ? G4ThreeVector(0,0,1) : G4ThreeVector(0,0,-1));
1047  return false;
1048  }
1049 }
CLHEP::Hep3Vector G4ThreeVector
G4int GetCandidates(std::vector< G4int > &curVoxel, std::vector< G4int > *&candidates, std::vector< G4int > &space) const
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
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
G4TessellatedSolid & G4TessellatedSolid::operator+= ( const G4TessellatedSolid &  right)

Definition at line 626 of file G4TessellatedSolid.cc.

References AddFacet(), G4VFacet::GetClone(), GetFacet(), and GetNumberOfFacets().

627 {
628  G4int size = right.GetNumberOfFacets();
629  for (G4int i = 0; i < size; ++i)
630  AddFacet(right.GetFacet(i)->GetClone());
631 
632  return *this;
633 }
int G4int
Definition: G4Types.hh:78
G4VFacet * GetFacet(G4int i) const
G4bool AddFacet(G4VFacet *aFacet)
G4int GetNumberOfFacets() const
virtual G4VFacet * GetClone()=0
G4TessellatedSolid & G4TessellatedSolid::operator= ( const G4TessellatedSolid &  right)

Definition at line 153 of file G4TessellatedSolid.cc.

References G4VSolid::operator=().

Referenced by G4ExtrudedSolid::operator=().

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
G4double G4TessellatedSolid::SafetyFromInside ( const G4ThreeVector &  p,
G4bool  aAccurate = false 
) const
virtual

Definition at line 1533 of file G4TessellatedSolid.cc.

References G4VFacet::Distance(), DistanceToIn(), G4Exception(), G4SurfaceVoxelizer::GetCountOfVoxels(), Inside(), JustWarning, G4VSolid::kCarTolerance, kOutside, python.hepunit::mm, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToOut().

1534 {
1535 #if G4SPECSDEBUG
1536  if ( Inside(p) == kOutside )
1537  {
1538  std::ostringstream message;
1539  G4int oldprc = message.precision(16) ;
1540  message << "Point p is already outside!?" << G4endl
1541  << "Position:" << G4endl << G4endl
1542  << "p.x() = " << p.x()/mm << " mm" << G4endl
1543  << "p.y() = " << p.y()/mm << " mm" << G4endl
1544  << "p.z() = " << p.z()/mm << " mm" << G4endl
1545  << "DistanceToIn(p) == " << DistanceToIn(p);
1546  message.precision(oldprc) ;
1547  G4Exception("G4TriangularFacet::DistanceToOut(p)",
1548  "GeomSolids1002", JustWarning, message);
1549  }
1550 #endif
1551 
1552  G4double minDist;
1553 
1554  if (OutsideOfExtent(p, kCarTolerance)) return 0.0;
1555 
1556  if (fVoxels.GetCountOfVoxels() > 1)
1557  {
1558  G4VFacet *facet;
1559  minDist = MinDistanceFacet(p, true, facet);
1560  }
1561  else
1562  {
1563  minDist = kInfinity;
1564  G4double dist = 0.0;
1565  G4int size = fFacets.size();
1566  for (G4int i = 0; i < size; ++i)
1567  {
1568  G4VFacet &facet = *fFacets[i];
1569  dist = facet.Distance(p,minDist);
1570  if (dist < minDist) minDist = dist;
1571  }
1572  }
1573  return minDist;
1574 }
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:305
double G4double
Definition: G4Types.hh:76
G4double G4TessellatedSolid::SafetyFromOutside ( const G4ThreeVector &  p,
G4bool  aAccurate = false 
) const
virtual

Definition at line 1474 of file G4TessellatedSolid.cc.

References G4VFacet::Distance(), G4SurfaceVoxelizer::DistanceToBoundingBox(), DistanceToOut(), G4Exception(), G4SurfaceVoxelizer::GetCandidates(), G4SurfaceVoxelizer::GetCountOfVoxels(), G4SurfBits::GetNbits(), G4SurfaceVoxelizer::GetPointIndex(), G4SurfaceVoxelizer::GetVoxel(), Inside(), JustWarning, G4VSolid::kCarTolerance, kInside, python.hepunit::mm, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToIn().

1476 {
1477 #if G4SPECSDEBUG
1478  if ( Inside(p) == kInside )
1479  {
1480  std::ostringstream message;
1481  G4int oldprc = message.precision(16) ;
1482  message << "Point p is already inside!?" << G4endl
1483  << "Position:" << G4endl << G4endl
1484  << "p.x() = " << p.x()/mm << " mm" << G4endl
1485  << "p.y() = " << p.y()/mm << " mm" << G4endl
1486  << "p.z() = " << p.z()/mm << " mm" << G4endl
1487  << "DistanceToOut(p) == " << DistanceToOut(p);
1488  message.precision(oldprc) ;
1489  G4Exception("G4TriangularFacet::DistanceToIn(p)",
1490  "GeomSolids1002", JustWarning, message);
1491  }
1492 #endif
1493 
1494  G4double minDist;
1495 
1496  if (fVoxels.GetCountOfVoxels() > 1)
1497  {
1498  if (!aAccurate)
1499  return fVoxels.DistanceToBoundingBox(p);
1500 
1501  if (!OutsideOfExtent(p, kCarTolerance))
1502  {
1503  vector<G4int> startingVoxel(3);
1504  fVoxels.GetVoxel(startingVoxel, p);
1505  const vector<G4int> &candidates = fVoxels.GetCandidates(startingVoxel);
1506  if (candidates.size() == 0 && fInsides.GetNbits())
1507  {
1508  G4int index = fVoxels.GetPointIndex(p);
1509  if (fInsides[index]) return 0.;
1510  }
1511  }
1512 
1513  G4VFacet *facet;
1514  minDist = MinDistanceFacet(p, true, facet);
1515  }
1516  else
1517  {
1518  minDist = kInfinity;
1519  G4int size = fFacets.size();
1520  for (G4int i = 0; i < size; ++i)
1521  {
1522  G4VFacet &facet = *fFacets[i];
1523  G4double dist = facet.Distance(p,minDist);
1524  if (dist < minDist) minDist = dist;
1525  }
1526  }
1527  return minDist;
1528 }
unsigned int GetNbits() const
Definition: G4SurfBits.hh:101
double x() const
G4int GetCandidates(std::vector< G4int > &curVoxel, std::vector< G4int > *&candidates, std::vector< G4int > &space) 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
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:305
double G4double
Definition: G4Types.hh:76
void G4TessellatedSolid::SetMaxVoxels ( G4int  max)
inline

Definition at line 307 of file G4TessellatedSolid.hh.

References G4SurfaceVoxelizer::SetMaxVoxels().

308 {
309  fVoxels.SetMaxVoxels(max);
310 }
void SetMaxVoxels(G4int max)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void G4TessellatedSolid::SetSolidClosed ( const G4bool  t)

Definition at line 578 of file G4TessellatedSolid.cc.

References DisplayAllocatedMemory(), G4cout, and G4endl.

Referenced by G4GDMLReadSolids::TessellatedRead().

579 {
580  if (t)
581  {
582 #ifdef G4SPECSDEBUG
583  G4cout << "Creating vertex list..." << G4endl;
584 #endif
585  CreateVertexList();
586 
587 #ifdef G4SPECSDEBUG
588  G4cout << "Setting extreme facets..." << G4endl;
589 #endif
590  SetExtremeFacets();
591 
592 #ifdef G4SPECSDEBUG
593  G4cout << "Voxelizing..." << G4endl;
594 #endif
595  Voxelize();
596 
597 #ifdef G4SPECSDEBUG
599 #endif
600 
601  }
602  fSolidClosed = t;
603 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
std::ostream & G4TessellatedSolid::StreamInfo ( std::ostream &  os) const
virtual

Implements G4VSolid.

Reimplemented in G4ExtrudedSolid.

Definition at line 1589 of file G4TessellatedSolid.cc.

References G4endl, and G4VFacet::StreamInfo().

1590 {
1591  os << G4endl;
1592  os << "Geometry Type = " << fGeometryType << G4endl;
1593  os << "Number of facets = " << fFacets.size() << G4endl;
1594 
1595  G4int size = fFacets.size();
1596  for (G4int i = 0; i < size; ++i)
1597  {
1598  os << "FACET # = " << i + 1 << G4endl;
1599  G4VFacet &facet = *fFacets[i];
1600  facet.StreamInfo(os);
1601  }
1602  os << G4endl;
1603 
1604  return os;
1605 }
int G4int
Definition: G4Types.hh:78
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4VFacet.cc:98
#define G4endl
Definition: G4ios.hh:61
G4ThreeVector G4TessellatedSolid::SurfaceNormal ( const G4ThreeVector &  p) const
virtual

Implements G4VSolid.

Definition at line 1643 of file G4TessellatedSolid.cc.

References n, and Normal().

Referenced by G4GenericTrap::SurfaceNormal().

1644 {
1645  G4ThreeVector n;
1646  Normal(p, n);
1647  return n;
1648 }
const G4int n
virtual G4bool Normal(const G4ThreeVector &p, G4ThreeVector &n) const

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