G4SurfaceBoundary Class Reference

#include <G4SurfaceBoundary.hh>


Public Member Functions

 G4SurfaceBoundary ()
 ~G4SurfaceBoundary ()
void Init (const G4CurveVector &bounds0)
const G4CurveVectorGetBounds () const
const G4BoundingBox3DBBox () const
G4SurfaceBoundaryProject (const G4Transform3D &tr=G4Transform3D::Identity)
G4int IntersectRay2D (const G4Ray &ray)
G4bool Tangent (G4CurvePoint &cp, G4Vector3D &v)
void SplitWithPlane (const G4Point3D &p0, const G4Vector3D &n, G4SurfaceBoundary *&new1, G4SurfaceBoundary *&new2)
void SplitWithCylinder (const G4CylindricalSurface &c, G4SurfaceBoundary *&new1, G4SurfaceBoundary *&new2)
G4int GetNumberOfPoints () const
const G4Point3DGetPoint (G4int Count) const


Detailed Description

Definition at line 53 of file G4SurfaceBoundary.hh.


Constructor & Destructor Documentation

G4SurfaceBoundary::G4SurfaceBoundary (  ) 

Definition at line 41 of file G4SurfaceBoundary.cc.

00042 {
00043 }

G4SurfaceBoundary::~G4SurfaceBoundary (  ) 

Definition at line 45 of file G4SurfaceBoundary.cc.

00046 {
00047 }


Member Function Documentation

const G4BoundingBox3D & G4SurfaceBoundary::BBox (  )  const [inline]

Definition at line 44 of file G4SurfaceBoundary.icc.

Referenced by G4Surface::CalcBBox(), G4FPlane::CalcBBox(), G4ConicalSurface::CalcBBox(), and Init().

00045 {
00046   return bBox;
00047 }

const G4CurveVector & G4SurfaceBoundary::GetBounds (  )  const [inline]

Definition at line 38 of file G4SurfaceBoundary.icc.

Referenced by G4Surface::ClosestDistanceToPoint().

00039 {
00040   return bounds;
00041 }

G4int G4SurfaceBoundary::GetNumberOfPoints (  )  const [inline]

Definition at line 50 of file G4SurfaceBoundary.icc.

Referenced by G4FPlane::GetNumberOfPoints().

00051 {
00052   return points.size();
00053 }

const G4Point3D & G4SurfaceBoundary::GetPoint ( G4int  Count  )  const [inline]

Definition at line 56 of file G4SurfaceBoundary.icc.

Referenced by G4FPlane::GetPoint().

00057 {
00058   return points[Count];
00059 }

void G4SurfaceBoundary::Init ( const G4CurveVector bounds0  ) 

Definition at line 49 of file G4SurfaceBoundary.cc.

References BBox(), G4BoundingBox3D::Extend(), G4BoundingBox3D::GetBoxMax(), G4BoundingBox3D::GetBoxMin(), G4BoundingBox3D::Init(), and G4CurveRayIntersection::Reset().

Referenced by Project(), and G4Surface::SetBoundaries().

00050 {
00051   bounds= bounds0;
00052   lastIntersection.Reset();
00053   
00054   const G4BoundingBox3D* b= bounds[0]->BBox();
00055   bBox.Init(b->GetBoxMin(), b->GetBoxMax());
00056   
00057   size_t i;
00058   for ( i=1; i<bounds.size(); i++) 
00059   {
00060     b= bounds[i]->BBox();
00061     bBox.Extend(b->GetBoxMin());
00062     bBox.Extend(b->GetBoxMax());
00063   }
00064 
00065   // the points array is probably unused, so the following code is useless
00066   G4int cnt= 0;
00067 
00068   size_t entr = bounds.size();
00069 
00070   for (i=0; i < entr; i++) 
00071   {
00072     G4Curve* c = bounds[i];
00073 
00074     if (c->GetEntityType() == "G4CompositeCurve") 
00075     {
00076       G4CompositeCurve* cc = (G4CompositeCurve*)c;
00077       const G4CurveVector& segments = cc->GetSegments();
00078       cnt+= segments.size();
00079     } 
00080     else 
00081       cnt++;
00082   }
00083 
00084   points.resize(cnt);
00085   
00086   G4int j= 0;
00087   
00088   for (i=0; i<bounds.size(); i++) 
00089   {
00090     G4Curve* c= bounds[i];
00091     if (c->GetEntityType() == "G4CompositeCurve") 
00092     {
00093       G4CompositeCurve* cc = (G4CompositeCurve*)c;
00094       const G4CurveVector& segments = cc->GetSegments();
00095      
00096       for (size_t k=0; k<segments.size(); k++) 
00097       {
00098         G4Curve* ccc = segments[k];
00099         G4Point3D p  = ccc->GetEnd();
00100         points[j]= p;
00101         j++;
00102       }
00103 
00104     } 
00105     else
00106     {
00107       G4Point3D p= c->GetEnd();
00108       points[j]= p;
00109       j++;
00110     }
00111   }
00112 }

