model_func
ThModelFunc
模型工具函数 Python 二次封装类 底层直接调用源扩展接口,提供静态工具方法
Source code in dimine_python_sdk\lib\algorithm\model_func.py
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
calculate_min_rectangle_2d(point_set, d_bounds)
staticmethod
计算点集的最小外接矩形 :param point_set: 点集列表 :param d_bounds: 包围盒 :return: 最小外接矩形的4个角点列表
example:
point_set = [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(1, 1, 0)]
d_bounds = [0, 1, 0, 1, 0, 1]
min_rect = ThModelFunc.calculate_min_rectangle_2d(point_set, d_bounds)
print(min_rect) # 输出: [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(1, 1, 0)]
Source code in dimine_python_sdk\lib\algorithm\model_func.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
compute_bounds(point_set)
staticmethod
计算点集的边界范围 :param point_set: 点集列表 :return: 边界参数列表(6个值)
example:
point_set = [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(1, 1, 0)]
bounds = ThModelFunc.compute_bounds(point_set)
print(bounds) # 输出: [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
Source code in dimine_python_sdk\lib\algorithm\model_func.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
compute_normal(point_set)
staticmethod
计算点集的法向量 :param point_set: 点集列表 :return: 法向量
example:
point_set = [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0)]
normal = ThModelFunc.compute_normal(point_set)
print(normal) # 输出: DmDPoint(0.0, 0.0, 1.0)
Source code in dimine_python_sdk\lib\algorithm\model_func.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
cross(vector1, vector2)
staticmethod
计算两个向量的叉积 :param vector1: 向量1 :param vector2: 向量2 :return: 叉积结果向量
example:
vector1 = DmDPoint(1, 0, 0)
vector2 = DmDPoint(0, 1, 0)
cross_product = ThModelFunc.cross(vector1, vector2)
print(cross_product) # 输出: DmDPoint(0, 0, 1)
Source code in dimine_python_sdk\lib\algorithm\model_func.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
cut_model_data(input_data, origin, normal, output_data, num=1, dist=0)
staticmethod
裁剪模型数据 :param input_data: 输入模型数据 :param origin: 裁剪平面原点 :param normal: 裁剪平面法向量 :param output_data: 返回值 :param num: 切面个数 :param dist: 切面距离 :return: 1成功 0失败
example:
input_data = DmPolyData()
origin = DmDPoint(0, 0, 0)
normal = DmDPoint(0, 0, 1)
output_data = DmPolyData()
result = ThModelFunc.cut_model_data(input_data, origin, normal,output_data)
print(result) # 输出: 1
Source code in dimine_python_sdk\lib\algorithm\model_func.py
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 | |
distance(point_a, point_b)
staticmethod
计算两点间距离 :param point_a: 点A对象 :param point_b: 点B对象 :return: 两点间距离(浮点数)
example:
point_a = DmDPoint(0, 0, 0)
point_b = DmDPoint(1, 1, 1)
distance = ThModelFunc.distance(point_a, point_b)
print(distance) # 输出: 1.7320508075688772
Source code in dimine_python_sdk\lib\algorithm\model_func.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
line_x_polyline(start, end, point_set, tolerance)
staticmethod
计算线段与多段线的交点 :param start: 线段起点 :param end: 线段终点 :param point_set: 多段线点集 :param tolerance: 容差 :return: 交点列表
example:
start = DmDPoint(0, 0, 0)
end = DmDPoint(1, 1, 1)
point_set = [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(1, 1, 0)]
tolerance = 0.01
intersections = ThModelFunc.line_x_polyline(start, end, point_set, tolerance)
print(intersections) # 输出: [DmDPoint(0.5, 0.5, 0.0)]
Source code in dimine_python_sdk\lib\algorithm\model_func.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
project_point_on_plane(origin, normal, point)
staticmethod
将点投影到平面上 :param origin: 平面原点 :param normal: 平面法向量 :param point: 待投影点 :return: 1成功,0失败
example:
origin = DmDPoint(0, 0, 0)
normal = DmDPoint(0, 0, 1)
point = DmDPoint(1, 1, 1)
result = ThModelFunc.project_point_on_plane(origin, normal, point)
print(result) # 输出: 1
Source code in dimine_python_sdk\lib\algorithm\model_func.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
TwModelFunc
点集处理工具类(Python风格二次封装)
Source code in dimine_python_sdk\lib\algorithm\model_func.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
calculate_theat_phi_psi(vector, use_radians=True)
staticmethod
这里的倾角定义为与 xy 平面的夹角 计算向量的方位角、倾角和长度 :param vector: 输入向量 :param use_radians: 是否返回弧度(默认返回角度) :return: 包含 'azimuth', 'dip'的字典
example:
vector = DmDPoint(1, 1, 1)
result = TwModelFunc.calculate_theat_phi_psi(vector,False)
print(result) # 输出: {'azimuth': 45.0, 'dip': 35.264389682754654}
Source code in dimine_python_sdk\lib\algorithm\model_func.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
sort_points(base_point, points)
staticmethod
根据点集和基点的距离按从小到大进行排列,并清除重复点 :param base_point: 基准点,计算距离的中心 :param points: 待排序的点集列表 :return: 排序并去重后的点集
example:
base_point = DmDPoint(0, 0, 0)
points = [DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(0, 0, 1)]
sorted_points = TwModelFunc.sort_points(base_point, points)
print(sorted_points) # 输出: [DmDPoint(0.0, 0.0, 1.0), DmDPoint(0.0, 1.0, 0.0), DmDPoint(1.0, 0.0, 0.0)]
Source code in dimine_python_sdk\lib\algorithm\model_func.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |