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

            布爾數(shù)據(jù) 邊的相交

            Posted on 2023-09-27 21:52 eryar 閱讀(777) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): 2.OpenCASCADE

            布爾數(shù)據(jù) 邊的相交

            eryar@163.com

            1 Introduction

            在OpenCASCADE中對(duì)于邊的相交分為三類(lèi):邊與點(diǎn),邊與邊,邊與面,邊與點(diǎn)的相交已經(jīng)歸結(jié)為點(diǎn)與邊的相交處理了,邊的相交主要處理邊與邊,邊與面的相交。邊與邊、邊與面的相交會(huì)引入一個(gè)新的數(shù)據(jù)結(jié)構(gòu)-公共部分Common Part,用于保存重疊的公共部分?jǐn)?shù)據(jù)。

            2 Edge/Edge Interferences

            對(duì)于兩條邊的相交是指在兩條邊的某些地方的距離小于邊的容差之和,主要分為兩種情況,一種是兩條邊只有一個(gè)交點(diǎn)的情況;一種是有重疊部分的情況;先看只有一個(gè)交點(diǎn)情況:

            我們?cè)贒RAW中通過(guò)腳本構(gòu)造最簡(jiǎn)單的情況來(lái)測(cè)試。

            在處理邊與邊相交的函數(shù)BOPAlgo_PaveFiller::PerformEE()中,對(duì)每?jī)蓷l邊調(diào)用BOPAlgo_EdgeEdge進(jìn)行求交。從這里可以看到Pave Block的使用,相當(dāng)于對(duì)每?jī)蓷l邊上的每對(duì)Pave Block部分進(jìn)行求交。這里有一些優(yōu)化空間,目前是使用的兩個(gè)循環(huán)處理,可以嘗試使用BVH來(lái)提升一些性能。當(dāng)每對(duì)Pave Block對(duì)應(yīng)的點(diǎn)的索引號(hào)一致時(shí),即每對(duì)Pave Block的端點(diǎn)重疊時(shí),使用快速計(jì)算的算法來(lái)判斷是否有重疊。

            對(duì)于邊的求交結(jié)果保存到BOPDS_InterfEE中,都會(huì)保存是哪兩條邊相交及相交的公共部分。對(duì)于相交于一點(diǎn)的公共部分的類(lèi)型為T(mén)opAbs_VERTEX,對(duì)于有重疊部分的公共部分類(lèi)型為T(mén)opAbs_EDGE:

            當(dāng)兩邊條有重疊部分時(shí),如下圖所示:

            如何檢測(cè)兩條邊的公共部分呢?在函數(shù)IntTools_EdgeEdge::IsCoincident()中實(shí)現(xiàn):

            //=======================================================================
            //function :  IsCoincident
            //purpose  : 
            //=======================================================================
            Standard_Boolean IntTools_EdgeEdge::IsCoincident() 
            {
              Standard_Integer i, iCnt, aNbSeg, aNbP2;
              Standard_Real dT, aT1, aCoeff, aTresh, aD;
              Standard_Real aT11, aT12, aT21, aT22;
              GeomAPI_ProjectPointOnCurve aProjPC;
              gp_Pnt aP1;
              //
              aTresh=0.5;
              aNbSeg=23;
              myRange1.Range(aT11, aT12);
              myRange2.Range(aT21, aT22);
              //
              aProjPC.Init(myGeom2, aT21, aT22);
              //
              dT=(aT12-aT11)/aNbSeg;
              //
              iCnt=0;
              for(i=0; i <= aNbSeg; ++i) {
                aT1 = aT11+i*dT;
                myGeom1->D0(aT1, aP1);
                //
                aProjPC.Perform(aP1);
                aNbP2=aProjPC.NbPoints();
                if (!aNbP2) {
                  continue;
                }
                //
                aD=aProjPC.LowerDistance();
                if(aD < myTol) {
                  ++iCnt; 
                }
              }
              //
              aCoeff=(Standard_Real)iCnt/((Standard_Real)aNbSeg+1);
              return aCoeff > aTresh;
            }

            從上述代碼可以看出,對(duì)于重疊部分的檢測(cè)是將一條邊根據(jù)檢測(cè)范圍分成23段采樣點(diǎn),計(jì)算每個(gè)點(diǎn)到另一條邊的距離,滿足條件的采樣點(diǎn)的數(shù)量超過(guò)12個(gè),基本認(rèn)為是重疊的。從這里可以看出這樣檢測(cè)重疊稍微有點(diǎn)不嚴(yán)謹(jǐn)。固定采樣點(diǎn)數(shù)量對(duì)于小段曲線來(lái)說(shuō)數(shù)量過(guò)大,對(duì)于很長(zhǎng)的曲線來(lái)說(shuō)數(shù)量又偏小,這里有待提高。如果重疊,則將公共部分的數(shù)據(jù)保存起來(lái):

            對(duì)于測(cè)試的TCL腳本不會(huì)走這個(gè)通用的判斷流程,會(huì)直接有IntTools_EdgeEdge::ComputeLineLine()函數(shù)來(lái)處理這種特殊情況:

            從保存的數(shù)據(jù)可以看出,公共部分的相交類(lèi)型為T(mén)opAbs_VERTEX,及交點(diǎn)分別在兩條邊上的參數(shù)。關(guān)于有重疊部分的兩條邊相交,同學(xué)們可以自行使用DRAW腳本來(lái)測(cè)試一下。

            3 Edge/Face Interferences

            邊與面的相交會(huì)遇到和邊與邊相交類(lèi)似的情況,即會(huì)有重疊部分Common Part。也分為兩種情況,一種情況是邊與面只有一個(gè)交點(diǎn)的情況,交點(diǎn)可能會(huì)有多個(gè);一種情況是有重疊部分的情況。

            我們可以在使用腳本來(lái)測(cè)試一下重疊的情況:

            從代碼中可以看出當(dāng)邊的端點(diǎn)在面上時(shí),則會(huì)判斷邊與面會(huì)不會(huì)重疊Coincidence。判斷邏輯與判斷邊是否重疊類(lèi)似,都是使用固定23個(gè)采樣點(diǎn)的方式處理,并加上定位器來(lái)判斷點(diǎn)是否在面上,因?yàn)槊嫔峡赡軙?huì)有孔洞:

            //=======================================================================
            //function :  IsCoincident
            //purpose  : 
            //=======================================================================
            Standard_Boolean IntTools_EdgeFace::IsCoincident() 
            {
              Standard_Integer i, iCnt;
              Standard_Real dT, aT, aD, aT1, aT2, aU, aV;
              gp_Pnt aP;
              TopAbs_State aState;
              gp_Pnt2d aP2d;
              //
              GeomAPI_ProjectPointOnSurf& aProjector=myContext->ProjPS(myFace);
              Standard_Integer aNbSeg=23;
              if (myC.GetType() == GeomAbs_Line &&
                  myS.GetType() == GeomAbs_Plane)
                aNbSeg = 2; // Check only three points for Line/Plane intersection
              const Standard_Real aTresh = 0.5;
              const Standard_Integer aTreshIdxF = RealToInt((aNbSeg+1)*0.25),
                                     aTreshIdxL = RealToInt((aNbSeg+1)*0.75);
              const Handle(Geom_Surface) aSurf = BRep_Tool::Surface(myFace);
              aT1=myRange.First();
              aT2=myRange.Last();
              Standard_Real aBndShift = 0.01 * (aT2 - aT1);
              //Shifting first and last curve points in order to avoid projection
              //on surface boundary and rejection projection point with minimal distance
              aT1 += aBndShift;
              aT2 -= aBndShift;
              dT=(aT2-aT1)/aNbSeg;
              //
              Standard_Boolean isClassified = Standard_False;
              iCnt=0;
              for(i=0; i <= aNbSeg; ++i) {
                aT = aT1+i*dT;
                aP=myC.Value(aT);
                //
                aProjector.Perform(aP);
                if (!aProjector.IsDone()) {
                  continue;
                }
                //
                aD=aProjector.LowerDistance();
                if (aD > myCriteria) {
                  if (aD > 100. * myCriteria)
                    return Standard_False;
                  else
                    continue;
                }
                //
                ++iCnt; 
                //We classify only three points: in the begin, in the 
                //end and in the middle of the edge.
                //However, exact middle point (when i == (aNbSeg + 1)/2)
                //can be unprojectable. Therefore, it will not be able to
                //be classified. Therefore, points with indexes in 
                //[aTreshIdxF, aTreshIdxL] range are made available 
                //for classification.
                //isClassified == TRUE if MIDDLE point has been chosen and
                //classified correctly.
                if(((0 < i) && (i < aTreshIdxF)) || ((aTreshIdxL < i ) && (i < aNbSeg)))
                  continue;
                if(isClassified && (i != aNbSeg))
                  continue;
                aProjector.LowerDistanceParameters(aU, aV);
                aP2d.SetX(aU);
                aP2d.SetY(aV);
                IntTools_FClass2d& aClass2d=myContext->FClass2d(myFace);
                aState = aClass2d.Perform(aP2d);
                if(aState == TopAbs_OUT)
                  return Standard_False;
                if(i != 0)
                  isClassified = Standard_True;
              }
              //
              const Standard_Real aCoeff=(Standard_Real)iCnt/((Standard_Real)aNbSeg+1);
              return (aCoeff > aTresh);
            }

            求交結(jié)果與邊與邊相交類(lèi)型,會(huì)保存邊與面的索引,及公共部分的數(shù)據(jù)。除了保存這些數(shù)據(jù)以外,還和點(diǎn)與面相交一樣,更新面上的信息FaceInfo,即有哪些邊在面上。

            4 Conclusion

            綜上所述,邊與邊、邊與面相交會(huì)得到公共部分Common Part,公共部分可能是點(diǎn),也可能是重疊的邊。在過(guò)濾相交的邊與邊、邊與面時(shí)都有一定的優(yōu)化空間,即使用BVH來(lái)加速檢測(cè)相交部分。在快速判斷邊與邊是否重疊、邊與面是否重疊部分的代碼采用固定數(shù)量的采樣點(diǎn)的處理方式不太嚴(yán)謹(jǐn)。將相交的結(jié)果及過(guò)程數(shù)據(jù)都保存到BOPDS_DS中作為后面算法使用。

            久久狠狠色狠狠色综合| 无码国内精品久久人妻麻豆按摩 | 久久久av波多野一区二区| 成人午夜精品久久久久久久小说| 久久久久青草线蕉综合超碰| 久久精品国产一区二区电影| 日本久久久精品中文字幕| 国产成年无码久久久久毛片| 欧美熟妇另类久久久久久不卡 | 国产免费福利体检区久久| 2021最新久久久视精品爱 | 久久精品亚洲一区二区三区浴池| 国产精品久久亚洲不卡动漫| 国产精品久久久久久搜索| 一级做a爰片久久毛片看看| 亚洲一区精品伊人久久伊人| 国产日产久久高清欧美一区| 综合久久国产九一剧情麻豆| 久久精品亚洲日本波多野结衣 | 亚洲国产精品久久久久久| 久久综合久久综合九色| 久久人人爽人人爽人人片av麻烦| 99久久国产综合精品五月天喷水 | 久久强奷乱码老熟女网站| 久久精品亚洲乱码伦伦中文| 久久99精品久久只有精品| 亚洲国产精品成人久久| 久久91亚洲人成电影网站| 久久综合噜噜激激的五月天| 人妻无码精品久久亚瑟影视| 精品久久人人爽天天玩人人妻| 性做久久久久久久久| 国产精品99久久久久久猫咪| 国内精品久久久久影院免费| 成人久久综合网| 久久99精品综合国产首页| 久久香综合精品久久伊人| 香蕉久久夜色精品升级完成| 亚洲精品无码久久久久| 97精品依人久久久大香线蕉97| 77777亚洲午夜久久多喷|