G4int G4SurfaceBoundary::IntersectRay2D ( const G4Ray ray  ) 

Definition at line 179 of file G4SurfaceBoundary.cc.

Referenced by G4FPlane::Intersect().

00180 {
00181   G4int nbinter = 0;
00182   G4int temp = 0;
00183 
00184   for (size_t i=0; i < bounds.size(); i++) 
00185   {   
00186     G4Curve& c = *bounds[i];
00187     temp = c.IntersectRay2D(ray);
00188 
00189     // test if the point is on the boundary
00190     if ( temp == 999 )
00191       nbinter = 1;
00192     else
00193       nbinter += temp; 
00194   }
00195 
00196   return nbinter;
00197 }

G4SurfaceBoundary * G4SurfaceBoundary::Project ( const G4Transform3D tr = G4Transform3D::Identity  ) 

Definition at line 115 of file G4SurfaceBoundary.cc.

References Init(), and G4Curve::SetSameSense().

Referenced by G4FPlane::InitBounded().

00116 {
00117   G4CurveVector newBounds;
00118   G4Curve* a = 0;
00119   G4Curve* c = 0;
00120   
00121   for (size_t i=0; i<bounds.size(); i++)
00122   {
00123     c= bounds[i]->Project(tr);
00124     
00125     if (c==0) 
00126     {
00127       // Remove newBounds and delete all its contents
00128       while (newBounds.size()>0)
00129       {
00130         a = newBounds.back();
00131         newBounds.pop_back();
00132         for (G4CurveVector::iterator it=newBounds.begin();
00133                                      it!=newBounds.end();)
00134         {
00135           if (*it==a)
00136           {
00137             it = newBounds.erase(it);
00138           }
00139           else
00140           {
00141             it--;
00142           }
00143         } 
00144         if ( a )  { delete a; }
00145       } 
00146       return 0;
00147     }
00148     // L. Broglia
00149     c->SetSameSense( bounds[i]->GetSameSense() );
00150 
00151     newBounds.push_back(c);
00152   }
00153   
00154   G4SurfaceBoundary* lof= new G4SurfaceBoundary;
00155   lof->Init(newBounds);
00156   return lof;
00157 }

void G4SurfaceBoundary::SplitWithCylinder ( const G4CylindricalSurface c,
G4SurfaceBoundary *&  new1,
G4SurfaceBoundary *&  new2 
)

Definition at line 221 of file G4SurfaceBoundary.cc.

References FatalException, and G4Exception().

00224 {
00225   G4Exception("G4SurfaceBoundary::SplitWithCylinder()", "GeomSolids0001",
00226               FatalException, "Sorry, not yet implemented.");
00227 }

void G4SurfaceBoundary::SplitWithPlane ( const G4Point3D p0,
const G4Vector3D n,
G4SurfaceBoundary *&  new1,
G4SurfaceBoundary *&  new2 
)

Definition at line 212 of file G4SurfaceBoundary.cc.

References FatalException, and G4Exception().

00216 {
00217   G4Exception("G4SurfaceBoundary::SplitWithPlane()", "GeomSolids0001",
00218               FatalException, "Sorry, not yet implemented.");
00219 }

G4bool G4SurfaceBoundary::Tangent ( G4CurvePoint cp,
G4Vector3D v 
)

Definition at line 200 of file G4SurfaceBoundary.cc.

References G4CurvePoint::GetCurve(), G4CurveRayIntersection::GetDistance(), and G4Curve::Tangent().

00201 {
00202   if (lastIntersection.GetDistance() == kInfinity) 
00203     return false;
00204   
00205   return lastIntersection.GetCurve().Tangent(lastIntersection, v);
00206   // should be true
00207   
00208   // cp is ignored for the moment
00209 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:28 2013 for Geant4 by  doxygen 1.4.7