Browse Subversion Repository
Contents of /script/dat2wrl.rb
Parent Directory
| Revision Log
Revision 372 -
( show annotations)
( download)
Mon Oct 6 21:13:53 2008 UTC
(15 years, 6 months ago)
by satofumi
File size: 614 byte(s)
fix dirname error
| 1 |
#!/usr/bin/ruby |
| 2 |
# "x y z" [mm] 形式のデータを、VRML 形式に変換するスクリプト |
| 3 |
# Satofumi KAMIMURA |
| 4 |
# $Id$ |
| 5 |
|
| 6 |
if ARGV.length < 1 |
| 7 |
print "usage:\n\t" + __FILE__ + " <data file>\n" |
| 8 |
exit |
| 9 |
end |
| 10 |
data_file = ARGV[0] |
| 11 |
|
| 12 |
print <<-"EOB" |
| 13 |
#VRML V2.0 utf8 |
| 14 |
|
| 15 |
Shape |
| 16 |
{ |
| 17 |
geometry PointSet |
| 18 |
{ |
| 19 |
coord Coordinate |
| 20 |
{ |
| 21 |
point |
| 22 |
[ |
| 23 |
EOB |
| 24 |
|
| 25 |
File.open(data_file) { |io| |
| 26 |
while line = io.gets |
| 27 |
if line =~ /(\S+)\s(\S+)\s(\S+)/ |
| 28 |
x = $1.to_f / 100.0 |
| 29 |
y = $2.to_f / 100.0 |
| 30 |
z = $3.to_f / 100.0 |
| 31 |
print ' ' + x.to_s + ' ' + y.to_s + ' ' + z.to_s + "\n" |
| 32 |
end |
| 33 |
end |
| 34 |
} |
| 35 |
|
| 36 |
print <<-"EOB" |
| 37 |
] |
| 38 |
} |
| 39 |
} |
| 40 |
} |
| 41 |
EOB |
|