#endif
+#include <memory>
+
namespace INTERP_KERNEL
{
/**
LOG(2, "Source mesh has " << numSrcElems << " elements and target mesh has " << numTargetElems << " elements ");
- std::vector<MeshElement<ConnType>*> srcElems(numSrcElems);
- std::vector<MeshElement<ConnType>*> targetElems(numTargetElems);
+ std::vector<std::unique_ptr<MeshElement<ConnType>>> srcElems(numSrcElems);
+ std::vector<std::unique_ptr<MeshElement<ConnType>>> targetElems(numTargetElems);
std::map<MeshElement<ConnType>*, ConnType> indices;
for(ConnType i = 0 ; i < numSrcElems ; ++i)
- srcElems[i] = new MeshElement<ConnType>(i, srcMesh);
+ srcElems[i].reset( new MeshElement<ConnType>(i, srcMesh) );
for(ConnType i = 0 ; i < numTargetElems ; ++i)
- targetElems[i] = new MeshElement<ConnType>(i, targetMesh);
+ targetElems[i].reset( new MeshElement<ConnType>(i, targetMesh) );
- Intersector3D<MyMeshType,MatrixType>* intersector=0;
+ std::unique_ptr<Intersector3D<MyMeshType,MatrixType>> intersector;
std::string methC = InterpolationOptions::filterInterpolationMethod(method);
if(methC=="P0P0")
{
switch(InterpolationOptions::getIntersectionType())
{
case Triangulation:
- intersector=new PolyhedronIntersectorP0P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy());
+ intersector.reset( new PolyhedronIntersectorP0P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy()) );
break;
case PointLocator:
- intersector=new PointLocator3DIntersectorP0P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
+ intersector.reset( new PointLocator3DIntersectorP0P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision()) );
break;
default:
throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P0P0 interp specified : must be Triangle or PointLocator.");
switch(InterpolationOptions::getIntersectionType())
{
case Triangulation:
- intersector=new PolyhedronIntersectorP0P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy());
+ intersector.reset( new PolyhedronIntersectorP0P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy()) );
break;
case PointLocator:
- intersector=new PointLocator3DIntersectorP0P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
+ intersector.reset( new PointLocator3DIntersectorP0P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision()) );
break;
default:
throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P0P1 interp specified : must be Triangle or PointLocator.");
switch(InterpolationOptions::getIntersectionType())
{
case Triangulation:
- intersector=new PolyhedronIntersectorP1P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy());
+ intersector.reset( new PolyhedronIntersectorP1P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy()) );
break;
case PointLocator:
- intersector=new PointLocator3DIntersectorP1P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
+ intersector.reset( new PointLocator3DIntersectorP1P0<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision()) );
break;
case Barycentric:
- intersector=new PolyhedronIntersectorP1P0Bary<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy());
+ intersector.reset( new PolyhedronIntersectorP1P0Bary<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy()) );
break;
default:
throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P0 interp specified : must be Triangle, PointLocator or Barycentric.");
switch(InterpolationOptions::getIntersectionType())
{
case Triangulation:
- intersector=new PolyhedronIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy());
+ intersector.reset( new PolyhedronIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getSplittingPolicy()) );
break;
case PointLocator:
- intersector=new PointLocator3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
+ intersector.reset( new PointLocator3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision()) );
break;
case Barycentric:
- intersector=new Barycentric3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
+ intersector.reset( new Barycentric3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision()) );
break;
case MappedBarycentric:
- intersector=new MappedBarycentric3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
+ intersector.reset( new MappedBarycentric3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision()) );
break;
default:
throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P1 interp specified : must be Triangle, PointLocator, Barycentric or MappedBarycentric.");
// create BBTree structure
// - get bounding boxes
- double* bboxes = new double[6 * numSrcElems];
- ConnType* srcElemIdx = new ConnType[numSrcElems];
+ std::unique_ptr<double[]> bboxes( new double[6 * numSrcElems] );
+ std::unique_ptr<ConnType[]> srcElemIdx( new ConnType[numSrcElems] );
for(ConnType i = 0; i < numSrcElems ; ++i)
{
// get source bboxes in right order
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
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();
}
}