1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
25 #include "MEDMEM_Exception.hxx"
26 #include "MEDMEM_Mesh.hxx"
27 #include "MEDMEM_Family.hxx"
28 #include "MEDMEM_Group.hxx"
30 #include "MEDMEM_MedMeshDriver.hxx"
31 #include "MEDMEM_MedFieldDriver.hxx"
32 #include "MEDMEM_Support.hxx"
33 #include "MEDMEM_Field.hxx"
34 #include "MEDMEM_define.hxx"
37 using namespace MEDMEM;
38 using namespace MED_EN;
40 void affiche_support(const SUPPORT * mySupport)
42 cout << " - Name : "<<mySupport->getName().c_str()<<endl ;
43 cout << " - Description : "<<mySupport->getDescription().c_str()<<endl ;
44 cout << " - Entity : "<<mySupport->getEntity()<<endl ;
45 cout << " - Entities list : "<<endl ;
46 if (!(mySupport->isOnAllElements())) {
47 int NumberOfTypes = mySupport->getNumberOfTypes() ;
48 cout<<" - NumberOfTypes : "<<NumberOfTypes<<endl;
49 const medGeometryElement * Types = mySupport->getTypes() ;
50 for (int j=0;j<NumberOfTypes;j++) {
51 cout<<" * Type "<<Types[j]<<" : ";
52 int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
53 const int * Number = mySupport->getNumber(Types[j]) ;
54 for (int k=0; k<NumberOfElements;k++)
55 cout << Number[k] << " ";
59 cout << " Is on all entities !"<< endl;
63 void affiche_famille(const FAMILY * myFamily)
65 affiche_support(myFamily);
66 cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
67 int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
68 cout << " - Attributes ("<<NumberOfAttributes<<") :"<<endl;
69 for (int j=1;j<NumberOfAttributes+1;j++)
70 cout << " * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str()<<endl ;
71 int NumberOfGroups = myFamily->getNumberOfGroups() ;
72 cout << " - Groups ("<<NumberOfGroups<<") :"<<endl;
73 for (int j=1;j<NumberOfGroups+1;j++)
74 cout << " * "<<myFamily->getGroupName(j).c_str()<<endl ;
77 void affiche_groupe(const GROUP * myGroup)
79 affiche_support(myGroup);
80 int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
81 cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
82 for (int j=1;j<NumberOfFamillies+1;j++)
83 cout << " * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
86 int main (int argc, char ** argv) {
89 if (argc <3) { // after 3, ignored !
90 cerr << "Usage : " << argv[0]
91 << " filename meshname" << endl << endl;
95 string filename = argv[1] ;
96 string meshname = argv[2] ;
98 MESH * myMesh= new MESH() ;
99 myMesh->setName(meshname);
100 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
101 myMeshDriver.setMeshName(meshname);
102 myMeshDriver.open() ;
103 myMeshDriver.read() ;
104 myMeshDriver.close() ;
106 const GROUP * myGroup = myMesh->getGroup(MED_NODE,1);
107 cout << "Show Group :"<<endl ;
108 affiche_groupe(myGroup);
109 GROUP * myGroup2 = new GROUP(* myGroup);
110 //delete myGroup; // no because in mesh !!
111 affiche_groupe(myGroup2);
112 GROUP * myGroup3 = new GROUP(* myGroup2);
114 affiche_groupe(myGroup3);