Skip to content
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

More shape/free func improvements #1692

Merged
merged 62 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c592ce8
Initial commit of better paramAt, solid and a new function check
adam-urbanczyk Sep 25, 2024
1dd7481
mypy fix
adam-urbanczyk Sep 25, 2024
3e9d30f
isSolid fix
adam-urbanczyk Sep 25, 2024
6ba8b72
Implement outerShell, innerShells
adam-urbanczyk Sep 25, 2024
44cb068
Imports cleanup
adam-urbanczyk Sep 25, 2024
bac0c7a
Typo fix
adam-urbanczyk Sep 25, 2024
12c5e0e
Make paramAt fully compatibile with Wires
adam-urbanczyk Sep 26, 2024
b820c3a
Typo fix
adam-urbanczyk Sep 26, 2024
908064b
Add check test
adam-urbanczyk Sep 26, 2024
eda0d3f
Fix orientation handling
adam-urbanczyk Sep 26, 2024
5330777
Add test
adam-urbanczyk Sep 26, 2024
151a70b
paramAt test
adam-urbanczyk Sep 27, 2024
a39a8cc
More tests
adam-urbanczyk Sep 27, 2024
c6d372e
Add orientation fix and optimize check
adam-urbanczyk Oct 1, 2024
06aa44f
Switch to miniforge
adam-urbanczyk Oct 1, 2024
de5cc76
Add missing newline
adam-urbanczyk Oct 8, 2024
a894918
Use OBB (perf) and modified frenet
adam-urbanczyk Oct 20, 2024
520afc5
Merge branch 'shape-improvements' of https://github.com/CadQuery/cadq…
adam-urbanczyk Oct 20, 2024
56d9cbe
Merge branch 'master' into shape-improvements
adam-urbanczyk Oct 20, 2024
6f3e93e
overload normalAt for parameters
adam-urbanczyk Oct 21, 2024
aabe46d
bulk normals calculation
adam-urbanczyk Oct 21, 2024
0446dcf
workaround for bad fonts
adam-urbanczyk Oct 21, 2024
8179a00
first pass at loft to vertex
adam-urbanczyk Oct 22, 2024
a3e87af
Add trim and more loft to vertex tweaks
adam-urbanczyk Oct 22, 2024
9af29a2
Some mypy fixes
adam-urbanczyk Oct 23, 2024
4e4ef16
Loft improvements and sewing fixes.
adam-urbanczyk Oct 24, 2024
2707a7d
Add loft to vertox to workplane
adam-urbanczyk Oct 24, 2024
36009e1
Add dummy kwargs for better unified codebase support (raw / CQ-editor)
adam-urbanczyk Oct 24, 2024
c7e676d
Add continuity
adam-urbanczyk Oct 24, 2024
ec7757e
Use seperate builders for loft
adam-urbanczyk Oct 27, 2024
3f96f18
Add parametrization to loft and aux spine to sweep
adam-urbanczyk Oct 27, 2024
d79f171
Add params to spline interpolation
adam-urbanczyk Oct 27, 2024
d00f113
Add missing arg
adam-urbanczyk Oct 31, 2024
64d88af
Add tol and smoothing
adam-urbanczyk Nov 1, 2024
0584b37
Fix cap handling
adam-urbanczyk Nov 7, 2024
e5ff3bc
Fix crash
adam-urbanczyk Nov 7, 2024
8410af5
Fix loft args
adam-urbanczyk Nov 7, 2024
198013e
Typo
adam-urbanczyk Nov 7, 2024
e302135
Fix test
adam-urbanczyk Nov 7, 2024
750ea3b
Fix show test
adam-urbanczyk Nov 7, 2024
bc5b987
2nd show fix
adam-urbanczyk Nov 7, 2024
3a02fe0
Some loft tests
adam-urbanczyk Nov 7, 2024
de6dd89
Logic fix
adam-urbanczyk Nov 8, 2024
4b6e84d
Add curvature calculation
adam-urbanczyk Nov 9, 2024
649f8f0
Add multimethod docstrings
adam-urbanczyk Nov 9, 2024
f60ea78
Some tests
adam-urbanczyk Nov 9, 2024
23a5c2e
Add and fix tests
adam-urbanczyk Nov 9, 2024
5040668
More tests
adam-urbanczyk Nov 9, 2024
334bc2b
Another overload
adam-urbanczyk Nov 9, 2024
452032b
Loft to vertex tests
adam-urbanczyk Nov 9, 2024
5db25e6
Imporve coverage
adam-urbanczyk Nov 9, 2024
859572b
Remove dead code
adam-urbanczyk Nov 9, 2024
a0c2f08
Readd code with better explanation
adam-urbanczyk Nov 9, 2024
57bc5ed
Better coverage
adam-urbanczyk Nov 9, 2024
938fed6
Extend vis
adam-urbanczyk Nov 9, 2024
5d2d901
Mypy fixes
adam-urbanczyk Nov 9, 2024
94b67e5
Add alpha
adam-urbanczyk Nov 9, 2024
4b227a5
Mypy fix
adam-urbanczyk Nov 9, 2024
ff3fea5
Fix vtk rotation order
adam-urbanczyk Nov 9, 2024
4af1dd1
Second vtk rot fix
adam-urbanczyk Nov 9, 2024
cc5ccfd
Merge branch 'master' into shape-improvements
adam-urbanczyk Nov 10, 2024
1fcefa4
Typo fixes
adam-urbanczyk Nov 11, 2024
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
36 changes: 31 additions & 5 deletions cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
from .occ_impl.geom import Vector, Plane, Location
from .occ_impl.shapes import (
Shape,
Vertex,
Edge,
Wire,
Face,
Solid,
Compound,
wiresToFaces,
Shapes,
loft,
)

