-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViaDistribution.hpp
79 lines (67 loc) · 2.58 KB
/
ViaDistribution.hpp
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
#pragma once
#include <lsGeometricAdvectDistributions.hpp>
#include "BoschProcessData.hpp"
template <class T, int D>
class ViaDistribution : public lsGeometricAdvectDistribution<T, D> {
double getDepth(const std::array<hrleCoordType, 3> &initial) const {
if (!isTapering ||
std::abs(data.taperStart) > std::abs(data.trenchBottom)) {
return data.trenchBottom;
}
double radius = 0;
for (unsigned i = 0; i < D - 1; ++i) {
double dist = initial[i] - data.maskOrigin[i];
radius += dist * dist;
}
radius = std::max(0.0, std::sqrt(radius) - data.bottomWidth);
// adjust depth depending on radius from the middle of the via
double depth =
data.taperStart +
std::max(1.0 - radius / (data.startWidth - data.bottomWidth), 0.0) *
taperDepth;
return depth;
}
public:
BoschProcessDataType<T> data;
const double taperDepth;
const bool isTapering;
ViaDistribution(const BoschProcessDataType<T> &processData)
: data(processData), taperDepth(data.trenchBottom - data.taperStart),
isTapering(data.sidewallTapering) {}
bool isInside(const std::array<hrleCoordType, 3> &initial,
const std::array<hrleCoordType, 3> &candidate,
double eps = 0.) const override {
for (unsigned i = 0; i < D - 1; ++i) {
if (std::abs(candidate[i] - initial[i]) > (data.gridDelta + eps)) {
return false;
}
}
if (std::abs(candidate[D - 1] - initial[D - 1]) >
std::abs(data.trenchBottom) + eps) {
return false;
}
return true;
}
T getSignedDistance(const std::array<hrleCoordType, 3> &initial,
const std::array<hrleCoordType, 3> &candidate,
unsigned long initialPointId) const override {
T distance = std::numeric_limits<T>::lowest();
for (unsigned i = 0; i < D - 1; ++i) {
T vector = std::abs(candidate[i] - initial[i]);
distance = std::max(vector - data.gridDelta, distance);
}
T vector = std::abs(candidate[D - 1] - initial[D - 1]);
distance = std::max(vector - std::abs(getDepth(initial)), distance);
return (data.trenchBottom < 0) ? -distance : distance;
}
std::array<hrleCoordType, 6> getBounds() const override {
std::array<hrleCoordType, 6> bounds = {};
for (unsigned i = 0; i < D - 1; ++i) {
bounds[2 * i] = -data.gridDelta * ((data.trenchBottom < 0) ? -1 : 1);
bounds[2 * i + 1] = data.gridDelta * ((data.trenchBottom < 0) ? -1 : 1);
}
bounds[2 * (D - 1)] = -data.trenchBottom;
bounds[2 * (D - 1) + 1] = data.trenchBottom;
return bounds;
}
};