00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4CompositeCurve.hh"
00037 #include "G4Line.hh"
00038
00039
00040 G4CompositeCurve::G4CompositeCurve(){}
00041
00042 G4CompositeCurve::G4CompositeCurve(const G4Point3DVector& vertices)
00043 {
00044 G4CurveVector cv;
00045 for (size_t i=0; i<vertices.size(); i++)
00046 {
00047 G4Point3D p1= vertices[i];
00048 G4Point3D p2= vertices[(i+1) % vertices.size()];
00049
00050 G4Line* l= new G4Line;
00051 l->Init(p1, p2-p1);
00052 l->SetBounds(p1, p2);
00053 cv.push_back(l);
00054 }
00055
00056 Init(cv);
00057 }
00058
00059 G4CompositeCurve::~G4CompositeCurve()
00060 {
00061
00062
00063 G4Curve* a = 0;
00064 while (segments.size()>0)
00065 {
00066 a = segments.back();
00067 segments.pop_back();
00068 for (G4CurveVector::iterator i=segments.begin(); i!=segments.end();)
00069 {
00070 if (*i==a)
00071 {
00072 i = segments.erase(i);
00073 }
00074 else
00075 {
00076 ++i;
00077 }
00078 }
00079 delete a;
00080 }
00081 }
00082
00083 G4String G4CompositeCurve::GetEntityType() const
00084 {
00085 return G4String("G4CompositeCurve");
00086 }
00087
00088 G4Curve* G4CompositeCurve::Project(const G4Transform3D& tr)
00089 {
00090 G4CurveVector newSegments;
00091 G4Curve* a = 0;
00092 G4Curve* c = 0;
00093
00094 for (size_t i=0; i<segments.size(); i++)
00095 {
00096 c = segments[i]->Project(tr);
00097 if (c==0)
00098 {
00099
00100 while (newSegments.size()>0)
00101 {
00102 a = newSegments.back();
00103 newSegments.pop_back();
00104 for (G4CurveVector::iterator it=newSegments.begin();
00105 it!=newSegments.end();)
00106 {
00107 if (*it==a)
00108 {
00109 it = newSegments.erase(it);
00110 }
00111 else
00112 {
00113 ++it;
00114 }
00115 }
00116 delete a;
00117 }
00118 return 0;
00119 }
00120 newSegments.push_back(c);
00121 }
00122
00123 G4CompositeCurve* r= new G4CompositeCurve;
00124 r->Init(newSegments);
00125 return r;
00126 }
00127
00129
00130 G4double G4CompositeCurve::GetPMax() const
00131 {
00132 G4Exception("G4CompositeCurve::GetPMax()", "GeomSolids0002",
00133 FatalException, "Not applicable to base class.");
00134 return 0;
00135 }
00136
00137 G4Point3D G4CompositeCurve::GetPoint(G4double) const
00138 {
00139 G4Exception("G4CompositeCurve::GetPoint()", "GeomSolids0002",
00140 FatalException, "Not applicable to base class.");
00141
00142 return G4Point3D();
00143 }
00144
00145 G4double G4CompositeCurve::GetPPoint(const G4Point3D&) const
00146 {
00147 G4Exception("G4CompositeCurve::GetPPoint()", "GeomSolids0002",
00148 FatalException, "Not applicable to base class.");
00149 return 0;
00150 }
00151
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 G4int G4CompositeCurve::IntersectRay2D(const G4Ray& ray)
00174 {
00175 G4int nbinter = 0;
00176 G4int temp = 0;
00177
00178 for (size_t i=0; i<segments.size(); i++)
00179 {
00180 G4Curve& c= *(segments[i]);
00181 temp = c.IntersectRay2D(ray);
00182
00183
00184 if( temp == 999 )
00185 return 999;
00186 else
00187 nbinter+= temp;
00188 }
00189
00190 return nbinter;
00191 }
00192
00193 G4bool G4CompositeCurve::Tangent(G4CurvePoint&, G4Vector3D& v)
00194 {
00195 if (lastIntersection.GetDistance() == kInfinity)
00196 return false;
00197
00198 return lastIntersection.GetCurve().Tangent(lastIntersection, v);
00199
00200
00201 }
00202
00203
00204 void G4CompositeCurve::InitBounded()
00205 {
00206 const G4BoundingBox3D* b= segments[0]->BBox();
00207 bBox.Init(b->GetBoxMin(), b->GetBoxMax());
00208
00209 for (size_t i=1; i<segments.size(); i++)
00210 {
00211 b= segments[i]->BBox();
00212 bBox.Extend(b->GetBoxMin());
00213 bBox.Extend(b->GetBoxMax());
00214 }
00215
00216
00217 }