Commit 974582a7 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

paraview plugin to extract material and boundary names

parent 93e7ae71
Pipeline #4899 passed with stage
in 26 seconds
......@@ -19,6 +19,6 @@
# along with this program (see COPYING and COPYING.LESSER files). If not,
# see <http://www.gnu.org/licenses/>.
MigFlow.xml : python_filter_generator.py contacts-extract.py ids-extract.py concentration-dg.py
python python_filter_generator.py $@ contacts-extract.py ids-extract.py concentration-dg.py
MigFlow.xml : python_filter_generator.py contacts-extract.py ids-extract.py concentration-dg.py names.py
python python_filter_generator.py $@ contacts-extract.py ids-extract.py concentration-dg.py names.py
......@@ -184,6 +184,61 @@
</SourceProxy>
</ProxyGroup>
<ProxyGroup name="filters">
<SourceProxy name="MFNames" class="vtkPythonProgrammableFilter" label="MigFlow names">
<Documentation
long_help="decode the material and tag name string arrays"
short_help="decode the material and tag name string arrays">
</Documentation>
<InputProperty
name="Input"
command="SetInputConnection">
<ProxyGroupDomain name="groups">
<Group name="sources"/>
<Group name="filters"/>
</ProxyGroupDomain>
<DataTypeDomain name="input_type">
<DataType value="vtkDataObject"/>
</DataTypeDomain>
</InputProperty>
<!-- Output data type: "Same as input" -->
<IntVectorProperty command="SetOutputDataSetType"
default_values="8"
name="OutputDataSetType"
number_of_elements="1"
panel_visibility="never">
<Documentation>The value of this property determines the dataset type
for the output of the programmable filter.</Documentation>
</IntVectorProperty>
<StringVectorProperty
name="Script"
command="SetScript"
number_of_elements="1"
default_values="import struct&#xA;def decode(name) :&#xA; es = inputs[0].FieldData[name].GetArrays()&#xA; for e in es :&#xA; if isinstance(e, vtk.numpy_interface.dataset_adapter.VTKNoneArray) :&#xA; continue&#xA; n = struct.unpack(&quot;i&quot;,e[:4])[0]&#xA; l = struct.unpack(&quot;%ii&quot;%n,e[4:4+4*n])&#xA; d = struct.unpack(&quot;&quot;.join(&quot;%is&quot;%i for i in l), e[4+n*4:])&#xA; print(name, list(n.decode() for n in d))&#xA;decode(&quot;MaterialNames&quot;)&#xA;decode(&quot;TagNames&quot;)&#xA;"
panel_visibility="advanced">
<Hints>
<Widget type="multi_line"/>
</Hints>
<Documentation>This property contains the text of a python program that
the programmable source runs.</Documentation>
</StringVectorProperty>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>
import struct
import numpy as np
Name = 'MFNames'
Label = 'MigFlow names'
Help = 'decode the material and tag name string arrays'
NumberOfInput = 1
#InputDataType = 'vtkUnstructuredGrid'
#OutputDataType = 'vtkUnstructuredGrid'
ExtraXml = ''
Properties = dict()
def RequestData():
import struct
def decode(name) :
es = inputs[0].FieldData[name].GetArrays()
for e in es :
if isinstance(e, vtk.numpy_interface.dataset_adapter.VTKNoneArray) :
continue
n = struct.unpack("i",e[:4])[0]
l = struct.unpack("%ii"%n,e[4:4+4*n])
d = struct.unpack("".join("%is"%i for i in l), e[4+n*4:])
print(name, list(n.decode() for n in d))
decode("MaterialNames")
decode("TagNames")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment