ruby-gr 0.0.23 → 0.58.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gr3.rb CHANGED
@@ -40,39 +40,54 @@
40
40
  #
41
41
  # Fiddley is Ruby-FFI compatible API layer for Fiddle.
42
42
  #
43
- # Why not GR::GR3?
44
- # * kojix2 did not want to force gr3 to be loaded when gr is loaded.
45
- # * kojix2 did not want to write `GR3 = GR::GR3` or something.
46
- # * This is a opinion of kojix2 and may be changed by future maintainers.
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
- # GR3 uses Numo::Narrray.
49
- # * It is difficult to write GR3 modules with only Ruby arrays.
50
- # * Numo::Narray has better performance and is easier to read.
51
- # * Numo::Narray does not work with JRuby.
52
- # * https://github.com/ruby-numo/numo-narray/issues/147
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
 
63
67
  require_relative 'gr_commons/gr_commons'
64
- extend GRCommons::SearchSharedLibrary
65
68
 
66
69
  # Platforms | path
67
70
  # Windows | bin/libGR3.dll
68
- # MacOSX | lib/libGR3.so (NOT .dylib)
71
+ # MacOSX | lib/libGR3.dylib ( <= v0.53.0 .so)
69
72
  # Ubuntu | lib/libGR3.so
70
- self.ffi_lib = case RbConfig::CONFIG['host_os']
71
- when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
72
- search_shared_library('libGR3.dll', 'gr3')
73
- else
74
- search_shared_library('libGR3.so', 'gr3')
75
- 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
+
84
+ # On Windows + RubyInstaller,
85
+ # the environment variable GKS_FONTPATH will be set.
86
+ lib_path = GRCommons::GRLib.search(lib_names, pkg_name)
87
+
88
+ raise NotFoundError, "#{lib_names} not found" if lib_path.nil?
89
+
90
+ self.ffi_lib = lib_path
76
91
 
77
92
  require_relative 'gr3/version'
78
93
  require_relative 'gr3/ffi'
@@ -117,70 +132,82 @@ module GR3
117
132
  end
118
133
  extend CheckError
119
134
 
120
- # Now you can see a lot of methods just calling super here.
121
- # They are written to help the yard generate the documentation.
122
135
  class << self
123
136
  # This method initializes the gr3 context.
137
+ #
124
138
  # @return [Integer]
125
- def gr3_init(*)
126
- super
127
- end
139
+ #
140
+ # @!method gr3_init
128
141
 
129
- def free(*)
130
- super
131
- end
142
+ # @!method free
132
143
 
133
144
  # This function terminates the gr3 context.
134
- def terminate(*)
135
- super
136
- end
145
+ #
146
+ # After calling this function, gr3 is in the same state as when it was first
147
+ # loaded, except for context-independent variables, i.e. the logging callback.
148
+ #
149
+ # @!method terminate
137
150
 
138
- # @!method geterror
151
+ # @note This method is defined in the CheckError module.
152
+ #
139
153
  # This function returns information on the most recent GR3 error.
154
+ #
140
155
  # @return [Integer]
141
- # @note This method is defined in the CheckError module.
156
+ #
157
+ # @!method geterror
142
158
 
143
159
  # This function allows the user to find out how his commands are rendered.
160
+ #
144
161
  # If gr3 is initialized, a string in the format:
145
- # `"gr3 - " + window toolkit + " - " + framebuffer extension + " - " + OpenGL version + " - " + OpenGL renderer string`.
146
- # For example `"gr3 - GLX - GL_ARB_framebuffer_object - 2.1 Mesa 7.10.2 - Software Rasterizer"`
147
- # might be returned on a Linux system (using GLX) with an available GL_ARB_framebuffer_object implementation.
162
+ # `"gr3 - " + window toolkit + " - " + framebuffer extension + " - "
163
+ # + OpenGL version + " - " + OpenGL renderer string`.
164
+ # For example
165
+ # `"gr3 - GLX - GL_ARB_framebuffer_object - 2.1 Mesa 7.10.2 - Software Rasterizer"`
166
+ # might be returned on a Linux system (using GLX) with an available
167
+ # GL_ARB_framebuffer_object implementation.
148
168
  # If gr3 is not initialized `"Not initialized"` is returned.
169
+ #
149
170
  # @return [String]
171
+ #
150
172
  def getrenderpathstring(*)
151
173
  super.to_s
152
174
  end
153
175
 
154
176
  # This function returns a string representation of a given error code.
177
+ #
155
178
  # @return [String]
179
+ #
156
180
  def geterrorstring(*)
157
181
  super.to_s
158
182
  end
159
183
 
160
184
  # This function clears the draw list.
185
+ #
161
186
  # @return [Integer]
162
- def clear(*)
163
- super
164
- end
187
+ #
188
+ # @!method clear
165
189
 
166
- # Use the currently bound framebuffer as the framebuffer used for drawing to OpenGL (using gr3.drawimage).
167
- # This function is only needed when you do not want to render to 0, the default framebuffer.
168
- def usecurrentframebuffer(*)
169
- super
170
- end
190
+ # Use the currently bound framebuffer as the framebuffer used for drawing to
191
+ # OpenGL (using gr3.drawimage).
192
+ # This function is only needed when you do not want to render to 0, the
193
+ # default framebuffer.
194
+ #
195
+ # @!method usecurrentframebuffer
171
196
 
172
197
  # Set the framebuffer used for drawing to OpenGL (using gr3.drawimage).
173
- # This function is only needed when you do not want to render to 0, the default framebuffer.
174
- def useframebuffer(*)
175
- super
176
- end
198
+ #
199
+ # This function is only needed when you do not want to render to 0, the
200
+ # default framebuffer.
201
+ #
202
+ # @!method useframebuffer
177
203
 
178
204
  # Set rendering quality
205
+ #
179
206
  # @param quality [] The quality to set
207
+ #
180
208
  # @return [Integer]
181
- def setquality(*)
182
- super
183
- end
209
+ #
210
+ # @!method setquality
184
211
 
185
212
  # @return [Integer]
186
213
  def getimage(width, height, use_alpha = true)
@@ -191,31 +218,31 @@ module GR3
191
218
  end
192
219
 
193
220
  # @return [Integer]
194
- def export(*)
195
- super
196
- end
221
+ # @!method export
197
222
 
198
223
  # @return [Integer]
199
- def drawimage(*)
200
- super
201
- end
224
+ # @!method drawimage
202
225
 
203
- # createmesh_nocopy
226
+ # This function creates a mesh from vertex position, normal and color data.
227
+ #
204
228
  # @return [Integer]
205
- def createmesh_nocopy(_n, vertices, normals, colors)
229
+ def createmesh_nocopy(n, vertices, normals, colors)
206
230
  inquiry_int do |mesh|
207
- super(mesh, vertices, normals, colors)
231
+ super(mesh, n, vertices, normals, colors)
208
232
  end
209
233
  end
210
234
 
211
235
  # This function creates a int from vertex position, normal and color data.
212
236
  # Returns a mesh.
213
- # @param n [Integer] the number of vertices in the mesh
237
+ #
238
+ # @param n [Integer] the number of vertices in the mesh
214
239
  # @param vertices [Array, NArray] the vertex positions
215
- # @param normals [Array, NArray] the vertex normals
216
- # @param colors [Array, NArray] the vertex colors,
217
- # they should be white (1,1,1) if you want to change the color for each drawn mesh
240
+ # @param normals [Array, NArray] the vertex normals
241
+ # @param colors [Array, NArray] the vertex colors, they should be
242
+ # white (1,1,1) if you want to change the color for each drawn mesh
243
+ #
218
244
  # @return [Integer]
245
+ #
219
246
  def createmesh(n, vertices, normals, colors)
220
247
  inquiry_int do |mesh|
221
248
  super(mesh, n, vertices, normals, colors)
@@ -223,6 +250,7 @@ module GR3
223
250
  end
224
251
 
225
252
  # This function creates a mesh from vertex position, normal and color data.
253
+ #
226
254
  # @return [Integer]
227
255
  def createindexedmesh_nocopy(num_vertices, vertices, normals, colors, num_indices, indices)
228
256
  inquiry_int do |mesh|
@@ -233,150 +261,159 @@ module GR3
233
261
  # This function creates an indexed mesh from vertex information (position,
234
262
  # normal and color) and triangle information (indices).
235
263
  # Returns a mesh.
236
- # @param num_vertices [Integer] the number of vertices in the mesh
237
- # @param vertices [Array, NArray] the vertex positions
238
- # @param normals [Array, NArray] the vertex normals
239
- # @param colors [Array, NArray] the vertex colors,
240
- # they should be white (1,1,1) if you want to change the color for each drawn mesh
241
- # @param num_indices [Integer] the number of indices in the mesh (three times the number of triangles)
242
- # @param indices [Array, NArray] the index array (vertex indices for each triangle)
264
+ #
265
+ # @param num_vertices [Integer] the number of vertices in the mesh
266
+ # @param vertices [Array, NArray] the vertex positions
267
+ # @param normals [Array, NArray] the vertex normals
268
+ # @param colors [Array, NArray] the vertex colors, they should be
269
+ # white (1,1,1) if you want to change
270
+ # the color for each drawn mesh
271
+ # @param num_indices [Integer] the number of indices in the mesh
272
+ # (three times the number of triangles)
273
+ # @param indices [Array, NArray] the index array (vertex indices for
274
+ # each triangle)
275
+ #
243
276
  # @return [Integer]
277
+ #
244
278
  def createindexedmesh(num_vertices, vertices, normals, colors, num_indices, indices)
245
279
  inquiry_int do |mesh|
246
280
  super(mesh, num_vertices, vertices, normals, colors, num_indices, indices)
247
281
  end
248
282
  end
249
283
 
250
- # This function adds a mesh to the draw list, so it will be drawn when the user calls getpixmap.
251
- # The given data stays owned by the user, a copy will be saved in the draw list and the mesh reference counter will be increased.
252
- # @param mesh [Integer] The mesh to be drawn
253
- # @param n [Integer] The number of meshes to be drawn
254
- # @param positions [Array, NArray] The positions where the meshes should be drawn
284
+ # This function adds a mesh to the draw list, so it will be drawn when the
285
+ # user calls getpixmap. The given data stays owned by the user, a copy will
286
+ # be saved in the draw list and the mesh reference counter will be increased.
287
+ #
288
+ # This function does not return an error code, because of its asynchronous
289
+ # nature. If gr3_getpixmap_() returns a GR3_ERROR_OPENGL_ERR, this might be
290
+ # caused by this function saving unuseable data into the draw list.
291
+ #
292
+ # @param mesh [Integer] The mesh to be drawn
293
+ # @param n [Integer] The number of meshes to be drawn
294
+ # @param positions [Array, NArray] The positions where the meshes should be drawn
255
295
  # @param directions [Array, NArray] The forward directions the meshes should be facing at
256
- # @param ups [Array, NArray] The up directions
257
- # @param colors [Array, NArray] The colors the meshes should be drawn in, it will be multiplied with each vertex color
258
- # @param scales [Array, NArray] The scaling factors
259
- def drawmesh(*)
260
- super
261
- end
262
-
263
- # This function marks a mesh for deletion and removes the user’s reference from the mesh’s referenc counter,
264
- # so a user must not use the mesh after calling this function.
296
+ # @param ups [Array, NArray] The up directions
297
+ # @param colors [Array, NArray] The colors the meshes should be drawn in,
298
+ # it will be multiplied with each vertex color
299
+ # @param scales [Array, NArray] The scaling factors
300
+ #
301
+ # @!method drawmesh
302
+
303
+ # This function marks a mesh for deletion and removes the user’s reference
304
+ # from the mesh’s referenc counter, so a user must not use the mesh after
305
+ # calling this function.
306
+ #
265
307
  # @param mesh [Integer] The mesh that should be marked for deletion
266
- def deletemesh(*)
267
- super
268
- end
308
+ #
309
+ # @!method deletemesh
269
310
 
270
311
  # This function sets the view matrix by getting the position of the camera,
271
312
  # the position of the center of focus and the direction which should point up.
313
+ # This function takes effect when the next image is created. Therefore if
314
+ # you want to take pictures of the same data from different perspectives,
315
+ # you can call and gr3_cameralookat(), gr3_getpixmap_(), gr3_cameralookat(),
316
+ # gr3_getpixmap_(), … without calling gr3_clear() and gr3_drawmesh() again.
317
+ #
272
318
  # @param camera_x [Array, NArray] The x-coordinate of the camera
273
319
  # @param camera_y [Array, NArray] The y-coordinate of the camera
274
320
  # @param camera_z [Array, NArray] The z-coordinate of the camera
275
321
  # @param center_x [Array, NArray] The x-coordinate of the center of focus
276
322
  # @param center_y [Array, NArray] The y-coordinate of the center of focus
277
323
  # @param center_z [Array, NArray] The z-coordinate of the center of focus
