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

#include <G4ExtrudedSolid.hh>

+ Inheritance diagram for G4ExtrudedSolid:

Classes

struct  ZSection
 

Public Member Functions

 G4ExtrudedSolid (const G4String &pName, std::vector< G4TwoVector > polygon, std::vector< ZSection > zsections)
 
 G4ExtrudedSolid (const G4String &pName, std::vector< G4TwoVector > polygon, G4double halfZ, G4TwoVector off1, G4double scale1, 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
 
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 EInside Inside (const G4ThreeVector &p) const
 
virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
virtual G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
virtual G4double DistanceToIn (const G4ThreeVector &p) const
 
virtual G4double DistanceToOut (const G4ThreeVector &p) const
 
virtual G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm, G4bool *validNorm, G4ThreeVector *norm) const
 
virtual G4bool Normal (const G4ThreeVector &p, G4ThreeVector &n) const
 
virtual G4double SafetyFromOutside (const G4ThreeVector &p, G4bool aAccurate=false) const
 
virtual G4double SafetyFromInside (const G4ThreeVector &p, G4bool aAccurate=false) const
 
virtual G4GeometryType GetEntityType () const
 
virtual std::ostream & StreamInfo (std::ostream &os) const
 
virtual G4VSolidClone () const
 
virtual G4ThreeVector GetPointOnSurface () const
 
virtual G4double GetSurfaceArea ()
 
virtual G4double GetCubicVolume ()
 
void SetSolidClosed (const G4bool t)
 
G4bool GetSolidClosed () const
 
void SetMaxVoxels (G4int max)
 
G4SurfaceVoxelizerGetVoxels ()
 
virtual G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
 
G4double GetMinXExtent () const
 
G4double GetMaxXExtent () const
 
G4double GetMinYExtent () const
 
G4double GetMaxYExtent () const
 
G4double GetMinZExtent () const
 
G4double GetMaxZExtent () const
 
G4ThreeVectorListCreateRotatedVertices (const G4AffineTransform &pT) const
 
virtual G4PolyhedronCreatePolyhedron () const
 
virtual G4PolyhedronGetPolyhedron () const
 
virtual G4NURBSCreateNURBS () const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
virtual G4VisExtent GetExtent () const
 
G4int AllocatedMemoryWithoutVoxels ()
 
G4int AllocatedMemory ()
 
void DisplayAllocatedMemory ()
 
- Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
 
virtual ~G4VSolid ()
 
G4bool operator== (const G4VSolid &s) const
 
G4String GetName () const
 
void SetName (const G4String &name)
 
G4double GetTolerance () const
 
virtual G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
 
virtual EInside Inside (const G4ThreeVector &p) const =0
 
virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p) const =0
 
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
virtual G4double GetCubicVolume ()
 
virtual G4double GetSurfaceArea ()
 
virtual G4GeometryType GetEntityType () const =0
 
virtual G4ThreeVector GetPointOnSurface () const
 
virtual G4VSolidClone () const
 
virtual std::ostream & StreamInfo (std::ostream &os) const =0
 
void DumpInfo () const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const =0
 
virtual G4VisExtent GetExtent () const
 
virtual G4PolyhedronCreatePolyhedron () const
 
virtual G4NURBSCreateNURBS () const
 
virtual G4PolyhedronGetPolyhedron () const
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 

Additional Inherited Members

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

Detailed Description

Definition at line 73 of file G4ExtrudedSolid.hh.

Constructor & Destructor Documentation

◆ G4ExtrudedSolid() [1/4]

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

Definition at line 52 of file G4ExtrudedSolid.cc.

