stbkit 0.1.0a9.dev1__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 (125) hide show
  1. stbkit/__main__.py +10 -0
  2. stbkit/api/__init__.py +48 -0
  3. stbkit/api/experimental/__init__.py +19 -0
  4. stbkit/api/experimental/repository/__init__.py +30 -0
  5. stbkit/api/py.typed +0 -0
  6. stbkit/api/stb_latest.py +7 -0
  7. stbkit/api/stb_v2_0_2.py +11 -0
  8. stbkit/api/stb_v2_1_1.py +9 -0
  9. stbkit/cli/__init__.py +17 -0
  10. stbkit/cli/_internal/cli_main.py +114 -0
  11. stbkit/cli/_internal/common.py +126 -0
  12. stbkit/cli/_internal/constants_exit_code.py +59 -0
  13. stbkit/cli/_internal/converter.py +693 -0
  14. stbkit/cli/_internal/diff.py +213 -0
  15. stbkit/cli/_internal/entry_points.py +25 -0
  16. stbkit/cli/_internal/global_parent.py +70 -0
  17. stbkit/cli/_internal/show_versions.py +36 -0
  18. stbkit/cli/_internal/validate.py +310 -0
  19. stbkit/cli/commands/convert.py +16 -0
  20. stbkit/cli/commands/diff.py +16 -0
  21. stbkit/cli/commands/validate.py +16 -0
  22. stbkit/cli/py.typed +0 -0
  23. stbkit/tools/__init__.py +12 -0
  24. stbkit/tools/_internal/__init__.py +5 -0
  25. stbkit/tools/_internal/constants.py +21 -0
  26. stbkit/tools/_internal/data_model/building_geometry.py +1208 -0
  27. stbkit/tools/_internal/data_model/building_geometry_web.py +106 -0
  28. stbkit/tools/_internal/data_model/element_data.py +93 -0
  29. stbkit/tools/_internal/data_model/ifc_data/entity_data.py +67 -0
  30. stbkit/tools/_internal/data_model/ifc_data/entity_names.py +32 -0
  31. stbkit/tools/_internal/data_model/shape_data.py +1089 -0
  32. stbkit/tools/_internal/diff/__init__.py +5 -0
  33. stbkit/tools/_internal/diff/common.py +50 -0
  34. stbkit/tools/_internal/diff/diff_xml.py +796 -0
  35. stbkit/tools/_internal/matrix.py +51 -0
  36. stbkit/tools/_internal/optional_dependencies/__init__.py +5 -0
  37. stbkit/tools/_internal/optional_dependencies/ifc_common.py +28 -0
  38. stbkit/tools/_internal/optional_dependencies/ifc_exporter/ifc_entity_exporter.py +473 -0
  39. stbkit/tools/_internal/optional_dependencies/ifc_exporter/ifc_profile_exporter.py +267 -0
  40. stbkit/tools/_internal/optional_dependencies/ifc_exporter/ifc_representation_exporter.py +178 -0
  41. stbkit/tools/_internal/optional_dependencies/ifc_pipeline.py +133 -0
  42. stbkit/tools/_internal/optional_dependencies/ifc_to_building_geometry.py +64 -0
  43. stbkit/tools/_internal/stb_io.py +116 -0
  44. stbkit/tools/_internal/stb_repair/_common.py +24 -0
  45. stbkit/tools/_internal/stb_repair/_stb_repair.py +197 -0
  46. stbkit/tools/_internal/stb_repair/_stb_v2_0_2_repair.py +53 -0
  47. stbkit/tools/_internal/stb_repair/_stb_v2_1_0_repair.py +109 -0
  48. stbkit/tools/_internal/stb_repair/_stb_v2_1_1_repair.py +109 -0
  49. stbkit/tools/_internal/studio_report.py +49 -0
  50. stbkit/tools/_internal/utils/atomic_writer.py +57 -0
  51. stbkit/tools/_internal/utils/float_rounding.py +49 -0
  52. stbkit/tools/_internal/utils/girder_utils.py +91 -0
  53. stbkit/tools/_internal/utils/guid_utils.py +30 -0
  54. stbkit/tools/_internal/utils/mesh_utils.py +1305 -0
  55. stbkit/tools/_internal/utils/node_utils.py +50 -0
  56. stbkit/tools/_internal/utils/unit_utils.py +23 -0
  57. stbkit/tools/_internal/vectors.py +222 -0
  58. stbkit/tools/converters/__init__.py +39 -0
  59. stbkit/tools/converters/_internal/__init__.py +5 -0
  60. stbkit/tools/converters/_internal/building_geometry_to_ply_text.py +32 -0
  61. stbkit/tools/converters/_internal/coord_converter.py +151 -0
  62. stbkit/tools/converters/_internal/element_data_to_building_geometry.py +549 -0
  63. stbkit/tools/converters/_internal/ifc_to_ply_text.py +21 -0
  64. stbkit/tools/converters/_internal/name_converter.py +23 -0
  65. stbkit/tools/converters/_internal/pipeline/__init__.py +5 -0
  66. stbkit/tools/converters/_internal/pipeline/data.py +188 -0
  67. stbkit/tools/converters/_internal/pipeline/execution.py +569 -0
  68. stbkit/tools/converters/_internal/pipeline/ply_pipeline.py +52 -0
  69. stbkit/tools/converters/_internal/pipeline/stb_pipeline.py +226 -0
  70. stbkit/tools/converters/_internal/pipeline/stb_pipeline_latest.py +39 -0
  71. stbkit/tools/converters/_internal/pipeline/step.py +139 -0
  72. stbkit/tools/converters/_internal/stb_latest_to_element_data/__init__.py +17 -0
  73. stbkit/tools/converters/_internal/stb_latest_to_element_data/_stb_latest_to_element_data.py +186 -0
  74. stbkit/tools/converters/_internal/stb_latest_to_element_data/member/member_footing.py +49 -0
  75. stbkit/tools/converters/_internal/stb_latest_to_element_data/member/member_line.py +533 -0
  76. stbkit/tools/converters/_internal/stb_latest_to_element_data/member/member_pile.py +100 -0
  77. stbkit/tools/converters/_internal/stb_latest_to_element_data/member/member_plane.py +103 -0
  78. stbkit/tools/converters/_internal/stb_latest_to_element_data/open.py +70 -0
  79. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec.py +214 -0
  80. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_beam_rc.py +67 -0
  81. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_beam_s.py +97 -0
  82. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_beam_src.py +28 -0
  83. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_brace_s.py +49 -0
  84. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_column_cft.py +217 -0
  85. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_column_rc.py +41 -0
  86. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_column_s.py +127 -0
  87. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_column_src.py +173 -0
  88. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_foundation.py +225 -0
  89. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_parapet_rc.py +53 -0
  90. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_pile_rc.py +106 -0
  91. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_pile_s.py +100 -0
  92. stbkit/tools/converters/_internal/stb_latest_to_element_data/section/sec_steel.py +432 -0
  93. stbkit/tools/converters/_internal/stb_to_building_geometry.py +44 -0
  94. stbkit/tools/converters/_internal/stb_to_ifc_data/__init__.py +5 -0
  95. stbkit/tools/converters/_internal/stb_to_ifc_data/_stb_to_ifc_data.py +59 -0
  96. stbkit/tools/converters/_internal/stb_to_ifc_data/convert_option.py +22 -0
  97. stbkit/tools/converters/_internal/stb_to_ply_text.py +22 -0
  98. stbkit/tools/py.typed +0 -0
  99. stbkit/tools/upgrade/__init__.py +13 -0
  100. stbkit/tools/upgrade/_internal/__init__.py +5 -0
  101. stbkit/tools/upgrade/_internal/common.py +205 -0
  102. stbkit/tools/upgrade/_internal/upgrade.py +228 -0
  103. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/__init__.py +60 -0
  104. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/hook_common.py +62 -0
  105. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/hook_joint_beam_shape_h.py +44 -0
  106. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/hook_sec_pile_rc.py +101 -0
  107. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/hook_sec_pile_s.py +78 -0
  108. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/hook_sec_slab_deck.py +56 -0
  109. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/hook_sec_slab_rc.py +128 -0
  110. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/post_girder.py +126 -0
  111. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/post_open.py +110 -0
  112. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/post_sec_beam_rc.py +227 -0
  113. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hook_funcs/post_sec_beam_s.py +1153 -0
  114. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/hooks.py +22 -0
  115. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/post.py +42 -0
  116. stbkit/tools/upgrade/_internal/v2_0_2_to_v2_1_0/tables.py +99 -0
  117. stbkit/tools/upgrade/_internal/v2_1_0_to_v2_1_1/__init__.py +58 -0
  118. stbkit/tools/upgrade/_internal/v2_1_0_to_v2_1_1/hooks.py +32 -0
  119. stbkit/tools/upgrade/_internal/v2_1_0_to_v2_1_1/tables.py +56 -0
  120. stbkit-0.1.0a9.dev1.dist-info/METADATA +196 -0
  121. stbkit-0.1.0a9.dev1.dist-info/RECORD +125 -0
  122. stbkit-0.1.0a9.dev1.dist-info/WHEEL +5 -0
  123. stbkit-0.1.0a9.dev1.dist-info/entry_points.txt +2 -0
  124. stbkit-0.1.0a9.dev1.dist-info/licenses/LICENSE +373 -0
  125. stbkit-0.1.0a9.dev1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,57 @@
