# Boilerplate code generated by OVITO Pro 3.7.2
from ovito.io import *
from ovito.modifiers import *
from ovito.data import *
from ovito.pipeline import *
from ovito.vis import *
from ovito.qt_compat import QtCore


pipeline = import_file('/data/emrosky-sim/Freezing_Simulations/Cavity_Within_Volume/Ibeam_capillary/Ten_Molecular_Layers/Wide_Ibeam/Constant_Cooling_240K/run_19/prod.ibeam_cooling_19.dump', multiple_frames = True)

# Visual element initialization:
data = pipeline.compute() # Evaluate new pipeline to gain access to visual elements associated with the imported data objects.
data.particles.vis.radius = 0.6
del data # Done accessing input DataCollection of pipeline.
pipeline.add_to_scene()

# Chill+:
pipeline.modifiers.append(ChillPlusModifier())

# Select type:
pipeline.modifiers.append(SelectTypeModifier(
    property = 'Structure Type', 
    types = {0, 3, 4, 5}))

# Delete selected:
pipeline.modifiers.append(DeleteSelectedModifier())

# Select type:
pipeline.modifiers.append(SelectTypeModifier(
    property = 'Structure Type', 
    types = {1, 2}, 
    enabled = False))

# Construct surface mesh:
mod = ConstructSurfaceModifier()
mod.radius = 5.8
mod.smoothing_level = 7
mod.identify_regions = True
mod.vis.show_cap = False
mod.vis.surface_transparency = 0.605
pipeline.modifiers.append(mod)

# Cluster analysis:
pipeline.modifiers.append(ClusterAnalysisModifier(
    sort_by_size = True, 
    compute_com = True))

# Expression selection:
pipeline.modifiers.append(ExpressionSelectionModifier(
    expression = 'Cluster != 1', 
    enabled = False))

# Delete selected:
pipeline.modifiers.append(DeleteSelectedModifier(enabled = False))

# Viewport setup:
viewport_layout = []

# Viewport "Top":
vp = Viewport()
vp.type = Viewport.Type.Top
vp.fov = 62.6142078915
vp.camera_pos = (78.752, 18.244646185, 20.239065242270662)
vp.overlays.append(CoordinateTripodOverlay())
viewport_layout.append((vp, [0.0, 0.0, 0.5, 0.5]))  # [left,top,width,height]

# Viewport "Left":
vp = Viewport()
vp.type = Viewport.Type.Left
vp.fov = 22.2629717665
vp.camera_dir = (1.0, -0.0, -0.0)
vp.camera_pos = (78.752, 18.244646185, 20.239065242270662)
vp.overlays.append(CoordinateTripodOverlay())
viewport_layout.append((vp, [0.0, 0.5, 0.5, 0.5]))  # [left,top,width,height]

# Viewport "Right":
vp = Viewport()
vp.type = Viewport.Type.Right
vp.fov = 21.2352289045
vp.camera_dir = (-1.0, -0.0, -0.0)
vp.camera_pos = (0.0, 17.568881137307553, 19.890582281926946)
vp.overlays.append(CoordinateTripodOverlay())
viewport_layout.append((vp, [0.5, 0.0, 0.5, 0.5]))  # [left,top,width,height]

# Viewport "Perspective":
vp = Viewport()
vp.type = Viewport.Type.Perspective
vp.fov = 0.610865238198
vp.camera_dir = (-0.6588262349773083, -0.5926456209285995, -0.4633779883634735)
vp.camera_pos = (206.61658482497984, 112.81567422187096, 87.42458590877047)
vp.overlays.append(CoordinateTripodOverlay())
vp.overlays.append(TextLabelOverlay(enabled = False))
viewport_layout.append((vp, [0.5, 0.5, 0.5, 0.5]))  # [left,top,width,height]

