Back to index

salome-med  6.5.0
testConvertPolygon.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "MEDMEM_Mesh.hxx"
00024 #ifdef WNT
00025 #include <io.h>
00026 #define access _access
00027 #define W_OK 02
00028 #endif
00029 
00030 int main()
00031 {
00032   // Get file to convert.
00033   string file;
00034   // During 'make check' $srcdir exists
00035   if ( getenv("srcdir") ) {
00036     file = string( getenv("srcdir")) + "/../../resources/";
00037   }
00038   else if ( getenv( "MED_ROOT_DIR")) {
00039     // after installation
00040     file = string( getenv( "MED_ROOT_DIR" )) + "/share/salome/resources/med/";
00041   }
00042   else
00043   {
00044     return -1;
00045   }
00046   file += "BoxTetra2.med";
00047   cout << "File to cnvert: " << file << endl;
00048   // convertion
00049   MEDMEM::MESH *mesh=new MEDMEM::MESH(MEDMEM::MED_DRIVER, file.c_str(), "BoxTetra2");
00050   mesh->convertToPoly();
00051 
00052   // File to store conversion result
00053   if ( getenv("TMP") && access(getenv("TMP"),W_OK)==0 )
00054     file = getenv("TMP");
00055   else if ( getenv("TMPDIR") && access(getenv("TMPDIR"),W_OK)==0 )
00056     file = getenv("TMPDIR");
00057   else
00058     file = "/tmp";
00059   file += "/pointe_testConvertPolygon.med";
00060 
00061   int id=mesh->addDriver(MEDMEM::MED_DRIVER,file.c_str(),"mesh");
00062   mesh->write(id);
00063   mesh->removeReference();
00064 
00065   remove(file.c_str());
00066 
00067   return 0;
00068 }