lib/measures/tbd/resources/psi.rb
##
# Check for matching vertex pairs between edges (10mm tolerance)
# @param [Hash] e1 First edge
# @param [Hash] e2 Second edge
#
# @return [Bool] Returns true if edges share vertex pairs
Check for matching vertex pairs between edges (10mm tolerance)
Check for matching vertex pairs between edges ( 10mm tolerance )
def matches?(e1, e2)
  unless e1 && e2
    TBD.log(TBD::DEBUG,
      "Invalid matching edge arguments - skipping")
    return false
  end
  unless e1.has_key?(:v0) && e1.has_key?(:v1) &&
         e2.has_key?(:v0) && e2.has_key?(:v1)
    TBD.log(TBD::DEBUG,
      "Missing vertices for matching edge(s) - skipping")
    return false
  end
  cl = Topolys::Point3D
  unless e1[:v0].is_a?(cl) && e1[:v1].is_a?(cl) &&
         e2[:v0].is_a?(cl) && e2[:v1].is_a?(cl)
    TBD.log(TBD::DEBUG,
      "#{cl}? Expecting Topolys 3D points for matching edge(s) - skipping")
    return false
  end
  e1_vector = e1[:v1] - e1[:v0]
  e2_vector = e2[:v1] - e2[:v0]
  if e1_vector.magnitude < TOL || e2_vector.magnitude < TOL
    TBD.log(TBD::DEBUG,
      "Matching edge lengths below TOL - skipping")
    return false
  end
  return true if
  (
    (
      ( (e1[:v0].x - e2[:v0].x).abs < TOL &&
        (e1[:v0].y - e2[:v0].y).abs < TOL &&
        (e1[:v0].z - e2[:v0].z).abs < TOL
      ) ||
      ( (e1[:v0].x - e2[:v1].x).abs < TOL &&
        (e1[:v0].y - e2[:v1].y).abs < TOL &&
        (e1[:v0].z - e2[:v1].z).abs < TOL
      )
    ) &&
    (
      ( (e1[:v1].x - e2[:v0].x).abs < TOL &&
        (e1[:v1].y - e2[:v0].y).abs < TOL &&
        (e1[:v1].z - e2[:v0].z).abs < TOL
      ) ||
      ( (e1[:v1].x - e2[:v1].x).abs < TOL &&
        (e1[:v1].y - e2[:v1].y).abs < TOL &&
        (e1[:v1].z - e2[:v1].z).abs < TOL
      )
    )
  )
  false
end
def matches? ( e1 , e2 ) unless e1 && e2 TBD . log ( TBD :: DEBUG , "Invalid matching edge arguments - skipping" ) return false end unless e1 . has_key? ( :v0 ) && e1 . has_key? ( :v1 ) && e2 . has_key? ( :v0 ) && e2 . has_key? ( :v1 ) TBD . log ( TBD :: DEBUG , "Missing vertices for matching edge(s) - skipping" ) return false end cl = Topolys :: Point3D unless e1 [ :v0 ] . is_a? ( cl ) && e1 [ :v1 ] . is_a? ( cl ) && e2 [ :v0 ] . is_a? ( cl ) && e2 [ :v1 ] . is_a? ( cl ) TBD . log ( TBD :: DEBUG , "#{cl}? Expecting Topolys 3D points for matching edge(s) - skipping" ) return false end e1_vector = e1 [ :v1 ] - e1 [ :v0 ] e2_vector = e2 [ :v1 ] - e2 [ :v0 ] if e1_vector . magnitude < TOL || e2_vector . magnitude < TOL TBD . log ( TBD :: DEBUG , "Matching edge lengths below TOL - skipping" ) return false end return true if ( ( ( ( e1 [ :v0 ] . x - e2 [ :v0 ] . x ) . abs < TOL && ( e1 [ :v0 ] . y - e2 [ :v0 ] . y ) . abs < TOL && ( e1 [ :v0 ] . z - e2 [ :v0 ] . z ) . abs < TOL ) || ( ( e1 [ :v0 ] . x - e2 [ :v1 ] . x ) . abs < TOL && ( e1 [ :v0 ] . y - e2 [ :v1 ] . y ) . abs < TOL && ( e1 [ :v0 ] . z - e2 [ :v1 ] . z ) . abs < TOL ) ) && ( ( ( e1 [ :v1 ] . x - e2 [ :v0 ] . x ) . abs < TOL && ( e1 [ :v1 ] . y - e2 [ :v0 ] . y ) . abs < TOL && ( e1 [ :v1 ] . z - e2 [ :v0 ] . z ) . abs < TOL ) || ( ( e1 [ :v1 ] . x - e2 [ :v1 ] . x ) . abs < TOL && ( e1 [ :v1 ] . y - e2 [ :v1 ] . y ) . abs < TOL && ( e1 [ :v1 ] . z - e2 [ :v1 ] . z ) . abs < TOL ) ) ) false end
Check for matching vertex pairs between edges (10mm tolerance)
Check for matching vertex pairs between edges ( 10mm tolerance )
Returns true if edges share vertex pairs
Returns true if edges share vertex pairs
Bool
e1
e2
e2 Second edge
e2 Second edge