From bc8e0ec7fd1942e0650878116f5093c1abb6a72c Mon Sep 17 00:00:00 2001 From: geay Date: Mon, 24 Feb 2014 12:05:30 +0100 Subject: [PATCH] Last checks of the new option for 3D surf --- src/INTERP_KERNEL/Geometric2DIntersector.txx | 4 ++-- src/INTERP_KERNEL/PlanarIntersector.txx | 10 ++++++++-- .../ThreeDSurfProjectionTest.cxx | 20 +++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.txx b/src/INTERP_KERNEL/Geometric2DIntersector.txx index 6b1e0f103..e153067a3 100644 --- a/src/INTERP_KERNEL/Geometric2DIntersector.txx +++ b/src/INTERP_KERNEL/Geometric2DIntersector.txx @@ -63,7 +63,7 @@ namespace INTERP_KERNEL QuadraticPolygon *p2=buildPolygonFrom(CoordsS,tS); double ret=p1->intersectWithAbs(*p2); delete p1; delete p2; - return ret; + return orientation*ret; } INTERSECTOR_TEMPLATE @@ -81,7 +81,7 @@ namespace INTERP_KERNEL QuadraticPolygon *p2=buildPolygonOfOneEdgeFrom(CoordsS,tS); double ret=p1->intersectWithAbs1D(*p2, isColinear); delete p1; delete p2; - return ret; + return orientation*ret; } INTERSECTOR_TEMPLATE diff --git a/src/INTERP_KERNEL/PlanarIntersector.txx b/src/INTERP_KERNEL/PlanarIntersector.txx index 6f0c5aa5d..11b959dec 100644 --- a/src/INTERP_KERNEL/PlanarIntersector.txx +++ b/src/INTERP_KERNEL/PlanarIntersector.txx @@ -32,7 +32,7 @@ namespace INTERP_KERNEL template PlanarIntersector::PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel): _meshT(meshT),_meshS(meshS), - _dim_caracteristic(dimCaracteristic),_max_distance_3Dsurf_intersect(md3DSurf),_precision(precision),_median_plane(medianPlane), + _dim_caracteristic(dimCaracteristic),_max_distance_3Dsurf_intersect(md3DSurf),_min_dot_btw_3Dsurf_intersect(minDot3DSurf),_precision(precision),_median_plane(medianPlane), _do_rotate(doRotate),_orientation(orientation),_print_level(printLevel) { _connectT=meshT.getConnectivityPtr(); @@ -344,7 +344,13 @@ namespace INTERP_KERNEL if(i_A2(normal_A,normal_B)>=0; + + double dotProd(dotprod(normal_A,normal_B)/(normA*normB)); + + if(fabs(dotProd)=0); if(!same_orientation) for(int idim =0; idim< SPACEDIM; idim++) diff --git a/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.cxx b/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.cxx index cce28e644..5d66b9d19 100644 --- a/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.cxx +++ b/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.cxx @@ -100,6 +100,26 @@ void INTERP_TEST::ThreeDSurfProjectionTest::test2() std::copy(coo2,coo2+9,tmp1); ret=INTERP_KERNEL::PlanarIntersector::Projection(tmp0,tmp1,3,3,1e-2,1e-8/* <- */,-1.,0.5,true); CPPUNIT_ASSERT_EQUAL(0,ret); + // again max 3D distance is 1e-5 > 1e-6 so 1 is expected + std::copy(coo,coo+9,tmp0); + std::copy(coo2,coo2+9,tmp1); + ret=INTERP_KERNEL::PlanarIntersector::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,-1.,0.5,true); + CPPUNIT_ASSERT_EQUAL(1,ret); + // again max 3D distance is 1e-5 > 1e-6 but minDot set to 0.8. 0 expected. because the angle is pi/4 so cos(pi/3) > 0.8 + std::copy(coo,coo+9,tmp0); + std::copy(coo2,coo2+9,tmp1); + ret=INTERP_KERNEL::PlanarIntersector::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,0.8/* <- */,0.5,true); + CPPUNIT_ASSERT_EQUAL(0,ret); + // again max 3D distance is 1e-5 > 1e-6 but minDot set to 0.7. 1 expected. because the angle is pi/4 so cos(pi/3) < 0.49 + std::copy(coo,coo+9,tmp0); + std::copy(coo2,coo2+9,tmp1); + ret=INTERP_KERNEL::PlanarIntersector::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,0.49/* <- */,0.5,true); + CPPUNIT_ASSERT_EQUAL(1,ret); + // again max 3D distance is 1e-5 > 1e-6 but minDot set to 0.7. 0 expected. because the angle is pi/4 so cos(pi/3) > 0.51 + std::copy(coo,coo+9,tmp0); + std::copy(coo2,coo2+9,tmp1); + ret=INTERP_KERNEL::PlanarIntersector::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,0.51/* <- */,0.5,true); + CPPUNIT_ASSERT_EQUAL(0,ret); // delete [] tmp0; delete [] tmp1; -- 2.39.2