mersh 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ require 'json'
21
21
  require 'digest/md5'
22
22
 
23
23
  class Mersh
24
- VERSION = "0.0.1"
24
+ VERSION = "0.0.2"
25
25
  attr_accessor :vertices, :faces, :normals
26
26
 
27
27
  def initialize(file)
@@ -102,12 +102,12 @@ class Mersh
102
102
 
103
103
  stl_data = @file.read
104
104
 
105
- stl_data.gsub!(/^\s*solid.*$/, '')
106
- stl_data.gsub!(/^\s*facet normal /, '').gsub!(/^\s*outer loop.*$/, '')
107
- stl_data.gsub!(/^\s*vertex /, '')
108
- stl_data.gsub!(/^\s*endloop.*$/, '').gsub!(/^\s*endfacet.*$/, '')
109
- stl_data.gsub!(/^\s*endsolid.*$/, '')
110
- stl_data.gsub!(/^\s*$\n/, '')
105
+ stl_data.gsub!(/^\s*solid.*$/i, '')
106
+ stl_data.gsub!(/^\s*facet normal /i, '').gsub!(/^\s*outer loop.*$/i, '')
107
+ stl_data.gsub!(/^\s*vertex /i, '')
108
+ stl_data.gsub!(/^\s*endloop.*$/i, '').gsub!(/^\s*endfacet.*$/i, '')
109
+ stl_data.gsub!(/^\s*endsolid.*$/i, '')
110
+ stl_data.gsub!(/^\s*$\n/i, '')
111
111
 
112
112
  stl_data.split("\n").each do |line|
113
113
  line_pos = 1 if line_pos > 4
