1 // MED MEDMEM : MED files in memory
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : test_copie_group.cxx
33 #include "MEDMEM_Exception.hxx"
34 #include "MEDMEM_Mesh.hxx"
35 #include "MEDMEM_Family.hxx"
36 #include "MEDMEM_Group.hxx"
38 #include "MEDMEM_MedMeshDriver.hxx"
39 #include "MEDMEM_MedFieldDriver.hxx"
40 #include "MEDMEM_Support.hxx"
41 #include "MEDMEM_Field.hxx"
42 #include "MEDMEM_define.hxx"
45 void affiche_support(const SUPPORT * mySupport)
47 cout << " - Name : "<<mySupport->getName().c_str()<<endl ;
48 cout << " - Description : "<<mySupport->getDescription().c_str()<<endl ;
49 cout << " - Entity : "<<mySupport->getEntity()<<endl ;
50 cout << " - Entities list : "<<endl ;
51 if (!(mySupport->isOnAllElements())) {
52 int NumberOfTypes = mySupport->getNumberOfTypes() ;
53 cout<<" - NumberOfTypes : "<<NumberOfTypes<<endl;
54 const medGeometryElement * Types = mySupport->getTypes() ;
55 for (int j=0;j<NumberOfTypes;j++) {
56 cout<<" * Type "<<Types[j]<<" : ";
57 int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
58 const int * Number = mySupport->getNumber(Types[j]) ;
59 for (int k=0; k<NumberOfElements;k++)
60 cout << Number[k] << " ";
64 cout << " Is on all entities !"<< endl;
68 void affiche_famille(const FAMILY * myFamily)
70 affiche_support(myFamily);
71 cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
72 int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
73 cout << " - Attributes ("<<NumberOfAttributes<<") :"<<endl;
74 for (int j=1;j<NumberOfAttributes+1;j++)
75 cout << " * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str()<<endl ;
76 int NumberOfGroups = myFamily->getNumberOfGroups() ;
77 cout << " - Groups ("<<NumberOfGroups<<") :"<<endl;
78 for (int j=1;j<NumberOfGroups+1;j++)
79 cout << " * "<<myFamily->getGroupName(j).c_str()<<endl ;
82 void affiche_groupe(const GROUP * myGroup)
84 affiche_support(myGroup);
85 int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
86 cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
87 for (int j=1;j<NumberOfFamillies+1;j++)
88 cout << " * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
91 int main (int argc, char ** argv) {
95 if (argc <3) { // after 3, ignored !
96 cerr << "Usage : " << argv[0]
97 << " filename meshname" << endl << endl;
101 string filename = argv[1] ;
102 string meshname = argv[2] ;
104 MESH * myMesh= new MESH() ;
105 myMesh->setName(meshname);
106 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
107 myMeshDriver.setMeshName(meshname);
108 myMeshDriver.open() ;
109 myMeshDriver.read() ;
110 myMeshDriver.close() ;
112 const GROUP * myGroup = myMesh->getGroup(MED_NODE,1);
113 cout << "Show Group :"<<endl ;
114 affiche_groupe(myGroup);
115 GROUP * myGroup2 = new GROUP(* myGroup);
116 //delete myGroup; // no because in mesh !!
117 affiche_groupe(myGroup2);
118 GROUP * myGroup3 = new GROUP(* myGroup2);
120 affiche_groupe(myGroup3);