-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodelGen2d.h
More file actions
119 lines (103 loc) · 3.05 KB
/
modelGen2d.h
File metadata and controls
119 lines (103 loc) · 3.05 KB
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
#ifndef MODELGEN2D_H
#define MODELGEN2D_H
#include <algorithm> //[min|max]element
#include <array>
#include <cassert>
#include <fstream>
#include <iostream>
#include <limits> //std::numeric_limits
#include <map>
#include <string>
#include <tuple>
#include <vector>
#include <functional> //std::function
#include <math.h>
#include "splineInterpolation.h"
struct PointClassification {
std::vector<int> dim;
std::vector<int> id;
std::vector<int> splineIdx;
void writeToOsh(std::string filename);
PointClassification(int n) : dim(n), id(n), splineIdx(n) {}
};
//FIXME - make this a class
struct GeomInfo {
int numVtx;
int numEdges;
std::vector<double> vtx_x;
std::vector<double> vtx_y;
std::vector<int> verts;
std::vector<std::array<int, 2>> edges;
static const int firstContourPt = 0; //FIXME - remove this
void addVtx(int id, double x, double y) {
numVtx++;
verts.push_back(id);
vtx_x.push_back(x);
vtx_y.push_back(y);
}
void addEdge(int vtxA, int vtxB) {
numEdges++;
edges.push_back({vtxA,vtxB});
}
int getPrevPtIdx(int i) {
if(i == firstContourPt) {
return vtx_x.size()-1;
} else {
return i-1;
}
}
int getNextPtIdx(int i) {
if(i == vtx_x.size()-1) {
return firstContourPt;
} else {
return i+1;
}
}
void reverseContourPoints() {
std::reverse(vtx_x.begin()+firstContourPt, vtx_x.end());
std::reverse(vtx_y.begin()+firstContourPt, vtx_y.end());
edges.clear(); //indices become invalid
}
};
struct ModelFeatures {
GeomInfo inner;
GeomInfo outer;
};
struct PlaneBounds {
double minX;
double maxX;
double minY;
double maxY;
};
PlaneBounds getBoundingPlane(GeomInfo &geom);
namespace Omega_h {
class Library; //fwd declare
};
GeomInfo readOmegahGeom(Omega_h::Library& lib, std::string fname, bool debug = false);
ModelFeatures readVtkGeom(std::string fname, bool debug = false);
ModelFeatures readJigGeom(std::string fname, bool debug = false);
double getLengthSquared(double ax, double ay, double bx, double by);
bool isPtCoincident(double ax, double ay, double bx, double by,
double tolSquared = 1);
int findFirstPt(std::vector<int>& prop, const int offset, const int match);
void convertMetersToKm(GeomInfo &geom);
GeomInfo cleanGeom(GeomInfo &dirty, double coincidentVtxToleranceSquared,
bool debug = false);
void makeOrientationPositive(GeomInfo& geom, bool debug=false);
std::tuple<std::vector<int>,std::vector<int>>
discoverTopology(GeomInfo& geom, double coincidentPtTolSquared, double angleTol, double onCurveAngleTol, bool debug = false);
class OnCurve {
public:
OnCurve(double onCurveAngleTol, bool isDebug=false);
//similar to scorec/tomms @ 2f97d13 (simapis-mod branch)
int operator()(double tc_m1, double tc, double tc_p1);
double getLowerTolTC() const { return tc_angle_lower; }
double getUpperTolTC() const { return tc_angle_upper; }
private:
const double deg_angle_lower;
const double deg_angle_upper;
const double tc_angle_lower;
const double tc_angle_upper;
const bool debug;
};
#endif