Skip to content

Add more trimming possibilities #1833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
May 13, 2025
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fefcada
Add more trimming possibilities
adam-urbanczyk May 2, 2025
fb0ba33
Expose edge
adam-urbanczyk May 2, 2025
1518cb6
Merge branch 'shapes-trimming' of https://github.com/CadQuery/cadquer…
adam-urbanczyk May 6, 2025
7d353fd
Black fix
adam-urbanczyk May 6, 2025
a75bb0f
Mypy fix
adam-urbanczyk May 6, 2025
3563f0f
Add more trim/edge overloads
adam-urbanczyk May 7, 2025
5bb84d4
Correct handling of periodicity
adam-urbanczyk May 8, 2025
201f7ce
Docstring fix
adam-urbanczyk May 8, 2025
23f654d
Add a test for edge()
adam-urbanczyk May 8, 2025
4bbff85
Rename edge, add wireOn and extend tests
adam-urbanczyk May 9, 2025
b3fe876
Black fix
adam-urbanczyk May 9, 2025
38c5ef0
Test additional overload
adam-urbanczyk May 9, 2025
d9964e4
Fix corner case
adam-urbanczyk May 9, 2025
9988e97
Corner case test
adam-urbanczyk May 9, 2025
3416701
Add hasPCurve()
adam-urbanczyk May 9, 2025
fe1b981
Make uvBounds public
adam-urbanczyk May 10, 2025
aefcf5b
Fix Mixin1DProtocol
adam-urbanczyk May 10, 2025
a002dd0
Add faceOn
adam-urbanczyk May 10, 2025
e4efee3
Add some docs
adam-urbanczyk May 10, 2025
9c0b102
Tweak parameters
adam-urbanczyk May 10, 2025
72a33ca
Doc fix
adam-urbanczyk May 10, 2025
03a4b3d
Doc tweaks
adam-urbanczyk May 10, 2025
4d816f1
Closed edge handling fix
adam-urbanczyk May 10, 2025
1703889
faceOn test
adam-urbanczyk May 10, 2025
f60633f
Add kwargs to faceOn
adam-urbanczyk May 10, 2025
77de8a0
Apply suggestions from code review
adam-urbanczyk May 12, 2025
d6f25d7
Apply suggestions from code review - docs
adam-urbanczyk May 12, 2025
1a9cdac
Fix the fix
adam-urbanczyk May 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mypy fix
  • Loading branch information
adam-urbanczyk committed May 6, 2025
commit a75bb0fe0fc4d83376eb5f9698ea47772732ba86
2 changes: 1 addition & 1 deletion cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3471,7 +3471,7 @@
return Solid(builder.Shape())

@classmethod
def constructOn(cls, f: "Face", outer: "Wire", *inner: "Wire") -> "Face":
def constructOn(cls, f: "Face", outer: "Wire", *inner: "Wire") -> Self:

bldr = BRepBuilderAPI_MakeFace(f._geomAdaptor(), outer.wrapped)

Expand Down Expand Up @@ -3520,33 +3520,33 @@
Trim the face using a polyline defined in the (u,v) space.
"""

segs_uv = []
geom = self._geomAdaptor()

Check warning on line 3524 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3523-L3524

Added lines #L3523 - L3524 were not covered by tests

# build (u,v) segments
for el1, el2 in zip((pt1, pt2, pt3, *pts), (pt2, pt3, *pts, pt1)):
segs_uv.append(GCE2d_MakeSegment(gp_Pnt2d(*el1), gp_Pnt2d(*el2)).Value())

Check warning on line 3528 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3528

Added line #L3528 was not covered by tests

# convert to edges
edges = []

Check warning on line 3531 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3531

Added line #L3531 was not covered by tests

for seg in segs_uv:
edges.append(BRepBuilderAPI_MakeEdge(seg, geom).Edge())

Check warning on line 3534 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3534

Added line #L3534 was not covered by tests

# convert to a wire
builder = BRepBuilderAPI_MakeWire()

Check warning on line 3537 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3537

Added line #L3537 was not covered by tests

tmp = TopTools_ListOfShape()

Check warning on line 3539 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3539

Added line #L3539 was not covered by tests
for edge in edges:
tmp.Append(edge)

Check warning on line 3541 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3541

Added line #L3541 was not covered by tests

builder.Add(tmp)

Check warning on line 3543 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3543

Added line #L3543 was not covered by tests

w = builder.Wire()
BRepLib.BuildCurves3d_s(w)

Check warning on line 3546 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3545-L3546

Added lines #L3545 - L3546 were not covered by tests

# construct the final trimmed face
return self.constructOn(self, Wire(w))

Check warning on line 3549 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L3549

Added line #L3549 was not covered by tests

def isoline(self, param: Real, direction: Literal["u", "v"] = "v") -> Edge:
"""
Expand Down Expand Up @@ -5051,12 +5051,12 @@
Convert a sequence of 2d points to a TColgp harray (OCCT specific).
"""

rv = TColgp_HArray1OfPnt2d(1, len(pts))

Check warning on line 5054 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L5054

Added line #L5054 was not covered by tests

for i, p in enumerate(pts):
rv.SetValue(i + 1, gp_Pnt2d(*p))

Check warning on line 5057 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L5057

Added line #L5057 was not covered by tests

return rv

Check warning on line 5059 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L5059

Added line #L5059 was not covered by tests


def _floats_to_harray(vals: Sequence[float]) -> TColStd_HArray1OfReal:
Expand Down Expand Up @@ -5170,17 +5170,17 @@
Build an edge on a face from points in (u,v) space.
"""

f = _get_one(base, "Face")

Check warning on line 5173 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L5173

Added line #L5173 was not covered by tests

# interpolate the u,v points
spline_bldr = Geom2dAPI_Interpolate(_pts_to_harray2d(pts), periodic, tol)
spline_bldr.Perform()

Check warning on line 5177 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L5176-L5177

Added lines #L5176 - L5177 were not covered by tests

# build the final edge
rv = BRepBuilderAPI_MakeEdge(spline_bldr.Curve(), f._geomAdaptor()).Edge()
BRepLib.BuildCurves3d_s(rv)

Check warning on line 5181 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L5180-L5181

Added lines #L5180 - L5181 were not covered by tests

return _compound_or_shape(rv)

Check warning on line 5183 in cadquery/occ_impl/shapes.py

View check run for this annotation

Codecov / codecov/patch

cadquery/occ_impl/shapes.py#L5183

Added line #L5183 was not covered by tests


@multimethod
Expand Down