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

#include <G4ExtrudedSolid.hh>

Inheritance diagram for G4ExtrudedSolid:
Collaboration diagram for G4ExtrudedSolid:

Classes

struct  ZSection
 

Public Member Functions

 G4ExtrudedSolid (const G4String &pName, const std::vector< G4TwoVector > &polygon, const std::vector< ZSection > &zsections)
 
 G4ExtrudedSolid (const G4String &pName, const std::vector< G4TwoVector > &polygon, G4double halfZ, const G4TwoVector &off1, G4double scale1, const G4TwoVector &off2, G4double scale2)
 
virtual ~G4ExtrudedSolid ()
 
G4int GetNofVertices () const
 
G4TwoVector GetVertex (G4int index) const
 
std::vector< G4TwoVectorGetPolygon () const
 
G4int GetNofZSections () const
 
ZSection GetZSection (G4int index) const
 
std::vector< ZSectionGetZSections () const
 
EInside Inside (const G4ThreeVector &p) const
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
 
G4double DistanceToOut (const G4ThreeVector &p) const
 
void Extent (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
 
G4GeometryType GetEntityType () const
 
G4VSolidClone () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
 G4ExtrudedSolid (__void__ &)
 
 G4ExtrudedSolid (const G4ExtrudedSolid &rhs)
 
G4ExtrudedSolidoperator= (const G4ExtrudedSolid &rhs)
 
- Public Member Functions inherited from G4TessellatedSolid
 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 G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
virtual G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
virtual G4double DistanceToIn (const G4ThreeVector &p) 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 G4ThreeVector GetPointOnSurface () const
 
virtual G4double GetSurfaceArea ()
 
virtual G4double GetCubicVolume ()
 
void SetSolidClosed (const G4bool t)
 
G4bool GetSolidClosed () const
 
void SetMaxVoxels (G4int max)
 
G4SurfaceVoxelizerGetVoxels ()
 
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 G4PolyhedronCreatePolyhedron () const
 
virtual G4PolyhedronGetPolyhedron () const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
virtual G4VisExtent GetExtent () const
 
G4int AllocatedMemoryWithoutVoxels ()
 
G4int AllocatedMemory ()
 
void DisplayAllocatedMemory ()
 
- Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
 
virtual ~G4VSolid ()
 
G4bool operator== (const G4VSolid &s) const
 
G4String GetName () const
 
void SetName (const G4String &name)
 
G4double GetTolerance () const
 
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
void DumpInfo () const
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 

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
 
- Protected Attributes inherited from G4TessellatedSolid
G4double kCarToleranceHalf
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 83 of file G4ExtrudedSolid.hh.

Constructor & Destructor Documentation

G4ExtrudedSolid::G4ExtrudedSolid ( const G4String pName,
const std::vector< G4TwoVector > &  polygon,
const std::vector< ZSection > &  zsections 
)

Definition at line 70 of file G4ExtrudedSolid.cc.

73  : G4TessellatedSolid(pName),
74  fNv(polygon.size()),
75  fNz(zsections.size()),
76  fPolygon(),
77  fZSections(),
78  fTriangles(),
79  fIsConvex(false),
80  fGeometryType("G4ExtrudedSolid")
81 
82 {
83  // General constructor
84 
85  // First check input parameters
86 
87  if (fNv < 3)
88  {
89  std::ostringstream message;
90  message << "Number of vertices in polygon < 3 - " << pName;
91  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
92  FatalErrorInArgument, message);
93  }
94 
95  if (fNz < 2)
96  {
97  std::ostringstream message;
98  message << "Number of z-sides < 2 - " << pName;
99  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
100  FatalErrorInArgument, message);
101  }
102 
103  for ( G4int i=0; i<fNz-1; ++i )
104  {
105  if ( zsections[i].fZ > zsections[i+1].fZ )
106  {
107  std::ostringstream message;
108  message << "Z-sections have to be ordered by z value (z0 < z1 < z2...) - "
109  << pName;
110  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
111  FatalErrorInArgument, message);
112  }
113  if ( std::fabs( zsections[i+1].fZ - zsections[i].fZ ) < kCarToleranceHalf )
114  {
115  std::ostringstream message;
116  message << "Z-sections with the same z position are not supported - "
117  << pName;
118  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0001",
119  FatalException, message);
120  }
121  }
122 
123  // Copy polygon
124  //
125  fPolygon = polygon;
126 
127  // Remove collinear and coincident vertices, if any
128  //
129  std::vector<G4int> removedVertices;
130  G4GeomTools::RemoveRedundantVertices(fPolygon,removedVertices,
131  2*kCarTolerance);
132  if (removedVertices.size() != 0)
133  {
134  G4int nremoved = removedVertices.size();
135  std::ostringstream message;
136  message << "The following "<< nremoved
137  << " vertices have been removed from polygon in " << pName
138  << "\nas collinear or coincident with other vertices: "
139  << removedVertices[0];
140  for (G4int i=1; i<nremoved; ++i) message << ", " << removedVertices[i];
141  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
142  JustWarning, message);
143  }
144 
145  fNv = fPolygon.size();
146  if (fNv < 3)
147  {
148  std::ostringstream message;
149  message << "Number of vertices in polygon after removal < 3 - " << pName;
150  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
151  FatalErrorInArgument, message);
152  }
153 
154  // Check if polygon vertices are defined clockwise
155  // (the area is positive if polygon vertices are defined anti-clockwise)
156  //
157  if (G4GeomTools::PolygonArea(fPolygon) > 0.)
158  {
159  // Polygon vertices are defined anti-clockwise, we revert them
160  // G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
161  // JustWarning,
162  // "Polygon vertices defined anti-clockwise, reverting polygon");
163  std::reverse(fPolygon.begin(),fPolygon.end());
164  }
165 
166  // Copy z-sections
167  //
168  fZSections = zsections;
169 
170  G4bool result = MakeFacets();
171  if (!result)
172  {
173  std::ostringstream message;
174  message << "Making facets failed - " << pName;
175  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0003",
176  FatalException, message);
177  }
178  fIsConvex = G4GeomTools::IsConvex(fPolygon);
179 
180  ComputeProjectionParameters();
181 }
G4double G4ParticleHPJENDLHEData::G4double result
static G4double PolygonArea(const G4TwoVectorList &polygon)
Definition: G4GeomTools.cc:82
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4bool IsConvex(const G4TwoVectorList &polygon)
Definition: G4GeomTools.cc:150
G4double kCarTolerance
Definition: G4VSolid.hh:307
static void RemoveRedundantVertices(G4TwoVectorList &polygon, std::vector< G4int > &iout, G4double tolerance=0)
Definition: G4GeomTools.cc:293

Here is the call graph for this function:

Here is the caller graph for this function:

G4ExtrudedSolid::G4ExtrudedSolid ( const G4String pName,
const std::vector< G4TwoVector > &  polygon,
G4double  halfZ,
const G4TwoVector off1,
G4double  scale1,
const G4TwoVector off2,
G4double  scale2 
)

Definition at line 185 of file G4ExtrudedSolid.cc.

190  : G4TessellatedSolid(pName),
191  fNv(polygon.size()),
192  fNz(2),
193  fPolygon(),
194  fZSections(),
195  fTriangles(),
196  fIsConvex(false),
197  fGeometryType("G4ExtrudedSolid")
198 
199 {
200  // Special constructor for solid with 2 z-sections
201 
202  // First check input parameters
203  //
204  if (fNv < 3)
205  {
206  std::ostringstream message;
207  message << "Number of vertices in polygon < 3 - " << pName;
208  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
209  FatalErrorInArgument, message);
210  }
211 
212  // Copy polygon
213  //
214  fPolygon = polygon;
215 
216  // Remove collinear and coincident vertices, if any
217  //
218  std::vector<G4int> removedVertices;
219  G4GeomTools::RemoveRedundantVertices(fPolygon,removedVertices,
220  2*kCarTolerance);
221  if (removedVertices.size() != 0)
222  {
223  G4int nremoved = removedVertices.size();
224  std::ostringstream message;
225  message << "The following "<< nremoved
226  << " vertices have been removed from polygon in " << pName
227  << "\nas collinear or coincident with other vertices: "
228  << removedVertices[0];
229  for (G4int i=1; i<nremoved; ++i) message << ", " << removedVertices[i];
230  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
231  JustWarning, message);
232  }
233 
234  fNv = fPolygon.size();
235  if (fNv < 3)
236  {
237  std::ostringstream message;
238  message << "Number of vertices in polygon after removal < 3 - " << pName;
239  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
240  FatalErrorInArgument, message);
241  }
242 
243  // Check if polygon vertices are defined clockwise
244  // (the area is positive if polygon vertices are defined anti-clockwise)
245  //
246  if (G4GeomTools::PolygonArea(fPolygon) > 0.)
247  {
248  // Polygon vertices are defined anti-clockwise, we revert them
249  // G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
250  // JustWarning,
251  // "Polygon vertices defined anti-clockwise, reverting polygon");
252  std::reverse(fPolygon.begin(),fPolygon.end());
253  }
254 
255  // Copy z-sections
256  //
257  fZSections.push_back(ZSection(-dz, off1, scale1));
258  fZSections.push_back(ZSection( dz, off2, scale2));
259 
260  G4bool result = MakeFacets();
261  if (!result)
262  {
263  std::ostringstream message;
264  message << "Making facets failed - " << pName;
265  G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0003",
266  FatalException, message);
267  }
268  fIsConvex = G4GeomTools::IsConvex(fPolygon);
269 
270  ComputeProjectionParameters();
271 }
G4double G4ParticleHPJENDLHEData::G4double result
static G4double PolygonArea(const G4TwoVectorList &polygon)
Definition: G4GeomTools.cc:82
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4bool IsConvex(const G4TwoVectorList &polygon)
Definition: G4GeomTools.cc:150
G4double kCarTolerance
Definition: G4VSolid.hh:307
static void RemoveRedundantVertices(G4TwoVectorList &polygon, std::vector< G4int > &iout, G4double tolerance=0)
Definition: G4GeomTools.cc:293

