Открыть боковую панель
nikitronn
sverchok
Коммиты
263db215
Коммит
263db215
создал
Июн 26, 2021
по автору
Ilya Portnov
Просмотр файлов
Tunes.
владелец
3fac45fd
Изменения
4
Скрыть пробелы
Построчно
Рядом
utils/curve/nurbs_algorithms.py
Просмотр файла @
263db215
...
...
@@ -8,6 +8,9 @@
import
numpy
as
np
from
collections
import
defaultdict
from
mathutils
import
Vector
import
mathutils.geometry
from
sverchok.utils.geom
import
Spline
,
linear_approximation
,
intersect_segment_segment
from
sverchok.utils.nurbs_common
import
SvNurbsBasisFunctions
,
SvNurbsMaths
,
from_homogenous
from
sverchok.utils.curve
import
knotvector
as
sv_knotvector
...
...
@@ -191,6 +194,14 @@ def _check_is_line(curve, eps=0.001):
return
(
cpts
[
0
],
cpts
[
-
1
])
def
intersect_segment_segment_mu
(
v1
,
v2
,
v3
,
v4
):
tolerance
=
1e-3
r1
,
r2
=
mathutils
.
geometry
.
intersect_line_line
(
v1
,
v2
,
v3
,
v4
)
if
(
r1
-
r2
).
length
<
tolerance
:
v
=
0.5
*
(
r1
+
r2
)
return
np
.
array
(
v
)
return
None
def
_intersect_curves_equation
(
curve1
,
curve2
):
t1_min
,
t1_max
=
curve1
.
get_u_bounds
()
t2_min
,
t2_max
=
curve2
.
get_u_bounds
()
...
...
@@ -207,6 +218,7 @@ def _intersect_curves_equation(curve1, curve2):
#print(f"Call L: [{t1_min} - {t1_max}] x [{t2_min} - {t2_max}]")
r
=
intersect_segment_segment
(
v1
,
v2
,
v3
,
v4
)
if
not
r
:
#print(f"({v1} - {v2}) x ({v3} - {v4}): no intersection")
return
[]
else
:
u
,
v
,
pt
=
r
...
...
@@ -263,7 +275,8 @@ def intersect_nurbs_curves(curve1, curve2):
THRESHOLD
=
0.01
if
bbox1
.
size
()
<
THRESHOLD
and
bbox2
.
size
()
<
THRESHOLD
:
#if bbox1.size() < THRESHOLD and bbox2.size() < THRESHOLD:
if
_check_is_line
(
curve1
)
and
_check_is_line
(
curve2
):
return
_intersect_curves_equation
(
curve1
,
curve2
)
mid1
=
(
t1_min
+
t1_max
)
*
0.5
...
...
utils/geom.py
Просмотр файла @
263db215
...
...
@@ -1276,7 +1276,7 @@ class LineEquation(object):
projections
=
projection_lengths
*
unit_direction
return
center
+
projections
def
intersect_segment_segment
(
v1
,
v2
,
v3
,
v4
,
tolerance
=
1e-
6
):
def
intersect_segment_segment
(
v1
,
v2
,
v3
,
v4
,
endpoint_
tolerance
=
1e-
3
):
x1
,
y1
,
z1
=
v1
x2
,
y2
,
z2
=
v2
x3
,
y3
,
z3
=
v3
...
...
@@ -1303,7 +1303,8 @@ def intersect_segment_segment(v1, v2, v3, v4, tolerance=1e-6):
u
=
num1
/
denom
v
=
num2
/
denom
if
not
((
0.0
-
tolerance
<=
u
<=
1.0
+
tolerance
)
and
(
0.0
-
tolerance
<=
v
<=
1.0
+
tolerance
)):
et
=
endpoint_tolerance
if
not
((
0.0
-
et
<=
u
<=
1.0
+
et
)
and
(
0.0
-
et
<=
v
<=
1.0
+
et
)):
return
None
x
=
u
*
(
x1
-
x2
)
+
x2
...
...
utils/surface/algorithms.py
Просмотр файла @
263db215
...
...
@@ -1081,7 +1081,7 @@ def unify_nurbs_surfaces(surfaces):
degree_u
=
max
(
degrees_u
)
degree_v
=
max
(
degrees_v
)
print
(
f
"Elevate everything to
{
degree_u
}
x
{
degree_v
}
"
)
#
print(f"Elevate everything to {degree_u}x{degree_v}")
surfaces
=
[
surface
.
elevate_degree
(
SvNurbsSurface
.
U
,
target
=
degree_u
)
for
surface
in
surfaces
]
surfaces
=
[
surface
.
elevate_degree
(
SvNurbsSurface
.
V
,
target
=
degree_v
)
for
surface
in
surfaces
]
...
...
@@ -1126,7 +1126,6 @@ def unify_nurbs_surfaces(surfaces):
for
v
,
diff
in
diffs_v
:
if
diff
>
0
:
print
(
f
"KV
{
surface
.
get_knotvector_v
()
}
, insert
{
v
}
x
{
diff
}
"
)
surface
=
surface
.
insert_knot
(
SvNurbsSurface
.
V
,
v
,
diff
)
result
.
append
(
surface
)
...
...
utils/surface/gordon.py
Просмотр файла @
263db215
...
...
@@ -22,8 +22,8 @@ def gordon_surface_impl(u_curves, v_curves, intersections, degree_u=None, degree
if
degree_v
is
None
:
degree_v
=
v_curves
[
0
].
get_degree
()
u_curves
=
[
c
.
reparametrize
(
0.0
,
1.0
)
for
c
in
u_curves
]
v_curves
=
[
c
.
reparametrize
(
0.0
,
1.0
)
for
c
in
v_curves
]
#
u_curves = [c.reparametrize(0.0, 1.0) for c in u_curves]
#
v_curves = [c.reparametrize(0.0, 1.0) for c in v_curves]
intersections
=
np
.
asarray
(
intersections
)
...
...
@@ -36,11 +36,15 @@ def gordon_surface_impl(u_curves, v_curves, intersections, degree_u=None, degree
knots
=
np
.
array
([
Spline
.
create_knots
(
intersections
[:,
j
],
metric
=
metric
)
for
j
in
range
(
m
)])
v_knots
=
knots
.
mean
(
axis
=
0
)
_
,
_
,
lofted_v
=
simple_loft
(
u_curves
,
degree_v
=
degree_
v
,
tknots
=
u_knots
)
_
,
_
,
lofted_u
=
simple_loft
(
v_curves
,
degree_v
=
degree_
u
,
tknots
=
v_knots
)
_
,
_
,
lofted_v
=
simple_loft
(
u_curves
,
degree_v
=
degree_
u
,
tknots
=
u_knots
)
_
,
_
,
lofted_u
=
simple_loft
(
v_curves
,
degree_v
=
degree_
v
,
tknots
=
v_knots
)
lofted_u
=
lofted_u
.
swap_uv
()
interpolated
=
interpolate_nurbs_surface
(
degree_u
,
degree_v
,
intersections
,
uknots
=
u_knots
,
vknots
=
v_knots
)
# int_degree_u = lofted_u.get_degree_v()
# int_degree_v = lofted_v.get_degree_u()
int_degree_u
=
m
-
1
int_degree_v
=
n
-
1
interpolated
=
interpolate_nurbs_surface
(
int_degree_u
,
int_degree_v
,
intersections
,
uknots
=
u_knots
,
vknots
=
v_knots
)
interpolated
=
interpolated
.
swap_uv
()
print
(
f
"Loft.U:
{
lofted_u
.
get_degree_u
()
}
x
{
lofted_u
.
get_degree_v
()
}
"
)
print
(
f
"
{
lofted_u
.
get_knotvector_u
()
}
"
)
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать