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,116 @@
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 logging import Logger
8
+
9
+ from stbkit.core._internal.constants import (
10
+ DEFAULT_MAX_XML_DEPTH,
11
+ DEFAULT_MAX_XML_SIZE,
12
+ )
13
+ from stbkit.core.data_model.common import StBridgeRoot
14
+ from stbkit.core.stb_io import load, loads
15
+ from stbkit.core.stb_reporting import Reporter
16
+ from stbkit.core.stb_typing import TextSource
17
+
18
+ from stbkit.api import stb_latest
19
+
20
+ from ..upgrade import upgrade_to_latest
21
+
22
+
23
+ def load_latest(
24
+ fp: TextSource,
25
+ *,
26
+ encoding: str | None = None,
27
+ max_size: int = DEFAULT_MAX_XML_SIZE,
28
+ max_depth: int = DEFAULT_MAX_XML_DEPTH,
29
+ logger: Logger | None = None,
30
+ reporter: Reporter | None = None,
31
+ ) -> stb_latest.StBridge:
32
+ """ST-Bridgeファイルを読み込み、最新版のデータモデルへ変換して返します。
33
+
34
+ Args:
35
+ fp: 読み込むファイルのパス、または開いたテキストストリーム。
36
+ encoding: ファイルのエンコーディング。
37
+ Noneの場合は自動判定し、判定できない場合はUTF-8を使用します。
38
+ fpがストリームの場合は無視します。
39
+ max_size: 読み込むサイズの上限。超えた場合は読み込みを中止します。
40
+ max_depth: 要素の階層の上限。超えた場合は読み込みを中止します。
41
+ logger: 出力先Logger。
42
+ reporter: 出力先Reporter。
43
+
44
+ Returns:
45
+ StBridge: 最新版のST-Bridgeのルート要素。
46
+
47
+ Raises:
48
+ OSError: ファイルを開けない場合。存在しない場合はサブクラスのFileNotFoundErrorを投げます。
49
+ LookupError: encodingに未知のエンコーディング名を指定した場合。
50
+ UnicodeDecodeError: デコードできない場合。
51
+ UnsafeXmlError: DOCTYPE宣言が含まれる場合。
52
+ XmlLimitExceededError: max_sizeまたはmax_depthを超えた場合。
53
+ SchemaError: versionを省略したときにversionが取得できなかった場合。
54
+ UnsupportedStbVersionError: 対応していないバージョンの場合。
55
+ xml.etree.ElementTree.ParseError: XMLとして解析できない場合。
56
+
57
+ Examples:
58
+ >>> import stbkit.api
59
+ >>> stb = stbkit.api.load_latest("model.stb")
60
+ """
61
+ stb: StBridgeRoot = load(
62
+ fp,
63
+ encoding=encoding,
64
+ max_size=max_size,
65
+ max_depth=max_depth,
66
+ logger=logger,
67
+ reporter=reporter,
68
+ )
69
+ latest: stb_latest.StBridge = upgrade_to_latest(
70
+ stb, logger=logger, reporter=reporter
71
+ )
72
+ return latest
73
+
74
+
75
+ def loads_latest(
76
+ s: str,
77
+ *,
78
+ max_size: int = DEFAULT_MAX_XML_SIZE,
79
+ max_depth: int = DEFAULT_MAX_XML_DEPTH,
80
+ logger: Logger | None = None,
81
+ reporter: Reporter | None = None,
82
+ ) -> stb_latest.StBridge:
83
+ """XML文字列をST-Bridgeのデータモデルへ読み込み、最新版のデータモデルへ変換して返します。
84
+
85
+ Args:
86
+ s: 読み込むST-BridgeのXML文字列。
87
+ max_size: 読み込む文字数の上限。超えた場合は読み込みを中止します。
88
+ max_depth: 要素の階層の上限。超えた場合は読み込みを中止します。
89
+ logger: 出力先Logger。
90
+ reporter: 出力先Reporter。
91
+
92
+ Returns:
93
+ StBridgeRoot: 最新版のST-Bridgeのルート要素。
94
+
95
+ Raises:
96
+ UnsafeXmlError: DOCTYPE宣言が含まれる場合。
97
+ XmlLimitExceededError: max_sizeまたはmax_depthを超えた場合。
98
+ SchemaError: versionを省略したときにversionが取得できなかった場合。
99
+ UnsupportedStbVersionError: 対応していないバージョンの場合。
100
+ xml.etree.ElementTree.ParseError: XMLとして解析できない場合。
101
+
102
+ Examples:
103
+ >>> import stbkit.api
104
+ >>> stb = stbkit.api.loads_latest(xml_text)
105
+ """
106
+ stb: StBridgeRoot = loads(
107
+ s,
108
+ max_size=max_size,
109
+ max_depth=max_depth,
110
+ logger=logger,
111
+ reporter=reporter,
112
+ )
113
+ latest: stb_latest.StBridge = upgrade_to_latest(
114
+ stb, logger=logger, reporter=reporter
115
+ )
116
+ return latest
@@ -0,0 +1,24 @@
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 dataclasses import dataclass
8
+
9
+ from stbkit.core.stb_reporting import Reporter
10
+
11
+
12
+ @dataclass
13
+ class Defaults:
14
+ steel_strength: str
15
+ default_length: float
16
+ default_float: float = 0.0
17
+ default_string: str = "repair"
18
+
19
+
20
+ @dataclass
21
+ class RepairContext:
22
+ defaults: Defaults
23
+ reporter: Reporter
24
+ unknown_section_id: int | None = None
@@ -0,0 +1,197 @@
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 typing import Any, get_args
8
+
9
+ from stbkit.core._internal.name_converter import private_field_name
10
+ from stbkit.core.data_model import stb_v2_0_2, stb_v2_1_0, stb_v2_1_1
11
+ from stbkit.core.data_model._internal.stb_types import DataType
12
+ from stbkit.core.data_model.common import (
13
+ StBridgeElement,
14
+ StBridgeRoot,
15
+ _FieldInfo,
16
+ _FieldKind,
17
+ )
18
+ from stbkit.core.stb_reporting import Code, Phase, Reporter, get_reporter
19
+
20
+ from ..constants import REPAIR_DEFAULT_LENGTH_MM
21
+ from . import _stb_v2_0_2_repair, _stb_v2_1_0_repair, _stb_v2_1_1_repair
22
+ from ._common import Defaults, RepairContext
23
+
24
+
25
+ def _repair_required_length(
26
+ element: StBridgeElement, *, context: RepairContext
27
+ ) -> None:
28
+ for key, field_info in element._fields.items():
29
+ p_name: str = private_field_name(key)
30
+ if field_info.required and field_info.data_type == DataType.LENGTH:
31
+ value = getattr(element, p_name)
32
+ if value is None or value <= 0:
33
+ context.reporter.warning(
34
+ message=(
35
+ f"属性[{key}]の値[{value}]は不正な長さであるため、デフォルト値[{context.defaults.default_length}]に修復します"
36
+ ),
37
+ code=Code.REPAIR_LOG,
38
+ phase=Phase.REPAIR,
39
+ stb_element=element,
40
+ attr_name=key,
41
+ )
42
+ setattr(element, p_name, context.defaults.default_length)
43
+ elif field_info.required and field_info.data_type == DataType.FLOAT:
44
+ value = getattr(element, p_name)
45
+ if value is None:
46
+ context.reporter.warning(
47
+ message=(
48
+ f"属性[{key}]の値がNoneであるため、デフォルト値[{context.defaults.default_float}]に修復します"
49
+ ),
50
+ code=Code.REPAIR_LOG,
51
+ phase=Phase.REPAIR,
52
+ stb_element=element,
53
+ attr_name=key,
54
+ )
55
+ setattr(element, p_name, context.defaults.default_float)
56
+ if field_info.kind == _FieldKind.ELEMENT:
57
+ child = getattr(element, p_name)
58
+ if isinstance(child, StBridgeElement):
59
+ _repair_required_length(child, context=context)
60
+ elif isinstance(child, list):
61
+ for c in child:
62
+ if isinstance(c, StBridgeElement):
63
+ _repair_required_length(c, context=context)
64
+
65
+
66
+ def _default_value_for_field(
67
+ field_info: _FieldInfo, *, defaults: Defaults
68
+ ) -> Any | None:
69
+ match field_info.data_type:
70
+ case DataType.FLOAT:
71
+ return defaults.default_float
72
+ case DataType.LENGTH | DataType.NON_NEGATIVE_LENGTH:
73
+ return defaults.default_length
74
+ case DataType.STR:
75
+ return defaults.default_string
76
+ case _:
77
+ return None
78
+
79
+
80
+ def _fill_required_attributes(
81
+ element: StBridgeElement, *, context: RepairContext
82
+ ) -> None:
83
+ for key, field_info in element._fields.items():
84
+ if field_info.kind not in (_FieldKind.ATTRIBUTE, _FieldKind.CONTENT):
85
+ continue
86
+ if not field_info.required:
87
+ continue
88
+ p_name: str = private_field_name(key)
89
+ if getattr(element, p_name) is not None:
90
+ continue
91
+ default_value = _default_value_for_field(field_info, defaults=context.defaults)
92
+ if default_value is None:
93
+ continue
94
+ context.reporter.warning(
95
+ message=(
96
+ f"属性[{key}]が存在しないため、デフォルト値[{default_value}]に修復します"
97
+ ),
98
+ code=Code.REPAIR_LOG,
99
+ phase=Phase.REPAIR,
100
+ stb_element=element,
101
+ attr_name=key,
102
+ )
103
+ setattr(element, p_name, default_value)
104
+
105
+
106
+ def _instantiate_child(
107
+ field_info: _FieldInfo, *, context: RepairContext
108
+ ) -> StBridgeElement | None:
109
+ element_cls = field_info.py_type
110
+ if not isinstance(element_cls, type):
111
+ args = get_args(element_cls)
112
+ if not args or not isinstance(args[0], type):
113
+ return None
114
+ element_cls = args[0]
115
+ if not issubclass(element_cls, StBridgeElement):
116
+ return None
117
+ instance: StBridgeElement = element_cls()
118
+ _fill_required_attributes(instance, context=context)
119
+ return instance
120
+
121
+
122
+ def _repair_occurs(element: StBridgeElement, *, context: RepairContext) -> None:
123
+ for key, field_info in element._fields.items():
124
+ if field_info.kind != _FieldKind.ELEMENT:
125
+ continue
126
+ p_name: str = private_field_name(key)
127
+ value = getattr(element, p_name)
128
+ if field_info.max_occurs == 1:
129
+ if value is None and (field_info.min_occurs or 0) >= 1:
130
+ new_child = _instantiate_child(field_info, context=context)
131
+ if new_child is not None:
132
+ context.reporter.warning(
133
+ message=f"必須要素[{key}]が存在しないため追加しました",
134
+ code=Code.REPAIR_LOG,
135
+ phase=Phase.REPAIR,
136
+ stb_element=element,
137
+ )
138
+ setattr(element, key, new_child)
139
+ value = new_child
140
+ if isinstance(value, StBridgeElement):
141
+ _repair_occurs(value, context=context)
142
+ elif isinstance(value, list):
143
+ if field_info.max_occurs is not None and len(value) > field_info.max_occurs:
144
+ del value[field_info.max_occurs :]
145
+ context.reporter.warning(
146
+ message=(
147
+ f"要素[{key}]が最大回数[{field_info.max_occurs}]を"
148
+ "超過しているため削除しました"
149
+ ),
150
+ code=Code.REPAIR_LOG,
151
+ phase=Phase.REPAIR,
152
+ stb_element=element,
153
+ )
154
+ if field_info.min_occurs is not None and len(value) < field_info.min_occurs:
155
+ while len(value) < field_info.min_occurs:
156
+ new_child = _instantiate_child(field_info, context=context)
157
+ if new_child is None:
158
+ break
159
+ value.append(new_child)
160
+ context.reporter.warning(
161
+ message=(
162
+ f"要素[{key}]が最小回数[{field_info.min_occurs}]に"
163
+ "満たないため追加しました"
164
+ ),
165
+ code=Code.REPAIR_LOG,
166
+ phase=Phase.REPAIR,
167
+ stb_element=element,
168
+ )
169
+ for item in value:
170
+ if isinstance(item, StBridgeElement):
171
+ _repair_occurs(item, context=context)
172
+
173
+
174
+ def repair_stb(
175
+ stb: StBridgeRoot,
176
+ *,
177
+ reporter: Reporter | None = None,
178
+ default_steel_strength: str = "SS400",
179
+ default_length: float = REPAIR_DEFAULT_LENGTH_MM,
180
+ ) -> None:
181
+ if reporter is None:
182
+ reporter = get_reporter()
183
+ defaults: Defaults = Defaults(
184
+ steel_strength=default_steel_strength, default_length=default_length
185
+ )
186
+ context: RepairContext = RepairContext(defaults=defaults, reporter=reporter)
187
+ _repair_occurs(stb, context=context)
188
+ _repair_required_length(stb, context=context)
189
+ match stb:
190
+ case stb_v2_1_1.StBridge():
191
+ _stb_v2_1_1_repair.repair_stb(stb, context=context)
192
+ case stb_v2_1_0.StBridge():
193
+ _stb_v2_1_0_repair.repair_stb(stb, context=context)
194
+ case stb_v2_0_2.StBridge():
195
+ _stb_v2_0_2_repair.repair_stb(stb, context=context)
196
+ case _:
197
+ pass
@@ -0,0 +1,53 @@
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 stbkit.core.data_model.stb_v2_0_2 import StbGirder, StBridge
8
+ from stbkit.core.stb_exceptions import NoneAccessError
9
+ from stbkit.core.stb_reporting import Code, Phase
10
+
11
+ from ._common import RepairContext
12
+
13
+
14
+ def _repair_stb_girder(stb: StBridge, *, context: RepairContext) -> None:
15
+ # isfoundationが無い場合falseを入れる
16
+ try:
17
+ girders: list[StbGirder] = stb.stb_model.stb_members.stb_girders.stb_girder
18
+ except NoneAccessError:
19
+ return
20
+ for girder in girders:
21
+ if girder.is_foundation_or_none is None:
22
+ girder.is_foundation = False
23
+ context.reporter.warning(
24
+ "StbGirderのisfoundationがNoneなのでFalseに設定しました",
25
+ code=Code.REPAIR_LOG,
26
+ phase=Phase.REPAIR,
27
+ stb_element=girder,
28
+ )
29
+
30
+
31
+ def _repair_stb_joint_beam_shape_h(stb: StBridge, *, context: RepairContext) -> None:
32
+ try:
33
+ joints = stb.stb_model.stb_joints.stb_joint_beam_shape_h
34
+ except NoneAccessError:
35
+ return
36
+ for joint in joints:
37
+ if (
38
+ joint.stb_joint_shape_h_or_none is not None
39
+ and joint.stb_joint_shape_h.strength_plate_or_none is None
40
+ ):
41
+ joint.stb_joint_shape_h.strength_plate = context.defaults.steel_strength
42
+ context.reporter.warning(
43
+ "StbJointShapeHのstrength_plateがNoneなので、デフォルト値を設定しました",
44
+ code=Code.REPAIR_LOG,
45
+ phase=Phase.REPAIR,
46
+ stb_element=joint.stb_joint_shape_h,
47
+ attr_name="strength_plate",
48
+ )
49
+
50
+
51
+ def repair_stb(stb: StBridge, *, context: RepairContext) -> None:
52
+ _repair_stb_girder(stb, context=context)
53
+ _repair_stb_joint_beam_shape_h(stb, context=context)
@@ -0,0 +1,109 @@
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 uuid
8
+
9
+ from stbkit.core.data_model.stb_v2_1_0 import (
10
+ StbGirder,
11
+ StBridge,
12
+ StbSections,
13
+ StbSecUndefined,
14
+ )
15
+ from stbkit.core.repository import RepositoryV2_1_0
16
+ from stbkit.core.stb_exceptions import NoneAccessError
17
+ from stbkit.core.stb_reporting import Code, Phase
18
+
19
+ from ._common import RepairContext
20
+
21
+
22
+ def _get_unknown_section_id(stb: StBridge, *, context: RepairContext) -> int:
23
+ if context.unknown_section_id is not None:
24
+ return context.unknown_section_id
25
+ sections: StbSections = stb.ensure.stb_model().ensure.stb_sections()
26
+ max_id: int = 1
27
+ for sec in sections.stb_sec_undefined:
28
+ max_id = max(max_id, sec.id)
29
+ unknown_id: int = max_id + 1
30
+ context.unknown_section_id = unknown_id
31
+ undefined: StbSecUndefined = StbSecUndefined(
32
+ id=unknown_id,
33
+ name="不明断面(stbkitにより自動生成)",
34
+ guid=uuid.uuid4(),
35
+ )
36
+ sections.stb_sec_undefined.append(undefined)
37
+ context.reporter.warning(
38
+ f"構造不明断面(id={unknown_id})を新規に作成しました",
39
+ code=Code.REPAIR_LOG,
40
+ phase=Phase.REPAIR,
41
+ stb_element=undefined,
42
+ )
43
+ return unknown_id
44
+
45
+
46
+ def _repair_stb_girder(
47
+ stb: StBridge, *, context: RepairContext, repo: RepositoryV2_1_0
48
+ ) -> None:
49
+ # isfoundationが無い場合falseを入れる
50
+ try:
51
+ girders: list[StbGirder] = stb.stb_model.stb_members.stb_girders.stb_girder
52
+ except NoneAccessError:
53
+ return
54
+ for girder in girders:
55
+ if girder.is_foundation_or_none is None:
56
+ girder.is_foundation = False
57
+ context.reporter.warning(
58
+ "StbGirderのisfoundationがNoneなのでFalseに設定しました",
59
+ code=Code.REPAIR_LOG,
60
+ phase=Phase.REPAIR,
61
+ stb_element=girder,
62
+ )
63
+ if repo.deref(girder).id_section_or_none is None:
64
+ unknown_id = _get_unknown_section_id(stb, context=context)
65
+ girder.id_section = unknown_id
66
+ context.reporter.warning(
67
+ f"StbGirderのid_sectionが不正な参照なので、構造不明断面(id={unknown_id})を設定しました",
68
+ code=Code.REPAIR_LOG,
69
+ phase=Phase.REPAIR,
70
+ stb_element=girder,
71
+ attr_name="id_section",
72
+ )
73
+ if girder.kind_structure_or_none != "UNDEFINED":
74
+ girder.kind_structure = "UNDEFINED"
75
+ context.reporter.warning(
76
+ "StbGirderのid_sectionが不正な参照なので、構造種別をUNDEFINEDに設定しました",
77
+ code=Code.REPAIR_LOG,
78
+ phase=Phase.REPAIR,
79
+ stb_element=girder,
80
+ attr_name="kind_structure",
81
+ )
82
+
83
+
84
+ def _repair_stb_joint_beam_shape_h(stb: StBridge, *, context: RepairContext) -> None:
85
+ try:
86
+ joints = stb.stb_model.stb_joints.stb_joint_beam_shape_h
87
+ except NoneAccessError:
88
+ return
89
+ for joint in joints:
90
+ if (
91
+ joint.stb_joint_shape_h_or_none is not None
92
+ and joint.stb_joint_shape_h.strength_plate_flange_or_none is None
93
+ ):
94
+ joint.stb_joint_shape_h.strength_plate_flange_or_none = (
95
+ context.defaults.steel_strength
96
+ )
97
+ context.reporter.warning(
98
+ "StbJointShapeHのstrength_plate_flangeがNoneなので、デフォルト値を設定しました",
99
+ code=Code.REPAIR_LOG,
100
+ phase=Phase.REPAIR,
101
+ stb_element=joint.stb_joint_shape_h,
102
+ attr_name="strength_plate_flange",
103
+ )
104
+
105
+
106
+ def repair_stb(stb: StBridge, *, context: RepairContext) -> None:
107
+ repo: RepositoryV2_1_0 = RepositoryV2_1_0(stb)
108
+ _repair_stb_girder(stb, context=context, repo=repo)
109
+ _repair_stb_joint_beam_shape_h(stb, context=context)
@@ -0,0 +1,109 @@
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 uuid
8
+
9
+ from stbkit.core.data_model.stb_v2_1_1 import (
10
+ StbGirder,
11
+ StBridge,
12
+ StbSections,
13
+ StbSecUndefined,
14
+ )
15
+ from stbkit.core.repository import RepositoryV2_1_1
16
+ from stbkit.core.stb_exceptions import NoneAccessError
17
+ from stbkit.core.stb_reporting import Code, Phase
18
+
19
+ from ._common import RepairContext
20
+
21
+
22
+ def _get_unknown_section_id(stb: StBridge, *, context: RepairContext) -> int:
23
+ if context.unknown_section_id is not None:
24
+ return context.unknown_section_id
25
+ sections: StbSections = stb.ensure.stb_model().ensure.stb_sections()
26
+ max_id: int = 1
27
+ for sec in sections.stb_sec_undefined:
28
+ max_id = max(max_id, sec.id)
29
+ unknown_id: int = max_id + 1
30
+ context.unknown_section_id = unknown_id
31
+ undefined: StbSecUndefined = StbSecUndefined(
32
+ id=unknown_id,
33
+ name="不明断面(stbkitにより自動生成)",
34
+ guid=uuid.uuid4(),
35
+ )
36
+ sections.stb_sec_undefined.append(undefined)
37
+ context.reporter.warning(
38
+ f"構造不明断面(id={unknown_id})を新規に作成しました",
39
+ code=Code.REPAIR_LOG,
40
+ phase=Phase.REPAIR,
41
+ stb_element=undefined,
42
+ )
43
+ return unknown_id
44
+
45
+
46
+ def _repair_stb_girder(
47
+ stb: StBridge, *, context: RepairContext, repo: RepositoryV2_1_1
48
+ ) -> None:
49
+ # isfoundationが無い場合falseを入れる
50
+ try:
51
+ girders: list[StbGirder] = stb.stb_model.stb_members.stb_girders.stb_girder
52
+ except NoneAccessError:
53
+ return
54
+ for girder in girders:
55
+ if girder.is_foundation_or_none is None:
56
+ girder.is_foundation = False
57
+ context.reporter.warning(
58
+ "StbGirderのisfoundationがNoneなのでFalseに設定しました",
59
+ code=Code.REPAIR_LOG,
60
+ phase=Phase.REPAIR,
61
+ stb_element=girder,
62
+ )
63
+ if repo.deref(girder).id_section_or_none is None:
64
+ unknown_id = _get_unknown_section_id(stb, context=context)
65
+ girder.id_section = unknown_id
66
+ context.reporter.warning(
67
+ f"StbGirderのid_sectionが不正な参照なので、構造不明断面(id={unknown_id})を設定しました",
68
+ code=Code.REPAIR_LOG,
69
+ phase=Phase.REPAIR,
70
+ stb_element=girder,
71
+ attr_name="id_section",
72
+ )
73
+ if girder.kind_structure_or_none != "UNDEFINED":
74
+ girder.kind_structure = "UNDEFINED"
75
+ context.reporter.warning(
76
+ "StbGirderのid_sectionが不正な参照なので、構造種別をUNDEFINEDに設定しました",
77
+ code=Code.REPAIR_LOG,
78
+ phase=Phase.REPAIR,
79
+ stb_element=girder,
80
+ attr_name="kind_structure",
81
+ )
82
+
83
+
84
+ def _repair_stb_joint_beam_shape_h(stb: StBridge, *, context: RepairContext) -> None:
85
+ try:
86
+ joints = stb.stb_model.stb_joints.stb_joint_beam_shape_h
87
+ except NoneAccessError:
88
+ return
89
+ for joint in joints:
90
+ if (
91
+ joint.stb_joint_shape_h_or_none is not None
92
+ and joint.stb_joint_shape_h.strength_plate_flange_or_none is None
93
+ ):
94
+ joint.stb_joint_shape_h.strength_plate_flange_or_none = (
95
+ context.defaults.steel_strength
96
+ )
97
+ context.reporter.warning(
98
+ "StbJointShapeHのstrength_plate_flangeがNoneなので、デフォルト値を設定しました",
99
+ code=Code.REPAIR_LOG,
100
+ phase=Phase.REPAIR,
101
+ stb_element=joint.stb_joint_shape_h,
102
+ attr_name="strength_plate_flange",
103
+ )
104
+
105
+
106
+ def repair_stb(stb: StBridge, *, context: RepairContext) -> None:
107
+ repo: RepositoryV2_1_1 = RepositoryV2_1_1(stb)
108
+ _repair_stb_girder(stb, context=context, repo=repo)
109
+ _repair_stb_joint_beam_shape_h(stb, context=context)
@@ -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
+ """StudioAppへ渡すReporter結果文字列を生成するモジュール"""
8
+
9
+ import json
10
+ from dataclasses import asdict
11
+ from pathlib import Path
12
+
13
+ from stbkit.core.data_model.common import StBridgeRoot
14
+ from stbkit.core.stb_io import load, loads
15
+ from stbkit.core.stb_reporting import (
16
+ CollectingReporter,
17
+ NullReporter,
18
+ Reporter,
19
+ ReportingResult,
20
+ )
21
+ from stbkit.core.validation import validate_schema
22
+
23
+
24
+ def _read_source(source: str, is_path: bool, *, reporter: Reporter) -> StBridgeRoot:
25
+ """Rustから渡されたST-Bridgeデータを読み込む
26
+
27
+ Rust側の読み込みの都合でpathで渡される場合と文字列で渡される場合がある。
28
+ """
29
+ if is_path:
30
+ return load(Path(source), reporter=reporter)
31
+ return loads(source, reporter=reporter)
32
+
33
+
34
+ def load_report_json(source: str, is_path: bool) -> str:
35
+ reporter: CollectingReporter = CollectingReporter()
36
+ _read_source(source, is_path, reporter=reporter)
37
+ return _report_to_json(reporter.report)
38
+
39
+
40
+ def validation_report_json(source: str, is_path: bool) -> str:
41
+ stb: StBridgeRoot = _read_source(source, is_path, reporter=NullReporter())
42
+ reporter: CollectingReporter = CollectingReporter()
43
+ validate_schema(stb, reporter=reporter, require_xsd=False)
44
+ return _report_to_json(reporter.report)
45
+
46
+
47
+ def _report_to_json(report: ReportingResult) -> str:
48
+ payload = [asdict(item) for item in report]
49
+ return json.dumps(payload, ensure_ascii=False)