Skip to content

Commit 9684db7

Browse files
committed
Input arrays for multiple inputs now supported!
1 parent 0ef028c commit 9684db7

File tree

4 files changed

+87
-74
lines changed

4 files changed

+87
-74
lines changed

plugins/PVGP-General-Filters.xml

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,6 @@
334334
</RequiredProperties>
335335
</FieldDataDomain>
336336
</StringVectorProperty>
337-
338-
339337
<StringVectorProperty
340338
name="SelectInputScalars1"
341339
label="Array Input 2"
@@ -365,8 +363,6 @@
365363
</StringVectorProperty>
366364

367365

368-
369-
370366
<IntVectorProperty
371367
panel_visibility="default"
372368
name="test_bool"
@@ -672,8 +668,6 @@
672668
</RequiredProperties>
673669
</FieldDataDomain>
674670
</StringVectorProperty>
675-
676-
677671
<StringVectorProperty
678672
name="SelectInputScalars1"
679673
label="Array 2"
@@ -703,8 +697,6 @@
703697
</StringVectorProperty>
704698

705699

706-
707-
708700
<DoubleVectorProperty
709701
panel_visibility="default"
710702
name="Multiplier"
@@ -831,8 +823,6 @@
831823
</RequiredProperties>
832824
</FieldDataDomain>
833825
</StringVectorProperty>
834-
835-
836826
<StringVectorProperty
837827
name="SelectInputScalars1"
838828
label="Longitude"
@@ -860,8 +850,6 @@
860850
</RequiredProperties>
861851
</FieldDataDomain>
862852
</StringVectorProperty>
863-
864-
865853
<StringVectorProperty
866854
name="SelectInputScalars2"
867855
label="Altitude"
@@ -891,8 +879,6 @@
891879
</StringVectorProperty>
892880

893881

894-
895-
896882
<DoubleVectorProperty
897883
panel_visibility="default"
898884
name="Radius"
@@ -1026,8 +1012,6 @@
10261012
</StringVectorProperty>
10271013

10281014

1029-
1030-
10311015
<IntVectorProperty
10321016
panel_visibility="default"
10331017
name="Absolute_Value"
@@ -1193,14 +1177,69 @@
11931177
</DataTypeDomain>
11941178
</InputProperty>
11951179

1180+
<StringVectorProperty
1181+
name="SelectInputScalars0"
1182+
label="Array Input 1"
1183+
command="SetInputArrayToProcess"
1184+
default_values="0 NULL"
1185+
number_of_elements="5"
1186+
element_types="0 0 0 0 2"
1187+
animateable="0">
1188+
<ArrayListDomain
1189+
name="array_list"
1190+
attribute_type="Scalars"
1191+
input_domain_name="inputs_array">
1192+
<RequiredProperties>
1193+
<Property
1194+
name="Input foo 1"
1195+
function="Input" />
1196+
</RequiredProperties>
1197+
</ArrayListDomain>
1198+
<FieldDataDomain
1199+
name="field_list">
1200+
<RequiredProperties>
1201+
<Property
1202+
name="Input foo 1"
1203+
function="Input" />
1204+
</RequiredProperties>
1205+
</FieldDataDomain>
1206+
</StringVectorProperty>
1207+
1208+
<StringVectorProperty
1209+
name="SelectInputScalars1"
1210+
label="Array Input 2"
1211+
command="SetInputArrayToProcess"
1212+
default_values="1 NULL"
1213+
number_of_elements="5"
1214+
element_types="0 0 0 0 2"
1215+
animateable="0">
1216+
<ArrayListDomain
1217+
name="array_list"
1218+
attribute_type="Scalars"
1219+
input_domain_name="inputs_array">
1220+
<RequiredProperties>
1221+
<Property
1222+
name="Input foo 2"
1223+
function="Input" />
1224+
</RequiredProperties>
1225+
</ArrayListDomain>
1226+
<FieldDataDomain
1227+
name="field_list">
1228+
<RequiredProperties>
1229+
<Property
1230+
name="Input foo 2"
1231+
function="Input" />
1232+
</RequiredProperties>
1233+
</FieldDataDomain>
1234+
</StringVectorProperty>
11961235

11971236

11981237