55 : G4TessellatedSolid(pName),
56 fNv(polygon.size()),
57 fNz(zsections.size()),
58 fPolygon(),
59 fZSections(),
60 fTriangles(),
61 fIsConvex(false),
62 fGeometryType("G4ExtrudedSolid")
63
64{
65 // General constructor
66
67 // First check input parameters
68
69 if ( fNv < 3 )
70 {
71 std::ostringstream message;
72 message << "Number of polygon vertices < 3 - " << pName;
73 G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
74 FatalErrorInArgument, message);
75 }
76
77 if ( fNz < 2 )
78 {
79 std::ostringstream message;
80 message << "Number of z-sides < 2 - " << pName;
81 G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
82 FatalErrorInArgument, message);
83 }
84
85 for ( G4int i=0; i<fNz-1; ++i )
86 {
87 if ( zsections[i].fZ > zsections[i+1].fZ )
88 {
89 std::ostringstream message;
90 message << "Z-sections have to be ordered by z value (z0 < z1 < z2...) - "
91 << pName;
92 G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
93 FatalErrorInArgument, message);
94 }
95 if ( std::fabs( zsections[i+1].fZ - zsections[i].fZ ) < kCarTolerance * 0.5 )
96 {
97 std::ostringstream message;
98 message << "Z-sections with the same z position are not supported - "
99 << pName;
100 G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0001",
101 FatalException, message);
102 }
103 }
104
105 // Check if polygon vertices are defined clockwise
106 // (the area is positive if polygon vertices are defined anti-clockwise)
107 //
108 G4double area = 0.;
109 for ( G4int i=0; i<fNv; ++i ) {
110 G4int j = i+1;
111 if ( j == fNv ) j = 0;
112 area += 0.5 * ( polygon[i].x()*polygon[j].y() - polygon[j].x()*polygon[i].y());
113 }
114
115 // Copy polygon
116 //
117 if ( area < 0. ) {
118 // Polygon vertices are defined clockwise, we just copy the polygon
119 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); }
120 }
121 else {
122 // Polygon vertices are defined anti-clockwise, we revert them
123 //G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
124 // JustWarning,
125 // "Polygon vertices defined anti-clockwise, reverting polygon");
126 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[fNv-i-1]); }
127 }
128
129
130 // Copy z-sections
131 //
132 for ( G4int i=0; i<fNz; ++i ) { fZSections.push_back(zsections[i]); }
133
134
135 G4bool result = MakeFacets();
136 if (!result)
137 {
138 std::ostringstream message;
139 message << "Making facets failed - " << pName;
140 G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0003",
141 FatalException, message);
142 }
143 fIsConvex = IsConvex();
144
145
146 ComputeProjectionParameters();
147}
@ FatalException
@ FatalErrorInArgument
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4double kCarTolerance
Definition: G4VSolid.hh:307
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ G4ExtrudedSolid() [2/4]

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

Definition at line 151 of file G4ExtrudedSolid.cc.

156 : G4TessellatedSolid(pName),
157 fNv(polygon.size()),
158 fNz(2),
159 fPolygon(),
160 fZSections(),
161 fTriangles(),
162 fIsConvex(false),
163 fGeometryType("G4ExtrudedSolid")
164
165{
166 // Special constructor for solid with 2 z-sections
167
168 // First check input parameters
169 //
170 if ( fNv < 3 )
171 {
172 std::ostringstream message;
173 message << "Number of polygon vertices < 3 - " << pName;
174 G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
175 FatalErrorInArgument, message);
176 }
177
178 // Check if polygon vertices are defined clockwise
179 // (the area is positive if polygon vertices are defined anti-clockwise)
180
181 G4double area = 0.;
182 for ( G4int i=0; i<fNv; ++i )
183 {
184 G4int j = i+1;
185 if ( j == fNv ) { j = 0; }
186 area += 0.5 * ( polygon[i].x()*polygon[j].y()
187 - polygon[j].x()*polygon[i].y());
188 }
189
190 // Copy polygon
191 //
192 if ( area < 0. )
193 {
194 // Polygon vertices are defined clockwise, we just copy the polygon
195 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); }
196 }
197 else
198 {
199 // Polygon vertices are defined anti-clockwise, we revert them
200 //G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
201 // JustWarning,
202 // "Polygon vertices defined anti-clockwise, reverting polygon");
203 for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[fNv-i-1]); }
204 }
205
206 // Copy z-sections
207 //
208 fZSections.push_back(ZSection(-dz, off1, scale1));
209 fZSections.push_back(ZSection( dz, off2, scale2));
210
211 G4bool result = MakeFacets();
212 if (!result)
213 {
214 std::ostringstream message;
215 message << "Making facets failed - " << pName;
216 G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0003",
217 FatalException, message);
218 }
219 fIsConvex = IsConvex();
220
221 ComputeProjectionParameters();
222}

◆ ~G4ExtrudedSolid()

G4ExtrudedSolid::~G4ExtrudedSolid ( )
virtual

Definition at line 272 of file G4ExtrudedSolid.cc.

273{
274 // Destructor
275}

◆ G4ExtrudedSolid() [3/4]

G4ExtrudedSolid::G4ExtrudedSolid ( __void__ &  a)

Definition at line 226 of file G4ExtrudedSolid.cc.

