forked from tudelft3d/3dfier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TopoFeature.h
158 lines (137 loc) · 6.74 KB
/
TopoFeature.h
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
3dfier: takes 2D GIS datasets and "3dfies" to create 3D city models.
Copyright (C) 2015-2016 3D geoinformation research group, TU Delft
This file is part of 3dfier.
3dfier is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
3dfier is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with 3difer. If not, see <http://www.gnu.org/licenses/>.
For any information or further details about the use of 3dfier, contact
Hugo Ledoux
<h.ledoux@tudelft.nl>
Faculty of Architecture & the Built Environment
Delft University of Technology
Julianalaan 134, Delft 2628BL, the Netherlands
*/
#ifndef __3DFIER__TopoFeature__
#define __3DFIER__TopoFeature__
#include "definitions.h"
#include "geomtools.h"
#include <random>
class TopoFeature {
public:
TopoFeature(char *wkt, std::string layername, std::vector<std::tuple<std::string, OGRFieldType, std::string>> attributes, std::string pid);
~TopoFeature();
virtual bool lift() = 0;
virtual bool buildCDT();
virtual bool add_elevation_point(Point2 &p, double z, float radius, LAS14Class lasclass, bool lastreturn) = 0;
virtual int get_number_vertices() = 0;
virtual TopoClass get_class() = 0;
virtual bool is_hard() = 0;
virtual std::string get_mtl() = 0;
virtual std::string get_citygml() = 0;
virtual std::string get_citygml_imgeo() = 0;
virtual bool get_shape(OGRLayer*) = 0;
std::string get_id();
void construct_vertical_walls(std::unordered_map< std::string, std::vector<int> > &nc, int baseheight);
void fix_bowtie();
void add_adjacent_feature(TopoFeature* adjFeature);
std::vector<TopoFeature*>* get_adjacent_features();
int get_counter();
Polygon2* get_Polygon2();
Box2 get_bbox2d();
Point2 get_point2(int ringi, int pi);
bool has_point2_(const Point2& p, std::vector<int>& ringis, std::vector<int>& pis);
bool has_segment(Point2& a, Point2& b, int& aringi, int& api, int& bringi, int& bpi);
float get_distance_to_boundaries(Point2& p);
int get_vertex_elevation(int ringi, int pi);
int get_vertex_elevation(Point2& p);
void set_vertex_elevation(int ringi, int pi, int z);
void set_top_level(bool toplevel);
bool has_vertical_walls();
void add_vertical_wall();
bool get_top_level();
std::string get_wkt();
bool get_shape_features(OGRLayer* layer, std::string className);
std::string get_obj(std::unordered_map< std::string, unsigned long > &dPts, std::string mtl);
std::string get_imgeo_object_info(std::string id);
std::string get_citygml_attributes(std::vector<std::tuple<std::string, OGRFieldType, std::string>> attributes);
protected:
Polygon2* _p2;
std::vector< std::vector<int> > _p2z;
std::vector<TopoFeature*>* _adjFeatures;
std::string _id;
int _counter;
static int _count;
bool _bVerticalWalls;
bool _toplevel;
std::string _layername;
std::vector<std::tuple<std::string, OGRFieldType, std::string>> _attributes;
std::vector< std::vector< std::vector<int> > > _lidarelevs; //-- used to collect all LiDAR points linked to the polygon
std::vector<Point3> _vertices; //-- output of Triangle
std::vector<Triangle> _triangles; //-- output of Triangle
std::vector<Point3> _vertices_vw; //-- for vertical walls
std::vector<Triangle> _triangles_vw; //-- for vertical walls
Point2 get_next_point2_in_ring(int ringi, int i, int& pi);
bool assign_elevation_to_vertex(Point2 &p, double z, float radius);
double distance(const Point2 &p1, const Point2 &p2);
bool within_range(Point2 &p, Polygon2 &oly, double radius);
bool point_in_polygon(Point2 &p, Polygon2 &poly);
void lift_each_boundary_vertices(float percentile);
void lift_all_boundary_vertices_same_height(int height);
std::string get_triangle_as_gml_surfacemember(Triangle& t, bool verticalwall = false);
std::string get_triangle_as_gml_triangle(Triangle& t, bool verticalwall = false);
bool get_attribute(std::string attributeName, std::string &attribute, std::string defaultValue = "");
};
//---------------------------------------------
class Flat: public TopoFeature {
public:
Flat(char *wkt, std::string layername, std::vector<std::tuple<std::string, OGRFieldType, std::string>> attributes, std::string pid);
int get_number_vertices();
bool add_elevation_point(Point2 &p, double z, float radius, LAS14Class lasclass, bool lastreturn);
int get_height();
virtual TopoClass get_class() = 0;
virtual bool is_hard() = 0;
virtual bool lift() = 0;
virtual std::string get_citygml() = 0;
protected:
std::vector<int> _zvaluesinside;
bool lift_percentile(float percentile);
};
//---------------------------------------------
class Boundary3D: public TopoFeature {
public:
Boundary3D(char *wkt, std::string layername, std::vector<std::tuple<std::string, OGRFieldType, std::string>> attributes, std::string pid);
int get_number_vertices();
bool add_elevation_point(Point2 &p, double z, float radius, LAS14Class lasclass, bool lastreturn);
virtual TopoClass get_class() = 0;
virtual bool is_hard() = 0;
virtual bool lift() = 0;
virtual std::string get_citygml() = 0;
protected:
int _simplification;
void smooth_boundary(int passes = 1);
};
//---------------------------------------------
class TIN: public TopoFeature {
public:
TIN(char *wkt, std::string layername, std::vector<std::tuple<std::string, OGRFieldType, std::string>> attributes, std::string pid, int simplification = 0, float innerbuffer = 0);
int get_number_vertices();
bool add_elevation_point(Point2 &p, double z, float radius, LAS14Class lasclass, bool lastreturn);
virtual TopoClass get_class() = 0;
virtual bool is_hard() = 0;
virtual bool lift() = 0;
virtual std::string get_citygml() = 0;
bool buildCDT();
protected:
int _simplification;
float _innerbuffer;
std::vector<Point3> _lidarpts;
};
#endif