• <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 閱讀(2591) 評論(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://m.shnenglu.com/eryar/archive/2014/03/22/206279.html

            2. PCurve - Curve on Surface, 

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

            3. Topology and Geometry in OpenCascade-Face, 

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

             

            PDF Version and Source code: OpenCASCADE Make Primitives - Sphere

            久久播电影网| 亚洲国产成人精品女人久久久| 久久精品中文字幕无码绿巨人| 久久国产色av免费看| 香蕉99久久国产综合精品宅男自 | 久久婷婷人人澡人人| 国内精品久久久久久麻豆| 亚洲国产小视频精品久久久三级| 亚洲婷婷国产精品电影人久久 | 久久精品国产亚洲网站| 久久影院午夜理论片无码| 中文字幕久久久久人妻| 色综合合久久天天综合绕视看| 久久久久国产一级毛片高清板| 中文字幕乱码人妻无码久久| 国产精品久久免费| 综合人妻久久一区二区精品| 99久久婷婷国产一区二区| 无码日韩人妻精品久久蜜桃 | 久久精品国产男包| 久久久久久噜噜精品免费直播 | 国内精品久久国产| 国产高清美女一级a毛片久久w| 日韩精品久久无码中文字幕| 久久国产精品波多野结衣AV| 国产69精品久久久久777| 亚洲国产视频久久| 精品国产乱码久久久久久浪潮| 久久国产色AV免费看| 久久久久久久女国产乱让韩| 久久久久久亚洲精品不卡| 久久天堂电影网| 2021国产成人精品久久| 久久精品国产只有精品2020| 国产亚洲欧美精品久久久| 亚洲中文字幕无码久久2020| 久久久久亚洲AV片无码下载蜜桃 | 久久精品国产99久久久香蕉| 久久人人爽爽爽人久久久| 无码国内精品久久综合88| 欧美一级久久久久久久大|