278
- # @param up_x [Array, NArray] The x-component of the up direction
279
- # @param up_y [Array, NArray] The y-component of the up direction
280
- # @param up_z [Array, NArray] The z-component of the up direction
281
- def cameralookat(*)
282
- super
283
- end
324
+ # @param up_x [Array, NArray] The x-component of the up direction
325
+ # @param up_y [Array, NArray] The y-component of the up direction
326
+ # @param up_z [Array, NArray] The z-component of the up direction
327
+ #
328
+ # @!method cameralookat
284
329
 
285
330
  # This function sets the projection parameters.
286
331
  # This function takes effect when the next image is created.
287
- # @param vertical_field_of_view [Numeric] This parameter is the vertical field of view in degrees.
288
- # It must be greater than 0 and less than 180.
332
+ #
333
+ # The ratio between zFar and zNear influences the precision of the depth
334
+ # buffer, the greater (zFar/zNear), the more likely are errors. So you should
335
+ # try to keep both values as close to each other as possible while making
336
+ # sure everything you want to be visible, is visible.
337
+ #
338
+ # @param vertical_field_of_view [Numeric]
339
+ # This parameter is the vertical field of view in degrees.
340
+ # It must be greater than 0 and less than 180.
289
341
  # @param zNear [Numeric] The distance to the near clipping plane.
290
- # @param zFar [Numeric] The distance to the far clipping plane.
342
+ # @param zFar [Numeric] The distance to the far clipping plane.
343
+ #
291
344
  # @return [Integer]
292
- def setcameraprojectionparameters(*)
293
- super
294
- end
345
+ #
346
+ # @!method setcameraprojectionparameters
295
347
 
296
348
  # Get the projection parameters.
349
+ #
350
+ # @param vfov [Array, NArray] Vertical field of view in degrees
351
+ # @param znear [Array, NArray] The distance to the near clipping plane.
352
+ # @param zfar [Array, NArray] The distance to the far clipping plane.
353
+ #
297
354
  # @return [Integer]
298
- def getcameraprojectionparameters(*)
299
- super
300
- end
355
+ #
356
+ # @!method getcameraprojectionparameters
301
357
 
302
- # This function sets the direction of light.
303
- # If it is called with (0, 0, 0), the light is always pointing into the same direction as the camera.
358
+ # This function sets the direction of light. If it is called with (0, 0, 0),
359
+ # the light is always pointing into the same direction as the camera.
360
+ #
304
361
  # @param x [Numeric] The x-component of the light's direction
305
362
  # @param y [Numeric] The y-component of the light's direction
306
363
  # @param z [Numeric] The z-component of the light's direction
307
- def setlightdirection(*)
308
- super
309
- end
364
+ #
365
+ # @!method setlightdirection
310
366
 
311
367
  # This function sets the background color.
312
- def setbackgroundcolor(*)
313
- super
314
- end
368
+ # @!method setbackgroundcolor
315
369
 
316
370
  # @return [Integer]
317
- def createheightmapmesh(*)
318
- super
319
- end
371
+ # @!method createheightmapmesh
320
372
 
321
- def drawheightmap(*)
322
- super
323
- end
373
+ # @!method drawheightmap
324
374
 
325
375
  # This function allows drawing a cylinder without requiring a mesh.
326
- def drawconemesh(*)
327
- super
328
- end
376
+ # @!method drawconemesh
329
377
 
330
378
  # This function allows drawing a cylinder without requiring a mesh.
331
- def drawcylindermesh(*)
332
- super
333
- end
379
+ # @!method drawcylindermesh
334
380
 
335
381
  # This function allows drawing a sphere without requiring a mesh.
336
- def drawspheremesh(*)
337
- super
338
- end
382
+ # @!method drawspheremesh
339
383
 
340
- def drawcubemesh(*)
341
- super
342
- end
384
+ # @!method drawcubemesh
343
385
 
344
- def setobjectid(*)
345
- super
346
- end
386
+ # @!method setobjectid
347
387
 
348
388
  # @return [Integer]
349
- def selectid(*)
350
- super
351
- end
389
+ # @!method selectid
352
390
 
353
- def getviewmatrix(*)
354
- super
355
- end
391
+ # @param m [Array, NArray] the 4x4 column major view matrix
392
+ # @!method getviewmatrix
356
393
 
357
- def setviewmatrix(*)
358
- super
359
- end
394
+ # @param m [Array, NArray] the 4x4 column major view matrix
395
+ # @!method setviewmatrix
360
396
 
361
- # the current projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
362
397
  # @return [Integer]
363
- def getprojectiontype(*)
364
- super
365
- end
398
+ # the current projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
399
+ # @!method getprojectiontype
366
400
 
