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_Grid.hxx"
22 using namespace MEDMEM;
23 using namespace MED_EN;
25 static void usage(const char * test)
27 cerr << "Usage : " << test
28 << " SpaceDimension nbMaille" << endl << endl
29 << "-> Crée une grille cartesienne en dimension SpaceDimension avec nbMaille suivant chaque direction" << endl;
33 int main (int argc, char ** argv) {
35 /* process the arguments */
39 const int SpaceDimension=atoi(argv[1]);
40 const int nbMaille=atoi(argv[2]);
41 if(SpaceDimension>3 || SpaceDimension<1 || nbMaille<1)
44 // Creation des tableaux necessaires à la construction de GRID
45 std::vector<int> nMaille(SpaceDimension,nbMaille);
46 std::vector<double> Origine(SpaceDimension,0.0);
47 std::vector<double> pas(SpaceDimension,10.0);
48 std::vector<std::vector<double> > XYZ_Array(SpaceDimension);
49 for(int i=0;i!=SpaceDimension;++i)
51 XYZ_Array[i].resize(nMaille[i]+1); // nbre de noeuds = nbre de mailles +1
52 XYZ_Array[i][0]=Origine[i];
53 for(int j=1;j!=XYZ_Array[i].size();++j)
54 XYZ_Array[i][j]=XYZ_Array[i][j-1] + pas[j-1];
57 std::vector<std::string> coord_name(SpaceDimension,"X");
62 std::vector<std::string> coord_unit(SpaceDimension,"cm");
64 // creation du pointeur MESH à partir d'un GRID, test affichage
65 std::auto_ptr<MEDMEM::MESH> Mesh (new MEDMEM::GRID( XYZ_Array, coord_name, coord_unit, MED_CARTESIAN) );
66 const MEDMEM::CONNECTIVITY* conn = Mesh->getConnectivityptr();
67 std::cout << "Affichage du maillage : " << endl << *Mesh << endl;