• <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 閱讀(2590) 評論(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)中最簡單的一個拓樸形狀了,因為它直接由球面來構(gòu)造。但是其中包含了一些重要的概念,如退化邊(degenerated edge)、銜接邊(seam edge)。由代碼手工來構(gòu)造一個球體,可以學(xué)習(xí)這些概念。首先要知道OpenCASCADE中球面的參數(shù)方程:

            wps_clip_image-28720

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

            wps_clip_image-6776

            Figure 1.1 Sphere in Draw Test Harness

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

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

            三維曲線圓的參數(shù)方程如下所示:

            wps_clip_image-15160

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

            2.Make the Sphere

            2.1 Make Vertex

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

            // 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,需要四條邊,其中在球面兩個極點處的兩條退化邊,還有連接兩個極點的重合的銜接邊。創(chuàng)建邊的代碼如下所示:

            // 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);
            }

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

            2.3 Make Wire

            創(chuàng)建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

            創(chuàng)建面后,將邊與面關(guān)聯(lián)起來至關(guān)重要,即PCurve的設(shè)置。程序代碼如下所示:


            // 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);
            }

            由上述代碼可知,球面中包含了一個幾何的曲面。創(chuàng)建球面后,將相關(guān)的邊與面關(guān)聯(lián)起來。參數(shù)曲線PCurve的范圍Range在球面的參數(shù)空間中應(yīng)該閉合。其中兩個退化邊的范圍都是從0到2PI,而銜接邊的范圍設(shè)置不當(dāng),會產(chǎn)生不正確的結(jié)果,如下圖所示:

            wps_clip_image-29088

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

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

            當(dāng)Seam邊的三維曲線方向不當(dāng)時,會不與球面的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

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

            wps_clip_image-21495

            Figure 3.1 Show the Sphere from file in Draw Test Harness

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

            wps_clip_image-18355

            Figure 3.2 Spher and a Box

            wps_clip_image-7716

            Figure 3.3 Sphere cut a Box

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

            4. Conclusion

            通過生成一個球體,示例了特殊邊的構(gòu)造,如退化邊和銜接邊。需要注意的事項還是組成Wire的所有邊中的PCurve必須在面的參數(shù)空間中閉合。由PCurve可知,球面對應(yīng)的參數(shù)空間不是幾何曲面的范圍,而是在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

            久久艹国产| 久久精品国产只有精品66| 久久这里只有精品首页| 久久精品国产男包| 99国产欧美久久久精品蜜芽| 伊人久久免费视频| 亚洲午夜精品久久久久久app| 亚洲中文字幕无码久久2020| 色综合久久天天综合| 欧美久久久久久精选9999| 久久久久人妻一区二区三区vr| 国产成人AV综合久久| 伊人久久大香线蕉精品不卡| 99久久国产免费福利| 日产精品99久久久久久| 亚洲国产成人久久一区WWW| 国产精品久久久久国产A级| 亚洲伊人久久综合影院| 色综合久久中文综合网| 亚洲AV无码一区东京热久久 | 人妻无码中文久久久久专区| 久久久99精品成人片中文字幕| 色综合久久久久久久久五月| 日韩欧美亚洲国产精品字幕久久久| 久久久久久久亚洲Av无码| 久久久精品人妻一区二区三区蜜桃| 爱做久久久久久| 日本免费一区二区久久人人澡| 日产精品99久久久久久| 亚洲av成人无码久久精品| 久久婷婷是五月综合色狠狠| 久久一区二区免费播放| 久久久久九国产精品| 久久AⅤ人妻少妇嫩草影院| Xx性欧美肥妇精品久久久久久 | 久久福利片| 91精品国产色综久久| 天天久久狠狠色综合| 品成人欧美大片久久国产欧美...| 日韩精品久久久久久| 久久se这里只有精品|