-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2021 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 <cmath>
#include <sstream>
#include <iostream>
#include <iterator>
-using namespace std;
using namespace INTERP_KERNEL;
+namespace INTERP_TEST
+{
+
void QuadraticPlanarInterpTest::checkPolygonsIntersection1()
{
//The "most" basic test1
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<QuadraticPolygon *> result;
+ std::vector<QuadraticPolygon *> result;
for(int k=0;k<2;k++)
for(int i=0;i<3;i++)
{
CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize());
double tmp1=0.,tmp2=0.,tmp3=0.;
pol1.intersectForPerimeter(pol2,tmp1,tmp2,tmp3);
- vector<double> v1,v2;
- vector<int> v3;
+ std::vector<double> v1,v2;
+ std::vector<int> v3;
pol1.intersectForPerimeterAdvanced(pol2,v1,v2);//no common edge
pol1.intersectForPoint(pol2,v3);
CPPUNIT_ASSERT_EQUAL(3,(int)v1.size());
delete result[0];
double tmp1=0.,tmp2=0.,tmp3=0.;
pol7.intersectForPerimeter(pol8,tmp1,tmp2,tmp3);
- vector<double> v1,v2;
+ std::vector<double> 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);
//
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<QuadraticPolygon *> result=pol1.intersectMySelfWith(pol2);
+ std::vector<QuadraticPolygon *> 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);
*/
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,
7.4192455562999999, 6.5142135623000001,
8.3334591186000004, 5.9660254036999998
};
- vector<Node *> nodes;
+ std::vector<Node *> 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<ElementaryEdge *>((*pol)[0]);
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));
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<ElementaryEdge *>((*pol)[0]);
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.,
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);
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<double> zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1);
+ std::vector<double> 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]=
, 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<double> zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1);
- map<int,map<int,double> > m;
- Edge::interpolate1DLin(zLev1,zLev2,m);
+ std::vector<double> zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1);
+ std::map<int,std::map<int,double> > m;
+ Edge::Interpolate1DLin(zLev1,zLev2,m);
CPPUNIT_ASSERT_EQUAL(30,(int)m.size());
double ret=0;
for(int i=0;i<30;i++)
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<double> zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1);
- Edge::interpolate1DLin(zLev3,zLev1,m);
+ std::vector<double> 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);
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);
}
/*!
*/
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,
void QuadraticPlanarInterpTest::checkNonRegression2()
{
- QUADRATIC_PLANAR::setPrecision(1e-12);
- QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
+ QuadraticPlanarPrecision::setPrecision(1e-12);
double coords1[]=
{
15.141499999899999, -26.226033271399999,
16.284787383000001, -24.763094964,
16.150490958999999, -24.132999999999999
};
- vector<Node *> nodes1;
+ std::vector<Node *> nodes1;
nodes1.push_back(new Node(coords1));
nodes1.push_back(new Node(coords1+2));
nodes1.push_back(new Node(coords1+4));
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<Node *> nodes2;
+ QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
+ std::vector<Node *> nodes2;
nodes2.push_back(new Node(coords2));
nodes2.push_back(new Node(coords2+2));
nodes2.push_back(new Node(coords2+4));
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<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
+ QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
+ std::vector<QuadraticPolygon *> 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];
void QuadraticPlanarInterpTest::checkNonRegression4()
{
- QUADRATIC_PLANAR::setPrecision(1e-12);
- QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9);
+ QuadraticPlanarPrecision::setPrecision(1e-12);
double coords1[]=
{
10.962340811000001, -22.417749999000002,
10.797961776699999, -22.893119169449999,
10.727500000099999, -23.66
};
- vector<Node *> nodes1;
+ std::vector<Node *> nodes1;
nodes1.push_back(new Node(coords1));
nodes1.push_back(new Node(coords1+2));
nodes1.push_back(new Node(coords1+4));
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<Node *> nodes2;
+ QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
+ std::vector<Node *> nodes2;
nodes2.push_back(new Node(coords2));
nodes2.push_back(new Node(coords2+2));
nodes2.push_back(new Node(coords2+4));
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<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
+ QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
+ std::vector<QuadraticPolygon *> 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];
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,
-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<Node *> nodes1;
+ std::vector<Node *> nodes1;
nodes1.push_back(new Node(coords1));
nodes1.push_back(new Node(coords1+2));
nodes1.push_back(new Node(coords1+4));
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<Node *> nodes2;
+ QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
+ std::vector<Node *> nodes2;
nodes2.push_back(new Node(coords2));
nodes2.push_back(new Node(coords2+2));
nodes2.push_back(new Node(coords2+4));
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<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
+ QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
+ std::vector<QuadraticPolygon *> 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];
void QuadraticPlanarInterpTest::checkNonRegression6()
{
- QUADRATIC_PLANAR::setPrecision(1e-12);
- QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
+ QuadraticPlanarPrecision::setPrecision(1e-12);
double coords1[]=
{
10.962340811000001, -22.417749999000002,
10.832860069499999, -22.027750000200001,
10.477274402499999, -22.80719124657,
10.3955000001, -23.66};
- vector<Node *> nodes1;
+ std::vector<Node *> nodes1;
nodes1.push_back(new Node(coords1));
nodes1.push_back(new Node(coords1+2));
nodes1.push_back(new Node(coords1+4));
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<Node *> nodes2;
+ QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
+ std::vector<Node *> nodes2;
nodes2.push_back(new Node(coords2));
nodes2.push_back(new Node(coords2+2));
nodes2.push_back(new Node(coords2+4));
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<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
+ QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
+ std::vector<QuadraticPolygon *> 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];
void QuadraticPlanarInterpTest::checkNonRegression7()
{
- QUADRATIC_PLANAR::setPrecision(1e-5);
- QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
+ QuadraticPlanarPrecision::setPrecision(1e-5);
double coords1[]=
{
-2., 0,
-2.1083388453499996, 1.2172499998499999,
-2.445724191994314, 0.65532982205982326,
-2.4344999998499999, 0 };
- vector<Node *> nodes1;
+ std::vector<Node *> nodes1;
nodes1.push_back(new Node(coords1));
nodes1.push_back(new Node(coords1+2));
nodes1.push_back(new Node(coords1+4));
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<Node *> nodes2;
+ QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
+ std::vector<Node *> nodes2;
nodes2.push_back(new Node(coords2));
nodes2.push_back(new Node(coords2+2));
nodes2.push_back(new Node(coords2+4));
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<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
+ QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
+ std::vector<QuadraticPolygon *> 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];
void QuadraticPlanarInterpTest::checkNonRegression8()
{
- QUADRATIC_PLANAR::setPrecision(1e-3);
- QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5);
+ QuadraticPlanarPrecision::setPrecision(1e-3);
double coords1[]=
{
-13.933240959000001, -28.559499999,
-13.933000000040851, -28.913499999870751,
-15.139355569325469, -28.635180276305853,
-16.323249999975001, -28.273034442748209 };
- vector<Node *> nodes1;
+ std::vector<Node *> nodes1;
nodes1.push_back(new Node(coords1));
nodes1.push_back(new Node(coords1+2));
nodes1.push_back(new Node(coords1+4));
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<Node *> nodes2;
+ QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
+ std::vector<Node *> nodes2;
nodes2.push_back(new Node(coords2));
nodes2.push_back(new Node(coords2+2));
nodes2.push_back(new Node(coords2+4));
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<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
+ QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
+ std::vector<QuadraticPolygon *> 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];
void QuadraticPlanarInterpTest::checkNonRegression9()
{
- QUADRATIC_PLANAR::setPrecision(1e-7);
- QUADRATIC_PLANAR::setArcDetectionPrecision(1e-8);
+ QuadraticPlanarPrecision::setPrecision(1e-8);
double coords1[]=
{
-0.04476229252902969, -0.085118027765365603,
-0.048696224921445964, -0.087834175258503858,
-0.050490195203805516, -0.087452715971391121};
- vector<Node *> nodes1;
+ std::vector<Node *> nodes1;
nodes1.push_back(new Node(coords1));
nodes1.push_back(new Node(coords1+2));
nodes1.push_back(new Node(coords1+4));
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<Node *> nodes2;
+ QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
+ std::vector<Node *> nodes2;
nodes2.push_back(new Node(coords2));
nodes2.push_back(new Node(coords2+2));
nodes2.push_back(new Node(coords2+4));
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<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
+ QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
+ std::vector<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
delete pol1;
delete pol2;
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,
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,
-0.002982346712452072, -0.1018362598405457,
-0.003829636200350435, -0.1051516213840111};
- vector<Node *> nodes1;
+ std::vector<Node *> nodes1;
nodes1.push_back(new Node(coords1));
nodes1.push_back(new Node(coords1+2));
nodes1.push_back(new Node(coords1+4));
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<Node *> nodes2;
+ QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
+ std::vector<Node *> nodes2;
nodes2.push_back(new Node(coords2));
nodes2.push_back(new Node(coords2+2));
nodes2.push_back(new Node(coords2+4));
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<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
+ QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
+ std::vector<QuadraticPolygon *> 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];
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,
-0.4869622492144596, -0.8783417525850385,
-0.5049019520380551, -0.8745271597139112};
- vector<Node *> nodes1;
+ std::vector<Node *> nodes1;
nodes1.push_back(new Node(coords1));
nodes1.push_back(new Node(coords1+2));
nodes1.push_back(new Node(coords1+4));
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<Node *> nodes2;
+ QuadraticPolygon *pol1=QuadraticPolygon::BuildArcCirclePolygon(nodes1);
+ std::vector<Node *> nodes2;
nodes2.push_back(new Node(coords2));
nodes2.push_back(new Node(coords2+2));
nodes2.push_back(new Node(coords2+4));
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<QuadraticPolygon *> v=pol1->intersectMySelfWith(*pol2);
+ QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2);
+ std::vector<QuadraticPolygon *> 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];
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,
for(int j=0;j<2;j++,work2+=8)
{
QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
- //vector<int> tmp;
+ //std::vector<int> tmp;
//pol1->intersectForPoint(*pol2,tmp);
pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
//pol1->intersectMySelfWith(*pol2);
{
QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8);
- //vector<int> tmp;
+ //std::vector<int> tmp;
//pol1->intersectForPoint(*pol2,tmp);
pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2);
delete pol2;
*/
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.,
27,28,29,30,31,32,2,33
};
QuadraticPolygon *pol1,*pol2;
- vector<int> goalOfTest;
+ std::vector<int> goalOfTest;
//
pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
// Level 1
*/
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.,
//pol1 and pol2 in same orientation
pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8);
pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8);
- vector<QuadraticPolygon *> res=pol1->intersectMySelfWith(*pol2);
+ std::vector<QuadraticPolygon *> 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);
*/
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,
QuadraticPolygon *pol1,*pol2;
//pol1 and pol2 in same orientation
- vector<double> test1,test2;
+ std::vector<double> test1,test2;
for(int ii=0;ii<24;ii++)
{
pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8);
{
pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8);
//
- vector<double> v1,v2;
+ std::vector<double> v1,v2;
pol1->initLocations();
pol1->intersectForPerimeterAdvanced(*pol2,v1,v2);
if(ii==16 && jj==1)
*/
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.};
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.);
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);
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();
+}
+
+
+}
+
+