ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VFacet.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VFacet.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
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. *
10 // * *
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. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration and of QinetiQ Ltd, *
20 // * subject to DEFCON 705 IPR conditions. *
21 // * By using, copying, modifying or distributing the software (or *
22 // * any work based on the software) you agree to acknowledge its *
23 // * use in resulting scientific publications, and indicate your *
24 // * acceptance of all terms of the Geant4 Software license. *
25 // ********************************************************************
26 //
27 // G4VFacet implementation.
28 //
29 // 31 October 2004, P R Truscott, QinetiQ Ltd, UK - Created.
30 // 12 October 2012, M Gayer, CERN, - Reviewed optimized implementation.
31 // --------------------------------------------------------------------
32 
33 #include "G4VFacet.hh"
34 #include "globals.hh"
35 #include "geomdefs.hh"
36 #include "G4GeometryTolerance.hh"
37 
38 using namespace std;
39 
40 const G4double G4VFacet::dirTolerance = 1.0E-14;
41 
43 //
45 {
47 }
48 
50 //
52 {
53 }
54 
56 //
58 {
59  G4double tolerance = kCarTolerance*kCarTolerance/4.0;
60 
61  if (GetNumberOfVertices() != right.GetNumberOfVertices())
62  return false;
63  else if ((GetCircumcentre()-right.GetCircumcentre()).mag2() > tolerance)
64  return false;
65  else if (std::fabs((right.GetSurfaceNormal()).dot(GetSurfaceNormal())) < 0.9999999999)
66  return false;
67 
68  G4bool coincident = true;
69  G4int i = 0;
70  do // Loop checking, 13.08.2015, G.Cosmo
71  {
72  coincident = false;
73  G4int j = 0;
74  do // Loop checking, 13.08.2015, G.Cosmo
75  {
76  coincident = (GetVertex(i)-right.GetVertex(j)).mag2() < tolerance;
77  } while (!coincident && ++j < GetNumberOfVertices());
78  } while (coincident && ++i < GetNumberOfVertices());
79 
80  return coincident;
81 }
82 
84 //
86 {
87  G4int n = GetNumberOfVertices();
88  for (G4int i = 0; i < n; ++i)
89  {
90  SetVertex(i, GetVertex(i) + v);
91  }
92 }
93 
95 //
96 std::ostream& G4VFacet::StreamInfo(std::ostream& os) const
97 {
98  os << G4endl;
99  os << "*********************************************************************"
100  << G4endl;
101  os << "FACET TYPE = " << GetEntityType() << G4endl;
102  os << "ABSOLUTE VECTORS = " << G4endl;
103  G4int n = GetNumberOfVertices();
104  for (G4int i = 0; i < n; ++i)
105  os << "P[" << i << "] = " << GetVertex(i) << G4endl;
106  os << "*********************************************************************"
107  << G4endl;
108 
109  return os;
110 }
111 
113 {
114  G4ThreeVector d = p-GetVertex(0);
115  G4double displacement = d.dot(GetSurfaceNormal());
116  return displacement <= 0.0;
117 }