lib/measures/tbd/resources/psi.rb
##
# Populate TBD edges with linked Topolys faces.
#
# @param [Hash] surfaces A collection of TBD surfaces
# @param [Hash] edges A collection TBD edges
#
# @return [Bool] Returns true if successful
Populate TBD edges with linked Topolys faces.
Populate TBD edges with linked Topolys faces .
def tbdSurfaceEdges(surfaces, edges)
  unless surfaces && edges
    TBD.log(TBD::DEBUG,
      "Invalid TBD (edges) arguments - skipping")
    return false
  end
  unless surfaces.is_a?(Hash)
    TBD.log(TBD::DEBUG,
      "#{surfaces.class}? expected TBD surfaces Hash (edges) - skipping")
    return false
  end
  unless edges.is_a?(Hash)
    TBD.log(TBD::DEBUG,
      "#{edges.class}? expected TBD edges Hash (edges) - skipping")
    return false
  end
  surfaces.each do |id, properties|
    unless properties.has_key?(:face)
      TBD.log(TBD::DEBUG,
        "Missing Topolys face for '#{id}' (edges) - skipping")
      next
    end
    properties[:face].wires.each do |wire|
      wire.edges.each do |e|
        unless edges.has_key?(e.id)
          edges[e.id] = { length: e.length,
                          v0: e.v0,
                          v1: e.v1,
                          surfaces: {} }
        end
        unless edges[e.id][:surfaces].has_key?(id)
          edges[e.id][:surfaces][id] = { wire: wire.id }
        end
      end
    end
  end
  true
end
def tbdSurfaceEdges ( surfaces , edges ) unless surfaces && edges TBD . log ( TBD :: DEBUG , "Invalid TBD (edges) arguments - skipping" ) return false end unless surfaces . is_a? ( Hash ) TBD . log ( TBD :: DEBUG , "#{surfaces.class}? expected TBD surfaces Hash (edges) - skipping" ) return false end unless edges . is_a? ( Hash ) TBD . log ( TBD :: DEBUG , "#{edges.class}? expected TBD edges Hash (edges) - skipping" ) return false end surfaces . each do | id , properties | unless properties . has_key? ( :face ) TBD . log ( TBD :: DEBUG , "Missing Topolys face for '#{id}' (edges) - skipping" ) next end properties [ :face ] . wires . each do | wire | wire . edges . each do | e | unless edges . has_key? ( e . id ) edges [ e . id ] = { length : e . length , v0 : e . v0 , v1 : e . v1 , surfaces : { } } end unless edges [ e . id ] [ :surfaces ] . has_key? ( id ) edges [ e . id ] [ :surfaces ] [ id ] = { wire : wire . id } end end end end true end
Populate TBD edges with linked Topolys faces.
Populate TBD edges with linked Topolys faces .
Returns true if successful
Returns true if successful
Bool
surfaces
edges
edges A collection TBD edges
edges A collection TBD edges