1
+ # Copyright 2026 TAISEI CORPORATION
2
+ # SPDX-License-Identifier: MPL-2.0
3
+ # This Source Code Form is subject to the terms of the Mozilla Public
4
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
+
7
+ import os
8
+ import tempfile
9
+ from collections.abc import Callable
10
+ from pathlib import Path
11
+ from typing import TextIO
12
+
13
+
14
+ def write_with_temp_file(output_path: Path, writer: Callable[[Path], None]) -> None:
15
+ output_path.parent.mkdir(parents=True, exist_ok=True)
16
+ with tempfile.NamedTemporaryFile(
17
+ mode="wb",
18
+ dir=output_path.parent,
19
+ prefix=f".{output_path.name}.",
20
+ suffix=".tmp",
21
+ delete=False,
22
+ ) as stream:
23
+ temporary_path: Path = Path(stream.name)
24
+ try:
25
+ writer(temporary_path)
26
+ os.replace(temporary_path, output_path)
27
+ finally:
28
+ temporary_path.unlink(missing_ok=True)
29
+
30
+
31
+ def write_text_with_temp_file(
32
+ output_path: Path, text: str, *, encoding: str = "utf-8", newline: str = "\n"
33
+ ) -> None:
34
+ def _write(temporary_path: Path) -> None:
35
+ with open(temporary_path, "w", encoding=encoding, newline=newline) as stream:
36
+ stream.write(text)
37
+
38
+ write_with_temp_file(output_path, _write)
39
+
40
+
41
+ def write_text_stream_with_temp_file(
42
+ output_path: Path,
43
+ writer: Callable[[TextIO], None],
44
+ *,
45
+ encoding: str = "utf-8",
46
+ newline: str = "\n",
47
+ ) -> None:
48
+ def _write(temporary_path: Path) -> None:
49
+ with open(
50
+ temporary_path,
51
+ "w",
52
+ encoding=encoding,
53
+ newline=newline,
54
+ ) as stream:
55
+ writer(stream)
56
+
57
+ write_with_temp_file(output_path, _write)
@@ -0,0 +1,49 @@
1
+ # Copyright 2026 TAISEI CORPORATION
2
+ # SPDX-License-Identifier: MPL-2.0
3
+ # This Source Code Form is subject to the terms of the Mozilla Public
4
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
+
7
+ from ..vectors import Vector2d, Vector3d
8
+
9
+
10
+ def validated_round_digits(round_digits: int | None) -> int | None:
11
+ if round_digits is None:
12
+ return None
13
+ if round_digits < 0:
14
+ raise AssertionError("round_digitsは0以上である必要があります")
15
+ return round_digits
16
+
17
+
18
+ def round_float(value: float, *, round_digits: int | None) -> float:
19
+ round_digits = validated_round_digits(round_digits)
20
+ if round_digits is None:
21
+ return value
22
+ return round(value, ndigits=round_digits)
23
+
24
+
25
+ def round_vector2d(
26
+ value: Vector2d,
27
+ *,
28
+ round_digits: int | None,
29
+ ) -> Vector2d:
30
+ if round_digits is None:
31
+ return value
32
+ return Vector2d(
33
+ round_float(value.x, round_digits=round_digits),
34
+ round_float(value.y, round_digits=round_digits),
35
+ )
36
+
37
+
38
+ def round_vector3d(
39
+ value: Vector3d,
40
+ *,
41
+ round_digits: int | None,
42
+ ) -> Vector3d:
43
+ if round_digits is None:
44
+ return value
45
+ return Vector3d(
46
+ round_float(value.x, round_digits=round_digits),
47
+ round_float(value.y, round_digits=round_digits),
48
+ round_float(value.z, round_digits=round_digits),
49
+ )
@@ -0,0 +1,91 @@
1
+ # Copyright 2025-2026 TAISEI CORPORATION
2
+ # SPDX-License-Identifier: MPL-2.0
3
+ # This Source Code Form is subject to the terms of the Mozilla Public
4
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
+
7
+ from dataclasses import dataclass
8
+ from typing import Protocol
9
+
10
+ from stbkit.core.data_model.common import StBridgeRoot
11
+ from stbkit.core.stb_exceptions import SchemaError
12
+
13
+ from ..vectors import Vector3d
14
+ from .node_utils import get_node_coordinate
15
+
16
+
17
+ class GirderLike(Protocol):
18
+ @property
19
+ def id_node_start(self) -> int: ...
20
+ @property
21
+ def id_node_start_or_none(self) -> int | None: ...
22
+ @property
23
+ def id_node_end(self) -> int: ...
24
+ @property
25
+ def id_node_end_or_none(self) -> int | None: ...
26
+ @property
27
+ def offset_start_x_or_none(self) -> float | None: ...
28
+ @property
29
+ def offset_start_y_or_none(self) -> float | None: ...
30
+ @property
31
+ def offset_start_z_or_none(self) -> float | None: ...
32
+ @property
33
+ def offset_end_x_or_none(self) -> float | None: ...
34
+ @property
35
+ def offset_end_y_or_none(self) -> float | None: ...
36
+ @property
37
+ def offset_end_z_or_none(self) -> float | None: ...
38
+ def _name_for_log(self) -> str: ...
39
+
40
+
41
+ def girder_offset_start(girder: GirderLike) -> Vector3d:
42
+ return Vector3d(
43
+ girder.offset_start_x_or_none or 0.0,
44
+ girder.offset_start_y_or_none or 0.0,
45
+ girder.offset_start_z_or_none or 0.0,
46
+ )
47
+
48
+
49
+ def girder_offset_end(girder: GirderLike) -> Vector3d:
50
+ return Vector3d(
51
+ girder.offset_end_x_or_none or 0.0,
52
+ girder.offset_end_y_or_none or 0.0,
53
+ girder.offset_end_z_or_none or 0.0,
54
+ )
55
+
56
+
57
+ @dataclass(slots=True)
58
+ class GirderLengthValue:
59
+ length: float
60
+ length_with_offset: float
61
+ pos_control_point_start: float
62
+ pos_control_point_end: float
63
+
64
+
65
+ def girder_length(
66
+ stb_girder: GirderLike,
67
+ stb: StBridgeRoot,
68
+ ) -> GirderLengthValue:
69
+ if (
70
+ stb_girder.id_node_start_or_none is None
71
+ or stb_girder.id_node_end_or_none is None
72
+ ):
73
+ raise SchemaError(f"{stb_girder._name_for_log()} 節点idがNoneです")
74
+ coord_start: Vector3d = get_node_coordinate(stb, stb_girder.id_node_start)
75
+ coord_end: Vector3d = get_node_coordinate(stb, stb_girder.id_node_end)
76
+ offset_start: Vector3d = girder_offset_start(stb_girder)
77
+ offset_end: Vector3d = girder_offset_end(stb_girder)
78
+ vx: Vector3d = (coord_end - coord_start).normalize()
79
+ length: float = coord_start.distance_to(coord_end)
80
+ length_with_offset: float = (coord_start + offset_start).distance_to(
81
+ coord_end + offset_end
82
+ )
83
+ pos_control_point_start: float = vx.dot(offset_start)
84
+ pos_control_point_end: float = length - vx.dot(offset_end)
85
+
86
+ return GirderLengthValue(
87
+ length=length,
88
+ length_with_offset=length_with_offset,
89
+ pos_control_point_start=pos_control_point_start,
90
+ pos_control_point_end=pos_control_point_end,
91
+ )
@@ -0,0 +1,30 @@
1
+ # Copyright 2025-2026 TAISEI CORPORATION
2
+ # SPDX-License-Identifier: MPL-2.0
3
+ # This Source Code Form is subject to the terms of the Mozilla Public
4
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
+
7
+ from uuid import UUID
8
+
9
+ from ..optional_dependencies.ifc_common import ensure_ifcopenshell
10
+
11
+
12
+ def to_ifc_guid(guid: UUID) -> str:
13
+ """UUIDをIFCのGlobalId形式に変換する
14
+
15
+ TODO:ifcopenshell無しで変換できるようにする"""
16
+ ensure_ifcopenshell()
17
+ import ifcopenshell
18
+
19
+ return ifcopenshell.guid.compress(str(guid))
20
+
21
+
22
+ def from_ifc_guid(ifc_guid: str) -> UUID:
23
+ """IFCのGlobalId形式をUUIDに変換する
24
+
25
+ TODO:ifcopenshell無しで変換できるようにする"""
26
+ ensure_ifcopenshell()
27
+ import ifcopenshell
28
+
29
+ decompressed = ifcopenshell.guid.expand(ifc_guid)
30
+ return UUID(decompressed)