From: Anthony Geay Date: Fri, 19 Aug 2022 13:34:13 +0000 (+0200) Subject: Update code to C++11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bd5a5cc70fc39ac2ef2eaaa4fd4f059ada103b94;p=tools%2Fmedcoupling.git Update code to C++11 --- diff --git a/src/INTERP_KERNEL/Interpolation3D.txx b/src/INTERP_KERNEL/Interpolation3D.txx index 355217c96..38ca91132 100755 --- a/src/INTERP_KERNEL/Interpolation3D.txx +++ b/src/INTERP_KERNEL/Interpolation3D.txx @@ -51,6 +51,8 @@ #endif +#include + namespace INTERP_KERNEL { /** @@ -84,28 +86,28 @@ namespace INTERP_KERNEL LOG(2, "Source mesh has " << numSrcElems << " elements and target mesh has " << numTargetElems << " elements "); - std::vector*> srcElems(numSrcElems); - std::vector*> targetElems(numTargetElems); + std::vector>> srcElems(numSrcElems); + std::vector>> targetElems(numTargetElems); std::map*, ConnType> indices; for(ConnType i = 0 ; i < numSrcElems ; ++i) - srcElems[i] = new MeshElement(i, srcMesh); + srcElems[i].reset( new MeshElement(i, srcMesh) ); for(ConnType i = 0 ; i < numTargetElems ; ++i) - targetElems[i] = new MeshElement(i, targetMesh); + targetElems[i].reset( new MeshElement(i, targetMesh) ); - Intersector3D* intersector=0; + std::unique_ptr> intersector; std::string methC = InterpolationOptions::filterInterpolationMethod(method); if(methC=="P0P0") { switch(InterpolationOptions::getIntersectionType()) { case Triangulation: - intersector=new PolyhedronIntersectorP0P0(targetMesh, srcMesh, getSplittingPolicy()); + intersector.reset( new PolyhedronIntersectorP0P0(targetMesh, srcMesh, getSplittingPolicy()) ); break; case PointLocator: - intersector=new PointLocator3DIntersectorP0P0(targetMesh, srcMesh, getPrecision()); + intersector.reset( new PointLocator3DIntersectorP0P0(targetMesh, srcMesh, getPrecision()) ); break; default: throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P0P0 interp specified : must be Triangle or PointLocator."); @@ -116,10 +118,10 @@ namespace INTERP_KERNEL switch(InterpolationOptions::getIntersectionType()) { case Triangulation: - intersector=new PolyhedronIntersectorP0P1(targetMesh, srcMesh, getSplittingPolicy()); + intersector.reset( new PolyhedronIntersectorP0P1(targetMesh, srcMesh, getSplittingPolicy()) ); break; case PointLocator: - intersector=new PointLocator3DIntersectorP0P1(targetMesh, srcMesh, getPrecision()); + intersector.reset( new PointLocator3DIntersectorP0P1(targetMesh, srcMesh, getPrecision()) ); break; default: throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P0P1 interp specified : must be Triangle or PointLocator."); @@ -130,13 +132,13 @@ namespace INTERP_KERNEL switch(InterpolationOptions::getIntersectionType()) { case Triangulation: - intersector=new PolyhedronIntersectorP1P0(targetMesh, srcMesh, getSplittingPolicy()); + intersector.reset( new PolyhedronIntersectorP1P0(targetMesh, srcMesh, getSplittingPolicy()) ); break; case PointLocator: - intersector=new PointLocator3DIntersectorP1P0(targetMesh, srcMesh, getPrecision()); + intersector.reset( new PointLocator3DIntersectorP1P0(targetMesh, srcMesh, getPrecision()) ); break; case Barycentric: - intersector=new PolyhedronIntersectorP1P0Bary(targetMesh, srcMesh, getSplittingPolicy()); + intersector.reset( new PolyhedronIntersectorP1P0Bary(targetMesh, srcMesh, getSplittingPolicy()) ); break; default: throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P0 interp specified : must be Triangle, PointLocator or Barycentric."); @@ -147,16 +149,16 @@ namespace INTERP_KERNEL switch(InterpolationOptions::getIntersectionType()) { case Triangulation: - intersector=new PolyhedronIntersectorP1P1(targetMesh, srcMesh, getSplittingPolicy()); + intersector.reset( new PolyhedronIntersectorP1P1(targetMesh, srcMesh, getSplittingPolicy()) ); break; case PointLocator: - intersector=new PointLocator3DIntersectorP1P1(targetMesh, srcMesh, getPrecision()); + intersector.reset( new PointLocator3DIntersectorP1P1(targetMesh, srcMesh, getPrecision()) ); break; case Barycentric: - intersector=new Barycentric3DIntersectorP1P1(targetMesh, srcMesh, getPrecision()); + intersector.reset( new Barycentric3DIntersectorP1P1(targetMesh, srcMesh, getPrecision()) ); break; case MappedBarycentric: - intersector=new MappedBarycentric3DIntersectorP1P1(targetMesh, srcMesh, getPrecision()); + intersector.reset( new MappedBarycentric3DIntersectorP1P1(targetMesh, srcMesh, getPrecision()) ); break; default: throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P1 interp specified : must be Triangle, PointLocator, Barycentric or MappedBarycentric."); @@ -306,8 +308,8 @@ namespace INTERP_KERNEL // create BBTree structure // - get bounding boxes - double* bboxes = new double[6 * numSrcElems]; - ConnType* srcElemIdx = new ConnType[numSrcElems]; + std::unique_ptr bboxes( new double[6 * numSrcElems] ); + std::unique_ptr srcElemIdx( new ConnType[numSrcElems] ); for(ConnType i = 0; i < numSrcElems ; ++i) { // get source bboxes in right order @@ -323,7 +325,7 @@ namespace INTERP_KERNEL srcElemIdx[i] = srcElems[i]->getIndex(); } - BBTree<3,ConnType> tree(bboxes, srcElemIdx, 0, numSrcElems); + BBTree<3,ConnType> tree(bboxes.get(), srcElemIdx.get(), 0, numSrcElems); // for each target element, get source elements with which to calculate intersection // - calculate intersection by calling intersectCells @@ -349,25 +351,8 @@ namespace INTERP_KERNEL intersector->intersectCells(targetIdx,intersectElems,result); } - delete [] bboxes; - delete [] srcElemIdx; - #endif - // free allocated memory - ConnType ret=intersector->getNumberOfColsOfResMatrix(); - - delete intersector; - - for(ConnType i = 0 ; i < numSrcElems ; ++i) - { - delete srcElems[i]; - } - for(ConnType i = 0 ; i < numTargetElems ; ++i) - { - delete targetElems[i]; - } - return ret; - + return intersector->getNumberOfColsOfResMatrix(); } }