• <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) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): 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)中最簡(jiǎn)單的一個(gè)拓樸形狀了,因?yàn)樗苯佑汕蛎鎭?lái)構(gòu)造。但是其中包含了一些重要的概念,如退化邊(degenerated edge)、銜接邊(seam edge)。由代碼手工來(lái)構(gòu)造一個(gè)球體,可以學(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時(shí),對(duì)應(yīng)球面上的點(diǎn)就是上圖所示的綠線,實(shí)際上是由兩個(gè)線重合在一起了。

            當(dāng)參數(shù)v=-PI/2或PI/2時(shí),對(duì)應(yīng)球面上兩個(gè)極點(diǎn),因?yàn)榍蛎娴膬蓚€(gè)極點(diǎn)處法向?yàn)榱悖蛎嬖趦蓚€(gè)極點(diǎn)處的法向是存在的,所以這樣的點(diǎn)即為邊退化而成,稱(chēng)為退化邊。

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

            wps_clip_image-15160

            通過(guò)代碼從點(diǎn)開(kāi)始來(lái)構(gòu)造一個(gè)球體,從而來(lái)加深理解OpenCASCADE的BRep表示法。

            2.Make the Sphere

            2.1 Make Vertex

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

            // 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,需要四條邊,其中在球面兩個(gè)極點(diǎn)處的兩條退化邊,還有連接兩個(gè)極點(diǎn)的重合的銜接邊。創(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。之后將邊上頂點(diǎn)在曲線上對(duì)應(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)起來(lái)至關(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);
            }

            由上述代碼可知,球面中包含了一個(gè)幾何的曲面。創(chuàng)建球面后,將相關(guān)的邊與面關(guān)聯(lián)起來(lái)。參數(shù)曲線PCurve的范圍Range在球面的參數(shù)空間中應(yīng)該閉合。其中兩個(gè)退化邊的范圍都是從0到2PI,而銜接邊的范圍設(shè)置不當(dāng),會(huì)產(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)時(shí),會(huì)不與球面的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中來(lái)顯示及進(jìn)行一些操作來(lái)驗(yàn)證結(jié)果的正確性。在Draw Test Harness中打開(kāi)brep文件并顯示球體如下圖所示:

            wps_clip_image-21495

            Figure 3.1 Show the Sphere from file in Draw Test Harness

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

            wps_clip_image-18355

            Figure 3.2 Spher and a Box

            wps_clip_image-7716

            Figure 3.3 Sphere cut a Box

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

            4. Conclusion

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

            99久久中文字幕| 久久久噜噜噜久久中文字幕色伊伊 | 色婷婷狠狠久久综合五月| 久久97久久97精品免视看秋霞| 久久伊人影视| 麻豆一区二区99久久久久| avtt天堂网久久精品| 久久精品国产精品亜洲毛片| 色婷婷久久综合中文久久一本| 久久人人爽人人爽人人AV| 久久精品免费大片国产大片| 中文字幕乱码人妻无码久久| 久久精品无码一区二区三区| 天天综合久久一二三区| 久久久久AV综合网成人| 欧美精品福利视频一区二区三区久久久精品 | 久久精品国产一区二区三区 | 久久夜色精品国产亚洲| 国产精品美女久久久久网| 伊人久久久AV老熟妇色| 丁香五月综合久久激情| 精品综合久久久久久97| 亚洲人成电影网站久久| 欧美久久一区二区三区| 久久精品国产久精国产| 性欧美丰满熟妇XXXX性久久久 | 新狼窝色AV性久久久久久| 久久精品国产亚洲Aⅴ香蕉| 91精品国产91久久综合| 亚洲中文字幕无码久久精品1| 日本久久久久久久久久| 久久99精品九九九久久婷婷| 久久午夜电影网| 精品国产VA久久久久久久冰| 无码AV波多野结衣久久| 一本色道久久HEZYO无码| 久久中文字幕人妻熟av女| 日本久久中文字幕| 久久精品国产欧美日韩99热| 日日狠狠久久偷偷色综合0| 久久99精品久久久久久9蜜桃|