From da5b690aeaee908b808cbf393d9ab5d4848a1f58 Mon Sep 17 00:00:00 2001 From: ndjinga Date: Fri, 3 Aug 2007 08:48:21 +0000 Subject: [PATCH] adding tests for 2D interp --- src/INTERP_KERNEL/3D_Vertex_Less.hxx | 22 ++ src/INTERP_KERNEL/test_InterpolationUtils.cxx | 337 ++++++++++++++++++ 2 files changed, 359 insertions(+) create mode 100644 src/INTERP_KERNEL/3D_Vertex_Less.hxx create mode 100644 src/INTERP_KERNEL/test_InterpolationUtils.cxx diff --git a/src/INTERP_KERNEL/3D_Vertex_Less.hxx b/src/INTERP_KERNEL/3D_Vertex_Less.hxx new file mode 100644 index 000000000..49d57f81a --- /dev/null +++ b/src/INTERP_KERNEL/3D_Vertex_Less.hxx @@ -0,0 +1,22 @@ +#ifndef _3D_VERTEX_HXX_ +#define _3D_VERTEX_HXX_ + +namespace MEDMEM +{ + struct Vertex_Less_3D + { + //double * x; + bool operator()(const double * p1,const double * p2) + { + return (*p1 < *p2) + || + ((*p1 == *p2)&&(*(p1+1) < *(p2+1))) + || + ((*p1 == *p2)&&(*(p1+1) == *(p2+1))&&(*(p1+2) < *(p2+2))); + } + }; + + // bool operator()(const double * p1,const double * p2) + +}; +#endif diff --git a/src/INTERP_KERNEL/test_InterpolationUtils.cxx b/src/INTERP_KERNEL/test_InterpolationUtils.cxx new file mode 100644 index 000000000..a68579ea2 --- /dev/null +++ b/src/INTERP_KERNEL/test_InterpolationUtils.cxx @@ -0,0 +1,337 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : testUUnit.cxx +// Module : MED + +#include "InterpolationUtils.hxx" +using namespace std; + +int main () +{ + cerr<< endl; + cerr<< " ************ Test 1 ************ "<< endl; + + const double Losange1[12]= + { + 1,0,0, + 0,1,0, + -1,0,0, + 0,-1,0 + }; + + const double Losange2[12]= + { + 2,0,0, + 1,1,0, + 0,0,0, + 1,-1,0 + }; + + deque< double > resultat_test1 = INTERP_UTILS::intersect_convex_polygons(Losange1,Losange2,4,4,1,1e-6); + + cerr<< " Test1: Résultat théorique" << endl; + cerr<< 0.5 << " ,"<< -0.5 << " ," << 0 << endl; + cerr<< 0 << " ,"<< 0 << " ,"<< 0 << endl; + cerr<< 0.5 << " ,"<< 0.5 << " ,"<< 0 << endl; + cerr<< 1 << " ," << 0 << " ," << 0 << endl; + + cerr<< " Test1: Résultat obtenu" << endl; + for (int i=0; i resultat_test2 = INTERP_UTILS::intersect_convex_polygons(Losange1,Losange3,4,4,1,1e-6); + + cerr<< " Test2: Résultat théorique" << endl; +// cerr<< 0.5 << " ,"<< 0.5 << " ," << 0 << endl; +// cerr<< 1 << " ,"<< 0 << " ," << 0 << endl; + + cerr<< " Test2: Résultat obtenu" << endl; + for (int i=0; i resultat_test3 = INTERP_UTILS::intersect_convex_polygons( Carre1, Carre2,4,4,1,1e-6); + + cerr<< " Test3: Résultat théorique" << endl; + cerr<< 0 << " ,"<< 0.25 << " ," << 0 << endl; + cerr<< 0 << " ,"<< -0.25 << " ," << 0 << endl; + cerr<< 1 << " ,"<< -0.25 << " ,"<< 0 << endl; + cerr<< 1 << " ,"<< 0.25 << " ," << 0 << endl; + + cerr<< " Test3: Résultat obtenu" << endl; + for (int i=0; i resultat_test4 = INTERP_UTILS::intersect_convex_polygons( Losange1, Losange4,4,4,1,1e-6); + + cerr<< " Test4: Résultat théorique" << endl; + cerr<< 1 << " ,"<< 0 << " ,"<< 0 << endl; + + cerr<< " Test4: Résultat obtenu" << endl; + for (int i=0; i resultat_test5 = INTERP_UTILS::intersect_convex_polygons( Carre1, Carre1,4,4,1,1e-6); + + cerr<< " Test5: Résultat théorique" << endl; + cerr<< -1 << " ,"<< 1 << " ," << 0 << endl; + cerr<< -1 << " ,"<< -1 << " ," << 0 << endl; + cerr<< 1 << " ,"<< -1 << " ," << 0 << endl; + cerr<< 1 << " ,"<< 1 << " ," << 0 << endl; + + cerr<< " Test5: Résultat obtenu" << endl; + for (int i=0; i resultat_test6 = INTERP_UTILS::intersect_convex_polygons( Carre1, Losange5,4,4,1,1e-6); + + cerr<< " Test6: Résultat théorique" << endl; + cerr<< 1 << " ,"<< -0.5 << " ," << 0 << endl; + cerr<< 0.5 << " ,"<< -1 << " ," << 0 << endl; + cerr<< -0.5 << " ,"<< -1 << " ," << 0 << endl; + cerr<< -1 << " ,"<< -0.5 << " ," << 0 << endl; + cerr<< -1 << " ,"<< 0.5 << " ," << 0 << endl; + cerr<< -0.5 << " ,"<< 1 << " ," << 0 << endl; + cerr<< 0.5 << " ,"<< 1 << " ,"<< 0 << endl; + cerr<< 1 << " ,"<< 0.5 << " ," << 0 << endl; + + cerr<< " Test6: Résultat obtenu" << endl; + for (int i=0; i resultat_test7 = INTERP_UTILS::intersect_convex_polygons( Losange1, Carre1,4,4,1,1e-6); + + cerr<< " Test7: Résultat théorique" << endl; + cerr<< 0 << " ,"<< -1 << " ," << 0 << endl; + cerr<< -1 << " ,"<< 0 << " ," << 0 << endl; + cerr<< 0 << " ,"<< 1 << " ,"<< 0 << endl; + cerr<< 1 << " ,"<< 0 << " ," << 0 << endl; + + cerr<< " Test7: Résultat obtenu" << endl; + for (int i=0; i resultat_test8 = INTERP_UTILS::intersect_convex_polygons(Losange6,Losange7,6,5,1,1e-6); + + cerr<< " Test8: Résultat théorique" << endl; + cerr<< 0.5 << " ,"<< -0.5 << " ," << 0 << endl; + cerr<< 0 << " ,"<< 0 << " ,"<< 0 << endl; + cerr<< 0.5 << " ,"<< 0.5 << " ,"<< 0 << endl; + cerr<< 1 << " ," << 0 << " ," << 0 << endl; + + cerr<< " Test8: Résultat obtenu" << endl; + for (int i=0; i resultat_test9 = INTERP_UTILS::intersect_convex_polygons(Carre4,Carre3,4,5,1,1e-6); + + cerr<< " Test9: Résultat théorique" << endl; + cerr<< -0.5 << " ,"<< -1 << " ," << 0 << endl; + cerr<< -0.5 << " ,"<< 1 << " ," << 0 << endl; + cerr<< 1 << " ,"<< 1 << " ," << 0 << endl; + cerr<< 1 << " ,"<< -1 << " ," << 0 << endl; + + cerr<< " Test9: Résultat obtenu" << endl; + for (int i=0; i resultat_test10 = INTERP_UTILS::intersect_convex_polygons(Losange8,Carre5,4,5,1,1e-6); + cerr<< " Test10: Résultat théorique" << endl; + cerr<< 0 << " ,"<< 1 << " ," << 0 << endl; + cerr<< -0.5 << " ,"<< -1 << " ," << 0 << endl; + cerr<< 1 << " ,"<< -1 << " ," << 0 << endl; + + cerr<< " Test10: Résultat obtenu" << endl; + for (int i=0; i resultat_test11 = INTERP_UTILS::intersect_convex_polygons(Losange1,Losange9,4,4,1,1e-6); + + cerr<< " Test11: Résultat théorique" << endl; + cerr<< 0 << " ,"<< -1 << " ," << 0 << endl; + cerr<< -1 << " ,"<< 0 << " ,"<< 0 << endl; + cerr<< 0 << " ,"<< 1 << " ,"<< 0 << endl; + cerr<< 0.5 << " ," << 0 << " ," << 0 << endl; + + cerr<< " Test11: Résultat obtenu" << endl; + for (int i=0; i