Class: Siren::Shape

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

Overview

Shape クラス拡張メソッド

Instance Method Summary collapse

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

Returns:

  • (Boolean)


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_compoundObject



109
110
111
# File 'lib/shape.rb', line 109

def dump_compound
  self.dump_tree{|depth, child| child.compound?}
end

#dump_edgeObject



129
130
131
# File 'lib/shape.rb', line 129

def dump_edge
  self.dump_tree{|depth, child| child.edge?}
end

#dump_faceObject



121
122
123
# File 'lib/shape.rb', line 121

def dump_face
  self.dump_tree{|depth, child| child.face?}
end

#dump_shellObject



117
118
119
# File 'lib/shape.rb', line 117

def dump_shell
  self.dump_tree{|depth, child| child.sell?}
end

#dump_solidObject



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_vertexObject



133
134
135
# File 'lib/shape.rb', line 133

def dump_vertex
  self.dump_tree{|depth, child| child.vertex?}
end

#dump_wireObject



125
126
127
# File 'lib/shape.rb', line 125

def dump_wire
  self.dump_tree{|depth, child| child.wire?}
end

#edge?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/shape.rb', line 86

def edge?
  self.is_a? Siren::Edge
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

#face?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/shape.rb', line 78

def face?
  self.is_a? Siren::Face
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

#shell?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/shape.rb', line 74

def shell?
  self.is_a? Siren::Shell
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

#solid?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/shape.rb', line 70

def solid?
  self.is_a? Siren::Solid
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_aObject



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

#vertex?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/shape.rb', line 90

def vertex?
  self.is_a? Siren::Vertex
end

#vertices(filter = nil) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/shape.rb', line 56

def vertices(filter = nil)
  if filter.nil?
    self.explore(Siren::Vertex)
  else
    self.explore(Siren::Vertex, filter)
  end
end

#wire?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/shape.rb', line 82

def wire?
  self.is_a? Siren::Wire
end

#wires(filter = nil) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/shape.rb', line 40

def wires(filter = nil)
  if filter.nil?
    self.explore(Siren::Wire)
  else
    self.explore(Siren::Wire, filter)
  end
end