Salome HOME
Building a version which will be tagged PreV2_0_0 working with KERNEL V1_4_0.
[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 namespace MEDMEM {
15 class MESH;
16 class CONNECTIVITY;
17 class COORDINATE;
18 class GROUP;
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() : geometricType(MED_EN::MED_NONE),ordre(0)
33     {
34     };
35     _maille(MED_EN::medGeometryElement _geometricType, size_t nelem) : geometricType(_geometricType),ordre(0)
36     {
37         sommets.reserve(nelem);
38     };
39     int dimension() const // retourne la dimension de la maille
40     {
41         return geometricType/100;
42     };
43     bool operator < (const _maille& ma) const;
44     MED_EN::medEntityMesh getEntity(const int meshDimension) const throw (MEDEXCEPTION);
45 };
46
47 struct _mailleIteratorCompare // pour ordonner le set d'iterateurs sur mailles
48 {
49     bool operator () (std::set<_maille>::iterator i1, std::set<_maille>::iterator i2)
50     {
51         return *i1<*i2;
52     }
53 };
54
55 struct _groupe
56 {
57     typedef std::set< std::set<_maille>::iterator>::const_iterator mailleIter;
58     std::string nom;
59     std::set< std::set<_maille>::iterator, _mailleIteratorCompare > mailles; // iterateurs sur les mailles composant le groupe
60     std::vector<int> groupes; // indices des sous-groupes composant le groupe
61 };
62
63 /*!
64  * \if developper
65  * Intermediate structure used by drivers to store data read from the other format file.
66  * The structure provides functions that transform the stored data to the MED format : 
67  * getCoordinate(), getConnectivity(), getGroups().
68  * The elements inserted in maillage and points are automaticaly ordered.
69  * Renumbering are performed by getConnectivity & getGroups before writing the MED structures.
70  * Read the conception ducumentation for more details.
71  * \endif
72  */
73 struct _intermediateMED
74 {
75     std::set<_maille> maillage;
76     std::vector<_groupe> groupes;
77     std::map< int, _noeud > points;
78
79     CONNECTIVITY * getConnectivity(); // set MED connectivity from the intermediate structure
80     COORDINATE * getCoordinate(const string & coordinateSystem="CARTESIAN"); // set MED coordinate from the 
81                                                                              // intermediate structure
82     void getGroups(std::vector<GROUP *> & _groupCell, std::vector<GROUP *> & _groupFace, 
83             std::vector<GROUP *> & _groupEdge, std::vector<GROUP *> & _groupNode, MESH * _ptrMesh);
84
85     // used by previous functions to renumber points & mesh.
86     void numerotationMaillage(); 
87     void numerotationPoints();
88
89 };
90
91 std::ostream& operator << (std::ostream& , const _maille& );
92 std::ostream& operator << (std::ostream& , const _groupe& );
93 std::ostream& operator << (std::ostream& , const _noeud& );
94 std::ostream& operator << (std::ostream& , const _intermediateMED& );
95
96 };
97 #endif /* DRIVERTOOLS_HXX */