导出step文件合并为整体,方便后续修改
This commit is contained in:
@@ -6,6 +6,7 @@ import json
|
||||
from utils.logger import get_logger
|
||||
from OCC.Core.GProp import GProp_GProps
|
||||
from OCC.Core.BRepGProp import brepgprop
|
||||
from OCC.Core.TopoDS import TopoDS_Shape
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -29,7 +30,7 @@ class STPParser:
|
||||
|
||||
|
||||
|
||||
def load_step_file(self, file_path: Path) -> Any:
|
||||
def load_step_file(self, file_path: Path) -> TopoDS_Shape:
|
||||
"""加载STP文件"""
|
||||
try:
|
||||
from OCC.Core.STEPControl import STEPControl_Reader
|
||||
@@ -51,7 +52,7 @@ class STPParser:
|
||||
logger.error(f"STP解析失败: {e}")
|
||||
raise
|
||||
|
||||
def analyze_geometry(self, shape) -> Dict[str, Any]:
|
||||
def analyze_geometry(self, shape: TopoDS_Shape) -> Dict[str, Any]:
|
||||
"""分析几何属性"""
|
||||
|
||||
try:
|
||||
@@ -97,7 +98,7 @@ class STPParser:
|
||||
logger.error(f"几何分析失败: {e}")
|
||||
raise
|
||||
|
||||
def _compute_bounding_box(self, shape) -> Dict[str, Any]:
|
||||
def _compute_bounding_box(self, shape: TopoDS_Shape) -> Dict[str, Any]:
|
||||
"""计算边界框"""
|
||||
try:
|
||||
from OCC.Core.Bnd import Bnd_Box
|
||||
@@ -125,7 +126,7 @@ class STPParser:
|
||||
logger.error(f"边界框计算失败: {e}")
|
||||
return self._default_bounding_box()
|
||||
|
||||
def _compute_volume(self, shape) -> float:
|
||||
def _compute_volume(self, shape: TopoDS_Shape) -> float:
|
||||
"""计算体积"""
|
||||
try:
|
||||
from OCC.Core.GProp import GProp_GProps
|
||||
@@ -141,7 +142,7 @@ class STPParser:
|
||||
logger.error(f"体积计算失败: {e}")
|
||||
raise RuntimeError(f"体积计算失败: {e}") from e
|
||||
|
||||
def _compute_surface_area(self, shape) -> float:
|
||||
def _compute_surface_area(self, shape: TopoDS_Shape) -> float:
|
||||
"""计算表面积"""
|
||||
try:
|
||||
from OCC.Core.GProp import GProp_GProps
|
||||
@@ -175,7 +176,7 @@ class STPParser:
|
||||
logger.error(f"表面积计算失败: {e}")
|
||||
raise RuntimeError(f"表面积计算失败: {e}") from e
|
||||
|
||||
def _compute_center_of_mass(self, shape) -> List[float]:
|
||||
def _compute_center_of_mass(self, shape: TopoDS_Shape) -> List[float]:
|
||||
"""计算质心"""
|
||||
try:
|
||||
from OCC.Core.GProp import GProp_GProps
|
||||
@@ -194,7 +195,7 @@ class STPParser:
|
||||
except Exception:
|
||||
raise RuntimeError(f"质心计算失败且边界框回退也失败: {e}") from e
|
||||
|
||||
def _compute_inertia_properties(self, shape) -> Dict[str, Any]:
|
||||
def _compute_inertia_properties(self, shape: TopoDS_Shape) -> Dict[str, Any]:
|
||||
"""计算惯性属性"""
|
||||
try:
|
||||
from OCC.Core.GProp import GProp_GProps
|
||||
@@ -216,7 +217,7 @@ class STPParser:
|
||||
logger.error(f"惯性属性计算失败: {e}")
|
||||
return {}
|
||||
|
||||
def _analyze_topology(self, shape) -> Dict[str, int]:
|
||||
def _analyze_topology(self, shape: TopoDS_Shape) -> Dict[str, int]:
|
||||
"""分析拓扑"""
|
||||
try:
|
||||
from OCC.Core.TopExp import TopExp_Explorer
|
||||
|
||||
Reference in New Issue
Block a user