367
- # @param type [Integer] the new projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
368
- def setprojectiontype(*)
369
- super
370
- end
401
+ # @param type [Integer]
402
+ # the new projection type: GR3_PROJECTION_PERSPECTIVE,
403
+ # GR3_PROJECTION_PARALLEL or GR3_PROJECTION_ORTHOGRAPHIC
404
+ # @!method setprojectiontype
371
405
 
372
406
  # This function creates an isosurface from voxel data using the
373
407
  # marching cubes algorithm.
374
408
  # Returns a mesh.
375
- # @param grid [NArray] 3D narray array containing the voxel data
376
- # @param step [Array] voxel sizes in each direction
377
- # @param offset [Array] coordinate origin in each direction
378
- # @param isolevel [Integer] isovalue at which the surface will be created
409
+ #
410
+ # @param grid [NArray] 3D narray array containing the voxel data
411
+ # @param step [Array, NArray] voxel sizes in each direction
412
+ # @param offset [Array, NArray] coordinate origin in each direction
413
+ # @param isolevel [Integer] isovalue at which the surface will be created
414
+ #
379
415
  # @return [Integer]
416
+ #
380
417
  def createisosurfacemesh(grid, step, offset, isolevel)
381
418
  args = _preprocess_createslicemesh(grid, step, offset)
382
419
  grid = args.shift
@@ -388,10 +425,11 @@ module GR3
388
425
  # Create a mesh of a surface plot similar to gr_surface.
389
426
  # Uses the current colormap. To apply changes of the colormap
390
427
  # a new mesh has to be created.
391
- # @param nx [Integer] number of points in x-direction
392
- # @param ny [Integer] number of points in y-direction
393
- # @param x [Array, NArray] an array containing the x-coordinates
394
- # @param y [Array, NArray] an array containing the y-coordinates
428
+ #
429
+ # @param nx [Integer] number of points in x-direction
430
+ # @param ny [Integer] number of points in y-direction
431
+ # @param x [Array, NArray] an array containing the x-coordinates
432
+ # @param y [Array, NArray] an array containing the y-coordinates
395
433
  # @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
396
434
  # @param option [Integer] option for the surface mesh; the GR3_SURFACE constants can be combined with bitwise or. See the table below.
397
435
  # * 0 : GR3_SURFACE_DEFAULT
@@ -406,6 +444,7 @@ module GR3
406
444
  # * color the surface according to the current gr colormap
407
445
  # * 16 : GR3_SURFACE_GRZSHADED
408
446
  # * like GR3_SURFACE_GRCOLOR, but use the z-value directly as color index
447
+ #
409
448
  # @return [Integer]
410
449
  def createsurfacemesh(nx, ny, x, y, z, option = 0)
411
450
  inquiry_int do |mesh|
@@ -419,29 +458,32 @@ module GR3
419
458
  # the viewmatrix and the light direction. If necessary, the user has to
420
459
  # save them before the call to this function and restore them after
421
460
  # the call to gr3_drawimage.
422
- # @param mesh [Integer] the mesh to be drawn
423
- # @param n [Integer] the number of meshes to be drawn
424
- # @param positions [Array, NArray] the positions where the meshes should be drawn
461
+ #
462
+ # @param mesh [Integer] the mesh to be drawn
463
+ # @param n [Integer] the number of meshes to be drawn
464
+ # @param positions [Array, NArray] the positions where the meshes should be drawn
425
465
  # @param directions [Array, NArray] the forward directions the meshes should be facing at
426
- # @param ups [Array, NArray] the up directions
427
- # @param colors [Array, NArray] the colors the meshes should be drawn in, it will be multiplied with each vertex color
428
- # @param scales [Array, NArray] the scaling factors
429
- def drawmesh_grlike(*)
430
- super
431
- end
466
+ # @param ups [Array, NArray] the up directions
467
+ # @param colors [Array, NArray] the colors the meshes should be drawn in,
468
+ # it will be multiplied with each vertex color
469
+ # @param scales [Array, NArray] the scaling factors
470
+ #
471
+ # @!method drawmesh_grlike
432
472
 
433
473
  # Convenience function for drawing a surfacemesh.
474
+ #
434
475
  # @param mesh [Integer] the mesh to be drawn
435
- def drawsurface(*)
436
- super
437
- end
476
+ #
477
+ # @!method drawsurface
438
478
 
439
479
  # Create a surface plot with gr3 and draw it with gks as cellarray.
