EMODnet Quantized Mesh Generator for Cesium
tin_creation_simplification_lindstrom_turk_strategy.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_TIN_CREATION_LINDSTROM_TURK_STRATEGY_H
22 #define EMODNET_QMGC_TIN_CREATION_LINDSTROM_TURK_STRATEGY_H
23 
24 #include "tin_creator.h"
25 
26 namespace TinCreation {
27 
39 public:
48  double weightVolume = 0.5,
49  double weightBoundary = 0.5,
50  double weightShape = 1e-10)
51  : m_stopEdgesCount(stopEdgesCount)
52  , m_weightVolume(weightVolume)
53  , m_weightBoundary(weightBoundary)
54  , m_stopEdgesCountPerZoom(1, stopEdgesCount)
55  , m_weightShape(weightShape) {}
56 
64  TinCreationSimplificationLindstromTurkStrategy(std::vector<int> stopEdgesCountPerZoom,
65  double weightVolume = 0.5,
66  double weightBoundary = 0.5,
67  double weightShape = 1e-10)
68  : m_stopEdgesCountPerZoom(stopEdgesCountPerZoom), m_weightVolume(weightVolume), m_weightBoundary(weightBoundary),
69  m_weightShape(weightShape)
70  {
72  }
73 
74  void setParamsForZoom(const unsigned int& zoom) {
75  if (m_stopEdgesCountPerZoom.size() == 0) {
76  std::cerr << "[WARNING::TinCreationSimplificationLindstromTurkStrategy] Input edges count per zoom vector is empty, using 500 (default value)" << std::endl;
77  m_stopEdgesCount = 500;
78  }
79  else if (zoom < m_stopEdgesCountPerZoom.size())
80  // Use the edges count corresponding to the required zoom
81  m_stopEdgesCount = m_stopEdgesCountPerZoom[zoom];
82  else {
83  // Use the edges count corresponding to the last zoom specified in the vector
84  m_stopEdgesCount = m_stopEdgesCountPerZoom.back();
85  }
86  }
87 
88  Polyhedron create(const std::vector<Point_3> &dataPts,
89  const bool &constrainEasternVertices,
90  const bool &constrainWesternVertices,
91  const bool &constrainNorthernVertices,
92  const bool &constrainSouthernVertices);
93 
94 private:
95  // Algorithm parameters
96  int m_stopEdgesCount; // Simplification edges count stop condition. If the number of edges in the surface being simplified drops below this threshold the process finishes
97  double m_weightVolume; // Weight for the volume part of Lindstrom-Turk's cost function
98  double m_weightBoundary; // Weight for the boundary part of Lindstrom-Turk's cost function
99  double m_weightShape; // Weight for the shape part of Lindstrom-Turk's cost function
100  std::vector<int> m_stopEdgesCountPerZoom; // Vector of desired edges count per zoom level
101 };
102 
103 } // End namespace TinCreation
104 
105 #endif //EMODNET_QMGC_TIN_CREATION_LINDSTROM_TURK_STRATEGY_H
Polyhedron create(const std::vector< Point_3 > &dataPts, const bool &constrainEasternVertices, const bool &constrainWesternVertices, const bool &constrainNorthernVertices, const bool &constrainSouthernVertices)
Create a TIN from a set of points.
Definition: tin_creation_simplification_lindstrom_turk_strategy.cpp:30
This namespace contains all the types/classes/functions required to create a TIN out of a regularly g...
Creates a TIN using an edge-collapse simplification method.
Definition: tin_creation_simplification_lindstrom_turk_strategy.h:38
TinCreationSimplificationLindstromTurkStrategy(std::vector< int > stopEdgesCountPerZoom, double weightVolume=0.5, double weightBoundary=0.5, double weightShape=1e-10)
Definition: tin_creation_simplification_lindstrom_turk_strategy.h:64
TinCreationSimplificationLindstromTurkStrategy(int stopEdgesCount, double weightVolume=0.5, double weightBoundary=0.5, double weightShape=1e-10)
Definition: tin_creation_simplification_lindstrom_turk_strategy.h:47
void setParamsForZoom(const unsigned int &zoom)
Adapts the parameters of the algorithm for the desired zoom level.
Definition: tin_creation_simplification_lindstrom_turk_strategy.h:74
Defines the interphase of a TIN creation algorithm.
Definition: tin_creator.h:37