• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            eryar

            PipeCAD - Plant Piping Design Software.
            RvmTranslator - Translate AVEVA RVM to OBJ, glTF, etc.
            posts - 603, comments - 590, trackbacks - 0, articles - 0

            OpenCASCADE Make Primitives-Sphere

            Posted on 2014-11-22 17:52 eryar 閱讀(2568) 評論(0)  編輯 收藏 引用 所屬分類: 2.OpenCASCADE

            OpenCASCADE Make Primitives-Sphere

            eryar@163.com

            Abstract. The sphere is the simplest topology shape of the BRep structure. But there are several import concept of the sphere edges, such as degenerated edge and seam edge. So construct a sphere by code, you will learn these.

            Key Words. OpenCASCADE, Sphere, BRep

            1. Introduction

            球體(sphere)是邊界表示法(BRep)中最簡單的一個拓樸形狀了,因為它直接由球面來構造。但是其中包含了一些重要的概念,如退化邊(degenerated edge)、銜接邊(seam edge)。由代碼手工來構造一個球體,可以學習這些概念。首先要知道OpenCASCADE中球面的參數方程:

            wps_clip_image-28720

            在Draw Test Harness中顯示如下圖所示:

            wps_clip_image-6776

            Figure 1.1 Sphere in Draw Test Harness

            由球面的參數方程可知,當參數u=0或2PI時,對應球面上的點就是上圖所示的綠線,實際上是由兩個線重合在一起了。

            當參數v=-PI/2或PI/2時,對應球面上兩個極點,因為球面的兩個極點處法向為零,而球面在兩個極點處的法向是存在的,所以這樣的點即為邊退化而成,稱為退化邊。

            三維曲線圓的參數方程如下所示:

            wps_clip_image-15160

            通過代碼從點開始來構造一個球體,從而來加深理解OpenCASCADE的BRep表示法。

            2.Make the Sphere

            2.1 Make Vertex

            從頂點開始來創建球體。因為球體就是一個球面,為了得到Face的Wire,需要構造一個閉合的區域。這里選擇兩個極點作為球體的頂點。創建球體的兩個極點,程序代碼如下所示:

            // make the north and south poles.
            aBuilder.MakeVertex(aNorthPole, aPoints[0], Precision::Confusion());
            aBuilder.MakeVertex(aSouthPole, aPoints[
            1], Precision::Confusion());

            2.2 Make Edge

            為了得到閉合的Wire,需要四條邊,其中在球面兩個極點處的兩條退化邊,還有連接兩個極點的重合的銜接邊。創建邊的代碼如下所示:

            // make the seam edge with the 3D geometry curve.
            aBuilder.MakeEdge(aSeamEdge, new Geom_Circle(aCircle), Precision::Confusion());

            // there is no 3D geometry curve in the degenerated edge.
            aBuilder.MakeEdge(aNorthEdge);
            aBuilder.Degenerated(aNorthEdge, Standard_True);

            // there is no 3D geometry curve in the degenerated edge.
            aBuilder.MakeEdge(aSouthEdge);
            aBuilder.Degenerated(aSouthEdge, Standard_True);

            // set the vertex info of the seam edges.
            {
                TopoDS_Vertex V1 
            = aNorthPole;
                TopoDS_Vertex V2 
            = aSouthPole;

                V1.Reverse();

                aBuilder.Add(aSeamEdge, V1);
                aBuilder.Add(aSeamEdge, V2);

                aBuilder.UpdateVertex(V1, ElCLib::Parameter(aCircle, aPoints[
            0]), aSeamEdge, Precision::Confusion());
                    
              aBuilder.UpdateVertex(V2, ElCLib::Parameter(aCircle, aPoints[
            1]), aSeamEdge, Precision::Confusion());

                BRepTools::Update(aSeamEdge);
            }

            // set the vertex info of the north degenerated edge.
            {
                TopoDS_Vertex V1 
            = aNorthPole;
                TopoDS_Vertex V2 
            = aNorthPole;

                V2.Reverse();

                aBuilder.Add(aNorthEdge, V1);
                aBuilder.Add(aNorthEdge, V2);

                BRepTools::Update(aNorthEdge);
            }

            // set the vertex info of the south degenerated edge.
            {
                TopoDS_Vertex V1 
            = aSouthPole;
                TopoDS_Vertex V2 
            = aSouthPole;

                V2.Reverse();

                aBuilder.Add(aSouthEdge, V1);
                aBuilder.Add(aSouthEdge, V2);

                BRepTools::Update(aSouthEdge);
            }

            由上述代碼可知,銜接邊中包含了幾何信息:三維曲線圓;退化邊中未包含幾何信息,但將其退化邊屬性設置為true。之后將邊上頂點在曲線上對應的參數值設置到邊中,退化邊不需要設置。

            2.3 Make Wire

            創建Wire需要確保組成Wire的邊要閉合。程序代碼如下所示:


            // make wire.
            aBuilder.MakeWire(aWire);

            // add edges to the wire.
            {
                TopoDS_Edge E1 
            = aNorthEdge;
                TopoDS_Edge E2 
            = aSeamEdge;
                TopoDS_Edge E3 
            = aSouthEdge;
                TopoDS_Edge E4 
            = aSeamEdge;

                E1.Reverse();
                E4.Reverse();

                aBuilder.Add(aWire, E1);
                aBuilder.Add(aWire, E2);
                aBuilder.Add(aWire, E3);
                aBuilder.Add(aWire, E4);

                BRepTools::Update(aWire);
            }

            2.4 Make Face

            創建面后,將邊與面關聯起來至關重要,即PCurve的設置。程序代碼如下所示:


            // make face.
            aBuilder.MakeFace(aFace, new Geom_SphericalSurface(aSphere), Precision::Confusion());

            // set the pcurve info between edge and face.
            {
                aBuilder.Range(aNorthEdge, 
            0.02 * M_PI);
                aBuilder.UpdateEdge(aNorthEdge, 
            new Geom2d_Line(aLines[0]), aFace, Precision::Confusion());

                aBuilder.Range(aSeamEdge, 
            1.5 * M_PI, 2.5 * M_PI);
                aBuilder.UpdateEdge(aSeamEdge, 
            new Geom2d_Line(aLines[1]), new Geom2d_Line(aLines[2]), aFace, Precision::Confusion());
                aBuilder.Continuity(aSeamEdge, aFace, aFace, GeomAbs_CN);
                    
                aBuilder.Range(aSouthEdge, 
            0.02 * M_PI);
                aBuilder.UpdateEdge(aSouthEdge, 
            new Geom2d_Line(aLines[3]), aFace, Precision::Confusion());

                BRepTools::Update(aFace);
            }

            由上述代碼可知,球面中包含了一個幾何的曲面。創建球面后,將相關的邊與面關聯起來。參數曲線PCurve的范圍Range在球面的參數空間中應該閉合。其中兩個退化邊的范圍都是從0到2PI,而銜接邊的范圍設置不當,會產生不正確的結果,如下圖所示:

            wps_clip_image-29088

            Figure 2.4.1 Seam Edge Range[-PI/2, PI/2]

            線框模式顯示正常,但是不能切換到渲染模式,即不能顯示出面。結合其PCurve的范圍可以發現組成Wire的邊的PCurve不能閉合。

            當Seam邊的三維曲線方向不當時,會不與球面的Seam重合,如下圖所示:

            wps_clip_image-24089

            Figure 2.4.2 Circle in Seam Edge Range [-PI/2, PI/2]

            wps_clip_image-7311

            Figure 2.4.3 Wrong Seam Edge Geometry Curve

            wps_clip_image-31932

            Figure 2.4.4 Wrong Seam Edge Geometry Curve

            3. Test the Sphere

            正確生成球體后導出為brep文件即可以在Draw Test Harness中來顯示及進行一些操作來驗證結果的正確性。在Draw Test Harness中打開brep文件并顯示球體如下圖所示:

            wps_clip_image-21495

            Figure 3.1 Show the Sphere from file in Draw Test Harness

            將其與一個長方體進行布爾運算,效果如下圖所示:

            wps_clip_image-18355

            Figure 3.2 Spher and a Box

            wps_clip_image-7716

            Figure 3.3 Sphere cut a Box

            由上圖可知,球體與長方體布爾運算結果正確。

            4. Conclusion

            通過生成一個球體,示例了特殊邊的構造,如退化邊和銜接邊。需要注意的事項還是組成Wire的所有邊中的PCurve必須在面的參數空間中閉合。由PCurve可知,球面對應的參數空間不是幾何曲面的范圍,而是在v方向上偏移了2PI。

            5. References

            1. OpenCascade Primitives BRep - Sphere,  

            http://www.shnenglu.com/eryar/archive/2014/03/22/206279.html

            2. PCurve - Curve on Surface, 

            http://www.shnenglu.com/eryar/archive/2014/03/15/206180.html

            3. Topology and Geometry in OpenCascade-Face, 

            http://www.shnenglu.com/eryar/archive/2013/09/12/203199.html

             

            PDF Version and Source code: OpenCASCADE Make Primitives - Sphere

            www久久久天天com| 性做久久久久久免费观看| 久久久久久久97| 久久亚洲春色中文字幕久久久| 久久婷婷五月综合97色直播| MM131亚洲国产美女久久| 一级做a爰片久久毛片人呢| 婷婷久久综合九色综合九七| 亚洲综合日韩久久成人AV| 久久se精品一区二区| 久久午夜综合久久| 精品久久8x国产免费观看| 亚洲精品国产自在久久| 综合久久给合久久狠狠狠97色| 精品久久人人妻人人做精品| 欧美va久久久噜噜噜久久| 久久久久噜噜噜亚洲熟女综合| 国产aⅴ激情无码久久| 久久精品国产精品亚洲下载 | 国产精品嫩草影院久久| 少妇人妻综合久久中文字幕| 久久久久久久99精品免费观看| 久久午夜无码鲁丝片秋霞| 久久久久无码精品国产app| 麻豆精品久久精品色综合| 久久久婷婷五月亚洲97号色 | 99久久www免费人成精品| 久久久久青草线蕉综合超碰 | 中文字幕精品久久久久人妻| 激情综合色综合久久综合| 久久精品国产只有精品2020| 一本久久a久久精品vr综合| 久久久久久免费视频| 亚洲精品综合久久| 亚洲国产精品成人久久蜜臀 | 国产精品一区二区久久不卡| 亚洲国产另类久久久精品| 亚洲精品乱码久久久久久蜜桃不卡| 久久久久久久免费视频| 久久国产劲爆AV内射—百度| 99久久夜色精品国产网站|