File: gridFile.h

package info (click to toggle)
groops 0%2Bgit20250907%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 11,140 kB
  • sloc: cpp: 135,607; fortran: 1,603; makefile: 20
file content (84 lines) | stat: -rw-r--r-- 1,959 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/***********************************************/
/**
* @file gridFile.h
*
* @brief Read grid from file.
* @see Grid
*
* @author Torsten Mayer-Guerr
* @date 2004-01-11
*
*/
/***********************************************/

#ifndef __GROOPS_GRIDFILE__
#define __GROOPS_GRIDFILE__

// Latex documentation
#ifdef DOCSTRING_Grid
static const char *docstringGridFile = R"(
\subsection{File}\label{gridType:file}
In this class grid is read from a file, which is given by \configFile{inputfileGrid}{griddedData}.
A corresponding file can be generated with \program{GriddedDataCreate} or with \program{Matrix2GriddedData}.
)";
#endif

/***********************************************/

#include "base/import.h"
#include "config/config.h"
#include "files/fileGriddedData.h"
#include "classes/border/border.h"
#include "classes/grid/grid.h"

/***** CLASS ***********************************/

/** @brief Read grid from file.
* @ingroup gridGroup
* @see Grid */
class GridFile : public GridBase
{
public:
  GridFile(Config &config);
};

/***********************************************/

inline GridFile::GridFile(Config &config)
{
  try
  {
    FileName  fileNameGrid;
    BorderPtr border;

    readConfig(config, "inputfileGrid",  fileNameGrid, Config::MUSTSET,  "", "");
    readConfig(config, "border",         border,       Config::OPTIONAL, "", "");
    if(isCreateSchema(config)) return;

    GriddedData grid;
    readFileGriddedData(fileNameGrid, grid);

    if(!border)
    {
      std::swap(points, grid.points);
      std::swap(areas,  grid.areas);
      return;
    }

    for(UInt i=0; i<grid.points.size(); i++)
      if(border->isInnerPoint(grid.points.at(i), grid.ellipsoid))
      {
        points.push_back(grid.points.at(i));
        if(grid.areas.size())
          areas.push_back(grid.areas.at(i));
      }
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

/***********************************************/

#endif /* __GROOPS__ */