X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNELTest%2FUnitTetraIntersectionBaryTest.cxx;h=5c3b4c6b76e73132dbc4e8717b9a4dcc2935ce0a;hb=214cb0a3e23e084616ebf247642bfbc43811e26d;hp=2c9570fbdcacad20abec1219d31b11ffe04f518f;hpb=378cb2ebe08f8f4543ef632b2bd5f77fe180f978;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx old mode 100755 new mode 100644 index 2c9570fbd..5c3b4c6b7 --- a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx +++ b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2023 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 @@ -27,6 +27,7 @@ #include "TetraAffineTransform.hxx" #include "InterpolationUtils.hxx" #include "SplitterTetra.txx" +#include "MCIdType.hxx" #include @@ -271,7 +272,7 @@ namespace INTERP_TEST struct __MESH_DUMMY { - typedef int MyConnType; + typedef mcIdType MyConnType; }; void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_13() @@ -288,7 +289,7 @@ namespace INTERP_TEST 75,150,75, 100,100,100}; - int conn[4] = { 0,1,2,3 }; + mcIdType conn[4] = { 0,1,2,3 }; const double* tnodes[4]={ T, T+3, T+6, T+9 }; const double* snodes[4]={ S, S+3, S+6, S+9 }; @@ -342,5 +343,148 @@ namespace INTERP_TEST CPPUNIT_ASSERT_DOUBLES_EQUAL( p[0], p2[0], 1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL( p[1], p2[1], 1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL( p[2], p2[2], 1e-12); - } + } + + /* Conventions: + * - for HEXA8, point 5 is taken to be the origin (see med file ref connec): + * 0 ------ 3 + /| /| + / | / | + 1 ------ 2 | + | | | | + | | | | + | 4-----|- 7 + | / | / + 5 ------ 6 + */ + void UnitTetraIntersectionBaryTest::test_cuboid_mapped_coords_3D() + { + double nodes[8][3] = { { 0.0, 2.0, 4.0 }, //0 + { 0.0, 0.0, 4.0 }, + { 1.0, 0.0, 4.0 }, + { 1.0, 2.0, 4.0 }, + { 0.0, 2.0, 0.0 }, // 4 + { 0.0, 0.0, 0.0 }, + { 1.0, 0.0, 0.0 }, + { 1.0, 2.0, 0.0 } + }; + // Translate cube: + for (int i=0; i < 8; ++i) + for (int j=0; j < 3; ++j) + nodes[i][j] += 15.0; + + std::vector n (8); + for (int i=0; i<8; i++) + n[i] = &nodes[i][0]; + + { + // middle point + double p[3] = { 15.5, 16.0, 17.0 }, bc[3]; + cuboid_mapped_coords(n, p, bc); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[1], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[2], 1e-12); + } + { + // point 1 + double p[3] = { 15.0, 15.0, 19.0 }, bc[3]; + cuboid_mapped_coords(n, p, bc); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[1], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[2], 1e-12); + } + { + // point 7 + double p[3] = { 16.0, 17.0, 15.0 }, bc[3]; + cuboid_mapped_coords(n, p, bc); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[2], 1e-12); + } + { + // point 3 + double p[3] = { 16.0, 17.0, 19.0 }, bc[3]; + cuboid_mapped_coords(n, p, bc); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[2], 1e-12); + } + { + // point outside + double p[3] = { 2.0, 16.0, 18.0 }, bc[3]; + CPPUNIT_ASSERT_THROW(cuboid_mapped_coords(n, p, bc), INTERP_KERNEL::Exception); + } + + } + + /* Convention + - for QUAD4, point 0 is taken to be the origin (again see med file ref connec): + + 1------2 + | | + | | + 0------3 + */ + void UnitTetraIntersectionBaryTest::test_quad_mapped_coords_2D() + { + + double nodes[4][2] = { { 0.0, 0.0 }, + { 0.0, 1.0 }, + { 2.0, 3.0 }, + { 1.0, 0.0 } }; + + // Translate quad4: + for (int i=0; i < 4; ++i) + for (int j=0; j < 2; ++j) + nodes[i][j] += 15.0; + + std::vector n (4); + for (int i=0; i<4; i++) + n[i] = &nodes[i][0]; + + { + // middle point + double p[2] = { 15.75, 16.0 }, bc[2]; + quad_mapped_coords(n, p, bc); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[1], 1e-12); + } + + { + // middle point of seg + double p[2] = { 15.5, 15.0 }, bc[2]; + quad_mapped_coords(n, p, bc); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, bc[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[1], 1e-12); + } + + { + // point 1 + double p[2] = { 15.0, 16.0 }, bc[2]; + quad_mapped_coords(n, p, bc); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12); + } + { + // point 2 + double p[2] = { 17.0, 18.0 }, bc[2]; + quad_mapped_coords(n, p, bc); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[1], 1e-12); + } + { + // point 3 + double p[2] = { 16.0, 15.0 }, bc[2]; + quad_mapped_coords(n, p, bc); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, bc[0], 1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, bc[1], 1e-12); + } + { + // point outside + double p[2] = { 18.0, 18.0 }, bc[2]; + CPPUNIT_ASSERT_THROW(quad_mapped_coords(n, p, bc), INTERP_KERNEL::Exception); + } + } + + }