Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -135,7 +135,7 @@ def exclude_scaling_box(
|
|
| 135 |
|
| 136 |
def resample_contour(contour):
|
| 137 |
# Get all the parameters at the start:
|
| 138 |
-
num_points =
|
| 139 |
smoothing_factor = 5
|
| 140 |
spline_degree = 3 # Typically k=3 for cubic spline
|
| 141 |
|
|
@@ -171,14 +171,11 @@ def save_dxf_spline(inflated_contours, scaling_factor, height):
|
|
| 171 |
msp = doc.modelspace()
|
| 172 |
|
| 173 |
for contour in inflated_contours:
|
| 174 |
-
# Ensure contour has enough points
|
| 175 |
-
if len(contour) < degree + 1:
|
| 176 |
-
raise gr.Error(f"Contour must have at least {degree + 1} points, but has {len(contour)} points.")
|
| 177 |
try:
|
| 178 |
-
|
| 179 |
points = [
|
| 180 |
(x * scaling_factor, (height - y) * scaling_factor)
|
| 181 |
-
for x, y in
|
| 182 |
]
|
| 183 |
if len(points) >= 3:
|
| 184 |
if np.linalg.norm(np.array(points[0]) - np.array(points[-1])) > 1e-2:
|
|
|
|
| 135 |
|
| 136 |
def resample_contour(contour):
|
| 137 |
# Get all the parameters at the start:
|
| 138 |
+
num_points = 800
|
| 139 |
smoothing_factor = 5
|
| 140 |
spline_degree = 3 # Typically k=3 for cubic spline
|
| 141 |
|
|
|
|
| 171 |
msp = doc.modelspace()
|
| 172 |
|
| 173 |
for contour in inflated_contours:
|
|
|
|
|
|
|
|
|
|
| 174 |
try:
|
| 175 |
+
resampled_contour = resample_contour(contour)
|
| 176 |
points = [
|
| 177 |
(x * scaling_factor, (height - y) * scaling_factor)
|
| 178 |
+
for x, y in resampled_contour
|
| 179 |
]
|
| 180 |
if len(points) >= 3:
|
| 181 |
if np.linalg.norm(np.array(points[0]) - np.array(points[-1])) > 1e-2:
|