source: trunk/source/geometry/solids/BREPS/src/G4SurfaceBoundary.cc@ 1350

Last change on this file since 1350 was 1337, checked in by garnier, 15 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 5.9 KB
RevLine 
[831]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: G4SurfaceBoundary.cc,v 1.14 2006/06/29 18:42:46 gunter Exp $
[1337]28// GEANT4 tag $Name: geant4-09-04-beta-01 $
[831]29//
30// ----------------------------------------------------------------------
31// GEANT 4 class source file
32//
33// G4SurfaceBoundary.cc
34//
35// ----------------------------------------------------------------------
36
37#include "G4SurfaceBoundary.hh"
38#include "geomdefs.hh"
39#include "G4CompositeCurve.hh"
40
41
42G4SurfaceBoundary::G4SurfaceBoundary()
43{
44}
45
46G4SurfaceBoundary::~G4SurfaceBoundary()
47{
48}
49
50void G4SurfaceBoundary::Init(const G4CurveVector& bounds0)
51{
52 bounds= bounds0;
53 lastIntersection.Reset();
54
55 const G4BoundingBox3D* b= bounds[0]->BBox();
56 bBox.Init(b->GetBoxMin(), b->GetBoxMax());
57
58 size_t i;
59 for ( i=1; i<bounds.size(); i++)
60 {
61 b= bounds[i]->BBox();
62 bBox.Extend(b->GetBoxMin());
63 bBox.Extend(b->GetBoxMax());
64 }
65
66 // the points array is probably unused, so the following code is useless
67 G4int cnt= 0;
68
69 size_t entr = bounds.size();
70
71 for (i=0; i < entr; i++)
72 {
73 G4Curve* c = bounds[i];
74
75 if (c->GetEntityType() == "G4CompositeCurve")
76 {
77 G4CompositeCurve* cc = (G4CompositeCurve*)c;
78 const G4CurveVector& segments = cc->GetSegments();
79 cnt+= segments.size();
80 }
81 else
82 cnt++;
83 }
84
85 points.resize(cnt);
86
87 G4int j= 0;
88
89 for (i=0; i<bounds.size(); i++)
90 {
91 G4Curve* c= bounds[i];
92 if (c->GetEntityType() == "G4CompositeCurve")
93 {
94 G4CompositeCurve* cc = (G4CompositeCurve*)c;
95 const G4CurveVector& segments = cc->GetSegments();
96
97 for (size_t i=0; i<segments.size(); i++)
98 {
99 G4Curve* ccc = segments[i];
100 G4Point3D p = ccc->GetEnd();
101 points[j]= p;
102 j++;
103 }
104
105 }
106 else
107 {
108 G4Point3D p= c->GetEnd();
109 points[j]= p;
110 j++;
111 }
112 }
113}
114
115
116G4SurfaceBoundary* G4SurfaceBoundary::Project(const G4Transform3D& tr)
117{
118 G4CurveVector newBounds;
119 G4Curve* a = 0;
120 G4Curve* c = 0;
121
122 for (size_t i=0; i<bounds.size(); i++)
123 {
124 c= bounds[i]->Project(tr);
125
126 if (c==0)
127 {
128 // Remove newBounds and delete all its contents
129 while (newBounds.size()>0)
130 {
131 a = newBounds.back();
132 newBounds.pop_back();
133 for (G4CurveVector::iterator i=newBounds.begin();
134 i!=newBounds.end(); i++)
135 {
136 if (*i==a)
137 {
138 newBounds.erase(i);
139 i--;
140 }
141 }
142 if ( a ) delete a;
143 }
144 return 0;
145 }
146 // L. Broglia
147 c->SetSameSense( bounds[i]->GetSameSense() );
148
149 newBounds.push_back(c);
150 }
151
152 G4SurfaceBoundary* lof= new G4SurfaceBoundary;
153 lof->Init(newBounds);
154 return lof;
155}
156
157/*
158void G4SurfaceBoundary::IntersectRay2D(const G4Ray& ray,
159 G4CurveRayIntersection& is)
160{
161 is.Reset();
162 G4int entr = bounds.entries();
163 for (G4int i=0; i < entr; i++)
164 {
165 G4Curve& c = *bounds.at(i);
166 G4CurveRayIntersection isTmp(c, ray);
167 c.IntersectRay2D(ray, isTmp);
168
169 if (std::fabs(isTmp.GetDistance()) < std::fabs(is.GetDistance()))
170 is= isTmp;
171 }
172
173 lastIntersection= is;
174}
175*/
176
177G4int G4SurfaceBoundary::IntersectRay2D(const G4Ray& ray)
178{
179 G4int nbinter = 0;
180 G4int temp = 0;
181
182 for (size_t i=0; i < bounds.size(); i++)
183 {
184 G4Curve& c = *bounds[i];
185 temp = c.IntersectRay2D(ray);
186
187 // test if the point is on the boundary
188 if ( temp == 999 )
189 nbinter = 1;
190 else
191 nbinter += temp;
192 }
193
194 return nbinter;
195}
196
197
198G4bool G4SurfaceBoundary::Tangent(G4CurvePoint&, G4Vector3D& v)
199{
200 if (lastIntersection.GetDistance() == kInfinity)
201 return false;
202
203 return lastIntersection.GetCurve().Tangent(lastIntersection, v);
204 // should be true
205
206 // cp is ignored for the moment
207}
208
209
210void G4SurfaceBoundary::SplitWithPlane(const G4Point3D&,
211 const G4Vector3D&,
212 G4SurfaceBoundary*&,
213 G4SurfaceBoundary*&)
214{
215 G4Exception("G4SurfaceBoundary::SplitWithPlane()", "NotImplemented",
216 FatalException, "Sorry, not yet implemented.");
217}
218
219void G4SurfaceBoundary::SplitWithCylinder(const G4CylindricalSurface&,
220 G4SurfaceBoundary*&,
221 G4SurfaceBoundary*&)
222{
223 G4Exception("G4SurfaceBoundary::SplitWithCylinder()", "NotImplemented",
224 FatalException, "Sorry, not yet implemented.");
225}
Note: See TracBrowser for help on using the repository browser.