-// Copyright (C) 2003 CEA/DEN, EDF R&D
+// SALOME VTKViewer : build VTK viewer into Salome desktop
//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
-// File : VISU_Convertor_impl.hxx
-// Author : Alexey PETROV
-// Module : VISU
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
#ifndef VISU_Convertor_impl_HeaderFile
#define VISU_Convertor_impl_HeaderFile
+#include <vtkSmartPointer.h>
+
+#include <boost/tuple/tuple.hpp>
+
+class vtkCell;
+class vtkPoints;
+class vtkUnstructuredGrid;
+class VTKViewer_AppendFilter;
+class VISU_MergeFilter;
+
#include "VISU_Convertor.hxx"
+#include "MED_SliceArray.hxx"
-extern "C"{
-#include <med.h>
-}
-
-#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&);
+#ifndef VISU_ENABLE_QUADRATIC
+#define VISU_ENABLE_QUADRATIC
+#define VISU_USE_VTK_QUADRATIC
+#endif
+namespace VISU
+{
+ //! Defines VISU enumeration of geometrical types
+ enum EGeometry {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203,
+ eQUAD4=204, eTRIA6=206,eQUAD8=208, eTETRA4=304,
+ ePYRA5=305, ePENTA6=306, eHEXA8=308, eTETRA10=310,
+ ePYRA13=313, ePENTA15=315, eHEXA20=320,
+ ePOLYGONE=400, ePOLYEDRE=500, eNONE=-1};
-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&);
+ //! Get number of nodes for defined geometrical type
+ vtkIdType
+ VISUGeom2NbNodes(EGeometry theGeom);
+ //! Maps VISU geometrical type to VTK one
+ vtkIdType
+ VISUGeom2VTK(EGeometry theGeom);
-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&);
+ //---------------------------------------------------------------
+ using MED::TCSlice;
+ using MED::TSlice;
+
+ typedef vtkUnstructuredGrid TDataSet;
+
+ typedef vtkSmartPointer<TDataSet> TVTKSource;
+ typedef vtkSmartPointer<vtkPoints> TVTKPoints;
+ typedef vtkSmartPointer<VISU_MergeFilter> TVTKMergeFilter;
+
+ typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
+
+ typedef float TCoord;
+
+ //---------------------------------------------------------------
+ //! Define an utility base class which is repsonsible for preventing repetion
+ struct TIsVTKDone: virtual TBaseStructure
+ {
+ TIsVTKDone();
+ bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure
+ bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define an utility base class which allow to keep calculated number of cells and their size
+ struct TSizeCounter: virtual TIsVTKDone
+ {
+ TSizeCounter();
+ vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass
+ vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container for VTK representation
+ class TSource: public virtual TSizeCounter
+ {
+ protected:
+ mutable TVTKSource mySource;
+ public:
+ TSource();
+
+ //! This method allow to create corresponding VTK data set by demand (not at once)
+ const TVTKSource&
+ GetSource() const;
+
+ //! Reimplement the TIDMapper::GetVTKOutput
+ virtual
+ TVTKOutput*
+ GetVTKOutput();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container for VTK representation
+ /*!
+ This container allow to combine other VTK representation into single one.
+ */
+ class TAppendFilter: public virtual TIsVTKDone,
+ public virtual TIDMapper
+ {
+ protected:
+ mutable TVTKAppendFilter myFilter;
+ public:
+ TAppendFilter();
+
+ //! This method allow to create corresponding VTK filter by demand (not at once)
+ const TVTKAppendFilter&
+ GetFilter() const;
+
+ //! Reimplement the TIDMapper::GetVTKOutput
+ virtual
+ TVTKOutput*
+ GetVTKOutput();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container for VTK representation
+ /*!
+ This container allow to assign data to mesh and represent them into single VTK representation
+ */
+ class TMergeFilter: public virtual TIsVTKDone,
+ public virtual TIDMapper
+ {
+ protected:
+ mutable TVTKMergeFilter myFilter;
+ public:
+ TMergeFilter();
+
+ //! This method allow to create corresponding VTK filter by demand (not at once)
+ const TVTKMergeFilter&
+ GetFilter() const;
+
+ //! Reimplement the TIDMapper::GetVTKOutput
+ virtual
+ TVTKOutput*
+ GetVTKOutput();
+ };
+
+
+ //---------------------------------------------------------------
+ typedef TVector<TCoord> TCoordArray;
+ typedef TSlice<TCoordArray> TCoordSlice;
+ typedef TCSlice<TCoordArray> TCCoordSlice;
+
+ //! This class is responsible for representation of mesh nodes
+ class TPointCoords: public virtual TBaseStructure
+ {
+ protected:
+ vtkIdType myDim; //!< Dimension of the nodal coordinates
+ vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh
+
+ //! An container for coordinates of the nodes
+ /*!
+ Usage of slices allow to minimize amount of memory to store the nodal coordinates and
+ provide unifirm way of conversation with this coordinates (independant from mesh dimension)
+ */
+ TCoordArray myCoord;
+ TVTKPoints myPoints; //!< VTK representation for the mesh nodes
+
+ public:
+ TPointCoords();
+
+ //! To initilize the class
+ void
+ Init(vtkIdType theNbPoints,
+ vtkIdType theDim);
+
+ //! Get slice of coordinates for defined node (const version)
+ TCCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) const;
+
+ //! Get slice of coordinates for defined node
+ TCoordSlice
+ GetCoordSlice(vtkIdType theNodeId);
+
+ vtkIdType
+ GetNbPoints() const { return myNbPoints; }
+
+ vtkIdType
+ GetDim() const { return myDim; }
+
+ vtkIdType
+ size() const { return GetNbPoints(); }
+
+ const TVTKPoints&
+ GetPoints() const { return myPoints;}
+ };
+ typedef SharedPtr<TPointCoords> PPointCoords;
+
+
+ //---------------------------------------------------------------
+ typedef TVector<vtkIdType> TVectorID;
+ typedef std::map<vtkIdType,vtkIdType> TObj2VTKID;
+
+ //! This class is responsible for representation of mesh nodes
+ /*!
+ In additition to its base functionlity it support mapping of VTK to object numeration and
+ keeps names for each of nodes.
+ */
+ class TNamedPointCoords: public virtual TPointCoords
+ {
+ protected:
+ typedef TVector<std::string> TPointsDim;
+ TPointsDim myPointsDim; //!< Keeps name of each dimension
+ TVectorID myVectorID; //!< Keeps object¶ numeration
+ TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
+
+ public:
+
+ //! To initilize the class (numeration of the nodes can be missed)
+ void
+ Init(vtkIdType theNbPoints,
+ vtkIdType theDim,
+ const TVectorID& theVectorID = TVectorID());
+
+ //! Get name for defined dimension
+ std::string&
+ GetName(vtkIdType theDim);
+
+ //! Get name for defined dimension (const version)
+ const std::string&
+ GetName(vtkIdType theDim) const;
+
+ //! Get object number for node by its VTK one
+ virtual
+ vtkIdType
+ GetObjID(vtkIdType theID) const;
+
+ //! Get VTK number for node by its object one
+ virtual
+ vtkIdType
+ GetVTKID(vtkIdType theID) const;
+
+ //! Get name of node by its object number
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const;
+ };
+ typedef SharedPtr<TNamedPointCoords> PNamedPointCoords;
+
+
+ //---------------------------------------------------------------
+ //! Specialize TMesh to provide VTK mapping for nodes
+ struct TMeshImpl: virtual TMesh,
+ virtual TIsVTKDone
+ {
+ PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
+
+ TVTKPoints myPoints; //!< Keeps VTK representation of the nodes
+ vtkIdType myNbPoints; //!< Keeps number of the nodes
+
+ TMeshImpl();
+ };
+ typedef SharedPtr<TMeshImpl> PMeshImpl;
+
+
+ //---------------------------------------------------------------
+ typedef TVector<vtkIdType> TSubMeshID;
+ typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus;
+
+ //! Specialize TSubProfile to provide VTK mapping
+ struct TSubProfileImpl: virtual TSubProfile,
+ virtual TSource
+ {
+ TSubProfileImpl();
+
+ EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to
+ std::string myName; //!< Keeps its name
+
+ //! Get object number of mesh cell by its VTK one
+ virtual
+ vtkIdType
+ GetElemObjID(int theVtkI) const;
+
+ //! Keeps status of the structure
+ /*!
+ In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre
+ in order to construct mesh for MED TIEMSTAMPS in uniform way.
+ */
+ ESubMeshStatus myStatus;
+ TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE
+ };
+ typedef SharedPtr<TSubProfileImpl> PSubProfileImpl;
+
+
+ //---------------------------------------------------------------
+ struct TMeshOnEntityImpl;
+
+ typedef std::map<vtkIdType,vtkIdType> TID2ID;
+ typedef TVector<PSubProfileImpl> TSubProfileArr;
+ typedef std::map<EGeometry,PSubProfileImpl> TGeom2SubProfile;
+
+ //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh
+ struct TProfileImpl: virtual TProfile,
+ virtual TAppendFilter
+ {
+ TProfileImpl();
+ bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not
+
+ //! Reimplement the TIDMapper::GetNodeObjID
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeCoord
+ virtual
+ float*
+ GetNodeCoord(vtkIdType theObjID);
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemCell
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
+ //! Reimplement the TIDMapper::GetVTKOutput
+ virtual
+ TVTKOutput*
+ GetVTKOutput();
+
+ //! Reimplement the TNamedIDMapper::GetNodeName
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const;
+
+ //! Reimplement the TNamedIDMapper::GetElemName
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const;
+
+ TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping
+ TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilter
+ PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh
+ TMeshOnEntityImpl* myMeshOnEntity; //<! Keeps backward reference to corresponding MED ENTITY mesh
+
+ TSource mySource; //!< Keeps VTK representation of the MED TIMESTAMP mesh
+ TGeom2SubProfile myGeom2SubProfile; //!< Keeps TSubProfiles according to their geometrical type
+ };
+ typedef SharedPtr<TProfileImpl> PProfileImpl;
+
+
+ //---------------------------------------------------------------
+ //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
+ struct TIDMapperFilter: virtual TMergeFilter
+ {
+ TAppendFilter myIDMapper; //!< Responsible for numbering
+ TSource mySource; //!< Keeps assigned data
+
+ //! Reimplement the TIDMapper::GetNodeObjID
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeCoord
+ virtual
+ float*
+ GetNodeCoord(vtkIdType theObjID);
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemCell
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
+ //! Reimplement the TIDMapper::GetVTKOutput
+ virtual
+ TVTKOutput*
+ GetVTKOutput();
+ };
+ typedef SharedPtr<TIDMapperFilter> PIDMapperFilter;
+
+
+ //---------------------------------------------------------------
+ struct TGaussImpl;
+ typedef SharedPtr<TGaussImpl> PGaussImpl;
+
+ //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping
+ struct TGaussImpl: virtual TGauss
+ {
+ EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs
+ std::string myName; //!< Keeps name of the MED GAUSS entity
+ vtkIdType myNbPoints; //<! Keeps number of points for the MED GAUSS entity
+
+ //! To define a way to implement more detail comparision of the TGaussSubMesh instances
+ virtual
+ void
+ LessThan(const PGaussImpl& theGauss,
+ bool& theResult) const;
+ };
+
+
+ //---------------------------------------------------------------
+ //! Specialize TGaussSubMesh to provide VTK mapping for the entity
+ struct TGaussSubMeshImpl: virtual TGaussSubMesh,
+ virtual TSource
+ {
+ TGaussSubMeshImpl();
+
+ //! To implement the TGaussPtsIDMapper::GetObjID
+ virtual
+ TGaussPointID
+ GetObjID(vtkIdType theID) const;
+
+ PGaussImpl myGauss; //<! Keep reference to corresponding TGauss structure
+
+ //! Keeps status of the structure
+ /*!
+ In some cases MED file does not use MED GAUSS, but at VISU creates corresponding data strucutre
+ in order to construct mesh for MED TIEMSTAMPS in uniform way.
+ */
+ ESubMeshStatus myStatus;
+
+ TPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points
+ };
+ typedef SharedPtr<TGaussSubMeshImpl> PGaussSubMeshImpl;
+
+
+ //---------------------------------------------------------------
+ typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
+ typedef std::map<EGeometry,PGaussSubMeshImpl> TGeom2GaussSubMesh;
+
+ //! Specialize TGaussMesh to provide VTK mapping for the entity
+ struct TGaussMeshImpl: virtual TGaussMesh,
+ virtual TAppendFilter
+ {
+ TGaussMeshImpl();
+
+ //! Reimplement the TGaussPtsIDMapper::GetObjID
+ virtual
+ TGaussPointID
+ GetObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetVTKOutput
+ virtual
+ TVTKOutput*
+ GetVTKOutput();
+
+ //! Reimplement the TGaussPtsIDMapper::GetParent
+ virtual
+ TNamedIDMapper*
+ GetParent();
+
+ TSource mySource; //!< Keeps VTK representation of the Gauss Points
+ TNamedIDMapper* myParent; //!< Refer to parent mesh
+ TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilter
+ TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type
+ };
+ typedef SharedPtr<TGaussMeshImpl> PGaussMeshImpl;
+
+ //---------------------------------------------------------------
+ //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
+ struct TGaussPtsIDFilter: virtual TIDMapperFilter,
+ virtual TGaussPtsIDMapper
+ {
+ PGaussPtsIDMapper myGaussPtsIDMapper;
+
+ //! Reimplement the TGaussPtsIDMapper::GetObjID
+ virtual
+ TGaussPointID
+ GetObjID(vtkIdType theID) const;
+
+ //! Reimplement the TGaussPtsIDMapper::GetParent
+ virtual
+ TNamedIDMapper*
+ GetParent();
+ };
+ typedef SharedPtr<TGaussPtsIDFilter> PGaussPtsIDFilter;
+
+
+ //---------------------------------------------------------------
+ typedef TVector<vtkIdType> TConnect;
+ typedef TVector<TConnect> TCell2Connect;
+
+ //! The class is responsible for mapping of cells of defined geometrical type
+ struct TSubMeshImpl: virtual TSource
+ {
+
+ //! To implement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! To implement the TNamedIDMapper::GetElemName
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const;
+
+ vtkIdType myStartID;
+ TCell2Connect myCell2Connect; //!< Contains connectivity for the cells
+ };
+ typedef SharedPtr<TSubMeshImpl> PSubMeshImpl;
+
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometry,PSubMeshImpl> TGeom2SubMesh;
+ typedef TVector<PSubMeshImpl> TSubMeshArr;
+
+ //! Specialize TMeshOnEntity to provide VTK mapping for the entity
+ struct TMeshOnEntityImpl: virtual TMeshOnEntity,
+ virtual TAppendFilter,
+ virtual TSizeCounter
+ {
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeObjID
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TNamedIDMapper::GetNodeName
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const;
+
+ //! Reimplement the TNamedIDMapper::GetElemName
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const;
+
+ TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
+ TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilter
+ PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
+
+ TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type
+ };
+ typedef SharedPtr<TMeshOnEntityImpl> PMeshOnEntityImpl;
+
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometry,TSubMeshID> TGeom2SubMeshID;
+
+ //! Specialize TFamily to provide VTK mapping for the entity
+ struct TFamilyImpl: virtual TFamily,
+ virtual TSource
+ {
+ //! Reimplement the TIDMapper::GetNodeObjID
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const ;
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const ;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetVTKOutput
+ virtual
+ TVTKOutput*
+ GetVTKOutput();
+
+ PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
+ TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
+ TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
+
+ TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
+ };
+ typedef SharedPtr<TFamilyImpl> PFamilyImpl;
+
+
+ //---------------------------------------------------------------
+ typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
+ typedef TVector<PFamilyImpl> TFamilyArr;
+
+ //! Specialize TGroup to provide VTK mapping for the entity
+ struct TGroupImpl: virtual TGroup,
+ virtual TAppendFilter
+ {
+ //! Calculate pair of values - number of cells and its size
+ TNbASizeCells
+ GetNbASizeCells() const;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeObjID
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const;
+
+ TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
+ TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilter
+ PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
+ };
+ typedef SharedPtr<TGroupImpl> PGroupImpl;
+
+
+ //---------------------------------------------------------------
+ typedef TVector<TMinMax> TMinMaxArr;
+
+ //! Specialize TField to provide VTK mapping for the entity
+ struct TFieldImpl: virtual TField
+ {
+ vtkIdType myDataSize; //!< Keeps size of the assigned data
+
+ TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
+
+ //! Implement the TField::GetMinMax
+ virtual
+ TMinMax
+ GetMinMax(vtkIdType theCompID);
+
+ //! To initialize the data structure
+ void
+ InitArrays(vtkIdType theNbComp);
+
+ TFieldImpl();
+ };
+ typedef SharedPtr<TFieldImpl> PFieldImpl;
+
+
+ //---------------------------------------------------------------
+ typedef TVector<float> TValue;
+ typedef TSlice<TValue> TValueSlice;
+ typedef TCSlice<TValue> TCValueSlice;
+
+ typedef TVector<TCValueSlice> TCValueSliceArr;
+ typedef TVector<TValueSlice> TValueSliceArr;
+
+ //! Define a container to get access to data assigned to mesh
+ struct TMeshValue
+ {
+ TValue myValue; //!< Keeps all values as one dimensional sequence
+
+ vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to
+ vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD
+ vtkIdType myNbGauss; //!< Defines number of Gauss Points
+ vtkIdType myStep; //! Internal variable
+
+ //! To intitilize the data strucutre
+ void
+ Init(vtkIdType theNbElem,
+ vtkIdType theNbGauss,
+ vtkIdType theNbComp);
+
+ //! To get assigned values first by Gauss Points and then by components (constant version)
+ TCValueSliceArr
+ GetGaussValueSliceArr(vtkIdType theElemId) const;
+
+ //! To get assigned values first by Gauss Points and then by components
+ TValueSliceArr
+ GetGaussValueSliceArr(vtkIdType theElemId);
+
+ //! To get assigned values first by components and then by Gauss Points (constant version)
+ TCValueSliceArr
+ GetCompValueSliceArr(vtkIdType theElemId) const;
+
+ //! To get assigned values first by components and then by Gauss Points
+ TValueSliceArr
+ GetCompValueSliceArr(vtkIdType theElemId);
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometry,TMeshValue> TGeom2Value;
+ typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
+
+ //! Specialize TValForTime to provide VTK mapping for the entity
+ struct TValForTimeImpl: virtual TValForTime
+ {
+ PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
+ PIDMapperFilter myIDMapperFilter; //!< Keep VTK representation for ordinary mesh and data
+ TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
+ TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
+
+ TValForTimeImpl();
+
+ //! Get mesh data for defined geometrical type (constant version)
+ const TMeshValue&
+ GetMeshValue(EGeometry theGeom) const;
+
+ //! Get mesh data for defined geometrical type
+ TMeshValue&
+ GetMeshValue(EGeometry theGeom);
+
+ //! Get number of Gauss Points for defined geometrical type
+ virtual
+ int
+ GetNbGauss(EGeometry theGeom) const;
+ };
+ typedef SharedPtr<TValForTimeImpl> PValForTimeImpl;
+}
+
+
+//! This class perfroms mapping of intermediate data strucutres into corresponding VTK representation
+/*!
+ It implements VISU_Convertor public interface and declare new pure virtual functions
+ to fill its intermediate data structure from a MED source
+*/
+class VISU_Convertor_impl: public VISU_Convertor
+{
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_impl();
-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);
-}
+ //! Just to define default behaviour
+ virtual
+ VISU_Convertor*
+ Build();
+
+ //! Just to define default behaviour
+ virtual
+ VISU_Convertor*
+ BuildEntities();
+
+ //! Just to define default behaviour
+ virtual
+ VISU_Convertor*
+ BuildFields();
+
+ //! Just to define default behaviour
+ virtual
+ VISU_Convertor*
+ BuildMinMax();
+
+ //! Just to define default behaviour
+ virtual
+ VISU_Convertor*
+ BuildGroups();
+
+ //! Implemention of the VISU_Convertor::GetSize
+ virtual
+ float
+ GetSize();
+
+ //! Implemention of the VISU_Convertor::GetMeshOnEntity
+ virtual
+ VISU::PNamedIDMapper
+ GetMeshOnEntity(const std::string& theMeshName,
+ const VISU::TEntity& theEntity);
-struct Med2vtk {
- med_geometrie_element medType;
- const char *medName;
- int medNbNodes;
- int vtkType;
- const char *vtkName;
- int vtkNbNodes;
+ //! Implemention of the VISU_Convertor::GetMeshOnEntitySize
+ virtual
+ float
+ GetMeshOnEntitySize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity);
+
+ //! Implemention of the VISU_Convertor::GetFamilyOnEntity
+ virtual
+ VISU::PIDMapper
+ GetFamilyOnEntity(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFamilyName);
+
+ //! Implemention of the VISU_Convertor::GetFamilyOnEntitySize
+ virtual
+ float
+ GetFamilyOnEntitySize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFamilyName);
+
+ //! Implemention of the VISU_Convertor::GetMeshOnGroup
+ virtual
+ VISU::PIDMapper
+ GetMeshOnGroup(const std::string& theMeshName,
+ const std::string& theGroupName);
+
+ //! Implemention of the VISU_Convertor::GetMeshOnGroupSize
+ virtual
+ float
+ GetMeshOnGroupSize(const std::string& theMeshName,
+ const std::string& theGroupName);
+
+ //! Implemention of the VISU_Convertor::GetTimeStampOnMesh
+ virtual
+ VISU::PIDMapper
+ GetTimeStampOnMesh(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum);
+
+ //! Implemention of the VISU_Convertor::GetTimeStampSize
+ virtual
+ float
+ GetTimeStampSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum);
+
+ //! Implemention of the VISU_Convertor::GetTimeStampOnGaussPts
+ virtual
+ VISU::PGaussPtsIDMapper
+ GetTimeStampOnGaussPts(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum);
+
+ //! Implemention of the VISU_Convertor::GetFieldOnMeshSize
+ virtual
+ float
+ GetFieldOnMeshSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName);
+
+ //! Implemention of the VISU_Convertor::GetField
+ virtual
+ const VISU::PField
+ GetField(const std::string& theMeshName,
+ VISU::TEntity theEntity,
+ const std::string& theFieldName);
+
+ //! Implemention of the VISU_Convertor::GetTimeStamp
+ virtual
+ const VISU::PValForTime
+ GetTimeStamp(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum);
+
+protected:
+ //! An utility method to find TMesh by its name
+ VISU::PMeshImpl
+ FindMesh(const std::string& theMeshName);
+
+ //! An utility method to find TMeshOnEntity by name of its parent mesh and entity
+ typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl> TFindMeshOnEntity;
+ TFindMeshOnEntity
+ FindMeshOnEntity(const std::string& theMeshName,
+ const VISU::TEntity& theEntity);
+
+ //! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name
+ typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindFamilyOnEntity;
+ TFindFamilyOnEntity
+ FindFamilyOnEntity(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFamilyName);
+
+ //! An utility method to find Group by name of its parent mesh and its name
+ typedef boost::tuple<VISU::PMeshImpl,VISU::PGroupImpl> TFindMeshOnGroup;
+ TFindMeshOnGroup
+ FindMeshOnGroup(const std::string& theMeshName,
+ const std::string& theGroupName);
+
+ //! An utility method to find TField by name of its parent mesh, corresponding entity and its name
+ 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);
+
+ //! An utility method to find TTimeStamp by name of its parent mesh, corresponding entity, field name and its number
+ 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);
+
+ VISU::TVTKOutput*
+ GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PFieldImpl& theField,
+ const VISU::PValForTimeImpl& theValForTime,
+ const VISU::PIDMapperFilter& theIDMapperFilter,
+ const VISU::PProfileImpl& theProfile,
+ const VISU::TEntity& theEntity);
+
+protected:
+ //! To fill intermeiate representation of TMeshOnEntity from a MED source
+ virtual
+ int
+ LoadMeshOnEntity(VISU::PMeshImpl theMesh,
+ VISU::PMeshOnEntityImpl theMeshOnEntity) = 0;
+
+ //! To fill intermeiate representation of TFamily from a MED source
+ virtual
+ int
+ LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
+ VISU::PMeshOnEntityImpl theMeshOnEntity,
+ VISU::PFamilyImpl theFamily) = 0;
+
+ //! To fill intermeiate representation of TGroup from a MED source
+ virtual
+ int
+ LoadMeshOnGroup(VISU::PMeshImpl theMesh,
+ const VISU::TFamilySet& theFamilySet) = 0;
+
+ //! To fill intermeiate representation of TValForTime for ordinary mesh from a MED source
+ virtual
+ int
+ LoadValForTimeOnMesh(VISU::PMeshImpl theMesh,
+ VISU::PMeshOnEntityImpl theMeshOnEntity,
+ VISU::PFieldImpl theField,
+ VISU::PValForTimeImpl theValForTime) = 0;
+
+ //! To fill intermeiate representation of TValForTime for mesh on Gauss Points from a MED source
+ virtual
+ int
+ LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh,
+ VISU::PMeshOnEntityImpl theMeshOnEntity,
+ VISU::PFieldImpl theField,
+ VISU::PValForTimeImpl theValForTime) = 0;
};
-extern Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE];
+
#endif