Class: Disp3D::STL

Inherits:
Object
  • Object
show all
Defined in:
lib/stl.rb

Constant Summary collapse

ASCII =
0
BINARY =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/stl.rb', line 7

def name
  @name
end

#normalsObject (readonly)

Returns the value of attribute normals.



6
7
8
# File 'lib/stl.rb', line 6

def normals
  @normals
end

#trisObject (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_meshObject



31
32
33
34
# File 'lib/stl.rb', line 31

def tri_mesh
  return nil if(!@tris)
  return GMath3D::TriMesh.from_triangles(@tris)
end