EMODnet Quantized Mesh Generator for Cesium
tile_border_vertices.h
1 // Copyright (c) 2018 Coronis Computing S.L. (Spain)
2 // All rights reserved.
3 //
4 // This file is part of EMODnet Quantized Mesh Generator for Cesium.
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <https://www.gnu.org/licenses/>.
18 //
19 // Author: Ricard Campos (ricardcd@gmail.com)
20 
21 #ifndef EMODNET_QMGC_TILE_BORDER_VERTICES_H
22 #define EMODNET_QMGC_TILE_BORDER_VERTICES_H
23 
24 #include "tin_creation/tin_creation_cgal_types.h"
25 #include <vector>
26 
27 
35 struct BorderVertex {
36  double coord ;
37  double height ;
38 
39  BorderVertex( const double& c, const double& h ) : coord(c), height(h) {}
40 
41  // To be able to sort the vertices by coordinates
42  bool operator < (const BorderVertex& v) const
43  {
44  return (coord < v.coord);
45  }
46 };
47 
48 
54 {
55 public:
57  : m_easternVertices()
58  , m_westernVertices()
59  , m_northernVertices()
60  , m_southernVertices()
61  , m_lifeCounter(0) {}
62 
63  TileBorderVertices( const std::vector<BorderVertex>& easternVertices,
64  const std::vector<BorderVertex>& westernVertices,
65  const std::vector<BorderVertex>& northernVertices,
66  const std::vector<BorderVertex>& southernVertices,
67  const int& lifeCounter = 4 ) // The life counter will be 4 for those tiles not in the zoom borders and surrounded by unprocessed tiles
68  : m_easternVertices(easternVertices)
69  , m_westernVertices(westernVertices)
70  , m_northernVertices(northernVertices)
71  , m_southernVertices(southernVertices)
72  , m_lifeCounter(lifeCounter) {}
73 
74  // Each time we consult for a border, we update the number of times it has been consulted by decreasing the lifeCounter.
75  // When it gets to zero, the information in this object will not be needed anymore and can be deleted (responsability of the cache object)
76  std::vector<BorderVertex> getEasternVerticesAndDecreaseLife() { m_lifeCounter-- ; return m_easternVertices ; }
77  std::vector<BorderVertex> getWesternVerticesAndDecreaseLife() { m_lifeCounter-- ; return m_westernVertices ; }
78  std::vector<BorderVertex> getNorthernVerticesAndDecreaseLife() { m_lifeCounter-- ; return m_northernVertices ; }
79  std::vector<BorderVertex> getSouthernVerticesAndDecreaseLife() { m_lifeCounter-- ; return m_southernVertices ; }
80 
81  std::vector<BorderVertex> getEasternVertices() { return m_easternVertices ; }
82  std::vector<BorderVertex> getWesternVertices() { return m_westernVertices ; }
83  std::vector<BorderVertex> getNorthernVertices() { return m_northernVertices ; }
84  std::vector<BorderVertex> getSouthernVertices() { return m_southernVertices ; }
85 
86  bool isAlive() { return m_lifeCounter > 0 ; }
87 
88 private:
89  std::vector<BorderVertex> m_easternVertices ;
90  std::vector<BorderVertex> m_westernVertices ;
91  std::vector<BorderVertex> m_northernVertices ;
92  std::vector<BorderVertex> m_southernVertices ;
93  int m_lifeCounter ;
94 };
95 
96 #endif //EMODNET_QMGC_TILE_BORDER_VERTICES_H
Class storing a vertex on the border of a tile.
Definition: tile_border_vertices.h:35
Stores the vertices on the borders of a tile.
Definition: tile_border_vertices.h:53