Class: JennCad::Primitives::Polyhedron
- Defined in:
- lib/jenncad/primitives/polyhedron.rb
Instance Attribute Summary collapse
-
#convexity ⇒ Object
Returns the value of attribute convexity.
-
#faces ⇒ Object
Returns the value of attribute faces.
-
#points ⇒ Object
Returns the value of attribute points.
Attributes inherited from Primitive
Attributes inherited from Thing
#anchors, #angle, #calc_h, #calc_x, #calc_y, #calc_z, #csize, #diameter, #fn, #name, #opts, #parent, #parts, #pos, #shape, #sits_on, #transformations, #x, #y
Instance Method Summary collapse
- #face(i) ⇒ Object
-
#initialize(args) ⇒ Polyhedron
constructor
A new instance of Polyhedron.
Methods inherited from Primitive
#feed_opts, #handle_diameter, #handle_margins
Methods inherited from Thing
#anchor, #at, #auto_color, #auto_color!, #auto_extrude, #calculate_center_rotation, #calculated_h, #children_list, #color, #color_or_fallback, #color_parse, #copy_anchor, #copy_anchors, #cut_to, #dbg, #debug?, #find_calculated_h, #fixate, #flip, #flipc, #get_children, #get_contents, #ghost, #has_explicit_color?, #hide, #hl, #inherit_color, #init, #is_2d?, #is_3d?, #mhx, #mhy, #mhz, #mirror, #mix, #miy, #miz, #modify_values, #modify_values!, #move, #movea, #moveai, #moveh, #movei, #multmatrix, #mx, #my, #mz, #on_top_of, #only, #only_color?, #openscad, #openscad_modifier, #option, #parse_xyz_shortcuts, #radians, #referenced_z, #reset, #reset_last_move, #rotate, #rotate_around, #rx, #ry, #rz, #scale, #set_anchor, #set_anchor_from, #set_auto_color, #set_auto_color_for_children, #set_flag, #set_heights_for_auto_extrude, #set_option, #set_parent, #skew, #to_mod, #top_of, #transform, #unset_flag, #z, #z=, #z_margin
Constructor Details
#initialize(args) ⇒ Polyhedron
Returns a new instance of Polyhedron.
4 5 6 7 8 9 10 11 |
# File 'lib/jenncad/primitives/polyhedron.rb', line 4 def initialize(args) @opts = args @points = args[:points] @faces = args[:faces] @convexity = args[:convexity] || 10 super end |
Instance Attribute Details
#convexity ⇒ Object
Returns the value of attribute convexity.
3 4 5 |
# File 'lib/jenncad/primitives/polyhedron.rb', line 3 def convexity @convexity end |
#faces ⇒ Object
Returns the value of attribute faces.
3 4 5 |
# File 'lib/jenncad/primitives/polyhedron.rb', line 3 def faces @faces end |
#points ⇒ Object
Returns the value of attribute points.
3 4 5 |
# File 'lib/jenncad/primitives/polyhedron.rb', line 3 def points @points end |
Instance Method Details
#face(i) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/jenncad/primitives/polyhedron.rb', line 13 def face(i) unless @faces[i] $log.error "polyhedron: Cannot find face #{i}" return self end face = 0 poly_faces = [] poly_points = [] @faces[i].each do |f| point = @points[f] if point.nil? $log.error "polyhedron: Cannot find point #{f} for face #{i}" end poly_points << point poly_faces << face face += 1 #poly_points << [point[0], point[1]] end #polygon(points: poly_points) polyhedron(points: poly_points, faces: [poly_faces, poly_faces.reverse]) end |