56 fNv(polygon.size()),
57 fNz(zsections.size()),
58 fPolygon(),
59 fZSections(),
60 fTriangles(),
61 fIsConvex(false),
62 fGeometryType("G4ExtrudedSolid")
63
64{
65
66
67
68
69 if ( fNv < 3 )
70 {
71 std::ostringstream message;
72 message << "Number of polygon vertices < 3 - " << pName;
73 G4Exception(
"G4ExtrudedSolid::G4ExtrudedSolid()",
"GeomSolids0002",
75 }
76
77 if ( fNz < 2 )
78 {
79 std::ostringstream message;
80 message << "Number of z-sides < 2 - " << pName;
81 G4Exception(
"G4ExtrudedSolid::G4ExtrudedSolid()",
"GeomSolids0002",
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",
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",
102 }
103 }
104
105
106
107
109 for (
G4int i=0; i<fNv; ++i ) {
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
116
117 if ( area < 0. ) {
118
119 for (
G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); }
120 }
121 else {
122
123
124
125
126 for (
G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[fNv-i-1]); }
127 }
128
129
130
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",
142 }
143 fIsConvex = IsConvex();
144
145
146 ComputeProjectionParameters();
147}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)