1 // Copyright (C) 2007-2008 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
23 // Author : Alexey PETROV
26 #ifndef VISU_Structures_impl_HeaderFile
27 #define VISU_Structures_impl_HeaderFile
30 \file VISU_Structures_impl.hxx
31 \brief The file contains definitions for basic classes of the implementation of VISU CONVERTER package
34 #include "VISUConvertor.hxx"
35 #include "VISU_Structures.hxx"
36 #include "VISU_ConvertorDef_impl.hxx"
43 //---------------------------------------------------------------
44 //! Define an utility base class which allow to keep calculated number of cells and their size
45 struct VISU_CONVERTOR_EXPORT TSizeCounter: virtual TIsVTKDone
48 vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass
49 vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass
53 //---------------------------------------------------------------
54 //! Define a container for VTK representation
55 class TPolyDataHolder: public virtual TSizeCounter
58 mutable PPolyData mySource;
62 //! This method allow to create corresponding VTK data set by demand (not at once)
70 //! Gets memory size used by the instance (bytes).
77 //---------------------------------------------------------------
78 //! Define a container for VTK representation
79 class VISU_CONVERTOR_EXPORT TUnstructuredGridHolder: public virtual TSizeCounter
82 TUnstructuredGridHolder();
84 //! This method allow to create corresponding VTK data set by demand (not at once)
85 const PUnstructuredGrid&
90 GetUnstructuredGridOutput();
92 //! Gets memory size used by the instance (bytes).
98 mutable PUnstructuredGrid mySource;
102 //---------------------------------------------------------------
103 //! Define an intermediate class which unifies memory size calculation
104 struct VISU_CONVERTOR_EXPORT TMemoryCheckIDMapper: public virtual TIsVTKDone,
105 public virtual TIDMapper
107 //! Gets memory size used by the instance (bytes).
114 //---------------------------------------------------------------
115 //! Define a container for VTK representation
117 This container allow to combine other VTK representation into single one.
119 class VISU_CONVERTOR_EXPORT TAppendFilterHolder: public virtual TMemoryCheckIDMapper
122 mutable PAppendFilter myFilter;
124 TAppendFilterHolder();
126 //! This method allow to create corresponding VTK filter by demand (not at once)
130 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
133 GetUnstructuredGridOutput();
137 This container allow to combine other VTK representation into single one.
139 //---------------------------------------------------------------
140 //! Define a container for VTK representation
142 This container allow to combine other VTK representation into single one.
144 class TAppendPolyDataHolder: public virtual TMemoryCheckIDMapper
147 mutable PAppendPolyData myFilter;
149 TAppendPolyDataHolder();
151 //! This method allow to create corresponding VTK filter by demand (not at once)
152 const PAppendPolyData&
155 //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput
162 //---------------------------------------------------------------
163 //! Define a container for VTK representation
165 This container allow to assign data to mesh and represent them into single VTK representation
167 class TMergeFilterHolder: public virtual TMemoryCheckIDMapper
170 mutable PMergeFilter myFilter;
172 TMergeFilterHolder();
174 //! This method allow to create corresponding VTK filter by demand (not at once)
178 //! Gets output of the filter as vtkDataSet
185 //---------------------------------------------------------------
186 //! Specialize TMesh to provide VTK mapping for nodes
187 struct VISU_CONVERTOR_EXPORT TMeshImpl: virtual TMesh,
190 PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
191 vtkIdType myNbPoints; //!< Keeps number of the nodes
202 GetPointSet(); //!< Gets initialized corresponding VTK structure
206 //---------------------------------------------------------------
207 typedef TVector<vtkIdType> TSubMeshID;
208 typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus;
210 //! Specialize TSubProfile to provide VTK mapping
211 struct VISU_CONVERTOR_EXPORT TSubProfileImpl: virtual TSubProfile,
212 virtual TUnstructuredGridHolder
216 EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to
217 std::string myName; //!< Keeps its name
219 //! Get object number of mesh cell by its VTK one
222 GetElemObjID(vtkIdType theVtkI) const;
224 //! Get cell VTK ID for corresponding object ID
227 GetElemVTKID(vtkIdType theID) const;
229 //! Gets memory size used by the instance (bytes).
234 //! Keeps status of the structure
236 In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre
237 in order to construct mesh for MED TIEMSTAMPS in uniform way.
239 ESubMeshStatus myStatus;
240 TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE
244 //---------------------------------------------------------------
245 typedef std::map<vtkIdType,vtkIdType> TID2ID;
246 typedef TVector<PSubProfileImpl> TSubProfileArr;
247 typedef std::map<EGeometry,PSubProfileImpl> TGeom2SubProfile;
249 //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh
250 struct VISU_CONVERTOR_EXPORT TProfileImpl: virtual TProfile,
251 virtual TAppendFilterHolder
254 bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not
256 //! Reimplement the TIDMapper::GetNodeObjID
259 GetNodeObjID(vtkIdType theID) const;
261 //! Reimplement the TIDMapper::GetNodeVTKID
264 GetNodeVTKID(vtkIdType theID) const;
266 //! Reimplement the TIDMapper::GetNodeCoord
268 vtkFloatingPointType*
269 GetNodeCoord(vtkIdType theObjID);
271 //! Reimplement the TIDMapper::GetElemObjID
274 GetElemObjID(vtkIdType theID) const;
276 //! Reimplement the TIDMapper::GetElemVTKID
279 GetElemVTKID(vtkIdType theID) const;
281 //! Reimplement the TIDMapper::GetElemCell
284 GetElemCell(vtkIdType theObjID);
286 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
289 GetUnstructuredGridOutput();
291 //! Gets memory size used by the instance (bytes).
296 //! Reimplement the TNamedIDMapper::GetNodeName
299 GetNodeName(vtkIdType theObjID) const;
301 //! Reimplement the TNamedIDMapper::GetElemName
304 GetElemName(vtkIdType theObjID) const;
306 TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping
307 TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilterHolder
308 PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh
309 TMeshOnEntityImpl* myMeshOnEntity; //<! Keeps backward reference to corresponding MED ENTITY mesh
311 TGeom2SubProfile myGeom2SubProfile; //!< Keeps TSubProfiles according to their geometrical type
315 //---------------------------------------------------------------
316 //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
317 struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder,
318 virtual TUnstructuredGridIDMapper
320 PAppendFilterHolder myIDMapper; //!< Responsible for numbering
321 PCommonCellsFilter myCommonCellsFilter;
323 TUnstructuredGridIDMapperImpl();
325 //! Reimplement the TIDMapper::GetNodeObjID
328 GetNodeObjID(vtkIdType theID) const;
330 //! Reimplement the TIDMapper::GetNodeVTKID
333 GetNodeVTKID(vtkIdType theID) const;
335 //! Reimplement the TIDMapper::GetNodeCoord
337 vtkFloatingPointType*
338 GetNodeCoord(vtkIdType theObjID);
340 //! Reimplement the TIDMapper::GetElemObjID
343 GetElemObjID(vtkIdType theID) const;
345 //! Reimplement the TIDMapper::GetElemVTKID
348 GetElemVTKID(vtkIdType theID) const;
350 //! Reimplement the TIDMapper::GetElemCell
353 GetElemCell(vtkIdType theObjID);
355 //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
358 GetUnstructuredGridOutput();
360 //! Reimplement the TIDMapper::GetOutput
365 //! Gets memory size used by the instance (bytes).
371 SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper );
379 TUnstructuredGridHolder mySource; //!< Keeps assigned data
382 //---------------------------------------------------------------
383 //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
384 struct TPolyDataIDMapperImpl: virtual TMergeFilterHolder,
385 virtual TPolyDataIDMapper
387 PAppendPolyDataHolder myIDMapper; //!< Responsible for numbering
389 //! Reimplement the TIDMapper::GetNodeObjID
392 GetNodeObjID(vtkIdType theID) const;
394 //! Reimplement the TIDMapper::GetNodeVTKID
397 GetNodeVTKID(vtkIdType theID) const;
399 //! Reimplement the TIDMapper::GetNodeCoord
401 vtkFloatingPointType*
402 GetNodeCoord(vtkIdType theObjID);
404 //! Reimplement the TIDMapper::GetElemObjID
407 GetElemObjID(vtkIdType theID) const;
409 //! Reimplement the TIDMapper::GetElemVTKID
412 GetElemVTKID(vtkIdType theID) const;
414 //! Reimplement the TIDMapper::GetElemCell
417 GetElemCell(vtkIdType theObjID);
419 //! Reimplement the TPolyDataIDMapper::GetPolyDataOutput
424 //! Reimplement the TIDMapper::GetOutput
429 //! Gets memory size used by the instance (bytes).
440 TPolyDataHolder mySource; //!< Keeps assigned data
444 //---------------------------------------------------------------
445 //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping
446 struct VISU_CONVERTOR_EXPORT TGaussImpl: virtual TGauss
448 EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs
449 std::string myName; //!< Keeps name of the MED GAUSS entity
450 vtkIdType myNbPoints; //<! Keeps number of points for the MED GAUSS entity
454 //! To define a way to implement more detail comparision of the TGaussSubMesh instances
457 LessThan(const PGaussImpl& theGauss,
458 bool& theResult) const;
462 //---------------------------------------------------------------
463 //! Specialize TGaussSubMesh to provide VTK mapping for the entity
464 struct VISU_CONVERTOR_EXPORT TGaussSubMeshImpl: virtual TGaussSubMesh,
465 virtual TPolyDataHolder
469 //! To implement the TGaussPtsIDMapper::GetObjID
472 GetObjID(vtkIdType theID) const;
474 //! To implement the TGaussPtsIDMapper::GetVTKID
477 GetVTKID(const TGaussPointID& theID) const;
481 GetElemObjID(vtkIdType theID) const;
485 GetElemVTKID(vtkIdType theID) const;
489 GetGlobalID(vtkIdType theID) const;
491 //! Gets memory size used by the instance (bytes).
496 PGaussImpl myGauss; //<! Keep reference to corresponding TGauss structure
498 //! Keeps status of the structure
500 In some cases MED file does not use MED GAUSS, but at VISU creates corresponding data strucutre
501 in order to construct mesh for MED TIEMSTAMPS in uniform way.
503 ESubMeshStatus myStatus;
506 PPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points
510 //---------------------------------------------------------------
511 typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
512 typedef std::map<EGeometry, PGaussSubMeshImpl> TGeom2GaussSubMesh;
514 //! Specialize TGaussMesh to provide VTK mapping for the entity
515 struct VISU_CONVERTOR_EXPORT TGaussMeshImpl: virtual TGaussMesh,
516 virtual TAppendPolyDataHolder
520 //! Reimplement the TGaussPtsIDMapper::GetObjID
523 GetObjID(vtkIdType theID) const;
525 //! Reimplements the TGaussPtsIDMapper::GetVTKID
528 GetVTKID(const TGaussPointID& theID) const;
530 //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput
535 //! Gets memory size used by the instance (bytes).
540 //! Reimplement the TGaussPtsIDMapper::GetParent
545 TNamedIDMapper* myParent; //!< Refer to parent mesh
546 TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilterHolder
547 TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type
551 //---------------------------------------------------------------
552 //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
553 struct VISU_CONVERTOR_EXPORT TGaussPtsIDFilter: virtual TPolyDataIDMapperImpl,
554 virtual TGaussPtsIDMapper
556 PGaussPtsIDMapper myGaussPtsIDMapper;
558 //! Reimplement the TGaussPtsIDMapper::GetObjID
561 GetObjID(vtkIdType theID) const;
563 //! Reimplements the TGaussPtsIDMapper::GetVTKID
566 GetVTKID(const TGaussPointID& theID) const;
568 //! Reimplements the TGaussPtsIDMapper::GetParent
569 //! Reimplement the TGaussPtsIDMapper::GetParent
574 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
579 //! Reimplement the TIDMapper::GetOutput
586 //---------------------------------------------------------------
587 typedef TVector<vtkIdType> TConnect;
588 typedef TVector<TConnect> TCell2Connect;
590 //! The class is responsible for mapping of cells of defined geometrical type
591 struct VISU_CONVERTOR_EXPORT TSubMeshImpl: virtual TUnstructuredGridHolder
595 //! Reimplements the TStructured::CopyStructure
598 CopyStructure( PStructured theStructured );
600 //! To implement the TIDMapper::GetElemObjID
603 GetElemObjID(vtkIdType theID) const;
605 //! To implement the TNamedIDMapper::GetElemName
608 GetElemName(vtkIdType theObjID) const;
610 //! Gets memory size used by the instance (bytes).
616 TCell2Connect myCell2Connect; //!< Contains connectivity for the cells
620 //---------------------------------------------------------------
621 typedef std::map<EGeometry,PSubMeshImpl> TGeom2SubMesh;
622 typedef TVector<PSubMeshImpl> TSubMeshArr;
624 //! Specialize TMeshOnEntity to provide VTK mapping for the entity
625 struct VISU_CONVERTOR_EXPORT TMeshOnEntityImpl: virtual TMeshOnEntity,
626 virtual TAppendFilterHolder,
631 //! Reimplements the TStructured::CopyStructure
634 CopyStructure( PStructured theStructured );
636 //! Reimplement the TIDMapper::GetNodeVTKID
639 GetNodeVTKID(vtkIdType theID) const;
641 //! Reimplement the TIDMapper::GetNodeObjID
644 GetNodeObjID(vtkIdType theID) const;
646 //! Reimplement the TIDMapper::GetElemVTKID
649 GetElemVTKID(vtkIdType theID) const;
651 //! Reimplement the TIDMapper::GetElemObjID
654 GetElemObjID(vtkIdType theID) const;
656 //! Reimplement the TNamedIDMapper::GetNodeName
659 GetNodeName(vtkIdType theObjID) const;
661 //! Reimplement the TNamedIDMapper::GetElemName
664 GetElemName(vtkIdType theObjID) const;
666 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
669 GetUnstructuredGridOutput();
671 //! Gets memory size used by the instance (bytes).
676 TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
677 TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilterHolder
678 PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
680 TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type
684 //---------------------------------------------------------------
685 typedef std::map<EGeometry,TSubMeshID> TGeom2SubMeshID;
687 //! Specialize TFamily to provide VTK mapping for the entity
688 struct VISU_CONVERTOR_EXPORT TFamilyImpl: virtual TFamily,
689 virtual TUnstructuredGridHolder
691 //! Reimplements the TStructured::CopyStructure
694 CopyStructure( PStructured theStructured );
696 //! Reimplement the TIDMapper::GetNodeObjID
698 GetNodeObjID(vtkIdType theID) const ;
700 //! Reimplement the TIDMapper::GetNodeVTKID
703 GetNodeVTKID(vtkIdType theID) const ;
705 //! Reimplement the TIDMapper::GetElemVTKID
708 GetElemVTKID(vtkIdType theID) const;
710 //! Reimplement the TIDMapper::GetElemObjID
713 GetElemObjID(vtkIdType theID) const;
715 //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
718 GetUnstructuredGridOutput();
720 //! Gets memory size used by the instance (bytes).
725 PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
726 TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
727 TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
729 TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
731 TNames myGroupNames; //!< Keeps names of groups that refer to the family
735 //---------------------------------------------------------------
736 typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
737 typedef TVector<PFamilyImpl> TFamilyArr;
739 //! Specialize TGroup to provide VTK mapping for the entity
740 struct VISU_CONVERTOR_EXPORT TGroupImpl: virtual TGroup,
741 virtual TAppendFilterHolder
743 //! Reimplements the TStructured::CopyStructure
746 CopyStructure( PStructured theStructured );
748 //! Calculate pair of values - number of cells and its size
750 GetNbASizeCells() const;
752 //! Reimplement the TIDMapper::GetElemVTKID
755 GetElemVTKID(vtkIdType theID) const;
757 //! Reimplement the TIDMapper::GetElemObjID
760 GetElemObjID(vtkIdType theID) const;
762 //! Reimplement the TIDMapper::GetNodeObjID
765 GetNodeObjID(vtkIdType theID) const;
767 //! Reimplement the TIDMapper::GetNodeVTKID
770 GetNodeVTKID(vtkIdType theID) const;
772 //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
775 GetUnstructuredGridOutput();
777 //! Gets memory size used by the instance (bytes).
782 TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
783 TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilterHolder
784 PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
788 //---------------------------------------------------------------
789 typedef TVector<TMinMax> TMinMaxArr;
791 typedef std::map<TName,TMinMax> TGroup2MinMax;
792 typedef TVector<TGroup2MinMax> TGroup2MinMaxArr;
794 //! Specialize TField to provide VTK mapping for the entity
795 struct VISU_CONVERTOR_EXPORT TFieldImpl: virtual TField
799 //! To initialize the data structure
801 Init(vtkIdType theNbComp,
802 vtkIdType theDataType);
804 //! Gets type idetificator of the mesh data.
808 //! Implement the TField::GetMinMax
811 GetMinMax(vtkIdType theCompID, const TNames& theGroupNames);
813 //! Implement the TField::GetAverageMinMax
816 GetAverageMinMax(vtkIdType theCompID, const TNames& theGroupNames);
818 vtkIdType myDataSize; //!< Keeps size of the assigned data
819 vtkIdType myDataType; //!< Keeps type idetificator of the mesh data
820 TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
821 TMinMaxArr myAverageMinMaxArr; //!< Keeps average by Gauss Points min/max values for each component of the MED FIELD
822 //!< If Nb of Gauss Points <=1 myAverageMinMaxArr equal myMinMaxArr
824 TGroup2MinMaxArr myGroup2MinMaxArr;
825 TGroup2MinMaxArr myGroup2AverageMinMaxArr;
829 //---------------------------------------------------------------
830 typedef std::map<EGeometry, PMeshValue> TGeom2MeshValue;
832 class TGeom2Value: public virtual TBaseStructure
834 TGeom2MeshValue myGeom2MeshValue;
837 //! Gets mesh data for defined geometrical type (constant version)
839 GetMeshValue(EGeometry theGeom) const;
841 //! Gets mesh data for defined geometrical type
843 GetMeshValue(EGeometry theGeom);
845 //! Gets container of the whole mesh data
849 //! Gets container of the whole mesh data (constant version)
850 const TGeom2MeshValue&
851 GetGeom2MeshValue() const;
853 //! Gets mesh data for the first geometry
855 GetFirstMeshValue() const;
859 //---------------------------------------------------------------
860 typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
862 //! Specialize TValForTime to provide VTK mapping for the entity
863 struct VISU_CONVERTOR_EXPORT TValForTimeImpl: virtual TValForTime
865 PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
866 PUnstructuredGridIDMapperImpl myUnstructuredGridIDMapper; //!< Keep VTK representation for ordinary mesh and data
867 TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
868 TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
875 const TGeom2MeshValue&
876 GetGeom2MeshValue() const;
878 //! Get mesh data for defined geometrical type (constant version)
880 GetMeshValue(EGeometry theGeom) const;
882 //! Get mesh data for defined geometrical type
884 GetMeshValue(EGeometry theGeom);
886 //! Gets mesh data for the first geometry
888 GetFirstMeshValue() const;
890 //! Get number of Gauss Points for defined geometrical type
893 GetNbGauss(EGeometry theGeom) const;
895 //! Gets memory size used by the instance (bytes).
902 //---------------------------------------------------------------