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_support.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(MESH *myMesh,medEntityMesh Entity)
70 int NumberOfFamilies = myMesh->getNumberOfFamilies(Entity) ;
71 cout << "NumberOfFamilies : "<<NumberOfFamilies<<endl;
72 for (int i=1; i<NumberOfFamilies+1;i++) {
73 const FAMILY* myFamily = myMesh->getFamily(Entity,i);
74 affiche_support(myFamily);
75 cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
76 int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
77 cout << " - Attributes ("<<NumberOfAttributes<<") :"<<endl;
78 for (int j=1;j<NumberOfAttributes+1;j++)
79 cout << " * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str()<<endl ;
80 int NumberOfGroups = myFamily->getNumberOfGroups() ;
81 cout << " - Groups ("<<NumberOfGroups<<") :"<<endl;
82 for (int j=1;j<NumberOfGroups+1;j++)
83 cout << " * "<<myFamily->getGroupName(j).c_str()<<endl ;
87 void affiche_groupe(MESH *myMesh,medEntityMesh Entity)
89 int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
90 cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
91 for (int i=1; i<NumberOfGroups+1;i++) {
92 const GROUP* myGroup = myMesh->getGroup(Entity,i);
93 affiche_support(myGroup);
94 int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
95 cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
96 for (int j=1;j<NumberOfFamillies+1;j++)
97 cout << " * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
101 int main (int argc, char ** argv) {
105 if (argc <3) { // after 3, ignored !
106 cerr << "Usage : " << argv[0]
107 << " filename meshname" << endl << endl;
111 string filename = argv[1] ;
112 string meshname = argv[2] ;
114 MESH * myMesh= new MESH() ;
115 myMesh->setName(meshname);
116 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
117 myMeshDriver.setMeshName(meshname);
118 myMeshDriver.open() ;
119 myMeshDriver.read() ;
120 myMeshDriver.close() ;
122 //Construction d'un support total
123 SUPPORT * mySupport = new SUPPORT(myMesh,"Support on CELLs",MED_CELL);
125 cout << "Show Support on all :"<<endl ;
126 affiche_support(mySupport);
127 SUPPORT * mySupport2 = new SUPPORT(* mySupport);
129 affiche_support(mySupport2);
132 //Construction d'un support partiel
133 mySupport = new SUPPORT(myMesh,"Support on CELLs",MED_CELL);
134 mySupport->setAll(false);
136 // int NumberOfGeometricType = 1;
137 int NumberOfGeometricType = 0;
138 // int TotalNumberOfEntity = 2;
139 // medGeometryElement * GeometricTypePartial = new medGeometryElement[NumberOfGeometricType];
140 // GeometricTypePartial[0] = MED_HEXA8;
141 int TotalNumberOfElements = 0;
142 int * NumberOfElements = new int[myMesh->getNumberOfTypes(MED_CELL)];
143 // NumberOfEntity[0] = 2;
144 // int * NumberValue = new int[TotalNumberOfEntity];
145 int * NumberValue = new int[myMesh->getGlobalNumberingIndex(MED_CELL)[myMesh->getNumberOfTypes(MED_CELL)]-1];
146 // NumberValue[0] = 14;
147 // NumberValue[1] = 15;
149 medGeometryElement * GeometricTypePartial = new medGeometryElement[myMesh->getNumberOfTypes(MED_CELL)];
150 const medGeometryElement * GeometricType = myMesh->getTypes(MED_CELL);
151 for (int i=0;i<myMesh->getNumberOfTypes(MED_CELL);i=i+2)
153 NumberOfGeometricType=NumberOfGeometricType+1;
154 TotalNumberOfElements=TotalNumberOfElements+myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
155 NumberOfElements[i/2]=myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
156 for (int j=0;j<myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);j++)
158 NumberValue[cmp]=myMesh->getGlobalNumberingIndex(MED_CELL)[i]+j;
161 GeometricTypePartial[i/2]=GeometricType[i];
164 mySupport->setpartial("Support partiel",NumberOfGeometricType,TotalNumberOfElements,GeometricTypePartial,NumberOfElements,NumberValue);
166 delete[] NumberOfElements ;
167 delete[] NumberValue ;
168 delete[] GeometricTypePartial ;
170 cout << "Show Partial Support :"<<endl ;
171 affiche_support(mySupport);
172 mySupport2 = new SUPPORT(* mySupport);
174 affiche_support(mySupport2);
178 cout << "Show Family :"<<endl ;
179 affiche_famille(myMesh,MED_NODE);
180 affiche_famille(myMesh,MED_CELL);
181 affiche_famille(myMesh,MED_FACE);
182 affiche_famille(myMesh,MED_EDGE);
184 cout << "Show Group :"<<endl ;
185 affiche_groupe(myMesh,MED_NODE);
186 affiche_groupe(myMesh,MED_CELL);
187 affiche_groupe(myMesh,MED_FACE);
188 affiche_groupe(myMesh,MED_EDGE);