MCPcopy
hub / github.com/CadQuery/cadquery / loft

Function loft

cadquery/occ_impl/nurbs.py:2064–2108  ·  view source on GitHub ↗

Regular (non-periodic) loft form curves.

(
    *curves: Curve,
    order: int = 3,
    lam: float = 1e-9,
    penalty: int = 4,
    tangents: Optional[List[Tuple[Array, Array]]] = None,
)

Source from the content-addressed store, hash-verified

2062
2063
2064def loft(
2065 *curves: Curve,
2066 order: int = 3,
2067 lam: float = 1e-9,
2068 penalty: int = 4,
2069 tangents: Optional[List[Tuple[Array, Array]]] = None,
2070) -> Surface:
2071 """
2072 Regular (non-periodic) loft form curves.
2073 """
2074
2075 nknots: int = len(curves)
2076
2077 # collect control pts
2078 pts = np.stack([c.pts for c in curves])
2079
2080 # approximate
2081 pts_new = []
2082
2083 for j in range(pts.shape[1]):
2084 pts_new.append(
2085 approximate(
2086 pts[:, j, :],
2087 knots=nknots,
2088 order=order,
2089 lam=lam,
2090 penalty=penalty,
2091 tangents=tangents[j] if tangents else None,
2092 ).pts
2093 )
2094
2095 # construct the final surface
2096 rv = Surface(
2097 np.stack(pts_new).swapaxes(0, 1),
2098 np.concatenate(
2099 (np.repeat(0, order), linspace(0, 1, nknots), np.repeat(1, order))
2100 ),
2101 curves[0].knots,
2102 order,
2103 curves[0].order,
2104 False,
2105 curves[0].periodic,
2106 )
2107
2108 return rv

Callers 5

test_loftFunction · 0.90
loftMethod · 0.50
test_loftFunction · 0.50
test_loft_vertexFunction · 0.50
test_history_loftFunction · 0.50

Calls 3

approximateFunction · 0.85
SurfaceClass · 0.85
appendMethod · 0.80

Tested by 4

test_loftFunction · 0.72
test_loftFunction · 0.40
test_loft_vertexFunction · 0.40
test_history_loftFunction · 0.40