440
- # @param x [Array, NArray] an array containing the x-coordinates
441
- # @param y [Array, NArray] an array containing the y-coordinates
442
- # @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
443
- # @param option [Integer] see the option parameter of gr_surface.
444
- # OPTION_COLORED_MESH and OPTION_Z_SHADED_MESH are supported.
480
+ #
481
+ # @param x [Array, NArray] an array containing the x-coordinates
482
+ # @param y [Array, NArray] an array containing the y-coordinates
483
+ # @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
484
+ # @param option [Integer] see the option parameter of gr_surface.
485
+ # OPTION_COLORED_MESH and OPTION_Z_SHADED_MESH are supported.
486
+ #
445
487
  def surface(x, y, z, option)
446
488
  nx = x.length
447
489
  ny = y.length
@@ -449,17 +491,20 @@ module GR3
449
491
  super(nx, ny, x, y, z, option)
450
492
  end
451
493
 
452
- # drawtubemesh
453
494
  # Draw a tube following a path given by a list of points. The colors and
454
495
  # radii arrays specify the color and radius at each point.
455
- # @param n [Integer] the number of points given
496
+ #
497
+ # @param n [Integer] the number of points given
456
498
  # @param points [Array, NArray] the points the tube should go through
457
499
  # @param colors [Array, NArray] the color at each point
458
- # @param radii [Array, NArray] the desired tube radius at each point
459
- # @param num_steps [Integer] the number of steps between each point, allowing for a more smooth tube
460
- # @param num_segments [Integer] the number of segments each ring of the tube consists of,
461
- # e.g. 3 would yield a triangular tube
500
+ # @param radii [Array, NArray] the desired tube radius at each point
501
+ # @param num_steps [Integer] the number of steps between each point,
502
+ # allowing for a more smooth tube
503
+ # @param num_segments [Integer] the number of segments each ring of the tube
504
+ # consists of, e.g. 3 would yield a triangular tube
505
+ #
462
506
  # @return [Integer]
507
+ #
463
508
  def drawtubemesh(n, points, colors, radii, num_steps = 10, num_segments = 20)
464
509
  super(n, points, colors, radii, num_steps, num_segments)
465
510
  end
@@ -467,12 +512,17 @@ module GR3
467
512
  # Create a mesh object in the shape of a tube following a path given by a
468
513
  # list of points. The colors and radii arrays specify the color and radius at
469
514
  # each point.
470
- # @param n [Integer] the number of points given
471
- # @param points [Array, NArray] the points the tube should go through
472
- # @param colors [Array, NArray] the color at each point
473
- # @param radii [Array, NArray] the desired tube radius at each point
474
- # @param num_steps [Integer] the number of steps between each point, allowing for a more smooth tube
475
- # @param num_segments [Integer] the number of segments each ring of the tube consists of, e.g. 3 would yield a triangular tube
515
+ #
516
+ # @param n [Integer] the number of points given
517
+ # @param points [Array, NArray] the points the tube should go through
518
+ # @param colors [Array, NArray] the color at each point
519
+ # @param radii [Array, NArray] the desired tube radius at each point
520
+ # @param num_steps [Integer] the number of steps between each point,
521
+ # allowing for a more smooth tube
522
+ # @param num_segments [Integer] the number of segments each ring of the
523
+ # tube consists of, e.g. 3 would yield a
524
+ # triangular tube
525
+ #
476
526
  # @return [Integer]
477
527
  def createtubemesh(n, points, colors, radii, num_steps = 10, num_segments = 20)
478
528
  inquiry_uint do |mesh| # mesh should be Int?
@@ -547,12 +597,14 @@ module GR3
547
597
  # drawn and at which positions they should go through the data. If neither
548
598
  # x nor y nor z are set, 0.5 will be used for all three.
549
599
  # Returns meshes for the yz-slice, the xz-slice and the xy-slice.
550
- # @param grid [NArray] 3D narray array containing the voxel data
551
- # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
552
- # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
553
- # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
554
- # @param step [Array] voxel sizes in each direction
555
- # @param offset [Array] coordinate origin in each direction
600
+ #
601
+ # @param grid [NArray] 3D narray array containing the voxel data
602
+ # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
603
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
604
+ # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
605
+ # @param step [Array, NArray] voxel sizes in each direction
606
+ # @param offset [Array, NArray] coordinate origin in each direction
607
+ #
556
608
  def createslicemeshes(grid, x = nil, y = nil, z = nil, step = nil, offset = nil)
