graphkit-vtk 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/graphkit-vtk.gemspec +3 -3
- data/lib/graphkit-vtk.rb +99 -5
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.1
|
data/graphkit-vtk.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "graphkit-vtk"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Edmund Highcock"]
|
12
|
-
s.date = "2012-12-
|
12
|
+
s.date = "2012-12-30"
|
13
13
|
s.description = "An extension allowing graphkits to be rendered using the Visualization Toolkit. Uses the RubyPython gem to access the Python bindings for VTK."
|
14
14
|
s.email = "edmundhighcock@sourceforge.net"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.homepage = "http://github.com/edmundhighcock/graphkit-vtk"
|
34
34
|
s.licenses = ["GPLv3"]
|
35
35
|
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version = "1.8.
|
36
|
+
s.rubygems_version = "1.8.23"
|
37
37
|
s.summary = "An extension allowing graphkits to be rendered using the Visualization Toolkit."
|
38
38
|
|
39
39
|
if s.respond_to? :specification_version then
|
data/lib/graphkit-vtk.rb
CHANGED
@@ -34,6 +34,86 @@ class GraphKit
|
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
|
+
# This module contains methods for rendering GraphKits
|
38
|
+
# using the Visualization Toolkit (VTK). It uses the
|
39
|
+
# Python interface to VTK via the RubyPython bridge
|
40
|
+
# (see rubygems.org/gems/rubypython).
|
41
|
+
#
|
42
|
+
# It should work with vtk and vtk-python installed
|
43
|
+
# on any Linux distro.
|
44
|
+
#
|
45
|
+
# If you want to use it on a supercomputer you will
|
46
|
+
# almost certainly have to build Python and VTK yourself.
|
47
|
+
#
|
48
|
+
# The instructions below have been tested on Hector but
|
49
|
+
# can be easily adapted to work anywhere.
|
50
|
+
#
|
51
|
+
# First you need to configure your system to use the GNU
|
52
|
+
# compilers and with dynamic linking enabled. The instructions
|
53
|
+
# for configuring your system for installing CodeRunner should
|
54
|
+
# work well. See the CodeRunner wiki (coderunner.sourceforge.net).
|
55
|
+
#
|
56
|
+
# Choose a directory to install everything: <tt>myprefix</tt>.
|
57
|
+
#
|
58
|
+
# Download the source for Python 2.x (2.7 works as of Dec 2012),
|
59
|
+
# extract it and build it (with shared libraries) as follows.
|
60
|
+
# $ cd Python-2.7.3
|
61
|
+
# $ ./configure --prefix=<myprefix> --enable-shared LDFLAGS="-Wl,-rpath <myprefix/lib"
|
62
|
+
# $ make && make install
|
63
|
+
#
|
64
|
+
# Download the VTK source (tested with VTK 5.10) and extract it.
|
65
|
+
#
|
66
|
+
# Make a directory at the same level as the VTK source folder,
|
67
|
+
# e.g. VTK-bin. Make sure CMake is available (e.g. module load CMake).
|
68
|
+
# Configure like this:
|
69
|
+
# 1. $ cd VTK-bin
|
70
|
+
# 2. $ ccmake -i ../VTK5.10.1 # (replace with appropriate folder)
|
71
|
+
#
|
72
|
+
# You will now enter the CMake interactive configuration. Press 'c' to
|
73
|
+
# run the initial configuration. Press 't' to get to the advanced options.
|
74
|
+
# Make sure the settings below are as follows
|
75
|
+
# CMAKE_INSTALL_PREFIX <myprefix>
|
76
|
+
# VTK_WRAP_PYTHON on
|
77
|
+
# VTK_USE_RENDERING on
|
78
|
+
# VTK_USE_X off
|
79
|
+
# VTK_OPENGL_HAS_OSMESA on
|
80
|
+
#
|
81
|
+
# The last two settings mean that VTK won't try to pop up windows when
|
82
|
+
# it is rendering: instead it will write them straight to file.
|
83
|
+
# OSMESA stands for Off Screen Mesa, where Mesa is the open source
|
84
|
+
# graphics library.
|
85
|
+
#
|
86
|
+
# Press 'c' to update the configuration.
|
87
|
+
# Now update the following settings:
|
88
|
+
# PYTHON_EXECUTABLE <myprefix>/bin/python
|
89
|
+
# PYTHON_INCLUDE_DIR <myprefix>/include/python2.x
|
90
|
+
# PYTHON_LIBRARY <myprefix>/lib/libpython2.x.so
|
91
|
+
# VTK_USE_OFFSCREEN on
|
92
|
+
#
|
93
|
+
#
|
94
|
+
# Here is the funky bit: we don't want to use the standard hardware-enabled
|
95
|
+
# OpenGL libraries because we want to render offscreen. The standard OpenGL
|
96
|
+
# conflicts with OSMESA and makes SEGFAULTS (yuk). Instead we can have OSMESA
|
97
|
+
# replace all their functionality by setting
|
98
|
+
# OPENGL_glu_LIBRARY
|
99
|
+
# OPENGL_gl_LIBRARY
|
100
|
+
# to the same value as
|
101
|
+
# OSMESA_LIBRARY
|
102
|
+
#
|
103
|
+
# This will of course not be as fast, but that's OK because we are going
|
104
|
+
# to parallelise over the supercomputer when we write our rendering scripts!
|
105
|
+
#
|
106
|
+
# Press 'c' to configure once more, and 'g' to generate the makefiles.
|
107
|
+
# Now build
|
108
|
+
# $ make # This will take about 40 mins.
|
109
|
+
# $ make install
|
110
|
+
#
|
111
|
+
# Finally we need to setup python: add these lines to your .bashrc
|
112
|
+
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<myprefix>/lib/vtk-5.10/
|
113
|
+
# export PYTHONPATH=$PYTHONPATH:<myprefix>/lib/python2.7/site-packages/
|
114
|
+
# export PATH=<myprefix>/bin:$PATH
|
115
|
+
module VTK
|
116
|
+
|
37
117
|
# This method returns a VTKObjectGroup object, which
|
38
118
|
# contains references to the VTK/Python objects
|
39
119
|
# which are necessary to plot the graph.
|
@@ -43,7 +123,7 @@ class GraphKit
|
|
43
123
|
temp_write = false
|
44
124
|
unless filename
|
45
125
|
temp_write = true
|
46
|
-
filename = (Time.now.to_i).to_s + rand(
|
126
|
+
filename = (Time.now.to_i).to_s + rand(1000000).to_s + ".tmp.vtk"
|
47
127
|
to_vtk_legacy_fast(file_name: filename)
|
48
128
|
end
|
49
129
|
|
@@ -68,12 +148,23 @@ class GraphKit
|
|
68
148
|
mapper.SetInput(output)
|
69
149
|
mapper.SetScalarRange(scalar_range)
|
70
150
|
|
151
|
+
look_up_table = vtk.vtkLookupTable
|
152
|
+
look_up_table.SetNumberOfColors(64)
|
153
|
+
look_up_table.SetHueRange(0.0, 0.667)
|
154
|
+
mapper.SetLookupTable(look_up_table)
|
155
|
+
mapper.SetScalarModeToDefault
|
156
|
+
#mapper.CreateDefaultLookupTable
|
157
|
+
mapper.ScalarVisibilityOn
|
158
|
+
#mapper.SelectColorArray('myvals')
|
159
|
+
|
160
|
+
|
71
161
|
vtk_og.actor = actor = vtk.vtkActor
|
72
162
|
actor.SetMapper(mapper)
|
163
|
+
actor.VisibilityOn
|
73
164
|
|
74
165
|
vtk_og.renderer = renderer = vtk.vtkRenderer
|
75
166
|
renderer.AddActor(actor)
|
76
|
-
renderer.SetBackground(0,0,0)
|
167
|
+
#renderer.SetBackground(0,0,0)
|
77
168
|
|
78
169
|
vtk_og.renderer_window = renderer_window = vtk.vtkRenderWindow
|
79
170
|
renderer_window.SetSize(640,480)
|
@@ -83,9 +174,9 @@ class GraphKit
|
|
83
174
|
render_large.SetInput(vtk_og.renderer)
|
84
175
|
render_large.SetMagnification(4)
|
85
176
|
|
86
|
-
|
87
|
-
|
88
|
-
|
177
|
+
vtk_og.interactor = interactor = vtk.vtkRenderWindowInteractor
|
178
|
+
interactor.SetRenderWindow(renderer_window)
|
179
|
+
interactor.Initialize
|
89
180
|
#interactor.Start
|
90
181
|
|
91
182
|
return vtk_og
|
@@ -131,6 +222,9 @@ class GraphKit
|
|
131
222
|
|
132
223
|
|
133
224
|
|
225
|
+
end #module VTK
|
226
|
+
|
227
|
+
include VTK
|
134
228
|
|
135
229
|
|
136
230
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphkit-vtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphkit
|
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
143
|
version: '0'
|
144
144
|
segments:
|
145
145
|
- 0
|
146
|
-
hash:
|
146
|
+
hash: -3523229928342679442
|
147
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
148
|
none: false
|
149
149
|
requirements:
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
154
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.8.
|
155
|
+
rubygems_version: 1.8.23
|
156
156
|
signing_key:
|
157
157
|
specification_version: 3
|
158
158
|
summary: An extension allowing graphkits to be rendered using the Visualization Toolkit.
|