#include <G4CompositeCurve.hh>
Inheritance diagram for G4CompositeCurve:
Public Member Functions | |
G4CompositeCurve () | |
virtual | ~G4CompositeCurve () |
G4CompositeCurve (const G4Point3DVector &vertices) | |
virtual G4String | GetEntityType () const |
virtual G4Curve * | Project (const G4Transform3D &tr=G4Transform3D::Identity) |
virtual G4bool | Tangent (G4CurvePoint &cp, G4Vector3D &v) |
virtual G4double | GetPMax () const |
virtual G4Point3D | GetPoint (G4double param) const |
virtual G4double | GetPPoint (const G4Point3D &p) const |
const G4CurveVector & | GetSegments () const |
void | Init (const G4CurveVector &segments0) |
virtual G4int | IntersectRay2D (const G4Ray &ray) |
Protected Member Functions | |
virtual void | InitBounded () |
Definition at line 48 of file G4CompositeCurve.hh.
G4CompositeCurve::G4CompositeCurve | ( | ) |
G4CompositeCurve::~G4CompositeCurve | ( | ) | [virtual] |
Definition at line 59 of file G4CompositeCurve.cc.
00060 { 00061 // Remove segments and delete all its contents 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 }
G4CompositeCurve::G4CompositeCurve | ( | const G4Point3DVector & | vertices | ) |
Definition at line 42 of file G4CompositeCurve.cc.
References Init(), G4Line::Init(), and G4Curve::SetBounds().
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 }
G4String G4CompositeCurve::GetEntityType | ( | ) | const [virtual] |
Reimplemented from G4Curve.
Definition at line 83 of file G4CompositeCurve.cc.
00084 { 00085 return G4String("G4CompositeCurve"); 00086 }
G4double G4CompositeCurve::GetPMax | ( | ) | const [virtual] |
Implements G4Curve.
Definition at line 130 of file G4CompositeCurve.cc.
References FatalException, and G4Exception().
00131 { 00132 G4Exception("G4CompositeCurve::GetPMax()", "GeomSolids0002", 00133 FatalException, "Not applicable to base class."); 00134 return 0; 00135 }
Implements G4Curve.
Definition at line 137 of file G4CompositeCurve.cc.
References FatalException, and G4Exception().
00138 { 00139 G4Exception("G4CompositeCurve::GetPoint()", "GeomSolids0002", 00140 FatalException, "Not applicable to base class."); 00141 // Fake return value 00142 return G4Point3D(); 00143 }
Implements G4Curve.
Definition at line 145 of file G4CompositeCurve.cc.
References FatalException, and G4Exception().
00146 { 00147 G4Exception("G4CompositeCurve::GetPPoint()", "GeomSolids0002", 00148 FatalException, "Not applicable to base class."); 00149 return 0; 00150 }
const G4CurveVector & G4CompositeCurve::GetSegments | ( | ) | const [inline] |
void G4CompositeCurve::Init | ( | const G4CurveVector & | segments0 | ) | [inline] |
Definition at line 38 of file G4CompositeCurve.icc.
References InitBounded(), and G4CurveRayIntersection::Reset().
Referenced by G4CompositeCurve(), and Project().
00039 { 00040 segments= segments0; 00041 lastIntersection.Reset(); 00042 InitBounded(); 00043 }
void G4CompositeCurve::InitBounded | ( | ) | [protected, virtual] |
Implements G4Curve.
Definition at line 204 of file G4CompositeCurve.cc.
References G4Curve::BBox(), G4Curve::bBox, G4BoundingBox3D::Extend(), G4BoundingBox3D::GetBoxMax(), G4BoundingBox3D::GetBoxMin(), and G4BoundingBox3D::Init().
Referenced by Init().
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 // init for efficient parameter <-> 3D point conversions 00217 }
Implements G4Curve.
Definition at line 173 of file G4CompositeCurve.cc.
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 // test if the point is on the composite curve 00184 if( temp == 999 ) 00185 return 999; 00186 else 00187 nbinter+= temp; 00188 } 00189 00190 return nbinter; 00191 }
G4Curve * G4CompositeCurve::Project | ( | const G4Transform3D & | tr = G4Transform3D::Identity |
) | [virtual] |
Implements G4Curve.
Definition at line 88 of file G4CompositeCurve.cc.
References Init().
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 // Remove newSegments and delete all its contents 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 }
G4bool G4CompositeCurve::Tangent | ( | G4CurvePoint & | cp, | |
G4Vector3D & | v | |||
) | [virtual] |
Implements G4Curve.
Definition at line 193 of file G4CompositeCurve.cc.
References G4CurvePoint::GetCurve(), G4CurveRayIntersection::GetDistance(), and G4Curve::Tangent().
00194 { 00195 if (lastIntersection.GetDistance() == kInfinity) 00196 return false; 00197 00198 return lastIntersection.GetCurve().Tangent(lastIntersection, v); 00199 // should be true 00200 // cp is ignored for the moment 00201 }