Skip to content

Commit

Permalink
Merge pull request #5129 from nortikin/fix_5128_Voronoi_On_Mesh_param…
Browse files Browse the repository at this point in the history
…eter_Output_Nesting

fix 5128 Voronoi On Mesh parameter Output Nesting, refactor UI
  • Loading branch information
satabol committed Jun 1, 2024
2 parents 242d6f8 + 4b2fee8 commit 37ee510
Show file tree
Hide file tree
Showing 15 changed files with 964 additions and 364 deletions.
21 changes: 15 additions & 6 deletions data_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def levels_of_list_or_np(lst):
SIMPLE_DATA_TYPES = (float, int, float64, int32, int64, str, Matrix)


def get_data_nesting_level(data, data_types=SIMPLE_DATA_TYPES):
def get_data_nesting_level(data, data_types=SIMPLE_DATA_TYPES, search_first_data=False):
"""
data: number, or list of numbers, or list of lists, etc.
data_types: list or tuple of types.
Expand All @@ -529,19 +529,28 @@ def get_data_nesting_level(data, data_types=SIMPLE_DATA_TYPES):
def helper(data, recursion_depth):
""" Needed only for better error reporting. """
if isinstance(data, data_types):
return 0
return (0, 0)
elif isinstance(data, (list, tuple, ndarray)):
if len(data) == 0:
return 1
return (1, -1)
else:
return helper(data[0], recursion_depth+1) + 1
if search_first_data==False:
res = helper(data[0], recursion_depth+1)
else:
for I, data_I in enumerate(data):
res = helper(data_I, recursion_depth+1)
if res[1]==0:
return (res[0]+1, res[1] )
#return helper(data[0], recursion_depth+1) + 1
return (res[0]+ 1, res[1] )
elif data is None:
raise TypeError("get_data_nesting_level: encountered None at nesting level {}".format(recursion_depth))
else:
#unknown class. Return 0 level
return 0
return (0, -1)

return helper(data, 0)
res = helper(data, 0)
return res[0]

def ensure_nesting_level(data, target_level, data_types=SIMPLE_DATA_TYPES, input_name=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/nodes/analyzer/bbox_aligned.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Examples
:target: https://github.com/nortikin/sverchok/assets/14288520/84588685-1360-4029-b8de-5346008b982b

* Spatial-> :doc:`Populate Mesh </nodes/spatial/random_points_on_mesh>`
* Spatial-> :doc:`Voronoi on Mesh </nodes/spatial/voronoi_on_mesh_mk2>`
* Spatial-> :doc:`Voronoi on Mesh </nodes/spatial/voronoi_on_mesh>`
* Viz-> :doc:`Viewer Draw </nodes/viz/viewer_draw_mk4>`
* Scene-> :doc:`Get Objects Data </nodes/scene/get_objects_data>`

Expand Down
2 changes: 1 addition & 1 deletion docs/nodes/pulga_physics/pulga_springs_force.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Example in description:

* Generator-> :doc:`Cylinder </nodes/generator/cylinder_mk2>`
* Spatial-> :doc:`Populate Mesh </nodes/spatial/random_points_on_mesh>`
* Spatial-> :doc:`Voronoi on Mesh </nodes/spatial/voronoi_on_mesh_mk2>`
* Spatial-> :doc:`Voronoi on Mesh </nodes/spatial/voronoi_on_mesh>`
* Modifiers->Modifier Change-> :doc:`Mesh Join </nodes/modifier_change/mesh_join_mk2>`
* Modifiers->Modifier Change-> :doc:`Merge by Distance </nodes/modifier_change/merge_by_distance>`
* Analyzers->Component Analyzer **Vertices->Sharpness**: :ref:`Vertices Sharpness<VERTICES_SHARPNESS>`
Expand Down
2 changes: 1 addition & 1 deletion docs/nodes/scene/get_objects_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Mask sites of Voronoi node with selection of faces:
Your browser does not support the video tag.
</video>

* Spatial-> :doc:`Voronoi on Mesh </nodes/spatial/voronoi_on_mesh_mk2>`
* Spatial-> :doc:`Voronoi on Mesh </nodes/spatial/voronoi_on_mesh>`
* Viz-> :doc:`Viewer Draw </nodes/viz/viewer_draw_mk4>`

Mask edges of Grid with selection of edges:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Voronoi on Mesh
===============

.. image:: https://github.com/nortikin/sverchok/assets/14288520/c907cc2d-7493-4117-a20f-b5e760a47d28
:target: https://github.com/nortikin/sverchok/assets/14288520/c907cc2d-7493-4117-a20f-b5e760a47d28
.. image:: https://github.com/nortikin/sverchok/assets/14288520/ecff1142-de97-438f-a3be-f609d0816b96
:target: https://github.com/nortikin/sverchok/assets/14288520/ecff1142-de97-438f-a3be-f609d0816b96

Dependencies
------------
Expand All @@ -28,19 +28,29 @@ Inputs
This node has the following inputs:

* **Vertices**. Vertices of the mesh to generate Voronoi diagram on. This input is mandatory.
* **Faces**. Faces of the mesh to generate Voronoi diagram on. This input is mandatory.
* **Mask**. List of True/False. What Sites will visible.
* **Polygons**. Faces of the mesh to generate Voronoi diagram on. This input is mandatory.

.. image:: https://github.com/nortikin/sverchok/assets/14288520/cc788894-acc7-4b1f-a1c0-fb5756e42eb2
:target: https://github.com/nortikin/sverchok/assets/14288520/cc788894-acc7-4b1f-a1c0-fb5756e42eb2
.. image:: https://github.com/nortikin/sverchok/assets/14288520/5a6ecd49-9ae1-4422-98b6-211060a22420
:target: https://github.com/nortikin/sverchok/assets/14288520/5a6ecd49-9ae1-4422-98b6-211060a22420


* **Sites**. The points to generate Voronoi diagram for. Usually you want for
* **Voronoi Sites**. The points to generate Voronoi diagram for. Usually you want for
this points to lie either inside the mesh or on it's surface, but this is not
necessary. This input is mandatory.
necessary. This input is mandatory. If list of Voronoi sites is Zero length then source object will not processed
and transfer it params to output sockets.

.. image:: https://github.com/nortikin/sverchok/assets/14288520/4353aec1-e4f5-4cb4-a9ec-f3e8c6435c0b
:target: https://github.com/nortikin/sverchok/assets/14288520/4353aec1-e4f5-4cb4-a9ec-f3e8c6435c0b

* **Mask of sites**. List of True/False or indexes. What Sites will be show in result.

.. image:: https://github.com/nortikin/sverchok/assets/14288520/61bd23e3-3a8e-47e2-b18f-1c7272b71679
:target: https://github.com/nortikin/sverchok/assets/14288520/61bd23e3-3a8e-47e2-b18f-1c7272b71679

.. image:: https://user-images.githubusercontent.com/14288520/202571362-7f047b5b-64a9-489c-8167-5fcb125f7fdf.png
:target: https://user-images.githubusercontent.com/14288520/202571362-7f047b5b-64a9-489c-8167-5fcb125f7fdf.png

* **invert** Invert list **Mask of Sites**.

.. image:: https://github.com/nortikin/sverchok/assets/14288520/b8360826-c678-4b47-b783-3e05a71f1275
:target: https://github.com/nortikin/sverchok/assets/14288520/b8360826-c678-4b47-b783-3e05a71f1275

* **Spacing**. Percent of space to leave between generated fragment meshes.
Zero means do not leave any space, i.e. regions will fully cover initial
Expand Down Expand Up @@ -82,14 +92,14 @@ This node has the following parameters:
.. image:: https://user-images.githubusercontent.com/14288520/202574847-5343b0d1-61f3-4313-a8a1-7efce49f1405.gif
:target: https://user-images.githubusercontent.com/14288520/202574847-5343b0d1-61f3-4313-a8a1-7efce49f1405.gif

* **Output nesting**. This defines nesting structure of output sockets. The available options are:
* **Post processing**. This defines nesting structure of result meshes. The available options are:

* **Separate All Meshes**. Separate the result meshes into individual meshes.
* **Keep Source Meshes**. Keep parts of the source meshes as source meshes.
* **Join All Meshes**. Join all results meshes into a single mesh.

* **Flat list**. Output a single flat list of mesh objects (Voronoi diagram
ridges / regions) for all input meshes.
* **Separate lists**. Output a separate list of mesh objects (Voronoi
diagram ridges / regions) for each input mesh.
* **Join meshes**. Output one mesh, joined from ridges / edges of Voronoi
diagram, for each input mesh.
.. image:: https://github.com/nortikin/sverchok/assets/14288520/afa0b637-b0cb-4813-9f10-3e05cd607e02
:target: https://github.com/nortikin/sverchok/assets/14288520/afa0b637-b0cb-4813-9f10-3e05cd607e02

* **Accuracy**. This parameter is available in the N panel only. This defines
the precision of mesh calculation (number of digits after decimal point). The
Expand All @@ -107,10 +117,11 @@ This node has the following outputs:
* **Vertices**. Vertices of generated mesh.
* **Edges**. Edges of generated mesh.
* **Faces**. Faces of generated mesh.
* **Sites_idx**. Indices of sources sites for further using. (from sverchok 1.3-alpha-master)
* **Used Sites idx**. Indices of sources sites for further using (after apply Mask of sites). (from sverchok 1.3-alpha-master)
* **Used Sites Verts**. Values of used sites. Keep of source struct of input socket "Voronoi sites" lists (after apply Mask of sites). (from sverchok 1.3-alpha-master)

.. image:: https://github.com/nortikin/sverchok/assets/14288520/4d60e90e-19af-4600-88dc-92b67896967a
:target: https://github.com/nortikin/sverchok/assets/14288520/4d60e90e-19af-4600-88dc-92b67896967a
.. image:: https://github.com/nortikin/sverchok/assets/14288520/91ccb203-e0bb-49a0-a626-e403ee30be3c
:target: https://github.com/nortikin/sverchok/assets/14288520/91ccb203-e0bb-49a0-a626-e403ee30be3c

* Text-> :doc:`Stethoscope </nodes/text/stethoscope_v28>`

Expand Down
2 changes: 1 addition & 1 deletion index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
- SvExVoronoi3DNode
- SvExVoronoiSphereNode
- SvVoronoiOnSurfaceNode
- SvVoronoiOnMeshNodeMK3
- SvVoronoiOnMeshNodeMK4
- SvVoronoiOnSolidNodeMK2
- ---
- SvLloyd2dNode
Expand Down
2 changes: 1 addition & 1 deletion menus/full_by_data_type.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@
- SvExVoronoi3DNode
- SvExVoronoiSphereNode
- SvVoronoiOnSurfaceNode
- SvVoronoiOnMeshNodeMK3
- SvVoronoiOnMeshNodeMK4
- SvVoronoiOnSolidNodeMK2
- ---
- SvLloyd2dNode
Expand Down
2 changes: 1 addition & 1 deletion menus/full_nortikin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
- SvExVoronoi3DNode
- SvExVoronoiSphereNode
- SvVoronoiOnSurfaceNode
- SvVoronoiOnMeshNodeMK3
- SvVoronoiOnMeshNodeMK4
- SvVoronoiOnSolidNodeMK2
- ---
- SvLloyd2dNode
Expand Down
Loading

0 comments on commit 37ee510

Please sign in to comment.