From: ageay Date: Thu, 16 Feb 2012 14:12:46 +0000 (+0000) Subject: Tessellate. X-Git-Tag: V6_main_FINAL~854 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a2d51a2ce2198b68f610495db76401ac32afc440;p=tools%2Fmedcoupling.git Tessellate. --- diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx new file mode 100644 index 000000000..db144f96e --- /dev/null +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -0,0 +1,84 @@ +// Copyright (C) 2007-2011 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDCouplingBasicsTest5.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingCMesh.hxx" +#include "MEDCouplingExtrudedMesh.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingGaussLocalization.hxx" +#include "MEDCouplingMultiFields.hxx" +#include "MEDCouplingFieldOverTime.hxx" + +#include +#include +#include + +using namespace ParaMEDMEM; + +void MEDCouplingBasicsTest5::testUMeshTessellate2D1() +{ + double m1Coords[50]={0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1,0.,-1.5,0.5,0.,1.25,0.,0.70710678118654757,0.70710678118654757,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.70710678118654757,0.70710678118654757,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.70710678118654757,-0.70710678118654757,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.70710678118654757,-0.70710678118654757,1.0606601717798214,-1.0606601717798214}; + int m1Conn[56]={0,3,1,13,11,9, 3,4,2,1,14,12,10,11, 5,3,0,15,13,17, 6,4,3,5,16,14,15,18, 5,0,7,17,21,19, 6,5,7,8,18,19,22,20, 0,1,7,9,23,21, 1,2,8,7,10,24,22,23}; + MEDCouplingUMesh *m1=MEDCouplingUMesh::New(); + m1->setMeshDimension(2); + m1->allocateCells(8); + m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn); + m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+6); + m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn+14); + m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+20); + m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn+28); + m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+34); + m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn+42); + m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+48); + m1->finishInsertingCells(); + DataArrayDouble *myCoords1=DataArrayDouble::New(); + myCoords1->alloc(25,2); + std::copy(m1Coords,m1Coords+50,myCoords1->getPointer()); + m1->setCoords(myCoords1); + myCoords1->decrRef(); + // + MEDCouplingUMesh *m11=static_cast(m1->deepCpy()); + m11->tessellate2D(1.); + CPPUNIT_ASSERT(m11->getCoords()->isEqual(*m11->getCoords(),1e-12)); + const int expected1[48]={5,0,3,11,1,5,3,4,12,2,1,11,5,5,15,3,0,5,6,16,4,3,15,5,5,5,0,7,19,5,6,5,19,7,8,20,5,0,1,23,7,5,1,2,24,8,7,23}; + const int expected2[9]={0,5,12,17,24,29,36,41,48}; + CPPUNIT_ASSERT_EQUAL(48,m11->getNodalConnectivity()->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(9,m11->getNodalConnectivityIndex()->getNumberOfTuples()); + CPPUNIT_ASSERT(std::equal(expected1,expected1+48,m11->getNodalConnectivity()->getConstPointer())); + CPPUNIT_ASSERT(std::equal(expected2,expected2+9,m11->getNodalConnectivityIndex()->getConstPointer())); + m11->decrRef(); + // + MEDCouplingUMesh *m12=static_cast(m1->deepCpy()); + m12->tessellate2D(0.5); + CPPUNIT_ASSERT_EQUAL(41,m12->getNumberOfNodes()); + const int expected3[60]={5,0,3,25,26,1,5,3,4,27,28,2,1,26,25,5,5,29,30,3,0,5,6,31,32,4,3,30,29,5,5,5,0,7,33,34,5,6,5,34,33,7,8,35,36,5,0,1,37,38,7,5,1,2,39,40,8,7,38,37}; + const int expected4[9]={0,6,15,21,30,36,45,51,60}; + const double expected5[82]={0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1.,0.,-1.5,0.5,0.,1.25,0.,0.7071067811865476,0.7071067811865476,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.7071067811865476,0.7071067811865476,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.7071067811865476,-0.7071067811865476,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.7071067811865476,-0.7071067811865476,1.0606601717798214,-1.0606601717798214,0.479425538604203,0.8775825618903728,0.8414709848078964,0.54030230586814,0.7191383079063044,1.3163738428355591,1.2622064772118446,0.8104534588022099,-0.877582561890373,0.4794255386042027,-0.5403023058681399,0.8414709848078964,-1.3163738428355596,0.7191383079063038,-0.8104534588022098,1.2622064772118446,-0.4794255386042031,-0.8775825618903728,-0.8414709848078965,-0.5403023058681399,-0.7191383079063045,-1.3163738428355591,-1.2622064772118449,-0.8104534588022098,0.8775825618903729,-0.47942553860420295,0.54030230586814,-0.8414709848078964,1.3163738428355594,-0.7191383079063043,0.8104534588022099,-1.2622064772118446}; + for(int i=0;i<82;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],m12->getCoords()->getIJ(0,i),1e-12); + CPPUNIT_ASSERT_EQUAL(60,m12->getNodalConnectivity()->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(9,m12->getNodalConnectivityIndex()->getNumberOfTuples()); + CPPUNIT_ASSERT(std::equal(expected3,expected3+60,m12->getNodalConnectivity()->getConstPointer())); + CPPUNIT_ASSERT(std::equal(expected4,expected4+9,m12->getNodalConnectivityIndex()->getConstPointer())); + m12->decrRef(); + // + m1->decrRef(); +} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx new file mode 100644 index 000000000..9fbf183b3 --- /dev/null +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2011 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __MEDCOUPLINGBASICSTEST5_HXX__ +#define __MEDCOUPLINGBASICSTEST5_HXX__ + +#include "MEDCouplingBasicsTest.hxx" + +#include +#include + +namespace ParaMEDMEM +{ + class DataArrayDouble; + class MEDCouplingUMesh; + class MEDCouplingFieldDouble; + class MEDCouplingMultiFields; + + class MEDCouplingBasicsTest5 : public MEDCouplingBasicsTest + { + CPPUNIT_TEST_SUITE(MEDCouplingBasicsTest5); + CPPUNIT_TEST( testUMeshTessellate2D1 ); + CPPUNIT_TEST_SUITE_END(); + public: + void testUMeshTessellate2D1(); + }; +} + +#endif diff --git a/src/MEDCoupling/Test/Makefile.am b/src/MEDCoupling/Test/Makefile.am index 6a4575890..26e05b93f 100755 --- a/src/MEDCoupling/Test/Makefile.am +++ b/src/MEDCoupling/Test/Makefile.am @@ -27,8 +27,8 @@ TestMEDCoupling_LDFLAGS = @CPPUNIT_LIBS@ ../libmedcoupling.la ../../INTERP_KERNE dist_TestMEDCoupling_SOURCES = TestMEDCoupling.cxx MEDCouplingBasicsTest.hxx MEDCouplingBasicsTest0.cxx MEDCouplingBasicsTest1.cxx \ MEDCouplingBasicsTest2.cxx MEDCouplingBasicsTest3.cxx MEDCouplingBasicsTestInterp.cxx MEDCouplingBasicsTestData1.hxx \ - MEDCouplingBasicsTest4.cxx MEDCouplingBasicsTest1.hxx MEDCouplingBasicsTest2.hxx MEDCouplingBasicsTest3.hxx \ - MEDCouplingBasicsTest4.hxx MEDCouplingBasicsTestInterp.hxx + MEDCouplingBasicsTest4.cxx MEDCouplingBasicsTest5.cxx MEDCouplingBasicsTest1.hxx MEDCouplingBasicsTest2.hxx \ + MEDCouplingBasicsTest3.hxx MEDCouplingBasicsTest4.hxx MEDCouplingBasicsTest5.hxx MEDCouplingBasicsTestInterp.hxx TestMEDCouplingRemapper_CPPFLAGS=@CPPUNIT_INCLUDES@ @PTHREAD_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../../INTERP_KERNEL/Bases -I$(srcdir)/../../INTERP_KERNELTest -I$(srcdir)/../../INTERP_KERNEL -I$(srcdir)/../../INTERP_KERNEL/Geometric2D diff --git a/src/MEDCoupling/Test/TestMEDCoupling.cxx b/src/MEDCoupling/Test/TestMEDCoupling.cxx index d65006d77..27407cdd4 100644 --- a/src/MEDCoupling/Test/TestMEDCoupling.cxx +++ b/src/MEDCoupling/Test/TestMEDCoupling.cxx @@ -21,12 +21,14 @@ #include "MEDCouplingBasicsTest2.hxx" #include "MEDCouplingBasicsTest3.hxx" #include "MEDCouplingBasicsTest4.hxx" +#include "MEDCouplingBasicsTest5.hxx" #include "MEDCouplingBasicsTestInterp.hxx" CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingBasicsTest1 ); CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingBasicsTest2 ); CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingBasicsTest3 ); CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingBasicsTest4 ); +CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingBasicsTest5 ); CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingBasicsTestInterp ); #include "BasicMainTest.hxx"