Class: Floorplanner::AreaBuilder
- Inherits:
-
Geom::TriangleMesh
- Object
- Geom::TriangleMesh
- Floorplanner::AreaBuilder
- Defined in:
- lib/floorplanner/area_builder.rb
Instance Attribute Summary collapse
-
#ceiling_z ⇒ Object
readonly
Returns the value of attribute ceiling_z.
Attributes inherited from Geom::TriangleMesh
#data, #faces, #meshes, #tess, #texcoord, #vertices
Instance Method Summary collapse
- #area(vertices, params = nil) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(&block) ⇒ AreaBuilder
constructor
A new instance of AreaBuilder.
- #update(ceiling_z) ⇒ Object
- #vertex(p) ⇒ Object
Methods inherited from Geom::TriangleMesh
#<<, #bounding_box, #merge, #reverse, #transform_vertices
Constructor Details
#initialize(&block) ⇒ AreaBuilder
Returns a new instance of AreaBuilder.
6 7 8 9 10 |
# File 'lib/floorplanner/area_builder.rb', line 6 def initialize(&block) super() @meshes = {} block.call(self) end |
Instance Attribute Details
#ceiling_z ⇒ Object (readonly)
Returns the value of attribute ceiling_z.
4 5 6 |
# File 'lib/floorplanner/area_builder.rb', line 4 def ceiling_z @ceiling_z end |
Instance Method Details
#area(vertices, params = nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/floorplanner/area_builder.rb', line 24 def area(vertices, params=nil) a_id = vertices.hash.abs.to_s + "_" + params[:type].to_s params[:color] = Floorplanner.read_color params[:color] @meshes[a_id] = Geom::Polygon.new(vertices, nil, params.merge({:id => a_id})) end |
#each(&block) ⇒ Object
12 13 14 |
# File 'lib/floorplanner/area_builder.rb', line 12 def each(&block) @meshes.each_value{|a| block.call(a)} end |
#update(ceiling_z) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/floorplanner/area_builder.rb', line 30 def update(ceiling_z) @ceiling_z = ceiling_z @meshes.each do |id,mesh| mesh.update end end |
#vertex(p) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/floorplanner/area_builder.rb', line 16 def vertex(p) if existing = @vertices.index(p) @vertices[existing] else @vertices << p; p end end |