Class: BTAP::EQuest::DOESpace

Inherits:
DOECommand show all
Defined in:
lib/openstudio-standards/btap/equest.rb

Overview

Interface for the DOESpace Command.

Instance Attribute Summary collapse

Attributes inherited from DOECommand

#building, #children, #commandName, #commandType, #comments, #exempt, #keywordPairs, #non_utype_commands, #one_line_commands, #parents, #utype, #uvalue

Instance Method Summary collapse

Methods inherited from DOECommand

#basic_output, #check_keyword?, #depth, #doe_scope, #get_children, #get_children_of_command, #get_command_from_string, #get_keyword_value, #get_name, #get_parent, #get_parents, #name, #remove, #remove_keyword_pair, #set_keyword_value, #set_parent

Constructor Details

#initializeDOESpace

Returns a new instance of DOESpace.



1482
1483
1484
1485
# File 'lib/openstudio-standards/btap/equest.rb', line 1482

def initialize

  super()
end

Instance Attribute Details

#polygonObject

Returns the value of attribute polygon.



1480
1481
1482
# File 'lib/openstudio-standards/btap/equest.rb', line 1480

def polygon
  @polygon
end

#zoneObject

Returns the value of attribute zone.



1481
1482
1483
# File 'lib/openstudio-standards/btap/equest.rb', line 1481

def zone
  @zone
end

Instance Method Details

#convert_to_openstudio(model, runner = nil) ⇒ Object



1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
# File 'lib/openstudio-standards/btap/equest.rb', line 1675

def convert_to_openstudio(model,runner = nil)
  if self.get_keyword_value("SHAPE") == "NO-SHAPE"
    BTAP::runner_register("Info", "OpenStudio does not support NO-SHAPE SPACE definitions currently. Not importing the space #{self.name}.",runner)
  else
    os_space = OpenStudio::Model::Space.new(model)
    os_space.setName(self.name)
    #set floor
    os_space.setBuildingStory(OpenStudio::Model::getBuildingStoryByName(model,self.get_parent("FLOOR").name).get)
    BTAP::runner_register("Info", "\tSpace: " + self.name + " created",runner)
    #puts "\t\t Azimuth:#{self.get_azimuth}"
    #puts "\t\t Azimuth:#{self.get_origin}"
  end
end

#get_areaObject

This method finds the area of the space



1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
# File 'lib/openstudio-standards/btap/equest.rb', line 1502

def get_area

  # get the keyword value of shape
  shape = get_keyword_value("SHAPE")

  # if the shape value is nil, or it is defined as "NO-SHAPE", the get_area value
  # would be defined, and would represent the get_area of the space
  if ( shape == nil || shape == "NO-SHAPE")
    area = get_keyword_value("AREA")
    area = area.to_f
    return area

    # if the shape value is "BOX", the height and width key values are given,
    # and the get_area would be defined as their product
  elsif ( shape == "BOX" )
    height = get_keyword_value("HEIGHT")
    width = get_keyword_value("WIDTH")
    height = height.to_f
    width = width.to_f
    return height * width

    # if the shape value is defined as a polygon , the get_area of the polygon would
    # represent the get_area of the space
  elsif ( shape == "POLYGON")
    return @polygon.get_area
  else
    raise "Error: The area could not be evaluated. Please check inputs\n "

  end
end

#get_azimuthObject



1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
# File 'lib/openstudio-standards/btap/equest.rb', line 1630

def get_azimuth()
  angle = 0.0
  #puts OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 0.0, 0.0), OpenStudio::Vector3d.new(1.0, 0.0, 0.0) ) )
  if check_keyword?("LOCATION") and not check_keyword?("AZIMUTH")
    case get_keyword_value("LOCATION")
    when /FLOOR-\s*V\s*(.*)/
      index = $1.strip.to_i - 1
      point0 = self.get_parent("FLOOR").polygon.point_list[index]
      point1 = self.get_parent("FLOOR").polygon.point_list[index + 1] ? get_parent("FLOOR").polygon.point_list[index + 1] : get_parent("FLOOR").polygon.point_list[0]
      edge = point1-point0


      sign = 1.0# OpenStudio::Vector3d.new(1.0, 0.0, 0.0).dot(( edge )) > 0 ? 1 :-1
      angle = OpenStudio::radToDeg( sign * OpenStudio::getAngle(OpenStudio::Vector3d.new(1.0, 0.0, 0.0), ( point1 - point0 ) ) )

      #since get angle only get acute angles we need to get sign and completment for reflex angle
      if edge.y > 0.0
        angle = -1.0 * angle 
      end

    when "FRONT"
      angle = OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 1.0, 0.0), ( get_parent("FLOOR").polygon.point_list[1] - get_parent("FLOOR").polygon.point_list[0] ) ) )
    when "RIGHT"
      angle = OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 1.0, 0.0), ( get_parent("FLOOR").polygon.point_list[2] - get_parent("FLOOR").polygon.point_list[1] ) ) )
    when "BACK"
      angle = OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 1.0, 0.0), ( get_parent("FLOOR").polygon.point_list[3] - get_parent("FLOOR").polygon.point_list[2] ) ) )
    when "LEFT"
      angle = OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 1.0, 0.0), ( get_parent("FLOOR").polygon.point_list[0] - get_parent("FLOOR").polygon.point_list[3] ) ) )
    end
  else
    angle =  self.check_keyword?("AZIMUTH")? self.get_keyword_value("AZIMUTH").to_f : 0.0
  end
  return angle
end

#get_depthObject



1583
1584
1585
1586
1587
# File 'lib/openstudio-standards/btap/equest.rb', line 1583