Here is the call graph for this function:

G4ExtrudedSolid::~G4ExtrudedSolid ( )
virtual

Definition at line 321 of file G4ExtrudedSolid.cc.

322 {
323  // Destructor
324 }
G4ExtrudedSolid::G4ExtrudedSolid ( __void__ &  a)

Definition at line 275 of file G4ExtrudedSolid.cc.

276  : G4TessellatedSolid(a), fNv(0), fNz(0), fPolygon(), fZSections(),
277  fTriangles(), fIsConvex(false), fGeometryType("G4ExtrudedSolid")
278 {
279  // Fake default constructor - sets only member data and allocates memory
280  // for usage restricted to object persistency.
281 }
G4ExtrudedSolid::G4ExtrudedSolid ( const G4ExtrudedSolid rhs)

Definition at line 285 of file G4ExtrudedSolid.cc.

286  : G4TessellatedSolid(rhs), fNv(rhs.fNv), fNz(rhs.fNz),
287  fPolygon(rhs.fPolygon), fZSections(rhs.fZSections),
288  fTriangles(rhs.fTriangles), fIsConvex(rhs.fIsConvex),
289  fGeometryType(rhs.fGeometryType), fKScales(rhs.fKScales),
290  fScale0s(rhs.fScale0s), fKOffsets(rhs.fKOffsets), fOffset0s(rhs.fOffset0s)
291 {
292 }

Member Function Documentation

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

Reimplemented from G4TessellatedSolid.

Definition at line 968 of file G4ExtrudedSolid.cc.

