Back to index

salome-med  6.5.0
UnitTetra3D2DIntersectionTest.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "UnitTetra3D2DIntersectionTest.hxx"
00021 
00022 #include "TetraAffineTransform.hxx"
00023 #include "InterpolationUtils.hxx"
00024 #include "SplitterTetra.txx"
00025 
00026 #include <iostream>
00027 
00028 using namespace INTERP_KERNEL;
00029 
00030 namespace INTERP_TEST
00031 {
00032   struct __MESH_DUMMY
00033   {
00034     typedef int MyConnType;
00035     static const int MY_SPACEDIM=3;
00036   };
00037 
00038   static SplitterTetra<__MESH_DUMMY>* buildSplitterTetra()
00039   {
00040     const int conn[4] = { 0,1,2,3 };
00041 
00042     const double targetCoords[] = { -20., 0.,10.,
00043                                     -20.,10.,10.,
00044                                     -12., 0.,10.,
00045                                     -20., 0.,18. };
00046 
00047     const double* tetraCoords[]={ targetCoords, targetCoords+3, targetCoords+6, targetCoords+9 };
00048 
00049     __MESH_DUMMY dummyMesh;
00050     SplitterTetra<__MESH_DUMMY>* targetTetra = new SplitterTetra<__MESH_DUMMY>( dummyMesh, tetraCoords, conn );
00051     return targetTetra;
00052   }
00053 
00054   void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_1()
00055   {
00056     const int conn[4] = { 0,1,2 };
00057 
00058     const double sourceCoords[] = { -20., 0., 10.,
00059                                     -12., 0., 10.,
00060                                     -20.,10., 10. };
00061 
00062     SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
00063     const double dimCaracteristic = 1.;
00064     const double precision = 1.e-12;
00065     std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
00066     std::set<TriangleFaceKey> listOfTetraFacesColinear;
00067 
00068     const double* sourceTriCoords[] = { sourceCoords, sourceCoords+3, sourceCoords+6 };
00069     double surface = targetTetra->intersectSourceFace(NORM_TRI3,
00070                                                       3,
00071                                                       conn,
00072                                                       sourceTriCoords,
00073                                                       dimCaracteristic,
00074                                                       precision,
00075                                                       listOfTetraFacesTreated,
00076                                                       listOfTetraFacesColinear);
00077 
00078     CPPUNIT_ASSERT_DOUBLES_EQUAL(40.,surface,precision);
00079 
00080     CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size());
00081     std::multiset<TriangleFaceKey> correctListOfTetraFacesTreated;
00082     TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2);
00083     correctListOfTetraFacesTreated.insert(key1);
00084     TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3);
00085     correctListOfTetraFacesTreated.insert(key2);
00086     TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3);
00087     correctListOfTetraFacesTreated.insert(key3);
00088     TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3);
00089     correctListOfTetraFacesTreated.insert(key4);
00090     CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated);
00091 
00092     CPPUNIT_ASSERT_EQUAL(1,(int)listOfTetraFacesColinear.size());
00093     std::set<TriangleFaceKey> correctListOfTetraFacesColinear;
00094     correctListOfTetraFacesColinear.insert(key1);
00095     CPPUNIT_ASSERT(correctListOfTetraFacesColinear == listOfTetraFacesColinear);
00096 
00097   }
00098 
00099   void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_2()
00100   {
00101     const int conn[4] = { 0,1,2,3 };
00102 
00103     const double sourceCoords[] = { -20., 0., 10.,
00104                                     -12., 0., 10.,
00105                                     -12.,10., 10.,
00106                                     -20.,10., 10. };
00107 
00108     SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
00109     const double dimCaracteristic = 1.;
00110     const double precision = 1.e-12;
00111     std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
00112     std::set<TriangleFaceKey> listOfTetraFacesColinear;
00113 
00114     const double* sourceQuadCoords[] = { sourceCoords, sourceCoords+3, sourceCoords+6, sourceCoords+9 };
00115     double surface = targetTetra->intersectSourceFace(NORM_QUAD4,
00116                                                       4,
00117                                                       conn,
00118                                                       sourceQuadCoords,
00119                                                       dimCaracteristic,
00120                                                       precision,
00121                                                       listOfTetraFacesTreated,
00122                                                       listOfTetraFacesColinear);
00123 
00124     CPPUNIT_ASSERT_DOUBLES_EQUAL(40.,surface,precision);
00125 
00126     CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size());
00127     std::multiset<TriangleFaceKey> correctListOfTetraFacesTreated;
00128     TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2);
00129     correctListOfTetraFacesTreated.insert(key1);
00130     TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3);
00131     correctListOfTetraFacesTreated.insert(key2);
00132     TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3);
00133     correctListOfTetraFacesTreated.insert(key3);
00134     TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3);
00135     correctListOfTetraFacesTreated.insert(key4);
00136     CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated);
00137 
00138     CPPUNIT_ASSERT_EQUAL(1,(int)listOfTetraFacesColinear.size());
00139     std::set<TriangleFaceKey> correctListOfTetraFacesColinear;
00140     correctListOfTetraFacesColinear.insert(key1);
00141     CPPUNIT_ASSERT(correctListOfTetraFacesColinear == listOfTetraFacesColinear);
00142 
00143  }
00144 
00145   void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_3()
00146   {
00147     const int conn[4] = { 0,1,2 };
00148 
00149     const double sourceCoords[] = { -20., 0., 16.,
00150                                     -18., 0., 16.,
00151                                     -20.,2.5, 16. };
00152 
00153     SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
00154     const double dimCaracteristic = 1.;
00155     const double precision = 1.e-12;
00156     std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
00157     std::set<TriangleFaceKey> listOfTetraFacesColinear;
00158 
00159     const double* sourceTri2Coords[] = { sourceCoords, sourceCoords+3, sourceCoords+6 };
00160     double surface = targetTetra->intersectSourceFace(NORM_TRI3,
00161                                                       3,
00162                                                       conn,
00163                                                       sourceTri2Coords,
00164                                                       dimCaracteristic,
00165                                                       precision,
00166                                                       listOfTetraFacesTreated,
00167                                                       listOfTetraFacesColinear);
00168 
00169     CPPUNIT_ASSERT_DOUBLES_EQUAL(2.5,surface,precision);
00170 
00171     CPPUNIT_ASSERT_EQUAL(0,(int)listOfTetraFacesTreated.size());
00172 
00173     CPPUNIT_ASSERT_EQUAL(0,(int)listOfTetraFacesColinear.size());
00174  }
00175 
00176 }