70 constructorParams.start_angle = start_angle;
71 constructorParams.opening_angle = opening_angle;
72 constructorParams.num_z_planes = num_z_planes;
73 constructorParams.z_start = z_start;
74 constructorParams.z_values = 0;
75 constructorParams.RMIN = 0;
76 constructorParams.RMAX = 0;
78 if( num_z_planes > 0 )
80 constructorParams.z_values =
new G4double[num_z_planes];
81 constructorParams.RMIN =
new G4double[num_z_planes];
82 constructorParams.RMAX =
new G4double[num_z_planes];
83 for(
G4int idx = 0; idx < num_z_planes; ++idx )
85 constructorParams.z_values[idx] = z_values[idx];
86 constructorParams.RMIN[idx] = RMIN[idx];
87 constructorParams.RMAX[idx] = RMAX[idx];
98 constructorParams.start_angle = 0.;
99 constructorParams.opening_angle = 0.;
100 constructorParams.num_z_planes = 0;
101 constructorParams.z_start = 0.;
102 constructorParams.z_values = 0;
103 constructorParams.RMIN = 0;
104 constructorParams.RMAX = 0;
109 if( constructorParams.num_z_planes > 0 )
111 delete [] constructorParams.z_values;
112 delete [] constructorParams.RMIN;
113 delete [] constructorParams.RMAX;
120 constructorParams.start_angle = rhs.constructorParams.start_angle;
121 constructorParams.opening_angle = rhs.constructorParams.opening_angle;
122 constructorParams.num_z_planes = rhs.constructorParams.num_z_planes;
123 constructorParams.z_start = rhs.constructorParams.z_start;
124 constructorParams.z_values = 0;
125 constructorParams.RMIN = 0;
126 constructorParams.RMAX = 0;
127 G4int nplanes = constructorParams.num_z_planes;
130 constructorParams.z_values =
new G4double[nplanes];
131 constructorParams.RMIN =
new G4double[nplanes];
132 constructorParams.RMAX =
new G4double[nplanes];
133 for(
G4int idx = 0; idx < nplanes; ++idx )
135 constructorParams.z_values[idx] = rhs.constructorParams.z_values[idx];
136 constructorParams.RMIN[idx] = rhs.constructorParams.RMIN[idx];
137 constructorParams.RMAX[idx] = rhs.constructorParams.RMAX[idx];
149 if (
this == &rhs) {
return *
this; }
157 constructorParams.start_angle = rhs.constructorParams.start_angle;
158 constructorParams.opening_angle = rhs.constructorParams.opening_angle;
159 constructorParams.num_z_planes = rhs.constructorParams.num_z_planes;
160 constructorParams.z_start = rhs.constructorParams.z_start;
161 G4int nplanes = constructorParams.num_z_planes;
164 delete [] constructorParams.z_values;
165 delete [] constructorParams.RMIN;
166 delete [] constructorParams.RMAX;
167 constructorParams.z_values =
new G4double[nplanes];
168 constructorParams.RMIN =
new G4double[nplanes];
169 constructorParams.RMAX =
new G4double[nplanes];
170 for(
G4int idx = 0; idx < nplanes; ++idx )
172 constructorParams.z_values[idx] = rhs.constructorParams.z_values[idx];
173 constructorParams.RMIN[idx] = rhs.constructorParams.RMIN[idx];
174 constructorParams.RMAX[idx] = rhs.constructorParams.RMAX[idx];
183void G4BREPSolidPCone::InitializePCone()
185 G4double opening_angle = constructorParams.opening_angle;
186 G4int num_z_planes = constructorParams.num_z_planes;
187 G4double z_start = constructorParams.z_start;
188 G4double* z_values = constructorParams.z_values;
189 G4double* RMIN = constructorParams.RMIN;
190 G4double* RMAX = constructorParams.RMAX;
192 G4int sections= constructorParams.num_z_planes-1;
212 if( opening_angle < 2*pi-perMillion )
214 G4Exception(
"G4BREPSolidPCone::G4BREPSolidPCone()",
216 "Sorry, phi-section not supported yet, try to use G4Polycone instead!");
225 if( ((RMIN[0] == 0) && (RMAX[0] == 0)) ||
226 ((RMIN[num_z_planes-1] == 0) && (RMAX[num_z_planes-1] == 0)) )
227 G4Exception(
"G4BREPSolidPCone::G4BREPSolidPCone()",
229 "RMIN at the extremities cannot be 0 when RMAX=0 !");
233 for(a = 1; a < num_z_planes-1; a++)
235 G4Exception(
"G4BREPSolidPCone::G4BREPSolidPCone()",
237 "RMAX inside the solid cannot be 0 !");
241 for(a = 1; a < num_z_planes-1; a++)
242 if (RMIN[a] >= RMAX[a])
243 G4Exception(
"G4BREPSolidPCone::G4BREPSolidPCone()",
245 "RMAX must be greater than RMIN in the middle Z planes !");
247 if( (RMIN[num_z_planes-1] > RMAX[num_z_planes-1] )
248 || (RMIN[0] > RMAX[0]) )
249 G4Exception(
"G4BREPSolidPCone::G4BREPSolidPCone()",
251 "RMAX must be greater or equal than RMIN at the ends !");
255 for( a = 0; a < sections; a++)
259 Length = z_values[a+1] - z_values[a];
265 if( RMAX[a] != RMAX[a+1] && RMIN[a] != RMIN[a+1] )
301 if( RMIN[a] > RMAX[a+1] || RMAX[a] < RMIN[a+1] )
303 std::ostringstream message;
304 message <<
"The values of RMIN[" << a
305 <<
"] & RMAX[" << a+1 <<
"] or RMAX[" << a
306 <<
"] & RMIN[" << a+1 <<
"]" <<
G4endl
307 <<
"generate an invalid configuration for solid: "
309 G4Exception(
"G4BREPSolidPCone::G4BREPSolidPCone()",
318 if( RMAX[a] > RMAX[a+1] )
322 if( RMIN[a] < RMIN[a+1] )
329 else if( RMAX[a+1] != RMIN[a])
348 if( RMIN[a] > RMIN[a+1] )
355 else if( RMIN[a+1] != RMAX[a] )
371 ComputePlanarSurface( RMAX[a], RMAX[a+1], LocalOrigin, PlaneAxis,
372 PlaneDir, UpSurfSense );
377 ComputePlanarSurface( RMIN[a], RMIN[a+1], LocalOrigin, PlaneAxis,
378 PlaneDir, LowSurfSense );
425 if( RMAX[a] != RMAX[a+1] )
444 else if(RMIN[a] != RMIN[a+1])
465 std::ostringstream message;
466 message <<
"Error in construction." <<
G4endl
467 <<
"Exactly the same z, rmin and rmax given for"
468 <<
"consecutive indices, " << a <<
" and " << a+1;
469 G4Exception(
"G4BREPSolidPCone::G4BREPSolidPCone()",
475 ComputePlanarSurface( R1, R2, LocalOrigin, PlaneAxis,
476 PlaneDir, SurfSense );
490 if(RMIN[a] != RMIN[a+1])
494 if(RMIN[a] > RMIN[a+1])
534 if(RMAX[a] != RMAX[a+1])
538 if(RMAX[a] > RMAX[a+1])
579 LocalOrigin = LocalOrigin + (Length*Axis);
588 if(RMIN[0] < RMAX[0])
621 if(RMIN[sections] < RMAX[sections])
630 if( RMIN[sections] > 0.0 )
689 G4Ray r(Pttmp, Vtmp);
708 G4bool isIntersected =
false;
709 G4int WhichSurface = 0;
725 if( std::fabs( hownear ) < sqrHalfTolerance )
732 isIntersected =
true;
735 if ( std::fabs( hownear ) < dist )
744 if ( !isIntersected )
752 dist = std::sqrt( dist );
753 G4Vector3D IntersectionPoint = Pttmp + dist*Vtmp;
777 G4int normSurface = 0;
786 if( dist < sqrHalfTolerance)
808 return hitNorm.
unit();
842 if( std::fabs(Dist) > std::fabs(dists[a]) )
848 if(Dist == kInfinity)
853 return std::fabs(Dist);
875 G4Ray r(Pttmp, Vtmp);
893 if( (Norm * Vtmp) < 0 && std::fabs(hownear) < sqrHalfTolerance )
904 if( distance > sqrHalfTolerance )
955 G4Ray r(Pttmp, Vtmp);
971 if( (Norm * Vtmp) > 0 && std::fabs( hownear ) < sqrHalfTolerance )
985 if( distance > sqrHalfTolerance )
1034 if( std::fabs(Dist) > std::fabs(dists[a]) )
1040 if(Dist == kInfinity)
1045 return std::fabs(Dist);
1058 <<
"\n start_angle: " << constructorParams.start_angle
1059 <<
"\n opening_angle: " << constructorParams.opening_angle
1060 <<
"\n num_z_planes: " << constructorParams.num_z_planes
1061 <<
"\n z_start: " << constructorParams.z_start
1064 for( idx = 0; idx < constructorParams.num_z_planes; idx++ )
1066 os << constructorParams.z_values[idx] <<
" ";
1069 for( idx = 0; idx < constructorParams.num_z_planes; idx++ )
1071 os << constructorParams.RMIN[idx] <<
" ";
1074 for( idx = 0; idx < constructorParams.num_z_planes; idx++ )
1076 os << constructorParams.RMAX[idx] <<
" ";
1078 os <<
"\n-----------------------------------------------------------\n";
1094G4BREPSolidPCone::ComputePlanarSurface(
G4double r1,
1122 cv1.push_back(tmp1);
1136 cv1.push_back(tmp2);
1139 planarFace =
new G4FPlane( planeDirection, planeAxis, origin, surfSense );
1153 constructorParams.opening_angle,
1154 constructorParams.num_z_planes,
1155 constructorParams.z_values,
1156 constructorParams.RMIN,
1157 constructorParams.RMAX );
std::vector< G4Curve * > G4CurveVector
HepGeom::Point3D< G4double > G4Point3D
HepGeom::Vector3D< G4double > G4Vector3D
std::ostream & StreamInfo(std::ostream &os) const
G4BREPSolidPCone(const G4String &name, G4double start_angle, G4double opening_angle, G4int num_z_planes, G4double z_start, G4double z_values[], G4double RMIN[], G4double RMAX[])
G4double DistanceToIn(const G4ThreeVector &) const
EInside Inside(register const G4ThreeVector &Pt) const
G4ThreeVector SurfaceNormal(const G4ThreeVector &) const
G4double DistanceToOut(register const G4ThreeVector &Pt, register const G4ThreeVector &V, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
G4Polyhedron * CreatePolyhedron() const
G4BREPSolidPCone & operator=(const G4BREPSolidPCone &rhs)
G4BREPSolid & operator=(const G4BREPSolid &rhs)
G4int StartInside() const
G4int Intersect(register const G4Ray &) const
virtual std::ostream & StreamInfo(std::ostream &os) const
void CheckSurfaceNormals()
virtual void CalcBBoxes()
const G4BoundingBox3D * GetBBox() const
static G4double ShortestDistance
void TestSurfaceBBoxes(register const G4Ray &) const
const G4String & GetName() const
void Init(const G4Axis2Placement3D &position0, G4double radius0)
void SetSameSense(G4int sameSense0)
void SetBounds(G4double p1, G4double p2)
virtual G4int Intersect(const G4Ray &)
void SetBoundaries(G4CurveVector *)
virtual G4Vector3D SurfaceNormal(const G4Point3D &Pt) const =0
void SetSameSense(G4int sameSense0)
const G4Point3D & GetClosestHit() const
virtual G4double HowNear(const G4Vector3D &x) const
G4double GetDistance() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)