X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FINTERP_KERNELTest%2FInterpolationOptionsTest.cxx;h=5079a72372614f55b4540769d3c0bf5f41a9edf2;hb=214cb0a3e23e084616ebf247642bfbc43811e26d;hp=6bafcb137f8a5fc6d8db803d76a9c7255e33e435;hpb=48782c06022ca2caa36f849cb5a29ea4fe2aaa83;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx b/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx index 6bafcb137..5079a7237 100644 --- a/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx +++ b/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx @@ -1,37 +1,43 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// Copyright (C) 2007-2023 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +#include "MEDFileMesh.hxx" +#include "MEDCouplingFieldDouble.hxx" + #include "InterpolationOptionsTest.hxx" -#include "MEDNormalizedUnstructuredMesh.hxx" -#include "Interpolation2D.hxx" +#include "MEDCouplingNormalizedUnstructuredMesh.txx" +#include "Interpolation2D.txx" +#include "TestInterpKernelUtils.hxx" + #include #include +using namespace MEDCoupling; + namespace INTERP_TEST { - - - void InterpolationOptionsTest::setUp() + void InterpolationOptionsTest::setUp() { } - - void InterpolationOptionsTest::tearDown() + + void InterpolationOptionsTest::tearDown() { } @@ -43,37 +49,42 @@ namespace INTERP_TEST * a standard case * a bbox overlapping the bboxes of the tree */ - void InterpolationOptionsTest::test_InterpolationOptions() { - string sourcename=getenv("MED_ROOT_DIR"); - sourcename +="/share/salome/resources/med/square1.med"; - MEDMEM::MESH source_mesh (MED_DRIVER,sourcename,"Mesh_2"); + void InterpolationOptionsTest::test_InterpolationOptions() + { + std::string sourcename=INTERP_TEST::getResourceFile("square1.med"); + MEDFileUMesh *source_mesh=MEDFileUMesh::New(sourcename.c_str(),"Mesh_2"); - string targetname=getenv("MED_ROOT_DIR"); - targetname +="/share/salome/resources/med/square2.med"; - MEDMEM::MESH target_mesh (MED_DRIVER,targetname,"Mesh_3"); + std::string targetname=INTERP_TEST::getResourceFile("square2.med"); + MEDFileUMesh *target_mesh=MEDFileUMesh::New(targetname.c_str(),"Mesh_3"); - MEDMEM::SUPPORT source_support(&source_mesh,"on All support"); - MEDMEM::FIELD source_field(&source_support,1); - double* value=const_cast(source_field.getValue()); - for (int i=0; igetMeshAtLevel(0); + MEDCouplingFieldDouble *source_field=MEDCouplingFieldDouble::New(ON_CELLS); + source_field->setMesh(source_mesh_mc); source_mesh_mc->decrRef(); + DataArrayDouble *arr=DataArrayDouble::New(); arr->alloc(source_mesh_mc->getNumberOfCells(),1); + source_field->setArray(arr); arr->decrRef(); + double *value=arr->getPointer(); + for(int i=0; igetNumberOfCells(); i++) value[i]=1.0; - - MEDMEM::SUPPORT target_support(&target_mesh,"on All support"); - MEDMEM::FIELD target_field(&target_support,1); - double* targetvalue=const_cast(target_field.getValue()); - for (int i=0; igetMeshAtLevel(0); + MEDCouplingFieldDouble *target_field=MEDCouplingFieldDouble::New(ON_CELLS); + target_field->setMesh(target_mesh_mc); target_mesh_mc->decrRef(); + arr=DataArrayDouble::New(); arr->alloc(target_mesh_mc->getNumberOfCells(),1); + target_field->setArray(arr); arr->decrRef(); + double* targetvalue=arr->getPointer(); + for(int i=0; igetNumberOfCells(); i++) targetvalue[i]=0.0; - // Ok at this point we have our mesh in MED-Memory format. // Go to wrap med_source_mesh and med_target_mesh. - MEDNormalizedUnstructuredMesh<2,2> wrap_source_mesh(&source_mesh); - MEDNormalizedUnstructuredMesh<2,2> wrap_target_mesh(&target_mesh); + MEDCouplingNormalizedUnstructuredMesh<2,2> wrap_source_mesh(source_mesh_mc); + MEDCouplingNormalizedUnstructuredMesh<2,2> wrap_target_mesh(target_mesh_mc); // Go for interpolation... INTERP_KERNEL::Interpolation2D myInterpolator; - //optionnal call to parametrize your interpolation. First precision, tracelevel, intersector wanted. + //optional call to parametrize your interpolation. First precision, tracelevel, intersector wanted. myInterpolator.setPrecision(1e-7); myInterpolator.setPrintLevel(1); + source_mesh->decrRef(); + source_field->decrRef(); + target_field->decrRef(); + target_mesh->decrRef(); } - - }