Коммит 3e752737 создал по автору Victor Doval's avatar Victor Doval
Просмотр файлов

renamed to Path Length

владелец aa05b554
......@@ -14,7 +14,6 @@ Analyzers
image_components
kd_tree
kd_tree_edges_mk2
length
mesh_filter
mesh_select
select_similar
......@@ -23,6 +22,7 @@ Analyzers
normals
bvh_overlap_polys
object_insolation
path_length
points_inside_mesh
polygons_centers
polygons_centers_mk3
......
Length
=====
Path Length
===========
Functionality
-------------
Length node is one of the analyzer type. It is used to get the length of any path, no matter the number of its vertices or its world position.
Path Length node is one of the analyzer type. It is used to get the length of any path, no matter the number of its vertices or its world position.
Inputs / Parameters
......@@ -18,7 +18,7 @@ Inputs / Parameters
+------------------+---------------+-------------+--------------------------------------------------+
| **Edges** | Strings | None | Edges referenced to vertices |
+------------------+---------------+-------------+--------------------------------------------------+
| **by Edges** | Boolean | True | output individual edges length or the sum of all |
| **Segment** | Boolean | True | output the segments lengths or its sum |
+------------------+---------------+-------------+--------------------------------------------------+
In the N-Panel you can use the toggle **Output NumPy** to get NumPy arrays in stead of regular lists (makes the node faster).
......@@ -32,12 +32,17 @@ Outputs
Example of usage
----------------
.. image:: https://user-images.githubusercontent.com/10011941/50869102-f52d3d80-13b2-11e9-8316-01106c61e8d7.png
:alt: LengthDemo1.PNG
.. image:: https://user-images.githubusercontent.com/10011941/51251936-c4449e00-199a-11e9-89a7-557cc7e93731.png
:alt: PathLengthDemo1.PNG
Measuring a Bender curve with the default vertices, with a higher interpolation and by edges
.. image:: https://user-images.githubusercontent.com/10011941/50869357-f317ae80-13b3-11e9-88a0-05888e9bc2c6.png
:alt: LengthDemo2.PNG
.. image:: https://user-images.githubusercontent.com/10011941/51251933-c4449e00-199a-11e9-99b8-fa53c8586484.png
:alt: PathLengthDemo2.PNG
Using the length node to know the linear distance needed to build a 3 meter radius geodesic dome
Using the node to know the linear distance needed to build a 3 meter radius geodesic dome
.. image:: https://user-images.githubusercontent.com/10011941/51251931-c4449e00-199a-11e9-9e75-69ead34fad64.png
:alt: PathLengthDemo2.PNG
Using the *Path Length* node to place circles of one meter of diameter along a given curve
\ Нет новой строки в конце файла
......@@ -49,7 +49,7 @@
SvVolumeNode
AreaNode
DistancePPNode
SvLengthNode
SvPathLengthNode
CentersPolsNodeMK2
CentersPolsNodeMK3
GetNormalsNode
......
......@@ -20,7 +20,7 @@
import bpy
from bpy.props import BoolProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, match_long_repeat
from sverchok.data_structure import updateNode, match_long_repeat, get_edge_list
import numpy as np
......@@ -39,7 +39,6 @@ def edges_length(meshes, gates, result):
for vertices, edges in zip(*meshes):
np_verts = np.array(vertices)
print(np_verts.shape)
if type(edges[0]) in (list, tuple):
np_edges = np.array(edges)
else:
......@@ -55,26 +54,26 @@ def edges_length(meshes, gates, result):
return result
class SvLengthNode(bpy.types.Node, SverchCustomTreeNode):
class SvPathLengthNode(bpy.types.Node, SverchCustomTreeNode):
'''
Triggers: Path / Edges length
Tooltip: Deformation between to states, edge elong a area variation
Tooltip: Masseuses the length of a path or the length of it's segments
'''
bl_idname = 'SvLengthNode'
bl_label = 'Length'
bl_idname = 'SvPathLengthNode'
bl_label = 'Path Length'
bl_icon = 'MOD_SIMPLEDEFORM'
output_numpy = BoolProperty(
name='Output NumPy', description='output NumPy arrays',
default=False, update=updateNode)
sum_lengths = BoolProperty(
name='by Edge', description='individual lengths or the sum of them',
segment = BoolProperty(
name='Segment', description='Get segments length or the sum of them',
default=True, update=updateNode)
def draw_buttons(self, context, layout):
'''draw buttons on the Node'''
layout.prop(self, "sum_lengths", toggle=False)
layout.prop(self, "segment", toggle=False)
def draw_buttons_ext(self, context, layout):
'''draw buttons on the N-panel'''
......@@ -85,7 +84,7 @@ class SvLengthNode(bpy.types.Node, SverchCustomTreeNode):
'''create sockets'''
sinw = self.inputs.new
sonw = self.outputs.new
sinw('VerticesSocket', "Verts")
sinw('VerticesSocket', "Vertices")
sinw('StringsSocket', "Edges")
sonw('StringsSocket', "Length")
......@@ -93,24 +92,28 @@ class SvLengthNode(bpy.types.Node, SverchCustomTreeNode):
def get_data(self):
'''get all data from sockets'''
si = self.inputs
vertices = si['Verts'].sv_get(default=[[]])
edges_in = si['Edges'].sv_get(default=[[]])
if len(edges_in[0]) < 1:
vertices = si['Vertices'].sv_get()
if si['Edges'].is_linked:
edges_in = si['Edges'].sv_get()
else:
edges_in = edges_aux(vertices)
return match_long_repeat([vertices, edges_in])
def process(self):
'''main node function called every update'''
si = self.inputs
so = self.outputs
if not (so[0].is_linked and si[0].is_linked):
if not (so['Length'].is_linked):
return
result = []
gates = []
gates.append(self.output_numpy)
gates.append(self.sum_lengths)
gates.append(self.segment)
meshes = self.get_data()
result = edges_length(meshes, gates, result)
......@@ -120,9 +123,9 @@ class SvLengthNode(bpy.types.Node, SverchCustomTreeNode):
def register():
'''register class in Blender'''
bpy.utils.register_class(SvLengthNode)
bpy.utils.register_class(SvPathLengthNode)
def unregister():
'''unregister class in Blender'''
bpy.utils.unregister_class(SvLengthNode)
bpy.utils.unregister_class(SvPathLengthNode)
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать