ruby-gr 0.0.1
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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/lib/gr.rb +550 -0
- data/lib/gr/ffi.rb +172 -0
- data/lib/gr/grbase.rb +13 -0
- data/lib/gr3.rb +134 -0
- data/lib/gr3/ffi.rb +94 -0
- data/lib/gr3/gr3base.rb +23 -0
- data/lib/gr_commons.rb +9 -0
- data/lib/gr_commons/attach_function.rb +13 -0
- data/lib/gr_commons/define_methods.rb +28 -0
- data/lib/gr_commons/gr_common_utils.rb +107 -0
- data/lib/gr_commons/jupyter_support.rb +24 -0
- metadata +153 -0
data/lib/gr/ffi.rb
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
|
5
|
+
module GR
|
6
|
+
module FFI
|
7
|
+
extend ::FFI::Library
|
8
|
+
|
9
|
+
ffi_lib GR.ffi_lib
|
10
|
+
|
11
|
+
extend GRCommons::AttachFunction
|
12
|
+
|
13
|
+
# https://github.com/sciapp/gr/blob/master/lib/gr/gr.c
|
14
|
+
|
15
|
+
attach_function :gr_initgr, %i[], :void
|
16
|
+
|
17
|
+
# gks - graphical kernel system
|
18
|
+
attach_function :gr_opengks, %i[], :void
|
19
|
+
attach_function :gr_closegks, %i[], :void
|
20
|
+
attach_function :gr_inqdspsize, %i[pointer pointer pointer pointer], :void
|
21
|
+
|
22
|
+
# ws - workstation
|
23
|
+
attach_function :gr_openws, %i[int string int], :void
|
24
|
+
attach_function :gr_closews, %i[int], :void
|
25
|
+
attach_function :gr_activatews, %i[int], :void
|
26
|
+
attach_function :gr_deactivatews, %i[int], :void
|
27
|
+
attach_function :gr_configurews, %i[], :void
|
28
|
+
attach_function :gr_clearws, %i[], :void
|
29
|
+
attach_function :gr_updatews, %i[], :void
|
30
|
+
|
31
|
+
attach_function :gr_polyline, %i[int pointer pointer], :void
|
32
|
+
attach_function :gr_polymarker, %i[int pointer pointer], :void
|
33
|
+
attach_function :gr_text, %i[double double string], :void
|
34
|
+
attach_function :gr_inqtext, %i[double double string pointer pointer], :void
|
35
|
+
attach_function :gr_fillarea, %i[int pointer pointer], :void
|
36
|
+
attach_function :gr_cellarray, %i[double double double double int int int int int int pointer], :void
|
37
|
+
attach_function :gr_nonuniformcellarray, %i[pointer pointer int int int int int int pointer], :void
|
38
|
+
attach_function :gr_polarcellarray, %i[double double double double double double int int int int int int pointer], :void
|
39
|
+
attach_function :gr_gdp, %i[int pointer pointer int int pointer], :void
|
40
|
+
attach_function :gr_spline, %i[int pointer pointer int int], :void
|
41
|
+
attach_function :gr_gridit, %i[int pointer pointer pointer int int pointer pointer pointer], :void
|
42
|
+
|
43
|
+
# inq - inquiry
|
44
|
+
attach_function :gr_setlinetype, %i[int], :void
|
45
|
+
attach_function :gr_inqlinetype, %i[pointer], :void
|
46
|
+
attach_function :gr_setlinewidth, %i[double], :void
|
47
|
+
attach_function :gr_inqlinewidth, %i[pointer], :void
|
48
|
+
attach_function :gr_setlinecolorind, %i[int], :void
|
49
|
+
attach_function :gr_inqlinecolorind, %i[pointer], :void
|
50
|
+
attach_function :gr_setmarkertype, %i[int], :void
|
51
|
+
attach_function :gr_inqmarkertype, %i[pointer], :void
|
52
|
+
attach_function :gr_setmarkersize, %i[double], :void
|
53
|
+
# gr_inqmarkersize is not implemented
|
54
|
+
attach_function :gr_setmarkercolorind, %i[int], :void
|
55
|
+
attach_function :gr_inqmarkercolorind, %i[pointer], :void
|
56
|
+
|
57
|
+
attach_function :gr_settextfontprec, %i[int int], :void
|
58
|
+
attach_function :gr_setcharexpan, %i[double], :void
|
59
|
+
attach_function :gr_setcharspace, %i[double], :void
|
60
|
+
attach_function :gr_settextcolorind, %i[int], :void
|
61
|
+
attach_function :gr_setcharheight, %i[double], :void
|
62
|
+
attach_function :gr_setcharup, %i[double double], :void
|
63
|
+
attach_function :gr_settextpath, %i[int], :void
|
64
|
+
attach_function :gr_settextalign, %i[int int], :void
|
65
|
+
|
66
|
+
attach_function :gr_setfillintstyle, %i[int], :void
|
67
|
+
attach_function :gr_inqfillintstyle, %i[pointer], :void
|
68
|
+
attach_function :gr_setfillstyle, %i[int], :void
|
69
|
+
attach_function :gr_inqfillstyle, %i[pointer], :void
|
70
|
+
attach_function :gr_setfillcolorind, %i[int], :void
|
71
|
+
attach_function :gr_inqfillcolorind, %i[pointer], :void
|
72
|
+
|
73
|
+
attach_function :gr_setcolorrep, %i[int double double double], :void
|
74
|
+
attach_function :gr_setscale, %i[int], :int
|
75
|
+
attach_function :gr_inqscale, %i[pointer], :void
|
76
|
+
|
77
|
+
attach_function :gr_setwindow, %i[double double double double], :void
|
78
|
+
attach_function :gr_inqwindow, %i[pointer pointer pointer pointer], :void
|
79
|
+
attach_function :gr_setviewport, %i[double double double double], :void
|
80
|
+
attach_function :gr_inqviewport, %i[pointer pointer pointer pointer], :void
|
81
|
+
attach_function :gr_selntran, %i[int], :void
|
82
|
+
attach_function :gr_setclip, %i[int], :void
|
83
|
+
|
84
|
+
attach_function :gr_setwswindow, %i[double double double double], :void
|
85
|
+
attach_function :gr_setwsviewport, %i[double double double double], :void
|
86
|
+
attach_function :gr_createseg, %i[int], :void
|
87
|
+
attach_function :gr_copysegws, %i[int], :void
|
88
|
+
attach_function :gr_redrawsegws, %i[], :void
|
89
|
+
attach_function :gr_setsegtran, %i[int double double double double double double double], :void
|
90
|
+
attach_function :gr_closeseg, %i[], :void
|
91
|
+
attach_function :gr_emergencyclosegks, %i[], :void
|
92
|
+
attach_function :gr_updategks, %i[], :void
|
93
|
+
attach_function :gr_setspace, %i[double double int int], :void
|
94
|
+
attach_function :gr_inqspace, %i[pointer pointer pointer pointer], :void
|
95
|
+
attach_function :gr_textext, %i[double double string], :int
|
96
|
+
attach_function :gr_inqtextext, %i[double double string pointer pointer], :void
|
97
|
+
|
98
|
+
# attach_function :gr_axeslbl
|
99
|
+
attach_function :gr_axes, %i[double double double double int int double], :void
|
100
|
+
attach_function :gr_grid, %i[double double double double int int], :void
|
101
|
+
attach_function :gr_grid3d, %i[double double double double double double int int int], :void
|
102
|
+
attach_function :gr_verrorbars, %i[int pointer pointer pointer pointer], :void
|
103
|
+
attach_function :gr_herrorbars, %i[int pointer pointer pointer pointer], :void
|
104
|
+
|
105
|
+
attach_function :gr_polyline3d, %i[int pointer pointer pointer], :void
|
106
|
+
attach_function :gr_polymarker3d, %i[int pointer pointer pointer], :void
|
107
|
+
attach_function :gr_axes3d, %i[double double double double double double int int int double], :void
|
108
|
+
attach_function :gr_titles3d, %i[string string string], :void
|
109
|
+
attach_function :gr_surface, %i[int int pointer pointer pointer int], :void
|
110
|
+
attach_function :gr_trisurface, %i[int pointer pointer pointer], :void
|
111
|
+
attach_function :gr_gradient, %i[int int pointer pointer pointer pointer pointer], :void
|
112
|
+
attach_function :gr_quiver, %i[int int pointer pointer pointer pointer int], :void
|
113
|
+
attach_function :gr_contour, %i[int int int pointer pointer pointer pointer int], :void
|
114
|
+
attach_function :gr_contourf, %i[int int int pointer pointer pointer pointer int], :void
|
115
|
+
attach_function :gr_tricontour, %i[int pointer pointer pointer int pointer], :void
|
116
|
+
attach_function :gr_hexbin, %i[int pointer pointer int], :int
|
117
|
+
attach_function :gr_setcolormap, %i[int], :void
|
118
|
+
attach_function :gr_inqcolormap, %i[pointer], :void
|
119
|
+
attach_function :gr_setcolormapfromrgb, %i[int pointer pointer pointer pointer], :void
|
120
|
+
attach_function :gr_colorbar, %i[], :void
|
121
|
+
attach_function :gr_inqcolor, %i[int pointer], :void
|
122
|
+
attach_function :gr_inqcolorfromrgb, %i[double double double], :int
|
123
|
+
attach_function :gr_hsvtorgb, %i[double double double pointer pointer pointer], :void
|
124
|
+
attach_function :gr_tick, %i[double double], :double
|
125
|
+
|
126
|
+
attach_function :gr_validaterange, %i[double double], :int
|
127
|
+
attach_function :gr_adjustrange, %i[pointer pointer], :void
|
128
|
+
attach_function :gr_beginprint, %i[string], :void
|
129
|
+
attach_function :gr_beginprintext, %i[string string string string], :void
|
130
|
+
attach_function :gr_endprint, %i[], :void
|
131
|
+
attach_function :gr_ndctowc, %i[pointer pointer], :void
|
132
|
+
attach_function :gr_wctondc, %i[pointer pointer], :void
|
133
|
+
attach_function :gr_wc3towc, %i[pointer pointer pointer], :void
|
134
|
+
attach_function :gr_drawrect, %i[double double double double], :void
|
135
|
+
attach_function :gr_fillrect, %i[double double double double], :void
|
136
|
+
attach_function :gr_drawarc, %i[double double double double double double], :void
|
137
|
+
attach_function :gr_fillarc, %i[double double double double double double], :void
|
138
|
+
attach_function :gr_drawpath, %i[int pointer pointer int], :void
|
139
|
+
attach_function :gr_setarrowstyle, %i[int], :void
|
140
|
+
attach_function :gr_setarrowsize, %i[double], :void
|
141
|
+
attach_function :gr_drawarrow, %i[double double double double], :void
|
142
|
+
attach_function :gr_drawimage, %i[double double double double int int pointer int], :void
|
143
|
+
attach_function :gr_setshadow, %i[double double double], :void
|
144
|
+
attach_function :gr_settransparency, %i[double], :void
|
145
|
+
attach_function :gr_setcoordxform, %i[pointer], :void
|
146
|
+
attach_function :gr_begingraphics, %i[string], :void
|
147
|
+
attach_function :gr_endgraphics, %i[], :void
|
148
|
+
attach_function :gr_mathtex, %i[double double string], :void
|
149
|
+
attach_function :gr_inqmathtex, %i[double double string pointer pointer], :void
|
150
|
+
attach_function :gr_beginselection, %i[int int], :void
|
151
|
+
attach_function :gr_endselection, %i[], :void
|
152
|
+
attach_function :gr_moveselection, %i[double double], :void
|
153
|
+
attach_function :gr_resizeselection, %i[int double double], :void
|
154
|
+
attach_function :gr_inqbbox, %i[pointer pointer pointer pointer], :void
|
155
|
+
attach_function :gr_precision, %i[], :void
|
156
|
+
attach_function :gr_setregenflags, %i[int], :void
|
157
|
+
attach_function :gr_inqregenflags, %i[], :void
|
158
|
+
attach_function :gr_savestate, %i[], :void
|
159
|
+
attach_function :gr_restorestate, %i[], :void
|
160
|
+
attach_function :gr_selectcontext, %i[int], :void
|
161
|
+
attach_function :gr_destroycontext, %i[int], :void
|
162
|
+
attach_function :gr_uselinespec, %i[string], :void
|
163
|
+
attach_function :gr_adjustlimits, %i[pointer pointer], :void
|
164
|
+
attach_function :gr_version, %i[], :pointer
|
165
|
+
|
166
|
+
attach_function :gr_reducepoints, %i[int pointer pointer int pointer pointer], :void
|
167
|
+
attach_function :gr_shadepoints, %i[int pointer pointer int int int], :void
|
168
|
+
attach_function :gr_shadelines, %i[int pointer pointer int int int], :void
|
169
|
+
attach_function :gr_panzoom, %i[double double double double pointer pointer pointer pointer], :void
|
170
|
+
# attach_function :gr_findboundary
|
171
|
+
end
|
172
|
+
end
|
data/lib/gr/grbase.rb
ADDED
data/lib/gr3.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
|
5
|
+
module GR3
|
6
|
+
class << self
|
7
|
+
attr_reader :ffi_lib
|
8
|
+
end
|
9
|
+
|
10
|
+
# Platforms | path
|
11
|
+
# Windows | bin/libgr3.dll
|
12
|
+
# MacOSX | lib/libGR3.so (NOT .dylib)
|
13
|
+
# Ubuntu | lib/libGR3.so
|
14
|
+
raise 'Please set env variable GRDIR' unless ENV['GRDIR']
|
15
|
+
|
16
|
+
ENV['GKS_FONTPATH'] ||= ENV['GRDIR']
|
17
|
+
@ffi_lib = case RbConfig::CONFIG['host_os']
|
18
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
19
|
+
File.expand_path('bin/libgr3.dll', ENV['GRDIR'])
|
20
|
+
.gsub('/', '\\') # windows backslash
|
21
|
+
else
|
22
|
+
File.expand_path('lib/libGR3.so', ENV['GRDIR'])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require_relative 'gr_commons'
|
27
|
+
require 'gr3/ffi'
|
28
|
+
require 'gr3/gr3base'
|
29
|
+
|
30
|
+
module GR3
|
31
|
+
extend GRCommons::JupyterSupport
|
32
|
+
extend GR3Base
|
33
|
+
|
34
|
+
# 1. double is the default type
|
35
|
+
# 2. don't check size (for now)
|
36
|
+
|
37
|
+
module CheckError
|
38
|
+
FFI.ffi_methods.each do |method|
|
39
|
+
method_name = method.to_s.sub(/^gr3_/, '')
|
40
|
+
next if method_name == 'geterror'
|
41
|
+
|
42
|
+
define_method(method_name) do |*args|
|
43
|
+
values = super(*args)
|
44
|
+
GR3Base.check_error
|
45
|
+
values
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
extend CheckError
|
50
|
+
|
51
|
+
class << self
|
52
|
+
def createmesh_nocopy(_n, vertices, normals, colors)
|
53
|
+
inquiry_int do |mesh|
|
54
|
+
super(mesh, vertices, normals, colors)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def createmesh(_n, vertices, normals, colors)
|
59
|
+
inquiry_int do |mesh|
|
60
|
+
super(mesh, vertices, normals, colors)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def createindexedmesh_nocopy(num_vertices, vertices, normals, colors, num_indices, indices)
|
65
|
+
inquiry_int do |mesh|
|
66
|
+
super(mesh, num_vertices, vertices, normals, colors, num_indices, indices)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def createindexedmesh(num_vertices, vertices, normals, colors, num_indices, indices)
|
71
|
+
inquiry_int do |mesh|
|
72
|
+
super(mesh, num_vertices, vertices, normals, colors, num_indices, indices)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def getimage(width, height, use_alpha = true)
|
77
|
+
bpp = use_alpha ? 4 : 3
|
78
|
+
inquiry(uint8: width * height * bpp) do |bitmap|
|
79
|
+
super(width, height, (use_alpha ? 1 : 0), bitmap)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# gr3_gr
|
84
|
+
|
85
|
+
def createsurfacemesh(nx, ny, px, py, pz, option = 0)
|
86
|
+
inquiry_int do |mesh|
|
87
|
+
super(mesh, nx, ny, px, py, pz, option)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# gr3_convenience
|
92
|
+
|
93
|
+
def drawtubemesh(n, points, colors, radii, num_steps = 10, num_segments = 20)
|
94
|
+
super(n, points, colors, radii, num_steps, num_segments)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
IA_END_OF_LIST = 0
|
99
|
+
IA_FRAMEBUFFER_WIDTH = 1
|
100
|
+
IA_FRAMEBUFFER_HEIGHT = 2
|
101
|
+
|
102
|
+
ERROR_NONE = 0
|
103
|
+
ERROR_INVALID_VALUE = 1
|
104
|
+
ERROR_INVALID_ATTRIBUTE = 2
|
105
|
+
ERROR_INIT_FAILED = 3
|
106
|
+
ERROR_OPENGL_ERR = 4
|
107
|
+
ERROR_OUT_OF_MEM = 5
|
108
|
+
ERROR_NOT_INITIALIZED = 6
|
109
|
+
ERROR_CAMERA_NOT_INITIALIZED = 7
|
110
|
+
ERROR_UNKNOWN_FILE_EXTENSION = 8
|
111
|
+
ERROR_CANNOT_OPEN_FILE = 9
|
112
|
+
ERROR_EXPORT = 10
|
113
|
+
|
114
|
+
QUALITY_OPENGL_NO_SSAA = 0
|
115
|
+
QUALITY_OPENGL_2X_SSAA = 2
|
116
|
+
QUALITY_OPENGL_4X_SSAA = 4
|
117
|
+
QUALITY_OPENGL_8X_SSAA = 8
|
118
|
+
QUALITY_OPENGL_16X_SSAA = 16
|
119
|
+
QUALITY_POVRAY_NO_SSAA = 0 + 1
|
120
|
+
QUALITY_POVRAY_2X_SSAA = 2 + 1
|
121
|
+
QUALITY_POVRAY_4X_SSAA = 4 + 1
|
122
|
+
QUALITY_POVRAY_8X_SSAA = 8 + 1
|
123
|
+
QUALITY_POVRAY_16X_SSAA = 16 + 1
|
124
|
+
|
125
|
+
DRAWABLE_OPENGL = 1
|
126
|
+
DRAWABLE_GKS = 2
|
127
|
+
|
128
|
+
SURFACE_DEFAULT = 0
|
129
|
+
SURFACE_NORMALS = 1
|
130
|
+
SURFACE_FLAT = 2
|
131
|
+
SURFACE_GRTRANSFORM = 4
|
132
|
+
SURFACE_GRCOLOR = 8
|
133
|
+
SURFACE_GRZSHADED = 16
|
134
|
+
end
|
data/lib/gr3/ffi.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
|
5
|
+
module GR3
|
6
|
+
module FFI
|
7
|
+
extend ::FFI::Library
|
8
|
+
|
9
|
+
ffi_lib GR3.ffi_lib
|
10
|
+
|
11
|
+
extend GRCommons::AttachFunction
|
12
|
+
|
13
|
+
# gr3.c
|
14
|
+
|
15
|
+
attach_function :gr3_init, %i[int], :int
|
16
|
+
attach_function :gr3_geterror, %i[int pointer pointer], :int
|
17
|
+
attach_function :gr3_terminate, %i[], :void
|
18
|
+
attach_function :gr3_clear, %i[], :int
|
19
|
+
attach_function :gr3_usecurrentframebuffer, %i[], :void
|
20
|
+
attach_function :gr3_useframebuffer, %i[uint], :void
|
21
|
+
attach_function :gr3_setbackgroundcolor, %i[float float float float], :void
|
22
|
+
# getbackgroundcolor not implemented
|
23
|
+
attach_function :gr3_createmesh_nocopy, %i[pointer int pointer pointer pointer], :int
|
24
|
+
attach_function :gr3_createmesh, %i[pointer int pointer pointer pointer], :int
|
25
|
+
attach_function :gr3_createindexedmesh_nocopy, %i[pointer int pointer pointer pointer int pointer], :int
|
26
|
+
attach_function :gr3_createindexedmesh, %i[pointer int pointer pointer pointer int pointer], :int
|
27
|
+
attach_function :gr3_drawmesh, %i[int int pointer pointer pointer pointer pointer], :void
|
28
|
+
attach_function :gr3_deletemesh, %i[int], :void
|
29
|
+
attach_function :gr3_setlightdirection, %i[float float float], :void
|
30
|
+
attach_function :gr3_cameralookat, %i[float float float float float float float float float], :void
|
31
|
+
attach_function :gr3_setcameraprojectionparameters, %i[float float float], :int
|
32
|
+
attach_function :gr3_getcameraprojectionparameters, %i[pointer pointer pointer], :int
|
33
|
+
attach_function :gr3_drawimage, %i[float float float float int int int], :int
|
34
|
+
attach_function :gr3_setquality, %i[int], :int
|
35
|
+
attach_function :gr3_getimage, %i[int int int pointer], :int
|
36
|
+
attach_function :gr3_export, %i[pointer int int], :int
|
37
|
+
attach_function :gr3_free, %i[pointer], :void
|
38
|
+
# callback :gr3_log_func, %i[string], :void
|
39
|
+
# attach_function :gr3_setlogcallback, %i[:gr3_log_func], :void
|
40
|
+
attach_function :gr3_geterrorstring, %i[int], :string
|
41
|
+
attach_function :gr3_getrenderpathstring, %i[], :string
|
42
|
+
attach_function :gr3_setobjectid, %i[int], :void
|
43
|
+
attach_function :gr3_selectid, %i[int int int int pointer], :int
|
44
|
+
attach_function :gr3_getviewmatrix, %i[pointer], :void
|
45
|
+
# attach_function :gr3_setviewmatrix, %i[pointer], :void
|
46
|
+
attach_function :gr3_getprojectiontype, %i[], :int
|
47
|
+
attach_function :gr3_setprojectiontype, %i[int], :void
|
48
|
+
|
49
|
+
# gr3_gr.c
|
50
|
+
|
51
|
+
attach_function :gr3_createsurfacemesh, %i[pointer int int pointer pointer pointer int], :int
|
52
|
+
attach_function :gr3_drawmesh_grlike, %i[int int pointer pointer pointer pointer pointer], :void
|
53
|
+
attach_function :gr3_drawsurface, %i[int], :void
|
54
|
+
# attach_function gr3_surface, %i[int int pointer pointer pointer int], :void
|
55
|
+
# attach_function gr3_drawtrianglesurface, %i[int pointer], :void
|
56
|
+
# attach_function gr_volume, %i[int int int pointer int pointer pointer], :void
|
57
|
+
|
58
|
+
# gr3_convenience.c
|
59
|
+
|
60
|
+
attach_function :gr3_drawcubemesh, %i[int pointer pointer pointer pointer pointer], :void
|
61
|
+
attach_function :gr3_drawcylindermesh, %i[int pointer pointer pointer pointer pointer], :void
|
62
|
+
attach_function :gr3_drawconemesh, %i[int pointer pointer pointer pointer pointer], :void
|
63
|
+
attach_function :gr3_drawspheremesh, %i[int pointer pointer pointer], :void
|
64
|
+
attach_function :gr3_drawheightmap, %i[pointer int int pointer pointer], :void
|
65
|
+
attach_function :gr3_createheightmapmesh, %i[pointer int int], :void
|
66
|
+
# attach_function :gr3_createisosurfacemesh,
|
67
|
+
# %i[pointer pointer ushort uint uint uint uint uint uint double double double double double double], :int
|
68
|
+
attach_function :gr3_drawtubemesh, %i[int pointer pointer pointer int int], :int
|
69
|
+
# attach_function gr3_drawspins, %i[int pointer pointer pointer float float float float], :void
|
70
|
+
# attach_function gr3_drawmolecule, %i[int pointer pointer pointer float pointer float], :void
|
71
|
+
|
72
|
+
# gr3_slices.c
|
73
|
+
|
74
|
+
# attach_function gr3_createxslicemesh,
|
75
|
+
# %i[pointer pointer uint uint uint uint uint uint uint double double double double double double], :void
|
76
|
+
# attach_function gr3_createyslicemesh
|
77
|
+
# %i[pointer pointer uint uint uint uint uint uint uint double double double double double double], :void
|
78
|
+
# attach_function gr3_createzslicemesh
|
79
|
+
# %i[pointer pointer uint uint uint uint uint uint uint double double double double double double], :void
|
80
|
+
# attach_function gr3_drawxslicemesh
|
81
|
+
# %i[pointer uint uint uint uint uint uint uint double double double double double double], :void
|
82
|
+
# attach_function gr3_drawyslicemesh
|
83
|
+
# %i[pointer uint uint uint uint uint uint uint double double double double double double], :void
|
84
|
+
# attach_function gr3_drawzslicemesh
|
85
|
+
# %i[pointer uint uint uint uint uint uint uint double double double double double double], :void
|
86
|
+
|
87
|
+
# gr3_mc.c
|
88
|
+
|
89
|
+
# attach_function gr3_triangulateindexed
|
90
|
+
# %i[pointer ushort uint uint uint uint uint uint double double double double double double pointer pointer pointer pointer poiter], :void
|
91
|
+
# attach_function gr3_triangulate
|
92
|
+
# %i[pointer ushort uint uint uint uint uint uint double double double double double double pointer], :void
|
93
|
+
end
|
94
|
+
end
|
data/lib/gr3/gr3base.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GR3
|
4
|
+
module GR3Base
|
5
|
+
extend GRCommons::DefineMethods
|
6
|
+
define_ffi_methods(FFI,
|
7
|
+
prefix: 'gr3_',
|
8
|
+
default_type: :float)
|
9
|
+
|
10
|
+
def self.check_error
|
11
|
+
line = ::FFI::MemoryPointer.new(:int)
|
12
|
+
file = ::FFI::MemoryPointer.new(:string, 100)
|
13
|
+
e = FFI.gr3_geterror(1, line, file)
|
14
|
+
return if e == 0
|
15
|
+
|
16
|
+
mesg = FFI.gr3_geterrorstring(e)
|
17
|
+
raise "GR3 error #{file} #{line} #{mesg}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
private_constant :GR3Base
|
21
|
+
|
22
|
+
extend GRCommons::GRCommonUtils
|
23
|
+
end
|