date=["hd"];hcw=[];hcd=[]
puts "追加文字を入力してください。 日本語入力は、「Alt」+「半角/全角」"
tuika_moji=gets;tuika_moji.chomp!
begin
puts "追加文字の位置を入力してください。 前付:1 後付:2"
iti=gets;iti.chomp!
puts "入力が不適当です。再入力してください\n" if iti.chomp !="1" && iti.chomp !="2"
end while(iti !="1" && iti.chomp !="2")
open("temp.txt","r"){|f|
while line=f.gets
xy =line.split
if xy[0] =~ /^hq/
elsif xy[0] =~ /^hcw/
xy.each{|item|hcw< date< elsif xy[0] =~ /^hcd/
xy.each{|item|hcd< date< elsif xy[0] =~ /^cn\d+$/
cn=xy
date< elsif xy[0] =~ /^msg|^\#/
msg=xy[0]
date< elsif xy[0] =~ /^z/
zno=f.lineno
date< elsif xy[0] =~ /^ch|^cs/
if cn[0]=="cn0"
moji_w=cn[1].to_f
moji_d=cn[3].to_f
else
moji_w=hcw[cn[0][2,1].to_i]
moji_d=hcd[cn[0][2,1].to_i]
end
if $_=~/\"/
moji=$'.chomp
end
chno=f.lineno
if msg=="msg"
x=xy[3].to_f
y=xy[4].to_f
moji_l=Math.sqrt(x**2+y**2)
moji_arg=Math.atan2(y,x)
tuika_moji_a=tuika_moji.split('')
if tuika_moji_a[0].size==1
tuika_moji_l=(moji_w/2+moji_d/2)*tuika_moji_a.size
elsif tuika_moji_a[0].size==2
tuika_moji_l=(moji_w+moji_d)*tuika_moji_a.size
end
date<< xy[0,5].join("\s")+"\""+tuika_moji+moji if iti=="1"
date<< xy[0,5].join("\s")+"\""+moji+tuika_moji if iti=="2"
else
date<< $`+$&+tuika_moji+moji if iti=="1"
date<< $`+$&+moji+tuika_moji if iti=="2"
end
else
date<< line.chomp
end
end
}
open("jwc_temp.txt","w"){|f|date.each{|item|f.puts item};}
@REM 法面を分割する
@echo off
REM #jww
REM #cd
REM #1ci法肩の円弧を指示
REM #2ci法尻の円弧を指示
REM #c分割数 無指定:10/_/a
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 法面分割.rb temp.txt %1 > jwc_temp.txt
◎バッチファイル(法面分割.rb)
include Math
puts"hd"
$n=10
while ARGV.size>1
case argument=ARGV.pop
when /\/a/
$n=argument[2..-1].to_f
end
end
def main
date=[];enko=[]
while ARGF.gets
xy =split
if xy[0]=~/^hq/
elsif xy[0]=~/^ci/
puts "pl"
xyt=xy.collect{|item|item.to_f}
x=xyt[1]
y=xyt[2]
zahyo=[]
if xy.size==8 && xyt[4] != xyt[5]
ziku=xyt[7]*2*PI/360
if xyt[4]>xyt[5]
xyt[4] -=360
end
bunkaku=((xyt[5]-xyt[4])/$n)*2*PI/360
kakudo=xyt[4]*2*PI/360
r=xyt[3]
while (kakudo < xyt[5]*2*PI/360)
x1=r*cos(kakudo)
y1=r*sin(kakudo)*xyt[6]
xyl=sqrt(x1**2+y1**2)
arg=atan2(y1,x1)
zahyo<<[x+xyl*cos(arg+ziku),y+xyl*sin(arg+ziku)]
kakudo += bunkaku
end
x1=xyt[3]*cos(xyt[5]*2*PI/360)
y1=xyt[3]*sin(xyt[5]*2*PI/360)*xyt[6]
arg=atan2(y1,x1)
xyl=sqrt(x1**2+y1**2)
zahyo<<[x+xyl*cos(arg+ziku),y+xyl*sin(arg+ziku)]
0.upto(zahyo.size-2){|i|
puts [zahyo[i][0],zahyo[i][1],zahyo[i+1][0],zahyo[i+1][1]].join("\s")}
enko< else
print $_
end
puts "\#"
else
print $_
end
end
include Math
puts"hd"
$n=10
while ARGV.size>1
case argument=ARGV.pop
when /\/a/
$n=argument[2..-1].to_f
end
end
def main
date=[];enko=[];lc=[];lt=[]
while ARGF.gets
xy =split
if xy[0]=~/^hq/
elsif xy[0]=~/^ci/
puts "pl"
xyt=xy.collect{|item|item.to_f}
x=xyt[1]
y=xyt[2]
zahyo=[]
if xy.size==8 && xyt[4] != xyt[5]
ziku=xyt[7]*2*PI/360
if xyt[4]>xyt[5]
xyt[4] -=360
end
bunkaku=((xyt[5]-xyt[4])/$n)*2*PI/360
kakudo=xyt[4]*2*PI/360
r=xyt[3]
while (kakudo < xyt[5]*2*PI/360)
x1=r*cos(kakudo)
y1=r*sin(kakudo)*xyt[6]
xyl=sqrt(x1**2+y1**2)
arg=atan2(y1,x1)
zahyo<<[x+xyl*cos(arg+ziku),y+xyl*sin(arg+ziku)]
kakudo += bunkaku
end
x1=xyt[3]*cos(xyt[5]*2*PI/360)
y1=xyt[3]*sin(xyt[5]*2*PI/360)*xyt[6]
arg=atan2(y1,x1)
xyl=sqrt(x1**2+y1**2)
zahyo<<[x+xyl*cos(arg+ziku),y+xyl*sin(arg+ziku)]
0.upto(zahyo.size-2){|i|
puts [zahyo[i][0],zahyo[i][1],zahyo[i+1][0],zahyo[i+1][1]].join("\s")}
enko< else
print $_
end
puts "\#"
elsif xy[0]=~/^lc/
print $_
lc< elsif xy[0]=~/^lt/
print $_
lt< else
print $_
end
end
puts(lc[0],lt[0])
return [zahyo_xt,zahyo_yt]
end
end
##################################################
n=10
while ARGV.size>1
case argument=ARGV.pop
when /\/a/
n=argument[2..-1].to_f
end
end
enko=[];zahyo1=[];zahyo2=[]
while ARGF.gets
xy=split
if xy[0]=~/^ci/
if xy.size==8
xy.collect!{|item|item.to_f}
if xy[4]>xy[5]
xy[4] -=360
end
enko< end
end
end
x1_1=daenko_siten(enko[0])[0]
y1_1=daenko_siten(enko[0])[1]
tanni_kakudo=enko[0][5]-enko[0][4]
bunkaku1=tanni_kakudo/(n)
m=1
while m<(n)
x=enko[0][1]+enko[0][3]*cos((enko[0][5]+enko[0][7]-bunkaku1*m)*2*PI/360)
y=enko[0][2]+enko[0][3]*sin((enko[0][5]+enko[0][7]-bunkaku1*m)*2*PI/360)
zahyo1<<[x,y];m+=1
end