moab
vtkMOABMesh.hpp
Go to the documentation of this file.
00001 #ifndef __vtkMOABMesh_h
00002 #define __vtkMOABMesh_h
00003 
00004 #include "vtkUnstructuredGrid.h"
00005 
00006 #include "moab/Interface.hpp"
00007 #include "moab/WriteUtilIface.hpp"
00008 #include "moab/Range.hpp"
00009 
00010 class vtkIntArray;
00011 
00012 using namespace moab;
00013 
00014 #include <vector>
00015 #include <string>
00016 
00017 class VTK_EXPORT vtkMOABMesh
00018 {
00019 public:
00020   static vtkMOABMesh *instance(Interface *iface = NULL, bool create_new = true);
00021 
00022   ErrorCode delete_instance();
00023   
00024   ErrorCode Update(EntityHandle file_set = 0);
00025 
00026   ErrorCode load_file(const char *file_name, const char *options, EntityHandle &file_set);
00027 
00028   vtkUnstructuredGrid *GetOutput();
00029   void SetOutput(vtkUnstructuredGrid *ug);
00030 
00031   void file_sets(Range &files);
00032   
00033   void file_names(std::vector<std::string> &fnames);
00034 
00035   bool file_loaded(const char *filename);
00036   
00037   void Execute();
00038 
00039 protected:
00040   vtkMOABMesh(Interface *impl);
00041   ~vtkMOABMesh();
00042 
00043 private:
00044   vtkMOABMesh(const vtkMOABMesh&);  // Not implemented.
00045   void operator=(const vtkMOABMesh&);  // Not implemented.
00046 
00047   static vtkMOABMesh *instance_;
00048   
00049   vtkUnstructuredGrid *myUG;
00050 
00051   Interface *mbImpl;
00052   
00053   WriteUtilIface *iFace;
00054 
00055   Range fileSets;
00056                                
00057   static const int vtk_cell_types[];
00058 
00059   int maxPointId;
00060   int maxCellId;
00061 
00062   Tag vtkIdTag;
00063   
00064   std::vector<std::string> fileNames;
00065 
00066   bool outOfDate;
00067   
00068   ErrorCode construct_mesh(EntityHandle file_set);
00069 
00070   ErrorCode create_points_vertices(EntityHandle file_set, Range &verts);
00071   
00072   ErrorCode create_elements(EntityHandle file_set);
00073   
00074   ErrorCode construct_filters();
00075 
00076   ErrorCode read_tags(EntityHandle file_set);
00077   
00078   ErrorCode read_sparse_tags(EntityHandle file_set);
00079 
00080   ErrorCode read_dense_tags(EntityHandle file_set);
00081 
00082   void add_name(vtkUnstructuredGrid *output, const char *prefix,
00083                 const int id);
00084   
00085 };
00086 
00087 inline vtkUnstructuredGrid *vtkMOABMesh::GetOutput() 
00088 {
00089   return myUG;
00090 }
00091 
00092 inline void vtkMOABMesh::SetOutput(vtkUnstructuredGrid *ug) 
00093 {
00094   myUG = ug;
00095 }
00096 
00097 inline void vtkMOABMesh::file_sets(Range &fsets) 
00098 {
00099   fsets.merge(fileSets);
00100 }
00101 
00102 inline void vtkMOABMesh::file_names(std::vector<std::string> &fnames) 
00103 {
00104   std::copy(fileNames.begin(), fileNames.end(), std::back_inserter(fnames));
00105 }
00106 
00107 inline bool vtkMOABMesh::file_loaded(const char *filename) 
00108 {
00109   return (std::find(fileNames.begin(), fileNames.end(), std::string(filename)) != fileNames.end());
00110 }
00111 
00112 #endif
00113 
00114 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines