-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpointlist.h
135 lines (129 loc) · 4.29 KB
/
pointlist.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
/******************************************************/
/* */
/* pointlist.h - list of points */
/* */
/******************************************************/
/* Copyright 2019-2022 Pierre Abbat.
* This file is part of PerfectTIN.
*
* PerfectTIN is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* PerfectTIN 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 and Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and Lesser General Public License along with PerfectTIN. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef POINTLIST_H
#define POINTLIST_H
class ContourLayer;
#include <map>
#include <string>
#include <vector>
#include <array>
#include <set>
#include "mthreads.h"
#include "point.h"
#include "tin.h"
#include "triangle.h"
#include "qindex.h"
#include "polyline.h"
#include "contour.h"
#include "unifiro.h"
typedef std::map<int,point> ptlist;
typedef std::map<point*,int> revptlist;
struct ContourPiece
{
spiralarc s;
std::vector<triangle *> tris;
};
class pointlist
{
public:
ptlist points;
revptlist revpoints;
std::map<int,edge> edges;
std::map<int,triangle> triangles;
std::map<triangle*,int> revtriangles;
/* edges and triangles are logically arrays from 0 to size()-1, but are
* implemented as maps, because they have pointers to each other, and points
* point to edges, and the pointers would be messed up by moving memory
* when a vector is resized.
*/
std::map<ContourInterval,std::vector<polyspiral> > contours;
std::vector<polyspiral> *currentContours;
polyline boundary;
qindex qinx;
std::vector<point*> convexHull;
Unifiro<triangle *> trianglePool,trianglePaint;
Unifiro<edge *> edgePool;
Unifiro<void *> pieceDraw;
double swishFactor; // for tracing top or bottom of a point cloud
time_t conversionTime; // Time when conversion starts, used to identify checkpoint files
std::shared_mutex wingEdge; // Lock this while changing pointers in the winged edge structure.
std::map<int,std::vector<ContourPiece> > contourPieces;
std::mutex pieceMutex;
int pieceInx;
void addpoint(int numb,point pnt,bool overwrite=false);
int addtriangle(int n=1,int thread=-1);
void insertHullPoint(point *newpnt,point *prec);
int closestHullPoint(xy pnt);
double distanceToHull(xy pnt);
bool validConvexHull();
std::vector<int> valencyHistogram();
bool shouldWrite(int n,int flags,bool contours);
void updateqindex();
double elevation(xy location);
xy gradient(xy location);
double dirbound(int angle);
void clear();
int size();
void clearmarks();
void clearTin();
void setDirty(bool d);
bool isDirty()
{
return dirty;
}
void unsetCurrentContours();
void setCurrentContours(ContourInterval &ci);
void deleteCurrentContours();
std::vector<ContourInterval> contourIntervals();
std::map<ContourLayer,int> contourLayers();
void insertContourPiece(spiralarc s,int thread);
void deleteContourPiece(spiralarc s,int thread);
std::vector<ContourPiece> getContourPieces(int inx);
void nipPieces();
void insertPieces(polyspiral ctour,int thread);
void deletePieces(polyspiral ctour,int thread);
int statsPieces();
void eraseEmptyContours();
int isSmoothed(const segment &seg);
int isNextPieceSmoothed();
bool checkTinConsistency();
triangle *findt(xy pnt,bool clip=false);
private:
bool dirty;
void nipPiece();
// the following methods are in tin.cpp
void dumpedges();
void dumpnext_ps(PostScript &ps);
public:
void dumpedges_ps(PostScript &ps,bool colorfibaster);
void maketriangles();
void makeqindex();
void makeEdges();
double totalEdgeLength();
std::array<double,2> lohi();
std::array<double,2> lohi(polyline p,double tolerance);
double contourError(segment seg);
virtual void roscat(xy tfrom,int ro,double sca,xy tto); // rotate, scale, translate
};
#endif