天天看點

OpenCASCADE Linear Extrusion Surface

abstract. opencascade linear extrusion surface is a generalized cylinder. such a surface is obtained by sweeping a curve (called the “extruded curve” or “basis”) in a given direction (referred to as the direction of extrusion and defined by a unit vector). the u parameter is along the extruded curve. the v parameter is along the direction of extrusion. the form of a surface of linear extrusion is generally a ruled surface. it can be a cylindrical surface, or a planar surface. key words. openc

[email protected]

abstract. opencascade linear extrusion surface is a generalized cylinder. such a surface is obtained by sweeping a curve (called the “extruded curve” or “basis”) in a given direction (referred to as the direction of extrusion and defined by a unit vector). the u parameter is along the extruded curve. the v parameter is along the direction of extrusion. the form of a surface of linear extrusion is generally a ruled surface. it can be a cylindrical surface, or a planar surface.

key words. opencascade, extrusion surface, sweeping

1. introduction

一般柱面(the general cylinder)可以由一段或整個圓弧沿一個方向偏移一定的距離得到。如下圖所示:

OpenCASCADE Linear Extrusion Surface

figure 1.1 extrusion shapes

當将頂點拉伸時,會生成一條邊;當将邊拉伸時,會生成面;當将wire拉伸時,會生成shell,當将面拉伸時,會生成體。當将曲線沿一個方向拉伸時,會形成一個曲面,如果此方向為直線,則會生成一般柱面。如果此方向是曲線時,會生成如下圖所示曲面:

OpenCASCADE Linear Extrusion Surface

figure 1.2 swept surface/ loft surface

本文主要介紹将曲線沿直線方向拉伸的算法,即一般柱面生成算法。并将生成的曲面在openscenegraph中進行顯示。

2.cylinder surface definition

設 w是一個機關向量,c(u)是定義在節點矢量u上,權值為wi的p次nurbs曲線。我們要得到一般柱面s(u,v)的表達式,s(u,v)是通過将 c(u)沿方向w平行掃描(sweep)距離d得到的。記掃描方向的參數為v, 0<v<1,顯然,s(u,v)必須滿足以下兩個條件:

v 對于固定的u0, s(u0, v)為由c(u0)到c(u0)+dw的直線段;

v 對于固定的v0:

OpenCASCADE Linear Extrusion Surface

所要求的柱面的表達式為:

OpenCASCADE Linear Extrusion Surface

s(u,v)定義在節點矢量u和v上,這裡v={0,0,1,1},u為c(u)的節點矢量。控制頂點由pi,0=pi和pi,1=pi+dw給出,權值wi,0=wi,1=wi。如下圖所示為一般柱面:

OpenCASCADE Linear Extrusion Surface

figure 2.1 a general cylinder obtained by translating c(u) a distance d along w.

其中opencascade中一般柱面的表達式如下所示:

OpenCASCADE Linear Extrusion Surface

其取值範圍的代碼如下所示:

由上代碼可知,參數在v方向上是趨于無窮的;在u方向上參數的範圍為曲線的範圍。計算柱面上點的方法代碼如下所示:

即将柱面上點先按v方向來計算,再按u方向來計算,最後将兩個方向的值相加即得到柱面上的點。

由上述代碼可知,opencascade中一般柱面沒有使用nurbs曲面來表示。根據這個方法,可以将任意曲線沿給定的方向來得到一個柱面,這個曲線可以是直線、圓弧、圓、橢圓等。關于柱面上更多算法,如求微分等,可以參考源程式。

3.display the surface

還是在openscenegraph中來對一般柱面進行可視化,來驗證結果。因為openscenegraph的簡單易用,顯示曲面的程式代碼如下所示:

上述顯示方法隻是顯示線框的最簡單的算法,隻為驗證一般柱面結果,不是高效算法。顯示結果如下圖所示:

OpenCASCADE Linear Extrusion Surface

figure 3.1 general cylinder for: circle, arc, line

如上圖所示分别為對圓、圓弧和直線進行拉伸得到的一般柱面。根據這個原理可以将任意曲線沿給定方向進行拉伸得到一個柱面。

4.conclusion

通 過對opencascade中一般柱面的類中代碼進行分析可知,opencascade的這個線性拉伸柱面 geom_surfaceoflinearextrusion是根據一般柱面的定義實作的,并不是使用nurbs曲面來表示的。當需要用nurbs曲面來 表示一般柱面時,需要注意控制頂點及權值的計算取值。

5. references

1. 趙罡,穆國旺,王拉柱譯. 非均勻有理b樣條. 清華大學出版社. 2010

2. les piegl, wayne tiller. the nurbs book. springer-verlag. 1997

3. opencascade team, opencascade brep format. 2014

4. donald hearn, m. pauline baker. computer graphics with opengl. prentice hall. 2009

5. 莫蓉,常智勇. 計算機輔助幾何造型技術. 科學出版社. 2009

繼續閱讀