diff --git a/source/parametric_modeling/HTML Dialogs/images/get-points-node-icon.svg b/source/parametric_modeling/HTML Dialogs/images/get-points-node-icon.svg new file mode 100644 index 0000000..9ed4121 --- /dev/null +++ b/source/parametric_modeling/HTML Dialogs/images/get-points-node-icon.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/parametric_modeling/HTML Dialogs/nodes-editor.css b/source/parametric_modeling/HTML Dialogs/nodes-editor.css index bc5cb90..9b66a00 100644 --- a/source/parametric_modeling/HTML Dialogs/nodes-editor.css +++ b/source/parametric_modeling/HTML Dialogs/nodes-editor.css @@ -48,8 +48,8 @@ body { display: inline-block; - width: 32px; - height: 32px; + width: 31px; + height: 31px; cursor: pointer; diff --git a/source/parametric_modeling/HTML Dialogs/nodes-editor.js b/source/parametric_modeling/HTML Dialogs/nodes-editor.js index 5bf1019..ca4cad2 100644 --- a/source/parametric_modeling/HTML Dialogs/nodes-editor.js +++ b/source/parametric_modeling/HTML Dialogs/nodes-editor.js @@ -425,9 +425,7 @@ class DrawBoxReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -461,9 +459,7 @@ class DrawPrismReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -497,9 +493,7 @@ class DrawCylinderReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -537,9 +531,7 @@ class DrawTubeReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -573,9 +565,7 @@ class DrawPyramidReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -609,9 +599,7 @@ class DrawConeReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -641,9 +629,7 @@ class DrawSphereReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -665,9 +651,7 @@ class DrawShapeReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1059,15 +1043,60 @@ class PointReteComponent extends Rete.Component { } - worker(node, _inputs, outputs) { + worker(node, _inputs, _outputs) {} - var x = PMG.Utils.isValidNumber(node.data.x) ? node.data.x : 0 - var y = PMG.Utils.isValidNumber(node.data.y) ? node.data.y : 0 - var z = PMG.Utils.isValidNumber(node.data.z) ? node.data.z : 0 +} - outputs['point'] = { x, y, z } +class GetPointsReteComponent extends Rete.Component { + constructor() { + super('Get points') } + + builder(node) { + + var inputGroup = new Rete.Input('groups', t('Group'), PMG.NodesEditor.sockets.groups) + + var outputFrontBottomLeft = new Rete.Output('front_bottom_left', t('Front bottom left'), PMG.NodesEditor.sockets.point) + var outputFrontBottomRight = new Rete.Output('front_bottom_right', t('Front bottom right'), PMG.NodesEditor.sockets.point) + var outputFrontCenter = new Rete.Output('front_center', t('Front center'), PMG.NodesEditor.sockets.point) + var outputFrontTopLeft = new Rete.Output('front_top_left', t('Front top left'), PMG.NodesEditor.sockets.point) + var outputFrontTopRight = new Rete.Output('front_top_right', t('Front top right'), PMG.NodesEditor.sockets.point) + + var outputBottomCenter = new Rete.Output('bottom_center', t('Bottom center'), PMG.NodesEditor.sockets.point) + var outputLeftCenter = new Rete.Output('left_center', t('Left center'), PMG.NodesEditor.sockets.point) + var outputCenter = new Rete.Output('center', t('Center'), PMG.NodesEditor.sockets.point) + var outputRightCenter = new Rete.Output('right_center', t('Right center'), PMG.NodesEditor.sockets.point) + var outputTopCenter = new Rete.Output('top_center', t('Top center'), PMG.NodesEditor.sockets.point) + + var outputBackBottomLeft = new Rete.Output('back_bottom_left', t('Back bottom left'), PMG.NodesEditor.sockets.point) + var outputBackBottomRight = new Rete.Output('back_bottom_right', t('Back bottom right'), PMG.NodesEditor.sockets.point) + var outputBackCenter = new Rete.Output('back_center', t('Back center'), PMG.NodesEditor.sockets.point) + var outputBackTopLeft = new Rete.Output('back_top_left', t('Back top left'), PMG.NodesEditor.sockets.point) + var outputBackTopRight = new Rete.Output('back_top_right', t('Back top right'), PMG.NodesEditor.sockets.point) + + return node + .addInput(inputGroup) + .addOutput(outputFrontBottomLeft) + .addOutput(outputFrontBottomRight) + .addOutput(outputFrontCenter) + .addOutput(outputFrontTopLeft) + .addOutput(outputFrontTopRight) + .addOutput(outputBottomCenter) + .addOutput(outputLeftCenter) + .addOutput(outputCenter) + .addOutput(outputRightCenter) + .addOutput(outputTopCenter) + .addOutput(outputBackBottomLeft) + .addOutput(outputBackBottomRight) + .addOutput(outputBackCenter) + .addOutput(outputBackTopLeft) + .addOutput(outputBackTopRight) + + } + + worker(_node, _inputs, _outputs) {} + } class VectorReteComponent extends Rete.Component { @@ -1097,15 +1126,8 @@ class VectorReteComponent extends Rete.Component { } - worker(node, _inputs, outputs) { - - var x = PMG.Utils.isValidNumber(node.data.x) ? node.data.x : 0 - var y = PMG.Utils.isValidNumber(node.data.y) ? node.data.y : 0 - var z = PMG.Utils.isValidNumber(node.data.z) ? node.data.z : 0 - - outputs['vector'] = { x, y, z } + worker(_node, _inputs, _outputs) {} - } } class IntersectSolidsReteComponent extends Rete.Component { @@ -1128,9 +1150,7 @@ class IntersectSolidsReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1154,9 +1174,7 @@ class UniteSolidsReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1180,9 +1198,7 @@ class SubtractSolidsReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1210,9 +1226,7 @@ class PushPullReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1237,9 +1251,7 @@ class MoveReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1268,9 +1280,7 @@ class RotateReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1303,9 +1313,7 @@ class ScaleReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1328,9 +1336,7 @@ class PaintReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1353,9 +1359,7 @@ class TagReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1374,8 +1378,7 @@ class EraseReteComponent extends Rete.Component { } - worker(_node, _inputs, _outputs) { - } + worker(_node, _inputs, _outputs) {} } @@ -1403,12 +1406,7 @@ class CopyReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - - outputs['groups'] = [] - outputs['original_groups'] = [] - - } + worker(_node, _inputs, _outputs) {} } @@ -1452,9 +1450,7 @@ class ConcatenateReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1528,12 +1524,7 @@ class SelectReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - - outputs['groups'] = [] - outputs['not_groups'] = [] - - } + worker(_node, _inputs, _outputs) {} } @@ -1580,9 +1571,7 @@ class MakeGroupReteComponent extends Rete.Component { } - worker(_node, _inputs, outputs) { - outputs['groups'] = [] - } + worker(_node, _inputs, _outputs) {} } @@ -1628,6 +1617,7 @@ PMG.NodesEditor.initializeComponents = () => { "Divide": new DivideReteComponent(), "Calculate": new CalculateReteComponent(), "Point": new PointReteComponent(), + "Get points": new GetPointsReteComponent(), "Vector": new VectorReteComponent(), "Intersect solids": new IntersectSolidsReteComponent(), "Unite solids": new UniteSolidsReteComponent(), diff --git a/source/parametric_modeling/HTML Dialogs/nodes-editor.rhtml b/source/parametric_modeling/HTML Dialogs/nodes-editor.rhtml index 2fa97d5..13eadab 100644 --- a/source/parametric_modeling/HTML Dialogs/nodes-editor.rhtml +++ b/source/parametric_modeling/HTML Dialogs/nodes-editor.rhtml @@ -59,6 +59,7 @@ + diff --git a/source/parametric_modeling/Resources/fr/pmg.translation b/source/parametric_modeling/Resources/fr/pmg.translation index 705be6a..6433a0b 100644 --- a/source/parametric_modeling/Resources/fr/pmg.translation +++ b/source/parametric_modeling/Resources/fr/pmg.translation @@ -60,13 +60,26 @@ "Variable K"="Variable K"; "Variable L"="Variable L"; "Formula example:"="Exemple de formule :"; -"Point"="Point"; +"Front bottom left"="Devant, en bas, à gauche"; +"Front bottom right"="Devant, en bas, à droite"; +"Front center"="Devant, au centre"; +"Front top left"="Devant, en haut, à gauche"; +"Front top right"="Devant, en haut, à droite"; +"Bottom center"="En bas, au centre"; +"Left center"="A gauche, au centre"; +"Center"="Centre"; +"Right center"="A droite, au centre"; +"Top center"="En haut, au centre"; +"Back bottom left"="Derrière, en bas, à gauche"; +"Back bottom right"="Derrière, en bas, à droite"; +"Back center"="Derrière, au centre"; +"Back top left"="Derrière, en haut, à gauche"; +"Back top right"="Derrière, en haut, à droite"; "Distance"="Distance"; "Direction"="Direction"; "Increment distance"="Incrémenter la distance"; "Position"="Position"; "Position is absolute"="La position est absolue"; -"Center"="Centre"; "Axis"="Axe"; "Angle"="Angle"; "X factor"="Facteur X"; @@ -91,6 +104,7 @@ "Multiply"="Multiplier"; "Divide"="Diviser"; "Calculate"="Calculer"; +"Get points"="Obtenir des points"; "Intersect solids"="Intersecter des solides"; "Unite solids"="Unir des solides"; "Subtract solids"="Soustraire des solides"; diff --git a/source/parametric_modeling/node.rb b/source/parametric_modeling/node.rb index 330a9da..915f918 100644 --- a/source/parametric_modeling/node.rb +++ b/source/parametric_modeling/node.rb @@ -884,9 +884,62 @@ def self.compute_once(node) when 'Get points' + node[:computed_data][:output][:front_bottom_left] = ORIGIN + node[:computed_data][:output][:front_bottom_right] = ORIGIN + node[:computed_data][:output][:front_center] = ORIGIN + node[:computed_data][:output][:front_top_left] = ORIGIN + node[:computed_data][:output][:front_top_right] = ORIGIN + + node[:computed_data][:output][:bottom_center] = ORIGIN + node[:computed_data][:output][:left_center] = ORIGIN node[:computed_data][:output][:center] = ORIGIN + node[:computed_data][:output][:right_center] = ORIGIN + node[:computed_data][:output][:top_center] = ORIGIN - # TODO + node[:computed_data][:output][:back_bottom_left] = ORIGIN + node[:computed_data][:output][:back_bottom_right] = ORIGIN + node[:computed_data][:output][:back_center] = ORIGIN + node[:computed_data][:output][:back_top_left] = ORIGIN + node[:computed_data][:output][:back_top_right] = ORIGIN + + if node[:computed_data][:input].key?(:groups) && + node[:computed_data][:input][:groups].is_a?(Array) && + !node[:computed_data][:input][:groups].empty? + + group = node[:computed_data][:input][:groups].first + bounding_box = group.bounds + + node[:computed_data][:output][:front_bottom_left] = bounding_box.corner(0) + node[:computed_data][:output][:front_bottom_right] = bounding_box.corner(1) + node[:computed_data][:output][:front_center] = Geom::Point3d.linear_combination( + 0.5, bounding_box.corner(1), 0.5, bounding_box.corner(4) + ) + node[:computed_data][:output][:front_top_left] = bounding_box.corner(4) + node[:computed_data][:output][:front_top_right] = bounding_box.corner(5) + + node[:computed_data][:output][:bottom_center] = Geom::Point3d.linear_combination( + 0.5, bounding_box.corner(0), 0.5, bounding_box.corner(3) + ) + node[:computed_data][:output][:left_center] = Geom::Point3d.linear_combination( + 0.5, bounding_box.corner(2), 0.5, bounding_box.corner(4) + ) + node[:computed_data][:output][:center] = bounding_box.center + node[:computed_data][:output][:right_center] = Geom::Point3d.linear_combination( + 0.5, bounding_box.corner(3), 0.5, bounding_box.corner(5) + ) + node[:computed_data][:output][:top_center] = Geom::Point3d.linear_combination( + 0.5, bounding_box.corner(4), 0.5, bounding_box.corner(7) + ) + + node[:computed_data][:output][:back_bottom_left] = bounding_box.corner(2) + node[:computed_data][:output][:back_bottom_right] = bounding_box.corner(3) + node[:computed_data][:output][:back_center] = Geom::Point3d.linear_combination( + 0.5, bounding_box.corner(3), 0.5, bounding_box.corner(6) + ) + node[:computed_data][:output][:back_top_left] = bounding_box.corner(6) + node[:computed_data][:output][:back_top_right] = bounding_box.corner(7) + + end when 'Vector' diff --git a/source/parametric_modeling/nodes_editor.rb b/source/parametric_modeling/nodes_editor.rb index a7954df..78b284f 100644 --- a/source/parametric_modeling/nodes_editor.rb +++ b/source/parametric_modeling/nodes_editor.rb @@ -140,12 +140,26 @@ def self.translation "Variable K": TRANSLATE['Variable K'], "Variable L": TRANSLATE['Variable L'], "Formula example:": TRANSLATE['Formula example:'], + "Front bottom left": TRANSLATE['Front bottom left'], + "Front bottom right": TRANSLATE['Front bottom right'], + "Front center": TRANSLATE['Front center'], + "Front top left": TRANSLATE['Front top left'], + "Front top right": TRANSLATE['Front top right'], + "Bottom center": TRANSLATE['Bottom center'], + "Left center": TRANSLATE['Left center'], + "Center": TRANSLATE['Center'], + "Right center": TRANSLATE['Right center'], + "Top center": TRANSLATE['Top center'], + "Back bottom left": TRANSLATE['Back bottom left'], + "Back bottom right": TRANSLATE['Back bottom right'], + "Back center": TRANSLATE['Back center'], + "Back top left": TRANSLATE['Back top left'], + "Back top right": TRANSLATE['Back top right'], "Distance": TRANSLATE['Distance'], "Direction": TRANSLATE['Direction'], "Increment distance": TRANSLATE['Increment distance'], "Position": TRANSLATE['Position'], "Position is absolute": TRANSLATE['Position is absolute'], - "Center": TRANSLATE['Center'], "Axis": TRANSLATE['Axis'], "Angle": TRANSLATE['Angle'], "X factor": TRANSLATE['X factor'], @@ -170,6 +184,7 @@ def self.translation "Multiply": TRANSLATE['Multiply'], "Divide": TRANSLATE['Divide'], "Calculate": TRANSLATE['Calculate'], + "Get points": TRANSLATE['Get points'], "Intersect solids": TRANSLATE['Intersect solids'], "Unite solids": TRANSLATE['Unite solids'], "Subtract solids": TRANSLATE['Subtract solids'], @@ -283,6 +298,11 @@ def self.icons color: 'rgba(229, 157, 31, 0.5)' }, + "Get points": { + path: File.join(images_dir, 'get-points-node-icon.svg'), + color: 'rgba(100, 128, 147, 0.5)' + }, + "Vector": { path: File.join(images_dir, 'vector-node-icon.svg'), color: 'rgba(229, 56, 4, 0.5)'