From: Anthony Geay Date: Mon, 17 Dec 2018 13:04:28 +0000 (+0100) Subject: First factorization X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b499362be0f87d3a9024c3819194d7c5221a8954;p=tools%2Fmedcoupling.git First factorization --- diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 6e6d5dc21..15bdffd94 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -2361,24 +2361,9 @@ void MEDCouplingFieldDouble::sortPerTuple(bool asc) */ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) { - if(!f1->areCompatibleForMerge(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MergeFields on them ! Check support mesh, field nature, and spatial and time discretisation."); - const MEDCouplingMesh *m1(f1->getMesh()),*m2(f2->getMesh()); - if(!f1->timeDiscr()) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : no time discr of f1 !"); - if(!f1->_type) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : no spatial discr of f1 !"); - MEDCouplingTimeDiscretization *td(f1->timeDiscr()->aggregate(f2->timeDiscr())); - td->copyTinyAttrFrom(*f1->timeDiscr()); - MCAuto ret(new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone())); - ret->setName(f1->getName()); - ret->setDescription(f1->getDescription()); - if(m1) - { - MCAuto m=m1->mergeMyselfWith(m2); - ret->setMesh(m); - } - return ret.retn(); + std::vector a(2); + a[0]=f1; a[1]=f2; + return MergeFields(a); } /*! diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index 99abe4394..4e859d322 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -1373,6 +1373,7 @@ void MEDCouplingBasicsTest1::testMergeField1() MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MergeFields(f1,f2); f3->checkConsistencyLight(); MEDCouplingUMesh *m4=build2DTargetMeshMerged_1(); + m4->setName(f1->getMesh()->getName()); CPPUNIT_ASSERT(f3->getMesh()->isEqual(m4,1.e-12)); std::string name=f3->getName(); CPPUNIT_ASSERT(name=="MeasureOfMesh_"); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py index 2d6a4c0cb..ae07b6d34 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py @@ -1030,6 +1030,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f3=MEDCouplingFieldDouble.MergeFields(f1,f2); f3.checkConsistencyLight(); m4=MEDCouplingDataForTest.build2DTargetMeshMerged_1(); + m4.setName(f1.getMesh().getName()) self.assertTrue(f3.getMesh().isEqual(m4,1.e-12)); name=f3.getName(); self.assertEqual(name,"MeasureOfMesh_");