LCOV - code coverage report
Current view: top level - utils/meshkit - ReadPolyLine.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 13 15 86.7 %
Date: 2020-07-01 15:24:36 Functions: 1 1 100.0 %
Branches: 13 24 54.2 %

           Branch data     Line data    Source code
       1                 :            : #ifndef READPOLYLINE_H
       2                 :            : #define READPOLYLINE_H
       3                 :            : 
       4                 :            : // this should not be compiled separately, included only after some stuff
       5                 :            : /*
       6                 :            : #include <vector>
       7                 :            : #include <fstream>
       8                 :            : #include <iostream>
       9                 :            : */
      10                 :            : // this is just a utility function used too many times in tests for
      11                 :            : // mesh-based geometry, so I put it separately
      12                 :            : 
      13                 :          1 : int ReadPolyLineFromFile(const char * filename, double direction[3],
      14                 :            :     std::vector<double> & points)
      15                 :            : {
      16                 :            :   // get the direction, and the polygon/ polyline points
      17         [ +  - ]:          1 :   std::ifstream datafile(filename, std::ifstream::in);
      18 [ +  - ][ -  + ]:          1 :   if (!datafile) {
      19         [ #  # ]:          0 :     std::cout << "can't read polyline file\n";
      20                 :          0 :     return 1;
      21                 :            :   }
      22                 :            :   //
      23                 :            :   char temp[100];
      24                 :            :   //double direction[3];// normalized
      25                 :            :   double gridSize;
      26         [ +  - ]:          1 :   datafile.getline(temp, 100);// first line
      27                 :            : 
      28                 :            :   // get direction and mesh size along polygon segments, from file
      29                 :            :   sscanf(temp, " %lf %lf %lf %lf ", direction, direction + 1, direction + 2,
      30                 :          1 :       &gridSize);
      31                 :            : 
      32                 :            :   //std::vector<double> xyz;
      33 [ +  - ][ +  + ]:          7 :   while (!datafile.eof()) {
      34         [ +  - ]:          6 :     datafile.getline(temp, 100);
      35                 :            :     //int id = 0;
      36                 :            :     double x, y, z;
      37                 :          6 :     int nr = sscanf(temp, "%lf %lf %lf", &x, &y, &z);
      38         [ +  + ]:          6 :     if (nr == 3) {
      39         [ +  - ]:          5 :       points.push_back(x);
      40         [ +  - ]:          5 :       points.push_back(y);
      41         [ +  - ]:          6 :       points.push_back(z);
      42                 :            :     }
      43                 :            :   }
      44                 :          1 :   return 0;
      45                 :            : }
      46                 :            : #endif // READPOLYLINE_H

Generated by: LCOV version 1.11