crystalcell 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +7 -1
- data/Gemfile +2 -2
- data/VERSION +1 -1
- data/crystalcell.gemspec +17 -10
- data/lib/crystalcell/cell.rb +8 -3
- data/lib/crystalcell/povray/camera.rb +47 -23
- data/lib/crystalcell/povray/cell.rb +47 -39
- data/lib/crystalcell/povray/color.rb +42 -0
- data/lib/crystalcell/povray/cylinder.rb +15 -5
- data/lib/crystalcell/povray/sphere.rb +4 -0
- data/lib/crystalcell/povray/tetrahedron.rb +34 -0
- data/lib/crystalcell/povray/triangle.rb +24 -8
- data/lib/crystalcell/povray.rb +189 -1
- data/test/povray/test_camera.rb +178 -42
- data/test/povray/test_cell.rb +38 -38
- data/test/povray/test_colors.rb +106 -0
- data/test/povray/test_cylinder.rb +29 -0
- data/test/povray/test_tetrahedron.rb +47 -0
- data/test/povray/test_triangle.rb +41 -0
- data/test/test_cell.rb +9 -4
- data/test/test_povray.rb +104 -0
- metadata +13 -6
@@ -0,0 +1,29 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "pp"
|
5
|
+
require "helper"
|
6
|
+
#require "test/unit"
|
7
|
+
#require "pkg/klass.rb"
|
8
|
+
|
9
|
+
class TC_Cylinder < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@c00 = CrystalCell::Povray::Cylinder.new([1.0, 2.0, 3.0], [4.0, 6.0, 8.0], 0.5 , [0.25, 0.5, 0.75])
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_initialize
|
15
|
+
assert_equal(Mageo::Vector3D[1.0, 2.0, 3.0], @c00.positions[0])
|
16
|
+
assert_equal(Mageo::Vector3D[4.0, 6.0, 8.0], @c00.positions[1])
|
17
|
+
assert_equal([0.25, 0.5, 0.75], @c00.color)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_to_pov
|
21
|
+
assert_equal(
|
22
|
+
"object { cylinder{ < 1.0000, 2.0000, 3.0000>, < 4.0000, 6.0000, 8.0000>, 0.5000 } pigment { color rgb <0.25, 0.50, 0.75> } }",
|
23
|
+
@c00.to_pov
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "pp"
|
5
|
+
require "helper"
|
6
|
+
#require "test/unit"
|
7
|
+
#require "pkg/klass.rb"
|
8
|
+
|
9
|
+
class TC_Tetrahedron < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@t00 = CrystalCell::Povray::Tetrahedron.new(
|
12
|
+
[0.0, 0.0, 0.0],
|
13
|
+
[1.0, 1.0, 0.0],
|
14
|
+
[0.0, 1.0, 1.0],
|
15
|
+
[1.0, 0.0, 1.0],
|
16
|
+
[0.25, 0.5, 0.75])
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_to_pov
|
20
|
+
#VERTEX_INDICES_OF_TRIANGLES = [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 0 ], [ 3, 0, 1 ] ]
|
21
|
+
correct = [
|
22
|
+
"triangle{<0.000000,0.000000,0.000000>,<1.000000,1.000000,0.000000>,<0.000000,1.000000,1.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
|
23
|
+
"triangle{<1.000000,1.000000,0.000000>,<0.000000,1.000000,1.000000>,<1.000000,0.000000,1.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
|
24
|
+
"triangle{<0.000000,1.000000,1.000000>,<1.000000,0.000000,1.000000>,<0.000000,0.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
|
25
|
+
"triangle{<1.000000,0.000000,1.000000>,<0.000000,0.000000,0.000000>,<1.000000,1.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
|
26
|
+
].join("\n")
|
27
|
+
assert_equal(
|
28
|
+
correct,
|
29
|
+
@t00.to_pov
|
30
|
+
)
|
31
|
+
|
32
|
+
@t00.transmit = 0.5
|
33
|
+
correct = [
|
34
|
+
"triangle{<0.000000,0.000000,0.000000>,<1.000000,1.000000,0.000000>,<0.000000,1.000000,1.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
|
35
|
+
"triangle{<1.000000,1.000000,0.000000>,<0.000000,1.000000,1.000000>,<1.000000,0.000000,1.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
|
36
|
+
"triangle{<0.000000,1.000000,1.000000>,<1.000000,0.000000,1.000000>,<0.000000,0.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
|
37
|
+
"triangle{<1.000000,0.000000,1.000000>,<0.000000,0.000000,0.000000>,<1.000000,1.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
|
38
|
+
].join("\n")
|
39
|
+
assert_equal(
|
40
|
+
correct,
|
41
|
+
@t00.to_pov
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "pp"
|
5
|
+
require "helper"
|
6
|
+
#require "test/unit"
|
7
|
+
#require "pkg/klass.rb"
|
8
|
+
|
9
|
+
class TC_Triangle < Test::Unit::TestCase
|
10
|
+
$tolerance = 10.0 ** (-10)
|
11
|
+
|
12
|
+
#VEC_O = Mageo::Vector3D[0.0, 0.0, 0.0]
|
13
|
+
#VEC_X = Mageo::Vector3D[1.0, 0.0, 0.0]
|
14
|
+
#VEC_Y = Mageo::Vector3D[0.0, 1.0, 0.0]
|
15
|
+
#VEC_Z = Mageo::Vector3D[0.0, 0.0, 1.0]
|
16
|
+
|
17
|
+
def setup
|
18
|
+
@t00 = CrystalCell::Povray::Triangle.new(
|
19
|
+
[0.0, 0.0, 0.0],
|
20
|
+
[1.0, 0.0, 0.0],
|
21
|
+
[0.0, 1.0, 0.0],
|
22
|
+
[0.25, 0.5, 0.75]
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_to_pov
|
27
|
+
assert_equal(
|
28
|
+
"triangle{<0.000000,0.000000,0.000000>,<1.000000,0.000000,0.000000>,<0.000000,1.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000>}}",
|
29
|
+
@t00.to_pov
|
30
|
+
)
|
31
|
+
|
32
|
+
@t00.transmit = 0.5
|
33
|
+
assert_equal(
|
34
|
+
"triangle{<0.000000,0.000000,0.000000>,<1.000000,0.000000,0.000000>,<0.000000,1.000000,0.000000> pigment {color rgb<0.250000,0.500000,0.750000> transmit 0.500000}}",
|
35
|
+
@t00.to_pov
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
data/test/test_cell.rb
CHANGED
@@ -1549,8 +1549,13 @@ class TC_Cell < Test::Unit::TestCase
|
|
1549
1549
|
assert_in_delta(0.0, result[0][2], $tolerance)
|
1550
1550
|
end
|
1551
1551
|
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1552
|
+
def test_to_povcell
|
1553
|
+
povcell = @c01.to_povcell
|
1554
|
+
assert_equal(CrystalCell::Povray::Cell, povcell.class)
|
1555
|
+
assert_equal(
|
1556
|
+
CrystalCell::LatticeAxes.new(
|
1557
|
+
[[2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0]]),
|
1558
|
+
povcell.axes
|
1559
|
+
)
|
1560
|
+
end
|
1556
1561
|
end
|
data/test/test_povray.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "pp"
|
5
|
+
require "helper"
|
6
|
+
#require "test/unit"
|
7
|
+
#require "pkg/klass.rb"
|
8
|
+
#
|
9
|
+
|
10
|
+
class TC_Povray < Test::Unit::TestCase
|
11
|
+
TOLERANCE = 1.0E-10
|
12
|
+
|
13
|
+
def setup
|
14
|
+
atoms = [
|
15
|
+
CrystalCell::Atom.new( 'Li', [0.0, 0.0, 0.0] ),
|
16
|
+
CrystalCell::Atom.new( 'O' , [0.2, 0.2, 0.2] ),
|
17
|
+
]
|
18
|
+
cell = CrystalCell::Cell.new(
|
19
|
+
[[2.0, 2.0, 2.0], [0.0, 2.0, 2.0], [0.0, 0.0, 2.0]],
|
20
|
+
atoms)
|
21
|
+
cell.comment = 'c02'
|
22
|
+
|
23
|
+
@p00 = CrystalCell::Povray.new(cell: cell)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_initialize
|
27
|
+
## look_at
|
28
|
+
assert_in_delta( 1.0, @p00.camera.look_at[0], TOLERANCE)
|
29
|
+
assert_in_delta( 2.0, @p00.camera.look_at[1], TOLERANCE)
|
30
|
+
assert_in_delta( 3.0, @p00.camera.look_at[2], TOLERANCE)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_camera_location
|
34
|
+
## look_at
|
35
|
+
@p00.camera_location([ 1.2, 2.3, 3.4])
|
36
|
+
assert_in_delta(2.2 , @p00.camera.location[0], TOLERANCE)
|
37
|
+
assert_in_delta(4.3 , @p00.camera.location[1], TOLERANCE)
|
38
|
+
assert_in_delta(6.4 , @p00.camera.location[2], TOLERANCE)
|
39
|
+
|
40
|
+
setup
|
41
|
+
@p00.camera.look_at = [0.1, 2.3, 3.4]
|
42
|
+
@p00.camera_location([ 1.2, 2.3, 3.4])
|
43
|
+
assert_in_delta(1.3 , @p00.camera.location[0], TOLERANCE)
|
44
|
+
assert_in_delta(4.6 , @p00.camera.location[1], TOLERANCE)
|
45
|
+
assert_in_delta(6.8 , @p00.camera.location[2], TOLERANCE)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_camera_location_polar
|
49
|
+
## look_at
|
50
|
+
@p00.camera_location_polar( 6.0, 0.0, 0.0)
|
51
|
+
assert_in_delta(1.0 , @p00.camera.location[0], TOLERANCE)
|
52
|
+
assert_in_delta(2.0 , @p00.camera.location[1], TOLERANCE)
|
53
|
+
assert_in_delta(9.0 , @p00.camera.location[2], TOLERANCE)
|
54
|
+
|
55
|
+
@p00.camera_location_polar( 6.0, 90.0, 0.0)
|
56
|
+
assert_in_delta(7.0 , @p00.camera.location[0], TOLERANCE)
|
57
|
+
assert_in_delta(2.0 , @p00.camera.location[1], TOLERANCE)
|
58
|
+
assert_in_delta(3.0 , @p00.camera.location[2], TOLERANCE)
|
59
|
+
|
60
|
+
@p00.camera_location_polar( 6.0, 90.0, 90.0)
|
61
|
+
assert_in_delta(1.0 , @p00.camera.location[0], TOLERANCE)
|
62
|
+
assert_in_delta(8.0 , @p00.camera.location[1], TOLERANCE)
|
63
|
+
assert_in_delta(3.0 , @p00.camera.location[2], TOLERANCE)
|
64
|
+
|
65
|
+
#setup
|
66
|
+
#@p00.camera.look_at = [0.1, 2.3, 3.4]
|
67
|
+
#@p00.camera_location_polar()
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_shoot_snap
|
71
|
+
#basename = 'test/povray/tmp'
|
72
|
+
#povfile = basename + '.pov'
|
73
|
+
#pngfile = basename + '.png'
|
74
|
+
|
75
|
+
#FileUtils.rm povfile if File.exist? povfile
|
76
|
+
#FileUtils.rm pngfile if File.exist? pngfile
|
77
|
+
|
78
|
+
#@p00.shoot_snap(basename)
|
79
|
+
|
80
|
+
##FileUtils.rm povfile if File.exist? povfile
|
81
|
+
##FileUtils.rm pngfile if File.exist? pngfile
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_shoot_4in1
|
85
|
+
#basename = 'test/povray/tmp'
|
86
|
+
#@p00.shoot_4in1(basename)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_dump
|
90
|
+
#io = StringIO.new
|
91
|
+
#@p00.dump(io)
|
92
|
+
#io.rewind
|
93
|
+
#puts io.read
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_set_axes
|
97
|
+
assert_equal(nil, @p00.axes)
|
98
|
+
@p00.set_axes([-1.0, -1.0, 0.0])
|
99
|
+
#assert_equal(false, @p00.axes)
|
100
|
+
@p00.axes
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crystalcell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ippei94da
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0.
|
103
|
+
version: '0.1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0.
|
110
|
+
version: '0.1'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: maset
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,20 +162,27 @@ files:
|
|
162
162
|
- lib/crystalcell/povray.rb
|
163
163
|
- lib/crystalcell/povray/camera.rb
|
164
164
|
- lib/crystalcell/povray/cell.rb
|
165
|
+
- lib/crystalcell/povray/color.rb
|
165
166
|
- lib/crystalcell/povray/cylinder.rb
|
166
167
|
- lib/crystalcell/povray/element.rb
|
167
168
|
- lib/crystalcell/povray/sphere.rb
|
169
|
+
- lib/crystalcell/povray/tetrahedron.rb
|
168
170
|
- lib/crystalcell/povray/triangle.rb
|
169
171
|
- test/cif/ZrO2-25C.cif
|
170
172
|
- test/helper.rb
|
171
173
|
- test/povray/test_camera.rb
|
172
174
|
- test/povray/test_cell.rb
|
175
|
+
- test/povray/test_colors.rb
|
176
|
+
- test/povray/test_cylinder.rb
|
173
177
|
- test/povray/test_element.rb
|
178
|
+
- test/povray/test_tetrahedron.rb
|
179
|
+
- test/povray/test_triangle.rb
|
174
180
|
- test/test_atom.rb
|
175
181
|
- test/test_cell.rb
|
176
182
|
- test/test_element.rb
|
177
183
|
- test/test_latticeaxes.rb
|
178
184
|
- test/test_periodiccell.rb
|
185
|
+
- test/test_povray.rb
|
179
186
|
homepage: http://github.com/ippei94da/crystalcell
|
180
187
|
licenses:
|
181
188
|
- MIT
|