#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>
-class VISU_Convertor_impl: public VISU_Convertor{
-private:
- void GetPoints(VISU::TVTKSource& theStorage,
- const VISU::TMesh& theMesh)
- const throw (std::runtime_error&);
- void GetCellsOnEntity(VISU::TVTKSource& theStorage,
- const VISU::TMeshOnEntity& theMeshOnEntity,
- const std::string& theFamilyName)
- const throw (std::runtime_error&);
- void GetCellsOnGroup(VISU::TVTKSource& theStorage,
- const VISU::TMesh& theMesh,
- const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
- const throw (std::runtime_error&);
- void GetField(VISU::TVTKSource& theStorage,
- const VISU::TMesh& theMesh,
- const VISU::TMeshOnEntity& theMeshOnEntity,
- const VISU::TField& theField,
- const VISU::TField::TValForTime& theValForTime)
- const throw (std::runtime_error&);
-
-
-protected:
- void FindMesh(const std::string& theMeshName, VISU::TMesh*& theMesh)
- throw(std::runtime_error&);
- void FindMeshOnEntity(const std::string& theMeshName, VISU::TMesh*& theMesh,
- const VISU::TEntity& theEntity, VISU::TMeshOnEntity*& theMeshOnEntity,
- const std::string& theFamilyName, VISU::TFamily*& theFamily)
- throw (std::runtime_error&);
-
- void FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh,
- const std::string& theGroupName, VISU::TGroup*& theGroup)
- throw (std::runtime_error&);
-
- 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)
- throw (std::runtime_error&);
- 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)
- throw (std::runtime_error&);
+#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 vtkIdType GetMeshOnEntitySize(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFamilyName = "")
- throw (std::runtime_error&);
- virtual vtkIdType GetMeshOnGroupSize(const std::string& theMeshName,
- const std::string& theGroupName)
- throw(std::runtime_error&);
- virtual vtkIdType GetTimeStampSize(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum)
- throw(std::runtime_error&);
- virtual vtkIdType GetFieldOnMeshSize(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName)
- throw(std::runtime_error&);
- virtual const VISU::TField& GetField(const std::string& theMeshName,
- VISU::TEntity theEntity,
- const std::string& theFieldName)
- throw(std::runtime_error&);
- virtual const VISU::TField::TValForTime& GetTimeStamp(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum)
- throw(std::runtime_error&);
+ 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::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();
+
virtual ~VISU_Convertor_impl();
- virtual VISU_Convertor* Build() throw (std::runtime_error&) { return this;};
- virtual TOutput* GetMeshOnEntity(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFamilyName = "")
- throw(std::runtime_error&);
- virtual TOutput* GetMeshOnGroup(const std::string& theMeshName,
- const std::string& theGroupName)
- throw(std::runtime_error&);
- virtual TOutput* GetTimeStampOnMesh(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum)
- throw(std::runtime_error&);
-
- protected:
- virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity,
- const std::string& theFamilyName = "")
- throw (std::runtime_error&) = 0;
- virtual int LoadMeshOnGroup(VISU::TMesh& theMesh,
- const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
- throw (std::runtime_error&) = 0;
- virtual int LoadFieldOnMesh(VISU::TMesh& theMesh,
- VISU::TMeshOnEntity& theMeshOnEntity,
- VISU::TField& theField,
- VISU::TField::TValForTime& theValForTime)
- throw (std::runtime_error&) = 0;
-};
-template<class T> std::string dtos(const std::string& fmt, T val){
- static QString aString;
- aString.sprintf(fmt.c_str(),val);
- return aString.latin1();
-}
+ 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);
-extern "C"{
- int getNbMedConnect(int theMedType, int theMedEntity, int theMeshDim);
- int getNbMedNodes(int theMedType);
- int med2vtkCellType(int theMedType);
- int vtk2medCellType(int theVtkType);
- int getIdMedType(int medType);
-}
+protected:
+ 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::PMeshOnEntityImpl theMeshOnEntity,
+ const std::string& theFamilyName = "") = 0;
+
+ virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh,
+ const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) = 0;
-struct Med2vtk {
- med_geometrie_element medType;
- const char *medName;
- int medNbNodes;
- int vtkType;
- const char *vtkName;
- int vtkNbNodes;
+ virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh,
+ VISU::PMeshOnEntityImpl theMeshOnEntity,
+ VISU::PFieldImpl theField,
+ VISU::PValForTimeImpl theValForTime) = 0;
};
-extern Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE];
+
#endif