227 : G4TessellatedSolid(a), fNv(0), fNz(0), fPolygon(), fZSections(),
228 fTriangles(), fIsConvex(false), fGeometryType("G4ExtrudedSolid")
229{
230 // Fake default constructor - sets only member data and allocates memory
231 // for usage restricted to object persistency.
232}

◆ G4ExtrudedSolid() [4/4]

G4ExtrudedSolid::G4ExtrudedSolid ( const G4ExtrudedSolid rhs)

Definition at line 236 of file G4ExtrudedSolid.cc.

237 : G4TessellatedSolid(rhs), fNv(rhs.fNv), fNz(rhs.fNz),
238 fPolygon(rhs.fPolygon), fZSections(rhs.fZSections),
239 fTriangles(rhs.fTriangles), fIsConvex(rhs.fIsConvex),
240 fGeometryType(rhs.fGeometryType), fKScales(rhs.fKScales),
241 fScale0s(rhs.fScale0s), fKOffsets(rhs.fKOffsets), fOffset0s(rhs.fOffset0s)
242{
243}

Member Function Documentation

◆ Clone()

G4VSolid * G4ExtrudedSolid::Clone ( ) const
virtual

Reimplemented from G4TessellatedSolid.

Definition at line 740 of file G4ExtrudedSolid.cc.

741{
742 return new G4ExtrudedSolid(*this);
743}

◆ DistanceToOut() [1/2]

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

Reimplemented from G4TessellatedSolid.

Definition at line 839 of file G4ExtrudedSolid.cc.

840{
841 // Override the overloaded base class function
842
844}
virtual G4double DistanceToOut(const G4ThreeVector &p) const

◆ DistanceToOut() [2/2]

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 820 of file G4ExtrudedSolid.cc.

825{
826 // Override the base class function to redefine validNorm
827 // (the solid can be concave)
828
829 G4double distOut =
830 G4TessellatedSolid::DistanceToOut(p, v, calcNorm, validNorm, n);
831 if (validNorm) { *validNorm = fIsConvex; }
832
833 return distOut;
834}

◆ GetEntityType()

G4GeometryType G4ExtrudedSolid::GetEntityType ( ) const
virtual

Reimplemented from G4TessellatedSolid.

Definition at line 731 of file G4ExtrudedSolid.cc.

732{
733 // Return entity type
734
735 return fGeometryType;
736}

◆ GetNofVertices()

G4int G4ExtrudedSolid::GetNofVertices ( ) const
inline

◆ GetNofZSections()

G4int G4ExtrudedSolid::GetNofZSections ( ) const
inline

◆ GetPolygon()

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

◆ GetVertex()

G4TwoVector G4ExtrudedSolid::GetVertex ( G4int  index) const
inline

◆ GetZSection()

ZSection G4ExtrudedSolid::GetZSection ( G4int  index) const
inline

◆ GetZSections()

std::vector< ZSection > G4ExtrudedSolid::GetZSections ( ) const
inline

◆ Inside()

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

Reimplemented from G4TessellatedSolid.

Definition at line 747 of file G4ExtrudedSolid.cc.