from .occ_impl.exporters.svg import getSVG, exportSVG
Expand Down Expand Up @@ -3697,15 +3699,22 @@ def loft(

"""

toLoft: List[Union[Wire, Vertex]] = []

if self.ctx.pendingWires:
wiresToLoft = self.ctx.popPendingWires()
toLoft.extend(self.ctx.popPendingWires())
else:
wiresToLoft = [f.outerWire() for f in self._getFaces()]
toLoft = [
el if isinstance(el, Vertex) else el.outerWire()
for el in self._getFacesVertices()
]

if not wiresToLoft:
if not toLoft:
raise ValueError("Nothing to loft")
elif len(toLoft) == 1:
raise ValueError("More than one wire or face is required")

r: Shape = Solid.makeLoft(wiresToLoft, ruled)
r: Shape = loft(toLoft, cap=True, ruled=ruled)

newS = self._combineWithBase(r, combine, clean)

Expand All @@ -3731,6 +3740,23 @@ def _getFaces(self) -> List[Face]:

return rv

def _getFacesVertices(self) -> List[Union[Face, Vertex]]:
"""
Convert pending wires or sketches to faces/vertices for subsequent operation
"""

rv: List[Union[Face, Vertex]] = []

for el in self.objects:
if isinstance(el, Sketch):
rv.extend(el)
elif isinstance(el, (Face, Vertex)):
rv.append(el)
elif isinstance(el, Compound):
rv.extend(subel for subel in el if isinstance(subel, (Face, Vertex)))

return rv

def _extrude(
self,
distance: Optional[float] = None,
Expand Down Expand Up @@ -4574,7 +4600,7 @@ def export(
) -> T:
"""
Export Workplane to file.

:param path: Filename.
:param tolerance: the deflection tolerance, in model units. Default 0.1.
:param angularTolerance: the angular tolerance, in radians. Default 0.1.
Expand Down
31 changes: 21 additions & 10 deletions cadquery/occ_impl/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,23 @@ def _toCAF(el, ancestor, color) -> TDF_Label:
return top, doc


def _loc2vtk(
loc: Location,
) -> Tuple[Tuple[float, float, float], Tuple[float, float, float]]:
"""
Convert location to t,rot pair following vtk conventions
"""

T = loc.wrapped.Transformation()

trans = T.TranslationPart().Coord()
rot = tuple(
map(degrees, T.GetRotation().GetEulerAngles(gp_EulerSequence.gp_Intrinsic_ZXY),)
)

return trans, (rot[1], rot[2], rot[0])


def toVTK(
assy: AssemblyProtocol,
color: Tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0),
Expand All @@ -273,14 +290,8 @@ def toVTK(
for shape, _, loc, col_ in assy:

col = col_.toTuple() if col_ else color
T = loc.wrapped.Transformation()
trans = T.TranslationPart().Coord()
rot = tuple(
map(
degrees,
T.GetRotation().GetEulerAngles(gp_EulerSequence.gp_Intrinsic_ZXY),
)
)

trans, rot = _loc2vtk(loc)

data = shape.toVtkPolyData(tolerance, angularTolerance)

Expand Down Expand Up @@ -311,7 +322,7 @@ def toVTK(
actor = vtkActor()
actor.SetMapper(mapper)
actor.SetPosition(*trans)
actor.SetOrientation(rot[1], rot[2], rot[0])
actor.SetOrientation(*rot)
actor.GetProperty().SetColor(*col[:3])
actor.GetProperty().SetOpacity(col[3])

Expand All @@ -323,7 +334,7 @@ def toVTK(
actor = vtkActor()
actor.SetMapper(mapper)
actor.SetPosition(*trans)
actor.SetOrientation(rot[1], rot[2], rot[0])
actor.SetOrientation(*rot)
actor.GetProperty().SetColor(0, 0, 0)
actor.GetProperty().SetLineWidth(2)

Expand Down
Loading