// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // Implementation of inline methods of G4ExtrudedSolid // -------------------------------------------------------------------- inline G4int G4ExtrudedSolid::GetNofVertices() const { return (G4int)fNv; } inline G4TwoVector G4ExtrudedSolid::GetVertex(G4int index) const { if ( index<0 || index >= (G4int)fNv ) { G4Exception ("G4ExtrudedSolid::GetVertex()", "GeomSolids0003", FatalException, "Index outside range."); return {}; } return fPolygon[index]; } inline std::vector G4ExtrudedSolid::GetPolygon() const { return fPolygon; } inline G4int G4ExtrudedSolid::GetNofZSections() const { return (G4int)fNz; } inline G4ExtrudedSolid::ZSection G4ExtrudedSolid::GetZSection(G4int index) const { if ( index<0 || index >= (G4int)fNz ) { G4Exception ("G4ExtrudedSolid::GetZSection()", "GeomSolids0003", FatalException, "Index outside range."); return ZSection(0.0, G4TwoVector(), 0.0); } return fZSections[index]; } inline std::vector G4ExtrudedSolid::GetZSections() const { return fZSections; } inline G4bool G4ExtrudedSolid::PointInPolygon(const G4ThreeVector& p) const { G4bool in = false; G4int icur = static_cast(fPolygon[fNv-1].y() > p.y()), iprev = 0; for (std::size_t i = 0; i < fNv; ++i) { iprev = icur; if ((icur = static_cast(fPolygon[i].y() > p.y())) != iprev) { in ^= static_cast(p.y()*fLines[i].k + fLines[i].m < p.x()); } } return in; } inline G4double G4ExtrudedSolid::DistanceToPolygonSqr(const G4ThreeVector& p) const { G4double dd = DBL_MAX; for (std::size_t i=0, k=fNv-1; i fLengths[i]) { G4double kx = p.x() - fPolygon[k].x(); G4double ky = p.y() - fPolygon[k].y(); G4double tmp = kx*kx + ky*ky; if (tmp < dd) { dd = tmp; } } else { G4double tmp = fPlanes[i].a*p.x() + fPlanes[i].b*p.y() + fPlanes[i].d; tmp *= tmp; if (tmp < dd) { dd = tmp; } } } return dd; }