• <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 Interpolations and Approximations

            Posted on 2016-03-17 23:10 eryar 閱讀(2757) 評(píng)論(1)  編輯 收藏 引用 所屬分類(lèi): 2.OpenCASCADE

            OpenCASCADE Interpolations and Approximations

            eryar@163.com

            Abstract. In modeling, it is often required to approximate or interpolate points to curves and surfaces. In interpolation, the process is complete when the curve or surface passes through all the points; in approximation, when it is as close to these points as possible. The paper is the translation of the OpenCASCADE Modeling Data user guide.

            Key Words. Interpolation, Approximation, Fitting

            1.Introduction

            在幾何造型中,經(jīng)常會(huì)需要根據(jù)點(diǎn)去擬合(插值Interpolation或逼近Approximation)曲線曲面。插值要求擬合所得的曲線或曲面必須通過(guò)所有擬合點(diǎn);而逼近要求擬合所得曲線或曲面盡可能地靠近全部擬合點(diǎn)。OpenCASCADE中提供了曲線曲面擬合的功能有:

            v 對(duì)二維點(diǎn)進(jìn)行二維B樣條或Bezier曲線插值;

            v 對(duì)二維點(diǎn)進(jìn)行二維B樣條或Bezier曲線逼近;

            v 對(duì)三維點(diǎn)進(jìn)行三維B樣條或Bezier曲線或B樣條曲面插值;

            v 對(duì)三維點(diǎn)進(jìn)行三維B樣條或Bezier曲線或B樣條曲面逼近;

            程序中使用擬合功能有兩種方式:

            v 使用高級(jí)功能:提供簡(jiǎn)單的方法調(diào)用來(lái)獲得擬合結(jié)果;

            v 使用低級(jí)功能:專(zhuān)為想對(duì)擬合有更多控制的用戶(hù)設(shè)計(jì);

            插值和逼近也是數(shù)值分析或計(jì)算方法中的主要內(nèi)容。用B樣條作為插值或逼近函數(shù)是數(shù)值分析中的一個(gè)具體方法。通過(guò)對(duì)OpenCASCADE中插值和逼近算法的學(xué)習(xí),加深對(duì)一些算法,如最小二乘法,多元函數(shù)求極值等數(shù)學(xué)知識(shí)的理解。

            本文主要是對(duì)OpenCASCADE的文檔Modeling Data 中的插值和逼近部分進(jìn)行翻譯,并給出了使用其低級(jí)功能具體的代碼示例。

            2.Analysis of a set of points

            包GProp中的類(lèi)PEquation提供了對(duì)點(diǎn)集、點(diǎn)云數(shù)據(jù)進(jìn)行分析的功能,可以用來(lái)驗(yàn)證在給定的精度范圍內(nèi)是否重合、共線或共面等,如果檢測(cè)結(jié)果是,那么算法將計(jì)算出這些點(diǎn)的重合點(diǎn)、線或面。如果檢測(cè)結(jié)果不是,則算法會(huì)計(jì)算出點(diǎn)集或點(diǎn)云的包圍盒。

            3.Basic Interpolation and Approximation

            包Geom2dAPI和GeomAPI提供了擬合(逼近和插值)簡(jiǎn)單的方法。

            v 2D Interpolation: 類(lèi)Geom2dAPI_Interpolate可以用于生成一條通過(guò)一系列點(diǎn)的二維B樣條曲線。如果需要,還可以設(shè)置點(diǎn)相應(yīng)的切矢及參數(shù)來(lái)對(duì)插值曲線做進(jìn)一步的約束。

            v 3D Interpolation: 類(lèi)GeomAPI_Interpolate可以用于生成一條通過(guò)一系列點(diǎn)的三維B樣條曲線。如果需要,還可以設(shè)置點(diǎn)相應(yīng)的切矢及參數(shù)來(lái)對(duì)插值曲線做進(jìn)一步的約束。因?yàn)槭歉呒?jí)功能,所以需要很少的代碼就可以得到插值曲線,用法如下:

            GeomAPI_Interpolate Interp(Points);

            Handle_Geom_BSplineCurve C = Interp.Curve()

            v 2D Approximation: 類(lèi)Geom2dAPI_PointsToBSpline可以用于生成逼近一系列點(diǎn)的二維B樣條曲線。你需要定義曲線次數(shù)范圍,連續(xù)性和容差。容差值只是用來(lái)檢查逼近點(diǎn)之間是不是有重合點(diǎn),或者切矢是否太小。逼近曲線將會(huì)是C2連續(xù)或2次曲線,當(dāng)有切矢約束時(shí),將會(huì)得到C1連續(xù)的曲線。

            wps_clip_image-12820

            v 3D Approximation:類(lèi)GeomAPI_PointsToBSpline可以用于生成逼近一系列點(diǎn)的三維B樣條曲線。你需要定義曲線次數(shù)范圍,連續(xù)性和容差。容差值只是用來(lái)檢查逼近點(diǎn)之間是不是有重合點(diǎn),或者切矢是否太小。逼近曲線將會(huì)是C2連續(xù)或2次曲線,當(dāng)有切矢約束時(shí),將會(huì)得到C1連續(xù)的曲線。類(lèi)的用法如下:

            GeomAPI_PointsToBSpline Approx(Points, DegMin, DegMax, Continutity, Tol);

            Handle_Geom_BSplineCurve K = Approx.Curve()

            v Surface Approximation:類(lèi)GeomAPI_PointsToBSplineSurface可以用于根據(jù)點(diǎn)集擬合B樣條曲面。

            4.Advanced Approximation

            包AppDef和AppParCurves提供了低級(jí)的功能,允許對(duì)擬合有更多地控制。低級(jí)功能提供了如下函數(shù)接口API:

            v 定義擬合切矢的規(guī)則,這些切矢有原點(diǎn)和極值;

            v 根據(jù)各自參數(shù)平行地?cái)M合一系列曲線;

            v 光滑擬合:生成光順(faired curve)的曲線。

            注:包AppDef和AppParCurves中通過(guò)宏定義實(shí)現(xiàn)了一種類(lèi)似多態(tài)的功能,但是程序調(diào)試不方便,導(dǎo)致一些類(lèi)名沒(méi)有看到聲明文件,對(duì)程序的理解造成一些不便。

            4.1 Approximation by multiple point constraints

            包AppDef中提供了低級(jí)工具用于對(duì)帶約束的點(diǎn)集進(jìn)行Bezier或B樣條曲線擬合。其中的功能有:

            v 定義一組約束點(diǎn),使用類(lèi)AppDef_MultiPointConstraint;

            v 定義一組約束線,使用類(lèi)AppDef_MultiLine;

            v 擬合Bezier曲線,使用類(lèi)AppDef_Compute;

            v 擬合B樣條曲線,使用類(lèi)AppDef_BSplineCompute;

            v 定義變分標(biāo)準(zhǔn)Variational Criteria;

            注:在類(lèi)AppDef_Variational中可以看到Variational Optimization變分優(yōu)化。對(duì)于工科出來(lái)的人來(lái)說(shuō),這些概念還真是有些陌生,還是學(xué)數(shù)學(xué)的人厲害!

            其中類(lèi)AppDef_MultiLine的用法也有點(diǎn)特別,通過(guò)文檔中的圖來(lái)理解下:

            wps_clip_image-28658

            其中:Pi, Qi, Ri, ..., Si可以是二維點(diǎn)或三維點(diǎn);

            按組來(lái)定義,其中Pn, Qn, Rn, ..., Sn都是在類(lèi)AppDef_MultiPointConstraint中定義;

            P1, P2, .., Pn或Q, R,..., S的點(diǎn)系列用來(lái)擬合。

            類(lèi)AppDef_Compute用Bezier曲線來(lái)擬合點(diǎn);

            類(lèi)AppDef_BSplineCompute用B樣條曲線來(lái)擬合點(diǎn);

            注:需要仔細(xì)理解AppDef_MultiPointConstraint和AppDef_MultiLine的用法。

            4.2  Example: How to approximate a curve with low-level tools

            使用低級(jí)功能的過(guò)程可分為如下幾步:

            v 定義擬合點(diǎn);

            v 根據(jù)擬合點(diǎn)創(chuàng)建MultiLine;

            v 使用AppDef_Compute或AppDef_BSplineCompute來(lái)擬合曲線;

            下面給出使用低級(jí)功能的代碼示例:

             

            /*
            *    Copyright (c) 2016 Shing Liu All Rights Reserved.
            *
            *           File : main.cpp
            *         Author : Shing Liu(eryar@163.com)
            *           Date : 2016-03-17 21:00
            *        Version : OpenCASCADE6.9.0
            *
            *    Description : test the low-level tools of approximation.
            */

            #define WNT

            #include 
            <TColgp_Array1OfPnt.hxx>

            #include 
            <AppDef_MultiPointConstraint.hxx>
            #include 
            <AppDef_MultiLine.hxx>
            #include 
            <AppDef_Compute.hxx>
            #include 
            <AppDef_BSplineCompute.hxx>

            #pragma comment(lib, 
            "TKernel.lib")
            #pragma comment(lib, 
            "TKMath.lib")
            #pragma comment(lib, 
            "TKGeomBase.lib")


            void testBezierApprox()
            {
                TColgp_Array1OfPnt aPoints(
            13);
                aPoints.SetValue(
            1, gp_Pnt(0.00.00.0));
                aPoints.SetValue(
            2, gp_Pnt(1.00.00.0));
                aPoints.SetValue(
            3, gp_Pnt(1.01.00.0));

                AppDef_MultiLine aMultiLine(aPoints);

                AppDef_Compute aBezierApprox(aMultiLine);
                aBezierApprox.Value().Dump(std::cout);

            }

            void testBSplineApprox()
            {
                AppDef_MultiLine aMultiLine(
            3);

                AppDef_MultiPointConstraint aMPC1(
            20);
                AppDef_MultiPointConstraint aMPC2(
            20);
                AppDef_MultiPointConstraint aMPC3(
            20);

                aMPC1.SetPoint(
            1, gp_Pnt(0.00.00.0));
                aMPC1.SetPoint(
            2, gp_Pnt(0.02.00.0));

                aMPC2.SetPoint(
            1, gp_Pnt(1.00.00.0));
                aMPC2.SetPoint(
            2, gp_Pnt(1.02.00.0));

                aMPC3.SetPoint(
            1, gp_Pnt(1.01.00.0));
                aMPC3.SetPoint(
            2, gp_Pnt(1.03.01.0));

                aMultiLine.SetValue(
            1, aMPC1);
                aMultiLine.SetValue(
            2, aMPC2);
                aMultiLine.SetValue(
            3, aMPC3);

                AppDef_BSplineCompute aBSplineApprox(aMultiLine);
                aBSplineApprox.Value().Dump(std::cout);
            }

            int main(int argc, char* argv[])
            {
                testBezierApprox();

                testBSplineApprox();

                
            return 0;
            }

            程序運(yùn)行結(jié)果如下圖所示:

            wps_clip_image-1016

            5.Conclusion

            關(guān)于點(diǎn)的插值和逼近是《數(shù)據(jù)逼近》或《數(shù)值分析》或《計(jì)算方法》書(shū)中關(guān)注的內(nèi)容。從文檔中可以看到包AppDef中的一些關(guān)鍵字:Gradient, BFGS, LeastSquare等,根據(jù)這些關(guān)鍵字可以看出OpenCASCADE中逼近使用的算法了。

            wps_clip_image-27642

            通過(guò)使用AppDef_MultiPointConstraint及AppDef_MultiLine等低級(jí)接口,來(lái)理解擬合數(shù)據(jù)點(diǎn)輸入及擬合結(jié)果的輸出。進(jìn)而去學(xué)習(xí)BFGS、LeastSquare等數(shù)學(xué)理論工具在實(shí)際中的應(yīng)用。對(duì)于多元函數(shù),梯度及BFGS等概念還好接受,對(duì)于變分法優(yōu)化之類(lèi)理論已經(jīng)超出了工科數(shù)學(xué)的范圍,不過(guò)結(jié)合實(shí)際去學(xué)習(xí)這些概念應(yīng)該會(huì)更有效率。

            Feedback

            # re: OpenCASCADE Interpolations and Approximations  回復(fù)  更多評(píng)論   

            2016-04-11 21:18 by zhaiht
            高手:Opencascade有大量的內(nèi)存泄露怎么處理,好抓狂啊
            色婷婷久久久SWAG精品| 91久久婷婷国产综合精品青草 | 亚洲精品成人久久久| 久久只有这精品99| 久久人人爽爽爽人久久久| 精品国产综合区久久久久久 | 久久精品国产只有精品66| 国内精品伊人久久久久妇| 欧美一区二区三区久久综合 | 一本久久免费视频| 久久精品国产精品青草| 欧美日韩精品久久久久| 亚洲一区二区三区日本久久九| 国产精品亚洲综合久久| 国产精品久久久久久久午夜片| 亚洲∧v久久久无码精品| 日本欧美国产精品第一页久久| 99国产欧美久久久精品蜜芽 | 国产精品热久久毛片| 久久精品99久久香蕉国产色戒 | 国产69精品久久久久777| 无码八A片人妻少妇久久| 久久福利片| 中文字幕一区二区三区久久网站 | 天堂无码久久综合东京热| 国产高潮久久免费观看| 日本免费久久久久久久网站| 777米奇久久最新地址| 日韩久久久久久中文人妻| 亚洲狠狠婷婷综合久久久久| 狠狠色丁香婷婷久久综合五月| 四虎国产精品成人免费久久| 香蕉久久永久视频| 久久婷婷午色综合夜啪| 怡红院日本一道日本久久| 久久99国产精一区二区三区 | 久久精品国产清自在天天线| 欧美日韩精品久久免费| 久久无码人妻一区二区三区午夜| 久久夜色精品国产噜噜麻豆| 久久亚洲中文字幕精品有坂深雪|