972 {
973  G4ThreeVector bmin, bmax;
974  G4bool exist;
975 
976  // Check bounding box (bbox)
977  //
978  Extent(bmin,bmax);
979  G4BoundingEnvelope bbox(bmin,bmax);
980 #ifdef G4BBOX_EXTENT
981  if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
982 #endif
983  if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
984  {
985  return exist = (pMin < pMax) ? true : false;
986  }
987 
988  // To find the extent, the base polygon is subdivided in triangles.
989  // The extent is calculated as cumulative extent of the parts
990  // formed by extrusion of the triangles
991  //
992  G4TwoVectorList triangles;
993  G4double eminlim = pVoxelLimit.GetMinExtent(pAxis);
994  G4double emaxlim = pVoxelLimit.GetMaxExtent(pAxis);
995 
996  // triangulate the base polygon
997  if (!G4GeomTools::TriangulatePolygon(fPolygon,triangles))
998  {
999  std::ostringstream message;
1000  message << "Triangulation of the base polygon has failed for solid: "
1001  << GetName() << " !"
1002  << "\nExtent has been calculated using boundary box";
1003  G4Exception("G4ExtrudedSolid::CalculateExtent()",
1004  "GeomMgt1002",JustWarning,message);
1005  return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
1006  }
1007 
1008  // allocate vector lists
1009  G4int nsect = GetNofZSections();
1010  std::vector<const G4ThreeVectorList *> polygons;
1011  polygons.resize(nsect);
1012  for (G4int k=0; k<nsect; ++k) { polygons[k] = new G4ThreeVectorList(3); }
1013 
1014  // main loop along triangles
1015  pMin = kInfinity;
1016  pMax = -kInfinity;
1017  G4int ntria = triangles.size()/3;
1018  for (G4int i=0; i<ntria; ++i)
1019  {
1020  G4int i3 = i*3;
1021  for (G4int k=0; k<nsect; ++k) // extrude triangle
1022  {
1023  ZSection zsect = GetZSection(k);
1024  G4double z = zsect.fZ;
1025  G4double dx = zsect.fOffset.x();
1026  G4double dy = zsect.fOffset.y();
1027  G4double scale = zsect.fScale;
1028 
1029  G4ThreeVectorList* ptr = const_cast<G4ThreeVectorList*>(polygons[k]);
1030  G4ThreeVectorList::iterator iter = ptr->begin();
1031  G4double x0 = triangles[i3+0].x()*scale+dx;
1032  G4double y0 = triangles[i3+0].y()*scale+dy;
1033  iter->set(x0,y0,z);
1034  iter++;
1035  G4double x1 = triangles[i3+1].x()*scale+dx;
1036  G4double y1 = triangles[i3+1].y()*scale+dy;
1037  iter->set(x1,y1,z);
1038  iter++;
1039  G4double x2 = triangles[i3+2].x()*scale+dx;
1040  G4double y2 = triangles[i3+2].y()*scale+dy;
1041  iter->set(x2,y2,z);
1042  }
1043 
1044  // set sub-envelope and adjust extent
1045  G4double emin,emax;
1046  G4BoundingEnvelope benv(polygons);
1047  if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax)) continue;
1048  if (emin < pMin) pMin = emin;
1049  if (emax > pMax) pMax = emax;
1050  if (eminlim > pMin && emaxlim < pMax) break; // max possible extent
1051  }
1052  // free memory
1053  for (G4int k=0; k<nsect; ++k) { delete polygons[k]; polygons[k]=0;}
1054  return (pMin < pMax);
1055 }
G4String GetName() const
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const
static const G4double kInfinity
Definition: geomdefs.hh:42
std::vector< G4TwoVector > G4TwoVectorList
Definition: G4GeomTools.hh:50
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
static G4bool TriangulatePolygon(const G4TwoVectorList &polygon, G4TwoVectorList &result)
Definition: G4GeomTools.cc:178
std::vector< G4ThreeVector > G4ThreeVectorList
G4int GetNofZSections() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static const G4double emax
ZSection GetZSection(G4int index) const
double G4double
Definition: G4Types.hh:76
G4double GetMaxExtent(const EAxis pAxis) const
G4double GetMinExtent(const EAxis pAxis) const

