]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
[EDF30834] : get rid of incrRef / decrRef delete -> use RAII
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 29 Aug 2024 08:42:26 +0000 (10:42 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 29 Aug 2024 08:42:26 +0000 (10:42 +0200)
17 files changed:
src/ShapeRecogn/Nodes.cxx
src/ShapeRecogn/Nodes.hxx
src/ShapeRecogn/NodesBuilder.cxx
src/ShapeRecogn/ShapeRecognMesh.cxx
src/ShapeRecogn/ShapeRecognMesh.hxx
src/ShapeRecogn/ShapeRecognMeshBuilder.cxx
src/ShapeRecogn/ShapeRecognMeshBuilder.hxx
src/ShapeRecogn/Test/ConeTest.cxx
src/ShapeRecogn/Test/ConeTest.hxx
src/ShapeRecogn/Test/CylinderTest.cxx
src/ShapeRecogn/Test/CylinderTest.hxx
src/ShapeRecogn/Test/PlaneTest.cxx
src/ShapeRecogn/Test/PlaneTest.hxx
src/ShapeRecogn/Test/SphereTest.cxx
src/ShapeRecogn/Test/SphereTest.hxx
src/ShapeRecogn/Test/TorusTest.cxx
src/ShapeRecogn/Test/TorusTest.hxx

index 615971ad4c1d3ea427c34634786a65ca0769988c..3e884d32766f6f1f5d8a649a239ac10b3b1c1b4d 100644 (file)
@@ -10,13 +10,6 @@ Nodes::Nodes(
 {
 }
 
-Nodes::~Nodes()
-{
-    mesh->decrRef();
-    neighbors->decrRef();
-    neighborsIdx->decrRef();
-}
-
 mcIdType Nodes::getNbNodes() const
 {
     return coords->getNumberOfTuples();
index 1d47d3060a923b3c8844b74e642747f9c397dd81..729a1910ef5ac19ea8f9dbca6aeb4a32f61c7633 100644 (file)
@@ -33,7 +33,7 @@ namespace MEDCoupling
         Nodes(const MEDCouplingUMesh *mesh,
               const DataArrayInt64 *neighbors,
               const DataArrayInt64 *neighborsIdx);
-        ~Nodes();
+        ~Nodes() = default;
 
         mcIdType getNbNodes() const;
         const std::vector<double> &getK1() const;
@@ -57,13 +57,13 @@ namespace MEDCoupling
         std::array<double, 3> getCoordinates(mcIdType nodeId) const;
 
     private:
-        const MEDCouplingUMesh *mesh;
+        MCConstAuto<MEDCouplingUMesh> mesh;
         const DataArrayDouble *coords;
         // normals 3 * nbNodes
         std::vector<double> normals;
         // neighbors
-        const DataArrayInt64 *neighbors;
-        const DataArrayInt64 *neighborsIdx;
+        MCConstAuto<DataArrayInt64> neighbors;
+        MCConstAuto<DataArrayInt64> neighborsIdx;
         // curvature
         std::vector<double> k1;
         std::vector<double> k2;
index 206c97387817c8333a5b8c6c35cf16fbb05a4c2f..a33103f4b183b6d7ee863644b90f21fbfd45850c 100644 (file)
@@ -41,8 +41,8 @@ void NodesBuilder::computeNormals()
     }
     //
     nodes->normals.resize(3 * nbNodes, 1.0);
-    DataArrayInt64 *revNodal = DataArrayInt64::New();
-    DataArrayInt64 *revNodalIdx = DataArrayInt64::New();
+    MCAuto<DataArrayInt64> revNodal = DataArrayInt64::New();
+    MCAuto<DataArrayInt64> revNodalIdx = DataArrayInt64::New();
     mesh->getReverseNodalConnectivity(revNodal, revNodalIdx);
     for (size_t nodeId = 0; nodeId < (size_t)nbNodes; nodeId++)
     {
@@ -67,8 +67,6 @@ void NodesBuilder::computeNormals()
         for (size_t i = 0; i < 3; i++)
             nodes->normals[3 * nodeId + i] /= sqrt(normal);
     }
-    revNodal->decrRef();
-    revNodalIdx->decrRef();
 }
 
 void NodesBuilder::computeCurvatures(double tol)
index 4c8ee5f9f894e79d1fefc515db64fb3885d7234d..ab76446a6a98a97634211d5ab630dbc7ebfac11a 100644 (file)
@@ -11,22 +11,6 @@ ShapeRecognMesh::ShapeRecognMesh()
       angle(0), center(0), axis(0), apex(0)
 {
 }
-ShapeRecognMesh::~ShapeRecognMesh()
-{
-    nodeK1->decrRef();
-    nodeK2->decrRef();
-    nodePrimitiveType->decrRef();
-    nodeNormal->decrRef();
-    areaId->decrRef();
-    areaPrimitiveType->decrRef();
-    areaNormal->decrRef();
-    minorRadius->decrRef();
-    radius->decrRef();
-    angle->decrRef();
-    center->decrRef();
-    axis->decrRef();
-    apex->decrRef();
-}
 
 std::size_t ShapeRecognMesh::getHeapMemorySizeWithoutChildren() const
 {
@@ -89,67 +73,67 @@ void ShapeRecognMesh::save(const std::string &outputFile, bool writeFromScratch)
     WriteField(outputFile, apex, false);
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getNodeK1() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getNodeK1() const
 {
     return nodeK1;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getNodeK2() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getNodeK2() const
 {
     return nodeK2;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getNodePrimitiveType() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getNodePrimitiveType() const
 {
     return nodePrimitiveType;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getNodeNormal() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getNodeNormal() const
 {
     return nodeNormal;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getAreaId() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getAreaId() const
 {
     return areaId;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getAreaPrimitiveType() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getAreaPrimitiveType() const
 {
     return areaPrimitiveType;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getAreaNormal() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getAreaNormal() const
 {
     return areaNormal;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getMinorRadius() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getMinorRadius() const
 {
     return minorRadius;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getRadius() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getRadius() const
 {
     return radius;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getAngle() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getAngle() const
 {
     return angle;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getCenter() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getCenter() const
 {
     return center;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getAxis() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getAxis() const
 {
     return axis;
 }
 
-MEDCouplingFieldDouble *ShapeRecognMesh::getApex() const
+const MEDCouplingFieldDouble *ShapeRecognMesh::getApex() const
 {
     return apex;
 }
index 02983e34a888841217348eeca75b1874dc83cec8..1ab49bf3ac2dcf6bec5e5f4a786286230f667a7d 100644 (file)
@@ -40,40 +40,40 @@ namespace MEDCoupling
         void save(const std::string &outputFile, bool writeFromScratch = true) const;
 
         // Node properties
-        MEDCoupling::MEDCouplingFieldDouble *getNodeK1() const;
-        MEDCoupling::MEDCouplingFieldDouble *getNodeK2() const;
-        MEDCoupling::MEDCouplingFieldDouble *getNodePrimitiveType() const;
-        MEDCoupling::MEDCouplingFieldDouble *getNodeNormal() const;
+        const MEDCouplingFieldDouble *getNodeK1() const;
+        const MEDCouplingFieldDouble *getNodeK2() const;
+        const MEDCouplingFieldDouble *getNodePrimitiveType() const;
+        const MEDCouplingFieldDouble *getNodeNormal() const;
 
         // Area properties
-        MEDCoupling::MEDCouplingFieldDouble *getAreaId() const;
-        MEDCoupling::MEDCouplingFieldDouble *getAreaPrimitiveType() const;
-        MEDCoupling::MEDCouplingFieldDouble *getAreaNormal() const;
-        MEDCoupling::MEDCouplingFieldDouble *getMinorRadius() const;
-        MEDCoupling::MEDCouplingFieldDouble *getRadius() const;
-        MEDCoupling::MEDCouplingFieldDouble *getAngle() const;
-        MEDCoupling::MEDCouplingFieldDouble *getCenter() const;
-        MEDCoupling::MEDCouplingFieldDouble *getAxis() const;
-        MEDCoupling::MEDCouplingFieldDouble *getApex() const;
+        const MEDCouplingFieldDouble *getAreaId() const;
+        const MEDCouplingFieldDouble *getAreaPrimitiveType() const;
+        const MEDCouplingFieldDouble *getAreaNormal() const;
+        const MEDCouplingFieldDouble *getMinorRadius() const;
+        const MEDCouplingFieldDouble *getRadius() const;
+        const MEDCouplingFieldDouble *getAngle() const;
+        const MEDCouplingFieldDouble *getCenter() const;
+        const MEDCouplingFieldDouble *getAxis() const;
+        const MEDCouplingFieldDouble *getApex() const;
 
     protected:
         ShapeRecognMesh();
-        ~ShapeRecognMesh();
+        ~ShapeRecognMesh() = default;
 
     private:
-        MEDCoupling::MEDCouplingFieldDouble *nodeK1;
-        MEDCoupling::MEDCouplingFieldDouble *nodeK2;
-        MEDCoupling::MEDCouplingFieldDouble *nodePrimitiveType;
-        MEDCoupling::MEDCouplingFieldDouble *nodeNormal;
-        MEDCoupling::MEDCouplingFieldDouble *areaId;
-        MEDCoupling::MEDCouplingFieldDouble *areaPrimitiveType;
-        MEDCoupling::MEDCouplingFieldDouble *areaNormal;
-        MEDCoupling::MEDCouplingFieldDouble *minorRadius;
-        MEDCoupling::MEDCouplingFieldDouble *radius;
-        MEDCoupling::MEDCouplingFieldDouble *angle;
-        MEDCoupling::MEDCouplingFieldDouble *center;
-        MEDCoupling::MEDCouplingFieldDouble *axis;
-        MEDCoupling::MEDCouplingFieldDouble *apex;
+        MCAuto<MEDCouplingFieldDouble> nodeK1;
+        MCAuto<MEDCouplingFieldDouble> nodeK2;
+        MCAuto<MEDCouplingFieldDouble> nodePrimitiveType;
+        MCAuto<MEDCouplingFieldDouble> nodeNormal;
+        MCAuto<MEDCouplingFieldDouble> areaId;
+        MCAuto<MEDCouplingFieldDouble> areaPrimitiveType;
+        MCAuto<MEDCouplingFieldDouble> areaNormal;
+        MCAuto<MEDCouplingFieldDouble> minorRadius;
+        MCAuto<MEDCouplingFieldDouble> radius;
+        MCAuto<MEDCouplingFieldDouble> angle;
+        MCAuto<MEDCouplingFieldDouble> center;
+        MCAuto<MEDCouplingFieldDouble> axis;
+        MCAuto<MEDCouplingFieldDouble> apex;
     };
 };
 
index 9118fa7585cd4566e7b855afe1b4e8d11d8df59c..82691750113885d7601a08f9b1b58e14993020e0 100644 (file)
@@ -17,23 +17,14 @@ ShapeRecognMeshBuilder::ShapeRecognMeshBuilder(const std::string &fileName, int
         throw INTERP_KERNEL::Exception("Expect a mesh containing exclusively triangular cells");
 }
 
-ShapeRecognMeshBuilder::~ShapeRecognMeshBuilder()
-{
-    if (areas != nullptr)
-        delete areas;
-    if (nodes != nullptr)
-        delete nodes;
-    mesh->decrRef();
-}
-
 MCAuto<ShapeRecognMesh> ShapeRecognMeshBuilder::recognize()
 {
     mesh->incrRef();
     NodesBuilder nodesBuilder(mesh);
-    nodes = nodesBuilder.build();
-    AreasBuilder areasBuilder(nodes);
+    nodes.reset( nodesBuilder.build() );
+    AreasBuilder areasBuilder(nodes.get());
     areasBuilder.build();
-    areas = areasBuilder.getAreas();
+    areas.reset( areasBuilder.getAreas() );
     MCAuto<ShapeRecognMesh> recognMesh = ShapeRecognMesh::New();
     recognMesh->nodeK1 = buildNodeK1();
     recognMesh->nodeK2 = buildNodeK2();
@@ -53,52 +44,52 @@ MCAuto<ShapeRecognMesh> ShapeRecognMeshBuilder::recognize()
 
 const Nodes *ShapeRecognMeshBuilder::getNodes() const
 {
-    return nodes;
+    return nodes.get();
 }
 
 const Areas *ShapeRecognMeshBuilder::getAreas() const
 {
-    return areas;
+    return areas.get();
 }
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildNodeK1() const
 {
-    if (nodes == nullptr)
+    if ( ! nodes.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     return buildField("K1 (Node)", 1, nodes->getK1());
 }
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildNodeK2() const
 {
-    if (nodes == nullptr)
+    if ( ! nodes.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     return buildField("K2 (Node)", 1, nodes->getK2());
 }
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildNodePrimitiveType() const
 {
-    if (nodes == nullptr)
+    if ( ! nodes.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     return buildField("Primitive Type (Node)", 1, nodes->getPrimitiveType());
 }
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildNodeNormal() const
 {
-    if (nodes == nullptr)
+    if ( ! nodes.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     return buildField("Normal (Node)", 3, nodes->getNormals());
 }
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildAreaId() const
 {
-    if (areas == nullptr)
+    if ( ! areas.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     return buildField("Area Id", 1, areas->getAreaIdByNodes());
 }
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildAreaPrimitiveType() const
 {
-    if (areas == nullptr)
+    if ( ! areas.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     double *values = buildAreaArray([](Areas *areas, mcIdType areaId) -> double
                                     { return (double)areas->getPrimitiveType(areaId); });
@@ -107,7 +98,7 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildAreaPrimitiveType() const
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildAreaNormal() const
 {
-    if (areas == nullptr)
+    if ( ! areas.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     double *values = buildArea3DArray([](Areas *areas, mcIdType areaId) -> const std::array<double, 3> &
                                       { return areas->getNormal(areaId); });
@@ -116,7 +107,7 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildAreaNormal() const
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildMinorRadius() const
 {
-    if (areas == nullptr)
+    if ( ! areas.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     double *values = buildAreaArray([](Areas *areas, mcIdType areaId) -> double
                                     { return areas->getMinorRadius(areaId); });
@@ -125,7 +116,7 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildMinorRadius() const
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildRadius() const
 {
-    if (areas == nullptr)
+    if ( ! areas.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     double *values = buildAreaArray([](Areas *areas, mcIdType areaId) -> double
                                     { return areas->getRadius(areaId); });
@@ -134,7 +125,7 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildRadius() const
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildAngle() const
 {
-    if (areas == nullptr)
+    if ( ! areas.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     double *values = buildAreaArray([](Areas *areas, mcIdType areaId) -> double
                                     { return areas->getAngle(areaId); });
@@ -143,7 +134,7 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildAngle() const
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildCenter() const
 {
-    if (areas == nullptr)
+    if ( ! areas.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     double *values = buildArea3DArray([](Areas *areas, mcIdType areaId) -> const std::array<double, 3> &
                                       { return areas->getCenter(areaId); });
@@ -152,7 +143,7 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildCenter() const
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildAxis() const
 {
-    if (areas == nullptr)
+    if ( ! areas.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     double *values = buildArea3DArray([](Areas *areas, mcIdType areaId) -> const std::array<double, 3> &
                                       { return areas->getAxis(areaId); });
@@ -161,7 +152,7 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildAxis() const
 
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildApex() const
 {
-    if (areas == nullptr)
+    if ( ! areas.get() )
         throw INTERP_KERNEL::Exception("recognize must be called before building any fields");
     double *values = buildArea3DArray([](Areas *areas, mcIdType areaId) -> const std::array<double, 3> &
                                       { return areas->getApex(areaId); });
@@ -174,7 +165,7 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildField(
     size_t nbOfCompo,
     const std::vector<T> &values) const
 {
-    DataArrayDouble *data = DataArrayDouble::New();
+    MCAuto<DataArrayDouble> data( DataArrayDouble::New() );
     data->setName(name);
     data->alloc(nodes->getNbNodes(), nbOfCompo);
     std::copy(values.begin(), values.end(), data->getPointer());
@@ -201,7 +192,7 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildField(
 MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildField(
     const std::string &name,
     size_t nbOfCompo,
-    DataArrayDouble *data) const
+    MCAuto<DataArrayDouble> data) const
 {
     MEDCouplingFieldDouble *field = MEDCouplingFieldDouble::New(ON_NODES);
     field->setName(name);
@@ -213,7 +204,6 @@ MEDCouplingFieldDouble *ShapeRecognMeshBuilder::buildField(
         data->setInfoOnComponent(2, "Z");
     }
     field->setArray(data);
-    data->decrRef();
     return field;
 }
 
@@ -227,7 +217,7 @@ double *ShapeRecognMeshBuilder::buildArea3DArray(
         mcIdType areaId = areaIdByNodes[nodeId];
         if (areaId != -1)
         {
-            const std::array<double, 3> &areaValues = areaFunc(areas, areaId);
+            const std::array<double, 3> &areaValues = areaFunc(areas.get(), areaId);
             values[3 * nodeId] = areaValues[0];
             values[3 * nodeId + 1] = areaValues[1];
             values[3 * nodeId + 2] = areaValues[2];
@@ -244,7 +234,7 @@ double *ShapeRecognMeshBuilder::buildAreaArray(double (*areaFunc)(Areas *, mcIdT
     {
         mcIdType areaId = areaIdByNodes[nodeId];
         if (areaId != -1)
-            values[nodeId] = areaFunc(areas, areaId);
+            values[nodeId] = areaFunc(areas.get(), areaId);
     }
     return values;
 }
index 6ac42743c7b2bedc2e802901f962f9a6807e68f1..9bc6ce3d8c78371cb7dc573b27cee52c5e351c0e 100644 (file)
 #include "MEDCouplingUMesh.hxx"
 #include "MEDCouplingFieldDouble.hxx"
 
+#include "Nodes.hxx"
+#include "Areas.hxx"
+
+#include <memory>
+
 namespace MEDCoupling
 {
-    class Nodes;
-    class Areas;
     class ShapeRecognMesh;
 
     class ShapeRecognMeshBuilder
     {
     public:
         ShapeRecognMeshBuilder(const std::string &fileName, int meshDimRelToMax = 0);
-        ~ShapeRecognMeshBuilder();
+        ~ShapeRecognMeshBuilder() = default;
 
         const Nodes *getNodes() const;
         const Areas *getAreas() const;
@@ -72,13 +75,13 @@ namespace MEDCoupling
         MEDCouplingFieldDouble *buildField(
             const std::string &name,
             size_t nbOfCompo,
-            DataArrayDouble *values) const;
+            MCAuto<DataArrayDouble> values) const;
         double *buildArea3DArray(const std::array<double, 3> &(*areaFunc)(Areas *, mcIdType)) const;
         double *buildAreaArray(double (*areaFunc)(Areas *, mcIdType)) const;
-
-        const MEDCouplingUMesh *mesh;
-        Nodes *nodes = nullptr;
-        Areas *areas = nullptr;
+    private:
+        MCConstAuto< MEDCouplingUMesh > mesh;
+        std::unique_ptr<Nodes> nodes;
+        std::unique_ptr<Areas> areas;
     };
 };
 
index b43616c4f69b3e6c2c23835effb682159459c3c7..7f2c435ad948457a4422151bb076a5d59ca6e3ed 100644 (file)
@@ -11,15 +11,13 @@ using namespace MEDCoupling;
 void ConeTest::setUp()
 {
     std::string file = INTERP_TEST::getResourceFile("ShapeRecognCone.med", 3);
-    srMesh = new ShapeRecognMeshBuilder(file);
+    srMesh.reset( new ShapeRecognMeshBuilder(file) );
     srMesh->recognize();
     areas = srMesh->getAreas();
 }
 
 void ConeTest::tearDown()
 {
-    if (srMesh != 0)
-        delete srMesh;
     areas = 0;
 }
 
index 20b1bef3fd02e514f77b2315d44c6c6bc6f8e046..b9e577e0fc5805d46bc6fba93e03a1b661ace95e 100644 (file)
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 
+#include "ShapeRecognMeshBuilder.hxx"
+
+#include <memory>
+
 namespace MEDCoupling
 {
     class ShapeRecognMeshBuilder;
@@ -54,7 +58,7 @@ namespace MEDCoupling
         void testThirdArea();
 
     private:
-        ShapeRecognMeshBuilder *srMesh = 0;
+        std::unique_ptr<ShapeRecognMeshBuilder> srMesh;
         const Areas *areas;
     };
 };
index abe69828a475ba5a921036efecdf12958397c7cc..256e5d35713a6b530d6d67f54bad59a11a8724d0 100644 (file)
@@ -11,15 +11,13 @@ using namespace MEDCoupling;
 void CylinderTest::setUp()
 {
     std::string file = INTERP_TEST::getResourceFile("ShapeRecognCylinder.med", 3);
-    srMesh = new ShapeRecognMeshBuilder(file);
+    srMesh.reset( new ShapeRecognMeshBuilder(file) );
     srMesh->recognize();
     areas = srMesh->getAreas();
 }
 
 void CylinderTest::tearDown()
 {
-    if (srMesh != 0)
-        delete srMesh;
     areas = 0;
 }
 
index a35ac14817921873150bf878e51c3b1499227e8d..9abab65d2776359d222fd75f0db6b926820360af 100644 (file)
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 
+#include "ShapeRecognMeshBuilder.hxx"
+
+#include <memory>
+
 namespace MEDCoupling
 {
     class ShapeRecognMeshBuilder;
@@ -47,7 +51,7 @@ namespace MEDCoupling
         void testThirdArea();
 
     private:
-        ShapeRecognMeshBuilder *srMesh = 0;
+        std::unique_ptr< ShapeRecognMeshBuilder > srMesh;
         const Areas *areas;
     };
 };
index ea11532529f8a6990fcd19be4218844462695110..2e4537f5454fca0afcc44c462d3327d718105232 100644 (file)
@@ -11,15 +11,13 @@ using namespace MEDCoupling;
 void PlaneTest::setUp()
 {
     std::string file = INTERP_TEST::getResourceFile("ShapeRecognPlane.med", 3);
-    srMesh = new ShapeRecognMeshBuilder(file);
+    srMesh.reset( new ShapeRecognMeshBuilder(file) );
     srMesh->recognize();
     areas = srMesh->getAreas();
 }
 
 void PlaneTest::tearDown()
 {
-    if (srMesh != 0)
-        delete srMesh;
     areas = 0;
 }
 
index af6eb47552294b512814f4bde47f6c66793f837c..df75b543fd13bd46794ddfd22f19943d9f8dd241 100644 (file)
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 
+#include "ShapeRecognMeshBuilder.hxx"
+
+#include <memory>
+
 namespace MEDCoupling
 {
     class ShapeRecognMeshBuilder;
@@ -41,7 +45,7 @@ namespace MEDCoupling
         void testArea();
 
     private:
-        ShapeRecognMeshBuilder *srMesh = 0;
+        std::unique_ptr<ShapeRecognMeshBuilder> srMesh;
         const Areas *areas;
     };
 };
index f0b82488630f07ae2d5ca5a8e32c1dffff67f641..b8c686fc8b845ed02bc8b9bac1ef98a4b4dbcc59 100644 (file)
@@ -11,15 +11,13 @@ using namespace MEDCoupling;
 void SphereTest::setUp()
 {
     std::string file = INTERP_TEST::getResourceFile("ShapeRecognSphere.med", 3);
-    srMesh = new ShapeRecognMeshBuilder(file);
+    srMesh.reset( new ShapeRecognMeshBuilder(file) );
     srMesh->recognize();
     areas = srMesh->getAreas();
 }
 
 void SphereTest::tearDown()
 {
-    if (srMesh != 0)
-        delete srMesh;
     areas = 0;
 }
 
index 6500def00b1561889adfc701ad561ddb70e51b72..c04218fd14d4fab406b888d1feff8497e2b69659 100644 (file)
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 
+#include "ShapeRecognMeshBuilder.hxx"
+
+#include <memory>
+
 namespace MEDCoupling
 {
     class ShapeRecognMeshBuilder;
@@ -41,7 +45,7 @@ namespace MEDCoupling
         void testArea();
 
     private:
-        ShapeRecognMeshBuilder *srMesh = 0;
+        std::unique_ptr<ShapeRecognMeshBuilder> srMesh;
         const Areas *areas;
     };
 };
index 9b55f23d008d5de3fb1bb6d5c3dd6bc7c0f752c3..60d8fce5a76d2cd377eced139ca25987941130f5 100644 (file)
@@ -11,15 +11,13 @@ using namespace MEDCoupling;
 void TorusTest::setUp()
 {
     std::string file = INTERP_TEST::getResourceFile("ShapeRecognTorus.med", 3);
-    srMesh = new ShapeRecognMeshBuilder(file);
+    srMesh.reset( new ShapeRecognMeshBuilder(file) );
     srMesh->recognize();
     areas = srMesh->getAreas();
 }
 
 void TorusTest::tearDown()
 {
-    if (srMesh != 0)
-        delete srMesh;
     areas = 0;
 }
 
index 07ae86d3aa722c599cec3e9edcd9013505f18131..9c700c7a34426f0a7f9d633c375c87879cd84516 100644 (file)
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 
+#include "ShapeRecognMeshBuilder.hxx"
+
+#include <memory>
+
 namespace MEDCoupling
 {
     class ShapeRecognMeshBuilder;
@@ -41,7 +45,7 @@ namespace MEDCoupling
         void testArea();
 
     private:
-        ShapeRecognMeshBuilder *srMesh = 0;
+        std::unique_ptr< ShapeRecognMeshBuilder > srMesh;
         const Areas *areas;
     };
 };