Sha256: 39dd83d469a2010aff1cfdbaf01f487fde7b3a65504405d3e4738043cd43c49e

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

# Methods to modify geometry
module OpenstudioStandards
  module Geometry
    # @!group Modify

    # lower z value of vertices with starting value above z_value_target to z_value_target
    #
    # @param surfaces [Array<OpenStudio::Model::Surface>] array of Surface objects
    # @param z_value_target [Double]
    # @return [Array] array of z values in meters
    def self.surfaces_lower_z_values(surfaces, z_value_target)
      count = 0

      # loop over all surfaces
      surfaces.each do |surface|
        # create a new set of vertices
        new_vertices = OpenStudio::Point3dVector.new

        # get the existing vertices for this interior partition
        vertices = surface.vertices
        flag = false
        vertices.each do |vertex|
          # initialize new vertex to old vertex
          x = vertex.x
          y = vertex.y
          z = vertex.z

          # if this z vertex is not on the z = 0 plane
          if z > z_value_target
            z = z_value_target
            flag = true
          end

          # add point to new vertices
          new_vertices << OpenStudio::Point3d.new(x, y, z)
        end

        # set vertices to new vertices
        # @todo check if this was made, and issue warning if it was not. Could happen if resulting surface not planer.
        surface.setVertices(new_vertices)

        count += 1 if flag
      end

      return count
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openstudio-standards-0.5.0 lib/openstudio-standards/geometry/modify.rb
openstudio-standards-0.5.0.rc1 lib/openstudio-standards/geometry/modify.rb