LCOV - code coverage report
Current view: top level - algs/AdvFront - AF2FreeZoneDefLCQualLim.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 55 103 53.4 %
Date: 2020-07-01 15:24:36 Functions: 3 6 50.0 %
Branches: 63 186 33.9 %

           Branch data     Line data    Source code
       1                 :            : // MeshhKit
       2                 :            : #include "meshkit/AF2FreeZoneDefLCQualLim.hpp"
       3                 :            : #include "meshkit/Error.hpp"
       4                 :            : 
       5                 :        156 : AF2FreeZoneDefLCQualLim::AF2FreeZoneDefLCQualLim(
       6                 :            :         std::list<AF2Point2D> const & preferBndryPnts,
       7                 :            :         std::list<const AF2PointTransform*> const & preferPntTrnsfrms,
       8                 :            :         std::list<AF2Point2D> const & limitBndryPnts,
       9                 :        156 :         std::list<const AF2PointTransform*> const & limitPntTrnsfrms)
      10                 :            : {
      11                 :            :   // confirm that the lists are the same size
      12 [ +  - ][ -  + ]:        468 :   if ((preferBndryPnts.size() != preferPntTrnsfrms.size()) ||
      13 [ +  - ][ -  + ]:        312 :       (preferBndryPnts.size() != limitBndryPnts.size()) ||
      14                 :        156 :       (preferBndryPnts.size() != limitPntTrnsfrms.size()))
      15                 :            :   {
      16         [ #  # ]:          0 :     MeshKit::Error badArg(MeshKit::MK_BAD_INPUT);
      17                 :            :     badArg.set_string(
      18         [ #  # ]:          0 :         "The lists passed to the constructor are not all the same size");
      19         [ #  # ]:          0 :     throw badArg;
      20                 :            :   }
      21                 :            : 
      22                 :        156 :   numPoints = preferBndryPnts.size();
      23 [ +  - ][ +  - ]:        826 :   prefBndryPoints = new AF2Point2D[numPoints];
         [ +  - ][ +  + ]
      24 [ +  - ][ +  - ]:        156 :   prefPointTransforms = new const AF2PointTransform*[numPoints];
      25 [ +  - ][ +  - ]:        826 :   limBndryPoints = new AF2Point2D[numPoints];
         [ +  - ][ +  + ]
      26 [ +  - ][ +  - ]:        156 :   limPointTransforms = new const AF2PointTransform*[numPoints];
      27                 :        156 :   int pIndx = 0;
      28   [ +  -  +  - ]:       1652 :   for (std::list<AF2Point2D>::const_iterator itr =
                 [ +  + ]
      29                 :        982 :       preferBndryPnts.begin(); itr != preferBndryPnts.end(); ++itr)
      30                 :            :   {
      31         [ +  - ]:        670 :     prefBndryPoints[pIndx] = *itr;
      32                 :        670 :     ++pIndx;
      33                 :            :   }
      34                 :            : 
      35                 :        156 :   pIndx = 0;
      36   [ +  -  +  - ]:       1652 :   for (std::list<const AF2PointTransform*>::const_iterator itr =
                 [ +  + ]
      37                 :        982 :       preferPntTrnsfrms.begin(); itr != preferPntTrnsfrms.end(); ++itr)
      38                 :            :   {
      39 [ +  - ][ +  - ]:        670 :     prefPointTransforms[pIndx] = (*itr)->clone();
      40                 :        670 :     ++pIndx;
      41                 :            :   }
      42                 :            : 
      43                 :        156 :   pIndx = 0;
      44   [ +  -  +  - ]:       1652 :   for (std::list<AF2Point2D>::const_iterator itr =
                 [ +  + ]
      45                 :        982 :       limitBndryPnts.begin(); itr != limitBndryPnts.end(); ++itr)
      46                 :            :   {
      47         [ +  - ]:        670 :     limBndryPoints[pIndx] = *itr;
      48                 :        670 :     ++pIndx;
      49                 :            :   }
      50                 :            : 
      51                 :        156 :   pIndx = 0;
      52   [ +  -  +  - ]:       1652 :   for (std::list<const AF2PointTransform*>::const_iterator itr =
                 [ +  + ]
      53                 :        982 :       limitPntTrnsfrms.begin(); itr != limitPntTrnsfrms.end(); ++itr)
      54                 :            :   {
      55 [ +  - ][ +  - ]:        670 :     limPointTransforms[pIndx] = (*itr)->clone();
      56                 :        670 :     ++pIndx;
      57                 :            :   }
      58                 :        156 : }
      59                 :            : 
      60                 :        468 : AF2FreeZoneDefLCQualLim::~AF2FreeZoneDefLCQualLim()
      61                 :            : {
      62         [ +  - ]:        156 :   delete[] prefBndryPoints;
      63         [ +  - ]:        156 :   delete[] limBndryPoints;
      64         [ +  + ]:        826 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
      65                 :            :   {
      66         [ +  - ]:        670 :     delete prefPointTransforms[pIndx];
      67         [ +  - ]:        670 :     delete limPointTransforms[pIndx];
      68                 :            :   }
      69         [ +  - ]:        156 :   delete[] prefPointTransforms;
      70         [ +  - ]:        156 :   delete[] limPointTransforms;
      71         [ -  + ]:        312 : }
      72                 :            : 
      73                 :          0 : AF2FreeZoneDefLCQualLim::AF2FreeZoneDefLCQualLim(
      74                 :          0 :     const AF2FreeZoneDefLCQualLim & toCopy)
      75                 :            : {
      76                 :          0 :   numPoints = toCopy.numPoints;
      77 [ #  # ][ #  # ]:          0 :   prefBndryPoints = new AF2Point2D[numPoints];
         [ #  # ][ #  # ]
      78 [ #  # ][ #  # ]:          0 :   prefPointTransforms = new const AF2PointTransform*[numPoints];
      79 [ #  # ][ #  # ]:          0 :   limBndryPoints = new AF2Point2D[numPoints];
         [ #  # ][ #  # ]
      80 [ #  # ][ #  # ]:          0 :   limPointTransforms = new const AF2PointTransform*[numPoints];
      81         [ #  # ]:          0 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
      82                 :            :   {
      83                 :          0 :     prefBndryPoints[pIndx] = toCopy.prefBndryPoints[pIndx];
      84         [ #  # ]:          0 :     prefPointTransforms[pIndx] = toCopy.prefPointTransforms[pIndx]->clone();
      85                 :          0 :     limBndryPoints[pIndx] = toCopy.limBndryPoints[pIndx];
      86         [ #  # ]:          0 :     limPointTransforms[pIndx] = toCopy.limPointTransforms[pIndx]->clone();
      87                 :            :   }
      88                 :          0 : }
      89                 :            : 
      90                 :          0 : AF2FreeZoneDefLCQualLim& AF2FreeZoneDefLCQualLim::operator=(
      91                 :            :     const AF2FreeZoneDefLCQualLim & rhs)
      92                 :            : {
      93                 :            :   // copy constructor functionality,
      94                 :            :   // but to other parts of memory, not yet to this
      95 [ #  # ][ #  # ]:          0 :   AF2Point2D* otherPrefBndryPoints = new AF2Point2D[numPoints];
                 [ #  # ]
      96                 :            :   const AF2PointTransform** otherPrefPointTransforms =
      97         [ #  # ]:          0 :       new const AF2PointTransform*[numPoints];
      98 [ #  # ][ #  # ]:          0 :   AF2Point2D* otherLimBndryPoints = new AF2Point2D[numPoints];
                 [ #  # ]
      99                 :            :   const AF2PointTransform** otherLimPointTransforms =
     100         [ #  # ]:          0 :       new const AF2PointTransform*[numPoints];
     101         [ #  # ]:          0 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
     102                 :            :   {
     103                 :          0 :     otherPrefBndryPoints[pIndx] = rhs.prefBndryPoints[pIndx];
     104                 :          0 :     otherPrefPointTransforms[pIndx] = rhs.prefPointTransforms[pIndx]->clone();
     105                 :          0 :     otherLimBndryPoints[pIndx] = rhs.limBndryPoints[pIndx];
     106                 :          0 :     otherLimPointTransforms[pIndx] = rhs.limPointTransforms[pIndx]->clone();
     107                 :            :   }
     108                 :            : 
     109                 :            :   // destructor functionality
     110         [ #  # ]:          0 :   delete[] prefBndryPoints;
     111         [ #  # ]:          0 :   delete[] limBndryPoints;
     112         [ #  # ]:          0 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
     113                 :            :   {
     114         [ #  # ]:          0 :     delete prefPointTransforms[pIndx];
     115         [ #  # ]:          0 :     delete limPointTransforms[pIndx];
     116                 :            :   }
     117         [ #  # ]:          0 :   delete[] prefPointTransforms;
     118         [ #  # ]:          0 :   delete[] limPointTransforms;
     119                 :            : 
     120                 :            :   // transfer ownership from other parts of memory to this object
     121                 :          0 :   numPoints = rhs.numPoints;
     122                 :          0 :   prefBndryPoints = otherPrefBndryPoints;
     123                 :          0 :   otherPrefBndryPoints = NULL; // not necessary, but to be explicit
     124                 :          0 :   prefPointTransforms = otherPrefPointTransforms;
     125                 :          0 :   otherPrefPointTransforms = NULL; // not necessary, but to be explicit
     126                 :          0 :   limBndryPoints = otherLimBndryPoints;
     127                 :          0 :   otherLimBndryPoints = NULL; // not necessary, but to be explicit
     128                 :          0 :   limPointTransforms = otherLimPointTransforms;
     129                 :          0 :   otherLimPointTransforms = NULL; // not necessary, but to be explicit
     130                 :            : 
     131                 :            :   // return this
     132                 :          0 :   return *this;
     133                 :            : }
     134                 :            : 
     135                 :          0 : AF2FreeZoneDefLCQualLim* AF2FreeZoneDefLCQualLim::clone() const
     136                 :            : {
     137         [ #  # ]:          0 :   return new AF2FreeZoneDefLCQualLim(*this);
     138                 :            : }
     139                 :            : 
     140                 :      15415 : AF2FreeZone* AF2FreeZoneDefLCQualLim::makeFreeZone(
     141                 :            :     AF2Binding const & vertexBinding, unsigned int qualityClass) const
     142                 :            : {
     143                 :            :   // Check that the quality class is greater than zero
     144         [ -  + ]:      15415 :   if (qualityClass == 0)
     145                 :            :   {
     146         [ #  # ]:          0 :     MeshKit::Error badArg(MeshKit::MK_BAD_INPUT);
     147         [ #  # ]:          0 :     badArg.set_string("The quality class is not greater than zero.");
     148         [ #  # ]:          0 :     throw badArg;
     149                 :            :   }
     150                 :            : 
     151                 :            :   // compute the coefficients to use in the linear combination
     152                 :      15415 :   double prefCoeff = 1.0/qualityClass;
     153                 :      15415 :   double limCoeff = 1.0 - prefCoeff;
     154                 :            : 
     155                 :            :   // compute the list of actual free zone boundary points
     156         [ +  - ]:      15415 :   std::list<AF2Point2D> freeZoneBndry;
     157         [ +  + ]:      89702 :   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
     158                 :            :   {
     159                 :     222861 :     AF2Point2D prefPnt = prefPointTransforms[pIndx]->transformPoint(
     160         [ +  - ]:      74287 :         prefBndryPoints[pIndx], vertexBinding);
     161                 :     222861 :     AF2Point2D limPnt = limPointTransforms[pIndx]->transformPoint(
     162         [ +  - ]:      74287 :         limBndryPoints[pIndx], vertexBinding);
     163                 :            :     AF2Point2D fzBndryPnt(
     164 [ +  - ][ +  - ]:      74287 :         prefCoeff * prefPnt.getX()  +  limCoeff * limPnt.getX(),
     165 [ +  - ][ +  - ]:     148574 :         prefCoeff * prefPnt.getY()  +  limCoeff * limPnt.getY());
                 [ +  - ]
     166         [ +  - ]:      74287 :     freeZoneBndry.push_back(fzBndryPnt);
     167                 :            :   }
     168                 :            : 
     169                 :            :   // construct and return the free zone
     170 [ +  - ][ +  - ]:      15415 :   AF2FreeZone* freeZone = new AF2FreeZone(freeZoneBndry);
     171                 :      15415 :   return freeZone;
     172                 :            : }

Generated by: LCOV version 1.11