Here is the call graph for this function:

G4VSolid * G4ExtrudedSolid::Clone ( ) const
virtual

Reimplemented from G4TessellatedSolid.

Definition at line 801 of file G4ExtrudedSolid.cc.

802 {
803  return new G4ExtrudedSolid(*this);
804 }
G4ExtrudedSolid(const G4String &pName, const std::vector< G4TwoVector > &polygon, const std::vector< ZSection > &zsections)

Here is the call graph for this function:

G4double G4ExtrudedSolid::DistanceToOut ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  calcNorm = false,
G4bool validNorm = 0,
G4ThreeVector n = 0 
) const
virtual

Reimplemented from G4TessellatedSolid.

Definition at line 881 of file G4ExtrudedSolid.cc.

886 {
887  // Override the base class function to redefine validNorm
888  // (the solid can be concave)
889 
890  G4double distOut =
891  G4TessellatedSolid::DistanceToOut(p, v, calcNorm, validNorm, n);
892  if (validNorm) { *validNorm = fIsConvex; }
893 
894  return distOut;
895 }
virtual G4double DistanceToOut(const G4ThreeVector &p) const
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

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

Reimplemented from G4TessellatedSolid.

Definition at line 900 of file G4ExtrudedSolid.cc.

901 {
902  // Override the overloaded base class function
903 
905 }
virtual G4double DistanceToOut(const G4ThreeVector &p) const

Here is the call graph for this function:

void G4ExtrudedSolid::Extent ( G4ThreeVector pMin,
G4ThreeVector pMax 
) const
virtual

Reimplemented from G4VSolid.

Definition at line 911 of file G4ExtrudedSolid.cc.

912 {
913  G4double xmin0 = kInfinity, xmax0 = -kInfinity;
914  G4double ymin0 = kInfinity, ymax0 = -kInfinity;
915 
916  for (G4int i=0; i<GetNofVertices(); ++i)
917  {
918  G4double x = fPolygon[i].x();
919  if (x < xmin0) xmin0 = x;
920  if (x > xmax0) xmax0 = x;
921  G4double y = fPolygon[i].y();
922  if (y < ymin0) ymin0 = y;
923  if (y > ymax0) ymax0 = y;
924  }
925 
926  G4double xmin = kInfinity, xmax = -kInfinity;
927  G4double ymin = kInfinity, ymax = -kInfinity;
928 
929  G4int nsect = GetNofZSections();
930  for (G4int i=0; i<nsect; ++i)
931  {
932  ZSection zsect = GetZSection(i);
933  G4double dx = zsect.fOffset.x();
934  G4double dy = zsect.fOffset.y();
935  G4double scale = zsect.fScale;
936  xmin = std::min(xmin,xmin0*scale+dx);
937  xmax = std::max(xmax,xmax0*scale+dx);
938  ymin = std::min(ymin,ymin0*scale+dy);
939  ymax = std::max(ymax,ymax0*scale+dy);
940  }
941 
942  G4double zmin = GetZSection(0).fZ;
943  G4double zmax = GetZSection(nsect-1).fZ;
944 
945  pMin.set(xmin,ymin,zmin);
946  pMax.set(xmax,ymax,zmax);
947 
948  // Check correctness of the bounding box
949  //
950  if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
951  {
952  std::ostringstream message;
953  message << "Bad bounding box (min >= max) for solid: "
954  << GetName() << " !"
955  << "\npMin = " << pMin
956  << "\npMax = " << pMax;
957  G4Exception("G4ExtrudedSolid::Extent()",
958  "GeomMgt0001", JustWarning, message);
959  DumpInfo();
960  }
961 }
void set(double x, double y, double z)
G4String GetName() const
static const G4double kInfinity
Definition: geomdefs.hh:42
double x() const
int G4int
Definition: G4Types.hh:78
double z() const
void DumpInfo() const
G4int GetNofVertices() const
G4int GetNofZSections() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
T max(const T t1, const T t2)
brief Return the largest of the two arguments
double y() const
ZSection GetZSection(G4int index) const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

