Class: Siren::Shape
- Inherits:
-
Object
- Object
- Siren::Shape
- Defined in:
- lib/shape.rb
Overview
Shape クラス拡張メソッド
Instance Method Summary collapse
- #clone(copy_geom = true) ⇒ Object
-
#compound? ⇒ Boolean
Type check methods.
-
#compounds(filter = nil) ⇒ Object
Explorer wrapper methods.
- #dump_compound ⇒ Object
- #dump_edge ⇒ Object
- #dump_face ⇒ Object
- #dump_shell ⇒ Object
- #dump_solid ⇒ Object
- #dump_tree(current_depth = 0, &limit) ⇒ Object
- #dump_vertex ⇒ Object
- #dump_wire ⇒ Object
- #edge? ⇒ Boolean
- #edges(filter = nil) ⇒ Object
- #face? ⇒ Boolean
- #faces(filter = nil) ⇒ Object
- #shell? ⇒ Boolean
- #shells(filter = nil) ⇒ Object
- #solid? ⇒ Boolean
- #solids(filter = nil) ⇒ Object
- #to_a ⇒ Object
- #vertex? ⇒ Boolean
- #vertices(filter = nil) ⇒ Object
- #wire? ⇒ Boolean
- #wires(filter = nil) ⇒ Object
Instance Method Details
#clone(copy_geom = true) ⇒ Object
137 138 139 |
# File 'lib/shape.rb', line 137 def clone(copy_geom = true) Siren.copy(self, copy_geom) end |
#compound? ⇒ Boolean
Type check methods
66 67 68 |
# File 'lib/shape.rb', line 66 def compound? self.is_a? Siren::Compound end |
#compounds(filter = nil) ⇒ Object
Explorer wrapper methods
8 9 10 11 12 13 14 |
# File 'lib/shape.rb', line 8 def compounds(filter = nil) if filter.nil? self.explore(Siren::Compound) else self.explore(Siren::Compound, filter) end end |
#dump_compound ⇒ Object
109 110 111 |
# File 'lib/shape.rb', line 109 def dump_compound self.dump_tree{|depth, child| child.compound?} end |
#dump_edge ⇒ Object
129 130 131 |
# File 'lib/shape.rb', line 129 def dump_edge self.dump_tree{|depth, child| child.edge?} end |
#dump_face ⇒ Object
121 122 123 |
# File 'lib/shape.rb', line 121 def dump_face self.dump_tree{|depth, child| child.face?} end |
#dump_shell ⇒ Object
117 118 119 |
# File 'lib/shape.rb', line 117 def dump_shell self.dump_tree{|depth, child| child.sell?} end |
#dump_solid ⇒ Object
113 114 115 |
# File 'lib/shape.rb', line 113 def dump_solid self.dump_tree{|depth, child| child.solid?} end |
#dump_tree(current_depth = 0, &limit) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/shape.rb', line 94 def dump_tree(current_depth = 0, &limit) hc = sprintf("%06X", self.hashcode(0xFFFFFF)) type = self.class.to_s puts " " * current_depth + "%s:0x%s" % [type, hc] if limit && limit.call(current_depth, self) # puts " " * current_depth + "..." return end current_depth += 1 self.subshapes.each do |s| s.dump_tree(current_depth, &limit) end nil end |
#dump_vertex ⇒ Object
133 134 135 |
# File 'lib/shape.rb', line 133 def dump_vertex self.dump_tree{|depth, child| child.vertex?} end |
#dump_wire ⇒ Object
125 126 127 |
# File 'lib/shape.rb', line 125 def dump_wire self.dump_tree{|depth, child| child.wire?} end |
#edges(filter = nil) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/shape.rb', line 48 def edges(filter = nil) if filter.nil? self.explore(Siren::Edge) else self.explore(Siren::Edge, filter) end end |
#faces(filter = nil) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/shape.rb', line 32 def faces(filter = nil) if filter.nil? self.explore(Siren::Face) else self.explore(Siren::Face, filter) end end |
#shells(filter = nil) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/shape.rb', line 24 def shells(filter = nil) if filter.nil? self.explore(Siren::Shell) else self.explore(Siren::Shell, filter) end end |
#solids(filter = nil) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/shape.rb', line 16 def solids(filter = nil) if filter.nil? self.explore(Siren::Solid) else self.explore(Siren::Solid, filter) end end |
#to_a ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/shape.rb', line 141 def to_a if self.compound? ar = [] self.subshapes.each do |s| if s.compound? ar << s.to_a else ar.push s end end return ar else return [self] end end |