• <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 Law Function

            Posted on 2018-03-25 17:11 eryar 閱讀(1304) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): 2.OpenCASCADE

            OpenCascade Law Function

            eryar@163.com

            1.Introduction

            在OpenCASCADE的TKGeomAlgo Toolkit中提供了一個(gè)Law Package,在Law包中有一個(gè)基類(lèi):Law_Function,字面上翻譯為 規(guī)則函數(shù)。其類(lèi)圖如下所示:

            wps_clip_image-22828

            Figure 1. Law Function class diagram

            本文主要對(duì)Law_Function的子類(lèi)進(jìn)行介紹,進(jìn)一步理解OpenCASCADE中Law相關(guān)類(lèi)的作用。

            2.Law Functions

            根據(jù)Law_Function可知,Law_Function的子類(lèi)有常量規(guī)則Law_Constant、線(xiàn)性規(guī)則Law_Linear、組合規(guī)則Law_Composite及B樣條規(guī)則Law_BSpFunc。抽象類(lèi)Law_Function的純虛函數(shù)有:

            l Continuity(): 規(guī)則函數(shù)的連續(xù)性;

            l Value():計(jì)算對(duì)應(yīng)參數(shù)X的函數(shù)值Y;

            l D1():計(jì)算規(guī)則函數(shù)在參數(shù)X處的一階導(dǎo)數(shù);

            l D2():計(jì)算規(guī)則函數(shù)在參數(shù)X處的二階導(dǎo)數(shù);

            l Bounds():規(guī)則函數(shù)的定義區(qū)間;

            wps_clip_image-13300

            從上面的虛函數(shù)可以看出類(lèi)Law_Function是一個(gè)一元變量的函數(shù),與類(lèi)math_Function的功能類(lèi)似。

            3.Test Code

            下面的代碼將規(guī)則函數(shù)Law_Function的幾個(gè)子類(lèi)通過(guò)生成Draw腳本,在Draw Test Harness中進(jìn)行可視化,直觀地顯示出了幾個(gè)規(guī)則函數(shù),便于理解。

            /*
            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 <TColgp_Array1OfPnt2d.hxx>
            #include <Law_Constant.hxx>
            #include <Law_Linear.hxx>
            #include <Law_BSpFunc.hxx>
            #include <Law_S.hxx>
            #include <Law_Interpol.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")
            Standard_Integer aId = 0;
            void draw(const Handle(Law_Function)& theLaw, std::ostream& theOutput)
            {
                const Standard_Integer aStep = 20;
                Standard_Real aFirst = 0.0;
                Standard_Real aLast = 0.0;
                Standard_Real aDelta = 0.0;
                Standard_Real aX = 0.0;
                Standard_Real aY = 0.0;
                theLaw->Bounds(aFirst, aLast);
                aDelta = (aLast - aFirst) / aStep;
                theOutput << "polyline law" << ++aId;
                for (Standard_Integer i = 0; i <= aStep; ++i)
                {
                    aX = aFirst + i * aDelta;
                    aY = theLaw->Value(aX);
                    theOutput  << " " << aX << " " << aY << " 0.0";
                }
                theOutput << "\n vdisplay law" << aId << std::endl;
                theOutput << "vaspects law" << aId << " -setColor " << ((aId % 2) ? " red " : " yellow ") << std::endl;
            }
            void test(std::ostream& theOutput)
            {
                // 1. Constant law.
                Handle(Law_Constant) aConstantLaw = new Law_Constant();
                aConstantLaw->Set(2.0, 0.0, 1.0);
                draw(aConstantLaw, theOutput);
                // 2. Linear evolution law.
                Handle(Law_Linear) aLinearLaw = new Law_Linear();
                aLinearLaw->Set(1.0, 2.0, 3.0, 5.0);
                draw(aLinearLaw, theOutput);
                // 3. An "S" evolution law.
                Handle(Law_S) aSLaw = new Law_S();
                aSLaw->Set(3.0, 5.0, 6.0, 8.0);
                draw(aSLaw, theOutput);
                // 4. Provides an evolution law that interpolates a set of parameter and value pairs (wi, radi)
                TColgp_Array1OfPnt2d aPoints(1, 4);
                aPoints.SetValue(1, gp_Pnt2d(6.0, 8.0));
                aPoints.SetValue(2, gp_Pnt2d(7.0, 5.0));
                aPoints.SetValue(3, gp_Pnt2d(8.0, 9.0));
                aPoints.SetValue(4, gp_Pnt2d(9.0, 2.0));
                Handle(Law_Interpol) anInterpolativeLaw = new Law_Interpol();
                anInterpolativeLaw->Set(aPoints);
                draw(anInterpolativeLaw, theOutput);
            }
            int main(int argc, char* argv[])
            {
                std::ofstream aTclFile("d:/tcl/law.tcl");
                test(aTclFile);
                return 0;
            }

            程序會(huì)在d:/tcl中生成一個(gè)law.tcl文件,將此文件加載到Draw 中即可顯示出規(guī)則函數(shù)對(duì)應(yīng)的曲線(xiàn),如下圖所示:

            wps_clip_image-6615

            Figure 2. Visualization Law Function Curves

            由圖可知,常量規(guī)則函數(shù)在定義區(qū)間內(nèi)是一條直線(xiàn);線(xiàn)性規(guī)則函數(shù)是一條直線(xiàn);S型函數(shù)是S型的B樣條曲線(xiàn);插值函數(shù)是根據(jù)指定點(diǎn)插值得到的B樣條曲線(xiàn)。

            4.Conclusion

            在OpenCASCADE中經(jīng)常可以看到一些與Law相關(guān)的類(lèi),本文介紹了TKGeomAlgo中的Law包,綜上所述可知,Law就是一元函數(shù),與math_Function的概念一致。

            本文顯示規(guī)則曲線(xiàn)的方式可供借鑒,提高開(kāi)發(fā)效率。只需要生成一個(gè)文本文件,就可以將結(jié)果可視化,對(duì)于其他三維的也是一樣。



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

             

            久久九九亚洲精品| 国产精品美女久久久m| 国产精品gz久久久| 亚洲AⅤ优女AV综合久久久| 久久无码AV一区二区三区| 久久综合给久久狠狠97色| 精品久久久久久久久午夜福利 | 精品久久久久香蕉网| 久久99久久99小草精品免视看| 99久久免费只有精品国产| 亚洲欧洲精品成人久久奇米网| 三上悠亚久久精品| 欧美与黑人午夜性猛交久久久| 精品久久久久久久久午夜福利| 日本精品久久久久影院日本| 久久国产亚洲精品无码| 亚洲精品久久久www| 情人伊人久久综合亚洲| 一本久久知道综合久久| 亚洲精品综合久久| 久久久久久噜噜精品免费直播| 久久99精品久久只有精品| 一级女性全黄久久生活片免费 | 狠狠色婷婷综合天天久久丁香| 亚洲综合久久久| 性做久久久久久久久| 99久久婷婷国产综合精品草原 | 国产精品18久久久久久vr| 人妻无码αv中文字幕久久琪琪布 人妻无码精品久久亚瑟影视 | 久久夜色tv网站| 久久精品无码专区免费东京热 | 中文精品久久久久国产网址| 久久久久久夜精品精品免费啦| 久久人妻无码中文字幕| 色妞色综合久久夜夜| 2021最新久久久视精品爱| 偷偷做久久久久网站| 久久精品国产男包| 天天躁日日躁狠狠久久| 人妻无码αv中文字幕久久| 人妻丰满AV无码久久不卡|