G4GeometryType G4ExtrudedSolid::GetEntityType ( ) const
virtual

Reimplemented from G4TessellatedSolid.

Definition at line 792 of file G4ExtrudedSolid.cc.

793 {
794  // Return entity type
795 
796  return fGeometryType;
797 }
G4int G4ExtrudedSolid::GetNofVertices ( ) const
inline

Here is the caller graph for this function:

G4int G4ExtrudedSolid::GetNofZSections ( ) const
inline

Here is the caller graph for this function:

std::vector<G4TwoVector> G4ExtrudedSolid::GetPolygon ( ) const
inline
G4TwoVector G4ExtrudedSolid::GetVertex ( G4int  index) const
inline

Here is the caller graph for this function:

ZSection G4ExtrudedSolid::GetZSection ( G4int  index) const
inline

Here is the caller graph for this function:

std::vector<ZSection> G4ExtrudedSolid::GetZSections ( ) const
inline
EInside G4ExtrudedSolid::Inside ( const G4ThreeVector p) const
virtual

Reimplemented from G4TessellatedSolid.

Definition at line 808 of file G4ExtrudedSolid.cc.

809 {
810  // Override the base class function as it fails in case of concave polygon.
811  // Project the point in the original polygon scale and check if it is inside
812  // for each triangle.
813 
814  // Check first if outside extent
815  //
816  if ( p.x() < GetMinXExtent() - kCarToleranceHalf ||
817  p.x() > GetMaxXExtent() + kCarToleranceHalf ||
818  p.y() < GetMinYExtent() - kCarToleranceHalf ||
819  p.y() > GetMaxYExtent() + kCarToleranceHalf ||
820  p.z() < GetMinZExtent() - kCarToleranceHalf ||
821  p.z() > GetMaxZExtent() + kCarToleranceHalf )
822  {
823  // G4cout << "G4ExtrudedSolid::Outside extent: " << p << G4endl;
824  return kOutside;
825  }
826 
827  // Project point p(z) to the polygon scale p0
828  //
829  G4TwoVector pscaled = ProjectPoint(p);
830 
831  // Check if on surface of polygon
832  //
833  for ( G4int i=0; i<fNv; ++i )
834  {
835  G4int j = (i+1) % fNv;
836  if ( IsSameLineSegment(pscaled, fPolygon[i], fPolygon[j]) )
837  {
838  // G4cout << "G4ExtrudedSolid::Inside return Surface (on polygon) "
839  // << G4endl;
840 
841  return kSurface;
842  }
843  }
844 
845  // Now check if inside triangles
846  //
847  std::vector< std::vector<G4int> >::const_iterator it = fTriangles.begin();
848  G4bool inside = false;
849  do // Loop checking, 13.08.2015, G.Cosmo
850  {
851  if ( IsPointInside(fPolygon[(*it)[0]], fPolygon[(*it)[1]],
852  fPolygon[(*it)[2]], pscaled) ) { inside = true; }
853  ++it;
854  } while ( (inside == false) && (it != fTriangles.end()) );
855 
856  if ( inside )
857  {
858  // Check if on surface of z sides
859  //
860  if ( std::fabs( p.z() - fZSections[0].fZ ) < kCarToleranceHalf ||
861  std::fabs( p.z() - fZSections[fNz-1].fZ ) < kCarToleranceHalf )
862  {
863  // G4cout << "G4ExtrudedSolid::Inside return Surface (on z side)"
864  // << G4endl;
865 
866  return kSurface;
867  }
868 
869  // G4cout << "G4ExtrudedSolid::Inside return Inside" << G4endl;
870 
871  return kInside;
872  }
873 
874  // G4cout << "G4ExtrudedSolid::Inside return Outside " << G4endl;
875 
876  return kOutside;
877 }
double x() const
G4double GetMaxXExtent() const
G4double GetMinXExtent() const
G4double GetMaxZExtent() const
int G4int
Definition: G4Types.hh:78
double z() const
G4double GetMinZExtent() const
bool G4bool
Definition: G4Types.hh:79
double y() const
G4double GetMaxYExtent() const
G4double GetMinYExtent() const

