Class: Disp3D::STL
- Inherits:
-
Object
- Object
- Disp3D::STL
- Defined in:
- lib/stl.rb
Constant Summary collapse
- ASCII =
0
- BINARY =
1
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#normals ⇒ Object
readonly
Returns the value of attribute normals.
-
#tris ⇒ Object
readonly
Returns the value of attribute tris.
Instance Method Summary collapse
-
#initialize(triangles = nil) ⇒ STL
constructor
A new instance of STL.
-
#parse(file_path, type = BINARY) ⇒ Object
return true if success processing.
- #tri_mesh ⇒ Object
Constructor Details
#initialize(triangles = nil) ⇒ STL
Returns a new instance of STL.
12 13 14 15 16 |
# File 'lib/stl.rb', line 12 def initialize(triangles = nil) @tris = triangles @normals = nil @name = "" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/stl.rb', line 7 def name @name end |
#normals ⇒ Object (readonly)
Returns the value of attribute normals.
6 7 8 |
# File 'lib/stl.rb', line 6 def normals @normals end |
#tris ⇒ Object (readonly)
Returns the value of attribute tris.
5 6 7 |
# File 'lib/stl.rb', line 5 def tris @tris end |
Instance Method Details
#parse(file_path, type = BINARY) ⇒ Object
return true if success processing.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/stl.rb', line 19 def parse(file_path, type =BINARY ) return false if(!FileTest.exist?(file_path)) if(type == ASCII) return parse_ascii(file_path) elsif(type == BINARY) return parse_binary(file_path) end @tris = nil return false end |
#tri_mesh ⇒ Object
31 32 33 34 |
# File 'lib/stl.rb', line 31 def tri_mesh return nil if(!@tris) return GMath3D::TriMesh.from_triangles(@tris) end |