1 // Copyright (C) 2007-2013 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
22 #include "MEDMEM_Meshing.hxx"
23 #include "MEDMEM_DriverFactory.hxx"
26 #define access _access
31 using namespace MEDMEM;
32 using namespace MED_EN;
33 using namespace DRIVERFACTORY;
35 int main (int argc, char ** argv)
37 // Traitement arguments
40 cerr << "Usage : " << argv[0]
41 << " filenameRoot" << endl << endl
42 << "-> creer un maillage et le sauve dans le fichier filenameRoot22.med sous le format Med Fichier V2.2 car il contient un polygon." << endl;
48 filenameRoot= argv[1] ;
50 if ( getenv("TMP") && access(getenv("TMP"),W_OK)==0 )
51 filenameRoot=getenv("TMP");
52 else if (getenv("TMPDIR") && access(getenv("TMPDIR"),W_OK)==0 )
53 filenameRoot=getenv("TMPDIR");
56 filenameRoot+="/testMeshingPoly";
59 string medfilename = filenameRoot + "22.med";
62 //***********************************************************************************
64 MESHING *myMeshing=new MESHING;
65 myMeshing->setName("myMeshing");
69 int SpaceDimension = 2;
70 int NumberOfNodes = 11;
71 double Coordinates[2*11] = {
85 myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE);
87 string Names[3] = { "X","Y","Z" };
88 myMeshing->setCoordinatesNames(Names);
90 string Units[3] = { "cm","cm","cm" };
91 myMeshing->setCoordinatesUnits(Units);
93 // define conectivities of classic types
97 const int NumberOfTypes = 3;
98 medGeometryElement Types[NumberOfTypes] = {MED_TRIA3,MED_QUAD4,MED_POLYGON};
99 const int NumberOfElements[NumberOfTypes] = {1,4,1};
101 myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL);
102 myMeshing->setTypes(Types,MED_CELL);
103 myMeshing->setNumberOfElements(NumberOfElements,MED_CELL);
105 int ConnectivityTria[1*3]=
110 myMeshing->setConnectivity(MED_CELL,MED_TRIA3,ConnectivityTria);
112 int ConnectivityQuad[4*4]=
120 myMeshing->setConnectivity(MED_CELL,MED_QUAD4,ConnectivityQuad);
122 // then define eventuel polygonal cells
124 int ConnectivityPolygon[1*5]=
128 int ConnectivityPolygonIndex[2]=
133 myMeshing->setConnectivity(MED_CELL,MED_POLYGON,ConnectivityPolygon,ConnectivityPolygonIndex);
137 int idMed22 = myMeshing->addDriver(MED_DRIVER,medfilename,myMeshing->getName());
138 myMeshing->write(idMed22) ;
140 // int idVtk = myMeshing->addDriver(VTK_DRIVER,"toto.vtk",myMeshing->getName());
141 // myMeshing->write(idVtk) ;
142 myMeshing->removeReference();
144 //************************************************************************************
146 // impression de controle
148 cout << "Impression de MESHING : " << endl;
152 cout << "Remove generated file" << endl;
153 remove( medfilename.c_str() );