Here is the call graph for this function:

G4ExtrudedSolid & G4ExtrudedSolid::operator= ( const G4ExtrudedSolid rhs)

Definition at line 297 of file G4ExtrudedSolid.cc.

298 {
299  // Check assignment to self
300  //
301  if (this == &rhs) { return *this; }
302 
303  // Copy base class data
304  //
306 
307  // Copy data
308  //
309  fNv = rhs.fNv; fNz = rhs.fNz;
310  fPolygon = rhs.fPolygon; fZSections = rhs.fZSections;
311  fTriangles = rhs.fTriangles; fIsConvex = rhs.fIsConvex;
312  fGeometryType = rhs.fGeometryType; fKScales = rhs.fKScales;
313  fScale0s = rhs.fScale0s; fKOffsets = rhs.fKOffsets;
314  fOffset0s = rhs.fOffset0s;
315 
316  return *this;
317 }
G4TessellatedSolid & operator=(const G4TessellatedSolid &right)

Here is the call graph for this function:

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

Reimplemented from G4TessellatedSolid.

Definition at line 1059 of file G4ExtrudedSolid.cc.

1060 {
1061  G4int oldprc = os.precision(16);
1062  os << "-----------------------------------------------------------\n"
1063  << " *** Dump for solid - " << GetName() << " ***\n"
1064  << " ===================================================\n"
1065  << " Solid geometry type: " << fGeometryType << G4endl;
1066 
1067  if ( fIsConvex)
1068  { os << " Convex polygon; list of vertices:" << G4endl; }
1069  else
1070  { os << " Concave polygon; list of vertices:" << G4endl; }
1071 
1072  for ( G4int i=0; i<fNv; ++i )
1073  {
1074  os << std::setw(5) << "#" << i
1075  << " vx = " << fPolygon[i].x()/mm << " mm"
1076  << " vy = " << fPolygon[i].y()/mm << " mm" << G4endl;
1077  }
1078 
1079  os << " Sections:" << G4endl;
1080  for ( G4int iz=0; iz<fNz; ++iz )
1081  {
1082  os << " z = " << fZSections[iz].fZ/mm << " mm "
1083  << " x0= " << fZSections[iz].fOffset.x()/mm << " mm "
1084  << " y0= " << fZSections[iz].fOffset.y()/mm << " mm "
1085  << " scale= " << fZSections[iz].fScale << G4endl;
1086  }
1087 
1088 /*
1089  // Triangles (for debugging)
1090  os << G4endl;
1091  os << " Triangles:" << G4endl;
1092  os << " Triangle # vertex1 vertex2 vertex3" << G4endl;
1093 
1094  G4int counter = 0;
1095  std::vector< std::vector<G4int> >::const_iterator it;
1096  for ( it = fTriangles.begin(); it != fTriangles.end(); it++ ) {
1097  std::vector<G4int> triangle = *it;
1098  os << std::setw(10) << counter++
1099  << std::setw(10) << triangle[0] << std::setw(10) << triangle[1]
1100  << std::setw(10) << triangle[2]
1101  << G4endl;
1102  }
1103 */
1104  os.precision(oldprc);
1105 
1106  return os;
1107 }
G4String GetName() const
static constexpr double mm
Definition: G4SIunits.hh:115
int G4int
Definition: G4Types.hh:78
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:


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