Salome HOME
[TetraIntersect] Formatting and including what's inline really inline!
[tools/medcoupling.git] / src / INTERP_KERNELTest / QuadraticPlanarInterpTest4.cxx
index 5ab41b33e10b7efcd163ddb3d68fc2b149d52c46..6259d42dfb179c8bc2ee583046d334059df5df65 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024  CEA, EDF
 //
 // 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.
+// 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
@@ -495,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,
@@ -519,9 +518,9 @@ void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1()
   ElementaryEdge *e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
   ElementaryEdge *e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
   CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
-  CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));//<- testing detection of colinearity
+  CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));// <- testing detection of colinearity
   CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
-  CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));//<- testing detection of colinearity
+  CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));// <- testing detection of colinearity
   nodes.clear();
   delete pol;
   nodes.push_back(new Node(coords));
@@ -537,9 +536,9 @@ void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1()
   e1=dynamic_cast<ElementaryEdge *>((*pol)[1]);
   e2=dynamic_cast<ElementaryEdge *>((*pol)[0]);
   CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2);
-  CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));//<- testing detection of colinearity
+  CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e0->getPtr()));// <- testing detection of colinearity
   CPPUNIT_ASSERT(dynamic_cast<EdgeArcCircle *>(e1->getPtr()));
-  CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));//<- testing detection of colinearity
+  CPPUNIT_ASSERT(dynamic_cast<EdgeLin *>(e2->getPtr()));// <- testing detection of colinearity
   delete pol;
   const double coords2[]={
     0.,0.,
@@ -581,13 +580,12 @@ void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1()
   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, 
@@ -631,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);
 }
 
 /*!
@@ -639,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,
@@ -709,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,
@@ -801,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,
@@ -857,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,
@@ -913,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,
@@ -965,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,
@@ -1017,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,
@@ -1068,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,
@@ -1119,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,
@@ -1149,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,
@@ -1200,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,
@@ -1252,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, 
@@ -1348,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.,
@@ -1418,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.,
@@ -1494,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, 
@@ -1574,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.};
@@ -1614,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.);
@@ -1665,7 +1647,7 @@ void QuadraticPlanarInterpTest::checkNormalize()
 
 void QuadraticPlanarInterpTest::checkMakePartitionAbs1()
 {
-  INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14);
+  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);
@@ -1682,4 +1664,36 @@ void QuadraticPlanarInterpTest::checkMakePartitionAbs1()
   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();
 }
+
+
+}
+
+