LCOV - code coverage report
Current view: top level - algs/AdvFront - AF2PntTrnsfrmLnrV.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 56 56 100.0 %
Date: 2020-07-01 15:24:36 Functions: 4 4 100.0 %
Branches: 82 152 53.9 %

           Branch data     Line data    Source code
       1                 :            : #include "meshkit/AF2PntTrnsfrmLnrV.hpp"
       2                 :            : 
       3                 :            : // C++
       4                 :            : #include <cstddef>
       5                 :            : #include <sstream>
       6                 :            : 
       7                 :            : // MeshKit
       8                 :            : #include "meshkit/Error.hpp"
       9                 :            : 
      10                 :       1068 : AF2PntTrnsfrmLnrV::AF2PntTrnsfrmLnrV(
      11                 :            :     std::list<const AF2RuleExistVertex*> vertices,
      12                 :            :     std::list<double> xDiffCoeff, std::list<double> yDiffCoeff) :
      13                 :            :     refVertices(vertices.begin(), vertices.end()),
      14                 :            :     xCoeff(xDiffCoeff.begin(), xDiffCoeff.end()),
      15 [ +  - ][ +  - ]:       1070 :     yCoeff(yDiffCoeff.begin(), yDiffCoeff.end())
                 [ +  - ]
      16                 :            : {
      17         [ +  + ]:       1068 :   if (xDiffCoeff.size() != 2 * vertices.size())
      18                 :            :   {
      19         [ +  - ]:          1 :     std::ostringstream errStringStream;
      20         [ +  - ]:          1 :     errStringStream << "The list of x coefficients (size "
      21 [ +  - ][ +  - ]:          2 :         << xDiffCoeff.size() << ") is not twice as long as the list of "
      22 [ +  - ][ +  - ]:          2 :         << "vertices (size " << vertices.size() << ").";
                 [ +  - ]
      23         [ +  - ]:          2 :     MeshKit::Error badArg(MeshKit::MK_BAD_INPUT);
      24 [ +  - ][ +  - ]:          1 :     badArg.set_string(errStringStream.str().c_str());
      25         [ +  - ]:          2 :     throw badArg;
      26                 :            :   }
      27         [ +  + ]:       1067 :   if (yDiffCoeff.size() != 2 * vertices.size())
      28                 :            :   {
      29         [ +  - ]:          1 :     std::ostringstream errStringStream;
      30         [ +  - ]:          1 :     errStringStream << "The list of y coefficients (size "
      31 [ +  - ][ +  - ]:          2 :         << yDiffCoeff.size() << ") is not twice as long as the list of "
      32 [ +  - ][ +  - ]:          2 :         << "vertices (size " << vertices.size() << ").";
                 [ +  - ]
      33         [ +  - ]:          2 :     MeshKit::Error badArg(MeshKit::MK_BAD_INPUT);
      34 [ +  - ][ +  - ]:          1 :     badArg.set_string(errStringStream.str().c_str());
      35         [ +  - ]:          2 :     throw badArg;
      36                 :            :   }
      37                 :       1066 : }
      38                 :            : 
      39                 :       1631 : AF2PntTrnsfrmLnrV::AF2PntTrnsfrmLnrV(
      40                 :            :     std::vector<const AF2RuleExistVertex*> vertices,
      41                 :            :     std::vector<double> xDiffCoeff, std::vector<double> yDiffCoeff) :
      42 [ +  - ][ +  - ]:       1633 :     refVertices(vertices), xCoeff(xDiffCoeff), yCoeff(yDiffCoeff)
                 [ +  - ]
      43                 :            : {
      44         [ +  + ]:       1631 :   if (xDiffCoeff.size() != 2 * vertices.size())
      45                 :            :   {
      46         [ +  - ]:          1 :     std::ostringstream errStringStream;
      47         [ +  - ]:          1 :     errStringStream << "The vector of x coefficients (size "
      48 [ +  - ][ +  - ]:          2 :         << xDiffCoeff.size() << ") is not twice as long as the vector of "
      49 [ +  - ][ +  - ]:          2 :         << "vertices (size " << vertices.size() << ").";
                 [ +  - ]
      50         [ +  - ]:          2 :     MeshKit::Error badArg(MeshKit::MK_BAD_INPUT);
      51 [ +  - ][ +  - ]:          1 :     badArg.set_string(errStringStream.str().c_str());
      52         [ +  - ]:          2 :     throw badArg;
      53                 :            :   }
      54         [ +  + ]:       1630 :   if (yDiffCoeff.size() != 2 * vertices.size())
      55                 :            :   {
      56         [ +  - ]:          1 :     std::ostringstream errStringStream;
      57         [ +  - ]:          1 :     errStringStream << "The vector of y coefficients (size "
      58 [ +  - ][ +  - ]:          2 :         << yDiffCoeff.size() << ") is not twice as long as the vector of "
      59 [ +  - ][ +  - ]:          2 :         << "vertices (size " << vertices.size() << ").";
                 [ +  - ]
      60         [ +  - ]:          2 :     MeshKit::Error badArg(MeshKit::MK_BAD_INPUT);
      61 [ +  - ][ +  - ]:          1 :     badArg.set_string(errStringStream.str().c_str());
      62         [ +  - ]:          2 :     throw badArg;
      63                 :            :   }
      64                 :       1629 : }
      65                 :            : 
      66                 :       1624 : AF2PntTrnsfrmLnrV* AF2PntTrnsfrmLnrV::clone() const
      67                 :            : {
      68 [ +  - ][ +  - ]:       1624 :   return new AF2PntTrnsfrmLnrV(refVertices, xCoeff, yCoeff);
         [ +  - ][ +  - ]
      69                 :            : }
      70                 :            : 
      71                 :     153713 : AF2Point2D AF2PntTrnsfrmLnrV::transformPoint(AF2Point2D const & point,
      72                 :            :     AF2Binding const & vBinding) const
      73                 :            : {
      74                 :     153713 :   double xOffset = 0.0;
      75                 :     153713 :   double yOffset = 0.0;
      76         [ +  + ]:     343333 :   for (unsigned int i = 0; i < refVertices.size(); ++i)
      77                 :            :   {
      78         [ +  - ]:     189621 :     const AF2RuleExistVertex* refVertex = refVertices[i];
      79         [ +  - ]:     189621 :     const AF2Point2D* boundVal = vBinding.getBoundValue(refVertex);
      80         [ +  + ]:     189621 :     if (boundVal == NULL)
      81                 :            :     {
      82         [ +  - ]:          1 :       MeshKit::Error badArg(MeshKit::MK_BAD_INPUT);
      83         [ +  - ]:          1 :       badArg.set_string("The binding does not have a bound value for all reference vertices.");
      84         [ +  - ]:          1 :       throw badArg;
      85                 :            :     }
      86 [ +  - ][ +  - ]:     189620 :     double xDiff = boundVal->getX() - refVertex->getX();
      87 [ +  - ][ +  - ]:     189620 :     double yDiff = boundVal->getY() - refVertex->getY();
      88 [ +  - ][ +  - ]:     189620 :     xOffset += xCoeff[2*i]*xDiff + xCoeff[2*i + 1]*yDiff;
      89 [ +  - ][ +  - ]:     189620 :     yOffset += yCoeff[2*i]*xDiff + yCoeff[2*i + 1]*yDiff;
      90                 :            :   }
      91                 :            : 
      92 [ +  - ][ +  - ]:     153712 :   AF2Point2D translated(point.getX() + xOffset, point.getY() + yOffset);
                 [ +  - ]
      93                 :     153712 :   return translated;
      94                 :            : }

Generated by: LCOV version 1.11