• <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中的gp包

            Posted on 2012-06-30 20:21 eryar 閱讀(4833) 評論(0)  編輯 收藏 引用 所屬分類: 2.OpenCASCADE

            Package gp in the OpenCASCADE

            eryar@163.com China

            一、簡介 Introduction to Package gp

            gp是幾何處理程序包(Geometric Processor package),簡稱gp。包gp提供以下功能:

            • 代數計算;如坐標計算、矩陣計算;
            • 基本解析幾何元素;如變換、點、矢量、線、面、軸、二次曲線和初等曲面;

            這些實體同時在二維和三維空間中定義,且包中的類都是非持續的(non-persistent),即這些類的實例都是以值的方式處理而不是引用。當復制這種對象時,是對象本體。改變一個實例不會影響到其他的實例。

            可用的幾何實體如下所示:

            1. 2D&3D Cartesian coordinates(x,y,z); 二維&三維笛卡爾坐標;
            2. Matrices; 矩陣;
            3. Cartesian points; 笛卡爾坐標點;
            4. Vector; 矢量;
            5. Direction; 方向;
            6. Axis; 軸;
            7. Line; 直線;
            8. Circle; 圓;
            9. Ellipse; 橢圓;
            10. Hyperbola; 雙曲線;
            11. Parabola; 拋物線;
            12. Plane; 面;
            13. Infinite cylindrical surface; 柱面;
            14. Spherical surface; 球面;
            15. Toroidal surface; 環面;
            16. Conical surface; 錐面;
            二、幾何元素的集合 Collections of Primitive Geometric Types

            創建幾何對象之前,根據你是將幾何對象用于二維還是三維來確定。若你需要一個幾何對象集而不是單一的幾何對象,即用來處理一類幾何元素,包TColgp就是提供這種功能的。

            Package TColgp提供類如:XY, XYZ, Pnt, Pnt2d, Vec, Vec2d, Lin, Lin2D, Circ, Circ2dTCollection的實例。包中的類簡單列舉如下:

            • TColgp_Array1OfCirc;
            • TColgp_Array1OfDir;
            • TColgp_Array1OfPnt;
            • TColgp_Array1OfVec;
            • TColgp_Array2OfCirc2d;
            • TColgp_Array2OfPnt;
            • TColgp_HArray1OfCirc2d;
            • TColgp_HArray2OfDir;
            • TColgp_HSequenceOfDir;
            • TColgp_SequenceOfDir;
            • TColgp_SequenceOfPnt;
            • TColgp_SequenceOfXYZ;

            個人意見,若使用標準C++的容器類(The STL Template Container),就不需要創建這么多類了。

            三、基本幾何庫 Basic Geometric Libraries

            有幾個庫提供了曲線和曲面的基本計算功能。若要處理由包gp創建的幾何對象,初等曲線曲面的有用算法庫在包:ElCLibElSLib中。包Precision提供兩個數字比較的功能。

            • Package ElCLib; ElCLib代表:Elementary Curves Library. 提供初等曲線曲面的基本幾何計算功能;
            • Package ElSLib; ElSLib代表:Elementary Surfaces Library. 提供初等曲面的基本幾何計算。
            • Package Bnd;提供二維和三維空間中幾何元素包圍盒的計算功能;
            • Package Precision; 由于浮點數在計算機內實際上是一個近似表示,在手工計算看來為正確的結果,在計算機中運算未必得出正確的結果。所以,我們得到一個重要的經驗:使用浮點數進行相等(==)和不等(!=)比較的操作通常是有問題的。浮點數的相等比較,一般總是使用兩者相減的值是否落在0的鄰域中來判斷。這就是鄰域比較技術。在OpenCASCADE中專門提供包Precision來處理兩個數值的比較問題。
            四、代碼示例 Code Sample
            //------------------------------------------------------------------------------
            //    Copyright (c) 2012 eryar All Rights Reserved.
            //
            //        File    : Main.cpp
            //        Author  : eryar@163.com
            //        Date    : 2012-6-23 21:30
            //        Version : 1.0v
            //
            //    Description : Test primitive Geometric Types in OpenCASCADE.
            //
            //      The Geometric Processor package, called gp.
            //
            //      The pg package offers classes for both 2D and 3D objects which
            //      are handled by value rather than by reference. When this sort of object
            //      is copied, it is copied entirely. Changes in one instance will not be 
            //      reflected in another.
            //
            //==============================================================================
             
            // Use Toolkit TKernel.
            #pragma comment(lib,"TKernel.lib")
            // Use Toolkit TKMath.
            #pragma comment(lib, "TKMath.lib")
             
            #include <gp.hxx>
            #include <gp_Pnt.hxx>
            #include <gp_Trsf.hxx>
            #include <Precision.hxx>
             
            void DumpPoint(const gp_Pnt& p);
             
            int main(int argc, char* argv[])
            {
                gp_Pnt  aPoint(0, 0, 0);
             
                // 1. Translate a point in a direction.
                // The direction determined by a gp_Vec or two gp_Pnt.
                cout<<"Before translated:";
                DumpPoint(aPoint);
             
                aPoint.Translate(gp_Pnt(2, 2, 3), gp_Pnt(10, 10, 0));
             
                cout<<"After translated:";
                DumpPoint(aPoint);
             
                // 2. Rotate a point.
                // Rotate a point by an axis and the rotate angle.
                cout<<"Before rotated:";
                DumpPoint(aPoint);
             
                // Roate 45 degree about Z axis.
                // Positive angle value will be rotated counterclockwise.
                aPoint.Rotate(gp::OZ(), PI/4);
                
                cout<<"After rotated 45 degree about Z axis:";
                DumpPoint(aPoint);
             
                // 2.1 Test Package Precision.
                if (aPoint.X() < Precision::Confusion() && aPoint.X() > -Precision::Confusion())
                {
                    cout<<"Point X value:"<<aPoint.X()<<endl;
                    cout<<"Precision::Confusion() value:"<<Precision::Confusion()<<endl;
                }
             
                aPoint.Rotate(gp::OZ(), PI/4);
                cout<<"After rotate 45 degree about Z axis:";
                DumpPoint(aPoint);
             
                // 3. Transform a point by gp_Trsf.
                gp_Trsf transform;
                transform.SetMirror(gp::OX());
             
                cout<<"Before gp_Trsf:";
                DumpPoint(aPoint);
             
                aPoint.Transform(transform);
             
                cout<<"After gp_Trsf:";
                DumpPoint(aPoint);
             
                // 4. Mirror a point.
                // 4.1 Performs the symmetrical transformation of
                // a point with respect to an axis placement which
                // is the axis of the symmetry.
                cout<<"Before mirrored with a symmetric axis:";
                DumpPoint(aPoint);
             
                aPoint.Mirror(gp::OY());
             
                cout<<"After mirrored with a symmetric axis:";
                DumpPoint(aPoint);
             
                // 4.2 Performs the symmetrical transformation of
                // a point with respect to a plane.
                cout<<"Before mirrored with a symmetric plane:";
                DumpPoint(aPoint);
             
                aPoint.Mirror(gp::XOY());
             
                cout<<"After mirrored with a symmetric plane";
                DumpPoint(aPoint);
             
                // 5. Scale a point.
                aPoint.SetCoord(1, 2, 1);
                cout<<"Before Scaled:";
                DumpPoint(aPoint);
             
                /*
                // Scale point source code...
                inline void gp_Pnt::Scale (const gp_Pnt& P,
                const Standard_Real S)
                {
                gp_XYZ XYZ = P.coord;
                XYZ.Multiply (1.0 - S);
                coord.Multiply (S);
                coord.Add      (XYZ);
                }
                */
             
                aPoint.Scale(gp_Pnt(1, 2, 2), 2);
             
                cout<<"After Scaled:";
                DumpPoint(aPoint);
             
                return 0;
            }
             
            /**
            * Description: Dump point information.
            */
            void DumpPoint( const gp_Pnt& p )
            {
                cout<<"("<<p.X()<<","<<p.Y()<<","<<p.Z()<<")"<<endl;
            }

            輸出結果如下:

               1:  Before translated:(0,0,0)
               2:  After translated:(8,8,-3)
               3:  Before rotated:(8,8,-3)
               4:  After rotated 45 degree about Z axis:(8.88178e-016,11.3137,-3)
               5:  Point X value:8.88178e-016
               6:  Precision::Confusion() value:1e-007
               7:  After rotate 45 degree about Z axis:(-8,8,-3)
               8:  Before gp_Trsf:(-8,8,-3)
               9:  After gp_Trsf:(-8,-8,3)
              10:  Before mirrored with a symmetric axis:(-8,-8,3)
              11:  After mirrored with a symmetric axis:(8,-8,-3)
              12:  Before mirrored with a symmetric plane:(8,-8,-3)
              13:  After mirrored with a symmetric plane(8,-8,3)
              14:  Before Scaled:(1,2,1)
              15:  After Scaled:(1,2,0)
              16:  Press any key to continue . . .

             

            五、結論

            gp提供了基本的幾何元素表示及初等解析幾何計算功能。對于幾何元素的集合也有自己的類庫。對于兩個數值的比較采用了鄰域比較技術。

            国产精品久久久久9999高清| 久久精品国产精品亚洲毛片| 99热成人精品免费久久| 国产精品欧美久久久久无广告 | 亚洲一区精品伊人久久伊人| 亚洲国产日韩综合久久精品| 久久久噜噜噜久久中文福利| 久久91精品久久91综合| 精品一久久香蕉国产线看播放| 久久午夜福利无码1000合集| 精品一区二区久久| 久久人人添人人爽添人人片牛牛| 色妞色综合久久夜夜| 色诱久久久久综合网ywww| 999久久久国产精品| 久久99精品久久久久久久不卡 | 一本久久a久久精品综合香蕉| 久久亚洲AV无码精品色午夜| 2021国产成人精品久久| 性欧美大战久久久久久久久| 亚洲精品国产自在久久| 久久精品18| 99久久国产主播综合精品| 国产精品久久久久影院色| 亚洲精品乱码久久久久久蜜桃不卡 | 久久亚洲AV成人出白浆无码国产 | 久久久久久国产精品免费无码| 久久黄色视频| 狠狠色丁香久久婷婷综合蜜芽五月| 93精91精品国产综合久久香蕉| 亚洲国产精品久久久久久| 国内精品久久久久国产盗摄| 草草久久久无码国产专区| 久久伊人色| 一本久久a久久精品亚洲| 久久综合狠狠综合久久| 国产精品禁18久久久夂久| 天天久久狠狠色综合| 久久亚洲中文字幕精品一区| 久久男人Av资源网站无码软件| 91精品国产高清91久久久久久|