def get_depth
  depth = get_keyword_value("DEPTH")
  depth = depth.to_f
  return depth
end

#get_floorObject



1594
1595
1596
# File 'lib/openstudio-standards/btap/equest.rb', line 1594

def get_floor
  get_parent("FLOOR")
end

#get_heightObject



1572
1573
1574
1575
# File 'lib/openstudio-standards/btap/equest.rb', line 1572

def get_height()
  if check_keyword?("HEIGHT") then return get_keyword_value("HEIGHT").to_f end
  return get_floor.get_keyword_value("SPACE-HEIGHT").to_f
end

#get_originObject



1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
# File 'lib/openstudio-standards/btap/equest.rb', line 1599

def get_origin()
  space_origin = nil
  if check_keyword?("LOCATION") and ( not self.check_keyword?("X") or not self.check_keyword?("Y") or not self.check_keyword?("Z") )
    zero = OpenStudio::Point3d.new( 0.0, 0.0, 0.0 )
    case get_keyword_value("LOCATION")
    when /FLOOR-\s*V\s*(.*)/
      index = $1.strip.to_i - 1
      surf_vector =  get_parent("FLOOR").polygon.point_list[index] - zero
    when "FRONT"
      surf_vector =  get_parent("FLOOR").polygon.point_list[0] - zero
    when "RIGHT"
      surf_vector =  get_parent("FLOOR").polygon.point_list[1] - zero
    when "BACK"
      surf_vector =  get_parent("FLOOR").polygon.point_list[2] - zero
    when "LEFT"
      surf_vector =  get_parent("FLOOR").polygon.point_list[3] - zero
    end
    space_xref = self.check_keyword?("X")? self.get_keyword_value("X").to_f : 0.0
    space_yref = self.check_keyword?("Y")? self.get_keyword_value("Y").to_f : 0.0
    space_zref = self.check_keyword?("Z")? self.get_keyword_value("Z").to_f : 0.0
    space_origin = OpenStudio::Vector3d.new(space_xref,space_yref,space_zref)
    space_origin = surf_vector + space_origin
  else
    space_xref = self.check_keyword?("X")? self.get_keyword_value("X").to_f : 0.0
    space_yref = self.check_keyword?("Y")? self.get_keyword_value("Y").to_f : 0.0
    space_zref = self.check_keyword?("Z")? self.get_keyword_value("Z").to_f : 0.0
    space_origin = OpenStudio::Vector3d.new(space_xref,space_yref,space_zref)
  end
  return space_origin
end

#get_rotation_matrixObject



1671
1672
1673
# File 'lib/openstudio-standards/btap/equest.rb', line 1671

def get_rotation_matrix()
  return OpenStudio::Transformation::rotation(OpenStudio::Vector3d.new(0.0, 0.0, 1.0), OpenStudio::degToRad(360.0 - self.get_azimuth()))
end

#get_shapeObject



1589
1590
1591
1592
# File 'lib/openstudio-standards/btap/equest.rb', line 1589

def get_shape
  return "NO-SHAPE" unless check_keyword?("SHAPE")
  return get_keyword_value("SHAPE")
end

#get_transformation_matrixObject



1666
1667
1668
1669
# File 'lib/openstudio-standards/btap/equest.rb', line 1666

def get_transformation_matrix()
  #This will transform the space vertices to normal space co-ordinates using Sketchup/OS convention
  return OpenStudio::createTranslation(self.get_origin) * OpenStudio::Transformation::rotation(OpenStudio::Vector3d.new(0.0, 0.0, 1.0), OpenStudio::degToRad(360.0 - self.get_azimuth()))
end

#get_volumeObject

This method finds the volume of the space



1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
# File 'lib/openstudio-standards/btap/equest.rb', line 1534

def get_volume

  # get the keyword value of "SHAPE"
  shape = get_keyword_value("SHAPE")

  # if the shape value returns nil, or is defined as "NO-SHAPE", the volume is
  # given directly
  if ( shape == nil || shape == "NO-SHAPE")
    volume = get_keyword_value("VOLUME")
    volume = volume.to_f
    return volume

    # if the shape is defined as a "BOX", the values for height, width, and
    # depth are given, from which you can get the volume
  elsif ( shape == "BOX" )
    height = get_keyword_value("HEIGHT")
    width = get_keyword_value("WIDTH")
    depth = get_keyword_value("DEPTH")
    height = height.to_f
    width = width.to_f
    depth = depth.to_f
    return height * width * depth

    # if the shape is defined as a "POLYGON", the get_area is defined as the area
    # of the polygon, and the height is given by the value of "HEIGHT"
  elsif ( shape == "POLYGON")
    height = getKeywordvalue("HEIGHT")
    temp = get_keyword_value("POLYGON")
    height = height.to_f
    @polygon.utype = temp
    return @polygon.get_area * height
  else
    raise "Error: The volume could not be evaluated. Please check inputs\n "

  end

end

#get_widthObject



1577
1578
1579
1580
1581
# File 'lib/openstudio-standards/btap/equest.rb', line 1577

def get_width
  width = get_keyword_value("WIDTH")
  width = width.to_f
  return width
end

#outputObject

this outputs the command to a string.



1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
# File 'lib/openstudio-standards/btap/equest.rb', line 1488

def output
  temp_string = basic_output()
  if @polygon != nil
    temp_string = temp_string + "$Polygon\n"
    temp_string = temp_string +  "$\t#{@polygon.utype} = #{@polygon.commandName}\n"
  end
  if @zone != nil
    temp_string = temp_string + "$Zone\n"
    temp_string = temp_string +  "$\t#{@zone.utype} = #{@zone.commandName}\n"
  end
  return temp_string
end