X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNELTest%2FQuadraticPlanarInterpTest4.cxx;h=92444771dce78819b4264af4959d383a2b6636f9;hb=8411b13fec372c7635bf04d2bb81a869dc038fdd;hp=cffd067b6e128478b2811a281ed643b5230047bb;hpb=48782c06022ca2caa36f849cb5a29ea4fe2aaa83;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx index cffd067b6..92444771d 100644 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx @@ -1,35 +1,39 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 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 // +// Author : Anthony Geay (CEA/DEN) + #include "QuadraticPlanarInterpTest.hxx" -#include "QuadraticPolygon.hxx" -#include "ElementaryEdge.hxx" -#include "EdgeArcCircle.hxx" -#include "EdgeLin.hxx" +#include "InterpKernelGeo2DQuadraticPolygon.hxx" +#include "InterpKernelGeo2DElementaryEdge.hxx" +#include "InterpKernelGeo2DEdgeArcCircle.hxx" +#include "InterpKernelGeo2DEdgeLin.hxx" #include #include #include #include -using namespace std; using namespace INTERP_KERNEL; +namespace INTERP_TEST +{ + void QuadraticPlanarInterpTest::checkPolygonsIntersection1() { //The "most" basic test1 @@ -40,7 +44,7 @@ void QuadraticPlanarInterpTest::checkPolygonsIntersection1() EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); // - vector result; + std::vector result; for(int k=0;k<2;k++) for(int i=0;i<3;i++) { @@ -56,8 +60,8 @@ void QuadraticPlanarInterpTest::checkPolygonsIntersection1() CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize()); double tmp1=0.,tmp2=0.,tmp3=0.; pol1.intersectForPerimeter(pol2,tmp1,tmp2,tmp3); - vector v1,v2; - vector v3; + std::vector v1,v2; + std::vector v3; pol1.intersectForPerimeterAdvanced(pol2,v1,v2);//no common edge pol1.intersectForPoint(pol2,v3); CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); @@ -161,7 +165,7 @@ void QuadraticPlanarInterpTest::checkPolygonsIntersection1() delete result[0]; double tmp1=0.,tmp2=0.,tmp3=0.; pol7.intersectForPerimeter(pol8,tmp1,tmp2,tmp3); - vector v1,v2; + std::vector v1,v2; pol7.intersectForPerimeterAdvanced(pol8,v1,v2);//only common edges. CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v1[0]+v1[1]+v1[2],1.e-14); CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v2[0]+v2[1]+v2[2],1.e-14); @@ -312,7 +316,7 @@ void QuadraticPlanarInterpTest::checkPolygonsIntersection2() // QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); - vector result=pol1.intersectMySelfWith(pol2); + std::vector result=pol1.intersectMySelfWith(pol2); CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10); @@ -491,8 +495,7 @@ void QuadraticPlanarInterpTest::checkBarycenterCalculations() */ void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1() { - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); + QuadraticPlanarPrecision::setPrecision(1e-10); double coords[]={ 8.8334591186000004, 5.0999999999999996, 7.1014083111000001, 6.0999999999999996, @@ -501,23 +504,23 @@ void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1() 7.4192455562999999, 6.5142135623000001, 8.3334591186000004, 5.9660254036999998 }; - vector nodes; + std::vector nodes; nodes.push_back(new Node(coords)); nodes.push_back(new Node(coords+2)); nodes.push_back(new Node(coords+4)); nodes.push_back(new Node(coords+6)); nodes.push_back(new Node(coords+8)); nodes.push_back(new Node(coords+10)); - QuadraticPolygon *pol=QuadraticPolygon::buildArcCirclePolygon(nodes); + QuadraticPolygon *pol=QuadraticPolygon::BuildArcCirclePolygon(nodes); CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.04719755,pol->getArea(),1e-5); CPPUNIT_ASSERT_EQUAL(3,pol->size()); ElementaryEdge *e0=dynamic_cast((*pol)[0]); ElementaryEdge *e1=dynamic_cast((*pol)[1]); ElementaryEdge *e2=dynamic_cast((*pol)[0]); CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2); - CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));//<- testing detection of colinearity + CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));// <- testing detection of colinearity CPPUNIT_ASSERT(dynamic_cast(e1->getPtr())); - CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));//<- testing detection of colinearity + CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));// <- testing detection of colinearity nodes.clear(); delete pol; nodes.push_back(new Node(coords)); @@ -526,16 +529,16 @@ void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1() nodes.push_back(new Node(coords+10)); nodes.push_back(new Node(coords+8)); nodes.push_back(new Node(coords+6)); - pol=QuadraticPolygon::buildArcCirclePolygon(nodes); + pol=QuadraticPolygon::BuildArcCirclePolygon(nodes); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.04719755,pol->getArea(),1e-5); CPPUNIT_ASSERT_EQUAL(3,pol->size()); e0=dynamic_cast((*pol)[0]); e1=dynamic_cast((*pol)[1]); e2=dynamic_cast((*pol)[0]); CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2); - CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));//<- testing detection of colinearity + CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));// <- testing detection of colinearity CPPUNIT_ASSERT(dynamic_cast(e1->getPtr())); - CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));//<- testing detection of colinearity + CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));// <- testing detection of colinearity delete pol; const double coords2[]={ 0.,0., @@ -548,7 +551,7 @@ void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1() nodes.push_back(new Node(coords2+2)); nodes.push_back(new Node(coords2+4)); nodes.push_back(new Node(coords2+6)); - pol=QuadraticPolygon::buildLinearPolygon(nodes); + pol=QuadraticPolygon::BuildLinearPolygon(nodes); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,pol->getArea(),1e-12); double tmp[2],tmp2; pol->getBarycenter(tmp,tmp2); @@ -574,23 +577,22 @@ void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1() nodes.push_back(new Node(coords3+10)); nodes.push_back(new Node(coords3+12)); nodes.push_back(new Node(coords3+14)); - pol=QuadraticPolygon::buildArcCirclePolygon(nodes); + pol=QuadraticPolygon::BuildArcCirclePolygon(nodes); pol->getBarycenter(tmp,tmp2); delete pol; - QUADRATIC_PLANAR::setPrecision(1e-14); + QuadraticPlanarPrecision::setPrecision(1e-14); } void QuadraticPlanarInterpTest::check1DInterpLin() { - QUADRATIC_PLANAR::setPrecision(1e-7); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); + QuadraticPlanarPrecision::setPrecision(1e-9); const int NB_OF_CELL_AXIAL_1=30; static const double Z_VALS_1[NB_OF_CELL_AXIAL_1+1]= { -0.1550 , -0.1356, -0.1162, -0.0969, -0.0775 ,-0.0581, -0.0387, -0.0194, 0.0000 , 0.0500, 0.1000 , 0.1500 , 0.2000 , 0.2500, 0.3000, 0.3500, 0.4000, 0.4500, 0.5000, 0.5500, 0.6000, 0.6500, 0.7000, 0.7194, 0.7388, 0.7581, 0.7775, 0.7969, 0.8163, 0.8356, 0.8550}; - vector zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1); + std::vector zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1); const int NB_OF_CELL_AXIAL_2=46; static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]= @@ -599,9 +601,9 @@ void QuadraticPlanarInterpTest::check1DInterpLin() , 0.20, 0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700 , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550 , 0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050}; - vector zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1); - map > m; - Edge::interpolate1DLin(zLev1,zLev2,m); + std::vector zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1); + std::map > m; + Edge::Interpolate1DLin(zLev1,zLev2,m); CPPUNIT_ASSERT_EQUAL(30,(int)m.size()); double ret=0; for(int i=0;i<30;i++) @@ -617,8 +619,8 @@ void QuadraticPlanarInterpTest::check1DInterpLin() static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={ 0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30, 0.35,0.40,0.45,0.50,0.55,0.60 }; - vector zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1); - Edge::interpolate1DLin(zLev3,zLev1,m); + std::vector zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1); + Edge::Interpolate1DLin(zLev3,zLev1,m); CPPUNIT_ASSERT_EQUAL(13,(int)m.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[1][8],1e-12); @@ -627,7 +629,7 @@ void QuadraticPlanarInterpTest::check1DInterpLin() CPPUNIT_ASSERT_EQUAL(1,(int)m[i+2].size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[i+2][i+9],1e-12); } - QUADRATIC_PLANAR::setPrecision(1e-14); + QuadraticPlanarPrecision::setPrecision(1e-14); } /*! @@ -635,8 +637,7 @@ void QuadraticPlanarInterpTest::check1DInterpLin() */ void QuadraticPlanarInterpTest::checkEpsilonCoherency1() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-12); const double pol1[]={ -2.1083388455000001, 1.2172499999999999, @@ -705,8 +706,7 @@ void QuadraticPlanarInterpTest::checkNonRegression1() void QuadraticPlanarInterpTest::checkNonRegression2() { - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); + QuadraticPlanarPrecision::setPrecision(1e-12); double coords1[]= { 15.141499999899999, -26.226033271399999, @@ -729,7 +729,7 @@ void QuadraticPlanarInterpTest::checkNonRegression2() 16.284787383000001, -24.763094964, 16.150490958999999, -24.132999999999999 }; - vector nodes1; + std::vector nodes1; nodes1.push_back(new Node(coords1)); nodes1.push_back(new Node(coords1+2)); nodes1.push_back(new Node(coords1+4)); @@ -738,8 +738,8 @@ void QuadraticPlanarInterpTest::checkNonRegression2() nodes1.push_back(new Node(coords1+10)); nodes1.push_back(new Node(coords1+12)); nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; + QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1); + std::vector nodes2; nodes2.push_back(new Node(coords2)); nodes2.push_back(new Node(coords2+2)); nodes2.push_back(new Node(coords2+4)); @@ -748,8 +748,8 @@ void QuadraticPlanarInterpTest::checkNonRegression2() nodes2.push_back(new Node(coords2+10)); nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); + QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + std::vector v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,v[0]->getArea(),1e-7); delete v[0]; @@ -797,8 +797,7 @@ void QuadraticPlanarInterpTest::checkNonRegression3() void QuadraticPlanarInterpTest::checkNonRegression4() { - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); + QuadraticPlanarPrecision::setPrecision(1e-12); double coords1[]= { 10.962340811000001, -22.417749999000002, @@ -822,7 +821,7 @@ void QuadraticPlanarInterpTest::checkNonRegression4() 10.797961776699999, -22.893119169449999, 10.727500000099999, -23.66 }; - vector nodes1; + std::vector nodes1; nodes1.push_back(new Node(coords1)); nodes1.push_back(new Node(coords1+2)); nodes1.push_back(new Node(coords1+4)); @@ -831,8 +830,8 @@ void QuadraticPlanarInterpTest::checkNonRegression4() nodes1.push_back(new Node(coords1+10)); nodes1.push_back(new Node(coords1+12)); nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; + QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1); + std::vector nodes2; nodes2.push_back(new Node(coords2)); nodes2.push_back(new Node(coords2+2)); nodes2.push_back(new Node(coords2+4)); @@ -841,8 +840,8 @@ void QuadraticPlanarInterpTest::checkNonRegression4() nodes2.push_back(new Node(coords2+10)); nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); + QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + std::vector v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7); delete v[0]; @@ -853,8 +852,7 @@ void QuadraticPlanarInterpTest::checkNonRegression4() void QuadraticPlanarInterpTest::checkNonRegression5() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-12); double coords1[]= { -1.7320508075000001, 1, @@ -878,7 +876,7 @@ void QuadraticPlanarInterpTest::checkNonRegression5() -2.2684999997999999, 0}; //Edge1_of_pol2 inter Edge4_of_pol1 = {-1.9381648533711939, 1.1189999998498941} //Edge4_of_pol1 _angle = -0.523598775922546, _angle0 = -3.1415926535897931, _radius = 2.2379999983074721, _center = {-1.4925279436059493e-09, 1.3300635705141101e-10}} - vector nodes1; + std::vector nodes1; nodes1.push_back(new Node(coords1)); nodes1.push_back(new Node(coords1+2)); nodes1.push_back(new Node(coords1+4)); @@ -887,8 +885,8 @@ void QuadraticPlanarInterpTest::checkNonRegression5() nodes1.push_back(new Node(coords1+10)); nodes1.push_back(new Node(coords1+12)); nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; + QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1); + std::vector nodes2; nodes2.push_back(new Node(coords2)); nodes2.push_back(new Node(coords2+2)); nodes2.push_back(new Node(coords2+4)); @@ -897,8 +895,8 @@ void QuadraticPlanarInterpTest::checkNonRegression5() nodes2.push_back(new Node(coords2+10)); nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); + QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + std::vector v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7); //delete v[0]; @@ -909,8 +907,7 @@ void QuadraticPlanarInterpTest::checkNonRegression5() void QuadraticPlanarInterpTest::checkNonRegression6() { - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + QuadraticPlanarPrecision::setPrecision(1e-12); double coords1[]= { 10.962340811000001, -22.417749999000002, @@ -931,7 +928,7 @@ void QuadraticPlanarInterpTest::checkNonRegression6() 10.832860069499999, -22.027750000200001, 10.477274402499999, -22.80719124657, 10.3955000001, -23.66}; - vector nodes1; + std::vector nodes1; nodes1.push_back(new Node(coords1)); nodes1.push_back(new Node(coords1+2)); nodes1.push_back(new Node(coords1+4)); @@ -940,8 +937,8 @@ void QuadraticPlanarInterpTest::checkNonRegression6() nodes1.push_back(new Node(coords1+10)); nodes1.push_back(new Node(coords1+12)); nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; + QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1); + std::vector nodes2; nodes2.push_back(new Node(coords2)); nodes2.push_back(new Node(coords2+2)); nodes2.push_back(new Node(coords2+4)); @@ -950,8 +947,8 @@ void QuadraticPlanarInterpTest::checkNonRegression6() nodes2.push_back(new Node(coords2+10)); nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); + QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + std::vector v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0]->getArea(),0.0150659,1e-7); delete v[0]; @@ -961,8 +958,7 @@ void QuadraticPlanarInterpTest::checkNonRegression6() void QuadraticPlanarInterpTest::checkNonRegression7() { - QUADRATIC_PLANAR::setPrecision(1e-5); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + QuadraticPlanarPrecision::setPrecision(1e-5); double coords1[]= { -2., 0, @@ -983,7 +979,7 @@ void QuadraticPlanarInterpTest::checkNonRegression7() -2.1083388453499996, 1.2172499998499999, -2.445724191994314, 0.65532982205982326, -2.4344999998499999, 0 }; - vector nodes1; + std::vector nodes1; nodes1.push_back(new Node(coords1)); nodes1.push_back(new Node(coords1+2)); nodes1.push_back(new Node(coords1+4)); @@ -992,8 +988,8 @@ void QuadraticPlanarInterpTest::checkNonRegression7() nodes1.push_back(new Node(coords1+10)); nodes1.push_back(new Node(coords1+12)); nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; + QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1); + std::vector nodes2; nodes2.push_back(new Node(coords2)); nodes2.push_back(new Node(coords2+2)); nodes2.push_back(new Node(coords2+4)); @@ -1002,8 +998,8 @@ void QuadraticPlanarInterpTest::checkNonRegression7() nodes2.push_back(new Node(coords2+10)); nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); + QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + std::vector v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.121795,v[0]->getArea(),1.e-6); delete v[0]; @@ -1013,8 +1009,7 @@ void QuadraticPlanarInterpTest::checkNonRegression7() void QuadraticPlanarInterpTest::checkNonRegression8() { - QUADRATIC_PLANAR::setPrecision(1e-3); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); + QuadraticPlanarPrecision::setPrecision(1e-3); double coords1[]= { -13.933240959000001, -28.559499999, @@ -1034,7 +1029,7 @@ void QuadraticPlanarInterpTest::checkNonRegression8() -13.933000000040851, -28.913499999870751, -15.139355569325469, -28.635180276305853, -16.323249999975001, -28.273034442748209 }; - vector nodes1; + std::vector nodes1; nodes1.push_back(new Node(coords1)); nodes1.push_back(new Node(coords1+2)); nodes1.push_back(new Node(coords1+4)); @@ -1043,8 +1038,8 @@ void QuadraticPlanarInterpTest::checkNonRegression8() nodes1.push_back(new Node(coords1+10)); nodes1.push_back(new Node(coords1+12)); nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; + QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1); + std::vector nodes2; nodes2.push_back(new Node(coords2)); nodes2.push_back(new Node(coords2+2)); nodes2.push_back(new Node(coords2+4)); @@ -1053,8 +1048,8 @@ void QuadraticPlanarInterpTest::checkNonRegression8() nodes2.push_back(new Node(coords2+10)); nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); + QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + std::vector v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.598232,v[0]->getArea(),1.e-6); delete v[0]; @@ -1064,8 +1059,7 @@ void QuadraticPlanarInterpTest::checkNonRegression8() void QuadraticPlanarInterpTest::checkNonRegression9() { - QUADRATIC_PLANAR::setPrecision(1e-7); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-8); + QuadraticPlanarPrecision::setPrecision(1e-8); double coords1[]= { -0.04476229252902969, -0.085118027765365603, @@ -1087,7 +1081,7 @@ void QuadraticPlanarInterpTest::checkNonRegression9() -0.048696224921445964, -0.087834175258503858, -0.050490195203805516, -0.087452715971391121}; - vector nodes1; + std::vector nodes1; nodes1.push_back(new Node(coords1)); nodes1.push_back(new Node(coords1+2)); nodes1.push_back(new Node(coords1+4)); @@ -1096,8 +1090,8 @@ void QuadraticPlanarInterpTest::checkNonRegression9() nodes1.push_back(new Node(coords1+10)); nodes1.push_back(new Node(coords1+12)); nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; + QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1); + std::vector nodes2; nodes2.push_back(new Node(coords2)); nodes2.push_back(new Node(coords2+2)); nodes2.push_back(new Node(coords2+4)); @@ -1106,8 +1100,8 @@ void QuadraticPlanarInterpTest::checkNonRegression9() nodes2.push_back(new Node(coords2+10)); nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); + QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + std::vector v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); delete pol1; delete pol2; @@ -1115,8 +1109,7 @@ void QuadraticPlanarInterpTest::checkNonRegression9() void QuadraticPlanarInterpTest::checkNonRegression10() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7); double coords1[]= { -0.002269581957210453, -0.09851030343724453, -0.004268022334182935, -0.1059685844580936, @@ -1145,8 +1138,7 @@ void QuadraticPlanarInterpTest::checkNonRegression10() void QuadraticPlanarInterpTest::checkNonRegression11() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7); double coords1[]= { -0.002269581957210453, -0.09851030343724453, -0.004268022334182935, -0.1059685844580936, @@ -1166,7 +1158,7 @@ void QuadraticPlanarInterpTest::checkNonRegression11() -0.002982346712452072, -0.1018362598405457, -0.003829636200350435, -0.1051516213840111}; - vector nodes1; + std::vector nodes1; nodes1.push_back(new Node(coords1)); nodes1.push_back(new Node(coords1+2)); nodes1.push_back(new Node(coords1+4)); @@ -1175,8 +1167,8 @@ void QuadraticPlanarInterpTest::checkNonRegression11() nodes1.push_back(new Node(coords1+10)); nodes1.push_back(new Node(coords1+12)); nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; + QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1); + std::vector nodes2; nodes2.push_back(new Node(coords2)); nodes2.push_back(new Node(coords2+2)); nodes2.push_back(new Node(coords2+4)); @@ -1185,8 +1177,8 @@ void QuadraticPlanarInterpTest::checkNonRegression11() nodes2.push_back(new Node(coords2+10)); nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); + QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + std::vector v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(2.28973e-06,v[0]->getArea(),1.e-11); delete v[0]; @@ -1196,8 +1188,7 @@ void QuadraticPlanarInterpTest::checkNonRegression11() void QuadraticPlanarInterpTest::checkNonRegression12() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-6); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7); double coords1[]= { -0.5032251558760915, -0.8716087994449138, -0.4695268343089433, -0.8806382374805872, @@ -1218,7 +1209,7 @@ void QuadraticPlanarInterpTest::checkNonRegression12() -0.4869622492144596, -0.8783417525850385, -0.5049019520380551, -0.8745271597139112}; - vector nodes1; + std::vector nodes1; nodes1.push_back(new Node(coords1)); nodes1.push_back(new Node(coords1+2)); nodes1.push_back(new Node(coords1+4)); @@ -1227,8 +1218,8 @@ void QuadraticPlanarInterpTest::checkNonRegression12() nodes1.push_back(new Node(coords1+10)); nodes1.push_back(new Node(coords1+12)); nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - vector nodes2; + QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1); + std::vector nodes2; nodes2.push_back(new Node(coords2)); nodes2.push_back(new Node(coords2+2)); nodes2.push_back(new Node(coords2+4)); @@ -1237,8 +1228,8 @@ void QuadraticPlanarInterpTest::checkNonRegression12() nodes2.push_back(new Node(coords2+10)); nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - vector v=pol1->intersectMySelfWith(*pol2); + QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + std::vector v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v[0]->getArea(),1.e-6); delete v[0]; @@ -1248,8 +1239,7 @@ void QuadraticPlanarInterpTest::checkNonRegression12() void QuadraticPlanarInterpTest::checkNonRegression13() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7); double coords_1[194]={ 0, 0, 0.304375, -7.454791178893722e-17, 0.2152256265236553, -0.2152256265236555, -5.591093384170291e-17, -0.304375, @@ -1313,7 +1303,7 @@ void QuadraticPlanarInterpTest::checkNonRegression13() for(int j=0;j<2;j++,work2+=8) { QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8); - //vector tmp; + //std::vector tmp; //pol1->intersectForPoint(*pol2,tmp); pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2); //pol1->intersectMySelfWith(*pol2); @@ -1330,7 +1320,7 @@ void QuadraticPlanarInterpTest::checkNonRegression13() { QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8); - //vector tmp; + //std::vector tmp; //pol1->intersectForPoint(*pol2,tmp); pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2); delete pol2; @@ -1344,8 +1334,7 @@ void QuadraticPlanarInterpTest::checkNonRegression13() */ void QuadraticPlanarInterpTest::checkNonRegression14() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7); double coords[72]={ 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1., @@ -1367,7 +1356,7 @@ void QuadraticPlanarInterpTest::checkNonRegression14() 27,28,29,30,31,32,2,33 }; QuadraticPolygon *pol1,*pol2; - vector goalOfTest; + std::vector goalOfTest; // pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8); // Level 1 @@ -1414,8 +1403,7 @@ void QuadraticPlanarInterpTest::checkNonRegression14() */ void QuadraticPlanarInterpTest::checkNonRegression15() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7); double coords[72]={ 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1., @@ -1442,7 +1430,7 @@ void QuadraticPlanarInterpTest::checkNonRegression15() //pol1 and pol2 in same orientation pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8); pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8); - vector res=pol1->intersectMySelfWith(*pol2); + std::vector res=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); @@ -1490,8 +1478,7 @@ private: */ void QuadraticPlanarInterpTest::checkNonRegression16() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7); double coords1[194]={ 0, 0, 0.304375, 0, 0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375, -0.2152256265236554, 0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236555, -0.2152256265236554, -5.591093384170291e-17, -0.304375, @@ -1540,7 +1527,7 @@ void QuadraticPlanarInterpTest::checkNonRegression16() QuadraticPolygon *pol1,*pol2; //pol1 and pol2 in same orientation - vector test1,test2; + std::vector test1,test2; for(int ii=0;ii<24;ii++) { pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8); @@ -1548,7 +1535,7 @@ void QuadraticPlanarInterpTest::checkNonRegression16() { pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8); // - vector v1,v2; + std::vector v1,v2; pol1->initLocations(); pol1->intersectForPerimeterAdvanced(*pol2,v1,v2); if(ii==16 && jj==1) @@ -1570,8 +1557,7 @@ void QuadraticPlanarInterpTest::checkNonRegression16() */ void QuadraticPlanarInterpTest::checkNonRegression17() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-7); double coords[16]={ -1., 0., 1., 0. , 1.5, 0., -1.5, 0., 0. , 1., 1.25, 0., 0., 1.5, -1.25, 0.}; @@ -1610,7 +1596,7 @@ void QuadraticPlanarInterpTest::checkNonRegression17() void QuadraticPlanarInterpTest::checkNormalize() { - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14); + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-14); Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-3.); Node *n2=new Node(10.,0.); Node *n5=new Node(10.,-3.); Node *n3=new Node(5.,10.); Node *n6=new Node(5.,7.); @@ -1622,7 +1608,8 @@ void QuadraticPlanarInterpTest::checkNormalize() QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); double area1Start=pol1.getArea(); - double fact=pol1.normalize(&pol2); + double xb,yb; + double fact=pol1.normalize(&pol2,xb,yb); double area1End=pol1.getArea(); CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14); CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14); @@ -1657,3 +1644,56 @@ void QuadraticPlanarInterpTest::checkNormalize() CPPUNIT_ASSERT_DOUBLES_EQUAL(0.034741420428165526,e1->getAreaOfZone(),1e-13); e1->decrRef(); } + +void QuadraticPlanarInterpTest::checkMakePartitionAbs1() +{ + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(1e-14); + Node *n0=new Node(0.,0.); Node *n4=new Node(0.5,0.25); + Node *n1=new Node(0.,0.5); Node *n5=new Node(0.3,1.2); + Node *n2=new Node(1.,0.5); Node *n6=new Node(1.1,1.3); + Node *n3=new Node(1.,0.); Node *n7=new Node(-0.1,0.9); + EdgeLin *e0_1=new EdgeLin(n0,n1); + EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); + EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); + EdgeLin *e3_0=new EdgeLin(n3,n0); EdgeLin *e6_4=new EdgeLin(n6,n4); + EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_5=new EdgeLin(n7,n5); + QuadraticPolygon pol1; pol1.pushBack(e0_1); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_0); + QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); + pol2.pushBack(e7_5); e4_5->incrRef(); pol2.pushBack(new ElementaryEdge(e4_5,false)); pol2.pushBack(e4_7); + n0->decrRef(); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); + pol1.dumpInXfigFileWithOther(pol2,"tony.fig"); +} + +/** + * Arc/arc intersection was buggy: a point was detected OFF when used in a linear segment, but + * detected ON when used in an (almost flat) arc of circle. + */ +void QuadraticPlanarInterpTest::checkArcArcIntersection1() +{ + double eps=1.0e-8; + INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(eps); + + Node *n0=new Node(6.37533,38.8928); Node *n3=new Node(6.29194,39.2789); + Node *n1=new Node(6.13158,38.8308); Node *n4=new Node(6.31919,38.7607); + Node *n2=new Node(6.25346,38.8618); Node *n5=new Node(6.38778,39.0241); + + Node *n6=new Node(6.2534549999999998, 38.861800000000002); // to have a linear edge e1 + + //EdgeArcCircle *e1=new EdgeArcCircle(n0, n2, n6, true); // to have a linear edge e1 + EdgeArcCircle *e1=new EdgeArcCircle(n0, n2, n1, true); + EdgeArcCircle *e2=new EdgeArcCircle(n3, n5, n4, true); + + MergePoints merge; + QuadraticPolygon c1,c2; + e1->intersectWith(e2,merge,c1,c2); + CPPUNIT_ASSERT_EQUAL(2,c1.size()); + CPPUNIT_ASSERT_EQUAL(2,c2.size()); + //clean-up + n0->decrRef(); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); + e1->decrRef(); e2->decrRef(); +} + + +} + +