3 // Copyright (C) 2003 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 class VISU_CONVERTOR_EXPORT TCommonCellsFilterHolder: public virtual TMemoryCheckIDMapper
143 mutable PCommonCellsFilter myFilter;
144 mutable PMergeFilter myMergeFilter;
146 TCommonCellsFilterHolder();
148 //! This method allow to create corresponding VTK filter by demand (not at once)
149 const PCommonCellsFilter&
152 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
155 GetUnstructuredGridOutput();
161 //! if false, TIDCommonCellsFilter - same as TIDMapperFilter
162 //! if true, TIDCommonCellsFilter - use VISU_CommonCellsFilter
165 //! Vector of id mappers, which consist of meshonentity in next sequence:
166 //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY
167 PNamedIDMapperMap myMappers;
170 //---------------------------------------------------------------
171 //! Define a container for VTK representation
173 This container allow to combine other VTK representation into single one.
175 class TAppendPolyDataHolder: public virtual TMemoryCheckIDMapper
178 mutable PAppendPolyData myFilter;
180 TAppendPolyDataHolder();
182 //! This method allow to create corresponding VTK filter by demand (not at once)
183 const PAppendPolyData&
186 //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput
193 //---------------------------------------------------------------
194 //! Define a container for VTK representation
196 This container allow to assign data to mesh and represent them into single VTK representation
198 class TMergeFilterHolder: public virtual TMemoryCheckIDMapper
201 mutable PMergeFilter myFilter;
203 TMergeFilterHolder();
205 //! This method allow to create corresponding VTK filter by demand (not at once)
209 //! Gets output of the filter as vtkDataSet
216 //---------------------------------------------------------------
217 //! Specialize TMesh to provide VTK mapping for nodes
218 struct VISU_CONVERTOR_EXPORT TMeshImpl: virtual TMesh,
221 PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
222 vtkIdType myNbPoints; //!< Keeps number of the nodes
233 GetPointSet(); //!< Gets initialized corresponding VTK structure
237 //---------------------------------------------------------------
238 typedef TVector<vtkIdType> TSubMeshID;
239 typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus;
241 //! Specialize TSubProfile to provide VTK mapping
242 struct VISU_CONVERTOR_EXPORT TSubProfileImpl: virtual TSubProfile,
243 virtual TUnstructuredGridHolder
247 EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to
248 std::string myName; //!< Keeps its name
250 //! Get object number of mesh cell by its VTK one
253 GetElemObjID(int theVtkI) const;
255 //! Get cell VTK ID for corresponding object ID
258 GetElemVTKID(vtkIdType theID) const;
260 //! Gets memory size used by the instance (bytes).
265 //! Keeps status of the structure
267 In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre
268 in order to construct mesh for MED TIEMSTAMPS in uniform way.
270 ESubMeshStatus myStatus;
271 TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE
275 //---------------------------------------------------------------
276 typedef std::map<vtkIdType,vtkIdType> TID2ID;
277 typedef TVector<PSubProfileImpl> TSubProfileArr;
278 typedef std::map<EGeometry,PSubProfileImpl> TGeom2SubProfile;
280 //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh
281 struct VISU_CONVERTOR_EXPORT TProfileImpl: virtual TProfile,
282 virtual TAppendFilterHolder
285 bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not
287 //! Reimplement the TIDMapper::GetNodeObjID
290 GetNodeObjID(vtkIdType theID) const;
292 //! Reimplement the TIDMapper::GetNodeVTKID
295 GetNodeVTKID(vtkIdType theID) const;
297 //! Reimplement the TIDMapper::GetNodeCoord
299 vtkFloatingPointType*
300 GetNodeCoord(vtkIdType theObjID);
302 //! Reimplement the TIDMapper::GetElemObjID
305 GetElemObjID(vtkIdType theID) const;
307 //! Reimplement the TIDMapper::GetElemVTKID
310 GetElemVTKID(vtkIdType theID) const;
312 //! Reimplement the TIDMapper::GetElemCell
315 GetElemCell(vtkIdType theObjID);
317 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
320 GetUnstructuredGridOutput();
322 //! Gets memory size used by the instance (bytes).
327 //! Reimplement the TNamedIDMapper::GetNodeName
330 GetNodeName(vtkIdType theObjID) const;
332 //! Reimplement the TNamedIDMapper::GetElemName
335 GetElemName(vtkIdType theObjID) const;
337 TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping
338 TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilterHolder
339 PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh
340 TMeshOnEntityImpl* myMeshOnEntity; //<! Keeps backward reference to corresponding MED ENTITY mesh
342 TGeom2SubProfile myGeom2SubProfile; //!< Keeps TSubProfiles according to their geometrical type
346 //---------------------------------------------------------------
347 //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
348 struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder,
349 virtual TUnstructuredGridIDMapper
351 PAppendFilterHolder myIDMapper; //!< Responsible for numbering
352 PCommonCellsFilter myCommonCellsFilter;
353 TUnstructuredGridHolder mySource; //!< Keeps assigned data
355 TUnstructuredGridIDMapperImpl();
357 //! Reimplement the TIDMapper::GetNodeObjID
360 GetNodeObjID(vtkIdType theID) const;
362 //! Reimplement the TIDMapper::GetNodeVTKID
365 GetNodeVTKID(vtkIdType theID) const;
367 //! Reimplement the TIDMapper::GetNodeCoord
369 vtkFloatingPointType*
370 GetNodeCoord(vtkIdType theObjID);
372 //! Reimplement the TIDMapper::GetElemObjID
375 GetElemObjID(vtkIdType theID) const;
377 //! Reimplement the TIDMapper::GetElemVTKID
380 GetElemVTKID(vtkIdType theID) const;
382 //! Reimplement the TIDMapper::GetElemCell
385 GetElemCell(vtkIdType theObjID);
387 //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
390 GetUnstructuredGridOutput();
392 //! Reimplement the TIDMapper::GetOutput
397 //! Gets memory size used by the instance (bytes).
402 //! if false, Not using CommonCellsFilter
403 //! if true, Using CommonCellsFilter
406 //! Vector of id mappers, which consist of meshonentity in next sequence:
407 //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY
408 PNamedIDMapperMap myMappers;
411 //---------------------------------------------------------------
412 //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
413 struct TPolyDataIDMapperImpl: virtual TMergeFilterHolder,
414 virtual TPolyDataIDMapper
416 PAppendPolyDataHolder myIDMapper; //!< Responsible for numbering
417 TPolyDataHolder mySource; //!< Keeps assigned data
419 //! Reimplement the TIDMapper::GetNodeObjID
422 GetNodeObjID(vtkIdType theID) const;
424 //! Reimplement the TIDMapper::GetNodeVTKID
427 GetNodeVTKID(vtkIdType theID) const;
429 //! Reimplement the TIDMapper::GetNodeCoord
431 vtkFloatingPointType*
432 GetNodeCoord(vtkIdType theObjID);
434 //! Reimplement the TIDMapper::GetElemObjID
437 GetElemObjID(vtkIdType theID) const;
439 //! Reimplement the TIDMapper::GetElemVTKID
442 GetElemVTKID(vtkIdType theID) const;
444 //! Reimplement the TIDMapper::GetElemCell
447 GetElemCell(vtkIdType theObjID);
449 //! Reimplement the TPolyDataIDMapper::GetPolyDataOutput
454 //! Reimplement the TIDMapper::GetOutput
459 //! Gets memory size used by the instance (bytes).
466 //---------------------------------------------------------------
467 //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping
468 struct VISU_CONVERTOR_EXPORT TGaussImpl: virtual TGauss
470 EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs
471 std::string myName; //!< Keeps name of the MED GAUSS entity
472 vtkIdType myNbPoints; //<! Keeps number of points for the MED GAUSS entity
476 //! To define a way to implement more detail comparision of the TGaussSubMesh instances
479 LessThan(const PGaussImpl& theGauss,
480 bool& theResult) const;
484 //---------------------------------------------------------------
485 //! Specialize TGaussSubMesh to provide VTK mapping for the entity
486 struct VISU_CONVERTOR_EXPORT TGaussSubMeshImpl: virtual TGaussSubMesh,
487 virtual TPolyDataHolder
491 //! To implement the TGaussPtsIDMapper::GetObjID
494 GetObjID(vtkIdType theID) const;
496 //! To implement the TGaussPtsIDMapper::GetVTKID
499 GetVTKID(const TGaussPointID& theID) const;
503 GetElemObjID(vtkIdType theID) const;
507 GetElemVTKID(vtkIdType theID) const;
511 GetGlobalID(vtkIdType theID) const;
513 //! Gets memory size used by the instance (bytes).
518 PGaussImpl myGauss; //<! Keep reference to corresponding TGauss structure
520 //! Keeps status of the structure
522 In some cases MED file does not use MED GAUSS, but at VISU creates corresponding data strucutre
523 in order to construct mesh for MED TIEMSTAMPS in uniform way.
525 ESubMeshStatus myStatus;
528 PPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points
532 //---------------------------------------------------------------
533 typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
534 typedef std::map<EGeometry, PGaussSubMeshImpl> TGeom2GaussSubMesh;
536 //! Specialize TGaussMesh to provide VTK mapping for the entity
537 struct VISU_CONVERTOR_EXPORT TGaussMeshImpl: virtual TGaussMesh,
538 virtual TAppendPolyDataHolder
542 //! Reimplement the TGaussPtsIDMapper::GetObjID
545 GetObjID(vtkIdType theID) const;
547 //! Reimplements the TGaussPtsIDMapper::GetVTKID
550 GetVTKID(const TGaussPointID& theID) const;
552 //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput
557 //! Gets memory size used by the instance (bytes).
562 //! Reimplement the TGaussPtsIDMapper::GetParent
567 TNamedIDMapper* myParent; //!< Refer to parent mesh
568 TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilterHolder
569 TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type
573 //---------------------------------------------------------------
574 //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
575 struct VISU_CONVERTOR_EXPORT TGaussPtsIDFilter: virtual TPolyDataIDMapperImpl,
576 virtual TGaussPtsIDMapper
578 PGaussPtsIDMapper myGaussPtsIDMapper;
580 //! Reimplement the TGaussPtsIDMapper::GetObjID
583 GetObjID(vtkIdType theID) const;
585 //! Reimplements the TGaussPtsIDMapper::GetVTKID
588 GetVTKID(const TGaussPointID& theID) const;
590 //! Reimplements the TGaussPtsIDMapper::GetParent
595 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
600 //! Reimplement the TIDMapper::GetOutput
607 //---------------------------------------------------------------
608 typedef TVector<vtkIdType> TConnect;
609 typedef TVector<TConnect> TCell2Connect;
611 //! The class is responsible for mapping of cells of defined geometrical type
612 struct VISU_CONVERTOR_EXPORT TSubMeshImpl: virtual TUnstructuredGridHolder
616 //! To implement the TIDMapper::GetElemObjID
619 GetElemObjID(vtkIdType theID) const;
621 //! To implement the TNamedIDMapper::GetElemName
624 GetElemName(vtkIdType theObjID) const;
626 //! Gets memory size used by the instance (bytes).
632 TCell2Connect myCell2Connect; //!< Contains connectivity for the cells
636 //---------------------------------------------------------------
637 typedef std::map<EGeometry,PSubMeshImpl> TGeom2SubMesh;
638 typedef TVector<PSubMeshImpl> TSubMeshArr;
640 //! Specialize TMeshOnEntity to provide VTK mapping for the entity
641 struct VISU_CONVERTOR_EXPORT TMeshOnEntityImpl: virtual TMeshOnEntity,
642 virtual TAppendFilterHolder,
647 //! Reimplement the TIDMapper::GetNodeVTKID
650 GetNodeVTKID(vtkIdType theID) const;
652 //! Reimplement the TIDMapper::GetNodeObjID
655 GetNodeObjID(vtkIdType theID) const;
657 //! Reimplement the TIDMapper::GetElemVTKID
660 GetElemVTKID(vtkIdType theID) const;
662 //! Reimplement the TIDMapper::GetElemObjID
665 GetElemObjID(vtkIdType theID) const;
667 //! Reimplement the TNamedIDMapper::GetNodeName
670 GetNodeName(vtkIdType theObjID) const;
672 //! Reimplement the TNamedIDMapper::GetElemName
675 GetElemName(vtkIdType theObjID) const;
677 //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
680 GetUnstructuredGridOutput();
682 //! Gets memory size used by the instance (bytes).
687 TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
688 TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilterHolder
689 PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
691 TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type
695 //---------------------------------------------------------------
696 typedef std::map<EGeometry,TSubMeshID> TGeom2SubMeshID;
698 //! Specialize TFamily to provide VTK mapping for the entity
699 struct VISU_CONVERTOR_EXPORT TFamilyImpl: virtual TFamily,
700 virtual TUnstructuredGridHolder
702 //! Reimplement the TIDMapper::GetNodeObjID
704 GetNodeObjID(vtkIdType theID) const ;
706 //! Reimplement the TIDMapper::GetNodeVTKID
709 GetNodeVTKID(vtkIdType theID) const ;
711 //! Reimplement the TIDMapper::GetElemVTKID
714 GetElemVTKID(vtkIdType theID) const;
716 //! Reimplement the TIDMapper::GetElemObjID
719 GetElemObjID(vtkIdType theID) const;
721 //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
724 GetUnstructuredGridOutput();
726 //! Gets memory size used by the instance (bytes).
731 PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
732 TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
733 TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
735 TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
739 //---------------------------------------------------------------
740 typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
741 typedef TVector<PFamilyImpl> TFamilyArr;
743 //! Specialize TGroup to provide VTK mapping for the entity
744 struct VISU_CONVERTOR_EXPORT TGroupImpl: virtual TGroup,
745 virtual TAppendFilterHolder
747 //! Calculate pair of values - number of cells and its size
749 GetNbASizeCells() const;
751 //! Reimplement the TIDMapper::GetElemVTKID
754 GetElemVTKID(vtkIdType theID) const;
756 //! Reimplement the TIDMapper::GetElemObjID
759 GetElemObjID(vtkIdType theID) const;
761 //! Reimplement the TIDMapper::GetNodeObjID
764 GetNodeObjID(vtkIdType theID) const;
766 //! Reimplement the TIDMapper::GetNodeVTKID
769 GetNodeVTKID(vtkIdType theID) const;
771 //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
774 GetUnstructuredGridOutput();
776 //! Gets memory size used by the instance (bytes).
781 TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
782 TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilterHolder
783 PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
787 //---------------------------------------------------------------
788 typedef TVector<TMinMax> TMinMaxArr;
790 //! Specialize TField to provide VTK mapping for the entity
791 struct VISU_CONVERTOR_EXPORT TFieldImpl: virtual TField
795 //! To initialize the data structure
797 Init(vtkIdType theNbComp,
798 vtkIdType theDataType);
800 //! Gets type idetificator of the mesh data.
804 //! Implement the TField::GetMinMax
807 GetMinMax(vtkIdType theCompID);
809 vtkIdType myDataSize; //!< Keeps size of the assigned data
810 vtkIdType myDataType; //!< Keeps type idetificator of the mesh data
811 TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
815 //---------------------------------------------------------------
816 typedef std::map<EGeometry, PMeshValue> TGeom2MeshValue;
818 class TGeom2Value: public virtual TBaseStructure
820 TGeom2MeshValue myGeom2MeshValue;
823 //! Gets mesh data for defined geometrical type (constant version)
825 GetMeshValue(EGeometry theGeom) const;
827 //! Gets mesh data for defined geometrical type
829 GetMeshValue(EGeometry theGeom);
831 //! Gets container of the whole mesh data
835 //! Gets container of the whole mesh data (constant version)
836 const TGeom2MeshValue&
837 GetGeom2MeshValue() const;
839 //! Gets mesh data for the first geometry
841 GetFirstMeshValue() const;
845 //---------------------------------------------------------------
846 typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
848 //! Specialize TValForTime to provide VTK mapping for the entity
849 struct VISU_CONVERTOR_EXPORT TValForTimeImpl: virtual TValForTime
851 PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
852 PUnstructuredGridIDMapperImpl myUnstructuredGridIDMapper; //!< Keep VTK representation for ordinary mesh and data
853 TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
854 TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
861 const TGeom2MeshValue&
862 GetGeom2MeshValue() const;
864 //! Get mesh data for defined geometrical type (constant version)
866 GetMeshValue(EGeometry theGeom) const;
868 //! Get mesh data for defined geometrical type
870 GetMeshValue(EGeometry theGeom);
872 //! Gets mesh data for the first geometry
874 GetFirstMeshValue() const;
876 //! Get number of Gauss Points for defined geometrical type
879 GetNbGauss(EGeometry theGeom) const;
881 //! Gets memory size used by the instance (bytes).
888 //---------------------------------------------------------------