Skip to content

Commit

Permalink
Deploy documentation of '20240903-news-scripted-diagrams' to GitHub P…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
mprinkezs committed Dec 17, 2024
1 parent 6702805 commit b3c14bf
Show file tree
Hide file tree
Showing 396 changed files with 38,089 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 20240903-news-scripted-diagrams/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: fe80d32e0caabf5fb3b4f1ed543d5913
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import gom

DIALOG4 = gom.script.sys.create_user_defined_dialog(dialog={
"content": [
[
{
"columns": 1,
"name": "label_6",
"rows": 1,
"text": {
"id": "",
"text": "New",
"translatable": True
},
"tooltip": {
"id": "",
"text": "",
"translatable": True
},
"type": "label",
"word_wrap": False
},
{
"columns": 1,
"fast_filter": False,
"name": "input_new",
"rows": 1,
"supplier": "custom",
"tooltip": {
"id": "",
"text": "",
"translatable": True
},
"type": "input::point3d"
}
]
],
"control": {
"id": "OkCancel"
},
"embedding": "",
"position": "",
"size": {
"height": 112,
"width": 200
},
"sizemode": "",
"style": "",
"title": {
"id": "",
"text": "Demo \"New selection element\"",
"translatable": True
}
})


def dialog_event_handler(widget):
pass


# filter system planes
def element_filter(element):
try:
if element.type == 'plane':
return True
except Exception as e:
pass
return False


DIALOG4.handler = dialog_event_handler
DIALOG4.input_new.filter = element_filter

# Alternative: use fast filtering
# from typing import Iterable
#
# def fast_element_filter(*elements) -> Iterable[bool]:
# return [element_filter(e) for e in elements]
#
# DIALOG4.input_new.fast_filter = True
# DIALOG4.input_new.filter = fast_element_filter

RESULT = gom.script.sys.show_user_defined_dialog(dialog=DIALOG4)

print("Chosen system plane:", RESULT.input_new.name)
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# -*- coding: utf-8 -*-

import gom

DIALOG=gom.script.sys.create_user_defined_dialog (dialog={
"content": [
[
{
"columns": 2,
"name": "label",
"rows": 1,
"text": {
"id": "",
"text": "Choose a button. Any button.",
"translatable": True
},
"tooltip": {
"id": "",
"text": "",
"translatable": True
},
"type": "label",
"word_wrap": False
},
{
}
],
[
{
"button_type": "push",
"columns": 1,
"icon": "AAAAAA==",
"icon_file_name": "",
"icon_size": {
"value": "icon"
},
"icon_system_size": {
"value": "default"
},
"icon_system_type": {
"value": "ok"
},
"icon_type": {
"value": "none"
},
"name": "button_yes",
"rows": 1,
"text": {
"id": "",
"text": "Yes",
"translatable": True
},
"tooltip": {
"id": "",
"text": "",
"translatable": True
},
"type": "button::pushbutton"
},
{
"button_type": "push",
"columns": 1,
"icon": "AAAAAA==",
"icon_file_name": "",
"icon_size": {
"value": "icon"
},
"icon_system_size": {
"value": "default"
},
"icon_system_type": {
"value": "ok"
},
"icon_type": {
"value": "none"
},
"name": "button_no",
"rows": 1,
"text": {
"id": "",
"text": "No",
"translatable": True
},
"tooltip": {
"id": "",
"text": "",
"translatable": True
},
"type": "button::pushbutton"
}
]
],
"control": {
"id": "Empty"
},
"embedding": "",
"position": "",
"size": {
"height": 121,
"width": 230
},
"sizemode": "",
"style": "",
"title": {
"id": "",
"text": "Push a button",
"translatable": True
}
})

#
# Event handler function called if anything happens inside of the dialog
#
def dialog_event_handler (widget):
if widget == DIALOG.button_yes:
gom.script.sys.close_user_defined_dialog( dialog = DIALOG, result = 'Yes' )
if widget == DIALOG.button_no:
gom.script.sys.close_user_defined_dialog( dialog = DIALOG, result = 'No' )

DIALOG.handler = dialog_event_handler

try:
RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG)
except gom.BreakError as e:
RESULT = 'Cheater'

print('RESULT', RESULT)

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def localize_triangles(triangles:np.ndarray, global_vertices:np.ndarray) -> tuple[np.ndarray, np.ndarray]:
"""This function resets the triangles' indices to be relative to the selection on mesh
Args:
triangles (np.ndarray): array of triangles from 'np.array(mesh.selection.triangles)[stage]'
global_vertices (np.ndarray): all vertices of the mesh 'np.array(mesh.data.coordinate)[stage]'
Returns:
tuple[np.ndarray, np.ndarray]: localized triangles' array and indices, for remapping of global vertices, values, etc.
Usage:
>>> global_vertices = np.array(mesh.data.coordinate)
>>> triangles = np.array(mesh.selection.triangle)
>>> number_of_stages = len(global_vertices)
>>> for stage in range(number_of_stages):
... localized_triangles, indices = localize_triangles(triangles[stage], global_vertices[stage])
... localized_vertices = global_vertices[stage][indices]
"""
indices = np.nonzero(np.bincount(triangles.ravel(), minlength=len(global_vertices)))[0]
remap = np.ndarray(len(global_vertices), dtype=np.int32)
remap[indices] = np.arange(0, len(indices))
triangles = remap[triangles.ravel()].reshape(triangles.shape)
return triangles, indices
Loading

0 comments on commit b3c14bf

Please sign in to comment.