557
609
  if [x, y, z].all?(&:nil?)
558
610
  x = 0.5
@@ -569,10 +621,11 @@ module GR3
569
621
  # using the current GR colormap. Use the x parameter to set the position of
570
622
  # the yz-slice.
571
623
  # Returns a mesh for the yz-slice.
572
- # @param grid [NArray] 3D narray array containing the voxel data
573
- # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
574
- # @param step [Array] voxel sizes in each direction
575
- # @param offset [Array] coordinate origin in each direction
624
+ #
625
+ # @param grid [NArray] 3D narray array containing the voxel data
626
+ # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
627
+ # @param step [Array, NArray] voxel sizes in each direction
628
+ # @param offset [Array, NArray] coordinate origin in each direction
576
629
  def createxslicemesh(grid, x = 0.5, step = nil, offset = nil)
577
630
  args = _preprocess_createslicemesh(grid, step, offset)
578
631
  grid = args.shift
@@ -586,10 +639,12 @@ module GR3
586
639
  # using the current GR colormap. Use the y parameter to set the position of
587
640
  # the xz-slice.
588
641
  # Returns a mesh for the xz-slice.
589
- # @param grid [NArray] 3D narray array containing the voxel data
590
- # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
591
- # @param step [Array] voxel sizes in each direction
592
- # @param offset [Array] coordinate origin in each direction
642
+ #
643
+ # @param grid [NArray] 3D narray array containing the voxel data
644
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
645
+ # @param step [Array, NArray] voxel sizes in each direction
646
+ # @param offset [Array, NArray] coordinate origin in each direction
647
+ #
593
648
  def createyslicemesh(grid, y = 0.5, step = nil, offset = nil)
594
649
  args = _preprocess_createslicemesh(grid, step, offset)
595
650
  grid = args.shift
@@ -603,10 +658,12 @@ module GR3
603
658
  # using the current GR colormap. Use the z parameter to set the position of
604
659
  # the xy-slice.
605
660
  # Returns a mesh for the xy-slice.
606
- # @param grid [NArray] 3D narray array containing the voxel data
607
- # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
608
- # @param step [Array] voxel sizes in each direction
609
- # @param offset [Array] coordinate origin in each direction
661
+ #
662
+ # @param grid [NArray] 3D narray array containing the voxel data
663
+ # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
664
+ # @param step [Array, NArray] voxel sizes in each direction
665
+ # @param offset [Array, NArray] coordinate origin in each direction
666
+ #
610
667
  def createzslicemesh(grid, z = 0.5, step = nil, offset = nil)
611
668
  args = _preprocess_createslicemesh(grid, step, offset)
612
669
  grid = args.shift
@@ -617,15 +674,18 @@ module GR3
617
674
  end
618
675
 
619
676
  # Draw a yz-slice through the given data, using the current GR colormap.
