• <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中散亂Edge生成Wire

            Posted on 2018-05-20 21:50 eryar 閱讀(2219) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 2.OpenCASCADE

            OpenCASCADE中散亂Edge生成Wire

            eryar@163.com

            Abstract. In OpenCASCADE a wire can be built from any number of edges in sequence. If edges are not in sequence, you must sort them in order.

            Key Words. Edge, Wire, Wire order

            1. Introduction

            在OpenCASCADE中生成WIRE時(shí)要求添加到WIRE中的邊EDGE是有順序要求的。當(dāng)給定的邊沒(méi)有按順序添加到WIRE之前,需要自己將EDGE按順序處理。OpenCASCADE中也提供了對(duì)EDGE按順序進(jìn)行排序的功能,方便WIRE的生成。

            本文給出將散亂的EDGE排序后生成WIRE的實(shí)現(xiàn)代碼,這個(gè)功能用處還是很大的。

            2. Code 

            在模型檢查模塊TKShHealing中,OpenCASCADE提供了類ShapeAnalysis_WireOrder用來(lái)將用于生成WIRE的一系列EDGE進(jìn)行排序。這個(gè)類的實(shí)現(xiàn)原理是根據(jù)EDGE的起點(diǎn)、終點(diǎn)坐標(biāo)來(lái)進(jìn)行連接,生成順序。

            如下圖所示為一個(gè)封閉的WIRE,根據(jù)這些尺寸標(biāo)注,生成WIRE的EDGE。

            wps_clip_image-18201

            實(shí)現(xiàn)上述Wire的程序代碼如下所示:

            /*
            The MIT License (MIT)
            ---------------------
            Copyright(C) 2018 Shing Liu(eryar@163.com)
            Permission is hereby granted, free of charge, to any person obtaining a copy
            of this software and associated documentation files(the "Software"), to deal
            in the Software without restriction, including without limitation the rights
            to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
            copies of the Software, and to permit persons to whom the Software is
            furnished to do so, subject to the following conditions :
            The above copyright notice and this permission notice shall be included in all
            copies or substantial portions of the Software.
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
            SOFTWARE.
            */
            #include <vector>
            #include <gp_Pnt.hxx>
            #include <gp_Circ.hxx>
            #include <TopTools_ListOfShape.hxx>
            #include <BRep_Tool.hxx>
            #include <BRepTools.hxx>
            #include <BRepBuilderAPI_MakeEdge.hxx>
            #include <BRepBuilderAPI_MakeWire.hxx>
            #include <ShapeAnalysis_Edge.hxx>
            #include <ShapeAnalysis_WireOrder.hxx>
            #pragma comment(lib, "TKernel.lib")
            #pragma comment(lib, "TKMath.lib")
            #pragma comment(lib, "TKG2d.lib")
            #pragma comment(lib, "TKG3d.lib")
            #pragma comment(lib, "TKGeomBase.lib")
            #pragma comment(lib, "TKGeomAlgo.lib")
            #pragma comment(lib, "TKBRep.lib")
            #pragma comment(lib, "TKTopAlgo.lib")
            #pragma comment(lib, "TKShHealing.lib")
            void test(void)
            {
                std::vector<TopoDS_Edge> anEdges;
                // 5 Segment edges.
                BRepBuilderAPI_MakeEdge anEdgeMaker1(
                    gp_Pnt(-1650.0, 2857.88383249, 0.0),
                    gp_Pnt(-750.0, 1299.03810568, 0.0));
                BRepBuilderAPI_MakeEdge anEdgeMaker2(
                    gp_Pnt(1299.03810568, 750.0, 0.0),
                    gp_Pnt(2857.88383249, 1650.0, 0.0));
                BRepBuilderAPI_MakeEdge anEdgeMaker3(
                    gp_Pnt(2857.88383249, 1650.0, 0.0),
                    gp_Pnt(8000.0, 1650.0, 0.0));
                BRepBuilderAPI_MakeEdge anEdgeMaker4(
                    gp_Pnt(8000.0, 1650.0, 0.0),
                    gp_Pnt(8000.0, -3300.0, 0.0));
                BRepBuilderAPI_MakeEdge anEdgeMaker5(
                    gp_Pnt(8000.0, -3300.0, 0.0),
                    gp_Pnt(0.0, -3300.0, 0.0));
                anEdges.push_back(anEdgeMaker1.Edge());
                anEdges.push_back(anEdgeMaker2.Edge());
                anEdges.push_back(anEdgeMaker3.Edge());
                anEdges.push_back(anEdgeMaker4.Edge());
                anEdges.push_back(anEdgeMaker5.Edge());
                // 2 Arc edges.
                gp_Circ aCircle1(gp::XOY(), 1500.0);
                gp_Circ aCircle2(gp::XOY(), 3300.0);
                BRepBuilderAPI_MakeEdge anEdgeMaker6(aCircle1,
                    gp_Pnt(-750.0, 1299.03810568, 0.0),
                    gp_Pnt(1299.03810568, 750.0, 0.0));
                BRepBuilderAPI_MakeEdge anEdgeMaker7(aCircle2,
                    gp_Pnt(-1650.0, 2857.88383249, 0.0),
                    gp_Pnt(0.0, -3300.0, 0.0));
                anEdges.push_back(anEdgeMaker6.Edge());
                anEdges.push_back(anEdgeMaker7.Edge());
                // Get edges order for the wire.
                ShapeAnalysis_Edge anEdgeAnalyser;
                ShapeAnalysis_WireOrder aWireOrder;
                for (std::vector<TopoDS_Edge>::const_iterator i = anEdges.begin();
                    i != anEdges.end(); ++i)
                {
                    TopoDS_Vertex aVf = anEdgeAnalyser.FirstVertex(*i);
                    TopoDS_Vertex aVl = anEdgeAnalyser.LastVertex(*i);
                    gp_Pnt aPf = BRep_Tool::Pnt(aVf);
                    gp_Pnt aPl = BRep_Tool::Pnt(aVl);
                    aWireOrder.Add(aPf.XYZ(), aPl.XYZ());
                }
                // 
                TopTools_ListOfShape aOrderedEdges;
                for (Standard_Integer e = 1; e <= aWireOrder.NbEdges(); ++e)
                {
                    const TopoDS_Edge& anEdge = anEdges.at(e - 1);
                    aOrderedEdges.Append(anEdge);
                }
                BRepBuilderAPI_MakeWire aWireMaker;
                aWireMaker.Add(aOrderedEdges);
                if (aWireMaker.IsDone())
                {
                    BRepTools::Write(aWireMaker.Shape(), "d:/wire.brep");
                }
            }
            int main(int argc, char* argv[])
            {
                test();
                return 0;
            }

            程序先添加5條線段到EDGE數(shù)組,再添加兩個(gè)圓弧到EDGE數(shù)組。再使用類ShapeAnalysis_WireOrder來(lái)對(duì)EDGE數(shù)組進(jìn)行排序,將排序后的EDGE數(shù)組去生成WIRE。如果生成WIRE成功,會(huì)在D盤得到一個(gè)wire.brep文件。在Draw中加載后顯示如下圖所示:

            wps_clip_image-1190

            生成WIRE后,繼而可以生成FACE,對(duì)FACE進(jìn)行拉伸可以得到拉伸體,如下圖所示:

            wps_clip_image-9137

            3. Conclusion

            OpenCASCADE中生成WIRE時(shí)對(duì)添加的EDGE是有順序的要求。如何對(duì)散亂的EDGE進(jìn)行排序以達(dá)到生成WIRE的要求呢?OpenCASCADE在TKShHealing模塊中提供了對(duì)EDGE排序的功能。

            對(duì)EDGE排序的功能原理很簡(jiǎn)單,就是將所有的EDGE首尾相連,感興趣的讀者可以結(jié)合源碼學(xué)習(xí)下。



            為了方便大家在移動(dòng)端也能看到我的博文和討論交流,現(xiàn)已注冊(cè)微信公眾號(hào),歡迎大家掃描下方二維碼關(guān)注。
            Shing Liu(eryar@163.com)

             

            国产精品久久成人影院| 99久久夜色精品国产网站 | 狠狠久久综合伊人不卡| 久久精品国产亚洲综合色| 久久99精品久久久久久野外| 久久人妻少妇嫩草AV无码蜜桃| 中文字幕乱码人妻无码久久| 亚洲一区中文字幕久久| 久久精品久久久久观看99水蜜桃| 久久午夜夜伦鲁鲁片免费无码影视 | 久久久久无码专区亚洲av| 国产香蕉久久精品综合网| 久久综合九色综合欧美狠狠| 97久久婷婷五月综合色d啪蜜芽| 66精品综合久久久久久久| 亚洲国产精品成人久久| 久久99精品国产麻豆不卡| 2021久久国自产拍精品| 国产精品一区二区久久精品涩爱 | 久久久免费观成人影院 | 精品午夜久久福利大片| 亚洲伊人久久成综合人影院| 亚洲欧美精品伊人久久| 91久久婷婷国产综合精品青草| 亚洲精品视频久久久| 久久精品无码一区二区三区免费| 精品久久久久久亚洲精品| 亚洲中文字幕无码久久2020| 伊人久久大香线蕉AV一区二区| 久久这里只有精品久久| 久久99精品综合国产首页| 99久久成人国产精品免费| 人妻精品久久无码区| 久久综合给合久久狠狠狠97色69| 亚洲精品高清一二区久久| 欧美与黑人午夜性猛交久久久| 久久久久亚洲精品天堂久久久久久 | 国产精品99久久久久久董美香| 狠狠色丁香婷婷综合久久来| 久久免费高清视频| 88久久精品无码一区二区毛片|