mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-05 18:20:46 -08:00
Fixed typing and linting issues
Some checks are pending
benchmarks / benchmarks (macos-14, 3.12) (push) Waiting to run
benchmarks / benchmarks (macos-15-intel, 3.12) (push) Waiting to run
benchmarks / benchmarks (ubuntu-latest, 3.12) (push) Waiting to run
benchmarks / benchmarks (windows-latest, 3.12) (push) Waiting to run
Upload coverage reports to Codecov / run (push) Waiting to run
pylint / lint (3.10) (push) Waiting to run
Run type checker / typecheck (3.10) (push) Waiting to run
Run type checker / typecheck (3.13) (push) Waiting to run
Wheel building and publishing / Build wheel on ubuntu-latest (push) Waiting to run
Wheel building and publishing / upload_pypi (push) Blocked by required conditions
tests / tests (macos-14, 3.10) (push) Waiting to run
tests / tests (macos-14, 3.13) (push) Waiting to run
tests / tests (macos-15-intel, 3.10) (push) Waiting to run
tests / tests (macos-15-intel, 3.13) (push) Waiting to run
tests / tests (ubuntu-latest, 3.10) (push) Waiting to run
tests / tests (ubuntu-latest, 3.13) (push) Waiting to run
tests / tests (windows-latest, 3.10) (push) Waiting to run
tests / tests (windows-latest, 3.13) (push) Waiting to run
Some checks are pending
benchmarks / benchmarks (macos-14, 3.12) (push) Waiting to run
benchmarks / benchmarks (macos-15-intel, 3.12) (push) Waiting to run
benchmarks / benchmarks (ubuntu-latest, 3.12) (push) Waiting to run
benchmarks / benchmarks (windows-latest, 3.12) (push) Waiting to run
Upload coverage reports to Codecov / run (push) Waiting to run
pylint / lint (3.10) (push) Waiting to run
Run type checker / typecheck (3.10) (push) Waiting to run
Run type checker / typecheck (3.13) (push) Waiting to run
Wheel building and publishing / Build wheel on ubuntu-latest (push) Waiting to run
Wheel building and publishing / upload_pypi (push) Blocked by required conditions
tests / tests (macos-14, 3.10) (push) Waiting to run
tests / tests (macos-14, 3.13) (push) Waiting to run
tests / tests (macos-15-intel, 3.10) (push) Waiting to run
tests / tests (macos-15-intel, 3.13) (push) Waiting to run
tests / tests (ubuntu-latest, 3.10) (push) Waiting to run
tests / tests (ubuntu-latest, 3.13) (push) Waiting to run
tests / tests (windows-latest, 3.10) (push) Waiting to run
tests / tests (windows-latest, 3.13) (push) Waiting to run
This commit is contained in:
parent
8985220c79
commit
5adf296fd8
2 changed files with 31 additions and 16 deletions
|
|
@ -56,8 +56,7 @@ from __future__ import annotations
|
|||
|
||||
from collections.abc import Iterable, Sequence
|
||||
from math import radians, cos, tan
|
||||
from typing import TYPE_CHECKING, Literal, overload
|
||||
from typing import cast as tcast
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
from typing_extensions import Self
|
||||
|
||||
import OCP.TopAbs as ta
|
||||
|
|
@ -118,7 +117,6 @@ from .shape_core import (
|
|||
Shape,
|
||||
ShapeList,
|
||||
Joint,
|
||||
TrimmingTool,
|
||||
downcast,
|
||||
shapetype,
|
||||
_sew_topods_faces,
|
||||
|
|
@ -137,7 +135,7 @@ from .zero_d import Vertex
|
|||
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from .composite import Compound, Curve, Sketch, Part # pylint: disable=R0801
|
||||
from .composite import Compound # pylint: disable=R0801
|
||||
|
||||
|
||||
class Mixin3D(Shape[TOPODS]):
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ from abc import ABC, abstractmethod
|
|||
from collections.abc import Iterable, Sequence
|
||||
from math import degrees
|
||||
from typing import TYPE_CHECKING, Any, TypeVar, overload
|
||||
from typing import cast as tcast
|
||||
|
||||
import OCP.TopAbs as ta
|
||||
from OCP.BRep import BRep_Builder, BRep_Tool
|
||||
|
|
@ -104,6 +105,7 @@ from OCP.Standard import (
|
|||
Standard_ConstructionError,
|
||||
Standard_Failure,
|
||||
Standard_NoSuchObject,
|
||||
Standard_TypeMismatch,
|
||||
)
|
||||
from OCP.StdFail import StdFail_NotDone
|
||||
from OCP.TColgp import TColgp_Array1OfPnt, TColgp_HArray2OfPnt
|
||||
|
|
@ -217,7 +219,7 @@ class Mixin2D(ABC, Shape[TOPODS]):
|
|||
if self._wrapped is None:
|
||||
raise ValueError("Invalid Shape")
|
||||
new_surface = copy.deepcopy(self)
|
||||
new_surface.wrapped = downcast(self.wrapped.Complemented())
|
||||
new_surface.wrapped = tcast(TOPODS, downcast(self.wrapped.Complemented()))
|
||||
|
||||
# As the surface has been modified, the parent is no longer valid
|
||||
new_surface.topo_parent = None
|
||||
|
|
@ -366,7 +368,9 @@ class Mixin2D(ABC, Shape[TOPODS]):
|
|||
for obj in common_set:
|
||||
match (obj, target):
|
||||
case (_, Vertex() | Edge() | Wire() | Face() | Shell()):
|
||||
operation = BRepAlgoAPI_Section()
|
||||
operation: BRepAlgoAPI_Section | BRepAlgoAPI_Common = (
|
||||
BRepAlgoAPI_Section()
|
||||
)
|
||||
result = bool_op((obj,), (target,), operation)
|
||||
if not isinstance(obj, Edge | Wire) and not isinstance(
|
||||
target, (Edge | Wire)
|
||||
|
|
@ -604,6 +608,7 @@ class Face(Mixin2D[TopoDS_Face]):
|
|||
"""
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any):
|
||||
obj: TopoDS_Face | Plane | None
|
||||
outer_wire, inner_wires, obj, label, color, parent = (None,) * 6
|
||||
|
||||
if args:
|
||||
|
|
@ -1463,7 +1468,7 @@ class Face(Mixin2D[TopoDS_Face]):
|
|||
|
||||
try:
|
||||
patch.Build()
|
||||
result = cls(patch.Shape())
|
||||
result = cls(TopoDS.Face_s(patch.Shape()))
|
||||
except (
|
||||
Standard_Failure,
|
||||
StdFail_NotDone,
|
||||
|
|
@ -1579,8 +1584,12 @@ class Face(Mixin2D[TopoDS_Face]):
|
|||
|
||||
if len(profile.edges()) != 1 or len(path.edges()) != 1:
|
||||
raise ValueError("Use Shell.sweep for multi Edge objects")
|
||||
profile = Wire([profile.edge()])
|
||||
path = Wire([path.edge()])
|
||||
profile_edge = profile.edge()
|
||||
path_edge = path.edge()
|
||||
assert profile_edge is not None
|
||||
assert path_edge is not None
|
||||
profile = Wire([profile_edge])
|
||||
path = Wire([path_edge])
|
||||
builder = BRepOffsetAPI_MakePipeShell(path.wrapped)
|
||||
builder.Add(profile.wrapped, False, False)
|
||||
builder.SetTransitionMode(Shape._transModeDict[transition])
|
||||
|
|
@ -1604,6 +1613,7 @@ class Face(Mixin2D[TopoDS_Face]):
|
|||
Returns:
|
||||
Vector: center
|
||||
"""
|
||||
center_point: Vector | gp_Pnt
|
||||
if (center_of == CenterOf.MASS) or (
|
||||
center_of == CenterOf.GEOMETRY and self.is_planar
|
||||
):
|
||||
|
|
@ -1663,7 +1673,10 @@ class Face(Mixin2D[TopoDS_Face]):
|
|||
|
||||
# Index or iterator access to OCP.TopTools.TopTools_ListOfShape is slow on M1 macs
|
||||
# Using First() and Last() to omit
|
||||
edges = (Edge(edge_list.First()), Edge(edge_list.Last()))
|
||||
edges = (
|
||||
Edge(TopoDS.Edge_s(edge_list.First())),
|
||||
Edge(TopoDS.Edge_s(edge_list.Last())),
|
||||
)
|
||||
|
||||
edge1, edge2 = Wire.order_chamfer_edges(reference_edge, edges)
|
||||
|
||||
|
|
@ -2053,7 +2066,7 @@ class Face(Mixin2D[TopoDS_Face]):
|
|||
BRepAlgoAPI_Common(),
|
||||
)
|
||||
for topods_shell in get_top_level_topods_shapes(topods_shape):
|
||||
intersected_shapes.append(Shell(topods_shell))
|
||||
intersected_shapes.append(Shell(TopoDS.Shell_s(topods_shell)))
|
||||
|
||||
intersected_shapes = intersected_shapes.sort_by(Axis(self.center(), direction))
|
||||
projected_shapes: ShapeList[Face | Shell] = ShapeList()
|
||||
|
|
@ -2110,7 +2123,7 @@ class Face(Mixin2D[TopoDS_Face]):
|
|||
for hole_wire in inner_wires:
|
||||
reshaper.Remove(hole_wire.wrapped)
|
||||
modified_shape = downcast(reshaper.Apply(self.wrapped))
|
||||
holeless.wrapped = modified_shape
|
||||
holeless.wrapped = TopoDS.Face_s(modified_shape)
|
||||
return holeless
|
||||
|
||||
def wire(self) -> Wire:
|
||||
|
|
@ -2513,7 +2526,10 @@ class Shell(Mixin2D[TopoDS_Shell]):
|
|||
builder.Add(shell, obj.wrapped)
|
||||
obj = shell
|
||||
elif isinstance(obj, Iterable):
|
||||
obj = _sew_topods_faces([f.wrapped for f in obj])
|
||||
try:
|
||||
obj = TopoDS.Shell_s(_sew_topods_faces([f.wrapped for f in obj]))
|
||||
except Standard_TypeMismatch:
|
||||
raise TypeError("Unable to create Shell, invalid input type")
|
||||
|
||||
super().__init__(
|
||||
obj=obj,
|
||||
|
|
@ -2531,6 +2547,7 @@ class Shell(Mixin2D[TopoDS_Shell]):
|
|||
solid_shell = ShapeFix_Solid().SolidFromShell(self.wrapped)
|
||||
properties = GProp_GProps()
|
||||
calc_function = Shape.shape_properties_LUT[shapetype(solid_shell)]
|
||||
assert calc_function is not None
|
||||
calc_function(solid_shell, properties)
|
||||
return properties.Mass()
|
||||
return 0.0
|
||||
|
|
@ -2573,7 +2590,7 @@ class Shell(Mixin2D[TopoDS_Shell]):
|
|||
Returns:
|
||||
Shell: Lofted object
|
||||
"""
|
||||
return cls(_make_loft(objs, False, ruled))
|
||||
return cls(TopoDS.Shell_s(_make_loft(objs, False, ruled)))
|
||||
|
||||
@classmethod
|
||||
def revolve(
|
||||
|
|
@ -2599,7 +2616,7 @@ class Shell(Mixin2D[TopoDS_Shell]):
|
|||
profile.wrapped, axis.wrapped, angle * DEG2RAD, True
|
||||
)
|
||||
|
||||
return cls(revol_builder.Shape())
|
||||
return cls(TopoDS.Shell_s(revol_builder.Shape()))
|
||||
|
||||
@classmethod
|
||||
def sweep(
|
||||
|
|
@ -2627,7 +2644,7 @@ class Shell(Mixin2D[TopoDS_Shell]):
|
|||
builder.Add(profile.wrapped, False, False)
|
||||
builder.SetTransitionMode(Shape._transModeDict[transition])
|
||||
builder.Build()
|
||||
result = Shell(builder.Shape())
|
||||
result = Shell(TopoDS.Shell_s(builder.Shape()))
|
||||
if SkipClean.clean:
|
||||
result = result.clean()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue