feat: 完善一级关系参数化建模与参数导出
This commit is contained in:
@@ -90,6 +90,7 @@ from .transforms import TransformMixin
|
||||
from .geometry_utils import * # noqa: F403
|
||||
from .model_types import PartNode, TopologyStats
|
||||
from .step_io import (
|
||||
_load_brep_shape,
|
||||
_load_plain_step,
|
||||
_load_with_xcaf,
|
||||
_parse_product_names,
|
||||
@@ -130,6 +131,8 @@ class StepModel(FeatureMixin, ExportMixin, TransformMixin, OperationMixin, Polyd
|
||||
self._edge_duplicate_key_ids_cache: dict[tuple[object, ...], list[int]] | None = None
|
||||
self._same_domain_internal_edge_ids_cache: set[int] | None = None
|
||||
self._same_domain_duplicate_edge_ids_cache: set[int] | None = None
|
||||
self._editable_feature_candidates_cache: dict[tuple[object, ...], list[dict[str, object]]] = {}
|
||||
self._cylindrical_feature_candidates_cache: dict[tuple[object, ...], list[dict[str, object]]] = {}
|
||||
self._face_polydata_cache: dict[tuple[object, ...], object] = {}
|
||||
self._edge_polydata_cache: dict[tuple[object, ...], object] = {}
|
||||
self._polydata_cache_limit = 96
|
||||
@@ -137,6 +140,13 @@ class StepModel(FeatureMixin, ExportMixin, TransformMixin, OperationMixin, Polyd
|
||||
self._face_mesh_deflections: dict[int, float] = {}
|
||||
self.refresh_topology()
|
||||
|
||||
@classmethod
|
||||
def from_shape(cls, filename: str | Path, shape: TopoDS_Shape, *, name: str | None = None) -> "StepModel":
|
||||
path = Path(filename)
|
||||
part_name = name or path.stem or "model"
|
||||
parts = [PartNode(1, part_name, "part", shape, path=part_name)]
|
||||
return cls(path, parts, shape)
|
||||
|
||||
@classmethod
|
||||
def load(cls, filename: str | Path) -> "StepModel":
|
||||
path = Path(filename)
|
||||
@@ -151,6 +161,13 @@ class StepModel(FeatureMixin, ExportMixin, TransformMixin, OperationMixin, Polyd
|
||||
parts = [PartNode(1, fallback_name, "part", whole_shape, path=fallback_name)]
|
||||
return cls(path, parts, whole_shape)
|
||||
|
||||
@classmethod
|
||||
def load_internal_brep(cls, filename: str | Path) -> "StepModel":
|
||||
path = Path(filename)
|
||||
if not path.exists():
|
||||
raise FileNotFoundError(path)
|
||||
return cls.from_shape(path, _load_brep_shape(path), name=path.stem)
|
||||
|
||||
def display_parts(self) -> list[PartNode]:
|
||||
leaf_parts = [p for p in self.parts if p.kind == "part" and not p.shape.IsNull()]
|
||||
if leaf_parts:
|
||||
@@ -220,6 +237,8 @@ class StepModel(FeatureMixin, ExportMixin, TransformMixin, OperationMixin, Polyd
|
||||
self._edge_duplicate_key_ids_cache = None
|
||||
self._same_domain_internal_edge_ids_cache = None
|
||||
self._same_domain_duplicate_edge_ids_cache = None
|
||||
self._editable_feature_candidates_cache.clear()
|
||||
self._cylindrical_feature_candidates_cache.clear()
|
||||
self._face_polydata_cache.clear()
|
||||
self._edge_polydata_cache.clear()
|
||||
self._mesh_deflection = None
|
||||
|
||||
Reference in New Issue
Block a user