ruby-gr 0.0.2 → 0.0.3
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/lib/gr.rb +482 -47
- data/lib/gr/ffi.rb +10 -9
- data/lib/gr/version.rb +5 -0
- data/lib/gr3.rb +503 -7
- data/lib/gr3/ffi.rb +30 -23
- data/lib/gr3/version.rb +5 -0
- data/lib/gr_commons.rb +1 -0
- data/lib/gr_commons/attach_function.rb +1 -0
- data/lib/gr_commons/gr_common_utils.rb +26 -21
- data/lib/gr_commons/jupyter_support.rb +1 -2
- data/lib/gr_commons/version.rb +5 -0
- metadata +19 -2
data/lib/gr3/ffi.rb
CHANGED
@@ -8,7 +8,7 @@ module GR3
|
|
8
8
|
|
9
9
|
begin
|
10
10
|
ffi_lib GR3.ffi_lib
|
11
|
-
rescue LoadError
|
11
|
+
rescue LoadError
|
12
12
|
raise LoadError, 'Could not find GR Framework'
|
13
13
|
end
|
14
14
|
|
@@ -55,33 +55,40 @@ module GR3
|
|
55
55
|
attach_function :gr3_setviewmatrix, %i[pointer], :void
|
56
56
|
attach_function :gr3_getprojectiontype, %i[], :int
|
57
57
|
attach_function :gr3_setprojectiontype, %i[int], :void
|
58
|
-
# attach_function gr3_triangulate
|
58
|
+
# attach_function :gr3_triangulate,
|
59
59
|
# %i[pointer ushort uint uint uint uint uint uint double double double double double double pointer], :void
|
60
|
-
# attach_function gr3_triangulateindexed
|
60
|
+
# attach_function :gr3_triangulateindexed,
|
61
61
|
# %i[pointer ushort uint uint uint uint uint uint double double double double double double pointer pointer pointer pointer poiter], :void
|
62
|
-
|
63
|
-
|
62
|
+
attach_function :gr3_createisosurfacemesh,
|
63
|
+
%i[pointer pointer ushort uint uint uint uint uint uint double double double double double double],
|
64
|
+
:int
|
64
65
|
attach_function :gr3_createsurfacemesh, %i[pointer int int pointer pointer pointer int], :int
|
65
66
|
attach_function :gr3_drawmesh_grlike, %i[int int pointer pointer pointer pointer pointer], :void
|
66
67
|
attach_function :gr3_drawsurface, %i[int], :void
|
67
|
-
|
68
|
+
attach_function :gr3_surface, %i[int int pointer pointer pointer int], :void
|
68
69
|
attach_function :gr3_drawtubemesh, %i[int pointer pointer pointer int int], :int
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
70
|
+
attach_function :gr3_createtubemesh, %i[pointer int pointer pointer pointer int int], :int
|
71
|
+
attach_function :gr3_drawspins, %i[int pointer pointer pointer float float float float], :void
|
72
|
+
attach_function :gr3_drawmolecule, %i[int pointer pointer pointer float pointer float], :void
|
73
|
+
attach_function :gr3_createxslicemesh,
|
74
|
+
%i[pointer pointer uint uint uint uint uint uint uint double double double double double double],
|
75
|
+
:void
|
76
|
+
attach_function :gr3_createyslicemesh,
|
77
|
+
%i[pointer pointer uint uint uint uint uint uint uint double double double double double double],
|
78
|
+
:void
|
79
|
+
attach_function :gr3_createzslicemesh,
|
80
|
+
%i[pointer pointer uint uint uint uint uint uint uint double double double double double double],
|
81
|
+
:void
|
82
|
+
attach_function :gr3_drawxslicemesh,
|
83
|
+
%i[pointer uint uint uint uint uint uint uint double double double double double double],
|
84
|
+
:void
|
85
|
+
attach_function :gr3_drawyslicemesh,
|
86
|
+
%i[pointer uint uint uint uint uint uint uint double double double double double double],
|
87
|
+
:void
|
88
|
+
attach_function :gr3_drawzslicemesh,
|
89
|
+
%i[pointer uint uint uint uint uint uint uint double double double double double double],
|
90
|
+
:void
|
91
|
+
# attach_function :gr3_drawtrianglesurface, %i[int pointer], :void
|
92
|
+
attach_function :gr_volume, %i[int int int pointer int pointer pointer], :void
|
86
93
|
end
|
87
94
|
end
|
data/lib/gr3/version.rb
ADDED
data/lib/gr_commons.rb
CHANGED
@@ -5,44 +5,36 @@ module GRCommons
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def equal_length(*args)
|
8
|
-
lengths = args.map
|
8
|
+
lengths = args.map(&:length)
|
9
9
|
raise ArgumentError, 'Sequences must have same length.' unless lengths.all? { |l| l == lengths[0] }
|
10
10
|
|
11
11
|
lengths[0]
|
12
12
|
end
|
13
13
|
|
14
|
-
def length(pt, dtype = :double)
|
15
|
-
case pt
|
16
|
-
when Array
|
17
|
-
pt.size
|
18
|
-
when ->(x) { narray? x }
|
19
|
-
pt.size
|
20
|
-
when ::FFI::MemoryPointer
|
21
|
-
case dtype
|
22
|
-
when :int
|
23
|
-
pt.size / ::FFI::Type::INT.size
|
24
|
-
when :double
|
25
|
-
pt.size / ::FFI::Type::DOUBLE.size
|
26
|
-
else
|
27
|
-
raise "Unknown type: #{dtype}"
|
28
|
-
end
|
29
|
-
else
|
30
|
-
raise
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
14
|
def uint8(data)
|
35
15
|
data = data.to_a.flatten
|
36
16
|
pt = ::FFI::MemoryPointer.new(:uint8, data.size)
|
37
17
|
pt.write_array_of_uint8 data
|
38
18
|
end
|
39
19
|
|
20
|
+
def uint16(data)
|
21
|
+
data = data.to_a.flatten
|
22
|
+
pt = ::FFI::MemoryPointer.new(:uint16, data.size)
|
23
|
+
pt.write_array_of_uint16 data
|
24
|
+
end
|
25
|
+
|
40
26
|
def int(data)
|
41
27
|
data = data.to_a.flatten
|
42
28
|
pt = ::FFI::MemoryPointer.new(:int, data.size)
|
43
29
|
pt.write_array_of_int data
|
44
30
|
end
|
45
31
|
|
32
|
+
def uint(data)
|
33
|
+
data = data.to_a.flatten
|
34
|
+
pt = ::FFI::MemoryPointer.new(:uint, data.size)
|
35
|
+
pt.write_array_of_uint data
|
36
|
+
end
|
37
|
+
|
46
38
|
def double(data)
|
47
39
|
data = data.to_a.flatten
|
48
40
|
pt = ::FFI::MemoryPointer.new(:double, data.size)
|
@@ -63,6 +55,10 @@ module GRCommons
|
|
63
55
|
inquiry(:int, &block)
|
64
56
|
end
|
65
57
|
|
58
|
+
def inquiry_uint(&block)
|
59
|
+
inquiry(:uint, &block)
|
60
|
+
end
|
61
|
+
|
66
62
|
def inquiry_double(&block)
|
67
63
|
inquiry(:double, &block)
|
68
64
|
end
|
@@ -105,3 +101,12 @@ module GRCommons
|
|
105
101
|
end
|
106
102
|
end
|
107
103
|
end
|
104
|
+
|
105
|
+
# Ruby 2.4.0 introduces Comparable#clamp
|
106
|
+
if RUBY_VERSION.to_f <= 2.3
|
107
|
+
class Numeric
|
108
|
+
def clamp(min, max)
|
109
|
+
[[self, max].min, min].max
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-gr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: wavefile
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: GR framework - the graphics library for visualisation - for Ruby
|
112
126
|
email: 2xijok@gmail.com
|
113
127
|
executables: []
|
@@ -119,14 +133,17 @@ files:
|
|
119
133
|
- lib/gr.rb
|
120
134
|
- lib/gr/ffi.rb
|
121
135
|
- lib/gr/grbase.rb
|
136
|
+
- lib/gr/version.rb
|
122
137
|
- lib/gr3.rb
|
123
138
|
- lib/gr3/ffi.rb
|
124
139
|
- lib/gr3/gr3base.rb
|
140
|
+
- lib/gr3/version.rb
|
125
141
|
- lib/gr_commons.rb
|
126
142
|
- lib/gr_commons/attach_function.rb
|
127
143
|
- lib/gr_commons/define_methods.rb
|
128
144
|
- lib/gr_commons/gr_common_utils.rb
|
129
145
|
- lib/gr_commons/jupyter_support.rb
|
146
|
+
- lib/gr_commons/version.rb
|
130
147
|
homepage: https://github.com/kojix2/GR.rb
|
131
148
|
licenses:
|
132
149
|
- MIT
|