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_family.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(MESH *myMesh,medEntityMesh Entity)
84 int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
85 cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
86 for (int i=1; i<NumberOfGroups+1;i++) {
87 const GROUP* myGroup = myMesh->getGroup(Entity,i);
88 affiche_support(myGroup);
89 int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
90 cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
91 for (int j=1;j<NumberOfFamillies+1;j++)
92 cout << " * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
96 int main (int argc, char ** argv) {
100 if (argc <3) { // after 3, ignored !
101 cerr << "Usage : " << argv[0]
102 << " filename meshname" << endl << endl;
106 string filename = argv[1] ;
107 string meshname = argv[2] ;
109 MESH * myMesh= new MESH() ;
110 myMesh->setName(meshname);
111 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
112 myMeshDriver.setMeshName(meshname);
113 myMeshDriver.open() ;
114 myMeshDriver.read() ;
115 myMeshDriver.close() ;
117 const FAMILY * myFamily = myMesh->getFamily(MED_NODE,1);
118 //On renseigne les attributs spécifiques à FAMILY (p/r à SUPPORT) et non renseignés lors de la lecture du maillage
119 // int NumberOfAttribute = 3;
120 // int *AttributeIdentifier = new int[NumberOfAttribute];
121 // int *AttributeValue = new int[NumberOfAttribute];
122 // string *AttributeDescription = new string[NumberOfAttribute];
124 // for (int i=0;i<NumberOfAttribute;i++)
126 // AttributeIdentifier[i]=i+1;
127 // AttributeValue[i]=(i+1)*10;
128 // sprintf(tmp,"Attribut N° %d",i+1);
129 // AttributeDescription[i]=tmp;
132 // myFamily->setNumberOfAttributes(NumberOfAttribute);
133 // myFamily->setAttributesIdentifiers (AttributeIdentifier);
134 // myFamily->setAttributesValues (AttributeValue);
135 // myFamily->setAttributesDescriptions (AttributeDescription);
137 cout << "Show Family :"<<endl ;
138 affiche_famille(myFamily);
139 FAMILY * myFamily2 = new FAMILY(* myFamily);
141 cout << "Show Family2 :"<<endl ;
142 affiche_famille(myFamily2);
143 FAMILY * myFamily3 = new FAMILY(* myFamily2);
145 cout << "Show Family3 :"<<endl ;
146 affiche_famille(myFamily3);
149 cout << "That's all"<<endl ;
152 cout << "Show Group :"<<endl ;
153 affiche_groupe(myMesh,MED_NODE);
154 affiche_groupe(myMesh,MED_CELL);
155 affiche_groupe(myMesh,MED_FACE);
156 affiche_groupe(myMesh,MED_EDGE);