11991238
<StringVectorProperty
12001239
name="Script"
12011240
command="SetScript"
12021241
number_of_elements="1"
1203-
default_values="from vtk.util import numpy_support as nps&#xA;import PVGPpy.helpers as inputhelp&#xA;pdo = self.GetOutput() # VTK Data Type&#xA;# Inputs from different ports:&#xA;pdi0 = self.GetInputDataObject(0, 0) # PORT 0&#xA;pdi1 = self.GetInputDataObject(1, 0) # PORT 1&#xA;print(type(pdi0))&#xA;print(type(pdi1))&#xA;&#xA;name = inputhelp.getSelectedArrayName(self, 0)&#xA;field = inputhelp.getSelectedArrayField(self, )&#xA;&#xA;print(name,field)&#xA;"
1242+
default_values="from vtk.util import numpy_support as nps&#xA;import PVGPpy.helpers as inputhelp&#xA;pdo = self.GetOutput() # VTK Data Type&#xA;# Inputs from different ports:&#xA;pdi0 = self.GetInputDataObject(0, 0) # PORT 0&#xA;pdi1 = self.GetInputDataObject(1, 0) # PORT 1&#xA;&#xA;# DO STUFF WITH INOUTS AND OUTPUTS&#xA;print(type(pdi0))&#xA;print(type(pdi1))&#xA;&#xA;name0 = inputhelp.getSelectedArrayName(self, 0)&#xA;name1 = inputhelp.getSelectedArrayName(self, 1)&#xA;&#xA;print(name0,name1)&#xA;"
12041243
panel_visibility="advanced">
12051244
<Hints>
12061245
<Widget type="multi_line" syntax="python"/>

plugins/PVGP-Tunneling-Plugins.xml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@
8989
</RequiredProperties>
9090
</FieldDataDomain>
9191
</StringVectorProperty>
92-
93-
9492
<StringVectorProperty
9593
name="SelectInputScalars1"
9694
label="Northing"
@@ -118,8 +116,6 @@
118116
</RequiredProperties>
119117
</FieldDataDomain>
120118
</StringVectorProperty>
121-
122-
123119
<StringVectorProperty
124120
name="SelectInputScalars2"
125121
label="Elevation"
@@ -147,8 +143,6 @@
147143
</RequiredProperties>
148144
</FieldDataDomain>
149145
</StringVectorProperty>
150-
151-
152146
<StringVectorProperty
153147
name="SelectInputScalars3"
154148
label="Status"
@@ -178,8 +172,6 @@
178172
</StringVectorProperty>
179173

180174

181-
182-
183175
<DoubleVectorProperty
184176
panel_visibility="default"
185177
name="Diameter"
@@ -341,8 +333,6 @@
341333
</RequiredProperties>
342334
</FieldDataDomain>
343335
</StringVectorProperty>
344-
345-
346336
<StringVectorProperty
347337
name="SelectInputScalars1"
348338
label="Head Northing"
@@ -370,8 +360,6 @@
370360
</RequiredProperties>
371361
</FieldDataDomain>
372362
</StringVectorProperty>
373-
374-
375363
<StringVectorProperty
376364
name="SelectInputScalars2"
377365
label="Head Elevation"
@@ -399,8 +387,6 @@
399387
</RequiredProperties>
400388
</FieldDataDomain>
401389
</StringVectorProperty>
402-
403-
404390
<StringVectorProperty
405391
name="SelectInputScalars3"
406392
label="Arti Easting"
@@ -428,8 +414,6 @@
428414
</RequiredProperties>
429415
</FieldDataDomain>
430416
</StringVectorProperty>
431-
432-
433417
<StringVectorProperty
434418
name="SelectInputScalars4"
435419
label="Arti Northing"
@@ -457,8 +441,6 @@
457441
</RequiredProperties>
458442
</FieldDataDomain>
459443
</StringVectorProperty>
460-
461-
462444
<StringVectorProperty
463445
name="SelectInputScalars5"
464446
label="Arti Elevation"
@@ -486,8 +468,6 @@
486468
</RequiredProperties>
487469
</FieldDataDomain>
488470
</StringVectorProperty>
489-
490-
491471
<StringVectorProperty
492472
name="SelectInputScalars6"
493473
label="Tail Easting"
@@ -515,8 +495,6 @@
515495
</RequiredProperties>
516496
</FieldDataDomain>
517497
</StringVectorProperty>
518-
519-
520498
<StringVectorProperty
521499
name="SelectInputScalars7"
522500
label="Tail Northing"
@@ -544,8 +522,6 @@
544522
</RequiredProperties>
545523
</FieldDataDomain>
546524
</StringVectorProperty>
547-
548-
549525
<StringVectorProperty
550526
name="SelectInputScalars8"
551527
label="Tail Elevation"
@@ -575,8 +551,6 @@
575551
</StringVectorProperty>
576552

577553

578-
579-
580554
<DoubleVectorProperty
581555
panel_visibility="default"
582556
name="Diameter"

src/filters-general/example_filter_mult.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
InputDataType = ['vtkDataObject', 'vtkDataObject']
1818
OutputDataType = 'vtkPolyData' # Must be specified when many inputs specified
1919

20-
# NOTE: Input arrays are not supported for filters with multiple inputs.
20+
# How to add input arrays:
21+
#- Number of Input array drop down choices
22+
NumberOfInputArrayChoices = [1,1]
23+
#- Labels for the array drop down choices:
24+
InputArrayLabels = [['Array Input 1'], ['Array Input 2']]
2125

