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,v 1.8 2008/12/18 12:57:38 gunter Exp $ |
---|
29 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
30 | // |
---|
31 | // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
32 | // |
---|
33 | // MODULE: G4VFacet.hh |
---|
34 | // |
---|
35 | // Date: 15/06/2005 |
---|
36 | // Author: P R Truscott |
---|
37 | // Organisation: QinetiQ Ltd, UK |
---|
38 | // Customer: UK Ministry of Defence : RAO CRP TD Electronic Systems |
---|
39 | // Contract: C/MAT/N03517 |
---|
40 | // |
---|
41 | // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
42 | // |
---|
43 | // CHANGE HISTORY |
---|
44 | // -------------- |
---|
45 | // |
---|
46 | // 31 October 2004, P R Truscott, QinetiQ Ltd, UK - Created. |
---|
47 | // |
---|
48 | // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
49 | |
---|
50 | #include "G4VFacet.hh" |
---|
51 | #include "globals.hh" |
---|
52 | #include "G4GeometryTolerance.hh" |
---|
53 | |
---|
54 | /////////////////////////////////////////////////////////////////////////////// |
---|
55 | // |
---|
56 | G4VFacet::G4VFacet () |
---|
57 | { |
---|
58 | dirTolerance = 1.0E-14; |
---|
59 | kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance(); |
---|
60 | |
---|
61 | P.clear(); |
---|
62 | E.clear(); |
---|
63 | |
---|
64 | circumcentre = G4ThreeVector(0.0,0.0,0.0); |
---|
65 | radius = 0.0; |
---|
66 | radiusSqr = 0.0; |
---|
67 | area = 0.0; |
---|
68 | } |
---|
69 | |
---|
70 | /////////////////////////////////////////////////////////////////////////////// |
---|
71 | // |
---|
72 | G4VFacet::~G4VFacet () |
---|
73 | { |
---|
74 | P.clear(); |
---|
75 | E.clear(); |
---|
76 | } |
---|
77 | |
---|
78 | /////////////////////////////////////////////////////////////////////////////// |
---|
79 | // |
---|
80 | G4bool G4VFacet::operator== (const G4VFacet &right) const |
---|
81 | { |
---|
82 | G4double tolerance = kCarTolerance*kCarTolerance/4.0; |
---|
83 | if (nVertices != right.GetNumberOfVertices()) |
---|
84 | { return false; } |
---|
85 | else if ((circumcentre-right.GetCircumcentre()).mag2() > tolerance) |
---|
86 | { return false; } |
---|
87 | else if (std::fabs((right.GetSurfaceNormal()).dot(surfaceNormal)) < 0.9999999999) |
---|
88 | { return false; } |
---|
89 | |
---|
90 | G4bool coincident = true; |
---|
91 | size_t i = 0; |
---|
92 | do |
---|
93 | { |
---|
94 | coincident = false; |
---|
95 | size_t j = 0; |
---|
96 | do |
---|
97 | { |
---|
98 | coincident = (GetVertex(i)-right.GetVertex(j)).mag2() < tolerance; |
---|
99 | } while (!coincident && ++j < nVertices); |
---|
100 | } while (coincident && ++i < nVertices); |
---|
101 | |
---|
102 | return coincident; |
---|
103 | } |
---|
104 | |
---|
105 | /////////////////////////////////////////////////////////////////////////////// |
---|
106 | // |
---|
107 | void G4VFacet::ApplyTranslation(const G4ThreeVector v) |
---|
108 | { |
---|
109 | P0 += v; |
---|
110 | for (G4ThreeVectorList::iterator it=P.begin(); it!=P.end(); it++) |
---|
111 | { |
---|
112 | (*it) += v; |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | /////////////////////////////////////////////////////////////////////////////// |
---|
117 | // |
---|
118 | std::ostream &G4VFacet::StreamInfo(std::ostream &os) const |
---|
119 | { |
---|
120 | os << G4endl; |
---|
121 | os << "*********************************************************************" |
---|
122 | << G4endl; |
---|
123 | os << "FACET TYPE = " << geometryType << G4endl; |
---|
124 | os << "ABSOLUTE VECTORS = " << G4endl; |
---|
125 | os << "P0 = " << P0 << G4endl; |
---|
126 | for (G4ThreeVectorList::const_iterator it=P.begin(); it!=P.end(); it++) |
---|
127 | { os << "P[" << it-P.begin()+1 << "] = " << *it << G4endl; } |
---|
128 | |
---|
129 | os << "RELATIVE VECTORS = " << G4endl; |
---|
130 | for (G4ThreeVectorList::const_iterator it=E.begin(); it!=E.end(); it++) |
---|
131 | { os << "E[" << it-E.begin()+1 << "] = " << *it << G4endl; } |
---|
132 | |
---|
133 | os << "*********************************************************************" |
---|
134 | << G4endl; |
---|
135 | |
---|
136 | return os; |
---|
137 | } |
---|
138 | |
---|
139 | /////////////////////////////////////////////////////////////////////////////// |
---|
140 | // |
---|
141 | G4VFacet* G4VFacet::GetClone () |
---|
142 | {return 0;} |
---|
143 | |
---|
144 | /////////////////////////////////////////////////////////////////////////////// |
---|
145 | // |
---|
146 | G4double G4VFacet::Distance (const G4ThreeVector&, const G4double) |
---|
147 | {return kInfinity;} |
---|
148 | |
---|
149 | /////////////////////////////////////////////////////////////////////////////// |
---|
150 | // |
---|
151 | G4double G4VFacet::Distance (const G4ThreeVector&, const G4double, |
---|
152 | const G4bool) |
---|
153 | {return kInfinity;} |
---|
154 | |
---|
155 | /////////////////////////////////////////////////////////////////////////////// |
---|
156 | // |
---|
157 | G4double G4VFacet::Extent (const G4ThreeVector) |
---|
158 | {return 0.0;} |
---|
159 | |
---|
160 | /////////////////////////////////////////////////////////////////////////////// |
---|
161 | // |
---|
162 | G4bool G4VFacet::Intersect (const G4ThreeVector&, const G4ThreeVector &, |
---|
163 | const G4bool , G4double &, G4double &, |
---|
164 | G4ThreeVector &) |
---|
165 | {return false;} |
---|