2// ********************************************************************
3// * License and Disclaimer *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
26// Implementation of inline methods of G4ExtrudedSolid
27// --------------------------------------------------------------------
30G4int G4ExtrudedSolid::GetNofVertices() const
35inline G4TwoVector G4ExtrudedSolid::GetVertex(G4int index) const
37 if ( index<0 || index >= fNv )
39 G4Exception ("G4ExtrudedSolid::GetVertex()", "GeomSolids0003",
40 FatalException, "Index outside range.");
43 return fPolygon[index];
47std::vector<G4TwoVector> G4ExtrudedSolid::GetPolygon() const
53G4int G4ExtrudedSolid::GetNofZSections() const
59G4ExtrudedSolid::ZSection G4ExtrudedSolid::GetZSection(G4int index) const
61 if ( index<0 || index >= fNz )
63 G4Exception ("G4ExtrudedSolid::GetZSection()", "GeomSolids0003",
64 FatalException, "Index outside range.");
65 return ZSection(0.0, G4TwoVector(), 0.0);
67 return fZSections[index];
71std::vector<G4ExtrudedSolid::ZSection> G4ExtrudedSolid::GetZSections() const
77G4bool G4ExtrudedSolid::PointInPolygon(const G4ThreeVector& p) const
80 G4int icur = (fPolygon[fNv-1].y() > p.y()), iprev = 0;
81 for (G4int i = 0; i < fNv; ++i)
84 if ((icur = (fPolygon[i].y() > p.y())) != iprev)
86 in ^= (p.y()*fLines[i].k + fLines[i].m < p.x());
93G4double G4ExtrudedSolid::DistanceToPolygonSqr(const G4ThreeVector& p) const
95 G4double dd = DBL_MAX;
96 for (G4int i=0, k=fNv-1; i<fNv; k=i++)
98 G4double ix = p.x() - fPolygon[i].x();
99 G4double iy = p.y() - fPolygon[i].y();
100 G4double u = fPlanes[i].a*iy - fPlanes[i].b*ix;
103 G4double tmp = ix*ix + iy*iy;
104 if (tmp < dd) dd = tmp;
106 else if (u > fLengths[i])
108 G4double kx = p.x() - fPolygon[k].x();
109 G4double ky = p.y() - fPolygon[k].y();
110 G4double tmp = kx*kx + ky*ky;
111 if (tmp < dd) dd = tmp;
115 G4double tmp = fPlanes[i].a*p.x() + fPlanes[i].b*p.y() + fPlanes[i].d;
117 if (tmp < dd) dd = tmp;