620
- # @param grid [NArray] 3D narray array containing the voxel data
621
- # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
622
- # @param step [Array] voxel sizes in each direction
623
- # @param offset [Array] coordinate origin in each direction
624
- # @param position [Array] the positions where the meshes should be drawn
625
- # @param direction [Array] the forward directions the meshes should be facing at
626
- # @param up [Array] the up directions
627
- # @param color [Array] the colors the meshes should be drawn in, it will be multiplied with each vertex color
628
- # @param scale [Array] the scaling factors
677
+ #
678
+ # @param grid [NArray] 3D narray array containing the voxel data
679
+ # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
680
+ # @param step [Array, NArray] voxel sizes in each direction
681
+ # @param offset [Array, NArray] coordinate origin in each direction
682
+ # @param position [Array, NArray] the positions where the meshes should be drawn
683
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
684
+ # @param up [Array, NArray] the up directions
685
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
686
+ # it will be multiplied with each vertex color
687
+ # @param scale [Array, NArray] the scaling factors
688
+ #
629
689
  def drawxslicemesh(grid, x = 0.5, step = nil, offset = nil,
630
690
  position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
631
691
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -635,15 +695,18 @@ module GR3
635
695
  end
636
696
 
637
697
  # Draw a xz-slice through the given data, using the current GR colormap.
638
- # @param grid [NArray] 3D narray array containing the voxel data
639
- # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
640
- # @param step [Array] voxel sizes in each direction
641
- # @param offset [Array] coordinate origin in each direction
642
- # @param position [Array] the positions where the meshes should be drawn
643
- # @param direction [Array] the forward directions the meshes should be facing at
644
- # @param up [Array] the up directions
645
- # @param color [Array] the colors the meshes should be drawn in, it will be multiplied with each vertex color
646
- # @param scale [Array] the scaling factors
698
+ #
699
+ # @param grid [NArray] 3D narray array containing the voxel data
700
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
701
+ # @param step [Array, NArray] voxel sizes in each direction
702
+ # @param offset [Array, NArray] coordinate origin in each direction
703
+ # @param position [Array, NArray] the positions where the meshes should be drawn
704
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
705
+ # @param up [Array, NArray] the up directions
706
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
707
+ # it will be multiplied with each vertex color
708
+ # @param scale [Array, NArray] the scaling factors
709
+ #
647
710
  def drawyslicemesh(grid, y = 0.5, step = nil, offset = nil,
648
711
  position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
649
712
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -653,15 +716,18 @@ module GR3
653
716
  end
654
717
 
655
718
  # Draw a xy-slice through the given data, using the current GR colormap.
656
- # @param grid [NArray] 3D narray array containing the voxel data
657
- # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
658
- # @param step [Array] voxel sizes in each direction
659
- # @param offset [Array] coordinate origin in each direction
660
- # @param position [Array] the positions where the meshes should be drawn
661
- # @param direction [Array] the forward directions the meshes should be facing at
662
- # @param up [Array] the up directions
663
- # @param color [Array] the colors the meshes should be drawn in, it will be multiplied with each vertex color
664
- # @param scale [Array] the scaling factors
719
+ #
720
+ # @param grid [NArray] 3D narray array containing the voxel data
721
+ # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
722
+ # @param step [Array, NArray] voxel sizes in each direction
723
+ # @param offset [Array, NArray] coordinate origin in each direction
724
+ # @param position [Array, NArray] the positions where the meshes should be drawn
725
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
726
+ # @param up [Array, NArray] the up directions
727
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
728
+ # it will be multiplied with each vertex color
729
+ # @param scale [Array, NArray] the scaling factors
730
+ #
665
731
  def drawzslicemesh(grid, z = 0.5, step = nil, offset = nil,
666
732
  position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
667
733
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -674,17 +740,20 @@ module GR3
674
740
  # Use the parameters x, y or z to specify what slices should be drawn and at
675
741
  # which positions they should go through the data. If neither x nor y nor
676
742
  # z are set, 0.5 will be used for all three.
743
+ #
677
744
  # @param grid [NArray] 3D narray array containing the voxel data
678
- # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
679
- # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
680
- # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
681
- # @param step [Array] voxel sizes in each direction
682
- # @param offset [Array] coordinate origin in each direction
683
- # @param position [Array] the positions where the meshes should be drawn
684
- # @param direction [Array] the forward directions the meshes should be facing at
685
- # @param up [Array] the up directions
686
- # @param color [Array] the colors the meshes should be drawn in, it will be multiplied with each vertex color
687
- # @param scale [Array] the scaling factors
745
+ # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
746
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
747
+ # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
748
+ # @param step [Array, NArray] voxel sizes in each direction
749
+ # @param offset [Array, NArray] coordinate origin in each direction
750
+ # @param position [Array, NArray] the positions where the meshes should be drawn
751
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
752
+ # @param up [Array, NArray] the up directions
753
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
754
+ # it will be multiplied with each vertex color
755
+ # @param scale [Array, NArray] the scaling factors
756
+ #
688
757
  def drawslicemeshes(grid, x = nil, y = nil, z = nil, step = nil,
689
758
  offset = nil, position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
690
759
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -757,6 +826,7 @@ module GR3
757
826
  IA_END_OF_LIST = 0
758
827
  IA_FRAMEBUFFER_WIDTH = 1
759
828
  IA_FRAMEBUFFER_HEIGHT = 2
829
+ IA_NUM_THREADS = 3
760
830
 
761
831
  # Error
762
832
  ERROR_NONE = 0
@@ -787,6 +857,11 @@ module GR3
787
857
  DRAWABLE_OPENGL = 1
788
858
  DRAWABLE_GKS = 2
789
859
 
860
+ # Projection
861
+ PROJECTION_PERSPECTIVE = 0
862
+ PROJECTION_PARALLEL = 1
863
+ PROJECTION_ORTHOGRAPHIC = 2
864
+
790
865
  # SurfaceOption
791
866
  SURFACE_DEFAULT = 0
792
867
  SURFACE_NORMALS = 1