|
# state file generated using paraview version 5.11.1 |
|
import paraview |
|
paraview.compatibility.major = 5 |
|
paraview.compatibility.minor = 11 |
|
|
|
#### import the simple module from the paraview |
|
from paraview.simple import * |
|
#### disable automatic camera reset on 'Show' |
|
paraview.simple._DisableFirstRenderCameraReset() |
|
|
|
# ---------------------------------------------------------------- |
|
# setup the data processing pipelines |
|
# |
|
# Edit the inputGeom to use your own geometry file |
|
# ---------------------------------------------------------------- |
|
|
|
# create a new 'Wavefront OBJ Reader' |
|
inputGeom = WavefrontOBJReader(registrationName='InputGeom.obj', FileName='/PATH/TO/YOUR_GEOMETRY_FILE_GOES_HERE.obj') |
|
|
|
# create a new 'Compute Connected Surface Properties' |
|
computeConnectedSurfaceProperties = ComputeConnectedSurfaceProperties(registrationName='ComputeConnectedSurfaceProperties', Input=inputGeom) |
|
|
|
# create a new 'Programmable Filter' |
|
programmableFilter = ProgrammableFilter(registrationName='ProgrammableFilter', Input=computeConnectedSurfaceProperties) |
|
programmableFilter.Script = """ |
|
|
|
# Using the output of the previous filter |
|
input0 = inputs[0] |
|
|
|
# Grab an object's centroid based on its ID & store it in a new field |
|
data = input0.FieldData["ObjectCentroids"][input0.CellData["ObjectIds"]] |
|
|
|
# Append the centroid field as cell data for use later |
|
output.CellData.append(data, "Centroid") |
|
|
|
# Append the object ID as cell data for use later |
|
output.CellData.append(input0.CellData["ObjectIds"], "Id") |
|
|
|
""" |
|
|
|
# create a new 'Cell Data to Point Data' |
|
cellDatatoPointData = CellDatatoPointData(registrationName='CellDatatoPointData', Input=programmableFilter) |
|
|
|
# create a modified version of the original 'Centroid' vector |
|
# this version exagerates the explosion in the Y & Z-directions & tones it down in the X-direction |
|
# modify this to suit your requirements |
|
calculator = Calculator(registrationName='Calculator', Input=cellDatatoPointData) |
|
calculator.ResultArrayName = 'ToWarp' |
|
calculator.Function = '(0.75*Centroid_X*iHat)+(1.1*Centroid_Y*jHat)+(2.2*Centroid_Z*kHat)' |
|
|
|
# explode our assembly using 'Warp By Vector' & our new/tweaked 'ToWarp' Vector |
|
warpByVector = WarpByVector(registrationName='WarpByVector', Input=calculator) |
|
warpByVector.Vectors = ['POINTS', 'ToWarp'] |
|
warpByVector.ScaleFactor = 1.0 |
|
|
|
|
|
# ---------------------------------------------------------------- |
|
# setup views used in the visualization |
|
# ---------------------------------------------------------------- |
|
|
|
# Create a new 'Render View' |
|
renderView1 = CreateView('RenderView') |
|
renderView1.CameraPosition = [-2525, 1327, 440] |
|
renderView1.CameraFocalPoint = [-390, 58, -190] |
|
renderView1.CameraViewUp = [0, 0, 1] |
|
renderView1.CameraFocalDisk = 1.0 |
|
renderView1.CameraParallelScale = 663.607 |
|
|
|
SetActiveView(None) |
|
|
|
# ---------------------------------------------------------------- |
|
# setup view layouts |
|
|
|
# create new layout object 'Layout #1' |
|
layout1 = CreateLayout(name='Layout #1') |
|
layout1.AssignView(0, renderView1) |
|
|
|
# restore active view |
|
SetActiveView(renderView1) |
|
# ---------------------------------------------------------------- |
|
|
|
# ---------------------------------------------------------------- |
|
# setup the visualization in view 'renderView1' |
|
|
|
# show data from warpByVector |
|
warpByVectorDisplay = Show(warpByVector, renderView1, 'GeometryRepresentation') |
|
|
|
# get 2D transfer function for 'Id' |
|
idTF2D = GetTransferFunction2D('Id') |
|
|
|
# get color transfer function/color map for 'Id' |
|
idLUT = GetColorTransferFunction('Id') |
|
idLUT.TransferFunction2D = idTF2D |
|
idLUT.RGBPoints = [0.0, 0.231373, 0.298039, 0.752941, 7.5, 0.865003, 0.865003, 0.865003, 15.0, 0.705882, 0.0156863, 0.14902] |
|
idLUT.ScalarRangeInitialized = 1.0 |
|
|
|
# set some basic display properties |
|
warpByVectorDisplay.Representation = 'Surface' |
|
warpByVectorDisplay.ColorArrayName = ['POINTS', 'Id'] |
|
warpByVectorDisplay.LookupTable = idLUT |
|
|
|
# ---------------------------------------------------------------- |
|
# restore active source |
|
SetActiveSource(warpByVector) |
|
|
|
renderView1.ResetCamera(True) |
|
# ---------------------------------------------------------------- |