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. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // $Id: G4Line.cc,v 1.10 2006/06/29 18:42:22 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
29 | // |
---|
30 | // ---------------------------------------------------------------------- |
---|
31 | // GEANT 4 class source file |
---|
32 | // |
---|
33 | // G4Line.cc |
---|
34 | // |
---|
35 | // ---------------------------------------------------------------------- |
---|
36 | |
---|
37 | #include "G4Line.hh" |
---|
38 | |
---|
39 | G4Line::G4Line (){} |
---|
40 | G4Line::~G4Line (){} |
---|
41 | |
---|
42 | G4Line::G4Line(const G4Line& right) |
---|
43 | : G4Curve(), pnt(right.pnt), dir(right.dir), |
---|
44 | invDir(right.invDir), v(right.v) |
---|
45 | { |
---|
46 | bBox = right.bBox; |
---|
47 | start = right.start; |
---|
48 | end = right.end; |
---|
49 | pStart = right.pStart; |
---|
50 | pEnd = right.pEnd; |
---|
51 | pRange = right.pRange; |
---|
52 | bounded = right.bounded; |
---|
53 | sameSense = right.sameSense; |
---|
54 | } |
---|
55 | |
---|
56 | G4Line& G4Line::operator=(const G4Line& right) |
---|
57 | { |
---|
58 | if (&right == this) return *this; |
---|
59 | |
---|
60 | pnt = right.pnt; |
---|
61 | dir = right.dir; |
---|
62 | invDir = right.invDir; |
---|
63 | v = right.v; |
---|
64 | bBox = right.bBox; |
---|
65 | start = right.start; |
---|
66 | end = right.end; |
---|
67 | pStart = right.pStart; |
---|
68 | pEnd = right.pEnd; |
---|
69 | pRange = right.pRange; |
---|
70 | bounded = right.bounded; |
---|
71 | sameSense = right.sameSense; |
---|
72 | |
---|
73 | return *this; |
---|
74 | } |
---|
75 | |
---|
76 | G4Curve* G4Line::Project(const G4Transform3D& tr) |
---|
77 | { |
---|
78 | G4Vector3D newDir= tr*dir; |
---|
79 | |
---|
80 | if (std::abs(newDir.x())+std::abs(newDir.y()) < kCarTolerance){ |
---|
81 | |
---|
82 | newDir.setX(kCarTolerance); |
---|
83 | newDir.setY(kCarTolerance); |
---|
84 | }; |
---|
85 | |
---|
86 | G4Point3D newPnt= tr*pnt; |
---|
87 | newDir.setZ(0); |
---|
88 | newPnt.setZ(0); |
---|
89 | |
---|
90 | G4Line* r= new G4Line(); |
---|
91 | |
---|
92 | // L. Broglia : terrible mistake !!!! |
---|
93 | //r->Init(newDir, newPnt); |
---|
94 | r->Init(newPnt, newDir); |
---|
95 | |
---|
96 | r->SetBounds(GetPStart(), GetPEnd()); |
---|
97 | |
---|
98 | return r; |
---|
99 | } |
---|
100 | |
---|
101 | //////////////////////////////////////////////////////////////////////////// |
---|
102 | |
---|
103 | G4bool G4Line::Tangent(G4CurvePoint&, G4Vector3D& vec) |
---|
104 | { |
---|
105 | if(GetSameSense()) |
---|
106 | vec = -dir; |
---|
107 | else |
---|
108 | vec = dir; |
---|
109 | |
---|
110 | return true; |
---|
111 | } |
---|