Salome HOME
Update Help for VISU module.
[modules/visu.git] / src / CONVERTOR / VISU_Convertor_impl.hxx
index fa2f829102dc0b9c9c348c65b8229ad67f4d4d5e..46284cba0cab26d047f6b2bc59202fec10e5121e 100644 (file)
 
 #include "VISU_Convertor.hxx"
 
-extern "C"{
-#include <med.h>
-}  
+#include <vtkSystemIncludes.h>
+
+#include <vtkPoints.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkMergeDataObjectFilter.h>
+#include <vtkFieldDataToAttributeDataFilter.h>
+#include "VISU_ExtractUnstructuredGrid.hxx"
 
 #include <qstring.h>
 #include <qfileinfo.h>
 
+#include <vtkSmartPointer.h>
+
+#include <boost/tuple/tuple.hpp>
+
+namespace VISU{
+
+  typedef vtkSmartPointer<vtkPoints> TVTKPoints;
+  typedef vtkSmartPointer<vtkUnstructuredGrid> TVTKSource;
+  typedef vtkSmartPointer<vtkMergeDataObjectFilter> TVTKMergetFilter;
+  typedef vtkSmartPointer<VISU_ExtractUnstructuredGrid> TVTKExtractFilter;
+  typedef vtkSmartPointer<vtkFieldDataToAttributeDataFilter> TVTKAttribyteFilter;
+
+  typedef float TCoord;
+
+  struct TMeshImpl: TMesh{
+    TVTKPoints myPoints;
+
+    typedef std::vector<TCoord> TPointsCoord;
+    TPointsCoord myPointsCoord;
+
+    typedef std::vector<std::string> TPointsDim;
+    TPointsDim myPointsDim;
+  };
+  typedef shared_ptr<TMeshImpl> PMeshImpl;
+
+  struct TMeshOnEntityImpl: TMeshOnEntity{
+    TVTKSource myStorage;
+    typedef std::vector<vtkIdType> TConnect;
+    typedef std::vector<TConnect> TConnForCellType;
+    typedef std::map<vtkIdType,TConnForCellType> TCellsConn;
+    TCellsConn myCellsConn;
+  };
+  typedef shared_ptr<TMeshOnEntityImpl> PMeshOnEntityImpl;
+
+  struct TFamilyImpl: TFamily{
+    TVTKSource myStorage;
+
+    typedef std::set<vtkIdType> TSubMeshOnCellType;
+    typedef std::map<vtkIdType,TSubMeshOnCellType> TSubMesh;
+    TSubMesh mySubMesh;
+  };
+  typedef shared_ptr<TFamilyImpl> PFamilyImpl;
+
+  struct TGroupImpl: TGroup{
+    TVTKSource myStorage;
+  };
+  typedef shared_ptr<TGroupImpl> PGroupImpl;
+
+  struct TFieldImpl: TField{
+    TVTKExtractFilter myExtractFilter;
+    ~TFieldImpl()
+    { 
+      if(myExtractFilter.GetPointer())
+       myExtractFilter->UnRegisterAllOutputs();
+    }
+  };
+  typedef shared_ptr<TFieldImpl> PFieldImpl;
+
+  struct TValForTimeImpl: TValForTime{
+    TVTKAttribyteFilter myAttribyteFilter;
+    TVTKMergetFilter myMergeFilter;
+    TVTKSource myStorage;
+
+    typedef std::vector<float> TValForCellsWithType;
+    typedef std::map<vtkIdType,TValForCellsWithType> TValForCells;
+    TValForCells myValForCells;
+
+    ~TValForTimeImpl()
+    { 
+      if(myMergeFilter.GetPointer())
+       myMergeFilter->UnRegisterAllOutputs();
+      if(myAttribyteFilter.GetPointer())
+       myAttribyteFilter->UnRegisterAllOutputs();
+    }
+  };
+  typedef shared_ptr<TValForTimeImpl> PValForTimeImpl;
+
+}
+
 class VISU_Convertor_impl: public VISU_Convertor{
 public:
   virtual float GetSize() ;
 
-  virtual float GetMeshOnEntitySize(const std::string& theMeshName, 
-                                   const VISU::TEntity& theEntity,
-                                   const std::string& theFamilyName = "");
-
-  virtual float GetMeshOnGroupSize(const std::string& theMeshName, 
-                                  const std::string& theGroupName);
-
-  virtual float GetTimeStampSize(const std::string& theMeshName, 
-                                const VISU::TEntity& theEntity,
-                                const std::string& theFieldName,
-                                int theStampsNum);
-
-  virtual float GetFieldOnMeshSize(const std::string& theMeshName, 
-                                  const VISU::TEntity& theEntity,
-                                  const std::string& theFieldName);
-
-  virtual const VISU::TField& GetField(const std::string& theMeshName, 
-                                      VISU::TEntity theEntity, 
-                                      const std::string& theFieldName);
-
-  virtual const VISU::TField::TValForTime& GetTimeStamp(const std::string& theMeshName, 
-                                                       const VISU::TEntity& theEntity,
-                                                       const std::string& theFieldName,
-                                                       int theStampsNum);
+  virtual 
+  float 
+  GetMeshOnEntitySize(const std::string& theMeshName, 
+                     const VISU::TEntity& theEntity,
+                     const std::string& theFamilyName = "");
+
+  virtual 
+  float 
+  GetMeshOnGroupSize(const std::string& theMeshName, 
+                    const std::string& theGroupName);
+
+  virtual 
+  float 
+  GetTimeStampSize(const std::string& theMeshName, 
+                  const VISU::TEntity& theEntity,
+                  const std::string& theFieldName,
+                  int theStampsNum);
+
+  virtual 
+  float 
+  GetFieldOnMeshSize(const std::string& theMeshName, 
+                    const VISU::TEntity& theEntity,
+                    const std::string& theFieldName);
+
+  virtual 
+  const VISU::PField 
+  GetField(const std::string& theMeshName, 
+          VISU::TEntity theEntity, 
+          const std::string& theFieldName);
+
+  virtual 
+  const VISU::PValForTime 
+  GetTimeStamp(const std::string& theMeshName, 
+              const VISU::TEntity& theEntity,
+              const std::string& theFieldName,
+              int theStampsNum);
 
 public:
   VISU_Convertor_impl();
@@ -54,52 +149,70 @@ public:
 
   virtual VISU_Convertor* Build()  { return this;};
 
-  virtual TOutput* GetMeshOnEntity(const std::string& theMeshName, 
-                                  const VISU::TEntity& theEntity,
-                                  const std::string& theFamilyName = "");
-
-  virtual TOutput* GetMeshOnGroup(const std::string& theMeshName, 
-                                 const std::string& theGroupName);
-
-  virtual TOutput* GetTimeStampOnMesh(const std::string& theMeshName, 
-                                     const VISU::TEntity& theEntity,
-                                     const std::string& theFieldName,
-                                     int theStampsNum);
+  virtual 
+  TOutput* 
+  GetMeshOnEntity(const std::string& theMeshName, 
+                 const VISU::TEntity& theEntity,
+                 const std::string& theFamilyName = "");
+
+  virtual 
+  TOutput* 
+  GetMeshOnGroup(const std::string& theMeshName, 
+                const std::string& theGroupName);
+  
+  virtual
+  TOutput* 
+  GetTimeStampOnMesh(const std::string& theMeshName, 
+                    const VISU::TEntity& theEntity,
+                    const std::string& theFieldName,
+                    int theStampsNum);
 
 protected:
-  void FindMesh(const std::string& theMeshName, VISU::TMesh*& theMesh);
-
-  void FindMeshOnEntity(const std::string& theMeshName, VISU::TMesh*& theMesh,
-                       const VISU::TEntity& theEntity, VISU::TMeshOnEntity*& theMeshOnEntity,
-                       const std::string& theFamilyName, VISU::TFamily*& theFamily);
-
-  void FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh,
-                      const std::string& theGroupName, VISU::TGroup*& theGroup);
-
-  void FindField(const std::string& theMeshName, VISU::TMesh*& theMesh,
-                const VISU::TEntity& theEntity, 
-                VISU::TMeshOnEntity*& theMeshOnEntity,
-                VISU::TMeshOnEntity*& theVTKMeshOnEntity,
-                const std::string& theFieldName, VISU::TField*& theField);
-
-  void FindTimeStamp(const std::string& theMeshName, VISU::TMesh*& theMesh,
-                    const VISU::TEntity& theEntity, 
-                    VISU::TMeshOnEntity*& theMeshOnEntity,
-                    VISU::TMeshOnEntity*& theVTKMeshOnEntity,
-                    const std::string& theFieldName, VISU::TField*& theField,
-                    int theStampsNum, VISU::TField::TValForTime*& theValForTime);
-
+  VISU::PMeshImpl 
+  FindMesh(const std::string& theMeshName);
+
+  typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindMeshOnEntity;
+  TFindMeshOnEntity
+  FindMeshOnEntity(const std::string& theMeshName,
+                  const VISU::TEntity& theEntity,
+                  const std::string& theFamilyName);
+
+  typedef boost::tuple<VISU::PMeshImpl,VISU::PGroupImpl> TFindMeshOnGroup;
+  TFindMeshOnGroup
+  FindMeshOnGroup(const std::string& theMeshName, 
+                 const std::string& theGroupName);
+
+  typedef boost::tuple<VISU::PMeshImpl,
+                      VISU::PMeshOnEntityImpl,
+                      VISU::PMeshOnEntityImpl,
+                      VISU::PFieldImpl> TFindField;
+  TFindField
+  FindField(const std::string& theMeshName, 
+           const VISU::TEntity& theEntity, 
+           const std::string& theFieldName);
+
+  typedef boost::tuple<VISU::PMeshImpl,
+                      VISU::PMeshOnEntityImpl,
+                      VISU::PMeshOnEntityImpl,
+                      VISU::PFieldImpl,
+                      VISU::PValForTimeImpl> TFindTimeStamp;
+  TFindTimeStamp
+  FindTimeStamp(const std::string& theMeshName, 
+               const VISU::TEntity& theEntity, 
+               const std::string& theFieldName, 
+               int theStampsNum);
+  
 protected:
-  virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, 
+  virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, 
                               const std::string& theFamilyName = "") = 0;
 
-  virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, 
+  virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
                              const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) = 0;
 
-  virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, 
-                             VISU::TMeshOnEntity& theMeshOnEntity, 
-                             VISU::TField& theField, 
-                             VISU::TField::TValForTime& theValForTime) = 0;
+  virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, 
+                             VISU::PMeshOnEntityImpl theMeshOnEntity, 
+                             VISU::PFieldImpl theField, 
+                             VISU::PValForTimeImpl theValForTime) = 0;
 };
 
 #endif