1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // Author : Alexey PETROV
27 #ifndef VISU_Structures_impl_HeaderFile
28 #define VISU_Structures_impl_HeaderFile
31 \file VISU_Structures_impl.hxx
32 \brief The file contains definitions for basic classes of the implementation of VISU CONVERTER package
35 #include "VISUConvertor.hxx"
36 #include "VISU_Structures.hxx"
37 #include "VISU_ConvertorDef_impl.hxx"
44 //---------------------------------------------------------------
45 //! Define an utility base class which allow to keep calculated number of cells and their size
46 struct VISU_CONVERTOR_EXPORT TSizeCounter: virtual TIsVTKDone
49 vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass
50 vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass
54 //---------------------------------------------------------------
55 //! Define a container for VTK representation
56 class TPolyDataHolder: public virtual TSizeCounter
59 mutable PPolyData mySource;
63 //! This method allow to create corresponding VTK data set by demand (not at once)
71 //! Gets memory size used by the instance (bytes).
78 //---------------------------------------------------------------
79 //! Define a container for VTK representation
80 class VISU_CONVERTOR_EXPORT TUnstructuredGridHolder: public virtual TSizeCounter
83 TUnstructuredGridHolder();
85 //! This method allow to create corresponding VTK data set by demand (not at once)
86 const PUnstructuredGrid&
91 GetUnstructuredGridOutput();
93 //! Gets memory size used by the instance (bytes).
99 mutable PUnstructuredGrid mySource;
103 //---------------------------------------------------------------
104 //! Define an intermediate class which unifies memory size calculation
105 struct VISU_CONVERTOR_EXPORT TMemoryCheckIDMapper: public virtual TIsVTKDone,
106 public virtual TIDMapper
108 //! Gets memory size used by the instance (bytes).
115 //---------------------------------------------------------------
116 //! Define a container for VTK representation
118 This container allow to combine other VTK representation into single one.
120 class VISU_CONVERTOR_EXPORT TAppendFilterHolder: public virtual TMemoryCheckIDMapper
123 mutable PAppendFilter myFilter;
125 TAppendFilterHolder();
127 //! This method allow to create corresponding VTK filter by demand (not at once)
131 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
134 GetUnstructuredGridOutput();
138 This container allow to combine other VTK representation into single one.
140 //---------------------------------------------------------------
141 //! Define a container for VTK representation
143 This container allow to combine other VTK representation into single one.
145 class TAppendPolyDataHolder: public virtual TMemoryCheckIDMapper
148 mutable PAppendPolyData myFilter;
150 TAppendPolyDataHolder();
152 //! This method allow to create corresponding VTK filter by demand (not at once)
153 const PAppendPolyData&
156 //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput
163 //---------------------------------------------------------------
164 //! Define a container for VTK representation
166 This container allow to assign data to mesh and represent them into single VTK representation
168 class TMergeFilterHolder: public virtual TMemoryCheckIDMapper
171 mutable PMergeFilter myFilter;
173 TMergeFilterHolder();
175 //! This method allow to create corresponding VTK filter by demand (not at once)
179 //! Gets output of the filter as vtkDataSet
186 //---------------------------------------------------------------
187 //! Specialize TMesh to provide VTK mapping for nodes
188 struct VISU_CONVERTOR_EXPORT TMeshImpl: virtual TMesh,
191 PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
192 vtkIdType myNbPoints; //!< Keeps number of the nodes
203 GetPointSet(); //!< Gets initialized corresponding VTK structure
207 //---------------------------------------------------------------
208 typedef TVector<vtkIdType> TSubMeshID;
209 typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus;
211 //! Specialize TSubProfile to provide VTK mapping
212 struct VISU_CONVERTOR_EXPORT TSubProfileImpl: virtual TSubProfile,
213 virtual TUnstructuredGridHolder
217 EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to
218 std::string myName; //!< Keeps its name
220 //! Get object number of mesh cell by its VTK one
223 GetElemObjID(vtkIdType theVtkI) const;
225 //! Get cell VTK ID for corresponding object ID
228 GetElemVTKID(vtkIdType theID) const;
230 //! Gets memory size used by the instance (bytes).
235 //! Keeps status of the structure
237 In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre
238 in order to construct mesh for MED TIEMSTAMPS in uniform way.
240 ESubMeshStatus myStatus;
241 TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE
245 //---------------------------------------------------------------
246 typedef std::map<vtkIdType,vtkIdType> TID2ID;
247 typedef TVector<PSubProfileImpl> TSubProfileArr;
248 typedef std::map<EGeometry,PSubProfileImpl> TGeom2SubProfile;
250 //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh
251 struct VISU_CONVERTOR_EXPORT TProfileImpl: virtual TProfile,
252 virtual TAppendFilterHolder
255 bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not
257 //! Reimplement the TIDMapper::GetNodeObjID
260 GetNodeObjID(vtkIdType theID) const;
262 //! Reimplement the TIDMapper::GetNodeVTKID
265 GetNodeVTKID(vtkIdType theID) const;
267 //! Reimplement the TIDMapper::GetNodeCoord
269 vtkFloatingPointType*
270 GetNodeCoord(vtkIdType theObjID);
272 //! Reimplement the TIDMapper::GetElemObjID
275 GetElemObjID(vtkIdType theID) const;
277 //! Reimplement the TIDMapper::GetElemVTKID
280 GetElemVTKID(vtkIdType theID) const;
282 //! Reimplement the TIDMapper::GetElemCell
285 GetElemCell(vtkIdType theObjID);
287 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
290 GetUnstructuredGridOutput();
292 //! Gets memory size used by the instance (bytes).
297 //! Reimplement the TNamedIDMapper::GetNodeName
300 GetNodeName(vtkIdType theObjID) const;
302 //! Reimplement the TNamedIDMapper::GetElemName
305 GetElemName(vtkIdType theObjID) const;
307 TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping
308 TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilterHolder
309 PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh
310 TMeshOnEntityImpl* myMeshOnEntity; //<! Keeps backward reference to corresponding MED ENTITY mesh
312 TGeom2SubProfile myGeom2SubProfile; //!< Keeps TSubProfiles according to their geometrical type
316 //---------------------------------------------------------------
317 //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
318 struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder,
319 virtual TUnstructuredGridIDMapper
321 PAppendFilterHolder myIDMapper; //!< Responsible for numbering
322 PCommonCellsFilter myCommonCellsFilter;
324 TUnstructuredGridIDMapperImpl();
326 //! Reimplement the TIDMapper::GetNodeObjID
329 GetNodeObjID(vtkIdType theID) const;
331 //! Reimplement the TIDMapper::GetNodeVTKID
334 GetNodeVTKID(vtkIdType theID) const;
336 //! Reimplement the TIDMapper::GetNodeCoord
338 vtkFloatingPointType*
339 GetNodeCoord(vtkIdType theObjID);
341 //! Reimplement the TIDMapper::GetElemObjID
344 GetElemObjID(vtkIdType theID) const;
346 //! Reimplement the TIDMapper::GetElemVTKID
349 GetElemVTKID(vtkIdType theID) const;
351 //! Reimplement the TIDMapper::GetElemCell
354 GetElemCell(vtkIdType theObjID);
356 //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
359 GetUnstructuredGridOutput();
361 //! Reimplement the TIDMapper::GetOutput
366 //! Gets memory size used by the instance (bytes).
372 SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper );
380 TUnstructuredGridHolder mySource; //!< Keeps assigned data
383 //---------------------------------------------------------------
384 //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
385 struct TPolyDataIDMapperImpl: virtual TMergeFilterHolder,
386 virtual TPolyDataIDMapper
388 PAppendPolyDataHolder myIDMapper; //!< Responsible for numbering
390 //! Reimplement the TIDMapper::GetNodeObjID
393 GetNodeObjID(vtkIdType theID) const;
395 //! Reimplement the TIDMapper::GetNodeVTKID
398 GetNodeVTKID(vtkIdType theID) const;
400 //! Reimplement the TIDMapper::GetNodeCoord
402 vtkFloatingPointType*
403 GetNodeCoord(vtkIdType theObjID);
405 //! Reimplement the TIDMapper::GetElemObjID
408 GetElemObjID(vtkIdType theID) const;
410 //! Reimplement the TIDMapper::GetElemVTKID
413 GetElemVTKID(vtkIdType theID) const;
415 //! Reimplement the TIDMapper::GetElemCell
418 GetElemCell(vtkIdType theObjID);
420 //! Reimplement the TPolyDataIDMapper::GetPolyDataOutput
425 //! Reimplement the TIDMapper::GetOutput
430 //! Gets memory size used by the instance (bytes).
441 TPolyDataHolder mySource; //!< Keeps assigned data
445 //---------------------------------------------------------------
446 //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping
447 struct VISU_CONVERTOR_EXPORT TGaussImpl: virtual TGauss
449 EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs
450 std::string myName; //!< Keeps name of the MED GAUSS entity
451 vtkIdType myNbPoints; //<! Keeps number of points for the MED GAUSS entity
455 //! To define a way to implement more detail comparision of the TGaussSubMesh instances
458 LessThan(const PGaussImpl& theGauss,
459 bool& theResult) const;
463 //---------------------------------------------------------------
464 //! Specialize TGaussSubMesh to provide VTK mapping for the entity
465 struct VISU_CONVERTOR_EXPORT TGaussSubMeshImpl: virtual TGaussSubMesh,
466 virtual TPolyDataHolder
470 //! To implement the TGaussPtsIDMapper::GetObjID
473 GetObjID(vtkIdType theID) const;
475 //! To implement the TGaussPtsIDMapper::GetVTKID
478 GetVTKID(const TGaussPointID& theID) const;
482 GetElemObjID(vtkIdType theID) const;
486 GetElemVTKID(vtkIdType theID) const;
490 GetGlobalID(vtkIdType theID) const;
492 //! Gets memory size used by the instance (bytes).
497 PGaussImpl myGauss; //<! Keep reference to corresponding TGauss structure
499 //! Keeps status of the structure
501 In some cases MED file does not use MED GAUSS, but at VISU creates corresponding data strucutre
502 in order to construct mesh for MED TIEMSTAMPS in uniform way.
504 ESubMeshStatus myStatus;
507 PPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points
511 //---------------------------------------------------------------
512 typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
513 typedef std::map<EGeometry, PGaussSubMeshImpl> TGeom2GaussSubMesh;
515 //! Specialize TGaussMesh to provide VTK mapping for the entity
516 struct VISU_CONVERTOR_EXPORT TGaussMeshImpl: virtual TGaussMesh,
517 virtual TAppendPolyDataHolder
521 //! Reimplement the TGaussPtsIDMapper::GetObjID
524 GetObjID(vtkIdType theID) const;
526 //! Reimplements the TGaussPtsIDMapper::GetVTKID
529 GetVTKID(const TGaussPointID& theID) const;
531 //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput
536 //! Gets memory size used by the instance (bytes).
541 //! Reimplement the TGaussPtsIDMapper::GetParent
546 TNamedIDMapper* myParent; //!< Refer to parent mesh
547 TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilterHolder
548 TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type
552 //---------------------------------------------------------------
553 //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
554 struct VISU_CONVERTOR_EXPORT TGaussPtsIDFilter: virtual TPolyDataIDMapperImpl,
555 virtual TGaussPtsIDMapper
557 PGaussPtsIDMapper myGaussPtsIDMapper;
559 //! Reimplement the TGaussPtsIDMapper::GetObjID
562 GetObjID(vtkIdType theID) const;
564 //! Reimplements the TGaussPtsIDMapper::GetVTKID
567 GetVTKID(const TGaussPointID& theID) const;
569 //! Reimplements the TGaussPtsIDMapper::GetParent
570 //! Reimplement the TGaussPtsIDMapper::GetParent
575 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
580 //! Reimplement the TIDMapper::GetOutput
587 //---------------------------------------------------------------
588 typedef TVector<vtkIdType> TConnect;
589 typedef TVector<TConnect> TCell2Connect;
591 //! The class is responsible for mapping of cells of defined geometrical type
592 struct VISU_CONVERTOR_EXPORT TSubMeshImpl: virtual TUnstructuredGridHolder
596 //! Reimplements the TStructured::CopyStructure
599 CopyStructure( PStructured theStructured );
601 //! To implement the TIDMapper::GetElemObjID
604 GetElemObjID(vtkIdType theID) const;
606 //! To implement the TNamedIDMapper::GetElemName
609 GetElemName(vtkIdType theObjID) const;
611 //! Gets memory size used by the instance (bytes).
617 TCell2Connect myCell2Connect; //!< Contains connectivity for the cells
621 //---------------------------------------------------------------
622 typedef std::map<EGeometry,PSubMeshImpl> TGeom2SubMesh;
623 typedef TVector<PSubMeshImpl> TSubMeshArr;
625 //! Specialize TMeshOnEntity to provide VTK mapping for the entity
626 struct VISU_CONVERTOR_EXPORT TMeshOnEntityImpl: virtual TMeshOnEntity,
627 virtual TAppendFilterHolder,
632 //! Reimplements the TStructured::CopyStructure
635 CopyStructure( PStructured theStructured );
637 //! Reimplement the TIDMapper::GetNodeVTKID
640 GetNodeVTKID(vtkIdType theID) const;
642 //! Reimplement the TIDMapper::GetNodeObjID
645 GetNodeObjID(vtkIdType theID) const;
647 //! Reimplement the TIDMapper::GetElemVTKID
650 GetElemVTKID(vtkIdType theID) const;
652 //! Reimplement the TIDMapper::GetElemObjID
655 GetElemObjID(vtkIdType theID) const;
657 //! Reimplement the TNamedIDMapper::GetNodeName
660 GetNodeName(vtkIdType theObjID) const;
662 //! Reimplement the TNamedIDMapper::GetElemName
665 GetElemName(vtkIdType theObjID) const;
667 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
670 GetUnstructuredGridOutput();
672 //! Gets memory size used by the instance (bytes).
677 TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
678 TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilterHolder
679 PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
681 TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type
685 //---------------------------------------------------------------
686 typedef std::map<EGeometry,TSubMeshID> TGeom2SubMeshID;
688 //! Specialize TFamily to provide VTK mapping for the entity
689 struct VISU_CONVERTOR_EXPORT TFamilyImpl: virtual TFamily,
690 virtual TUnstructuredGridHolder
692 //! Reimplements the TStructured::CopyStructure
695 CopyStructure( PStructured theStructured );
697 //! Reimplement the TIDMapper::GetNodeObjID
699 GetNodeObjID(vtkIdType theID) const ;
701 //! Reimplement the TIDMapper::GetNodeVTKID
704 GetNodeVTKID(vtkIdType theID) const ;
706 //! Reimplement the TIDMapper::GetElemVTKID
709 GetElemVTKID(vtkIdType theID) const;
711 //! Reimplement the TIDMapper::GetElemObjID
714 GetElemObjID(vtkIdType theID) const;
716 //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
719 GetUnstructuredGridOutput();
721 //! Gets memory size used by the instance (bytes).
726 PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
727 TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
728 TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
730 TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
732 TNames myGroupNames; //!< Keeps names of groups that refer to the family
736 //---------------------------------------------------------------
737 typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
738 typedef TVector<PFamilyImpl> TFamilyArr;
740 //! Specialize TGroup to provide VTK mapping for the entity
741 struct VISU_CONVERTOR_EXPORT TGroupImpl: virtual TGroup,
742 virtual TAppendFilterHolder
744 //! Reimplements the TStructured::CopyStructure
747 CopyStructure( PStructured theStructured );
749 //! Calculate pair of values - number of cells and its size
751 GetNbASizeCells() const;
753 //! Reimplement the TIDMapper::GetElemVTKID
756 GetElemVTKID(vtkIdType theID) const;
758 //! Reimplement the TIDMapper::GetElemObjID
761 GetElemObjID(vtkIdType theID) const;
763 //! Reimplement the TIDMapper::GetNodeObjID
766 GetNodeObjID(vtkIdType theID) const;
768 //! Reimplement the TIDMapper::GetNodeVTKID
771 GetNodeVTKID(vtkIdType theID) const;
773 //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
776 GetUnstructuredGridOutput();
778 //! Gets memory size used by the instance (bytes).
783 TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
784 TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilterHolder
785 PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
789 //---------------------------------------------------------------
790 typedef TVector<TMinMax> TComp2MinMax;
791 typedef TVector<TComp2MinMax> TMetric2Comp2MinMax;
793 typedef std::map<TName,TMinMax> TGroup2MinMax;
794 typedef TVector<TGroup2MinMax> TComp2Group2MinMax;
795 typedef TVector<TComp2Group2MinMax> TMetric2Comp2Group2MinMax;
797 //! Specialize TField to provide VTK mapping for the entity
798 struct VISU_CONVERTOR_EXPORT TFieldImpl: virtual TField
802 //! To initialize the data structure
804 Init(vtkIdType theNbComp,
805 vtkIdType theDataType);
807 //! Gets type idetificator of the mesh data.
811 //! Implement the TField::GetMinMax
814 GetMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric = VISU::AVERAGE_METRIC);
816 //! Implement the TField::GetAverageMinMax
819 GetAverageMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric = VISU::AVERAGE_METRIC);
821 vtkIdType myDataSize; //!< Keeps size of the assigned data
822 vtkIdType myDataType; //!< Keeps type idetificator of the mesh data
823 TMetric2Comp2MinMax myMetric2Comp2MinMax; //!< Keeps min/max values for each component of the MED FIELD
824 TMetric2Comp2MinMax myMetric2Comp2AverageMinMax; //!< Keeps average by Gauss Points min/max values for each component of the MED FIELD
825 //!< If Nb of Gauss Points <=1 myAverageMinMaxArr equal myMinMaxArr
827 TMetric2Comp2Group2MinMax myMetric2Comp2Group2MinMax;
828 TMetric2Comp2Group2MinMax myMetric2Comp2Group2AverageMinMax;
832 //---------------------------------------------------------------
833 typedef std::map<EGeometry, PMeshValue> TGeom2MeshValue;
835 class TGeom2Value: public virtual TBaseStructure
837 TGeom2MeshValue myGeom2MeshValue;
840 //! Gets mesh data for defined geometrical type (constant version)
842 GetMeshValue(EGeometry theGeom) const;
844 //! Gets mesh data for defined geometrical type
846 GetMeshValue(EGeometry theGeom);
848 //! Gets container of the whole mesh data
852 //! Gets container of the whole mesh data (constant version)
853 const TGeom2MeshValue&
854 GetGeom2MeshValue() const;
856 //! Gets mesh data for the first geometry
858 GetFirstMeshValue() const;
862 //---------------------------------------------------------------
863 typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
865 //! Specialize TValForTime to provide VTK mapping for the entity
866 struct VISU_CONVERTOR_EXPORT TValForTimeImpl: virtual TValForTime
868 PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
869 PUnstructuredGridIDMapperImpl myUnstructuredGridIDMapper; //!< Keep VTK representation for ordinary mesh and data
870 TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
871 TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
878 const TGeom2MeshValue&
879 GetGeom2MeshValue() const;
881 //! Get mesh data for defined geometrical type (constant version)
883 GetMeshValue(EGeometry theGeom) const;
885 //! Get mesh data for defined geometrical type
887 GetMeshValue(EGeometry theGeom);
889 //! Gets mesh data for the first geometry
891 GetFirstMeshValue() const;
893 //! Get number of Gauss Points for defined geometrical type
896 GetNbGauss(EGeometry theGeom) const;
898 //! Get maximum number of Gauss Points among all geometrical types (provided for convenience)
901 GetMaxNbGauss() const;
903 //! Gets memory size used by the instance (bytes).
910 //---------------------------------------------------------------