ruby-gr 0.0.20 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +2 -2
- data/README.md +44 -36
- data/lib/gr.rb +1022 -843
- data/lib/gr/ffi.rb +5 -2
- data/lib/gr/plot.rb +93 -41
- data/lib/gr3.rb +305 -246
- data/lib/gr3/ffi.rb +1 -1
- data/lib/gr_commons/define_methods.rb +5 -5
- data/lib/gr_commons/fiddley.rb +7 -7
- data/lib/gr_commons/gr_common_utils.rb +4 -4
- data/lib/gr_commons/gr_commons.rb +5 -1
- data/lib/gr_commons/gr_lib.rb +83 -0
- data/lib/gr_commons/gr_logger.rb +106 -0
- data/lib/gr_commons/jupyter_support.rb +5 -5
- data/lib/gr_commons/{extern.rb → try_extern.rb} +1 -1
- data/lib/gr_commons/version.rb +1 -1
- data/lib/grm.rb +34 -17
- data/lib/grm/ffi.rb +28 -14
- metadata +21 -6
- data/lib/gr/plot.rb.md +0 -172
data/lib/gr/ffi.rb
CHANGED
@@ -15,7 +15,7 @@ module GR
|
|
15
15
|
raise LoadError, 'Could not find GR Framework'
|
16
16
|
end
|
17
17
|
|
18
|
-
extend GRCommons::
|
18
|
+
extend GRCommons::TryExtern
|
19
19
|
|
20
20
|
# https://github.com/sciapp/gr/blob/master/lib/gr/gr.h
|
21
21
|
# keep same order
|
@@ -41,6 +41,8 @@ module GR
|
|
41
41
|
'int, int, int, int, int, int, int *)'
|
42
42
|
try_extern 'void gr_polarcellarray(double, double, double, double, double, double, ' \
|
43
43
|
'int, int, int, int, int, int, int *)'
|
44
|
+
try_extern 'void gr_nonuniformpolarcellarray(double, double, double *, double *, ' \
|
45
|
+
'int, int, int, int, int, int, int *);'
|
44
46
|
try_extern 'void gr_gdp(int, double *, double *, int, int, int *)'
|
45
47
|
try_extern 'void gr_spline(int, double *, double *, int, int)'
|
46
48
|
try_extern 'void gr_gridit(int, double *, double *, double *, int, int, ' \
|
@@ -174,7 +176,7 @@ module GR
|
|
174
176
|
try_extern 'void gr_shadepoints(int, double *, double *, int, int, int)'
|
175
177
|
try_extern 'void gr_shadelines(int, double *, double *, int, int, int)'
|
176
178
|
try_extern 'void gr_panzoom(double, double, double, double, double *, double *, double *, double *)'
|
177
|
-
|
179
|
+
try_extern 'int gr_findboundary(int, double *, double *, double, double (*)(double, double), int, int *)'
|
178
180
|
try_extern 'void gr_setresamplemethod(unsigned int flag)'
|
179
181
|
try_extern 'void gr_inqresamplemethod(unsigned int *flag)'
|
180
182
|
try_extern 'void gr_path(int, double *, double *, const char *)'
|
@@ -202,5 +204,6 @@ module GR
|
|
202
204
|
try_extern 'void gr_inqtext3d(double, double, double, char *, int axis, double *, double *)'
|
203
205
|
try_extern 'void gr_settextencoding(int)'
|
204
206
|
try_extern 'void gr_inqtextencoding(int *)'
|
207
|
+
# gr_setcallback(char *(*)(const char *));
|
205
208
|
end
|
206
209
|
end
|
data/lib/gr/plot.rb
CHANGED
@@ -38,12 +38,49 @@ module GR
|
|
38
38
|
|
39
39
|
# Keyword options conform to GR.jl.
|
40
40
|
KW_ARGS = %i[accelerate algorithm alpha ax backgroundcolor barwidth baseline
|
41
|
-
clabels clear clim color colormap crange figsize grid
|
42
|
-
isovalue kind label labels levels location nbins
|
43
|
-
scale size spec subplot tilt title update xaxis
|
44
|
-
xlabel xlim xlog xrange xticks yaxis yflip ylabel
|
45
|
-
zflip yrange yticks viewport vp where window zaxis
|
46
|
-
zlog zrange zticks].freeze
|
41
|
+
clabels clear clim color colormap crange figsize font grid
|
42
|
+
horizontal isovalue kind label labels levels location nbins
|
43
|
+
ratio rotation scale size spec subplot tilt title update xaxis
|
44
|
+
xflip xform xlabel xlim xlog xrange xticks yaxis yflip ylabel
|
45
|
+
ylim ylog zflip yrange yticks viewport vp where window zaxis
|
46
|
+
zlabel zlim zlog zrange zticks].freeze
|
47
|
+
|
48
|
+
FONTS = {
|
49
|
+
times_roman: 101,
|
50
|
+
times_italic: 102,
|
51
|
+
times_bold: 103,
|
52
|
+
times_bolditalic: 104,
|
53
|
+
helvetica_regular: 105,
|
54
|
+
helvetica_oblique: 106,
|
55
|
+
helvetica_bold: 107,
|
56
|
+
helvetica_boldoblique: 108,
|
57
|
+
courier_regular: 109,
|
58
|
+
courier_oblique: 110,
|
59
|
+
courier_bold: 111,
|
60
|
+
courier_boldoblique: 112,
|
61
|
+
symbol: 113,
|
62
|
+
bookman_light: 114,
|
63
|
+
bookman_lightitalic: 115,
|
64
|
+
bookman_demi: 116,
|
65
|
+
bookman_demiitalic: 117,
|
66
|
+
newcenturyschlbk_roman: 118,
|
67
|
+
newcenturyschlbk_italic: 119,
|
68
|
+
newcenturyschlbk_bold: 120,
|
69
|
+
newcenturyschlbk_bolditalic: 121,
|
70
|
+
avantgarde_book: 122,
|
71
|
+
avantgarde_bookoblique: 123,
|
72
|
+
avantgarde_demi: 124,
|
73
|
+
avantgarde_demioblique: 125,
|
74
|
+
palatino_roman: 126,
|
75
|
+
palatino_italic: 127,
|
76
|
+
palatino_bold: 128,
|
77
|
+
palatino_bolditalic: 129,
|
78
|
+
zapfchancery_mediumitalic: 130,
|
79
|
+
zapfdingbats: 131,
|
80
|
+
cmuserif_math: 232, # original: cmuserif-math
|
81
|
+
dejavusans: 233,
|
82
|
+
pingfangsc: 234
|
83
|
+
}.freeze
|
47
84
|
|
48
85
|
@last_plot = nil
|
49
86
|
class << self
|
@@ -62,7 +99,7 @@ module GR
|
|
62
99
|
# label(singular form) is a original keyword arg which GR.jl does not have.
|
63
100
|
kvs[:labels] ||= [kvs[:label]] if kvs.has_key? :label
|
64
101
|
|
65
|
-
# Don't use
|
102
|
+
# Don't use ||= here, because we need to tell `false` from `nil`
|
66
103
|
kvs[:size] = [600, 450] unless kvs.has_key? :size
|
67
104
|
kvs[:ax] = false unless kvs.has_key? :ax
|
68
105
|
kvs[:subplot] = [0, 1, 0, 1] unless kvs.has_key? :subplot
|
@@ -185,8 +222,12 @@ module GR
|
|
185
222
|
minmax
|
186
223
|
end
|
187
224
|
|
188
|
-
major_count = %i[wireframe surface plot3 scatter3 polar polarhist
|
189
|
-
|
225
|
+
major_count = if %i[wireframe surface plot3 scatter3 polar polarhist
|
226
|
+
polarheatmap trisurf volume].include?(kind)
|
227
|
+
2
|
228
|
+
else
|
229
|
+
5
|
230
|
+
end
|
190
231
|
|
191
232
|
kvs[:xticks] = [kvs[:xticks], major_count] if kvs[:xticks].is_a? Numeric
|
192
233
|
kvs[:yticks] = [kvs[:yticks], major_count] if kvs[:yticks].is_a? Numeric
|
@@ -198,10 +239,10 @@ module GR
|
|
198
239
|
xmax += 0.5
|
199
240
|
end
|
200
241
|
xtick, majorx = if (scale & GR::OPTION_X_LOG) == 0
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
242
|
+
if !%i[heatmap polarheatmap].include?(kind) &&
|
243
|
+
!kvs.has_key?(:xlim) &&
|
244
|
+
!kvs[:panzoom]
|
245
|
+
xmin, xmax = GR.adjustlimits(xmin, xmax)
|
205
246
|
end
|
206
247
|
if kvs.has_key?(:xticks)
|
207
248
|
kvs[:xticks]
|
@@ -227,10 +268,10 @@ module GR
|
|
227
268
|
end
|
228
269
|
end
|
229
270
|
ytick, majory = if (scale & GR::OPTION_Y_LOG) == 0
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
271
|
+
if !%i[heatmap polarheatmap].include?(kind) &&
|
272
|
+
!kvs.has_key?(:ylim) &&
|
273
|
+
!kvs[:panzoom]
|
274
|
+
ymin, ymax = GR.adjustlimits(ymin, ymax)
|
234
275
|
end
|
235
276
|
if kvs.has_key?(:yticks)
|
236
277
|
kvs[:yticks]
|
@@ -341,29 +382,29 @@ module GR
|
|
341
382
|
GR.axes(xtick, ytick, xorg[1], yorg[1], -majorx, -majory, -ticksize)
|
342
383
|
end
|
343
384
|
|
344
|
-
if kvs
|
385
|
+
if kvs.has_key?(:title)
|
345
386
|
GR.savestate
|
346
387
|
GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
|
347
|
-
text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title])
|
388
|
+
text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title].to_s)
|
348
389
|
GR.restorestate
|
349
390
|
end
|
350
391
|
if %i[wireframe surface plot3 scatter3 trisurf volume].include?(kind)
|
351
|
-
xlabel = kvs[:xlabel] || ''
|
352
|
-
ylabel = kvs[:ylabel] || ''
|
353
|
-
zlabel = kvs[:zlabel] || ''
|
392
|
+
xlabel = (kvs[:xlabel] || '').to_s
|
393
|
+
ylabel = (kvs[:ylabel] || '').to_s
|
394
|
+
zlabel = (kvs[:zlabel] || '').to_s
|
354
395
|
GR.titles3d(xlabel, ylabel, zlabel)
|
355
396
|
else
|
356
397
|
if kvs.has_key?(:xlabel)
|
357
398
|
GR.savestate
|
358
399
|
GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_BOTTOM)
|
359
|
-
text(0.5 * (viewport[0] + viewport[1]), vp[2] + 0.5 * charheight, kvs[:xlabel])
|
400
|
+
text(0.5 * (viewport[0] + viewport[1]), vp[2] + 0.5 * charheight, kvs[:xlabel].to_s)
|
360
401
|
GR.restorestate
|
361
402
|
end
|
362
403
|
if kvs.has_key?(:ylabel)
|
363
404
|
GR.savestate
|
364
405
|
GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
|
365
406
|
GR.setcharup(-1, 0)
|
366
|
-
text(vp[0] + 0.5 * charheight, 0.5 * (viewport[2] + viewport[3]), kvs[:ylabel])
|
407
|
+
text(vp[0] + 0.5 * charheight, 0.5 * (viewport[2] + viewport[3]), kvs[:ylabel].to_s)
|
367
408
|
GR.restorestate
|
368
409
|
end
|
369
410
|
end
|
@@ -471,7 +512,7 @@ module GR
|
|
471
512
|
if kvs.has_key?(:title)
|
472
513
|
GR.savestate
|
473
514
|
GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
|
474
|
-
text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title])
|
515
|
+
text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title].to_s)
|
475
516
|
GR.restorestate
|
476
517
|
end
|
477
518
|
GR.selntran(1)
|
@@ -573,7 +614,22 @@ module GR
|
|
573
614
|
# Not yet.
|
574
615
|
end
|
575
616
|
|
576
|
-
|
617
|
+
if kvs.has_key?(:font)
|
618
|
+
name = kvs[:font]
|
619
|
+
# 'Cmuserif-Math' => :cmuserif_math
|
620
|
+
sym_name = name.to_s.gsub('-', '_').downcase.to_sym
|
621
|
+
if FONTS.include?(sym_name)
|
622
|
+
font = FONTS[sym_name]
|
623
|
+
GR.settextfontprec(font, font > 200 ? 3 : 0)
|
624
|
+
else
|
625
|
+
warn "Unknown font name: #{name}" # should raise error?
|
626
|
+
end
|
627
|
+
else
|
628
|
+
# The following fonts are the default in GR.jl
|
629
|
+
# Japanese, Chinese, Korean, etc. cannot be displayed.
|
630
|
+
|
631
|
+
# GR.settextfontprec(232, 3) # CM Serif Roman
|
632
|
+
end
|
577
633
|
|
578
634
|
set_viewport(kind, kvs[:subplot])
|
579
635
|
unless kvs[:ax]
|
@@ -641,8 +697,7 @@ module GR
|
|
641
697
|
if z || c
|
642
698
|
if c
|
643
699
|
cmin, cmax = kvs[:crange]
|
644
|
-
c = c.
|
645
|
-
c.map! { |i| normalize_color(i, cmin, cmax) }
|
700
|
+
c = c.map { |i| normalize_color(i, cmin, cmax) }
|
646
701
|
cind = c.map { |i| (1000 + i * 255).round }
|
647
702
|
end
|
648
703
|
x.length.times do |i|
|
@@ -743,9 +798,10 @@ module GR
|
|
743
798
|
else
|
744
799
|
h = levels
|
745
800
|
end
|
746
|
-
|
801
|
+
case kind
|
802
|
+
when :contour
|
747
803
|
GR._contour_(x, y, h, z, clabels ? 1 : 1000)
|
748
|
-
|
804
|
+
when :contourf
|
749
805
|
GR._contourf_(x, y, h, z, clabels ? 1 : 0)
|
750
806
|
end
|
751
807
|
colorbar(0, h.length)
|
@@ -834,7 +890,7 @@ module GR
|
|
834
890
|
GR.setmarkertype(GR::MARKERTYPE_SOLID_CIRCLE)
|
835
891
|
if c
|
836
892
|
cmin, cmax = kvs[:crange]
|
837
|
-
c = c.map { |i| normalize_color(i, cmin, cmax) }
|
893
|
+
c = c.map { |i| normalize_color(i, cmin, cmax) }
|
838
894
|
cind = c.map { |i| (1000 + i * 255).round }
|
839
895
|
x.length.times do |i|
|
840
896
|
GR.setmarkercolorind(cind[i])
|
@@ -1040,13 +1096,16 @@ module GR
|
|
1040
1096
|
|
1041
1097
|
# Normalize a color c with the range [cmin, cmax]
|
1042
1098
|
# 0 <= normalize_color(c, cmin, cmax) <= 1
|
1099
|
+
# Note: narray.map{|i| normalize_color(i)} There's room for speedup.
|
1043
1100
|
def normalize_color(c, cmin, cmax)
|
1101
|
+
c = c.to_f # if c is Integer
|
1044
1102
|
c = c.clamp(cmin, cmax) - cmin
|
1045
1103
|
c /= (cmax - cmin) if cmin != cmax
|
1046
1104
|
c
|
1047
1105
|
end
|
1048
1106
|
|
1049
1107
|
def inqtext(x, y, s)
|
1108
|
+
s = s.to_s
|
1050
1109
|
if s.length >= 2 && s[0] == '$' && s[-1] == '$'
|
1051
1110
|
GR.inqmathtex(x, y, s[1..-2])
|
1052
1111
|
elsif s.include?('\\') || s.include?('_') || s.include?('^')
|
@@ -1057,6 +1116,7 @@ module GR
|
|
1057
1116
|
end
|
1058
1117
|
|
1059
1118
|
def text(x, y, s)
|
1119
|
+
s = s.to_s
|
1060
1120
|
if s.length >= 2 && s[0] == '$' && s[-1] == '$'
|
1061
1121
|
GR.mathtex(x, y, s[1..-2])
|
1062
1122
|
elsif s.include?('\\') || s.include?('_') || s.include?('^')
|
@@ -1156,20 +1216,12 @@ module GR
|
|
1156
1216
|
[w, h]
|
1157
1217
|
end
|
1158
1218
|
|
1159
|
-
# NOTE: duplicated definition (GRCommonUtils)
|
1160
1219
|
def equal_length(*args)
|
1161
|
-
|
1162
|
-
unless lengths.all? { |l| l == lengths[0] }
|
1163
|
-
raise ArgumentError,
|
1164
|
-
'Sequences must have same length.'
|
1165
|
-
end
|
1166
|
-
|
1167
|
-
lengths[0]
|
1220
|
+
GRCommons::GRCommonUtils.equal_length(*args)
|
1168
1221
|
end
|
1169
1222
|
|
1170
|
-
# NOTE: duplicated definition (GRCommonUtils)
|
1171
1223
|
def narray?(data)
|
1172
|
-
|
1224
|
+
GRCommons::GRCommonUtils.narray?(data)
|
1173
1225
|
end
|
1174
1226
|
end
|
1175
1227
|
|
data/lib/gr3.rb
CHANGED
@@ -40,47 +40,52 @@
|
|
40
40
|
#
|
41
41
|
# Fiddley is Ruby-FFI compatible API layer for Fiddle.
|
42
42
|
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
43
|
+
# @note
|
44
|
+
# Why not GR::GR3?
|
45
|
+
# * kojix2 did not want to force gr3 to be loaded when gr is loaded.
|
46
|
+
# * kojix2 did not want to write `GR3 = GR::GR3` or something.
|
47
|
+
# * This is a opinion of kojix2 and may be changed by future maintainers.
|
47
48
|
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
# *
|
49
|
+
# @note
|
50
|
+
# GR3 uses Numo::Narrray.
|
51
|
+
# * It is difficult to write GR3 modules with only Ruby arrays.
|
52
|
+
# * Numo::Narray has better performance and is easier to read.
|
53
|
+
# * Numo::Narray does not work with JRuby.
|
54
|
+
# * https://github.com/ruby-numo/numo-narray/issues/147
|
53
55
|
#
|
54
56
|
# This is a procedural interface to the GR3 in GR plotting library,
|
55
57
|
# https://github.com/sciapp/gr
|
56
58
|
module GR3
|
57
59
|
class Error < StandardError; end
|
58
60
|
|
61
|
+
class NotFoundError < Error; end
|
62
|
+
|
59
63
|
class << self
|
60
64
|
attr_accessor :ffi_lib
|
61
65
|
end
|
62
66
|
|
67
|
+
require_relative 'gr_commons/gr_commons'
|
68
|
+
|
63
69
|
# Platforms | path
|
64
70
|
# Windows | bin/libGR3.dll
|
65
|
-
# MacOSX | lib/libGR3.
|
71
|
+
# MacOSX | lib/libGR3.dylib (v0.53.0 .so)
|
66
72
|
# Ubuntu | lib/libGR3.so
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
73
|
+
platform = RbConfig::CONFIG['host_os']
|
74
|
+
lib_names, pkg_name = \
|
75
|
+
case platform
|
76
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
77
|
+
[['libGR3.dll'], 'gr3']
|
78
|
+
when /darwin|mac os/
|
79
|
+
[['libGR3.dylib', 'libGR3.so'], 'gr3']
|
80
|
+
else
|
81
|
+
[['libGR3.so'], 'gr3']
|
82
|
+
end
|
83
|
+
lib_path = GRCommons::GRLib.search(lib_names, pkg_name)
|
79
84
|
|
80
|
-
|
81
|
-
|
85
|
+
raise NotFoundError, "#{lib_names} not found" if lib_path.nil?
|
86
|
+
|
87
|
+
self.ffi_lib = lib_path
|
82
88
|
|
83
|
-
require_relative 'gr_commons/gr_commons'
|
84
89
|
require_relative 'gr3/version'
|
85
90
|
require_relative 'gr3/ffi'
|
86
91
|
require_relative 'gr3/gr3base'
|
@@ -124,70 +129,82 @@ module GR3
|
|
124
129
|
end
|
125
130
|
extend CheckError
|
126
131
|
|
127
|
-
# Now you can see a lot of methods just calling super here.
|
128
|
-
# They are written to help the yard generate the documentation.
|
129
132
|
class << self
|
130
133
|
# This method initializes the gr3 context.
|
134
|
+
#
|
131
135
|
# @return [Integer]
|
132
|
-
|
133
|
-
|
134
|
-
end
|
136
|
+
#
|
137
|
+
# @!method gr3_init
|
135
138
|
|
136
|
-
|
137
|
-
super
|
138
|
-
end
|
139
|
+
# @!method free
|
139
140
|
|
140
141
|
# This function terminates the gr3 context.
|
141
|
-
|
142
|
-
|
143
|
-
|
142
|
+
#
|
143
|
+
# After calling this function, gr3 is in the same state as when it was first
|
144
|
+
# loaded, except for context-independent variables, i.e. the logging callback.
|
145
|
+
#
|
146
|
+
# @!method terminate
|
144
147
|
|
145
|
-
#
|
148
|
+
# @note This method is defined in the CheckError module.
|
149
|
+
#
|
146
150
|
# This function returns information on the most recent GR3 error.
|
151
|
+
#
|
147
152
|
# @return [Integer]
|
148
|
-
#
|
153
|
+
#
|
154
|
+
# @!method geterror
|
149
155
|
|
150
156
|
# This function allows the user to find out how his commands are rendered.
|
157
|
+
#
|
151
158
|
# If gr3 is initialized, a string in the format:
|
152
|
-
# `"gr3 - " + window toolkit + " - " + framebuffer extension + " - "
|
153
|
-
#
|
154
|
-
#
|
159
|
+
# `"gr3 - " + window toolkit + " - " + framebuffer extension + " - "
|
160
|
+
# + OpenGL version + " - " + OpenGL renderer string`.
|
161
|
+
# For example
|
162
|
+
# `"gr3 - GLX - GL_ARB_framebuffer_object - 2.1 Mesa 7.10.2 - Software Rasterizer"`
|
163
|
+
# might be returned on a Linux system (using GLX) with an available
|
164
|
+
# GL_ARB_framebuffer_object implementation.
|
155
165
|
# If gr3 is not initialized `"Not initialized"` is returned.
|
166
|
+
#
|
156
167
|
# @return [String]
|
168
|
+
#
|
157
169
|
def getrenderpathstring(*)
|
158
170
|
super.to_s
|
159
171
|
end
|
160
172
|
|
161
173
|
# This function returns a string representation of a given error code.
|
174
|
+
#
|
162
175
|
# @return [String]
|
176
|
+
#
|
163
177
|
def geterrorstring(*)
|
164
178
|
super.to_s
|
165
179
|
end
|
166
180
|
|
167
181
|
# This function clears the draw list.
|
182
|
+
#
|
168
183
|
# @return [Integer]
|
169
|
-
|
170
|
-
|
171
|
-
end
|
184
|
+
#
|
185
|
+
# @!method clear
|
172
186
|
|
173
|
-
# Use the currently bound framebuffer as the framebuffer used for drawing to
|
174
|
-
#
|
175
|
-
|
176
|
-
|
177
|
-
|
187
|
+
# Use the currently bound framebuffer as the framebuffer used for drawing to
|
188
|
+
# OpenGL (using gr3.drawimage).
|
189
|
+
# This function is only needed when you do not want to render to 0, the
|
190
|
+
# default framebuffer.
|
191
|
+
#
|
192
|
+
# @!method usecurrentframebuffer
|
178
193
|
|
179
194
|
# Set the framebuffer used for drawing to OpenGL (using gr3.drawimage).
|
180
|
-
#
|
181
|
-
|
182
|
-
|
183
|
-
|
195
|
+
#
|
196
|
+
# This function is only needed when you do not want to render to 0, the
|
197
|
+
# default framebuffer.
|
198
|
+
#
|
199
|
+
# @!method useframebuffer
|
184
200
|
|
185
201
|
# Set rendering quality
|
202
|
+
#
|
186
203
|
# @param quality [] The quality to set
|
204
|
+
#
|
187
205
|
# @return [Integer]
|
188
|
-
|
189
|
-
|
190
|
-
end
|
206
|
+
#
|
207
|
+
# @!method setquality
|
191
208
|
|
192
209
|
# @return [Integer]
|
193
210
|
def getimage(width, height, use_alpha = true)
|
@@ -198,31 +215,31 @@ module GR3
|
|
198
215
|
end
|
199
216
|
|
200
217
|
# @return [Integer]
|
201
|
-
|
202
|
-
super
|
203
|
-
end
|
218
|
+
# @!method export
|
204
219
|
|
205
220
|
# @return [Integer]
|
206
|
-
|
207
|
-
super
|
208
|
-
end
|
221
|
+
# @!method drawimage
|
209
222
|
|
210
|
-
#
|
223
|
+
# This function creates a mesh from vertex position, normal and color data.
|
224
|
+
#
|
211
225
|
# @return [Integer]
|
212
|
-
def createmesh_nocopy(
|
226
|
+
def createmesh_nocopy(n, vertices, normals, colors)
|
213
227
|
inquiry_int do |mesh|
|
214
|
-
super(mesh, vertices, normals, colors)
|
228
|
+
super(mesh, n, vertices, normals, colors)
|
215
229
|
end
|
216
230
|
end
|
217
231
|
|
218
232
|
# This function creates a int from vertex position, normal and color data.
|
219
233
|
# Returns a mesh.
|
220
|
-
#
|
234
|
+
#
|
235
|
+
# @param n [Integer] the number of vertices in the mesh
|
221
236
|
# @param vertices [Array, NArray] the vertex positions
|
222
|
-
# @param normals
|
223
|
-
# @param colors
|
224
|
-
#
|
237
|
+
# @param normals [Array, NArray] the vertex normals
|
238
|
+
# @param colors [Array, NArray] the vertex colors, they should be
|
239
|
+
# white (1,1,1) if you want to change the color for each drawn mesh
|
240
|
+
#
|
225
241
|
# @return [Integer]
|
242
|
+
#
|
226
243
|
def createmesh(n, vertices, normals, colors)
|
227
244
|
inquiry_int do |mesh|
|
228
245
|
super(mesh, n, vertices, normals, colors)
|
@@ -230,6 +247,7 @@ module GR3
|
|
230
247
|
end
|
231
248
|
|
232
249
|
# This function creates a mesh from vertex position, normal and color data.
|
250
|
+
#
|
233
251
|
# @return [Integer]
|
234
252
|
def createindexedmesh_nocopy(num_vertices, vertices, normals, colors, num_indices, indices)
|
235
253
|
inquiry_int do |mesh|
|
@@ -240,150 +258,159 @@ module GR3
|
|
240
258
|
# This function creates an indexed mesh from vertex information (position,
|
241
259
|
# normal and color) and triangle information (indices).
|
242
260
|
# Returns a mesh.
|
243
|
-
#
|
244
|
-
# @param
|
245
|
-
# @param
|
246
|
-
# @param
|
247
|
-
#
|
248
|
-
#
|
249
|
-
#
|
261
|
+
#
|
262
|
+
# @param num_vertices [Integer] the number of vertices in the mesh
|
263
|
+
# @param vertices [Array, NArray] the vertex positions
|
264
|
+
# @param normals [Array, NArray] the vertex normals
|
265
|
+
# @param colors [Array, NArray] the vertex colors, they should be
|
266
|
+
# white (1,1,1) if you want to change
|
267
|
+
# the color for each drawn mesh
|
268
|
+
# @param num_indices [Integer] the number of indices in the mesh
|
269
|
+
# (three times the number of triangles)
|
270
|
+
# @param indices [Array, NArray] the index array (vertex indices for
|
271
|
+
# each triangle)
|
272
|
+
#
|
250
273
|
# @return [Integer]
|
274
|
+
#
|
251
275
|
def createindexedmesh(num_vertices, vertices, normals, colors, num_indices, indices)
|
252
276
|
inquiry_int do |mesh|
|
253
277
|
super(mesh, num_vertices, vertices, normals, colors, num_indices, indices)
|
254
278
|
end
|
255
279
|
end
|
256
280
|
|
257
|
-
# This function adds a mesh to the draw list, so it will be drawn when the
|
258
|
-
# The given data stays owned by the user, a copy will
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
281
|
+
# This function adds a mesh to the draw list, so it will be drawn when the
|
282
|
+
# user calls getpixmap. The given data stays owned by the user, a copy will
|
283
|
+
# be saved in the draw list and the mesh reference counter will be increased.
|
284
|
+
#
|
285
|
+
# This function does not return an error code, because of its asynchronous
|
286
|
+
# nature. If gr3_getpixmap_() returns a GR3_ERROR_OPENGL_ERR, this might be
|
287
|
+
# caused by this function saving unuseable data into the draw list.
|
288
|
+
#
|
289
|
+
# @param mesh [Integer] The mesh to be drawn
|
290
|
+
# @param n [Integer] The number of meshes to be drawn
|
291
|
+
# @param positions [Array, NArray] The positions where the meshes should be drawn
|
262
292
|
# @param directions [Array, NArray] The forward directions the meshes should be facing at
|
263
|
-
# @param ups
|
264
|
-
# @param colors
|
265
|
-
#
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
# This function marks a mesh for deletion and removes the user’s reference
|
271
|
-
# so a user must not use the mesh after
|
293
|
+
# @param ups [Array, NArray] The up directions
|
294
|
+
# @param colors [Array, NArray] The colors the meshes should be drawn in,
|
295
|
+
# it will be multiplied with each vertex color
|
296
|
+
# @param scales [Array, NArray] The scaling factors
|
297
|
+
#
|
298
|
+
# @!method drawmesh
|
299
|
+
|
300
|
+
# This function marks a mesh for deletion and removes the user’s reference
|
301
|
+
# from the mesh’s referenc counter, so a user must not use the mesh after
|
302
|
+
# calling this function.
|
303
|
+
#
|
272
304
|
# @param mesh [Integer] The mesh that should be marked for deletion
|
273
|
-
|
274
|
-
|
275
|
-
end
|
305
|
+
#
|
306
|
+
# @!method deletemesh
|
276
307
|
|
277
308
|
# This function sets the view matrix by getting the position of the camera,
|
278
309
|
# the position of the center of focus and the direction which should point up.
|
310
|
+
# This function takes effect when the next image is created. Therefore if
|
311
|
+
# you want to take pictures of the same data from different perspectives,
|
312
|
+
# you can call and gr3_cameralookat(), gr3_getpixmap_(), gr3_cameralookat(),
|
313
|
+
# gr3_getpixmap_(), … without calling gr3_clear() and gr3_drawmesh() again.
|
314
|
+
#
|
279
315
|
# @param camera_x [Array, NArray] The x-coordinate of the camera
|
280
316
|
# @param camera_y [Array, NArray] The y-coordinate of the camera
|
281
317
|
# @param camera_z [Array, NArray] The z-coordinate of the camera
|
282
318
|
# @param center_x [Array, NArray] The x-coordinate of the center of focus
|
283
319
|
# @param center_y [Array, NArray] The y-coordinate of the center of focus
|
284
320
|
# @param center_z [Array, NArray] The z-coordinate of the center of focus
|
285
|
-
# @param up_x
|
286
|
-
# @param up_y
|
287
|
-
# @param up_z
|
288
|
-
|
289
|
-
|
290
|
-
end
|
321
|
+
# @param up_x [Array, NArray] The x-component of the up direction
|
322
|
+
# @param up_y [Array, NArray] The y-component of the up direction
|
323
|
+
# @param up_z [Array, NArray] The z-component of the up direction
|
324
|
+
#
|
325
|
+
# @!method cameralookat
|
291
326
|
|
292
327
|
# This function sets the projection parameters.
|
293
328
|
# This function takes effect when the next image is created.
|
294
|
-
#
|
295
|
-
#
|
329
|
+
#
|
330
|
+
# The ratio between zFar and zNear influences the precision of the depth
|
331
|
+
# buffer, the greater (zFar/zNear), the more likely are errors. So you should
|
332
|
+
# try to keep both values as close to each other as possible while making
|
333
|
+
# sure everything you want to be visible, is visible.
|
334
|
+
#
|
335
|
+
# @param vertical_field_of_view [Numeric]
|
336
|
+
# This parameter is the vertical field of view in degrees.
|
337
|
+
# It must be greater than 0 and less than 180.
|
296
338
|
# @param zNear [Numeric] The distance to the near clipping plane.
|
297
|
-
# @param zFar
|
339
|
+
# @param zFar [Numeric] The distance to the far clipping plane.
|
340
|
+
#
|
298
341
|
# @return [Integer]
|
299
|
-
|
300
|
-
|
301
|
-
end
|
342
|
+
#
|
343
|
+
# @!method setcameraprojectionparameters
|
302
344
|
|
303
345
|
# Get the projection parameters.
|
346
|
+
#
|
347
|
+
# @param vfov [Array, NArray] Vertical field of view in degrees
|
348
|
+
# @param znear [Array, NArray] The distance to the near clipping plane.
|
349
|
+
# @param zfar [Array, NArray] The distance to the far clipping plane.
|
350
|
+
#
|
304
351
|
# @return [Integer]
|
305
|
-
|
306
|
-
|
307
|
-
end
|
352
|
+
#
|
353
|
+
# @!method getcameraprojectionparameters
|
308
354
|
|
309
|
-
# This function sets the direction of light.
|
310
|
-
#
|
355
|
+
# This function sets the direction of light. If it is called with (0, 0, 0),
|
356
|
+
# the light is always pointing into the same direction as the camera.
|
357
|
+
#
|
311
358
|
# @param x [Numeric] The x-component of the light's direction
|
312
359
|
# @param y [Numeric] The y-component of the light's direction
|
313
360
|
# @param z [Numeric] The z-component of the light's direction
|
314
|
-
|
315
|
-
|
316
|
-
end
|
361
|
+
#
|
362
|
+
# @!method setlightdirection
|
317
363
|
|
318
364
|
# This function sets the background color.
|
319
|
-
|
320
|
-
super
|
321
|
-
end
|
365
|
+
# @!method setbackgroundcolor
|
322
366
|
|
323
367
|
# @return [Integer]
|
324
|
-
|
325
|
-
super
|
326
|
-
end
|
368
|
+
# @!method createheightmapmesh
|
327
369
|
|
328
|
-
|
329
|
-
super
|
330
|
-
end
|
370
|
+
# @!method drawheightmap
|
331
371
|
|
332
372
|
# This function allows drawing a cylinder without requiring a mesh.
|
333
|
-
|
334
|
-
super
|
335
|
-
end
|
373
|
+
# @!method drawconemesh
|
336
374
|
|
337
375
|
# This function allows drawing a cylinder without requiring a mesh.
|
338
|
-
|
339
|
-
super
|
340
|
-
end
|
376
|
+
# @!method drawcylindermesh
|
341
377
|
|
342
378
|
# This function allows drawing a sphere without requiring a mesh.
|
343
|
-
|
344
|
-
super
|
345
|
-
end
|
379
|
+
# @!method drawspheremesh
|
346
380
|
|
347
|
-
|
348
|
-
super
|
349
|
-
end
|
381
|
+
# @!method drawcubemesh
|
350
382
|
|
351
|
-
|
352
|
-
super
|
353
|
-
end
|
383
|
+
# @!method setobjectid
|
354
384
|
|
355
385
|
# @return [Integer]
|
356
|
-
|
357
|
-
super
|
358
|
-
end
|
386
|
+
# @!method selectid
|
359
387
|
|
360
|
-
|
361
|
-
|
362
|
-
end
|
388
|
+
# @param m [Array, NArray] the 4x4 column major view matrix
|
389
|
+
# @!method getviewmatrix
|
363
390
|
|
364
|
-
|
365
|
-
|
366
|
-
end
|
391
|
+
# @param m [Array, NArray] the 4x4 column major view matrix
|
392
|
+
# @!method setviewmatrix
|
367
393
|
|
368
|
-
# the current projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
|
369
394
|
# @return [Integer]
|
370
|
-
|
371
|
-
|
372
|
-
end
|
395
|
+
# the current projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
|
396
|
+
# @!method getprojectiontype
|
373
397
|
|
374
|
-
# @param type [Integer]
|
375
|
-
|
376
|
-
|
377
|
-
|
398
|
+
# @param type [Integer]
|
399
|
+
# the new projection type: GR3_PROJECTION_PERSPECTIVE,
|
400
|
+
# GR3_PROJECTION_PARALLEL or GR3_PROJECTION_ORTHOGRAPHIC
|
401
|
+
# @!method setprojectiontype
|
378
402
|
|
379
403
|
# This function creates an isosurface from voxel data using the
|
380
404
|
# marching cubes algorithm.
|
381
405
|
# Returns a mesh.
|
382
|
-
#
|
383
|
-
# @param
|
384
|
-
# @param
|
385
|
-
# @param
|
406
|
+
#
|
407
|
+
# @param grid [NArray] 3D narray array containing the voxel data
|
408
|
+
# @param step [Array, NArray] voxel sizes in each direction
|
409
|
+
# @param offset [Array, NArray] coordinate origin in each direction
|
410
|
+
# @param isolevel [Integer] isovalue at which the surface will be created
|
411
|
+
#
|
386
412
|
# @return [Integer]
|
413
|
+
#
|
387
414
|
def createisosurfacemesh(grid, step, offset, isolevel)
|
388
415
|
args = _preprocess_createslicemesh(grid, step, offset)
|
389
416
|
grid = args.shift
|
@@ -395,10 +422,11 @@ module GR3
|
|
395
422
|
# Create a mesh of a surface plot similar to gr_surface.
|
396
423
|
# Uses the current colormap. To apply changes of the colormap
|
397
424
|
# a new mesh has to be created.
|
398
|
-
#
|
399
|
-
# @param
|
400
|
-
# @param
|
401
|
-
# @param
|
425
|
+
#
|
426
|
+
# @param nx [Integer] number of points in x-direction
|
427
|
+
# @param ny [Integer] number of points in y-direction
|
428
|
+
# @param x [Array, NArray] an array containing the x-coordinates
|
429
|
+
# @param y [Array, NArray] an array containing the y-coordinates
|
402
430
|
# @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
|
403
431
|
# @param option [Integer] option for the surface mesh; the GR3_SURFACE constants can be combined with bitwise or. See the table below.
|
404
432
|
# * 0 : GR3_SURFACE_DEFAULT
|
@@ -413,6 +441,7 @@ module GR3
|
|
413
441
|
# * color the surface according to the current gr colormap
|
414
442
|
# * 16 : GR3_SURFACE_GRZSHADED
|
415
443
|
# * like GR3_SURFACE_GRCOLOR, but use the z-value directly as color index
|
444
|
+
#
|
416
445
|
# @return [Integer]
|
417
446
|
def createsurfacemesh(nx, ny, x, y, z, option = 0)
|
418
447
|
inquiry_int do |mesh|
|
@@ -426,29 +455,32 @@ module GR3
|
|
426
455
|
# the viewmatrix and the light direction. If necessary, the user has to
|
427
456
|
# save them before the call to this function and restore them after
|
428
457
|
# the call to gr3_drawimage.
|
429
|
-
#
|
430
|
-
# @param
|
431
|
-
# @param
|
458
|
+
#
|
459
|
+
# @param mesh [Integer] the mesh to be drawn
|
460
|
+
# @param n [Integer] the number of meshes to be drawn
|
461
|
+
# @param positions [Array, NArray] the positions where the meshes should be drawn
|
432
462
|
# @param directions [Array, NArray] the forward directions the meshes should be facing at
|
433
|
-
# @param ups
|
434
|
-
# @param colors
|
435
|
-
#
|
436
|
-
|
437
|
-
|
438
|
-
|
463
|
+
# @param ups [Array, NArray] the up directions
|
464
|
+
# @param colors [Array, NArray] the colors the meshes should be drawn in,
|
465
|
+
# it will be multiplied with each vertex color
|
466
|
+
# @param scales [Array, NArray] the scaling factors
|
467
|
+
#
|
468
|
+
# @!method drawmesh_grlike
|
439
469
|
|
440
470
|
# Convenience function for drawing a surfacemesh.
|
471
|
+
#
|
441
472
|
# @param mesh [Integer] the mesh to be drawn
|
442
|
-
|
443
|
-
|
444
|
-
end
|
473
|
+
#
|
474
|
+
# @!method drawsurface
|
445
475
|
|
446
476
|
# Create a surface plot with gr3 and draw it with gks as cellarray.
|
447
|
-
#
|
448
|
-
# @param
|
449
|
-
# @param
|
450
|
-
# @param
|
451
|
-
#
|
477
|
+
#
|
478
|
+
# @param x [Array, NArray] an array containing the x-coordinates
|
479
|
+
# @param y [Array, NArray] an array containing the y-coordinates
|
480
|
+
# @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
|
481
|
+
# @param option [Integer] see the option parameter of gr_surface.
|
482
|
+
# OPTION_COLORED_MESH and OPTION_Z_SHADED_MESH are supported.
|
483
|
+
#
|
452
484
|
def surface(x, y, z, option)
|
453
485
|
nx = x.length
|
454
486
|
ny = y.length
|
@@ -456,17 +488,20 @@ module GR3
|
|
456
488
|
super(nx, ny, x, y, z, option)
|
457
489
|
end
|
458
490
|
|
459
|
-
# drawtubemesh
|
460
491
|
# Draw a tube following a path given by a list of points. The colors and
|
461
492
|
# radii arrays specify the color and radius at each point.
|
462
|
-
#
|
493
|
+
#
|
494
|
+
# @param n [Integer] the number of points given
|
463
495
|
# @param points [Array, NArray] the points the tube should go through
|
464
496
|
# @param colors [Array, NArray] the color at each point
|
465
|
-
# @param radii
|
466
|
-
# @param num_steps
|
467
|
-
#
|
468
|
-
#
|
497
|
+
# @param radii [Array, NArray] the desired tube radius at each point
|
498
|
+
# @param num_steps [Integer] the number of steps between each point,
|
499
|
+
# allowing for a more smooth tube
|
500
|
+
# @param num_segments [Integer] the number of segments each ring of the tube
|
501
|
+
# consists of, e.g. 3 would yield a triangular tube
|
502
|
+
#
|
469
503
|
# @return [Integer]
|
504
|
+
#
|
470
505
|
def drawtubemesh(n, points, colors, radii, num_steps = 10, num_segments = 20)
|
471
506
|
super(n, points, colors, radii, num_steps, num_segments)
|
472
507
|
end
|
@@ -474,12 +509,17 @@ module GR3
|
|
474
509
|
# Create a mesh object in the shape of a tube following a path given by a
|
475
510
|
# list of points. The colors and radii arrays specify the color and radius at
|
476
511
|
# each point.
|
477
|
-
#
|
478
|
-
# @param
|
479
|
-
# @param
|
480
|
-
# @param
|
481
|
-
# @param
|
482
|
-
# @param
|
512
|
+
#
|
513
|
+
# @param n [Integer] the number of points given
|
514
|
+
# @param points [Array, NArray] the points the tube should go through
|
515
|
+
# @param colors [Array, NArray] the color at each point
|
516
|
+
# @param radii [Array, NArray] the desired tube radius at each point
|
517
|
+
# @param num_steps [Integer] the number of steps between each point,
|
518
|
+
# allowing for a more smooth tube
|
519
|
+
# @param num_segments [Integer] the number of segments each ring of the
|
520
|
+
# tube consists of, e.g. 3 would yield a
|
521
|
+
# triangular tube
|
522
|
+
#
|
483
523
|
# @return [Integer]
|
484
524
|
def createtubemesh(n, points, colors, radii, num_steps = 10, num_segments = 20)
|
485
525
|
inquiry_uint do |mesh| # mesh should be Int?
|
@@ -554,12 +594,14 @@ module GR3
|
|
554
594
|
# drawn and at which positions they should go through the data. If neither
|
555
595
|
# x nor y nor z are set, 0.5 will be used for all three.
|
556
596
|
# Returns meshes for the yz-slice, the xz-slice and the xy-slice.
|
557
|
-
#
|
558
|
-
# @param
|
559
|
-
# @param
|
560
|
-
# @param
|
561
|
-
# @param
|
562
|
-
# @param
|
597
|
+
#
|
598
|
+
# @param grid [NArray] 3D narray array containing the voxel data
|
599
|
+
# @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
|
600
|
+
# @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
|
601
|
+
# @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
|
602
|
+
# @param step [Array, NArray] voxel sizes in each direction
|
603
|
+
# @param offset [Array, NArray] coordinate origin in each direction
|
604
|
+
#
|
563
605
|
def createslicemeshes(grid, x = nil, y = nil, z = nil, step = nil, offset = nil)
|
564
606
|
if [x, y, z].all?(&:nil?)
|
565
607
|
x = 0.5
|
@@ -576,10 +618,11 @@ module GR3
|
|
576
618
|
# using the current GR colormap. Use the x parameter to set the position of
|
577
619
|
# the yz-slice.
|
578
620
|
# Returns a mesh for the yz-slice.
|
579
|
-
#
|
580
|
-
# @param
|
581
|
-
# @param
|
582
|
-
# @param
|
621
|
+
#
|
622
|
+
# @param grid [NArray] 3D narray array containing the voxel data
|
623
|
+
# @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
|
624
|
+
# @param step [Array, NArray] voxel sizes in each direction
|
625
|
+
# @param offset [Array, NArray] coordinate origin in each direction
|
583
626
|
def createxslicemesh(grid, x = 0.5, step = nil, offset = nil)
|
584
627
|
args = _preprocess_createslicemesh(grid, step, offset)
|
585
628
|
grid = args.shift
|
@@ -593,10 +636,12 @@ module GR3
|
|
593
636
|
# using the current GR colormap. Use the y parameter to set the position of
|
594
637
|
# the xz-slice.
|
595
638
|
# Returns a mesh for the xz-slice.
|
596
|
-
#
|
597
|
-
# @param
|
598
|
-
# @param
|
599
|
-
# @param
|
639
|
+
#
|
640
|
+
# @param grid [NArray] 3D narray array containing the voxel data
|
641
|
+
# @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
|
642
|
+
# @param step [Array, NArray] voxel sizes in each direction
|
643
|
+
# @param offset [Array, NArray] coordinate origin in each direction
|
644
|
+
#
|
600
645
|
def createyslicemesh(grid, y = 0.5, step = nil, offset = nil)
|
601
646
|
args = _preprocess_createslicemesh(grid, step, offset)
|
602
647
|
grid = args.shift
|
@@ -610,10 +655,12 @@ module GR3
|
|
610
655
|
# using the current GR colormap. Use the z parameter to set the position of
|
611
656
|
# the xy-slice.
|
612
657
|
# Returns a mesh for the xy-slice.
|
613
|
-
#
|
614
|
-
# @param
|
615
|
-
# @param
|
616
|
-
# @param
|
658
|
+
#
|
659
|
+
# @param grid [NArray] 3D narray array containing the voxel data
|
660
|
+
# @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
|
661
|
+
# @param step [Array, NArray] voxel sizes in each direction
|
662
|
+
# @param offset [Array, NArray] coordinate origin in each direction
|
663
|
+
#
|
617
664
|
def createzslicemesh(grid, z = 0.5, step = nil, offset = nil)
|
618
665
|
args = _preprocess_createslicemesh(grid, step, offset)
|
619
666
|
grid = args.shift
|
@@ -624,15 +671,18 @@ module GR3
|
|
624
671
|
end
|
625
672
|
|
626
673
|
# Draw a yz-slice through the given data, using the current GR colormap.
|
627
|
-
#
|
628
|
-
# @param
|
629
|
-
# @param
|
630
|
-
# @param
|
631
|
-
# @param
|
632
|
-
# @param
|
633
|
-
# @param
|
634
|
-
# @param
|
635
|
-
# @param
|
674
|
+
#
|
675
|
+
# @param grid [NArray] 3D narray array containing the voxel data
|
676
|
+
# @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
|
677
|
+
# @param step [Array, NArray] voxel sizes in each direction
|
678
|
+
# @param offset [Array, NArray] coordinate origin in each direction
|
679
|
+
# @param position [Array, NArray] the positions where the meshes should be drawn
|
680
|
+
# @param direction [Array, NArray] the forward directions the meshes should be facing at
|
681
|
+
# @param up [Array, NArray] the up directions
|
682
|
+
# @param color [Array, NArray] the colors the meshes should be drawn in,
|
683
|
+
# it will be multiplied with each vertex color
|
684
|
+
# @param scale [Array, NArray] the scaling factors
|
685
|
+
#
|
636
686
|
def drawxslicemesh(grid, x = 0.5, step = nil, offset = nil,
|
637
687
|
position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
|
638
688
|
color = [1, 1, 1], scale = [1, 1, 1])
|
@@ -642,15 +692,18 @@ module GR3
|
|
642
692
|
end
|
643
693
|
|
644
694
|
# Draw a xz-slice through the given data, using the current GR colormap.
|
645
|
-
#
|
646
|
-
# @param
|
647
|
-
# @param
|
648
|
-
# @param
|
649
|
-
# @param
|
650
|
-
# @param
|
651
|
-
# @param
|
652
|
-
# @param
|
653
|
-
# @param
|
695
|
+
#
|
696
|
+
# @param grid [NArray] 3D narray array containing the voxel data
|
697
|
+
# @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
|
698
|
+
# @param step [Array, NArray] voxel sizes in each direction
|
699
|
+
# @param offset [Array, NArray] coordinate origin in each direction
|
700
|
+
# @param position [Array, NArray] the positions where the meshes should be drawn
|
701
|
+
# @param direction [Array, NArray] the forward directions the meshes should be facing at
|
702
|
+
# @param up [Array, NArray] the up directions
|
703
|
+
# @param color [Array, NArray] the colors the meshes should be drawn in,
|
704
|
+
# it will be multiplied with each vertex color
|
705
|
+
# @param scale [Array, NArray] the scaling factors
|
706
|
+
#
|
654
707
|
def drawyslicemesh(grid, y = 0.5, step = nil, offset = nil,
|
655
708
|
position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
|
656
709
|
color = [1, 1, 1], scale = [1, 1, 1])
|
@@ -660,15 +713,18 @@ module GR3
|
|
660
713
|
end
|
661
714
|
|
662
715
|
# Draw a xy-slice through the given data, using the current GR colormap.
|
663
|
-
#
|
664
|
-
# @param
|
665
|
-
# @param
|
666
|
-
# @param
|
667
|
-
# @param
|
668
|
-
# @param
|
669
|
-
# @param
|
670
|
-
# @param
|
671
|
-
# @param
|
716
|
+
#
|
717
|
+
# @param grid [NArray] 3D narray array containing the voxel data
|
718
|
+
# @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
|
719
|
+
# @param step [Array, NArray] voxel sizes in each direction
|
720
|
+
# @param offset [Array, NArray] coordinate origin in each direction
|
721
|
+
# @param position [Array, NArray] the positions where the meshes should be drawn
|
722
|
+
# @param direction [Array, NArray] the forward directions the meshes should be facing at
|
723
|
+
# @param up [Array, NArray] the up directions
|
724
|
+
# @param color [Array, NArray] the colors the meshes should be drawn in,
|
725
|
+
# it will be multiplied with each vertex color
|
726
|
+
# @param scale [Array, NArray] the scaling factors
|
727
|
+
#
|
672
728
|
def drawzslicemesh(grid, z = 0.5, step = nil, offset = nil,
|
673
729
|
position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
|
674
730
|
color = [1, 1, 1], scale = [1, 1, 1])
|
@@ -681,17 +737,20 @@ module GR3
|
|
681
737
|
# Use the parameters x, y or z to specify what slices should be drawn and at
|
682
738
|
# which positions they should go through the data. If neither x nor y nor
|
683
739
|
# z are set, 0.5 will be used for all three.
|
740
|
+
#
|
684
741
|
# @param grid [NArray] 3D narray array containing the voxel data
|
685
|
-
# @param x
|
686
|
-
# @param y
|
687
|
-
# @param z
|
688
|
-
# @param step
|
689
|
-
# @param offset
|
690
|
-
# @param position
|
691
|
-
# @param direction [Array] the forward directions the meshes should be facing at
|
692
|
-
# @param up
|
693
|
-
# @param color
|
694
|
-
#
|
742
|
+
# @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
|
743
|
+
# @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
|
744
|
+
# @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
|
745
|
+
# @param step [Array, NArray] voxel sizes in each direction
|
746
|
+
# @param offset [Array, NArray] coordinate origin in each direction
|
747
|
+
# @param position [Array, NArray] the positions where the meshes should be drawn
|
748
|
+
# @param direction [Array, NArray] the forward directions the meshes should be facing at
|
749
|
+
# @param up [Array, NArray] the up directions
|
750
|
+
# @param color [Array, NArray] the colors the meshes should be drawn in,
|
751
|
+
# it will be multiplied with each vertex color
|
752
|
+
# @param scale [Array, NArray] the scaling factors
|
753
|
+
#
|
695
754
|
def drawslicemeshes(grid, x = nil, y = nil, z = nil, step = nil,
|
696
755
|
offset = nil, position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
|
697
756
|
color = [1, 1, 1], scale = [1, 1, 1])
|