Class: Floorplanner::Design
- Inherits:
-
Object
- Object
- Floorplanner::Design
- Includes:
- ColladaExport, SvgExport
- Defined in:
- lib/floorplanner/design.rb
Constant Summary
Constants included from ColladaExport
Instance Method Summary collapse
-
#build_geometries ⇒ Object
Builds geometries of walls and areas.
-
#initialize(doc) ⇒ Design
constructor
Constructs new floorplan design from FML.
Methods included from SvgExport
Methods included from ColladaExport
#assets, #objects, #save_textures, #to_dae
Constructor Details
#initialize(doc) ⇒ Design
Constructs new floorplan design from FML
10 11 12 |
# File 'lib/floorplanner/design.rb', line 10 def initialize(doc) @doc = doc end |
Instance Method Details
#build_geometries ⇒ Object
Builds geometries of walls and areas.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/floorplanner/design.rb', line 17 def build_geometries @areas = AreaBuilder.new do |b| @doc.areas.each do |area| if area.asset texture_url = @doc.asset(area.asset).url2d end b.area(area.vertices, :color => area.color, :name => area.name, :texture => texture_url, :type => area.type) end end heights = Hash.new @walls = WallBuilder.new do |b| @doc.lines.select{|l| l.type == :default_wall}.each do |line| sp = b.vertex(line.vertices[0]) ep = b.vertex(line.vertices[1]) b.wall(sp, ep, line.thickness, line.height) if heights.include?(line.height) heights[line.height] += 1 else heights[line.height] = 1 end end end # get the most used (common) height accross linears @areas.update(heights.sort{|a,b| a[1]<=>b[1]}.last[0]-0.02) @walls.prepare @doc.openings.each do |opening| asset = @doc.asset(opening.asset) type = which_opening(opening, asset) @walls.opening(opening.position ,opening.size, type) end @walls.update end |