Back to index

salome-kernel  6.5.0
test6.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
00024 //  File   : test6.cxx
00025 //  Module : SALOME
00026 //
00027 #include <iostream.h>
00028 #include "HDFOI.hxx"
00029 #include <stdlib.h>
00030 
00031 int main()
00032 {
00033   HDFfile *study;
00034   HDFgroup *geom, *mesh;
00035   HDFgroup *geom1, *geom2, *mesh1, *mesh2;
00036   int n,m,i;
00037   char name[HDF_NAME_MAX_LEN+1];
00038 
00039   try
00040     {
00041       // the groups 'GEOM' and 'MESH' become mounted points for
00042       // the files 'geom.hdf' and 'mesh.hdf' in the 'study.hdf' file
00043 
00044       study = new HDFfile("study.hdf");
00045       MESSAGE( ">> The HDFfile object for 'study.hdf' is created" );
00046 
00047       study->OpenOnDisk(HDF_RDONLY);
00048       MESSAGE( "--> The file is opened" );
00049 
00050       geom = new HDFgroup("GEOM",study);
00051       MESSAGE( ">> The HDFgroup object for 'GEOM' is created" );
00052 
00053       geom->FileMount("geom.hdf",HDF_RDONLY);
00054       MESSAGE( ">> 'GEOM' becomes a mounted point for the file 'geom.hdf'" );
00055 
00056       geom->OpenOnDisk();
00057       MESSAGE( "--> The group is opened" );
00058 
00059       m = geom->nInternalObjects();
00060       MESSAGE( "--> There are " << m << " objects in the group" );
00061       
00062       for (i=0;i<m;i++) 
00063         {
00064           geom->InternalObjectIndentify(i,name);
00065           MESSAGE( "--> First Level Internal Object Name : " << name );
00066         }        
00067 
00068       geom1 = new HDFgroup("GEOM_1",geom);
00069       MESSAGE( ">> The HDF group object is created for 'GEOM_1' with 'GEOM' as father" );
00070       MESSAGE( "--> This group is in fact in the file 'geom.hdf'");
00071 
00072       geom1->OpenOnDisk();
00073       MESSAGE( "-> The group 'GEOM_1' is opened" );
00074 
00075       geom1->CloseOnDisk();
00076       MESSAGE( "-> The group 'GEOM_1' is closed" );
00077 
00078       geom2 = new HDFgroup("GEOM_2",geom);
00079       MESSAGE( ">> The HDF group object is created for 'GEOM_2' with 'GEOM' as father" );
00080       MESSAGE( "--> This group is in fact in the file 'geom.hdf'");      
00081 
00082       geom2->OpenOnDisk();
00083       MESSAGE( "-> The group 'GEOM_2' is opened" );
00084 
00085       geom2->CloseOnDisk();
00086       MESSAGE( "-> The group 'GEOM_2' is closed" );
00087 
00088       geom->CloseOnDisk();
00089       MESSAGE( "-> The group 'GEOM' is closed" );
00090 
00091       geom->FileUnMount();
00092       MESSAGE( ">> The file 'geom.hdf' is unmounted from 'GEOM' " ); 
00093 
00094       mesh = new HDFgroup("MESH",study);
00095 
00096       mesh->FileMount("mesh.hdf",HDF_RDONLY);
00097 
00098       mesh->OpenOnDisk();
00099 
00100       mesh1 = new HDFgroup("MESH_1",mesh);
00101 
00102       mesh1->OpenOnDisk();
00103 
00104       mesh1->CloseOnDisk();
00105 
00106       mesh2 = new HDFgroup("MESH_2",mesh);
00107 
00108       mesh2->OpenOnDisk();
00109 
00110       mesh2->CloseOnDisk();
00111 
00112       mesh->CloseOnDisk();
00113 
00114       mesh->FileUnMount();
00115 
00116       MESSAGE( ">> The same operations have been done for the file 'mesh.hdf'" )
00117       MESSAGE( "   and the groups MESH_1 and MESH_2" )
00118       MESSAGE( "--> This file has been mounted on the group 'MESH' of the file 'study.hdf' ")
00119               
00120       study->CloseOnDisk();
00121       MESSAGE( ">> The study.hdf file is closed" );
00122 
00123       MESSAGE( ">> Memory clean" );
00124       delete mesh1;
00125       delete mesh2;
00126       delete mesh;
00127       delete geom1;
00128       delete geom2;
00129       delete geom;
00130       delete study;
00131     }
00132   catch(HDFexception)
00133     {
00134       MESSAGE( "!!! HDFexception !!! ")
00135     }
00136   return 0;
00137 }