748{
749 // Override the base class function as it fails in case of concave polygon.
750 // Project the point in the original polygon scale and check if it is inside
751 // for each triangle.
752
753 // Check first if outside extent
754 //
755 if ( p.x() < GetMinXExtent() - kCarTolerance * 0.5 ||
756 p.x() > GetMaxXExtent() + kCarTolerance * 0.5 ||
757 p.y() < GetMinYExtent() - kCarTolerance * 0.5 ||
758 p.y() > GetMaxYExtent() + kCarTolerance * 0.5 ||
759 p.z() < GetMinZExtent() - kCarTolerance * 0.5 ||
760 p.z() > GetMaxZExtent() + kCarTolerance * 0.5 )
761 {
762 // G4cout << "G4ExtrudedSolid::Outside extent: " << p << G4endl;
763 return kOutside;
764 }
765
766 // Project point p(z) to the polygon scale p0
767 //
768 G4TwoVector pscaled = ProjectPoint(p);
769
770 // Check if on surface of polygon
771 //
772 for ( G4int i=0; i<fNv; ++i )
773 {
774 G4int j = (i+1) % fNv;
775 if ( IsSameLineSegment(pscaled, fPolygon[i], fPolygon[j]) )
776 {
777 // G4cout << "G4ExtrudedSolid::Inside return Surface (on polygon) "
778 // << G4endl;
779
780 return kSurface;
781 }
782 }
783
784 // Now check if inside triangles
785 //
786 std::vector< std::vector<G4int> >::const_iterator it = fTriangles.begin();
787 G4bool inside = false;
788 do
789 {
790 if ( IsPointInside(fPolygon[(*it)[0]], fPolygon[(*it)[1]],
791 fPolygon[(*it)[2]], pscaled) ) { inside = true; }
792 ++it;
793 } while ( (inside == false) && (it != fTriangles.end()) );
794
795 if ( inside )
796 {
797 // Check if on surface of z sides
798 //
799 if ( std::fabs( p.z() - fZSections[0].fZ ) < kCarTolerance * 0.5 ||
800 std::fabs( p.z() - fZSections[fNz-1].fZ ) < kCarTolerance * 0.5 )
801 {
802 // G4cout << "G4ExtrudedSolid::Inside return Surface (on z side)"
803 // << G4endl;
804
805 return kSurface;
806 }
807
808 // G4cout << "G4ExtrudedSolid::Inside return Inside" << G4endl;
809
810 return kInside;
811 }
812
813 // G4cout << "G4ExtrudedSolid::Inside return Outside " << G4endl;
814
815 return kOutside;
816}
double z() const
double x() const
double y() const
G4double GetMinYExtent() const
G4double GetMinZExtent() const
G4double GetMaxYExtent() const
G4double GetMaxZExtent() const
G4double GetMaxXExtent() const
G4double GetMinXExtent() const
@ kInside
Definition: geomdefs.hh:58
@ kOutside
Definition: geomdefs.hh:58
@ kSurface
Definition: geomdefs.hh:58

◆ operator=()

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

Definition at line 248 of file G4ExtrudedSolid.cc.

249{
250 // Check assignment to self
251 //
252 if (this == &rhs) { return *this; }
253
254 // Copy base class data
255 //
257
258 // Copy data
259 //
260 fNv = rhs.fNv; fNz = rhs.fNz;
261 fPolygon = rhs.fPolygon; fZSections = rhs.fZSections;
262 fTriangles = rhs.fTriangles; fIsConvex = rhs.fIsConvex;
263 fGeometryType = rhs.fGeometryType; fKScales = rhs.fKScales;
264 fScale0s = rhs.fScale0s; fKOffsets = rhs.fKOffsets;
265 fOffset0s = rhs.fOffset0s;
266
267 return *this;
268}
G4TessellatedSolid & operator=(const G4TessellatedSolid &right)

◆ StreamInfo()

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

Reimplemented from G4TessellatedSolid.

Definition at line 848 of file G4ExtrudedSolid.cc.

849{
850 G4int oldprc = os.precision(16);
851 os << "-----------------------------------------------------------\n"
852 << " *** Dump for solid - " << GetName() << " ***\n"
853 << " ===================================================\n"
854 << " Solid geometry type: " << fGeometryType << G4endl;
855
856 if ( fIsConvex)
857 { os << " Convex polygon; list of vertices:" << G4endl; }
858 else
859 { os << " Concave polygon; list of vertices:" << G4endl; }
860
861 for ( G4int i=0; i<fNv; ++i )
862 {
863 os << std::setw(5) << "#" << i
864 << " vx = " << fPolygon[i].x()/mm << " mm"
865 << " vy = " << fPolygon[i].y()/mm << " mm" << G4endl;
866 }
867
868 os << " Sections:" << G4endl;
869 for ( G4int iz=0; iz<fNz; ++iz )
870 {
871 os << " z = " << fZSections[iz].fZ/mm << " mm "
872 << " x0= " << fZSections[iz].fOffset.x()/mm << " mm "
873 << " y0= " << fZSections[iz].fOffset.y()/mm << " mm "
874 << " scale= " << fZSections[iz].fScale << G4endl;
875 }
876
877/*
878 // Triangles (for debugging)
879 os << G4endl;
880 os << " Triangles:" << G4endl;
881 os << " Triangle # vertex1 vertex2 vertex3" << G4endl;
882
883 G4int counter = 0;
884 std::vector< std::vector<G4int> >::const_iterator it;
885 for ( it = fTriangles.begin(); it != fTriangles.end(); it++ ) {
886 std::vector<G4int> triangle = *it;
887 os << std::setw(10) << counter++
888 << std::setw(10) << triangle[0] << std::setw(10) << triangle[1] << std::setw(10) << triangle[2]
889 << G4endl;
890 }
891*/
892 os.precision(oldprc);
893
894 return os;
895}
#define G4endl
Definition: G4ios.hh:52
G4String GetName() const

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