Открыть боковую панель
nikitronn
sverchok
Коммиты
a9cd356d
Коммит
a9cd356d
создал
Сен 21, 2019
по автору
Ilya Portnov
Просмотр файлов
Port diameter node.
владелец
ed549f19
Изменения
2
Скрыть пробелы
Построчно
Рядом
docs/nodes/analyzers/diameter.rst
0 → 100644
Просмотр файла @
a9cd356d
Diameter
========
Functionality
-------------
This node calculates the diameter of input set of vertices.
It can calculate diameter in two ways:
* General diameter, i.e. maximum distance between any two vertices from input set.
* Diameter along specified direction (axis), i.e. the length of the projection
of whole input vertices set to specified direction.
Inputs
------
This node has the following inputs:
* **Vertices** - vertices to calculate diameter of. This input is mandatory for the node to function.
* **Direction** - direction, along which diameter should be calculated. If this
input is not connected, then the node will calculate "general diameter" of
input vertices set.
Outputs
-------
This node has one output: **Diameter** - calculated diameter of vertices set.
Examples of usage
-----------------
Suzanne has "general diameter" of 2.73:
.. image:: https://user-images.githubusercontent.com/284644/58649984-03aad000-8327-11e9-90b8-0c39f328402a.png
Diameter of Suzanne along some diagonal direction is 2.44. Here the direction
is drawn as green line, and the projection of Suzanne to that direction is
marked with red dots:
.. image:: https://user-images.githubusercontent.com/284644/58649983-03aad000-8327-11e9-852a-a75d8eb4aad4.png
nodes/analyzer/diameter.py
0 → 100644
Просмотр файла @
a9cd356d
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
from
itertools
import
product
import
bpy
from
sverchok.node_tree
import
SverchCustomTreeNode
from
sverchok.data_structure
import
updateNode
,
match_long_repeat
from
sverchok.utils.geom
import
diameter
class
SvDiameterNode
(
bpy
.
types
.
Node
,
SverchCustomTreeNode
):
"""
Triggers: Diameter
Tooltip: Calculate diameter of input object
"""
bl_idname
=
'SvDiameterNode'
bl_label
=
"Diameter"
bl_icon
=
'ARROW_LEFTRIGHT'
def
sv_init
(
self
,
context
):
self
.
inputs
.
new
(
'VerticesSocket'
,
'Vertices'
)
self
.
inputs
.
new
(
'VerticesSocket'
,
'Direction'
)
self
.
outputs
.
new
(
'StringsSocket'
,
'Diameter'
)
def
process
(
self
):
if
not
self
.
inputs
[
'Vertices'
].
is_linked
:
return
if
not
any
(
s
.
is_linked
for
s
in
self
.
outputs
):
return
any_direction
=
not
self
.
inputs
[
'Direction'
].
is_linked
out_results
=
[]
vertices_s
=
self
.
inputs
[
'Vertices'
].
sv_get
(
default
=
[[]])
directions_s
=
self
.
inputs
[
'Direction'
].
sv_get
(
default
=
[[]])
objects
=
match_long_repeat
([
vertices_s
,
directions_s
])
for
vertices
,
directions
in
zip
(
*
objects
):
if
any_direction
:
direction
=
None
else
:
direction
=
directions
[
0
]
diam
=
diameter
(
vertices
,
direction
)
out_results
.
append
([
diam
])
self
.
outputs
[
'Diameter'
].
sv_set
(
out_results
)
def
register
():
bpy
.
utils
.
register_class
(
SvDiameterNode
)
def
unregister
():
bpy
.
utils
.
unregister_class
(
SvDiameterNode
)
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать