Открыть боковую панель
nikitronn
sverchok
Коммиты
b46b45a9
Коммит
b46b45a9
создал
Сен 13, 2022
по автору
Ilya Portnov
Просмотр файлов
"Viewer Draw Surface": ability to display node lines
(i.e. isolines at node values along U and V directions)
владелец
a1d8247d
Изменения
5
Скрыть пробелы
Построчно
Рядом
nodes/viz/viewer_draw_surface.py
Просмотр файла @
b46b45a9
...
@@ -56,6 +56,12 @@ def draw_surfaces(context, args):
...
@@ -56,6 +56,12 @@ def draw_surfaces(context, args):
if
node
.
draw_edges
:
if
node
.
draw_edges
:
draw_edges
(
e_shader
,
item
.
points_list
,
item
.
edges
,
node
.
edges_line_width
,
node
.
edges_color
)
draw_edges
(
e_shader
,
item
.
points_list
,
item
.
edges
,
node
.
edges_line_width
,
node
.
edges_color
)
if
node
.
draw_node_lines
and
item
.
node_u_isoline_data
is
not
None
:
for
line
in
item
.
node_u_isoline_data
:
draw_edges
(
e_shader
,
line
.
points
,
line
.
edges
,
node
.
node_lines_width
,
node
.
node_lines_color
)
for
line
in
item
.
node_v_isoline_data
:
draw_edges
(
e_shader
,
line
.
points
,
line
.
edges
,
node
.
node_lines_width
,
node
.
node_lines_color
)
if
node
.
draw_control_net
and
item
.
cpts_list
is
not
None
:
if
node
.
draw_control_net
and
item
.
cpts_list
is
not
None
:
draw_edges
(
e_shader
,
item
.
cpts_list
,
item
.
control_net
,
node
.
control_net_line_width
,
node
.
control_net_color
)
draw_edges
(
e_shader
,
item
.
cpts_list
,
item
.
control_net
,
node
.
control_net_line_width
,
node
.
control_net_color
)
...
@@ -182,6 +188,23 @@ class SvSurfaceViewerDrawNode(bpy.types.Node, SverchCustomTreeNode):
...
@@ -182,6 +188,23 @@ class SvSurfaceViewerDrawNode(bpy.types.Node, SverchCustomTreeNode):
min
=
1
,
default
=
3
,
min
=
1
,
default
=
3
,
update
=
updateNode
)
update
=
updateNode
)
draw_node_lines
:
BoolProperty
(
name
=
"Display node lines"
,
default
=
False
,
update
=
updateNode
)
node_lines_color
:
FloatVectorProperty
(
name
=
"Node Lines Color"
,
default
=
(
0.2
,
0.0
,
0.0
,
1.0
),
size
=
4
,
min
=
0.0
,
max
=
1.0
,
subtype
=
'COLOR'
,
update
=
updateNode
)
node_lines_width
:
IntProperty
(
name
=
"Node Lines Width"
,
min
=
1
,
default
=
2
,
update
=
updateNode
)
light_vector
:
FloatVectorProperty
(
light_vector
:
FloatVectorProperty
(
name
=
'Light Direction'
,
subtype
=
'DIRECTION'
,
min
=
0
,
max
=
1
,
size
=
3
,
name
=
'Light Direction'
,
subtype
=
'DIRECTION'
,
min
=
0
,
max
=
1
,
size
=
3
,
default
=
(
0.2
,
0.6
,
0.4
),
update
=
updateNode
)
default
=
(
0.2
,
0.6
,
0.4
),
update
=
updateNode
)
...
@@ -220,6 +243,11 @@ class SvSurfaceViewerDrawNode(bpy.types.Node, SverchCustomTreeNode):
...
@@ -220,6 +243,11 @@ class SvSurfaceViewerDrawNode(bpy.types.Node, SverchCustomTreeNode):
row
.
prop
(
self
,
'control_net_color'
,
text
=
""
)
row
.
prop
(
self
,
'control_net_color'
,
text
=
""
)
row
.
prop
(
self
,
'control_net_line_width'
,
text
=
"px"
)
row
.
prop
(
self
,
'control_net_line_width'
,
text
=
"px"
)
row
=
grid
.
row
(
align
=
True
)
row
.
prop
(
self
,
'draw_node_lines'
,
icon
=
'EVENT_N'
,
text
=
''
)
row
.
prop
(
self
,
'node_lines_color'
,
text
=
""
)
row
.
prop
(
self
,
'node_lines_width'
,
text
=
"px"
)
row
=
layout
.
row
(
align
=
True
)
row
=
layout
.
row
(
align
=
True
)
row
.
scale_y
=
4.0
if
self
.
prefs_over_sized_buttons
else
1
row
.
scale_y
=
4.0
if
self
.
prefs_over_sized_buttons
else
1
self
.
wrapper_tracked_ui_draw_op
(
row
,
SvBakeSurfaceOp
.
bl_idname
,
icon
=
'OUTLINER_OB_MESH'
,
text
=
"B A K E"
)
self
.
wrapper_tracked_ui_draw_op
(
row
,
SvBakeSurfaceOp
.
bl_idname
,
icon
=
'OUTLINER_OB_MESH'
,
text
=
"B A K E"
)
...
...
utils/curve/knotvector.py
Просмотр файла @
b46b45a9
...
@@ -96,6 +96,12 @@ def average(knotvectors):
...
@@ -96,6 +96,12 @@ def average(knotvectors):
kvs
=
np
.
array
(
knotvectors
)
kvs
=
np
.
array
(
knotvectors
)
return
kvs
.
mean
(
axis
=
0
)
return
kvs
.
mean
(
axis
=
0
)
def
calc_nodes
(
degree
,
n_cpts
,
knotvector
):
nodes
=
np
.
zeros
((
n_cpts
,))
for
i
in
range
(
n_cpts
):
nodes
[
i
]
=
knotvector
[
i
+
1
:
i
+
degree
+
1
].
mean
()
return
nodes
def
to_multiplicity
(
knot_vector
,
tolerance
=
1e-6
):
def
to_multiplicity
(
knot_vector
,
tolerance
=
1e-6
):
count
=
0
count
=
0
prev_u
=
None
prev_u
=
None
...
...
utils/curve/nurbs.py
Просмотр файла @
b46b45a9
...
@@ -332,14 +332,8 @@ class SvNurbsCurve(SvCurve):
...
@@ -332,14 +332,8 @@ class SvNurbsCurve(SvCurve):
raise
Exception
(
"Not implemented!"
)
raise
Exception
(
"Not implemented!"
)
def
calc_greville_ts
(
self
):
def
calc_greville_ts
(
self
):
cpts
=
self
.
get_control_points
()
n
=
len
(
self
.
get_control_points
())
n
=
len
(
cpts
)
return
sv_knotvector
.
calc_nodes
(
self
.
get_degree
(),
n
,
self
.
get_knotvector
())
p
=
self
.
get_degree
()
gps
=
np
.
zeros
((
n
,))
kv
=
self
.
get_knotvector
()
for
i
in
range
(
n
):
gps
[
i
]
=
kv
[
i
+
1
:
i
+
p
+
1
].
mean
()
return
gps
def
calc_greville_points
(
self
):
def
calc_greville_points
(
self
):
return
self
.
evaluate_array
(
self
.
calc_greville_ts
())
return
self
.
evaluate_array
(
self
.
calc_greville_ts
())
...
...
utils/surface/bakery.py
Просмотр файла @
b46b45a9
...
@@ -12,6 +12,8 @@ import bpy
...
@@ -12,6 +12,8 @@ import bpy
from
sverchok.utils.modules.polygon_utils
import
pols_normals
from
sverchok.utils.modules.polygon_utils
import
pols_normals
from
sverchok.utils.modules.vertex_utils
import
np_vertex_normals
from
sverchok.utils.modules.vertex_utils
import
np_vertex_normals
from
sverchok.utils.math
import
np_dot
from
sverchok.utils.math
import
np_dot
from
sverchok.utils.curve.algorithms
import
SvIsoUvCurve
from
sverchok.utils.curve.bakery
import
CurveData
def
make_quad_edges
(
n_u
,
n_v
):
def
make_quad_edges
(
n_u
,
n_v
):
edges
=
[]
edges
=
[]
...
@@ -87,6 +89,14 @@ def calc_surface_data(light_vector, surface_color, n_u, n_v, points):
...
@@ -87,6 +89,14 @@ def calc_surface_data(light_vector, surface_color, n_u, n_v, points):
return
tris
,
colors
return
tris
,
colors
class
SurfaceData
(
object
):
class
SurfaceData
(
object
):
class
IsoCurveConfig
(
object
):
def
__init__
(
self
):
self
.
draw_line
=
True
self
.
draw_verts
=
False
self
.
draw_control_polygon
=
False
self
.
draw_control_points
=
False
self
.
draw_nodes
=
False
def
__init__
(
self
,
node
,
surface
,
resolution_u
,
resolution_v
):
def
__init__
(
self
,
node
,
surface
,
resolution_u
,
resolution_v
):
self
.
node
=
node
self
.
node
=
node
self
.
surface
=
surface
self
.
surface
=
surface
...
@@ -111,6 +121,17 @@ class SurfaceData(object):
...
@@ -111,6 +121,17 @@ class SurfaceData(object):
else
:
else
:
self
.
cpts_list
=
None
self
.
cpts_list
=
None
if
hasattr
(
surface
,
'calc_greville_us'
):
nodes_u
=
surface
.
calc_greville_us
()
nodes_v
=
surface
.
calc_greville_vs
()
node_u_isolines
=
[
SvIsoUvCurve
(
surface
,
'U'
,
u
)
for
u
in
nodes_u
]
node_v_isolines
=
[
SvIsoUvCurve
(
surface
,
'V'
,
v
)
for
v
in
nodes_v
]
cfg
=
SurfaceData
.
IsoCurveConfig
()
self
.
node_u_isoline_data
=
[
CurveData
(
cfg
,
isoline
,
resolution_v
)
for
isoline
in
node_u_isolines
]
self
.
node_v_isoline_data
=
[
CurveData
(
cfg
,
isoline
,
resolution_u
)
for
isoline
in
node_v_isolines
]
else
:
self
.
node_u_isoline_data
=
node_v_isoline_data
=
None
self
.
edges
=
make_quad_edges
(
resolution_u
,
resolution_v
)
self
.
edges
=
make_quad_edges
(
resolution_u
,
resolution_v
)
self
.
tris
,
self
.
tri_colors
=
calc_surface_data
(
node
.
light_vector
,
node
.
surface_color
,
resolution_u
,
resolution_v
,
self
.
points
)
self
.
tris
,
self
.
tri_colors
=
calc_surface_data
(
node
.
light_vector
,
node
.
surface_color
,
resolution_u
,
resolution_v
,
self
.
points
)
...
...
utils/surface/nurbs.py
Просмотр файла @
b46b45a9
...
@@ -120,6 +120,18 @@ class SvNurbsSurface(SvSurface):
...
@@ -120,6 +120,18 @@ class SvNurbsSurface(SvSurface):
def
iso_curve
(
self
,
fixed_direction
,
param
):
def
iso_curve
(
self
,
fixed_direction
,
param
):
raise
Exception
(
"Not implemented"
)
raise
Exception
(
"Not implemented"
)
def
calc_greville_us
(
self
):
n
=
self
.
get_control_points
().
shape
[
0
]
p
=
self
.
get_degree_u
()
kv
=
self
.
get_knotvector_u
()
return
sv_knotvector
.
calc_nodes
(
p
,
n
,
kv
)
def
calc_greville_vs
(
self
):
n
=
self
.
get_control_points
().
shape
[
1
]
p
=
self
.
get_degree_v
()
kv
=
self
.
get_knotvector_v
()
return
sv_knotvector
.
calc_nodes
(
p
,
n
,
kv
)
def
get_homogenous_control_points
(
self
):
def
get_homogenous_control_points
(
self
):
"""
"""
returns: np.array of shape (m, n, 4)
returns: np.array of shape (m, n, 4)
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать