シェイプ生成メソッド
Siren::Shape オブジェクトを生成するためのメソッドです。 Open CASCADE における TopAlgo ツールキットに相当します。
copy(shape, copy_geom=true) -> Shape
shape を複製したものを返します。 copy_geom が真の時、ジオメトリーも含めて複製します。
box1 = Siren.box
box2 = Siren.copy box1
# これも同じ
box3 = box1.clone
vertex(point = [0, 0, 0]) -> Vertex
指定された座標 point に Siren::Vertex (点)を生成します。引数を省略した場合、[0, 0, 0] の位置に生成します。
mypoint = Siren.vertex [10, 20, 30]
line(sp = [0, 0, 0], tp = [1, 1, 1]) -> Edge
指定された2点 sp
と tp
をそれぞれ始点・終点とする Siren::Shape::Edge オブジェクトを生成します。引数を省略すると、[0, 0, 0] と [1, 1, 1] を始終点として生成します。
myline = Siren.line [0, 0, 0], [10, 20, 30]
myline2 = Siren.line
infline(op = [0, 0, 0], dir = [1, 0, 0]) -> Edge
指定された点 op
を通り、方向 dir
に伸びる無限直線の Siren::Shape::Edge オブジェクトを作成します。引数を省略すると、通過点 [0, 0, 0] と方向 [1, 0, 0] を引数として生成します。
z_axis = Siren.infline [0, 0, 0], [0, 0, 1]
myline = Siren.infline
polyline([p1, p2, ... ]) -> Wire
2つ以上の頂点を持つ点列から折れ線状のポリライン Siren::Wire オブジェクトを生成します。同一座標値を持つ頂点を連続して指定することはできません。
mypolyline = Siren.polyline [[0, 0, 0], [1, 0, 0], [1, 1, 0], [1, 1, 1]]
interpolate([p1, p2, ...], [v1, v2, ...]=nil) -> Edge
指定した点列を通過する高次スプライン曲線を生成します。戻り値は Siren::Edge 型になります。第1引数は、2つ以上の要素を持つ頂点の列を指定します。第2引数は、各頂点を通過する際、その頂点に曲線がどのような角度で入るかを指定する接ベクトルの列です。 頂点数と接ベクトルの要素数は一致する必要があります。接ベクトルを明示的に指定しなくてもよい頂点には nil
を指定します。
mycurve = Siren.curve [[0, 0, 0], [1, 0, 0], [1, 1, 0]], [[1, 0, 0], nil, [0, 1, 0], [1, 0, 0]]
wire([e1, e2, ...], tol=0.001) -> Wire
1つ以上の Siren::Edge オブジェクトを含む配列から Siren::Wire オブジェクトを生成します。ワイヤーとは、1つ以上のエッジがつながった状態を保証する型です。第2引数はワイヤーとして各々のエッジを結合するための距離トレランスです。
myedge1 = Siren.line [0, 0, 0], [1, 1, 0]
myedge2 = Siren.line [1, 1, 0], [2, 1, 0]
mycurve = Siren.wire [myedge1, myedge2], 0.001]
arc(op, dir, vx, radius, start_angle, term_angle) -> Edge
円弧を生成します。各引数は次のとおりです。
- op 原点
- dir 方向
- vx
- radius 半径
- start_angle 開始角(ラジアン)
- term_angle 終了角(ラジアン)
myarc = Siren.arc [0, 0, 0], [0, 0, 1], [1, 0, 0], 10, 0, Math::PI
arc3p(p1, p2, p3) -> Edge
指定した3点を通過する円弧を作成します。
myarc = Siren.arc3p [0, 0, 0], [1, 1, 0], [2, 0, 0]
-
circle(op, dir, radius) -> Edge
- 原点、方向、半径を指定して円を作成します。
mycircle = Siren.circle [0, 0, 0], [0, 0, 1], 10
circle3p(p1, p2, p3) -> Edge
指定した3点を通過する円を作成します。
mycircle = Siren.circle3p [0, 0, 0], [1, 1, 0], [2, 0, 0]
plane(op, norm, vx, umin, umax, vmin, vmax) -> Face
矩形状の平面を生成します。各引数は次のとおりです。
- op 原点
- norm 法線方向
- vx
- umin u軸方向の範囲の最小値
- umax u軸方向の範囲の最大値
- vmin v軸方向の範囲の最小値
- vmax v軸方向の範囲の最大値
myplane = Siren.plane [0, 0, 0], [0, 0, 1], [1, 0, 0], -1, 1, -1, 1
face(wire, force_plane) -> Face
与えられた wire
を外周線とする面を生成します。 force_plane
を true
にすると、強制的に平面として生成を試みます。
mypolyline = Siren.polyline [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 0]]
myface = Siren.face mypolyline, true
infplane(op, norm) -> Face
原点 op
を通過し、法線方向 norm
を持つ無限平面を作成します。
myinfplane = Siren.infplane [0, 0, 0], [0, 0, 1]
polygon([p1, p2, p3, ...], force_plane) -> Face
与えられた頂点配列を外周線とする面を生成します。 force_plane
を true
にすると、強制的に平面として作成を試みます。
mypolygon = Siren.polygon [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 0]], true
bzcurve(poles, weights=nil, first=nil, last=nil) -> Edge
Bezier (ベジエ)曲線を生成します。weights を省略すると、ウエイトの値はすべて 1.0
となります。
bzcurve
メソッドは次のコードのラッパーです。
Siren.curve(BzCurve.new(poles, weights), first, last)
bscurve(degree, knots, mults, poles, weights=nil, first=nil, last=nil) -> Edge
NURBS (ナーブス)曲線を生成します。weights を省略すると、ウエイトの値はすべて 1.0
となり、通常のBスプライン曲線となります。
- degree 次数
- knots ノットベクトル配列
- poles コントロール点列
- weights ウエイト配列
- first 開始曲線パラメータ
- last 終了曲線パラメータ
bscurve
メソッドは次のコードのラッパーです。
Siren.curve(BSCurve.new(degree, knots, mults, poles, weights), first, last)
bzsurf(ps, ws=[]) -> Face
ベジエ(Bezier)曲面を生成します。
bssurf(udeg, vdeg, uknots, vknots, poles, wire=nil) -> Face
NURBS 曲面を生成します。
shell([face1, face2, ...], tol=nil) -> Shell
sew([face1, face2, ...], tol=nil) -> Shell
1つ以上のフェイスを含む配列からシェルを生成します。
solid(shell) -> Solid
シェルからソリッドを生成します。