]> SALOME platform Git repositories - modules/kernel.git/blob - src/HDFPersist/test6.cxx
Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / src / HDFPersist / test6.cxx
1 using namespace std;
2 #include <iostream.h>
3 #include "HDFOI.hxx"
4 #include <stdlib.h>
5
6 int main()
7 {
8   HDFfile *study;
9   HDFgroup *geom, *mesh;
10   HDFgroup *geom1, *geom2, *mesh1, *mesh2;
11   int n,m,i;
12   char name[HDF_NAME_MAX_LEN+1];
13
14   try
15     {
16       // the groups 'GEOM' and 'MESH' become mounted points for
17       // the files 'geom.hdf' and 'mesh.hdf' in the 'study.hdf' file
18
19       study = new HDFfile("study.hdf");
20       MESSAGE( ">> The HDFfile object for 'study.hdf' is created" );
21
22       study->OpenOnDisk(HDF_RDONLY);
23       MESSAGE( "--> The file is opened" );
24
25       geom = new HDFgroup("GEOM",study);
26       MESSAGE( ">> The HDFgroup object for 'GEOM' is created" );
27
28       geom->FileMount("geom.hdf",HDF_RDONLY);
29       MESSAGE( ">> 'GEOM' becomes a mounted point for the file 'geom.hdf'" );
30
31       geom->OpenOnDisk();
32       MESSAGE( "--> The group is opened" );
33
34       m = geom->nInternalObjects();
35       MESSAGE( "--> There are " << m << " objects in the group" );
36       
37       for (i=0;i<m;i++) 
38         {
39           geom->InternalObjectIndentify(i,name);
40           MESSAGE( "--> First Level Internal Object Name : " << name );
41         }        
42
43       geom1 = new HDFgroup("GEOM_1",geom);
44       MESSAGE( ">> The HDF group object is created for 'GEOM_1' with 'GEOM' as father" );
45       MESSAGE( "--> This group is in fact in the file 'geom.hdf'");
46
47       geom1->OpenOnDisk();
48       MESSAGE( "-> The group 'GEOM_1' is opened" );
49
50       geom1->CloseOnDisk();
51       MESSAGE( "-> The group 'GEOM_1' is closed" );
52
53       geom2 = new HDFgroup("GEOM_2",geom);
54       MESSAGE( ">> The HDF group object is created for 'GEOM_2' with 'GEOM' as father" );
55       MESSAGE( "--> This group is in fact in the file 'geom.hdf'");      
56
57       geom2->OpenOnDisk();
58       MESSAGE( "-> The group 'GEOM_2' is opened" );
59
60       geom2->CloseOnDisk();
61       MESSAGE( "-> The group 'GEOM_2' is closed" );
62
63       geom->CloseOnDisk();
64       MESSAGE( "-> The group 'GEOM' is closed" );
65
66       geom->FileUnMount();
67       MESSAGE( ">> The file 'geom.hdf' is unmounted from 'GEOM' " ); 
68
69       mesh = new HDFgroup("MESH",study);
70
71       mesh->FileMount("mesh.hdf",HDF_RDONLY);
72
73       mesh->OpenOnDisk();
74
75       mesh1 = new HDFgroup("MESH_1",mesh);
76
77       mesh1->OpenOnDisk();
78
79       mesh1->CloseOnDisk();
80
81       mesh2 = new HDFgroup("MESH_2",mesh);
82
83       mesh2->OpenOnDisk();
84
85       mesh2->CloseOnDisk();
86
87       mesh->CloseOnDisk();
88
89       mesh->FileUnMount();
90
91       MESSAGE( ">> The same operations have been done for the file 'mesh.hdf'" )
92       MESSAGE( "   and the groups MESH_1 and MESH_2" )
93       MESSAGE( "--> This file has been mounted on the group 'MESH' of the file 'study.hdf' ")
94               
95       study->CloseOnDisk();
96       MESSAGE( ">> The study.hdf file is closed" );
97
98       MESSAGE( ">> Memory clean" );
99       delete mesh1;
100       delete mesh2;
101       delete mesh;
102       delete geom1;
103       delete geom2;
104       delete geom;
105       delete study;
106     }
107   catch(HDFexception)
108     {
109       MESSAGE( "!!! HDFexception !!! ")
110     }
111   return 0;
112 }