2226
# Any extra XML GUI components you might like:
2327
ExtraXml = ''
@@ -41,10 +45,12 @@ def RequestData(self):
4145
# Inputs from different ports:
4246
pdi0 = self.GetInputDataObject(0, 0) # PORT 0
4347
pdi1 = self.GetInputDataObject(1, 0) # PORT 1
48+
49+
# DO STUFF WITH INOUTS AND OUTPUTS
4450
print(type(pdi0))
4551
print(type(pdi1))
4652

47-
name = inputhelp.getSelectedArrayName(self, 0)
48-
field = inputhelp.getSelectedArrayField(self, )
53+
name0 = inputhelp.getSelectedArrayName(self, 0)
54+
name1 = inputhelp.getSelectedArrayName(self, 1)
4955

50-
print(name,field)
56+
print(name0,name1)

src/python_filter_generator.py

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,12 @@ def getInputPropertyXml(info, inputDataType=None, name="Input", port=0):
312312

313313

314314

315-
def _helpArraysXML(info, inputName=None, numArrays=None, labels=None):
316-
# Gets input arrays XML for each input
317-
###################################################
318-
# Perfrom XML generation for single input at a time
319-
def _getInputArrayXML(idx, label, name=None):
320-
if name is None: name = 'Input'
321-
return'''
315+
def _helpArraysXML(info, idx, inputName=None, label=None):
316+
if inputName is None:
317+
inputName = 'Input'
318+
if label is None:
319+
label = 'Array%d' % idx
320+
return'''
322321
<StringVectorProperty
323322
name="SelectInputScalars%d"
324323
label="%s"
@@ -345,14 +344,7 @@ def _getInputArrayXML(idx, label, name=None):
345344
function="Input" />
346345
</RequiredProperties>
347346
</FieldDataDomain>
348-
</StringVectorProperty>''' % (idx, label, idx, name, name)
349-
350-
351-
xml = ''
352-
for i in range(numArrays):
353-
xml += _getInputArrayXML(i, labels[i], name=inputName)
354-
xml += '\n\n'
355-
return xml
347+
</StringVectorProperty>''' % (idx, label, idx, inputName, inputName)
356348

357349

358350

@@ -366,20 +358,19 @@ def getInputArraysXML(info):
366358
numberOfInputs = getNumberOfInputs(info)
367359
numArrays = info.get("NumberOfInputArrayChoices")
368360

369-
if numberOfInputs > 1:
361+
"""if numberOfInputs > 1:
370362
print('WARNING: Filters with multiple inputs do not support input selection arrays at this time.')
371-
return ''
363+
return ''"""
372364

373365
def getLabels():
374366
labels = info.get('InputArrayLabels', None)
375-
"""FOR MULTIPLE INPUTS
376367
if labels is None and numberOfInputs > 1:
377368
labels = [None]*numberOfInputs
378369
return labels
379370
if numberOfInputs > 1:
380371
for l in labels:
381372
if type(l) is not list:
382-
raise Exception('`InputArrayLabels` is improperly structured. Must be a list of lists.')"""
373+
raise Exception('`InputArrayLabels` is improperly structured. Must be a list of lists.')
383374
return labels
384375

385376
labels = getLabels()
@@ -397,28 +388,31 @@ def fixArrayLabels(labels, numArrays):
397388
return labels
398389

399390
# Recursively call for each input
400-
"""FOR MULTIPLE INPUTS
401391
if numberOfInputs > 1:
402392
if type(numArrays) is not list:
403393
raise Exception('When multiple inputs, the `NumberOfInputArrayChoices` must be a list of ints for the number of arrays from each input.')
404394
if len(numArrays) != numberOfInputs:
405395
raise Exception('You must spectify how many arrays come from each input. `len(NumberOfInputArrayChoices) != NumberOfInputs`.')
406396
inputNames = info.get('InputNames')
407-
print(inputNames)
408397

409398
# Now perfrom recursion
410399
out = []
411400
for i in range(numberOfInputs):
412401
# Fix labels
413-
print(i)
414402
labs = fixArrayLabels(labels[i], numArrays[i])
415-
out.append(_helpArraysXML(info, inputName=inputNames[i], numArrays=numArrays[i], labels=labs))
403+
xml = ''
404+
for j in range(numArrays[i]):
405+
xml += _helpArraysXML(info, i+j, inputName=inputNames[i], label=labs[j])
406+
out.append(xml)
416407
outstr = "\n".join(inp for inp in out)
417408
return outstr
418-
else:"""
419-
# Get parameters from info and call:
420-
labels = fixArrayLabels(labels, numArrays)
421-
return _helpArraysXML(info, inputName=None, numArrays=numArrays, labels=labels)
409+
else:
410+
# Get parameters from info and call:
411+
labs = fixArrayLabels(labels, numArrays)
412+
xml = ''
413+
for j in range(numArrays):
414+
xml += _helpArraysXML(info, j, inputName=None, label=labs[j])
415+
return xml
422416

423417

424418
def getVersionAttribute():

0 commit comments

Comments
 (0)