C#ATIA

↑タイトル詐欺 主にFusion360API 偶にCATIA V5 VBA(絶賛ネタ切れ中)

Sirenテスト-Filler

こちらの続きです。
Sirenテスト-sewing,fix - C#ATIA

自由曲面が作成出来そうな、Fillerクラスがあります。
点・線・平面は、Buildモジュールで生成出来るのですが、
自由曲面はFillerクラスのインスタンスに境界やサポートを突っ込んで
.Build → .face で受け取るみたいです。
インスタンス自体はShapeクラスでは無いので、自由曲面工場みたいな
感覚がします。

#SirenScript
expName = "/shape"
expIges = ARGV[0] + expName + ".igs"
expBrep = ARGV[0] + expName + ".brep"
expDunp = ARGV[0] + "/dump.txt"

bounds=[]
bounds << Build.line([0, 0, 0], [10, 0, 0])
bounds << Build.line([10, 0, 0], [10, 10, 0])
bounds << Build.line([10, 10, 0], [0, 10, 0])
bounds << Build.line([0, 10, 0], [0, 0, 0])

sh = Filler.new
bounds.each do |edge|
 sh.add_bound edge, 0
end

sh.build

open(expDunp, "w") {|f| f.write sh.to_s}
open(expDunp, "a") {|f| f.write "\r\n" + sh.face.to_s}
open(expDunp, "a") {|f| f.write "\r\n" + sh.done?.to_s}

IGES.save [sh] , expIges
BRepIO::save sh , expBrep

puts "OK"

配列に境界線を突っ込んで、ループさせadd_boundさせるのも
何となく遠回りな気もし、こんなコードでも動く事が何となく
わかっては来ましたが

・・・
sh = Filler.new
[[[0, 0, 0], [10, 0, 0]],
 [[10, 0, 0], [10, 10, 0]],
 [[10, 10, 0], [0, 10, 0]],
 [[0, 10, 0], [0, 0, 0]],].each do |pts|
 sh.add_bound Build.line(pts[0],pts[1]), 0
end
・・・

ちょっとやり過ぎを感じました・・・。結果はこちら
f:id:kandennti:20160308184736p:plain
えぇ、polygonで作成した面と変わらないです。
通過点を追加します。

・・・
sh.add ([3, 5 , 5])
sh.add ([7 , 5 , -5])

sh.build
・・・

f:id:kandennti:20160308184748p:plain
見事な曲面が出来ました。Zをこんな感じの過剰な数値すると

・・・
sh.add ([3, 5 , 100])
sh.add ([7 , 5 , -100])

sh.build
・・・

f:id:kandennti:20160308185012p:plain
出来ちゃいました。 CATIAのFillなら余裕でエラーです。


通過点は可能なのがわかったので、今度は通過線にしてみます。
平面より少し浮いたところに閉じた円弧を作成し、それを
サポートとして追加します。

・・・
#sh.add ([3, 5 , 100])
#sh.add ([7 , 5 , -100])
arc=Build.circle3p([3, 3, 1], [7, 5, 1], [3, 7, 1])
sh.add (arc)

sh.build

open(expDunp, "w") {|f| f.write sh.to_s}
open(expDunp, "a") {|f| f.write "\r\n" + sh.face.to_s}
open(expDunp, "a") {|f| f.write "\r\n" + sh.done?.to_s}
open(expDunp, "a") {|f| f.write "\r\n" + arc.to_s}

com = Build::compound [sh.face,arc]

IGES.save [com] , expIges
BRepIO::save com , expBrep

puts "OK"

こんな感じになりました。
f:id:kandennti:20160308184801p:plain
残念ながら通過してません。
CATIAのFillでは、こんな感じで作成出来たので形状的に
無理な指定では無いと思っています。
f:id:kandennti:20160308184809p:plain


他にも

・・・
arc=Build.arc3p([0, 0, 0], [5, 5, 1], [10, 10, 0])
・・・

f:id:kandennti:20160308184820p:plain

・・・
arc=Build.line([4, 4, 1], [6, 6, -1])
・・・

(直線がarcなのは、おかしいのですが・・・)
f:id:kandennti:20160308184829p:plain
何れも通過しなかったので、今のところは点のみっぽいです。
(インスタンス生成を引数付きのものにすれば、変わるのかな?)


もう一個わからなかったのが、境界を追加するadd_bound関数の
2番目の引数。 サンプルで "0" になっていたのでそのままに
したのですが、他の数値ではエラーになりました。
sirenのリファレンスマニュアルでは、特に説明書きが無かった為、OCCTの
こちらを見た感じだと、
Open CASCADE Technology: BRepFill_Filling Class Reference

境界に対してのサポートっぽいのですが、ん~まぁわかりません。
将来的に拡張する為のものと思っておきます。(逃げました)