@@ -0,0 +1,86 @@
1
+ SOLID Untitled1
2
+ FACET NORMAL 0.00000000E+00 0.00000000E+00 1.00000000E+00
3
+ OUTER LOOP
4
+ VERTEX -1.96850394E+00 1.96850394E+00 1.96850394E+00
5
+ VERTEX -1.96850394E+00 -1.96850394E+00 1.96850394E+00
6
+ VERTEX 1.96850394E+00 -1.96850394E+00 1.96850394E+00
7
+ ENDLOOP
8
+ ENDFACET
9
+ FACET NORMAL 0.00000000E+00 -0.00000000E+00 1.00000000E+00
10
+ OUTER LOOP
11
+ VERTEX 1.96850394E+00 -1.96850394E+00 1.96850394E+00
12
+ VERTEX 1.96850394E+00 1.96850394E+00 1.96850394E+00
13
+ VERTEX -1.96850394E+00 1.96850394E+00 1.96850394E+00
14
+ ENDLOOP
15
+ ENDFACET
16
+ FACET NORMAL 0.00000000E+00 -0.00000000E+00 -1.00000000E+00
17
+ OUTER LOOP
18
+ VERTEX 1.96850394E+00 1.96850394E+00 -1.96850394E+00
19
+ VERTEX 1.96850394E+00 -1.96850394E+00 -1.96850394E+00
20
+ VERTEX -1.96850394E+00 -1.96850394E+00 -1.96850394E+00
21
+ ENDLOOP
22
+ ENDFACET
23
+ FACET NORMAL 0.00000000E+00 0.00000000E+00 -1.00000000E+00
24
+ OUTER LOOP
25
+ VERTEX -1.96850394E+00 -1.96850394E+00 -1.96850394E+00
26
+ VERTEX -1.96850394E+00 1.96850394E+00 -1.96850394E+00
27
+ VERTEX 1.96850394E+00 1.96850394E+00 -1.96850394E+00
28
+ ENDLOOP
29
+ ENDFACET
30
+ FACET NORMAL -1.00000000E+00 0.00000000E+00 0.00000000E+00
31
+ OUTER LOOP
32
+ VERTEX -1.96850394E+00 1.96850394E+00 -1.96850394E+00
33
+ VERTEX -1.96850394E+00 -1.96850394E+00 -1.96850394E+00
34
+ VERTEX -1.96850394E+00 -1.96850394E+00 1.96850394E+00
35
+ ENDLOOP
36
+ ENDFACET
37
+ FACET NORMAL -1.00000000E+00 0.00000000E+00 0.00000000E+00
38
+ OUTER LOOP
39
+ VERTEX -1.96850394E+00 -1.96850394E+00 1.96850394E+00
40
+ VERTEX -1.96850394E+00 1.96850394E+00 1.96850394E+00
41
+ VERTEX -1.96850394E+00 1.96850394E+00 -1.96850394E+00
42
+ ENDLOOP
43
+ ENDFACET
44
+ FACET NORMAL 1.00000000E+00 0.00000000E+00 0.00000000E+00
45
+ OUTER LOOP
46
+ VERTEX 1.96850394E+00 1.96850394E+00 1.96850394E+00
47
+ VERTEX 1.96850394E+00 -1.96850394E+00 1.96850394E+00
48
+ VERTEX 1.96850394E+00 -1.96850394E+00 -1.96850394E+00
49
+ ENDLOOP
50
+ ENDFACET
51
+ FACET NORMAL 1.00000000E+00 0.00000000E+00 0.00000000E+00
52
+ OUTER LOOP
53
+ VERTEX 1.96850394E+00 -1.96850394E+00 -1.96850394E+00
54
+ VERTEX 1.96850394E+00 1.96850394E+00 -1.96850394E+00
55
+ VERTEX 1.96850394E+00 1.96850394E+00 1.96850394E+00
56
+ ENDLOOP
57
+ ENDFACET
58
+ FACET NORMAL 0.00000000E+00 -1.00000000E+00 0.00000000E+00
59
+ OUTER LOOP
60
+ VERTEX -1.96850394E+00 -1.96850394E+00 1.96850394E+00
61
+ VERTEX -1.96850394E+00 -1.96850394E+00 -1.96850394E+00
62
+ VERTEX 1.96850394E+00 -1.96850394E+00 -1.96850394E+00
63
+ ENDLOOP
64
+ ENDFACET
65
+ FACET NORMAL 0.00000000E+00 -1.00000000E+00 0.00000000E+00
66
+ OUTER LOOP
67
+ VERTEX 1.96850394E+00 -1.96850394E+00 -1.96850394E+00
68
+ VERTEX 1.96850394E+00 -1.96850394E+00 1.96850394E+00
69
+ VERTEX -1.96850394E+00 -1.96850394E+00 1.96850394E+00
70
+ ENDLOOP
71
+ ENDFACET
72
+ FACET NORMAL 0.00000000E+00 1.00000000E+00 0.00000000E+00
73
+ OUTER LOOP
74
+ VERTEX -1.96850394E+00 1.96850394E+00 -1.96850394E+00
75
+ VERTEX -1.96850394E+00 1.96850394E+00 1.96850394E+00
76
+ VERTEX 1.96850394E+00 1.96850394E+00 1.96850394E+00
77
+ ENDLOOP
78
+ ENDFACET
79
+ FACET NORMAL 0.00000000E+00 1.00000000E+00 0.00000000E+00
80
+ OUTER LOOP
81
+ VERTEX 1.96850394E+00 1.96850394E+00 1.96850394E+00
82
+ VERTEX 1.96850394E+00 1.96850394E+00 -1.96850394E+00
83
+ VERTEX -1.96850394E+00 1.96850394E+00 -1.96850394E+00
84
+ ENDLOOP
85
+ ENDFACET
86
+ ENDSOLID Untitled1
@@ -8,6 +8,7 @@ class MershTest < Test::Unit::TestCase
8
8
  @binary_stl = @current_dir + "/box_binary.stl"
9
9
  @threejs_json = @current_dir + "/box_threejs.json"
10
10
  @plain_json = @current_dir + "/box_plain.json"
11
+ @capitalized_ascii_stl = @current_dir + "/capitalized_ascii.stl"
11
12
  end
12
13
 
13
14
  def test_ascii_stl
@@ -48,4 +49,10 @@ class MershTest < Test::Unit::TestCase
48
49
  assert_equal 12, box.faces.size
49
50
  assert_equal 12, box.normals.size
50
51
  end
52
+
53
+ def test_capitalized_ascii_stl
54
+ stl = Mersh.new(@capitalized_ascii_stl)
55
+
56
+ assert stl.vertices.size > 0
57
+ end
51
58
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mersh
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Buser
@@ -46,6 +46,7 @@ files:
46
46
  - test/box_binary.stl
47
47
  - test/box_plain.json
48
48
  - test/box_threejs.json
49
+ - test/capitalized_ascii.stl
49
50
  - test/test_mersh.rb
50
51
  - LICENSE
51
52
  - README.rdoc