• <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://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

            东方aⅴ免费观看久久av| 国产精品一区二区久久精品| 久久精品国产一区二区三区日韩| 国产免费久久精品99re丫y| 久久久精品波多野结衣| 狠狠久久综合| 精品久久久久久国产三级| 久久综合综合久久97色| 老司机国内精品久久久久| 久久综合九色综合网站| 99久久国产精品免费一区二区 | 久久久久久亚洲精品无码| 18岁日韩内射颜射午夜久久成人| 久久综合综合久久狠狠狠97色88| .精品久久久麻豆国产精品| 精品午夜久久福利大片| 99久久精品国产综合一区| 9999国产精品欧美久久久久久| 国产毛片久久久久久国产毛片 | AAA级久久久精品无码区| 国产一区二区精品久久凹凸| 精品无码久久久久久久动漫| 久久久国产亚洲精品| 久久国产精品无码一区二区三区| 狠狠干狠狠久久| 久久国产福利免费| 久久婷婷五月综合色99啪ak| 伊人久久综合无码成人网| 韩国三级大全久久网站| 久久综合成人网| 99久久免费国产精精品| 久久精品国产精品亚洲人人 | 久久精品国产亚洲综合色| 久久影视综合亚洲| 国产精品对白刺激久久久| 色播久久人人爽人人爽人人片aV| 精品久久久无码人妻中文字幕| 999久久久无码国产精品| 亚洲成av人片不卡无码久久| 国产一级做a爰片久久毛片| 久久久久久久久久久|