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.
Files changed (135) hide show
  1. dimine_python_sdk/__init__.py +13 -0
  2. dimine_python_sdk/conn/__init__.py +5 -0
  3. dimine_python_sdk/conn/base_conn_client.py +167 -0
  4. dimine_python_sdk/conn/conn_client.py +382 -0
  5. dimine_python_sdk/docs/guides/data_edit.md +306 -0
  6. dimine_python_sdk/docs/guides/data_get.md +266 -0
  7. dimine_python_sdk/docs/guides/data_types.md +152 -0
  8. dimine_python_sdk/docs/guides/features.md +271 -0
  9. dimine_python_sdk/docs/guides/io.md +157 -0
  10. dimine_python_sdk/docs/index.md +41 -0
  11. dimine_python_sdk/docs/quickstart.md +45 -0
  12. dimine_python_sdk/docs/reference/SUMMARY.md +19 -0
  13. dimine_python_sdk/docs/reference/conn/base_conn_client.md +3 -0
  14. dimine_python_sdk/docs/reference/conn/conn_client.md +3 -0
  15. dimine_python_sdk/docs/reference/lib/algorithm/model_func.md +3 -0
  16. dimine_python_sdk/docs/reference/lib/io/file_conversion.md +3 -0
  17. dimine_python_sdk/docs/reference/lib/io/models.md +3 -0
  18. dimine_python_sdk/docs/reference/lib/io/project_plotting.md +3 -0
  19. dimine_python_sdk/docs/reference/lib/prospecting/block_data.md +3 -0
  20. dimine_python_sdk/docs/reference/lib/prospecting/drill_db.md +3 -0
  21. dimine_python_sdk/docs/reference/lib/prospecting/models.md +3 -0
  22. dimine_python_sdk/docs/reference/lib/prospecting/valuation.md +3 -0
  23. dimine_python_sdk/docs/reference/lib/types/entity.md +3 -0
  24. dimine_python_sdk/docs/reference/lib/types/line.md +3 -0
  25. dimine_python_sdk/docs/reference/lib/types/point.md +3 -0
  26. dimine_python_sdk/docs/reference/logger.md +3 -0
  27. dimine_python_sdk/docs/reference/models/conn.md +3 -0
  28. dimine_python_sdk/docs/reference/models/errors.md +3 -0
  29. dimine_python_sdk/docs/reference/models/types.md +3 -0
  30. dimine_python_sdk/docs/summary.md +6 -0
  31. dimine_python_sdk/lib/__init__.py +20 -0
  32. dimine_python_sdk/lib/algorithm/__init__.py +1 -0
  33. dimine_python_sdk/lib/algorithm/model_func.py +219 -0
  34. dimine_python_sdk/lib/exploitation/__init__.py +0 -0
  35. dimine_python_sdk/lib/io/__init__.py +2 -0
  36. dimine_python_sdk/lib/io/file_conversion.py +143 -0
  37. dimine_python_sdk/lib/io/models.py +180 -0
  38. dimine_python_sdk/lib/io/project_plotting.py +40 -0
  39. dimine_python_sdk/lib/prospecting/__init__.py +3 -0
  40. dimine_python_sdk/lib/prospecting/block_data.py +289 -0
  41. dimine_python_sdk/lib/prospecting/drill_db.py +333 -0
  42. dimine_python_sdk/lib/prospecting/models.py +276 -0
  43. dimine_python_sdk/lib/prospecting/valuation.py +113 -0
  44. dimine_python_sdk/lib/types/__init__.py +4 -0
  45. dimine_python_sdk/lib/types/entity.py +957 -0
  46. dimine_python_sdk/lib/types/line.py +188 -0
  47. dimine_python_sdk/lib/types/point.py +695 -0
  48. dimine_python_sdk/logger.py +7 -0
  49. dimine_python_sdk/models/__init__.py +3 -0
  50. dimine_python_sdk/models/conn.py +53 -0
  51. dimine_python_sdk/models/errors.py +4 -0
  52. dimine_python_sdk/models/types.py +131 -0
  53. dimine_python_sdk/site/404.html +671 -0
  54. dimine_python_sdk/site/assets/_mkdocstrings.css +237 -0
  55. dimine_python_sdk/site/assets/images/favicon.png +0 -0
  56. dimine_python_sdk/site/assets/javascripts/bundle.79ae519e.min.js +16 -0
  57. dimine_python_sdk/site/assets/javascripts/bundle.79ae519e.min.js.map +7 -0
  58. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ar.min.js +1 -0
  59. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.da.min.js +18 -0
  60. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.de.min.js +18 -0
  61. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.du.min.js +18 -0
  62. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.el.min.js +1 -0
  63. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.es.min.js +18 -0
  64. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.fi.min.js +18 -0
  65. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.fr.min.js +18 -0
  66. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.he.min.js +1 -0
  67. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.hi.min.js +1 -0
  68. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.hu.min.js +18 -0
  69. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.hy.min.js +1 -0
  70. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.it.min.js +18 -0
  71. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ja.min.js +1 -0
  72. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.jp.min.js +1 -0
  73. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.kn.min.js +1 -0
  74. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ko.min.js +1 -0
  75. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.multi.min.js +1 -0
  76. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.nl.min.js +18 -0
  77. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.no.min.js +18 -0
  78. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.pt.min.js +18 -0
  79. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ro.min.js +18 -0
  80. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ru.min.js +18 -0
  81. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.sa.min.js +1 -0
  82. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +1 -0
  83. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.sv.min.js +18 -0
  84. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.ta.min.js +1 -0
  85. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.te.min.js +1 -0
  86. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.th.min.js +1 -0
  87. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.tr.min.js +18 -0
  88. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.vi.min.js +1 -0
  89. dimine_python_sdk/site/assets/javascripts/lunr/min/lunr.zh.min.js +1 -0
  90. dimine_python_sdk/site/assets/javascripts/lunr/tinyseg.js +206 -0
  91. dimine_python_sdk/site/assets/javascripts/lunr/wordcut.js +6708 -0
  92. dimine_python_sdk/site/assets/javascripts/workers/search.2c215733.min.js +42 -0
  93. dimine_python_sdk/site/assets/javascripts/workers/search.2c215733.min.js.map +7 -0
  94. dimine_python_sdk/site/assets/stylesheets/main.484c7ddc.min.css +1 -0
  95. dimine_python_sdk/site/assets/stylesheets/main.484c7ddc.min.css.map +1 -0
  96. dimine_python_sdk/site/assets/stylesheets/palette.ab4e12ef.min.css +1 -0
  97. dimine_python_sdk/site/assets/stylesheets/palette.ab4e12ef.min.css.map +1 -0
  98. dimine_python_sdk/site/guides/data_edit.html +1251 -0
  99. dimine_python_sdk/site/guides/data_get.html +1206 -0
  100. dimine_python_sdk/site/guides/data_types.html +1529 -0
  101. dimine_python_sdk/site/guides/features.html +1217 -0
  102. dimine_python_sdk/site/guides/io.html +1025 -0
  103. dimine_python_sdk/site/index.html +849 -0
  104. dimine_python_sdk/site/objects.inv +0 -0
  105. dimine_python_sdk/site/quickstart.html +859 -0
  106. dimine_python_sdk/site/reference/SUMMARY.html +729 -0
  107. dimine_python_sdk/site/reference/conn/base_conn_client.html +1295 -0
  108. dimine_python_sdk/site/reference/conn/conn_client.html +3551 -0
  109. dimine_python_sdk/site/reference/lib/algorithm/model_func.html +2162 -0
  110. dimine_python_sdk/site/reference/lib/io/file_conversion.html +1725 -0
  111. dimine_python_sdk/site/reference/lib/io/models.html +1625 -0
  112. dimine_python_sdk/site/reference/lib/io/project_plotting.html +984 -0
  113. dimine_python_sdk/site/reference/lib/prospecting/block_data.html +2455 -0
  114. dimine_python_sdk/site/reference/lib/prospecting/drill_db.html +2836 -0
  115. dimine_python_sdk/site/reference/lib/prospecting/models.html +2309 -0
  116. dimine_python_sdk/site/reference/lib/prospecting/valuation.html +1373 -0
  117. dimine_python_sdk/site/reference/lib/types/entity.html +6728 -0
  118. dimine_python_sdk/site/reference/lib/types/line.html +1985 -0
  119. dimine_python_sdk/site/reference/lib/types/point.html +3672 -0
  120. dimine_python_sdk/site/reference/logger.html +751 -0
  121. dimine_python_sdk/site/reference/models/conn.html +751 -0
  122. dimine_python_sdk/site/reference/models/errors.html +802 -0
  123. dimine_python_sdk/site/reference/models/types.html +1679 -0
  124. dimine_python_sdk/site/search/search_index.json +1 -0
  125. dimine_python_sdk/site/sitemap.xml +107 -0
  126. dimine_python_sdk/site/sitemap.xml.gz +0 -0
  127. dimine_python_sdk/site/summary.html +697 -0
  128. dimine_python_sdk-0.1.8.dist-info/METADATA +15 -0
  129. dimine_python_sdk-0.1.8.dist-info/RECORD +135 -0
  130. dimine_python_sdk-0.1.8.dist-info/WHEEL +5 -0
  131. dimine_python_sdk-0.1.8.dist-info/top_level.txt +2 -0
  132. tests/conn_test.py +250 -0
  133. tests/test_base_type.py +143 -0
  134. tests/ws_client.py +60 -0
  135. tests/ws_server.py +271 -0
@@ -0,0 +1,695 @@
1
+ import DmPyBindInterface as Dm
2
+
3
+ #点
4
+ class Point:
5
+ """二次封装Point类"""
6
+ def __init__(self, a: int = 0):
7
+ """
8
+ 构造函数
9
+ :param a: 初始化x分量的值,默认0
10
+ """
11
+ self._obj = Dm.Point(a)
12
+
13
+ # ---------------------- 核心方法封装 ----------------------
14
+ def get(self) -> int:
15
+ """
16
+ 获取x分量的值
17
+ :return: x分量的整数值
18
+ """
19
+ return self._obj.get()
20
+
21
+ def set(self, a: int) -> None:
22
+ """
23
+ 设置x分量的值
24
+ :param a: 新的x分量整数值
25
+ """
26
+ self._obj.set(a)
27
+
28
+
29
+ class DmDPoint:
30
+ """双精度点"""
31
+
32
+ def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0):
33
+ """
34
+ 构造函数
35
+ :param x: 向量x分量,默认0.0
36
+ :param y: 向量y分量,默认0.0
37
+ :param z: 向量z分量,默认0.0
38
+ """
39
+ self._obj = Dm.dmDPoint(x, y, z)
40
+
41
+ @classmethod
42
+ def _from_obj(cls, obj):
43
+ """
44
+ :param obj: 源dmDPoint对象
45
+ :return: DmDPoint实例
46
+ """
47
+ instance = cls()
48
+ instance._obj = obj
49
+ return instance
50
+
51
+
52
+ # ---------------------- 分量属性封装 ----------------------
53
+ @property
54
+ def x(self) -> float:
55
+ return self._obj.x
56
+
57
+ @x.setter
58
+ def x(self, value: float):
59
+ self._obj.x = float(value)
60
+
61
+ @property
62
+ def y(self) -> float:
63
+ return self._obj.y
64
+
65
+ @y.setter
66
+ def y(self, value: float):
67
+ self._obj.y = float(value)
68
+
69
+ @property
70
+ def z(self) -> float:
71
+ return self._obj.z
72
+
73
+ @z.setter
74
+ def z(self, value: float):
75
+ self._obj.z = float(value)
76
+
77
+ # ---------------------- 基础运算符 ----------------------
78
+ def __add__(self, other: "DmDPoint") -> "DmDPoint":
79
+ """
80
+ 向量加法
81
+ :param other: 待相加的DmDPoint实例
82
+ :return: 相加后的新DmDPoint实例
83
+ :raise TypeError: 非DmDPoint实例时抛出
84
+ """
85
+ if not isinstance(other, DmDPoint):
86
+ raise TypeError(f"仅支持DmDPoint实例相加,当前为{type(other)}")
87
+ res = DmDPoint()
88
+ res._obj = self._obj + other._obj
89
+ return res
90
+
91
+ def __sub__(self, other: "DmDPoint") -> "DmDPoint":
92
+ """
93
+ 向量减法
94
+ :param other: 待相减的DmDPoint实例
95
+ :return: 相减后的新DmDPoint实例
96
+ :raise TypeError: 非DmDPoint实例时抛出
97
+ """
98
+ if not isinstance(other, DmDPoint):
99
+ raise TypeError(f"仅支持DmDPoint实例相减,当前为{type(other)}")
100
+ res = DmDPoint()
101
+ res._obj = self._obj - other._obj
102
+ return res
103
+
104
+ def __mul__(self, scalar: (int, float)) -> "DmDPoint":
105
+ """
106
+ 向量标量乘法
107
+ :param scalar: 相乘的标量(int/float)
108
+ :return: 相乘后的新DmDPoint实例
109
+ :raise TypeError: 非标量类型时抛出
110
+ """
111
+ if not isinstance(scalar, (int, float)):
112
+ raise TypeError(f"仅支持与标量(int/float)相乘,当前为{type(scalar)}")
113
+ res = DmDPoint()
114
+ res._obj = self._obj * scalar
115
+ return res
116
+
117
+ def __truediv__(self, scalar: (int, float)) -> "DmDPoint":
118
+ """
119
+ 向量标量除法
120
+ :param scalar: 相除的标量(int/float)
121
+ :return: 相除后的新DmDPoint实例
122
+ :raise TypeError: 非标量类型时抛出
123
+ :raise ZeroDivisionError: 标量为0时抛出
124
+ """
125
+ if not isinstance(scalar, (int, float)):
126
+ raise TypeError(f"仅支持与标量(int/float)相除,当前为{type(scalar)}")
127
+ if scalar == 0:
128
+ raise ZeroDivisionError("向量标量除法,标量不能为0")
129
+ res = DmDPoint()
130
+ res._obj = self._obj / scalar
131
+ return res
132
+
133
+ # ---------------------- 复合赋值运算符 ----------------------
134
+ def __iadd__(self, other: "DmDPoint") -> "DmDPoint":
135
+ """
136
+ 向量加法赋值(原地修改)
137
+ :param other: 待相加的DmDPoint实例
138
+ :return: 自身实例(支持链式调用)
139
+ :raise TypeError: 非DmDPoint实例时抛出
140
+ """
141
+ if not isinstance(other, DmDPoint):
142
+ raise TypeError(f"仅支持DmDPoint实例相加赋值,当前为{type(other)}")
143
+ self._obj += other._obj
144
+ return self
145
+
146
+ def __isub__(self, other: "DmDPoint") -> "DmDPoint":
147
+ """
148
+ 向量减法赋值(原地修改)
149
+ :param other: 待相减的DmDPoint实例
150
+ :return: 自身实例(支持链式调用)
151
+ :raise TypeError: 非DmDPoint实例时抛出
152
+ """
153
+ if not isinstance(other, DmDPoint):
154
+ raise TypeError(f"仅支持DmDPoint实例相减赋值,当前为{type(other)}")
155
+ self._obj -= other._obj
156
+ return self
157
+
158
+ def __imul__(self, scalar: (int, float)) -> "DmDPoint":
159
+ """
160
+ 向量标量乘法赋值(原地修改)
161
+ :param scalar: 相乘的标量(int/float)
162
+ :return: 自身实例(支持链式调用)
163
+ :raise TypeError: 非标量类型时抛出
164
+ """
165
+ if not isinstance(scalar, (int, float)):
166
+ raise TypeError(f"仅支持与标量(int/float)相乘赋值,当前为{type(scalar)}")
167
+ self._obj *= scalar
168
+ return self
169
+
170
+ def __itruediv__(self, scalar: (int, float)) -> "DmDPoint":
171
+ """
172
+ 向量标量除法赋值(原地修改)
173
+ :param scalar: 相除的标量(int/float)
174
+ :return: 自身实例(支持链式调用)
175
+ :raise TypeError: 非标量类型时抛出
176
+ :raise ZeroDivisionError: 标量为0时抛出
177
+ """
178
+ if not isinstance(scalar, (int, float)):
179
+ raise TypeError(f"仅支持与标量(int/float)相除赋值,当前为{type(scalar)}")
180
+ if scalar == 0:
181
+ raise ZeroDivisionError("向量标量除法赋值,标量不能为0")
182
+ self._obj /= scalar
183
+ return self
184
+
185
+ # ---------------------- 单目/比较运算符 ----------------------
186
+ def __neg__(self) -> "DmDPoint":
187
+ """
188
+ 负号运算符(取反向量)
189
+ :return: 取反后的新DmDPoint实例
190
+ """
191
+ res = DmDPoint()
192
+ res._obj = -self._obj
193
+ return res
194
+
195
+ def __eq__(self, other: "DmDPoint") -> bool:
196
+ """
197
+ 等于比较运算符
198
+ :param other: 待比较的DmDPoint实例
199
+ :return: 相等返回True,否则返回False;非DmDPoint实例直接返回False
200
+ """
201
+ if not isinstance(other, DmDPoint):
202
+ return False
203
+ return self._obj == other._obj
204
+
205
+ def __ne__(self, other: "DmDPoint") -> bool:
206
+ """
207
+ 不等于比较运算符
208
+ :param other: 待比较的DmDPoint实例
209
+ :return: 不相等返回True,否则返回False;非DmDPoint实例直接返回True
210
+ """
211
+ if not isinstance(other, DmDPoint):
212
+ return True
213
+ return self._obj != other._obj
214
+
215
+ # ---------------------- 核心工具方法 ----------------------
216
+ def __getitem__(self, idx: int) -> float:
217
+ """
218
+ 索引访问分量(0=x,1=y,2=z)
219
+ :param idx: 索引值(仅支持0/1/2)
220
+ :return: 对应索引的分量值(float)
221
+ :raise IndexError: 索引非整数/超出0-2范围时抛出
222
+ """
223
+ if not isinstance(idx, int) or idx < 0 or idx >= 3:
224
+ raise IndexError("向量索引仅支持0(x)、1(y)、2(z),超出范围")
225
+ return self._obj[idx]
226
+
227
+ def is_zero_length(self, tol: float = 1e-10) -> bool:
228
+ """
229
+ 判断是否为零向量(考虑浮点精度误差)
230
+ :param tol: 浮点容差阈值,默认1e-10(值越小精度要求越高)
231
+ :return: 向量长度接近0返回True,否则返回False
232
+
233
+ example:
234
+ ```python
235
+ pt = DmDPoint(0, 0, 0)
236
+ print(pt.is_zero_length())
237
+ ```
238
+ """
239
+ return self._obj.IsZeroLength(tol)
240
+
241
+ def dot_product(self, other: "DmDPoint") -> float:
242
+ """
243
+ 计算两个向量的点积(数量积)
244
+ :param other: 待计算点积的DmDPoint实例
245
+ :return: 点积结果(float)
246
+ :raise TypeError: 非DmDPoint实例时抛出
247
+
248
+ example:
249
+ ```python
250
+ pt1 = DmDPoint(1, 2, 3)
251
+ pt2 = DmDPoint(4, 5, 6)
252
+ dot = pt1.dot_product(pt2)
253
+ print(dot)
254
+ ```
255
+ """
256
+ if not isinstance(other, DmDPoint):
257
+ raise TypeError(f"仅支持与DmDPoint实例计算点积,当前为{type(other)}")
258
+ return self._obj.DotProduct(other._obj)
259
+
260
+ def cross_product(self, other: "DmDPoint") -> "DmDPoint":
261
+ """
262
+ 计算两个向量的叉积(向量积)
263
+ :param other: 待计算叉积的DmDPoint实例
264
+ :return: 叉积结果的新DmDPoint实例
265
+ :raise TypeError: 非DmDPoint实例时抛出
266
+
267
+ example:
268
+ ```python
269
+ pt1 = DmDPoint(1, 2, 3)
270
+ pt2 = DmDPoint(4, 5, 6)
271
+ cross = pt1.cross_product(pt2)
272
+ print(cross)
273
+ ```
274
+ """
275
+ if not isinstance(other, DmDPoint):
276
+ raise TypeError(f"仅支持与DmDPoint实例计算叉积,当前为{type(other)}")
277
+ res = DmDPoint()
278
+ res._obj = self._obj.CrossProduct(other._obj)
279
+ return res
280
+
281
+ def norm(self) -> float:
282
+ """
283
+ 计算向量的模长(长度)
284
+ :return: 向量模长结果(float)
285
+
286
+ example:
287
+ ```python
288
+ pt = DmDPoint(3, 4, 0)
289
+ print(pt.norm())
290
+ ```
291
+ """
292
+ return self._obj.Norm()
293
+
294
+ def normalize(self) -> "DmDPoint":
295
+ """
296
+ 向量归一化(原地修改,转为单位向量)
297
+ :return: 自身实例
298
+
299
+ example:
300
+ ```python
301
+ pt = DmDPoint(3, 4, 0)
302
+ pt.normalize()
303
+ print(pt)
304
+ ```
305
+ """
306
+ self._obj.Normalize()
307
+ return self
308
+
309
+ def set(self, x: float, y: float, z: float) -> "DmDPoint":
310
+ """
311
+ 一次性设置向量x/y/z分量(原地修改)
312
+ :param x: 新的x分量值(float)
313
+ :param y: 新的y分量值(float)
314
+ :param z: 新的z分量值(float)
315
+ :return: 自身实例(支持链式调用)
316
+
317
+ example:
318
+ ```python
319
+ pt = DmDPoint()
320
+ pt.set(1, 2, 3)
321
+ print(pt) # 输出: (1.0, 2.0, 3.0)
322
+ ```
323
+ """
324
+ self._obj.Set(float(x), float(y), float(z))
325
+ return self
326
+
327
+ # ---------------------- 字符串表示 ----------------------
328
+ def __repr__(self) -> str:
329
+ """
330
+ 字符串表示
331
+ :return: 向量的标准字符串表示
332
+ """
333
+ return self._obj.__repr__()
334
+
335
+ def __str__(self) -> str:
336
+ """
337
+ 打印字符串,与__repr__保持一致,确保输出格式统一
338
+ :return: 向量的打印字符串表示
339
+ """
340
+ return self._obj.__repr__()
341
+
342
+ # class DmSPoint:
343
+ # """单精度点类"""
344
+ #
345
+ # def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0):
346
+ # """
347
+ # 构造函数
348
+ # :param x: 向量x分量,默认0.0
349
+ # :param y: 向量y分量,默认0.0
350
+ # :param z: 向量z分量,默认0.0
351
+ # """
352
+ # self._obj = Dm.dmSPoint(x, y, z)
353
+ #
354
+ # # ---------------------- 分量属性封装 ----------------------
355
+ # @property
356
+ # def x(self) -> float:
357
+ # return self._obj.x
358
+ #
359
+ # @x.setter
360
+ # def x(self, value: float):
361
+ # self._obj.x = float(value)
362
+ #
363
+ # @property
364
+ # def y(self) -> float:
365
+ # return self._obj.y
366
+ #
367
+ # @y.setter
368
+ # def y(self, value: float):
369
+ # self._obj.y = float(value)
370
+ #
371
+ # @property
372
+ # def z(self) -> float:
373
+ # return self._obj.z
374
+ #
375
+ # @z.setter
376
+ # def z(self, value: float):
377
+ # self._obj.z = float(value)
378
+ #
379
+ # # ---------------------- 基础运算符 ----------------------
380
+ # def __add__(self, other: "DmSPoint") -> "DmSPoint":
381
+ # """
382
+ # 向量加法
383
+ # :param other: 待相加的DmSPoint实例
384
+ # :return: 相加后的新DmSPoint实例
385
+ # :raise TypeError: 非DmSPoint实例时抛出
386
+ # """
387
+ # if not isinstance(other, DmSPoint):
388
+ # raise TypeError(f"仅支持DmSPoint实例相加,当前为{type(other)}")
389
+ # res = DmSPoint()
390
+ # res._obj = self._obj + other._obj
391
+ # return res
392
+ #
393
+ # def __sub__(self, other: "DmSPoint") -> "DmSPoint":
394
+ # """
395
+ # 向量减法
396
+ # :param other: 待相减的DmSPoint实例
397
+ # :return: 相减后的新DmSPoint实例
398
+ # :raise TypeError: 非DmSPoint实例时抛出
399
+ # """
400
+ # if not isinstance(other, DmSPoint):
401
+ # raise TypeError(f"仅支持DmSPoint实例相减,当前为{type(other)}")
402
+ # res = DmSPoint()
403
+ # res._obj = self._obj - other._obj
404
+ # return res
405
+ #
406
+ # def __mul__(self, scalar: (int, float)) -> "DmSPoint":
407
+ # """
408
+ # 向量标量乘法
409
+ # :param scalar: 相乘的标量(int/float)
410
+ # :return: 相乘后的新DmSPoint实例
411
+ # :raise TypeError: 非标量类型时抛出
412
+ # """
413
+ # if not isinstance(scalar, (int, float)):
414
+ # raise TypeError(f"仅支持与标量(int/float)相乘,当前为{type(scalar)}")
415
+ # res = DmSPoint()
416
+ # res._obj = self._obj * scalar
417
+ # return res
418
+ #
419
+ # def __truediv__(self, scalar: (int, float)) -> "DmSPoint":
420
+ # """
421
+ # 向量标量除法
422
+ # :param scalar: 相除的标量(int/float)
423
+ # :return: 相除后的新DmSPoint实例
424
+ # :raise TypeError: 非标量类型时抛出
425
+ # :raise ZeroDivisionError: 标量为0时抛出
426
+ # """
427
+ # if not isinstance(scalar, (int, float)):
428
+ # raise TypeError(f"仅支持与标量(int/float)相除,当前为{type(scalar)}")
429
+ # if scalar == 0:
430
+ # raise ZeroDivisionError("向量标量除法,标量不能为0")
431
+ # res = DmSPoint()
432
+ # res._obj = self._obj / scalar
433
+ # return res
434
+ #
435
+ # # ---------------------- 复合赋值运算符 ----------------------
436
+ # def __iadd__(self, other: "DmSPoint") -> "DmSPoint":
437
+ # """
438
+ # 向量加法赋值
439
+ # :param other: 待相加的DmSPoint实例
440
+ # :return: 自身实例(支持链式调用)
441
+ # :raise TypeError: 非DmSPoint实例时抛出
442
+ # """
443
+ # if not isinstance(other, DmSPoint):
444
+ # raise TypeError(f"仅支持DmSPoint实例相加赋值,当前为{type(other)}")
445
+ # self._obj += other._obj
446
+ # return self
447
+ #
448
+ # def __isub__(self, other: "DmSPoint") -> "DmSPoint":
449
+ # """
450
+ # 向量减法赋值
451
+ # :param other: 待相减的DmSPoint实例
452
+ # :return: 自身实例(支持链式调用)
453
+ # :raise TypeError: 非DmSPoint实例时抛出
454
+ # """
455
+ # if not isinstance(other, DmSPoint):
456
+ # raise TypeError(f"仅支持DmSPoint实例相减赋值,当前为{type(other)}")
457
+ # self._obj -= other._obj
458
+ # return self
459
+ #
460
+ # def __imul__(self, scalar: (int, float)) -> "DmSPoint":
461
+ # """
462
+ # 向量标量乘法赋值
463
+ # :param scalar: 相乘的标量(int/float)
464
+ # :return: 自身实例(支持链式调用)
465
+ # :raise TypeError: 非标量类型时抛出
466
+ # """
467
+ # if not isinstance(scalar, (int, float)):
468
+ # raise TypeError(f"仅支持与标量(int/float)相乘赋值,当前为{type(scalar)}")
469
+ # self._obj *= scalar
470
+ # return self
471
+ #
472
+ # def __itruediv__(self, scalar: (int, float)) -> "DmSPoint":
473
+ # """
474
+ # 向量标量除法赋值
475
+ # :param scalar: 相除的标量(int/float)
476
+ # :return: 自身实例(支持链式调用)
477
+ # :raise TypeError: 非标量类型时抛出
478
+ # :raise ZeroDivisionError: 标量为0时抛出
479
+ # """
480
+ # if not isinstance(scalar, (int, float)):
481
+ # raise TypeError(f"仅支持与标量(int/float)相除赋值,当前为{type(scalar)}")
482
+ # if scalar == 0:
483
+ # raise ZeroDivisionError("向量标量除法赋值,标量不能为0")
484
+ # self._obj /= scalar
485
+ # return self
486
+ #
487
+ # # ---------------------- 单目/比较运算符 ----------------------
488
+ # def __neg__(self) -> "DmSPoint":
489
+ # """
490
+ # 负号运算符(取反向量)
491
+ # :return: 取反后的新DmSPoint实例
492
+ # """
493
+ # res = DmSPoint()
494
+ # res._obj = -self._obj
495
+ # return res
496
+ #
497
+ # def __eq__(self, other: "DmSPoint") -> bool:
498
+ # """
499
+ # 等于比较运算符
500
+ # :param other: 待比较的DmSPoint实例
501
+ # :return: 分量均在容差内相等返回True,否则返回False
502
+ # """
503
+ # if not isinstance(other, DmSPoint):
504
+ # return False
505
+ # return self._obj == other._obj
506
+ #
507
+ # def __ne__(self, other: "DmSPoint") -> bool:
508
+ # """
509
+ # 不等于比较运算符
510
+ # :param other: 待比较的DmSPoint实例
511
+ # :return: 任意分量在容差外不等返回True,否则返回False
512
+ # """
513
+ # if not isinstance(other, DmSPoint):
514
+ # return True
515
+ # return self._obj != other._obj
516
+ #
517
+ # # ---------------------- 核心工具方法(小写+下划线规范) ----------------------
518
+ # def dot_product(self, other: "DmSPoint") -> float:
519
+ # """
520
+ # 计算两个向量的点积(数量积)
521
+ # :param other: 待计算点积的DmSPoint实例
522
+ # :return: 点积结果(float)
523
+ # :raise TypeError: 非DmSPoint实例时抛出
524
+ # """
525
+ # if not isinstance(other, DmSPoint):
526
+ # raise TypeError(f"仅支持与DmSPoint实例计算点积,当前为{type(other)}")
527
+ # return self._obj.DotProduct(other._obj)
528
+ #
529
+ # def cross_product(self, other: "DmSPoint") -> "DmSPoint":
530
+ # """
531
+ # 计算两个向量的叉积(向量积)
532
+ # :param other: 待计算叉积的DmSPoint实例
533
+ # :return: 叉积结果的新DmSPoint实例
534
+ # :raise TypeError: 非DmSPoint实例时抛出
535
+ # """
536
+ # if not isinstance(other, DmSPoint):
537
+ # raise TypeError(f"仅支持与DmSPoint实例计算叉积,当前为{type(other)}")
538
+ # res = DmSPoint()
539
+ # res._obj = self._obj.CrossProduct(other._obj)
540
+ # return res
541
+ #
542
+ # def norm(self) -> float:
543
+ # """
544
+ # 计算向量的模长(长度的平方开根)
545
+ # :return: 向量模长结果(float)
546
+ # """
547
+ # return self._obj.Norm()
548
+ #
549
+ # def __getitem__(self, idx: int) -> float:
550
+ # """
551
+ # 索引访问分量(0=x,1=y,2=z)
552
+ # :param idx: 索引值(仅支持0/1/2)
553
+ # :return: 对应索引的分量值(float)
554
+ # :raise IndexError: 索引非整数/超出0-2范围时抛出
555
+ # """
556
+ # if not isinstance(idx, int) or idx < 0 or idx >= 3:
557
+ # raise IndexError("向量索引仅支持0(x)、1(y)、2(z),超出范围")
558
+ # return self._obj[idx]
559
+ #
560
+ # def is_zero_length(self, tol: float = 1e-10) -> bool:
561
+ # """
562
+ # 判断是否为零向量(考虑浮点精度误差)
563
+ # :param tol: 浮点容差阈值,默认1e-10(值越小精度要求越高)
564
+ # :return: 向量长度接近0返回True,否则返回False
565
+ # """
566
+ # return self._obj.IsZeroLength(tol)
567
+ #
568
+ # def normalize(self) -> "DmSPoint":
569
+ # """
570
+ # 向量归一化(原地修改,转为单位向量)
571
+ # :return: 自身实例(支持链式调用)
572
+ # """
573
+ # self._obj.Normalize()
574
+ # return self
575
+ #
576
+ # # ---------------------- 字符串表示 ----------------------
577
+ # def __repr__(self) -> str:
578
+ # """
579
+ # 字符串表示
580
+ # :return: 向量的标准字符串表示
581
+ # """
582
+ # return self._obj.__repr__()
583
+ #
584
+ # def __str__(self) -> str:
585
+ # """
586
+ # 打印字符串,与__repr__保持一致
587
+ # :return: 向量的打印字符串表示
588
+ # """
589
+ # return self._obj.__repr__()
590
+
591
+ #点集
592
+ class DmPoints:
593
+ """点集类"""
594
+
595
+ def __init__(self):
596
+ """
597
+ 构造函数:初始化点集合对象
598
+ :return: None
599
+ """
600
+ self._obj = Dm.dmPoints()
601
+
602
+ def insert_point(self, point: DmDPoint, point_id: int) -> None:
603
+ """
604
+ 插入一个点并指定ID,ID不连续则会在中间插入[0,0,0]
605
+ :param point: 待插入的点(DmDPoint实例)
606
+ :param point_id: 点的唯一ID(整数)
607
+
608
+ example:
609
+ ```python
610
+ points = DmPoints()
611
+ points.insert_point(DmDPoint(1, 2, 3), 0)
612
+ ```
613
+ """
614
+ self._obj.InsertPoint(point._obj, point_id)
615
+
616
+ def insert_next_point(self, point: DmDPoint) -> int:
617
+ """
618
+ 插入下一个点,自动分配ID
619
+ :param point: 待插入的点(DmDPoint实例)
620
+ :return: 自动分配的点索引(整数)
621
+
622
+ example:
623
+ ```python
624
+ points = DmPoints()
625
+ point_id = points.insert_next_point(DmDPoint(1, 2, 3))
626
+ ```
627
+ """
628
+ return self._obj.InsertNextPoint(point._obj)
629
+
630
+ def get_point_data_list(self) -> list[DmDPoint]:
631
+ """
632
+ 获取所有点的坐标数据
633
+ :return: 点列表,每个元素为DmDPoint实例
634
+
635
+ example:
636
+ ```python
637
+ points = DmPoints()
638
+ points.insert_point(DmDPoint(1, 2, 3), 0)
639
+ points.insert_point(DmDPoint(4, 5, 6), 1)
640
+ point_list = points.get_point_data_list()
641
+ for point in point_list:
642
+ print(point)
643
+ ```
644
+ """
645
+ cpp_list = self._obj.GetPointData()
646
+ return [DmDPoint._from_obj(item) for item in cpp_list]
647
+
648
+ def __repr__(self) -> str:
649
+ """
650
+ 字符串表示(直接调用源端实现,包含点数量和坐标)
651
+ :return: 点集合的标准字符串表示
652
+ """
653
+ return self._obj.__repr__()
654
+
655
+ @classmethod
656
+ def _from_obj(cls, obj):
657
+ """
658
+ :param obj: 原生dmPoints对象
659
+ :return: DmPoints实例
660
+ """
661
+ instance = cls.__new__(cls)
662
+ instance._obj = obj
663
+ return instance
664
+
665
+ #点实体
666
+ class DmDbPoint:
667
+ """点实体"""
668
+ def __init__(self):
669
+ """构造函数,初始化数据库点对象"""
670
+ self._obj = Dm.dmDbPoint()
671
+
672
+ def get_graph_data(self) -> DmDPoint:
673
+ """
674
+ 获取该点的图形数据(坐标信息)
675
+ :return: 点的坐标(DmDPoint实例)
676
+
677
+ example:
678
+ ```python
679
+ if entity.get_type() == ETT_POINT:
680
+ graph_data = entity.get_graph_data()
681
+ print(graph_data)
682
+ ```
683
+ """
684
+ cpp_result = self._obj.GetGraphData()
685
+ return DmDPoint._from_obj(cpp_result)
686
+
687
+ @classmethod
688
+ def _from_obj(cls, obj):
689
+ """
690
+ :param obj: 原生dmDbPoint对象
691
+ :return: DmDbPoint实例
692
+ """
693
+ instance = cls.__new__(cls)
694
+ instance._obj = obj
695
+ return instance
@@ -0,0 +1,7 @@
1
+ import logging
2
+ import os,sys
3
+
4
+ LOG_FORMAT = "%(asctime)s %(levelname)s[%(filename)s:%(lineno)d] %(message)s"
5
+ logging.basicConfig(level=os.environ.get("DA_LOG_LEVEL", "INFO"), format=LOG_FORMAT)
6
+
7
+ logger = logging.getLogger(__name__)
@@ -0,0 +1,3 @@
1
+ from .conn import *
2
+ from .errors import *
3
+ from .types import *