Last active
November 21, 2018 09:02
-
-
Save tkfm-yamaguchi/d7ddb0616ecfca62a399728288e8e5c5 to your computer and use it in GitHub Desktop.
a ruby method to detect x-y coords uniquness of points in VTK file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Detects whether the x/y coordinates of points in VTK are all different. | |
# | |
# @params {string} vtk path to VTK file | |
# @return {boolean} | |
def all_coords_uniq?(vtk) | |
File.open(vtk, "r") do |f| | |
points_count = 0 | |
while line = f.gets.chomp | |
if line =~ /^POINTS/ | |
points_count = line.split[1].to_i | |
break | |
end | |
end | |
points = points_count.times.map do | |
f.gets.split[0..1] | |
end | |
return points.size == points.uniq.size | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment