Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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// 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"
37
38using namespace std;
39
40const G4double G4VFacet::dirTolerance = 1.0E-14;
41
42///////////////////////////////////////////////////////////////////////////////
43//
45{
47}
48
49///////////////////////////////////////////////////////////////////////////////
50//
52{
53}
54
55///////////////////////////////////////////////////////////////////////////////
56//
58{
59 G4double tolerance = kCarTolerance*kCarTolerance/4.0;
60
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
83///////////////////////////////////////////////////////////////////////////////
84//
86{
88 for (G4int i = 0; i < n; ++i)
89 {
90 SetVertex(i, GetVertex(i) + v);
91 }
92}
93
94///////////////////////////////////////////////////////////////////////////////
95//
96std::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;
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}
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
double dot(const Hep3Vector &) const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
void ApplyTranslation(const G4ThreeVector v)
Definition: G4VFacet.cc:85
virtual G4GeometryType GetEntityType() const =0
G4bool operator==(const G4VFacet &right) const
Definition: G4VFacet.cc:57
virtual G4ThreeVector GetCircumcentre() const =0
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4VFacet.cc:96
static const G4double dirTolerance
Definition: G4VFacet.hh:92
G4bool IsInside(const G4ThreeVector &p) const
Definition: G4VFacet.cc:112
virtual G4ThreeVector GetSurfaceNormal() const =0
virtual G4ThreeVector GetVertex(G4int i) const =0
virtual G4int GetNumberOfVertices() const =0
G4VFacet()
Definition: G4VFacet.cc:44
virtual void SetVertex(G4int i, const G4ThreeVector &val)=0
virtual ~G4VFacet()
Definition: G4VFacet.cc:51
G4double kCarTolerance
Definition: G4VFacet.hh:93