Geant4_10
G4VFacet.cc
Go to the documentation of this file.
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 //
28 // $Id: G4VFacet.cc 66356 2012-12-18 09:02:32Z gcosmo $
29 //
30 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 //
32 // CHANGE HISTORY
33 // --------------
34 //
35 // 31 October 2004, P R Truscott, QinetiQ Ltd, UK - Created.
36 // 12 October 2012, M Gayer, CERN, - Reviewed optimized implementation.
37 //
38 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 
40 #include "G4VFacet.hh"
41 #include "globals.hh"
42 #include "geomdefs.hh"
43 #include "G4GeometryTolerance.hh"
44 
45 using namespace std;
46 
47 const G4double G4VFacet::dirTolerance = 1.0E-14;
50 
52 //
54 {
55 }
56 
58 //
60 {
61  G4double tolerance = kCarTolerance*kCarTolerance/4.0;
62 
63  if (GetNumberOfVertices() != right.GetNumberOfVertices())
64  return false;
65  else if ((GetCircumcentre()-right.GetCircumcentre()).mag2() > tolerance)
66  return false;
67  else if (std::fabs((right.GetSurfaceNormal()).dot(GetSurfaceNormal())) < 0.9999999999)
68  return false;
69 
70  G4bool coincident = true;
71  G4int i = 0;
72  do
73  {
74  coincident = false;
75  G4int j = 0;
76  do
77  {
78  coincident = (GetVertex(i)-right.GetVertex(j)).mag2() < tolerance;
79  } while (!coincident && ++j < GetNumberOfVertices());
80  } while (coincident && ++i < GetNumberOfVertices());
81 
82  return coincident;
83 }
84 
86 //
88 {
89  G4int n = GetNumberOfVertices();
90  for (G4int i = 0; i < n; ++i)
91  {
92  SetVertex(i, GetVertex(i) + v);
93  }
94 }
95 
97 //
98 std::ostream &G4VFacet::StreamInfo(std::ostream &os) const
99 {
100  os << G4endl;
101  os << "*********************************************************************"
102  << G4endl;
103  os << "FACET TYPE = " << GetEntityType() << G4endl;
104  os << "ABSOLUTE VECTORS = " << G4endl;
105  G4int n = GetNumberOfVertices();
106  for (G4int i = 0; i < n; ++i)
107  os << "P[" << i << "] = " << GetVertex(i) << G4endl;
108  os << "*********************************************************************"
109  << G4endl;
110 
111  return os;
112 }
113 
115 {
116  G4ThreeVector d = p - GetVertex(0);
117  G4double displacement = d.dot(GetSurfaceNormal());
118  return displacement <= 0.0;
119 }
Float_t d
Definition: plot.C:237
static const G4double kCarTolerance
Definition: G4VFacet.hh:102
double dot(const Hep3Vector &) const
const char * p
Definition: xmltok.h:285
G4double GetSurfaceTolerance() const
virtual G4int GetNumberOfVertices() const =0
virtual G4ThreeVector GetCircumcentre() const =0
G4bool operator==(const G4VFacet &right) const
Definition: G4VFacet.cc:59
int G4int
Definition: G4Types.hh:78
virtual G4ThreeVector GetSurfaceNormal() const =0
Char_t n[5]
static const G4double dirTolerance
Definition: G4VFacet.hh:101
bool G4bool
Definition: G4Types.hh:79
virtual ~G4VFacet()
Definition: G4VFacet.cc:53
tuple v
Definition: test.py:18
G4bool IsInside(const G4ThreeVector &p) const
Definition: G4VFacet.cc:114
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4VFacet.cc:98
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
virtual G4ThreeVector GetVertex(G4int i) const =0
void ApplyTranslation(const G4ThreeVector v)
Definition: G4VFacet.cc:87
static G4GeometryTolerance * GetInstance()