1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
27 #include "MEDMEM_Exception.hxx"
28 #include "MEDMEM_Mesh.hxx"
29 #include "MEDMEM_Family.hxx"
30 #include "MEDMEM_Group.hxx"
32 #include "MEDMEM_MedMeshDriver.hxx"
33 #include "MEDMEM_MedFieldDriver.hxx"
34 #include "MEDMEM_Support.hxx"
35 #include "MEDMEM_Field.hxx"
36 #include "MEDMEM_define.hxx"
39 using namespace MEDMEM;
40 using namespace MED_EN;
42 static void affiche_support(const SUPPORT * mySupport)
44 cout << " - Name : "<<mySupport->getName().c_str()<<endl ;
45 cout << " - Description : "<<mySupport->getDescription().c_str()<<endl ;
46 cout << " - Entity : "<<mySupport->getEntity()<<endl ;
47 cout << " - Entities list : "<<endl ;
48 if (!(mySupport->isOnAllElements()))
50 int NumberOfTypes = mySupport->getNumberOfTypes() ;
51 cout<<" - NumberOfTypes : "<<NumberOfTypes<<endl;
52 const medGeometryElement * Types = mySupport->getTypes() ;
53 for (int j=0;j<NumberOfTypes;j++)
55 cout<<" * Type "<<Types[j]<<" : ";
56 int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
57 const int * Number = mySupport->getNumber(Types[j]) ;
58 for (int k=0; k<NumberOfElements;k++)
59 cout << Number[k] << " ";
64 cout << " Is on all entities !"<< endl;
68 static 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 int main (int argc, char ** argv)
85 { // after 3, ignored !
86 cerr << "Usage : " << argv[0]
87 << " filename meshname" << endl << endl;
91 string filename = argv[1] ;
92 string meshname = argv[2] ;
94 MESH * myMesh= new MESH;
95 myMesh->setName(meshname);
96 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
97 myMeshDriver.setMeshName(meshname);
100 myMeshDriver.close() ;
102 if ( myMesh->getNumberOfFamilies(MED_NODE) < 1 )
104 cerr << "No nodal families in the file" << endl;
107 const FAMILY * myFamily = myMesh->getFamily(MED_NODE,1);
109 cout << "Show Family :"<<endl ;
110 affiche_famille(myFamily);
111 FAMILY * myFamily2 = new FAMILY(* myFamily);
113 cout << "Show Family2 :"<<endl ;
114 affiche_famille(myFamily2);
115 FAMILY * myFamily3 = new FAMILY(* myFamily2);
116 myFamily2->removeReference();
117 cout << "Show Family3 :"<<endl ;
118 affiche_famille(myFamily3);
119 myFamily3->removeReference();
121 cout << "That's all"<<endl ;
123 myMesh->removeReference();