This file is indexed.

/usr/share/vtk/Modelling/Python/SpherePuzzle.py is in vtk-examples 5.8.0-17.5.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env python

# A game with VTK and Tkinter. :)

import Tkinter
import vtk
from vtk.tk.vtkTkRenderWindowInteractor import vtkTkRenderWindowInteractor

# Create the pipeline
puzzle = vtk.vtkSpherePuzzle()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(puzzle.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)

arrows = vtk.vtkSpherePuzzleArrows()
mapper2 = vtk.vtkPolyDataMapper()
mapper2.SetInputConnection(arrows.GetOutputPort())
actor2 = vtk.vtkActor()
actor2.SetMapper(mapper2)

renWin = vtk.vtkRenderWindow()
ren = vtk.vtkRenderer()
renWin.AddRenderer(ren)

# Add the actors to the renderer, set the background and size
ren.AddActor(actor)
ren.AddActor(actor2)
ren.SetBackground(0.1, 0.2, 0.4)

ren.ResetCamera()
cam = ren.GetActiveCamera()
cam.Elevation(-40)


## Generate the GUI
root = Tkinter.Tk()
root.withdraw()

# Define a quit method that exits cleanly.
def quit(obj=root):
    obj.quit()

# Create the toplevel window
top = Tkinter.Toplevel(root)
top.title("Sphere Puzzle")
top.protocol("WM_DELETE_WINDOW", quit)

# Create some frames
f1 = Tkinter.Frame(top)
f2 = Tkinter.Frame(top)

f1.pack(side="top", anchor="n", expand=1, fill="both")
f2.pack(side="bottom", anchor="s", expand="t", fill="x")

# Create the Tk render widget, and bind the events
rw = vtkTkRenderWindowInteractor(f1, width=400, height=400, rw=renWin)
rw.pack(expand="t", fill="both")

def reset(evt=None):
    puzzle.Reset()
    renWin.Render()

# Display some information
l1 = Tkinter.Label(f2, text="Position cursor over the rotation plane.")
l2 = Tkinter.Label(f2, text="Moving pieces will be highlighted.")
l3 = Tkinter.Label(f2, text="Press 'm' to make a move.")
reset = Tkinter.Button(f2, text="Reset", command=reset)

b1 = Tkinter.Button(f2, text="Quit", command=quit)

for i in (l1, l2, l3, reset, b1):
    i.pack(side="top", expand="t", fill="x")

# Done with the GUI.  Create callback functions.

in_piece_rotation = 0
LastVal = None

# Highlight pieces
def MotionCallback(obj, event):
    global in_piece_rotation
    global LastVal
    if in_piece_rotation:
        return 

    iren = renWin.GetInteractor()
    istyle = iren.GetInteractorStyle().GetCurrentStyle()

    # Return if the user is performing interaction
    if istyle.GetState():
        return
 
    # Get mouse position
    pos = iren.GetEventPosition()
    x, y = pos

    # Get world point
    ren.SetDisplayPoint(x, y, ren.GetZ(x, y))
    ren.DisplayToWorld()
    pt = ren.GetWorldPoint()
    val = puzzle.SetPoint(pt[0], pt[1], pt[2])

    if (not LastVal) or val != LastVal:
        renWin.Render()
        LastVal = val

# Rotate the puzzle
def CharCallback(obj, event):
    iren = renWin.GetInteractor()

    keycode = iren.GetKeyCode()
    if keycode != "m" and keycode != "M":
        return
    
    pos = iren.GetEventPosition()
    ButtonCallback(pos[0], pos[1])
 

def ButtonCallback(x, y):
    global in_piece_rotation
    if in_piece_rotation:
        return
    in_piece_rotation = 1

    # Get world point
    ren.SetDisplayPoint(x, y, ren.GetZ(x,y))
    ren.DisplayToWorld()
    pt = ren.GetWorldPoint()
    x, y, z = pt[:3]

    for i in range(0, 101, 10):
        puzzle.SetPoint(x, y, z)
        puzzle.MovePoint(i)
        renWin.Render()
        root.update()

    in_piece_rotation = 0
 
root.update()

# Modify some bindings, use the interactor style 'switch'
iren = renWin.GetInteractor()
istyle = vtk.vtkInteractorStyleSwitch()

iren.SetInteractorStyle(istyle)
istyle.SetCurrentStyleToTrackballCamera()

iren.AddObserver("MouseMoveEvent", MotionCallback)
iren.AddObserver("CharEvent", CharCallback)

# Shuffle the puzzle
ButtonCallback(218, 195)
ButtonCallback(261, 128)
ButtonCallback(213, 107)
ButtonCallback(203, 162)
ButtonCallback(134, 186)

iren.Initialize()
renWin.Render()
iren.Start()

root.mainloop()