Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

LayeredMedium.h

Go to the documentation of this file.
00001 //  $Id: LayeredMedium.h,v 1.4 2001/01/23 03:41:32 burnett Exp $
00002 //
00003 
00004 #ifndef LAYEREDMEDIUM_H
00005 #define LAYEREDMEDIUM_H
00006 
00007 #include "gismo/CompositeMedium.h"
00008 #include "geometry/Volume.h"
00009 
00018 class LayeredMedium : public CompositeMedium {
00019 public:
00020 
00022     virtual ~LayeredMedium();
00023 
00024     virtual double distanceToLeave( const Ray& r, const Medium*& nextMedium, double maxStep ) const;
00025     // returns distance to leave this medium (perhaps to enter an inner Medium if implemented by
00026     // a CompositeMedium), setting nextMedium if a boundary is reached. Will be limited to maxStep
00027 
00029     virtual double distanceToEnter( const Ray& r, const Medium*& nextMedium, double maxStep) const;
00030 
00031     const Medium* inside(const Point& x)const;
00032 
00034     virtual void createDetectorView(gui::DisplayRep& v){};
00035 
00036 
00037 //protected:
00038     LayeredMedium(Medium* mother, int num_sufaces, double inner_offset=0); 
00039     // abstract class: ctor only accessible to subclasses 
00040 
00041 
00042     Medium& addLayer(Medium * inner_medium, double thickness);
00043     // add a new layer, enlarging the current structure. inner_medium will be associated
00044     // with the new layer, and any internal Shapes it has must fit within the layer. Subclass
00045     // is responsible for shifting it into place.
00046 
00047 
00048     virtual const Medium* select(const Point& x)const;
00049     // return the correct inner medium, given the point x
00050     // virtual to allow subclass to make efficient calculation
00051 
00052     class Slice; 
00053     class Volume;
00054 
00055     //-------------------------------------------------------------------
00056     // Define a special volume that handles the logic of an individual layer
00057     class Slice : public ::Volume {
00058     public:
00059         Slice(LayeredMedium& mother, int index);
00060         ~Slice();
00061 
00062         const char* nameOf()const{return "LayeredMedium::Slice";}
00063 
00064         double distanceToLeave(const Ray& r, double d)const;
00065         // override in order to reverse inner surface, flag the mother
00066 
00067         const ::Volume& setMotherVolume()const;
00068         // set up the mother volume for this slice, return reference to it
00069 
00070         const ::Volume& resetMotherVolume()const;
00071         // reset the mother volume  to have again initial size 
00072 
00073         void printOn(std::ostream& out)const;
00074 
00075         virtual GeomObject& transform(const CoordTransform& ){return *this;};
00076         // override since don't own any objects
00077 
00078     private:
00079         LayeredMedium& m_mother;
00080         int m_index;    // index of this slice: -1 for the mother
00081         
00082 
00083     };
00084     //-------------------------------------------------------------------
00085 
00086     const Surface& referenceSurface()const;
00087     // access to the inner surface used to define the division
00088 
00089     //-------------------------------------------------------------------
00090     // special Volume for this Medium 
00091     class Volume : public ::Volume {
00092     public:
00093         Volume(int n);
00094 
00095         void setSurface(int n, Surface* surf){ operator[](n)=surf;}
00096         Surface& surface(int n){return *operator[](n);}
00097         // full access to internal surfaces 
00098         
00099         void setOffsets(double inner, double outer);
00100         // adjust the offsets
00101 
00102         const char* nameOf()const{return "LayeredMedium::Volume";}
00103     private:
00104     };
00105     //-------------------------------------------------------------------
00106 
00107     friend class Slice;
00108 
00109     std::vector<double> m_offset;
00110     // list of offsets for the inner and outer surfaces that define the slices
00111 
00112     Volume* m_vol;
00113     // separate pointer to the Shape to avoid casts
00114 private:
00115 
00116     int m_select_index;
00117     int m_last_boundary; 
00118     // tags: keep track of which layer we are in, communicate which surface left
00119 };
00120 
00121 #endif
00122 

Generated at Mon Nov 26 18:18:33 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000