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/ or email : webmaster.salome@opencascade.com
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(MESH *myMesh,medEntityMesh Entity)
65 int NumberOfFamilies = myMesh->getNumberOfFamilies(Entity) ;
66 cout << "NumberOfFamilies : "<<NumberOfFamilies<<endl;
67 for (int i=1; i<NumberOfFamilies+1;i++) {
68 const FAMILY* myFamily = myMesh->getFamily(Entity,i);
69 affiche_support(myFamily);
70 cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
71 int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
72 cout << " - Attributes ("<<NumberOfAttributes<<") :"<<endl;
73 for (int j=1;j<NumberOfAttributes+1;j++)
74 cout << " * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str()<<endl ;
75 int NumberOfGroups = myFamily->getNumberOfGroups() ;
76 cout << " - Groups ("<<NumberOfGroups<<") :"<<endl;
77 for (int j=1;j<NumberOfGroups+1;j++)
78 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) {
99 if (argc <3) { // after 3, ignored !
100 cerr << "Usage : " << argv[0]
101 << " filename meshname" << endl << endl;
105 string filename = argv[1] ;
106 string meshname = argv[2] ;
108 MESH * myMesh= new MESH() ;
109 myMesh->setName(meshname);
110 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
111 myMeshDriver.setMeshName(meshname);
112 myMeshDriver.open() ;
113 myMeshDriver.read() ;
114 myMeshDriver.close() ;
116 //Construction d'un support total
117 SUPPORT * mySupport = new SUPPORT(myMesh,"Support on CELLs",MED_CELL);
119 cout << "Show Support on all :"<<endl ;
120 affiche_support(mySupport);
121 SUPPORT * mySupport2 = new SUPPORT(* mySupport);
123 affiche_support(mySupport2);
126 //Construction d'un support partiel
127 mySupport = new SUPPORT(myMesh,"Support on CELLs",MED_CELL);
128 mySupport->setAll(false);
130 // int NumberOfGeometricType = 1;
131 int NumberOfGeometricType = 0;
132 // int TotalNumberOfEntity = 2;
133 // medGeometryElement * GeometricTypePartial = new medGeometryElement[NumberOfGeometricType];
134 // GeometricTypePartial[0] = MED_HEXA8;
135 int TotalNumberOfElements = 0;
136 int * NumberOfElements = new int[myMesh->getNumberOfTypes(MED_CELL)];
137 // NumberOfEntity[0] = 2;
138 // int * NumberValue = new int[TotalNumberOfEntity];
139 int * NumberValue = new int[myMesh->getGlobalNumberingIndex(MED_CELL)[myMesh->getNumberOfTypes(MED_CELL)]-1];
140 // NumberValue[0] = 14;
141 // NumberValue[1] = 15;
143 medGeometryElement * GeometricTypePartial = new medGeometryElement[myMesh->getNumberOfTypes(MED_CELL)];
144 const medGeometryElement * GeometricType = myMesh->getTypes(MED_CELL);
145 for (int i=0;i<myMesh->getNumberOfTypes(MED_CELL);i=i+2)
147 NumberOfGeometricType=NumberOfGeometricType+1;
148 TotalNumberOfElements=TotalNumberOfElements+myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
149 NumberOfElements[i/2]=myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
150 for (int j=0;j<myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);j++)
152 NumberValue[cmp]=myMesh->getGlobalNumberingIndex(MED_CELL)[i]+j;
155 GeometricTypePartial[i/2]=GeometricType[i];
158 mySupport->setpartial("Support partiel",NumberOfGeometricType,TotalNumberOfElements,GeometricTypePartial,NumberOfElements,NumberValue);
160 delete[] NumberOfElements ;
161 delete[] NumberValue ;
162 delete[] GeometricTypePartial ;
164 cout << "Show Partial Support :"<<endl ;
165 affiche_support(mySupport);
166 mySupport2 = new SUPPORT(* mySupport);
168 affiche_support(mySupport2);
172 cout << "Show Family :"<<endl ;
173 affiche_famille(myMesh,MED_NODE);
174 affiche_famille(myMesh,MED_CELL);
175 affiche_famille(myMesh,MED_FACE);
176 affiche_famille(myMesh,MED_EDGE);
178 cout << "Show Group :"<<endl ;
179 affiche_groupe(myMesh,MED_NODE);
180 affiche_groupe(myMesh,MED_CELL);
181 affiche_groupe(myMesh,MED_FACE);
182 affiche_groupe(myMesh,MED_EDGE);