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
20 #include "MEDMEM_Meshing.hxx"
21 #include "MEDMEM_DriverFactory.hxx"
24 using namespace MEDMEM;
25 using namespace MED_EN;
26 using namespace DRIVERFACTORY;
28 int main (int argc, char ** argv)
30 // Traitement arguments
33 cerr << "Usage : " << argv[0]
34 << " filenameRoot" << endl << endl
35 << "-> creer un maillage et le sauve dans le fichier filenameRoot22.med sous le format Med Fichier V2.2 car il contient un polygon." << endl;
41 filenameRoot= argv[1] ;
43 filenameRoot="/tmp/testMeshingPoly";
45 string medfilename = filenameRoot + "22.med";
48 //***********************************************************************************
51 myMeshing.setName("myMeshing");
55 int SpaceDimension = 2;
56 int NumberOfNodes = 11;
57 double Coordinates[2*11] = {
71 myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE);
73 string Names[3] = { "X","Y","Z" };
74 myMeshing.setCoordinatesNames(Names);
76 string Units[3] = { "cm","cm","cm" };
77 myMeshing.setCoordinatesUnits(Units);
79 // define conectivities of classic types
83 const int NumberOfTypes = 2;
84 medGeometryElement Types[NumberOfTypes] = {MED_TRIA3,MED_QUAD4};
85 const int NumberOfElements[NumberOfTypes] = {1,4};
87 myMeshing.setNumberOfTypes(NumberOfTypes,MED_CELL);
88 myMeshing.setTypes(Types,MED_CELL);
89 myMeshing.setNumberOfElements(NumberOfElements,MED_CELL);
91 int ConnectivityTria[1*3]=
96 myMeshing.setConnectivity(ConnectivityTria,MED_CELL,MED_TRIA3);
98 int ConnectivityQuad[4*4]=
106 myMeshing.setConnectivity(ConnectivityQuad,MED_CELL,MED_QUAD4);
108 int MeshDimension = SpaceDimension ;
109 // because there are 2D cells in the mesh
111 myMeshing.setMeshDimension(MeshDimension) ;
113 // then define eventuel polygonal cells
115 int ConnectivityPolygon[1*5]=
119 int ConnectivityPolygonIndex[2]=
124 myMeshing.setPolygonsConnectivity(ConnectivityPolygonIndex,ConnectivityPolygon,1,MED_CELL);
128 medFileVersion version = getMedFileVersionForWriting();
130 setMedFileVersionForWriting(V22);
132 int idMed22 = myMeshing.addDriver(MED_DRIVER,medfilename,myMeshing.getName());
133 myMeshing.write(idMed22) ;
135 // int idVtk = myMeshing.addDriver(VTK_DRIVER,"toto.vtk",myMeshing.getName());
136 // myMeshing.write(idVtk) ;
138 //************************************************************************************
140 // impression de controle
142 cout << "Impression de MESHING : " << endl;