lib/tbd/psi.rb in tbd-3.4.1 vs lib/tbd/psi.rb in tbd-3.4.3
- old
+ new
@@ -1715,53 +1715,30 @@
# Loop through each linked wire and determine farthest point from
# edge while ensuring candidate point is not aligned with edge.
t_model.wires.each do |wire|
next unless surface[:wire] == wire.id # should be a unique match
- normal = tbd[:surfaces][id][:n] if tbd[:surfaces].key?(id)
- normal = holes[id].attributes[:n] if holes.key?(id)
- normal = shades[id][:n] if shades.key?(id)
- farthest = Topolys::Point3D.new(origin.x, origin.y, origin.z)
- farthest_V = farthest - origin # zero magnitude, initially
- inverted = false
- i_origin = wire.points.index(origin)
- i_terminal = wire.points.index(terminal)
- i_last = wire.points.size - 1
+ normal = tbd[:surfaces][id][:n] if tbd[:surfaces].key?(id)
+ normal = holes[id].attributes[:n] if holes.key?(id)
+ normal = shades[id][:n] if shades.key?(id)
+ farthest = Topolys::Point3D.new(origin.x, origin.y, origin.z)
+ farthest_V = farthest - origin # zero magnitude, initially
+ farthest_mag = 0
- if i_terminal == 0
- inverted = true unless i_origin == i_last
- elsif i_origin == i_last
- inverted = true unless i_terminal == 0
- else
- inverted = true unless i_terminal - i_origin == 1
- end
-
wire.points.each do |point|
next if point == origin
next if point == terminal
- point_on_plane = edge_plane.project(point)
- origin_point_V = point_on_plane - origin
- point_V_magnitude = origin_point_V.magnitude
- next unless point_V_magnitude > TOL
+ point_on_plane = edge_plane.project(point)
+ origin_point_V = point_on_plane - origin
+ point_V_mag = origin_point_V.magnitude
+ next unless point_V_mag > TOL
+ next unless point_V_mag > farthest_mag
- # Generate a plane between origin, terminal & point. Only consider
- # planes that share the same normal as wire.
- if inverted
- plane = Topolys::Plane3D.from_points(terminal, origin, point)
- else
- plane = Topolys::Plane3D.from_points(origin, terminal, point)
- end
-
- dnx = (normal.x - plane.normal.x).abs
- dny = (normal.y - plane.normal.y).abs
- dnz = (normal.z - plane.normal.z).abs
- next unless dnx < TOL && dny < TOL && dnz < TOL
-
- farther = point_V_magnitude > farthest_V.magnitude
- farthest = point if farther
- farthest_V = origin_point_V if farther
+ farthest = point
+ farthest_V = origin_point_V
+ fathest_mag = point_V_mag
end
angle = reference_V.angle(farthest_V)
angle = 0 if angle.nil?
adjust = false # adjust angle [180°, 360°] if necessary
@@ -2123,11 +2100,11 @@
set[:cornerconvex ] = shorts[:val][:cornerconvex ] if convex
is[:corner ] = true
end
# Label edge as :ceiling if linked to:
- # +1 deratable surfaces
+ # +1 deratable surface(s)
# 1x underatable CONDITIONED floor linked to an unoccupied space
# 1x adjacent CONDITIONED ceiling linked to an occupied space
edge[:surfaces].keys.each do |i|
break if is[:ceiling]
break unless deratables.size > 0
@@ -2137,13 +2114,13 @@
next if floors[i][:ground ]
next unless floors[i][:conditioned]
next if floors[i][:occupied ]
ceiling = floors[i][:boundary]
- next unless ceilings.key?(ceiling)
- next unless ceilings[ceiling][:conditioned]
- next unless ceilings[ceiling][:occupied ]
+ next unless ceilings.key?(ceiling)
+ next unless ceilings[ceiling][:conditioned]
+ next unless ceilings[ceiling][:occupied ]
other = deratables.first unless deratables.first == id
other = deratables.last unless deratables.last == id
other = id if deratables.size == 1
@@ -3306,12 +3283,12 @@
# 'Apply Measure Now' won't cp files from 1st path back to generated_files.
match1 = /WorkingFiles/.match(file_paths[1].to_s.strip)
match2 = /files/.match(file_paths[1].to_s.strip)
match = match1 || match2
- if file_paths.size >= 2 && File.exists?(file_paths[1].to_s.strip) && match
+ if file_paths.size >= 2 && File.exist?(file_paths[1].to_s.strip) && match
out_dir = file_paths[1].to_s.strip
- elsif !file_paths.empty? && File.exists?(file_paths.first.to_s.strip)
+ elsif !file_paths.empty? && File.exist?(file_paths.first.to_s.strip)
out_dir = file_paths.first.to_s.strip
end
out_path = File.join(out_dir, "tbd.out.json")