Back to index

salome-med  6.5.0
test_copie_group.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 #include<string>
00023 
00024 #include <math.h>
00025 #include <stdlib.h>
00026 
00027 #include "MEDMEM_Exception.hxx"
00028 #include "MEDMEM_Mesh.hxx"
00029 #include "MEDMEM_Family.hxx"
00030 #include "MEDMEM_Group.hxx"
00031 
00032 #include "MEDMEM_MedMeshDriver.hxx"
00033 #include "MEDMEM_MedFieldDriver.hxx"
00034 #include "MEDMEM_Support.hxx"
00035 #include "MEDMEM_Field.hxx"
00036 #include "MEDMEM_define.hxx"
00037 
00038 using namespace std;
00039 using namespace MEDMEM;
00040 using namespace MED_EN;
00041 
00042 static void affiche_support(const SUPPORT * mySupport) 
00043 {
00044   cout << "  - Name : "<<mySupport->getName().c_str()<<endl ;
00045   cout << "  - Description : "<<mySupport->getDescription().c_str()<<endl ;
00046   cout << "  - Entity : "<<mySupport->getEntity()<<endl ;
00047   cout << "  - Entities list : "<<endl ;
00048   if (!(mySupport->isOnAllElements())) {
00049     int NumberOfTypes = mySupport->getNumberOfTypes() ;
00050     cout<<"  - NumberOfTypes : "<<NumberOfTypes<<endl;
00051     const medGeometryElement * Types = mySupport->getTypes() ;
00052     for (int j=0;j<NumberOfTypes;j++) {
00053       cout<<"    * Type "<<Types[j]<<" : ";
00054       int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
00055       const int * Number = mySupport->getNumber(Types[j]) ;
00056       for (int k=0; k<NumberOfElements;k++)
00057         cout << Number[k] << " ";
00058       cout << endl ;
00059     }
00060   } else
00061     cout << "    Is on all entities !"<< endl;
00062 }
00063 
00064 
00065 static void affiche_groupe(const GROUP * myGroup) 
00066 {
00067     affiche_support(myGroup);
00068     int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
00069     cout << "  - Families ("<<NumberOfFamillies<<") :"<<endl;
00070     for (int j=1;j<NumberOfFamillies+1;j++)
00071       cout << "    * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
00072 }
00073 
00074 int main (int argc, char ** argv) {
00075 
00076   if (argc <3) { // after 3, ignored !
00077     cerr << "Usage : " << argv[0] 
00078          << " filename meshname" << endl << endl;
00079     exit(-1);
00080   }
00081 
00082   string filename = argv[1] ;
00083   string meshname = argv[2] ;
00084 
00085   MESH * myMesh= new MESH;
00086   myMesh->setName(meshname);
00087   MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
00088   myMeshDriver.setMeshName(meshname);
00089   myMeshDriver.open() ;
00090   myMeshDriver.read() ;
00091   myMeshDriver.close() ;
00092 
00093   const GROUP * myGroup = myMesh->getGroup(MED_NODE,1);
00094   cout << "Show Group :"<<endl ;
00095   affiche_groupe(myGroup);
00096   GROUP * myGroup2 = new GROUP(* myGroup);
00097   affiche_groupe(myGroup2);
00098   GROUP * myGroup3 = new GROUP(* myGroup2);
00099   myGroup2->removeReference();
00100   affiche_groupe(myGroup3);
00101   myGroup3->removeReference();
00102 
00103   myMesh->removeReference() ;
00104 
00105   return 0;
00106 }