Geant4 9.6.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//
28// $Id$
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"
44
45using namespace std;
46
47const G4double G4VFacet::dirTolerance = 1.0E-14;
50
51///////////////////////////////////////////////////////////////////////////////
52//
54{
55}
56
57///////////////////////////////////////////////////////////////////////////////
58//
60{
61 G4double tolerance = kCarTolerance*kCarTolerance/4.0;
62
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
85///////////////////////////////////////////////////////////////////////////////
86//
88{
90 for (G4int i = 0; i < n; ++i)
91 {
92 SetVertex(i, GetVertex(i) + v);
93 }
94}
95
96///////////////////////////////////////////////////////////////////////////////
97//
98std::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;
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}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
double dot(const Hep3Vector &) const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
void ApplyTranslation(const G4ThreeVector v)
Definition: G4VFacet.cc:87
static const G4double kCarTolerance
Definition: G4VFacet.hh:102
virtual G4GeometryType GetEntityType() const =0
G4bool operator==(const G4VFacet &right) const
Definition: G4VFacet.cc:59
virtual G4ThreeVector GetCircumcentre() const =0
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4VFacet.cc:98
static const G4double dirTolerance
Definition: G4VFacet.hh:101
G4bool IsInside(const G4ThreeVector &p) const
Definition: G4VFacet.cc:114
virtual G4ThreeVector GetSurfaceNormal() const =0
virtual G4ThreeVector GetVertex(G4int i) const =0
virtual G4int GetNumberOfVertices() const =0
virtual void SetVertex(G4int i, const G4ThreeVector &val)=0
virtual ~G4VFacet()
Definition: G4VFacet.cc:53