dimine-python-sdk 0.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dimine_python_sdk/__init__.py +13 -0
- dimine_python_sdk/conn/__init__.py +5 -0
- dimine_python_sdk/conn/base_conn_client.py +167 -0
- dimine_python_sdk/conn/conn_client.py +382 -0
- dimine_python_sdk/docs/guides/data_edit.md +306 -0
- dimine_python_sdk/docs/guides/data_get.md +266 -0
- dimine_python_sdk/docs/guides/data_types.md +152 -0
- dimine_python_sdk/docs/guides/features.md +271 -0
- dimine_python_sdk/docs/guides/io.md +157 -0
- dimine_python_sdk/docs/index.md +41 -0
- dimine_python_sdk/docs/quickstart.md +45 -0
- dimine_python_sdk/docs/reference/SUMMARY.md +19 -0
- dimine_python_sdk/docs/reference/conn/base_conn_client.md +3 -0
- dimine_python_sdk/docs/reference/conn/conn_client.md +3 -0
- dimine_python_sdk/docs/reference/lib/algorithm/model_func.md +3 -0
- dimine_python_sdk/docs/reference/lib/io/file_conversion.md +3 -0
- dimine_python_sdk/docs/reference/lib/io/models.md +3 -0
- dimine_python_sdk/docs/reference/lib/io/project_plotting.md +3 -0
- dimine_python_sdk/docs/reference/lib/prospecting/block_data.md +3 -0
- dimine_python_sdk/docs/reference/lib/prospecting/drill_db.md +3 -0
- dimine_python_sdk/docs/reference/lib/prospecting/models.md +3 -0
- dimine_python_sdk/docs/reference/lib/prospecting/valuation.md +3 -0
- dimine_python_sdk/docs/reference/lib/types/entity.md +3 -0
- dimine_python_sdk/docs/reference/lib/types/line.md +3 -0
- dimine_python_sdk/docs/reference/lib/types/point.md +3 -0
- dimine_python_sdk/docs/reference/logger.md +3 -0
- dimine_python_sdk/docs/reference/models/conn.md +3 -0
- dimine_python_sdk/docs/reference/models/errors.md +3 -0
- dimine_python_sdk/docs/reference/models/types.md +3 -0
- dimine_python_sdk/docs/summary.md +6 -0
- dimine_python_sdk/lib/__init__.py +20 -0
- dimine_python_sdk/lib/algorithm/__init__.py +1 -0
- dimine_python_sdk/lib/algorithm/model_func.py +219 -0
- dimine_python_sdk/lib/exploitation/__init__.py +0 -0
- dimine_python_sdk/lib/io/__init__.py +2 -0
- dimine_python_sdk/lib/io/file_conversion.py +143 -0
- dimine_python_sdk/lib/io/models.py +180 -0
- dimine_python_sdk/lib/io/project_plotting.py +40 -0
- dimine_python_sdk/lib/prospecting/__init__.py +3 -0
- dimine_python_sdk/lib/prospecting/block_data.py +289 -0
- dimine_python_sdk/lib/prospecting/drill_db.py +333 -0
- dimine_python_sdk/lib/prospecting/models.py +276 -0
- dimine_python_sdk/lib/prospecting/valuation.py +113 -0
- dimine_python_sdk/lib/types/__init__.py +4 -0
- dimine_python_sdk/lib/types/entity.py +957 -0
- dimine_python_sdk/lib/types/line.py +188 -0
- dimine_python_sdk/lib/types/point.py +695 -0
- dimine_python_sdk/logger.py +7 -0
- dimine_python_sdk/models/__init__.py +3 -0
- dimine_python_sdk/models/conn.py +53 -0
- dimine_python_sdk/models/errors.py +4 -0
- dimine_python_sdk/models/types.py +131 -0
- dimine_python_sdk/site/404.html +671 -0
- dimine_python_sdk/site/assets/_mkdocstrings.css +237 -0
- dimine_python_sdk/site/assets/images/favicon.png +0 -0
- dimine_python_sdk/site/assets/javascripts/bundle.79ae519e.min.js +16 -0
- dimine_python_sdk/site/assets/javascripts/bundle.79ae519e.min.js.map +7 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ar.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.da.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.de.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.du.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.el.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.es.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.fi.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.fr.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.he.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.hi.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.hu.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.hy.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.it.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ja.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.jp.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.kn.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ko.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.multi.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.nl.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.no.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.pt.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ro.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ru.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.sa.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.sv.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ta.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.te.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.th.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.tr.min.js +18 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.vi.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.zh.min.js +1 -0
- dimine_python_sdk/site/assets/javascripts/lunr/tinyseg.js +206 -0
- dimine_python_sdk/site/assets/javascripts/lunr/wordcut.js +6708 -0
- dimine_python_sdk/site/assets/javascripts/workers/search.2c215733.min.js +42 -0
- dimine_python_sdk/site/assets/javascripts/workers/search.2c215733.min.js.map +7 -0
- dimine_python_sdk/site/assets/stylesheets/main.484c7ddc.min.css +1 -0
- dimine_python_sdk/site/assets/stylesheets/main.484c7ddc.min.css.map +1 -0
- dimine_python_sdk/site/assets/stylesheets/palette.ab4e12ef.min.css +1 -0
- dimine_python_sdk/site/assets/stylesheets/palette.ab4e12ef.min.css.map +1 -0
- dimine_python_sdk/site/guides/data_edit.html +1251 -0
- dimine_python_sdk/site/guides/data_get.html +1206 -0
- dimine_python_sdk/site/guides/data_types.html +1529 -0
- dimine_python_sdk/site/guides/features.html +1217 -0
- dimine_python_sdk/site/guides/io.html +1025 -0
- dimine_python_sdk/site/index.html +849 -0
- dimine_python_sdk/site/objects.inv +0 -0
- dimine_python_sdk/site/quickstart.html +859 -0
- dimine_python_sdk/site/reference/SUMMARY.html +729 -0
- dimine_python_sdk/site/reference/conn/base_conn_client.html +1295 -0
- dimine_python_sdk/site/reference/conn/conn_client.html +3551 -0
- dimine_python_sdk/site/reference/lib/algorithm/model_func.html +2162 -0
- dimine_python_sdk/site/reference/lib/io/file_conversion.html +1725 -0
- dimine_python_sdk/site/reference/lib/io/models.html +1625 -0
- dimine_python_sdk/site/reference/lib/io/project_plotting.html +984 -0
- dimine_python_sdk/site/reference/lib/prospecting/block_data.html +2455 -0
- dimine_python_sdk/site/reference/lib/prospecting/drill_db.html +2836 -0
- dimine_python_sdk/site/reference/lib/prospecting/models.html +2309 -0
- dimine_python_sdk/site/reference/lib/prospecting/valuation.html +1373 -0
- dimine_python_sdk/site/reference/lib/types/entity.html +6728 -0
- dimine_python_sdk/site/reference/lib/types/line.html +1985 -0
- dimine_python_sdk/site/reference/lib/types/point.html +3672 -0
- dimine_python_sdk/site/reference/logger.html +751 -0
- dimine_python_sdk/site/reference/models/conn.html +751 -0
- dimine_python_sdk/site/reference/models/errors.html +802 -0
- dimine_python_sdk/site/reference/models/types.html +1679 -0
- dimine_python_sdk/site/search/search_index.json +1 -0
- dimine_python_sdk/site/sitemap.xml +107 -0
- dimine_python_sdk/site/sitemap.xml.gz +0 -0
- dimine_python_sdk/site/summary.html +697 -0
- dimine_python_sdk-0.1.8.dist-info/METADATA +15 -0
- dimine_python_sdk-0.1.8.dist-info/RECORD +135 -0
- dimine_python_sdk-0.1.8.dist-info/WHEEL +5 -0
- dimine_python_sdk-0.1.8.dist-info/top_level.txt +2 -0
- tests/conn_test.py +250 -0
- tests/test_base_type.py +143 -0
- tests/ws_client.py +60 -0
- tests/ws_server.py +271 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import sys
|
|
4
|
+
from dimine_python_sdk.logger import logger
|
|
5
|
+
|
|
6
|
+
DM_PYD_NAME = "DmPyBindInterface.pyd"
|
|
7
|
+
|
|
8
|
+
__DIMINE_HOME__ = os.environ.get("DIMINE_HOME", None) # DIMINE 软件安装路径
|
|
9
|
+
if __DIMINE_HOME__ and (Path(__DIMINE_HOME__)/DM_PYD_NAME).exists():
|
|
10
|
+
sys.path.append(__DIMINE_HOME__)
|
|
11
|
+
else:
|
|
12
|
+
logger.error("DIMINE_HOME not found or DmPyBindInterface.pyd not found in DIMINE_HOME")
|
|
13
|
+
|
|
14
|
+
def set_dimine_home(dimine_home: str):
|
|
15
|
+
if dimine_home and (Path(dimine_home)/DM_PYD_NAME).exists():
|
|
16
|
+
os.environ["DIMINE_HOME"] = dimine_home
|
|
17
|
+
logger.info(f"set DIMINE_HOME to {dimine_home}")
|
|
18
|
+
__DIMINE_HOME__ = dimine_home
|
|
19
|
+
else:
|
|
20
|
+
raise Exception(f"dimine_home not found: {dimine_home} or DmPyBindInterface.pyd not found in dimine_home")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from dimine_python_sdk.lib.algorithm.model_func import *
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import DmPyBindInterface as Dm
|
|
2
|
+
|
|
3
|
+
from dimine_python_sdk.lib.types import DmDPoint, DmPolyData
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ThModelFunc:
|
|
7
|
+
"""
|
|
8
|
+
模型工具函数 Python 二次封装类
|
|
9
|
+
底层直接调用源扩展接口,提供静态工具方法
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def distance(point_a: DmDPoint, point_b: DmDPoint) -> float:
|
|
14
|
+
"""
|
|
15
|
+
计算两点间距离
|
|
16
|
+
:param point_a: 点A对象
|
|
17
|
+
:param point_b: 点B对象
|
|
18
|
+
:return: 两点间距离(浮点数)
|
|
19
|
+
|
|
20
|
+
example:
|
|
21
|
+
```python
|
|
22
|
+
point_a = DmDPoint(0, 0, 0)
|
|
23
|
+
point_b = DmDPoint(1, 1, 1)
|
|
24
|
+
distance = ThModelFunc.distance(point_a, point_b)
|
|
25
|
+
print(distance) # 输出: 1.7320508075688772
|
|
26
|
+
```
|
|
27
|
+
"""
|
|
28
|
+
return Dm.thModelFunc.Distance(point_a._obj, point_b._obj)
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def calculate_min_rectangle_2d(point_set: list[DmDPoint],d_bounds: list[float]) -> list[DmDPoint]:
|
|
32
|
+
"""
|
|
33
|
+
计算点集的最小外接矩形
|
|
34
|
+
:param point_set: 点集列表
|
|
35
|
+
:param d_bounds: 包围盒
|
|
36
|
+
:return: 最小外接矩形的4个角点列表
|
|
37
|
+
|
|
38
|
+
example:
|
|
39
|
+
```python
|
|
40
|
+
point_set = [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(1, 1, 0)]
|
|
41
|
+
d_bounds = [0, 1, 0, 1, 0, 1]
|
|
42
|
+
min_rect = ThModelFunc.calculate_min_rectangle_2d(point_set, d_bounds)
|
|
43
|
+
print(min_rect) # 输出: [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(1, 1, 0)]
|
|
44
|
+
```
|
|
45
|
+
"""
|
|
46
|
+
cpp_points = [p._obj for p in point_set]
|
|
47
|
+
cpp_result = Dm.thModelFunc.CalcultateMinRectangle2D(cpp_points,d_bounds)
|
|
48
|
+
return [DmDPoint._from_obj(p) for p in cpp_result]
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def cross(vector1: DmDPoint, vector2: DmDPoint) -> DmDPoint:
|
|
52
|
+
"""
|
|
53
|
+
计算两个向量的叉积
|
|
54
|
+
:param vector1: 向量1
|
|
55
|
+
:param vector2: 向量2
|
|
56
|
+
:return: 叉积结果向量
|
|
57
|
+
|
|
58
|
+
example:
|
|
59
|
+
```python
|
|
60
|
+
vector1 = DmDPoint(1, 0, 0)
|
|
61
|
+
vector2 = DmDPoint(0, 1, 0)
|
|
62
|
+
cross_product = ThModelFunc.cross(vector1, vector2)
|
|
63
|
+
print(cross_product) # 输出: DmDPoint(0, 0, 1)
|
|
64
|
+
```
|
|
65
|
+
"""
|
|
66
|
+
cpp_result = Dm.thModelFunc.Cross(vector1._obj, vector2._obj)
|
|
67
|
+
return DmDPoint._from_obj(cpp_result)
|
|
68
|
+
|
|
69
|
+
@staticmethod
|
|
70
|
+
def compute_bounds(point_set: list[DmDPoint]) -> list[float]:
|
|
71
|
+
"""
|
|
72
|
+
计算点集的边界范围
|
|
73
|
+
:param point_set: 点集列表
|
|
74
|
+
:return: 边界参数列表(6个值)
|
|
75
|
+
|
|
76
|
+
example:
|
|
77
|
+
```python
|
|
78
|
+
point_set = [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(1, 1, 0)]
|
|
79
|
+
bounds = ThModelFunc.compute_bounds(point_set)
|
|
80
|
+
print(bounds) # 输出: [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
|
|
81
|
+
```
|
|
82
|
+
"""
|
|
83
|
+
cpp_points = [p._obj for p in point_set]
|
|
84
|
+
return Dm.thModelFunc.ComputeBounds(cpp_points)
|
|
85
|
+
|
|
86
|
+
@staticmethod
|
|
87
|
+
def cut_model_data(input_data: DmPolyData, origin: DmDPoint, normal: DmDPoint,output_data: DmPolyData,num:int = 1,dist:float = 0) -> int:
|
|
88
|
+
"""
|
|
89
|
+
裁剪模型数据
|
|
90
|
+
:param input_data: 输入模型数据
|
|
91
|
+
:param origin: 裁剪平面原点
|
|
92
|
+
:param normal: 裁剪平面法向量
|
|
93
|
+
:param output_data: 返回值
|
|
94
|
+
:param num: 切面个数
|
|
95
|
+
:param dist: 切面距离
|
|
96
|
+
:return: 1成功 0失败
|
|
97
|
+
|
|
98
|
+
example:
|
|
99
|
+
```python
|
|
100
|
+
input_data = DmPolyData()
|
|
101
|
+
origin = DmDPoint(0, 0, 0)
|
|
102
|
+
normal = DmDPoint(0, 0, 1)
|
|
103
|
+
output_data = DmPolyData()
|
|
104
|
+
result = ThModelFunc.cut_model_data(input_data, origin, normal,output_data)
|
|
105
|
+
print(result) # 输出: 1
|
|
106
|
+
```
|
|
107
|
+
"""
|
|
108
|
+
result = Dm.thModelFunc.CutModelData(input_data._obj, origin._obj, normal._obj,output_data._obj, num, dist)
|
|
109
|
+
if result != 1:
|
|
110
|
+
raise ValueError(f"模型切割失败,底层返回结果码:{result}")
|
|
111
|
+
return result
|
|
112
|
+
|
|
113
|
+
@staticmethod
|
|
114
|
+
def project_point_on_plane(origin: DmDPoint, normal: DmDPoint, point: DmDPoint) -> int:
|
|
115
|
+
"""
|
|
116
|
+
将点投影到平面上
|
|
117
|
+
:param origin: 平面原点
|
|
118
|
+
:param normal: 平面法向量
|
|
119
|
+
:param point: 待投影点
|
|
120
|
+
:return: 1成功,0失败
|
|
121
|
+
|
|
122
|
+
example:
|
|
123
|
+
```python
|
|
124
|
+
origin = DmDPoint(0, 0, 0)
|
|
125
|
+
normal = DmDPoint(0, 0, 1)
|
|
126
|
+
point = DmDPoint(1, 1, 1)
|
|
127
|
+
result = ThModelFunc.project_point_on_plane(origin, normal, point)
|
|
128
|
+
print(result) # 输出: 1
|
|
129
|
+
```
|
|
130
|
+
"""
|
|
131
|
+
print(point._obj)
|
|
132
|
+
result = Dm.thModelFunc.ProjectPointsOnPlane(origin._obj, normal._obj, point._obj)
|
|
133
|
+
print(point._obj)
|
|
134
|
+
if result != 1:
|
|
135
|
+
raise ValueError(f"投影失败,底层返回结果码:{result}")
|
|
136
|
+
return result
|
|
137
|
+
|
|
138
|
+
@staticmethod
|
|
139
|
+
def line_x_polyline(start: DmDPoint, end: DmDPoint, point_set: list[DmDPoint], tolerance: float) -> list[DmDPoint]:
|
|
140
|
+
"""
|
|
141
|
+
计算线段与多段线的交点
|
|
142
|
+
:param start: 线段起点
|
|
143
|
+
:param end: 线段终点
|
|
144
|
+
:param point_set: 多段线点集
|
|
145
|
+
:param tolerance: 容差
|
|
146
|
+
:return: 交点列表
|
|
147
|
+
|
|
148
|
+
example:
|
|
149
|
+
```python
|
|
150
|
+
start = DmDPoint(0, 0, 0)
|
|
151
|
+
end = DmDPoint(1, 1, 1)
|
|
152
|
+
point_set = [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(1, 1, 0)]
|
|
153
|
+
tolerance = 0.01
|
|
154
|
+
intersections = ThModelFunc.line_x_polyline(start, end, point_set, tolerance)
|
|
155
|
+
print(intersections) # 输出: [DmDPoint(0.5, 0.5, 0.0)]
|
|
156
|
+
```
|
|
157
|
+
"""
|
|
158
|
+
cpp_points = [p._obj for p in point_set]
|
|
159
|
+
cpp_result = Dm.thModelFunc.LineXPolyline(start._obj, end._obj, cpp_points, tolerance)
|
|
160
|
+
return [DmDPoint._from_obj(p) for p in cpp_result]
|
|
161
|
+
|
|
162
|
+
@staticmethod
|
|
163
|
+
def compute_normal(point_set: list[DmDPoint]) -> DmDPoint:
|
|
164
|
+
"""
|
|
165
|
+
计算点集的法向量
|
|
166
|
+
:param point_set: 点集列表
|
|
167
|
+
:return: 法向量
|
|
168
|
+
|
|
169
|
+
example:
|
|
170
|
+
```python
|
|
171
|
+
point_set = [DmDPoint(0, 0, 0), DmDPoint(1, 0, 0), DmDPoint(0, 1, 0)]
|
|
172
|
+
normal = ThModelFunc.compute_normal(point_set)
|
|
173
|
+
print(normal) # 输出: DmDPoint(0.0, 0.0, 1.0)
|
|
174
|
+
```
|
|
175
|
+
"""
|
|
176
|
+
cpp_points = [p._obj for p in point_set]
|
|
177
|
+
cpp_result = Dm.thModelFunc.ComputeNormal(cpp_points)
|
|
178
|
+
return DmDPoint._from_obj(cpp_result)
|
|
179
|
+
|
|
180
|
+
class TwModelFunc:
|
|
181
|
+
"""点集处理工具类(Python风格二次封装)"""
|
|
182
|
+
@staticmethod
|
|
183
|
+
def sort_points(base_point: DmDPoint,points: list[DmDPoint]) -> list[DmDPoint]:
|
|
184
|
+
"""
|
|
185
|
+
根据点集和基点的距离按从小到大进行排列,并清除重复点
|
|
186
|
+
:param base_point: 基准点,计算距离的中心
|
|
187
|
+
:param points: 待排序的点集列表
|
|
188
|
+
:return: 排序并去重后的点集
|
|
189
|
+
|
|
190
|
+
example:
|
|
191
|
+
```python
|
|
192
|
+
base_point = DmDPoint(0, 0, 0)
|
|
193
|
+
points = [DmDPoint(1, 0, 0), DmDPoint(0, 1, 0), DmDPoint(0, 0, 1)]
|
|
194
|
+
sorted_points = TwModelFunc.sort_points(base_point, points)
|
|
195
|
+
print(sorted_points) # 输出: [DmDPoint(0.0, 0.0, 1.0), DmDPoint(0.0, 1.0, 0.0), DmDPoint(1.0, 0.0, 0.0)]
|
|
196
|
+
```
|
|
197
|
+
"""
|
|
198
|
+
cpp_points = [p._obj for p in points]
|
|
199
|
+
sorted_points = Dm.PointSetSort(base_point._obj, cpp_points)
|
|
200
|
+
return [DmDPoint._from_obj(p) for p in sorted_points]
|
|
201
|
+
|
|
202
|
+
@staticmethod
|
|
203
|
+
def calculate_theat_phi_psi(vector: DmDPoint,use_radians: bool = True) -> dict:
|
|
204
|
+
"""
|
|
205
|
+
这里的倾角定义为与 xy 平面的夹角
|
|
206
|
+
计算向量的方位角、倾角和长度
|
|
207
|
+
:param vector: 输入向量
|
|
208
|
+
:param use_radians: 是否返回弧度(默认返回角度)
|
|
209
|
+
:return: 包含 'azimuth', 'dip'的字典
|
|
210
|
+
|
|
211
|
+
example:
|
|
212
|
+
```python
|
|
213
|
+
vector = DmDPoint(1, 1, 1)
|
|
214
|
+
result = TwModelFunc.calculate_theat_phi_psi(vector,False)
|
|
215
|
+
print(result) # 输出: {'azimuth': 45.0, 'dip': 35.264389682754654}
|
|
216
|
+
```
|
|
217
|
+
"""
|
|
218
|
+
result = Dm.twModelFunc.CalculateTheatPhiPsi(vector._obj, use_radians)
|
|
219
|
+
return result
|
|
File without changes
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import DmPyBindInterface as Dm
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Union
|
|
4
|
+
|
|
5
|
+
class FileConverter:
|
|
6
|
+
"""
|
|
7
|
+
文件格式转换工具类,支持AutoCAD、Surpac、MicroMine、DataMine、MapGIS与DMF格式互转
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
@staticmethod
|
|
11
|
+
def cad_to_dmf(cad_file: Union[str, Path], dmf_file: Union[str, Path]) -> bool:
|
|
12
|
+
"""
|
|
13
|
+
AutoCAD文件转DMF格式
|
|
14
|
+
:param cad_file: 输入AutoCAD文件路径
|
|
15
|
+
:param dmf_file: 输出DMF文件路径
|
|
16
|
+
:return: 是否转换成功
|
|
17
|
+
|
|
18
|
+
example:
|
|
19
|
+
```python
|
|
20
|
+
FileConverter.cad_to_dmf("input.dwg", "output.dmf")
|
|
21
|
+
```
|
|
22
|
+
"""
|
|
23
|
+
return Dm.dmIO_CADToDmf(str(cad_file), str(dmf_file))
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def dmf_to_cad(dmf_file: Union[str, Path], cad_file: Union[str, Path]) -> bool:
|
|
27
|
+
"""
|
|
28
|
+
DMF文件转AutoCAD格式
|
|
29
|
+
:param dmf_file: 输入DMF文件路径
|
|
30
|
+
:param cad_file: 输出AutoCAD文件路径
|
|
31
|
+
:return: 是否转换成功
|
|
32
|
+
|
|
33
|
+
example:
|
|
34
|
+
```python
|
|
35
|
+
FileConverter.dmf_to_cad("input.dmf", "output.dwg")
|
|
36
|
+
```
|
|
37
|
+
"""
|
|
38
|
+
return Dm.dmIO_DmfToCAD(str(dmf_file), str(cad_file))
|
|
39
|
+
|
|
40
|
+
@staticmethod
|
|
41
|
+
def surpac_to_dmf(surpac_file: Union[str, Path], dmf_file: Union[str, Path]) -> bool:
|
|
42
|
+
"""
|
|
43
|
+
Surpac文件转DMF格式
|
|
44
|
+
:param surpac_file: 输入Surpac文件路径
|
|
45
|
+
:param dmf_file: 输出DMF文件路径
|
|
46
|
+
:return: 是否转换成功
|
|
47
|
+
|
|
48
|
+
example:
|
|
49
|
+
```python
|
|
50
|
+
FileConverter.surpac_to_dmf("input.sur", "output.dmf")
|
|
51
|
+
```
|
|
52
|
+
"""
|
|
53
|
+
return Dm.dmIO_SurpacToDmf(str(surpac_file), str(dmf_file))
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def dmf_to_surpac(dmf_file: Union[str, Path], surpac_file: Union[str, Path]) -> bool:
|
|
57
|
+
"""
|
|
58
|
+
DMF文件转Surpac格式
|
|
59
|
+
:param dmf_file: 输入DMF文件路径
|
|
60
|
+
:param surpac_file: 输出Surpac文件路径
|
|
61
|
+
:return: 是否转换成功
|
|
62
|
+
|
|
63
|
+
example:
|
|
64
|
+
```python
|
|
65
|
+
FileConverter.dmf_to_surpac("input.dmf", "output.sur")
|
|
66
|
+
```
|
|
67
|
+
"""
|
|
68
|
+
return Dm.dmIO_DmfToSurpac(str(dmf_file), str(surpac_file))
|
|
69
|
+
|
|
70
|
+
@staticmethod
|
|
71
|
+
def micromine_to_dmf(micromine_file: Union[str, Path], dmf_file: Union[str, Path]) -> bool:
|
|
72
|
+
"""
|
|
73
|
+
MicroMine文件转DMF格式
|
|
74
|
+
:param micromine_file: 输入MicroMine文件路径
|
|
75
|
+
:param dmf_file: 输出DMF文件路径
|
|
76
|
+
:return: 是否转换成功
|
|
77
|
+
|
|
78
|
+
example:
|
|
79
|
+
```python
|
|
80
|
+
FileConverter.micromine_to_dmf("input.mic", "output.dmf")
|
|
81
|
+
```
|
|
82
|
+
"""
|
|
83
|
+
return Dm.dmIO_MicroMineToDmf(str(micromine_file), str(dmf_file))
|
|
84
|
+
|
|
85
|
+
@staticmethod
|
|
86
|
+
def dmf_to_micromine(dmf_file: Union[str, Path], micromine_file: Union[str, Path]) -> bool:
|
|
87
|
+
"""
|
|
88
|
+
DMF文件转MicroMine格式
|
|
89
|
+
:param dmf_file: 输入DMF文件路径
|
|
90
|
+
:param micromine_file: 输出MicroMine文件路径
|
|
91
|
+
:return: 是否转换成功
|
|
92
|
+
|
|
93
|
+
example:
|
|
94
|
+
```python
|
|
95
|
+
FileConverter.dmf_to_micromine("input.dmf", "output.mic")
|
|
96
|
+
```
|
|
97
|
+
"""
|
|
98
|
+
return Dm.dmIO_DmfToMicroMine(str(dmf_file), str(micromine_file))
|
|
99
|
+
|
|
100
|
+
@staticmethod
|
|
101
|
+
def datamine_to_dmf(datamine_file: Union[str, Path], dmf_file: Union[str, Path]) -> bool:
|
|
102
|
+
"""
|
|
103
|
+
DataMine文件转DMF格式
|
|
104
|
+
:param datamine_file: 输入DataMine文件路径
|
|
105
|
+
:param dmf_file: 输出DMF文件路径
|
|
106
|
+
:return: 是否转换成功
|
|
107
|
+
|
|
108
|
+
example:
|
|
109
|
+
```python
|
|
110
|
+
FileConverter.datamine_to_dmf("input.dat", "output.dmf")
|
|
111
|
+
```
|
|
112
|
+
"""
|
|
113
|
+
return Dm.dmIO_DataMineToDmf(str(datamine_file), str(dmf_file))
|
|
114
|
+
|
|
115
|
+
@staticmethod
|
|
116
|
+
def mapgis_to_dmf(mapgis_file: Union[str, Path], dmf_file: Union[str, Path]) -> bool:
|
|
117
|
+
"""
|
|
118
|
+
MapGIS文件转DMF格式
|
|
119
|
+
:param mapgis_file: 输入MapGIS文件路径
|
|
120
|
+
:param dmf_file: 输出DMF文件路径
|
|
121
|
+
:return: 是否转换成功
|
|
122
|
+
|
|
123
|
+
example:
|
|
124
|
+
```python
|
|
125
|
+
FileConverter.mapgis_to_dmf("input.map", "output.dmf")
|
|
126
|
+
```
|
|
127
|
+
"""
|
|
128
|
+
return Dm.dmIO_MapGisToDmf(str(mapgis_file), str(dmf_file))
|
|
129
|
+
|
|
130
|
+
@staticmethod
|
|
131
|
+
def dmf_to_mapgis(dmf_file: Union[str, Path], mapgis_file: Union[str, Path]) -> bool:
|
|
132
|
+
"""
|
|
133
|
+
DMF文件转MapGIS格式
|
|
134
|
+
:param dmf_file: 输入DMF文件路径
|
|
135
|
+
:param mapgis_file: 输出MapGIS文件路径
|
|
136
|
+
:return: 是否转换成功
|
|
137
|
+
|
|
138
|
+
example:
|
|
139
|
+
```python
|
|
140
|
+
FileConverter.dmf_to_mapgis("input.dmf", "output.map")
|
|
141
|
+
```
|
|
142
|
+
"""
|
|
143
|
+
return Dm.dmIO_DmfToMapGis(str(dmf_file), str(mapgis_file))
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
from dataclasses import dataclass,field
|
|
2
|
+
from typing import Optional, Dict, Any,List
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class LayoutParam:
|
|
6
|
+
"""
|
|
7
|
+
包含原点坐标、法向量、坐标轴、厚度等核心布局参数
|
|
8
|
+
"""
|
|
9
|
+
# 原点坐标
|
|
10
|
+
origin_x: float # 原点X坐标
|
|
11
|
+
origin_y: float # 原点Y坐标
|
|
12
|
+
origin_z: float # 原点Z坐标
|
|
13
|
+
|
|
14
|
+
# 法向量
|
|
15
|
+
normal_x: float # 法向量X分量
|
|
16
|
+
normal_y: float # 法向量Y分量
|
|
17
|
+
normal_z: float # 法向量Z分量
|
|
18
|
+
|
|
19
|
+
# X轴向量
|
|
20
|
+
x_axis_x: float # X轴向量X分量
|
|
21
|
+
x_axis_y: float # X轴向量Y分量
|
|
22
|
+
x_axis_z: float # X轴向量Z分量
|
|
23
|
+
|
|
24
|
+
# Y轴向量
|
|
25
|
+
y_axis_x: float # Y轴向量X分量
|
|
26
|
+
y_axis_y: float # Y轴向量Y分量
|
|
27
|
+
y_axis_z: float # Y轴向量Z分量
|
|
28
|
+
|
|
29
|
+
# 厚度参数
|
|
30
|
+
forward_thickness: float # 正向厚度
|
|
31
|
+
reverse_thickness: float # 反向厚度
|
|
32
|
+
|
|
33
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
34
|
+
"""转换为字典,便于JSON序列化"""
|
|
35
|
+
return {
|
|
36
|
+
"origin_x": self.origin_x,
|
|
37
|
+
"origin_y": self.origin_y,
|
|
38
|
+
"origin_z": self.origin_z,
|
|
39
|
+
"normal_x": self.normal_x,
|
|
40
|
+
"normal_y": self.normal_y,
|
|
41
|
+
"normal_z": self.normal_z,
|
|
42
|
+
"x_axis_x": self.x_axis_x,
|
|
43
|
+
"x_axis_y": self.x_axis_y,
|
|
44
|
+
"x_axis_z": self.x_axis_z,
|
|
45
|
+
"y_axis_x": self.y_axis_x,
|
|
46
|
+
"y_axis_y": self.y_axis_y,
|
|
47
|
+
"y_axis_z": self.y_axis_z,
|
|
48
|
+
"forward_thickness": self.forward_thickness,
|
|
49
|
+
"reverse_thickness": self.reverse_thickness
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@dataclass
|
|
53
|
+
class BlockHatch:
|
|
54
|
+
angle:float
|
|
55
|
+
block_name:str
|
|
56
|
+
color:int
|
|
57
|
+
ratio:float
|
|
58
|
+
|
|
59
|
+
@dataclass
|
|
60
|
+
class PatternHatch:
|
|
61
|
+
angle:float
|
|
62
|
+
backcolor:int
|
|
63
|
+
color:int
|
|
64
|
+
pattern_name:str
|
|
65
|
+
ratio:float
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@dataclass
|
|
69
|
+
class ProjectHatchItem:
|
|
70
|
+
"""单个项目的 Hatch 参数"""
|
|
71
|
+
annotation_property: str
|
|
72
|
+
annotation_style: str
|
|
73
|
+
block_hatch: BlockHatch
|
|
74
|
+
pattern_hatch: PatternHatch
|
|
75
|
+
color: int = 0
|
|
76
|
+
line_style: str = "Continuous"
|
|
77
|
+
line_style_ratio: float = 1.0
|
|
78
|
+
line_weight: int = 6
|
|
79
|
+
name: str = ""
|
|
80
|
+
output_mode: int = 2
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass
|
|
84
|
+
class PlotProjectParam:
|
|
85
|
+
"""项目参数集合"""
|
|
86
|
+
enable: bool
|
|
87
|
+
file_project_param: List[ProjectHatchItem] = field(default_factory=list)
|
|
88
|
+
type: int = 0
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@dataclass
|
|
92
|
+
class PlotBlockParam:
|
|
93
|
+
"""块参数"""
|
|
94
|
+
display_mode: int
|
|
95
|
+
enable: bool
|
|
96
|
+
shrinkage_coefficient: float
|
|
97
|
+
|
|
98
|
+
@dataclass
|
|
99
|
+
class AnnotatinoStyleParam:
|
|
100
|
+
annotation_position: float = 0.0
|
|
101
|
+
style_bottom: str = ""
|
|
102
|
+
style_left: str = ""
|
|
103
|
+
style_right: str = ""
|
|
104
|
+
style_top: str = ""
|
|
105
|
+
text_size: float = 0.5
|
|
106
|
+
|
|
107
|
+
@dataclass
|
|
108
|
+
class PlotDrillParam:
|
|
109
|
+
"""钻孔参数"""
|
|
110
|
+
AnnotatinoStyle: AnnotatinoStyleParam
|
|
111
|
+
annotation_collar_triangle: bool = False
|
|
112
|
+
annotation_cutting_point_circle: bool = False
|
|
113
|
+
annotation_drill_name: bool = False
|
|
114
|
+
annotation_hole_bottom_line: bool = False
|
|
115
|
+
annotation_position: float = 0.0
|
|
116
|
+
annotation_text_height: float = 0.0
|
|
117
|
+
collar_triangle_ratio: float = 0.0
|
|
118
|
+
cutting_into_point: bool = False
|
|
119
|
+
cutting_point_circle: float = 0.0
|
|
120
|
+
draw_sample_tray: bool = False
|
|
121
|
+
enable: bool = True
|
|
122
|
+
gram_per_ton_field_set: str = ""
|
|
123
|
+
have_intersetion_projection_track: bool = False
|
|
124
|
+
hole_bottom_line_length: float = 0.0
|
|
125
|
+
is_multiple_table: bool = False
|
|
126
|
+
negative_thickness: float = 20.0
|
|
127
|
+
no_intersetion_projection_track: bool = False
|
|
128
|
+
other_field_set: str = ""
|
|
129
|
+
output_drill_section: bool = False
|
|
130
|
+
output_param_table: bool = False
|
|
131
|
+
output_sample_info_table: bool = False
|
|
132
|
+
percentage_field_set: str = ""
|
|
133
|
+
positive_thickness: float = 20.0
|
|
134
|
+
reserve_drill_track_outside_layout: bool = False
|
|
135
|
+
sample_tray_content: str = ""
|
|
136
|
+
sample_tray_interval: float = 0.0
|
|
137
|
+
sample_tray_text_height: float = 0.0
|
|
138
|
+
sample_tray_width: float = 0.0
|
|
139
|
+
|
|
140
|
+
@dataclass
|
|
141
|
+
class PlotGirdParam:
|
|
142
|
+
"""网格参数"""
|
|
143
|
+
check_x: bool
|
|
144
|
+
check_y: bool
|
|
145
|
+
check_z: bool
|
|
146
|
+
color: int
|
|
147
|
+
enable: bool
|
|
148
|
+
mode: int
|
|
149
|
+
separated: bool
|
|
150
|
+
text_height: float
|
|
151
|
+
x: float = 50.0
|
|
152
|
+
y: float = 50.0
|
|
153
|
+
z: float = 50.0
|
|
154
|
+
transverse: bool = False
|
|
155
|
+
|
|
156
|
+
@dataclass
|
|
157
|
+
class SetupParams:
|
|
158
|
+
"""主配置参数类"""
|
|
159
|
+
current: bool
|
|
160
|
+
name: str
|
|
161
|
+
plot_block_param: PlotBlockParam
|
|
162
|
+
plot_drill_param: PlotDrillParam
|
|
163
|
+
plot_gird_param: PlotGirdParam
|
|
164
|
+
plot_hatch_param: Dict[str, Any] = field(default_factory=lambda: {"enable": False})
|
|
165
|
+
plot_project_param: PlotProjectParam = field(default_factory=PlotProjectParam)
|
|
166
|
+
uuid: str = ""
|
|
167
|
+
|
|
168
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
169
|
+
"""转换为嵌套字典,支持JSON序列化"""
|
|
170
|
+
def dc_to_dict(obj):
|
|
171
|
+
if isinstance(obj, (int, float, str, bool)):
|
|
172
|
+
return obj
|
|
173
|
+
elif hasattr(obj, '__dataclass_fields__'):
|
|
174
|
+
return {k: dc_to_dict(getattr(obj, k)) for k in obj.__dataclass_fields__}
|
|
175
|
+
elif isinstance(obj, list):
|
|
176
|
+
return [dc_to_dict(item) for item in obj]
|
|
177
|
+
elif isinstance(obj, dict):
|
|
178
|
+
return {k: dc_to_dict(v) for k, v in obj.items()}
|
|
179
|
+
return obj
|
|
180
|
+
return dc_to_dict(self)
|