1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "InterpolationOptionsTest.hxx"
20 #include "MEDNormalizedUnstructuredMesh.hxx"
21 #include "Interpolation2D.hxx"
29 void InterpolationOptionsTest::setUp()
34 void InterpolationOptionsTest::tearDown()
39 * Test that creates a tree in 2D and check that
40 * the results are correct in three
42 * a non matching search
44 * a bbox overlapping the bboxes of the tree
46 void InterpolationOptionsTest::test_InterpolationOptions() {
47 string sourcename=getenv("MED_ROOT_DIR");
48 sourcename +="/share/salome/resources/med/square1.med";
49 MEDMEM::MESH source_mesh (MED_DRIVER,sourcename,"Mesh_2");
51 string targetname=getenv("MED_ROOT_DIR");
52 targetname +="/share/salome/resources/med/square2.med";
53 MEDMEM::MESH target_mesh (MED_DRIVER,targetname,"Mesh_3");
55 MEDMEM::SUPPORT source_support(&source_mesh,"on All support");
56 MEDMEM::FIELD<double> source_field(&source_support,1);
57 double* value=const_cast<double*>(source_field.getValue());
58 for (int i=0; i<source_support.getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); i++)
61 MEDMEM::SUPPORT target_support(&target_mesh,"on All support");
62 MEDMEM::FIELD<double> target_field(&target_support,1);
63 double* targetvalue=const_cast<double*>(target_field.getValue());
64 for (int i=0; i<target_support.getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); i++)
67 // Ok at this point we have our mesh in MED-Memory format.
68 // Go to wrap med_source_mesh and med_target_mesh.
69 MEDNormalizedUnstructuredMesh<2,2> wrap_source_mesh(&source_mesh);
70 MEDNormalizedUnstructuredMesh<2,2> wrap_target_mesh(&target_mesh);
71 // Go for interpolation...
72 INTERP_KERNEL::Interpolation2D myInterpolator;
73 //optionnal call to parametrize your interpolation. First precision, tracelevel, intersector wanted.
74 myInterpolator.setPrecision(1e-7);
75 myInterpolator.setPrintLevel(1);