Salome HOME
adding some castem mesh file to test the GIBI driver of Med Memory.
[modules/med.git] / src / MEDMEM / MEDMEM_DriverTools.hxx
1 #ifndef DRIVERTOOLS_HXX
2 #define DRIVERTOOLS_HXX
3
4
5 #include "MEDMEM_define.hxx"
6 #include "MEDMEM_Exception.hxx"
7 #include <string>
8 #include <vector>
9 #include <set>
10 #include <list>
11 #include <map>
12 #include <iostream>
13
14 class MESH;
15 class CONNECTIVITY;
16 class COORDINATE;
17 class GROUP;
18
19 struct _noeud
20 {
21     mutable int number;
22     std::vector<double> coord;
23 };
24
25 struct _maille
26 {
27     typedef std::map<int,_noeud>::iterator iter;
28     MED_EN::medGeometryElement geometricType;
29     std::vector< iter > sommets;
30     mutable unsigned ordre; // l'ordre est fixé après insertion dans le set, et ne change ni l'état, ni l'ordre -> mutable
31
32     _maille(MED_EN::medGeometryElement _geometricType, size_t nelem) : geometricType(_geometricType),ordre(0)
33     {
34         sommets.reserve(nelem);
35     };
36     int dimension() const // retourne la dimension de la maille
37     {
38         return geometricType/100;
39     };
40     bool operator < (const _maille& ma) const;
41     MED_EN::medEntityMesh getEntity(const int meshDimension) const throw (MEDEXCEPTION);
42 };
43
44 struct _mailleIteratorCompare // pour ordonner le set d'iterateurs sur mailles
45 {
46     bool operator () (std::set<_maille>::iterator i1, std::set<_maille>::iterator i2)
47     {
48         return *i1<*i2;
49     }
50 };
51
52 struct _groupe
53 {
54     typedef std::set< std::set<_maille>::iterator>::const_iterator mailleIter;
55     std::string nom;
56     std::set< std::set<_maille>::iterator, _mailleIteratorCompare > mailles; // iterateurs sur les mailles composant le groupe
57     std::list<int> groupes; // indices des sous-groupes composant le groupe
58 };
59
60 /*!
61  * \if developper
62  * Intermediate structure used by drivers to store data read from the other format file.
63  * The structure provides functions that transform the stored data to the MED format : 
64  * getCoordinate(), getConnectivity(), getGroups().
65  * The elements inserted in maillage and points are automaticaly ordered.
66  * Renumbering are performed by getConnectivity & getGroups before writing the MED structures.
67  * Read the conception ducumentation for more details.
68  * \endif
69  */
70 struct _intermediateMED
71 {
72     std::set<_maille> maillage;
73     std::vector<_groupe> groupes;
74     std::map< int, _noeud > points;
75
76     CONNECTIVITY * getConnectivity(); // set MED connectivity from the intermediate structure
77     COORDINATE * getCoordinate(); // set MED coordinate from the intermediate structure
78     void getGroups(std::vector<GROUP *> & _groupCell, std::vector<GROUP *> & _groupFace, std::vector<GROUP *> & _groupEdge, std::vector<GROUP *> & _groupNode, MESH * _ptrMesh);
79
80     // used by previous functions to renumber points & mesh.
81     void numerotationMaillage(); 
82     void numerotationPoints();
83
84 };
85
86 std::ostream& operator << (std::ostream& , const _maille& );
87 std::ostream& operator << (std::ostream& , const _groupe& );
88 std::ostream& operator << (std::ostream& , const _noeud& );
89 std::ostream& operator << (std::ostream& , const _intermediateMED& );
90
91 #endif /* DRIVERTOOLS_HXX */