Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

geometry/meshImport2D.hh
Go to the documentation of this file.
00001 /* Meshes
00002  * Combining cells to a mesh to represent a computational domain
00003  * Importing 2D meshes from text files
00004  */
00005 
00006 #ifndef meshImport2D_hh
00007 #define meshImport2D_hh
00008 
00009 #include <vector>
00010 #include <map>
00011 #include "mesh.hh"
00012 #include "meshImport.hh"
00013 #include "toolbox/array.hh"
00014 #include "toolbox/multiArray.hh"
00015 
00016 namespace concepts {
00017 
00018   // ****************************************************** Import2dMeshBase **
00019 
00030   class Import2dMeshBase : public Mesh2, public ImportMesh {
00031   public:
00032     Import2dMeshBase(const std::string coord, const std::string elms,
00033          const uint idxStart = 1);
00034     virtual ~Import2dMeshBase();
00035     virtual uint ncell() const { return cell_.size(); }
00036     virtual Scan2* scan();
00037   protected:
00038     virtual std::ostream& info(std::ostream& os) const;
00039 
00041     class S;
00042 
00044     std::vector<Cell2*> cell_;
00045 
00047     const std::string coord_, elms_;
00048 
00050     std::vector<Real3d> vertices_;
00051     uint dim_;
00052 
00054     std::vector<Connector2*> cntr2_;
00056     MultiArray<3, Triangle*> Tri_;
00057     MultiArray<4, Quad*> Quad_;
00058 
00060     virtual void createEntity_(const MultiIndex<1>& idx) 
00061     { ImportMesh::createEntity_(idx); }
00062     virtual void createEntity_(const MultiIndex<2>& idx) 
00063     { ImportMesh::createEntity_(idx); }
00064     virtual void createEntity_(const MultiIndex<3>& idx) 
00065       throw(concepts::MissingFeature);
00066     virtual void createEntity_(const MultiIndex<4>& idx)
00067       throw(concepts::MissingFeature);
00068 
00070     virtual void createCell_(const MultiIndex<3>& idx)
00071       throw(concepts::MissingFeature);
00072     virtual void createCell_(const MultiIndex<4>& idx)
00073       throw(concepts::MissingFeature);
00074 
00076     virtual void readVertices_();
00077     uint readVertexLine_(const std::string& i, uint* idx, Real3d* coord) const;
00078 
00080     void attributes_(const std::string boundary);
00082     void import_();
00083   };
00084 
00086   class Import2dMeshBase::S : public Scan<Cell2> {
00087   public:
00088     inline S(std::vector<Cell2*>& cell) :
00089       idx_(cell.begin()), cell_(cell) {}
00090     inline S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
00091     inline bool eos() const { return idx_ == cell_.end(); }
00092     inline Cell2& operator++(int) { return *(*idx_++); }
00093     inline Scan2* clone() const { return new S(*this); }
00094   private:
00095     std::vector<Cell2*>::iterator idx_;
00096     std::vector<Cell2*>& cell_;
00097   };
00098 
00099   // ********************************************************** Import2dMesh **
00100 
00101   class Import2dMesh : public Import2dMeshBase {
00102   public:
00135     Import2dMesh(const std::string coord, const std::string elms,
00136      const std::string boundary, const uint idxStart = 1);
00137 
00138 //my_new:
00139     Import2dMesh(const std::string coord, const std::string elms,
00140      const std::string boundary, const std::string edgecorr,
00141      const uint idxStart = 1);
00169     Import2dMesh(const std::string coord, const std::string elms,
00170      const uint idxStart = 1);
00171     virtual ~Import2dMesh() {}
00172   protected:
00173     virtual std::ostream& info(std::ostream& os) const;
00174   };
00175 
00176 } // namespace concepts
00177 
00178 #endif // meshImport2D_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)