LCOV - code coverage report
Current view: top level - algs/AdvFront - AF2FreeZoneDefSimple.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 30 59 50.8 %
Date: 2020-07-01 15:24:36 Functions: 3 6 50.0 %
Branches: 32 96 33.3 %

           Branch data     Line data    Source code
       1                 :            : #include "meshkit/AF2FreeZoneDefSimple.hpp"
       2                 :            : #include "meshkit/Error.hpp"
       3                 :            : 
       4                 :        123 : AF2FreeZoneDefSimple::AF2FreeZoneDefSimple(
       5                 :            :         std::list<AF2Point2D> const & rfrncBndryPnts,
       6                 :        123 :         std::list<const AF2PointTransform*> const & bndryPntTrnsfrms)
       7                 :            : {
       8                 :            :   // confirm that the lists are the same size
       9         [ -  + ]:        123 :   if (rfrncBndryPnts.size() != bndryPntTrnsfrms.size())
      10                 :            :   {
      11         [ #  # ]:          0 :     MeshKit::Error badArg(MeshKit::MK_BAD_INPUT);
      12         [ #  # ]:          0 :     badArg.set_string("The lists of reference points and point transforms are not the same size");
      13         [ #  # ]:          0 :     throw badArg;
      14                 :            :   }
      15                 :            : 
      16                 :        123 :   numPoints = rfrncBndryPnts.size();
      17 [ +  - ][ +  - ]:        763 :   bndryPoints = new AF2Point2D[numPoints];
         [ +  - ][ +  + ]
      18 [ +  - ][ +  - ]:        123 :   pointTransforms = new const AF2PointTransform*[numPoints];
      19                 :        123 :   int pIndx = 0;
      20   [ +  -  +  - ]:       1526 :   for (std::list<AF2Point2D>::const_iterator itr =
                 [ +  + ]
      21                 :        886 :       rfrncBndryPnts.begin(); itr != rfrncBndryPnts.end(); ++itr)
      22                 :            :   {
      23         [ +  - ]:        640 :     bndryPoints[pIndx] = *itr;
      24                 :        640 :     ++pIndx;
      25                 :            :   }
      26                 :            : 
      27                 :        123 :   pIndx = 0;
      28   [ +  -  +  - ]:       1526 :   for (std::list<const AF2PointTransform*>::const_iterator itr =
                 [ +  + ]
      29                 :        886 :       bndryPntTrnsfrms.begin(); itr != bndryPntTrnsfrms.end(); ++itr)
      30                 :            :   {
      31 [ +  - ][ +  - ]:        640 :     pointTransforms[pIndx] = (*itr)->clone();
      32                 :        640 :     ++pIndx;
      33                 :            :   }
      34                 :        123 : }
      35                 :            : 
      36                 :        369 : AF2FreeZoneDefSimple::~AF2FreeZoneDefSimple()
      37                 :            : {
      38         [ +  - ]:        123 :   delete[] bndryPoints;
      39         [ +  + ]:        763 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
      40                 :            :   {
      41         [ +  - ]:        640 :     delete pointTransforms[pIndx];
      42                 :            :   }
      43         [ +  - ]:        123 :   delete[] pointTransforms;
      44         [ -  + ]:        246 : }
      45                 :            : 
      46                 :          0 : AF2FreeZoneDefSimple::AF2FreeZoneDefSimple(const AF2FreeZoneDefSimple & toCopy)
      47                 :            : {
      48                 :          0 :   numPoints = toCopy.numPoints;
      49 [ #  # ][ #  # ]:          0 :   bndryPoints = new AF2Point2D[numPoints];
         [ #  # ][ #  # ]
      50 [ #  # ][ #  # ]:          0 :   pointTransforms = new const AF2PointTransform*[numPoints];
      51         [ #  # ]:          0 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
      52                 :            :   {
      53                 :          0 :     bndryPoints[pIndx] = toCopy.bndryPoints[pIndx];
      54         [ #  # ]:          0 :     pointTransforms[pIndx] = toCopy.pointTransforms[pIndx]->clone();
      55                 :            :   }
      56                 :          0 : }
      57                 :            : 
      58                 :          0 : AF2FreeZoneDefSimple& AF2FreeZoneDefSimple::operator=(
      59                 :            :     const AF2FreeZoneDefSimple & rhs)
      60                 :            : {
      61                 :            :   // copy constructor functionality,
      62                 :            :   // but to other parts of memory, not yet to this
      63 [ #  # ][ #  # ]:          0 :   AF2Point2D* otherBndryPoints = new AF2Point2D[numPoints];
                 [ #  # ]
      64                 :            :   const AF2PointTransform** otherPointTransforms =
      65         [ #  # ]:          0 :       new const AF2PointTransform*[numPoints];
      66         [ #  # ]:          0 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
      67                 :            :   {
      68                 :          0 :     otherBndryPoints[pIndx] = rhs.bndryPoints[pIndx];
      69                 :          0 :     otherPointTransforms[pIndx] = rhs.pointTransforms[pIndx]->clone();
      70                 :            :   }
      71                 :            : 
      72                 :            :   // destructor functionality
      73         [ #  # ]:          0 :   delete[] bndryPoints;
      74         [ #  # ]:          0 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
      75                 :            :   {
      76         [ #  # ]:          0 :     delete pointTransforms[pIndx];
      77                 :            :   }
      78         [ #  # ]:          0 :   delete[] pointTransforms;
      79                 :            : 
      80                 :            :   // transfer ownership from other parts of memory to this object
      81                 :          0 :   numPoints = rhs.numPoints;
      82                 :          0 :   bndryPoints = otherBndryPoints;
      83                 :          0 :   otherBndryPoints = NULL; // not necessary, but to be explicit
      84                 :          0 :   pointTransforms = otherPointTransforms;
      85                 :          0 :   otherPointTransforms = NULL; // not necessary, but to be explicit
      86                 :            : 
      87                 :            :   // return this
      88                 :          0 :   return *this;
      89                 :            : }
      90                 :            : 
      91                 :          0 : AF2FreeZoneDefSimple* AF2FreeZoneDefSimple::clone() const
      92                 :            : {
      93         [ #  # ]:          0 :   return new AF2FreeZoneDefSimple(*this);
      94                 :            : }
      95                 :            : 
      96                 :       6603 : AF2FreeZone* AF2FreeZoneDefSimple::makeFreeZone(
      97                 :            :     AF2Binding const & vertexBinding, unsigned int qualityClass) const
      98                 :            : {
      99         [ +  - ]:       6603 :   std::list<AF2Point2D> freeZoneBndry;
     100         [ +  + ]:      44966 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
     101                 :            :   {
     102                 :     115089 :     freeZoneBndry.push_back(pointTransforms[pIndx]->transformPoint(
     103 [ +  - ][ +  - ]:      38363 :         bndryPoints[pIndx], vertexBinding));
     104                 :            :   }
     105 [ +  - ][ +  - ]:       6603 :   AF2FreeZone* freeZone = new AF2FreeZone(freeZoneBndry);
     106                 :       6603 :   return freeZone;
     107                 :            : }

Generated by: LCOV version 1.11