From 26544984ade9e05f49614537593f5a28a9017e64 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 16 Feb 2024 08:46:02 +0100 Subject: [PATCH 1/5] EgtExecutor 2.6b3 : - adattamenti per modifiche a funzioni Collision Detection. --- EXE_CDeObjSolid.cpp | 34 +++++++++++++++++++--------------- EgtExecutor.rc | Bin 18890 -> 18890 bytes 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/EXE_CDeObjSolid.cpp b/EXE_CDeObjSolid.cpp index f24aeb3..c628a32 100644 --- a/EXE_CDeObjSolid.cpp +++ b/EXE_CDeObjSolid.cpp @@ -49,7 +49,7 @@ MyCDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, int nSurfTmI // porto in locale alla superficie il riferimento del box (il vettore è già in questo stesso riferimento) Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frSurf) ; // verifico la collisione - return ( CDeBoxClosedSurfTm( frBoxL, vtDiag, dSafeDist, *pStm) ? 1 : 0) ; + return ( CDeBoxClosedSurfTm( frBoxL, vtDiag, *pStm, dSafeDist) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -69,7 +69,7 @@ MyCDeBoxVolZmap( const Frame3d& frBox, const Vector3d& vtDiag, int nZmapId, doub // porto in locale il riferimento (il vettore è già in locale a questo stesso riferimento) Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidBox( frBoxL, vtDiag, dSafeDist, false) ? 0 : 1) ; + return ( pVZM->CDeBox( frBoxL, vtDiag, dSafeDist, false) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -118,7 +118,7 @@ MyCDeRectPrismoidClosedSurfTm( const Frame3d& frPrismoid, double dBaseLenX, doub // porto in locale alla superficie il riferimento del prismoide rettangolare Frame3d frPrismoidL = GetFrameLocal( pGeomDB, frPrismoid, nRefType, frSurf) ; // verifico la collisione - return ( CDeRectPrismoidClosedSurfTm( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, dSafeDist, *pStm) ? 1 : 0) ; + return ( CDeRectPrismoidClosedSurfTm( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, *pStm, dSafeDist) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -140,7 +140,7 @@ MyCDeRectPrismoidVolZmap( const Frame3d& frPrismoid, double dBaseLenX, double dB // porto in locale il riferimento (il vettore è già in locale a questo stesso riferimento) Frame3d frPrismoidL = GetFrameLocal( pGeomDB, frPrismoid, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidRectPrismoid( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, dSafeDist, false) ? 0 : 1) ; + return ( pVZM->CDeRectPrismoid( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, dSafeDist, false) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -193,7 +193,7 @@ MyCDeCylClosedSurfTm( const Frame3d& frCyl, double dR, double dH, int nSurfTmId, // porto in locale alla superficie il riferimento del cilindro Frame3d frCylL = GetFrameLocal( pGeomDB, frCyl, nRefType, frSurf) ; // verifico la collisione - return ( CDeCylClosedSurfTm( frCylL, dR, dH, dSafeDist, *pStm) ? 1 : 0) ; + return ( CDeCylClosedSurfTm( frCylL, dR, dH, *pStm, dSafeDist) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -213,7 +213,7 @@ MyCDeCylVolZmap( const Frame3d& frCyl, double dR, double dH, int nZmapId, double // porto in locale il riferimento Frame3d frCylL = GetFrameLocal( pGeomDB, frCyl, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidCylinder( frCylL, dR, dH, dSafeDist, false) ? 0 : 1) ; + return ( pVZM->CDeCylinder( frCylL, dR, dH, dSafeDist, false) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -261,7 +261,7 @@ MyCDeConeClosedSurfTm( const Frame3d& frCone, double dR1, double dR2, double dH, // porto in locale alla superficie il riferimento del cilindro Frame3d frConeL = GetFrameLocal( pGeomDB, frCone, nRefType, frSurf) ; // verifico la collisione - return ( CDeConeFrustumClosedSurfTm( frConeL, dR1, dR2, dH, dSafeDist, *pStm) ? 1 : 0) ; + return ( CDeConeFrustumClosedSurfTm( frConeL, dR1, dR2, dH, *pStm, dSafeDist) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -281,7 +281,7 @@ MyCDeConeVolZmap( const Frame3d& frCone, double dR1, double dR2, double dH, int // porto in locale il riferimento Frame3d frConeL = GetFrameLocal( pGeomDB, frCone, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidConeFrustum( frConeL, dR1, dR2, dH, dSafeDist, false) ? 0 : 1) ; + return ( pVZM->CDeConeFrustum( frConeL, dR1, dR2, dH, dSafeDist, false) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -330,7 +330,7 @@ MyCDeSpheClosedSurfTm( const Point3d& ptCen, double dR, int nSurfTmId, double dS // porto in locale alla superficie il centro della sfera Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frSurf) ; // verifico la collisione - return ( CDeSpheClosedSurfTm( ptCenL, dR, dSafeDist, *pStm) ? 1 : 0) ; + return ( CDeSpheClosedSurfTm( ptCenL, dR, *pStm, dSafeDist) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -350,7 +350,7 @@ MyCDeSpheVolZmap( const Point3d& ptCen, double dRad, int nZmapId, double dSafeDi // porto in locale il centro della sfera Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidSphere( ptCenL, dRad, dSafeDist, false) ? 0 : 1) ; + return ( pVZM->CDeSphere( ptCenL, dRad, dSafeDist, false) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -420,7 +420,7 @@ MyCDeClosedSurfTmVolZmap( int nSurfTmId, int nZmapId, double dSafeDist) if ( pVZM == nullptr) return -1 ; // verifico la collisione - return ( pVZM->AvoidSurfTm( *pStm, dSafeDist, false) ? 0 : 1) ; + return ( pVZM->CDeSurfTm( *pStm, dSafeDist, false) ? 1 : 0) ; } //---------------------------------------------------------------------------- @@ -429,10 +429,14 @@ ExeCDeSolidSolid( int nSolid1Id, int nSolid2Id, double dSafeDist) { IGeomDB* pGeomDB = GetCurrGeomDB() ; int nRes = -1 ; - if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == SRF_TRIMESH) - nRes = MyCDeClosedSurfTmClosedSurfTm( nSolid1Id, nSolid2Id, dSafeDist) ; - else if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == VOL_ZMAP) - nRes = MyCDeClosedSurfTmVolZmap( nSolid1Id, nSolid2Id, dSafeDist) ; + if ( pGeomDB != nullptr) { + if ( pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == SRF_TRIMESH) + nRes = MyCDeClosedSurfTmClosedSurfTm( nSolid1Id, nSolid2Id, dSafeDist) ; + else if ( pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == VOL_ZMAP) + nRes = MyCDeClosedSurfTmVolZmap( nSolid1Id, nSolid2Id, dSafeDist) ; + else if ( pGeomDB->GetGeoType( nSolid1Id) == VOL_ZMAP && pGeomDB->GetGeoType( nSolid2Id) == SRF_TRIMESH) + nRes = MyCDeClosedSurfTmVolZmap( nSolid2Id, nSolid1Id, dSafeDist) ; + } // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtCDeSolidSolid({" + IdToString( nSolid1Id) + "," + diff --git a/EgtExecutor.rc b/EgtExecutor.rc index da0fe7093d4ba7b9ba85db5a4987cffa9e1bda8c..5c7d67edf8242caa8f66a39a865420a6943ba780 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7>zgoW^-i*QjT29S-`yGOp`YVRxuh+cH~Ol+$UrM5#neo(Q#tpyN7>zdnW^-i*QjT29S-`yGOp`YVRxuh)cH~Ol+$UrM5m>XaK From ed1ba0543b62a22ccbca828d885710384ca33f4d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 19 Feb 2024 14:52:24 +0100 Subject: [PATCH 2/5] EgtExecutor 2.6b4 : - aggiunta funzioni Exe e Lua Set/GetViewOrizzOffsStep - aggiunte funzioni Lua EgtGetView e EgtGetGenericView. --- EXE_Scene.cpp | 22 +++++++++++++++ EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_Scene.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/EXE_Scene.cpp b/EXE_Scene.cpp index 514cf0b..4afafcd 100644 --- a/EXE_Scene.cpp +++ b/EXE_Scene.cpp @@ -640,6 +640,15 @@ ExeZoomWin( int nPrevX, int nPrevY, int nCurrX, int nCurrY, bool bRedraw) return true ; } +//----------------------------------------------------------------------------- +bool +ExeSetViewOrizzOffsStep( int nDirOffsStep) +{ + IEGrScene* pScene = GetCurrScene() ; + VERIFY_SCENE( pScene, false) + return pScene->SetCameraDirOrizzOffset( nDirOffsStep) ; +} + //----------------------------------------------------------------------------- bool ExeSetView( int nDir, bool bRedraw) @@ -709,6 +718,19 @@ ExeRotateView( int nPrevX, int nPrevY, int nCurrX, int nCurrY, bool bRedraw) return true ; } +//----------------------------------------------------------------------------- +bool +ExeGetViewOrizzOffsStep( int* pnDirOffsStep) +{ + IEGrScene* pScene = GetCurrScene() ; + VERIFY_SCENE( pScene, false) + // recupero offset direzione di vista + if ( pnDirOffsStep == nullptr) + return false ; + *pnDirOffsStep = pScene->GetCameraDirOrizzOffset() ; + return true ; +} + //----------------------------------------------------------------------------- bool ExeGetView( int* pnDir) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 5c7d67edf8242caa8f66a39a865420a6943ba780..50163c363192bd160da54aa54936ff5843647942 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7)>_+W^-i*QjT29S-`yGOp`YVRxz4PcH~Ol+$UrM5#neo(Q#tpyN7>zgoW^-i*QjT29S-`yGOp`YVRxuh+cH~Ol+$UrM5 Date: Tue, 20 Feb 2024 15:53:59 +0100 Subject: [PATCH 3/5] EgtExecutor : - modifiche a AdjustLayerForSideAngle per gestire la creazione della regione anche nel caso di raccordi in tangenza. --- EXE_NstCreateFlatParts.cpp | 86 ++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 9 deletions(-) diff --git a/EXE_NstCreateFlatParts.cpp b/EXE_NstCreateFlatParts.cpp index 30d1970..8d06027 100644 --- a/EXE_NstCreateFlatParts.cpp +++ b/EXE_NstCreateFlatParts.cpp @@ -1613,6 +1613,50 @@ ExeCalcFlatPartUpRegion( int nPartId, bool bCalc) return true ; } +//---------------------------------------------------------------------------- +static bool +IgnoreOutlineFillet( IGeomDB* pGeomDB, int nCrvId, int nLayId) +{ + // verifico se la curva nCrvId è un raccordo che deve essere ignorato, ovvero se si tratta di un arco non inclinato, in tangenza + // e consecutivo ad almeno un lato inclinato + + // verifico se arco + if ( pGeomDB->GetGeoType( nCrvId) == CRV_ARC) { + // verifico se non inclinato + double dSideAng = 0, dSideAng2 = 0 ; + pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG, dSideAng) ; + pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG2, dSideAng2) ; + if ( abs( dSideAng) < EPS_ANG_SMALL && abs( dSideAng2) < EPS_ANG_SMALL) { + // verifico se in tangenza con curve consecutive + double dPrevAng = ANG_RIGHT, dNextAng = ANG_RIGHT ; + pGeomDB->GetInfo( nCrvId, MCH_KEY_PREVANG, dPrevAng) ; + pGeomDB->GetInfo( nCrvId, MCH_KEY_NEXTANG, dNextAng) ; + if ( abs( dPrevAng) < EPS_ANG_SMALL && abs( dNextAng) < EPS_ANG_SMALL) { + // verifico se è inclinata almeno una tra la curva precedente e quella successiva + int nPrevId = pGeomDB->GetPrev( nCrvId) ; + if ( nPrevId == GDB_ID_NULL) + nPrevId = pGeomDB->GetLastInGroup( nLayId) ; + if ( nPrevId == GDB_ID_NULL) + return false ; + double dSideAng, dSideAng2 ; + if ( ( pGeomDB->GetInfo( nPrevId, NST_KEY_SIDEANG, dSideAng) && abs( dSideAng) > EPS_ANG_SMALL) || + ( pGeomDB->GetInfo( nPrevId, NST_KEY_SIDEANG2, dSideAng2) && abs( dSideAng2) > EPS_ANG_SMALL)) + return true ; + + int nNextId = pGeomDB->GetNext( nCrvId) ; + if ( nNextId == GDB_ID_NULL) + nNextId = pGeomDB->GetFirstInGroup( nLayId) ; + if ( nNextId == GDB_ID_NULL) + return false ; + if ( ( pGeomDB->GetInfo( nNextId, NST_KEY_SIDEANG, dSideAng) && abs( dSideAng) > EPS_ANG_SMALL) || + ( pGeomDB->GetInfo( nNextId, NST_KEY_SIDEANG2, dSideAng2) && abs( dSideAng2) > EPS_ANG_SMALL)) + return true ; + } + } + } + return false ; +} + //---------------------------------------------------------------------------- static bool AdjustLayerForSideAngle( IGeomDB* pGeomDB, int nLayOrigId, const string& sLayOrig, int nLayReg, double dH) @@ -1683,7 +1727,8 @@ AdjustLayerForSideAngle( IGeomDB* pGeomDB, int nLayOrigId, const string& sLayOri ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nNewId)) ; if ( pCrv == nullptr) return false ; - pCrv->SimpleOffset( dCalcOffset) ; + if ( ! pCrv->SimpleOffset( dCalcOffset)) + pGeomDB->Erase( nNewId) ; } else if ( pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG2, dSideAng2) && abs( dSideAng2) > EPS_ANG_SMALL) { double dOffset2 = 0 ; @@ -1696,8 +1741,12 @@ AdjustLayerForSideAngle( IGeomDB* pGeomDB, int nLayOrigId, const string& sLayOri ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nNewId)) ; if ( pCrv == nullptr) return false ; - pCrv->SimpleOffset( dCalcOffset) ; + if ( ! pCrv->SimpleOffset( dCalcOffset)) + pGeomDB->Erase( nNewId) ; } + // verifico se raccordo da ignorare per poter calcolare la regione + else if ( IgnoreOutlineFillet( pGeomDB, nCrvId, nLayId)) + pGeomDB->Erase( nNewId) ; } // aggiusto tra loro le curve offsettate (allungandole e/o accorciandole) if ( ! AdjustLayerCurves( pGeomDB, nTmpLayId)) @@ -1720,7 +1769,7 @@ AdjustLayerForSideAngle( IGeomDB* pGeomDB, int nLayOrigId, const string& sLayOri if ( nNewId == GDB_ID_NULL) return false ; // determino ed eseguo offset - double dSideAng ; + double dSideAng, dSideAng2 ; if ( pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG, dSideAng) && abs( dSideAng) > EPS_ANG_SMALL) { double dOffset = 0 ; pGeomDB->GetInfo( nCrvId, NST_KEY_OFFSET, dOffset) ; @@ -1728,8 +1777,22 @@ AdjustLayerForSideAngle( IGeomDB* pGeomDB, int nLayOrigId, const string& sLayOri ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nNewId)) ; if ( pCrv == nullptr) return false ; - pCrv->SimpleOffset( dCalcOffset) ; + if ( ! pCrv->SimpleOffset( dCalcOffset)) + pGeomDB->Erase( nNewId) ; } + else if ( pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG2, dSideAng2) && abs( dSideAng2) > EPS_ANG_SMALL) { + double dOffset2 = 0 ; + pGeomDB->GetInfo( nCrvId, NST_KEY_OFFSET2, dOffset2) ; + double dCalcOffset = dOffset2 ; + ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nNewId)) ; + if ( pCrv == nullptr) + return false ; + if ( ! pCrv->SimpleOffset( dCalcOffset)) + pGeomDB->Erase( nNewId) ; + } + // verifico se raccordo da ignorare per poter calcolare la regione + else if ( IgnoreOutlineFillet( pGeomDB, nCrvId, nLayId)) + pGeomDB->Erase( nNewId) ; } // aggiusto tra loro le curve offsettate (allungandole e/o accorciandole) if ( ! AdjustLayerCurves( pGeomDB, nTmpLay2Id)) @@ -1769,10 +1832,13 @@ AdjustLayerForSideAngle( IGeomDB* pGeomDB, int nLayOrigId, const string& sLayOri //if ( dStartProD > EPS_SMALL) // pCrv->ExtendStartByLen( dStartProD) ; double dStartProMin = min( dStartProD, dStartProU) ; - if ( dStartProMin < - EPS_SMALL) + if ( dStartProMin < - EPS_SMALL) { pCrv->TrimStartAtLen( - dStartProMin) ; - if ( abs( dStartProD - dStartProU) > EPS_SMALL) - pGeomDB->SetInfo( nCrvId, MCH_KEY_START_WHISKEXT, abs( dStartProD - dStartProU)) ; + if ( abs( dStartProD - dStartProU) > EPS_SMALL) + pGeomDB->SetInfo( nCrvId, MCH_KEY_START_WHISKEXT, abs( dStartProD - dStartProU)) ; + } + else + pGeomDB->SetInfo( nCrvId, MCH_KEY_START_WHISKEXT, max( dStartProD, dStartProU)) ; } else { if ( dStartProD < - EPS_SMALL) @@ -1799,9 +1865,11 @@ AdjustLayerForSideAngle( IGeomDB* pGeomDB, int nLayOrigId, const string& sLayOri double dLen ; pCrv->GetLength( dLen) ; pCrv->TrimEndAtLen( dLen + dEndProMin) ; + if ( abs( dEndProD - dEndProU) > EPS_SMALL) + pGeomDB->SetInfo( nCrvId, MCH_KEY_END_WHISKEXT, abs( dEndProD - dEndProU)) ; } - if ( abs( dEndProD - dEndProU) > EPS_SMALL) - pGeomDB->SetInfo( nCrvId, MCH_KEY_END_WHISKEXT, abs( dEndProD - dEndProU)) ; + else + pGeomDB->SetInfo( nCrvId, MCH_KEY_END_WHISKEXT, max( dEndProD, dEndProU)) ; } else { if ( dEndProD < - EPS_SMALL) { From 5f2c538ab8d31e410509415b27bd11b7660b1e75 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 21 Feb 2024 15:37:35 +0100 Subject: [PATCH 4/5] EgtExecutor : - correzione della chiamata di conversione da bezier a trimesh in caso di con bezier nulla. --- EXE_GdbCreateSurf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 59ae3e7..f0bfbe5 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -1536,7 +1536,7 @@ ExeCreateSurfTmBySurfBezier( int nParentId, int nSbezId) PtrOwner pStm( pAuxSurf != nullptr ? pAuxSurf->Clone() : nullptr) ; bOk = bOk && ! IsNull( pStm) ; // la porto nel riferimento destinazione - pStm->LocToLoc( frSou, frLoc) ; + bOk = bOk && pStm->LocToLoc( frSou, frLoc) ; // inserisco la superficie trimesh nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) : GDB_ID_NULL) ; ExeSetModified() ; From 308e50549d89986d460c0a6c14584f85b4c5f699 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 26 Feb 2024 15:09:35 +0100 Subject: [PATCH 5/5] EgtExecutor : - aggiunta funzione Exe e Lua CurveSurfTmInters - filtri su intersezioni portati in GeomKernel. --- EXE_GeoInters.cpp | 274 +++++++++++++++++++++++++--------------------- LUA_GeoInters.cpp | 27 +++++ 2 files changed, 174 insertions(+), 127 deletions(-) diff --git a/EXE_GeoInters.cpp b/EXE_GeoInters.cpp index 2ee0acc..6b6f7aa 100644 --- a/EXE_GeoInters.cpp +++ b/EXE_GeoInters.cpp @@ -29,13 +29,16 @@ #include "/EgtDev/Include/EGkStmFromTriangleSoup.h" #include "/EgtDev/Include/EGkSurfLocal.h" #include "/EgtDev/Include/EGkVolZmap.h" -#include "/EgtDev/Include/EGkIntersCurves.h" #include "/EgtDev/Include/EGkIntersLineBox.h" -#include "/EgtDev/Include/EGkIntersPlaneBox.h" -#include "/EgtDev/Include/EGkIntersLineSurfTm.h" -#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h" -#include "/EgtDev/Include/EGkIntersSurfTmSurfTm.h" #include "/EgtDev/Include/EGkIntersLinePlane.h" +#include "/EgtDev/Include/EGkIntersLineSurfTm.h" +#include "/EgtDev/Include/EGkIntersLineVolZmap.h" +#include "/EgtDev/Include/EGkIntersPlaneBox.h" +#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h" +#include "/EgtDev/Include/EGkIntersPlaneVolZmap.h" +#include "/EgtDev/Include/EGkIntersCurves.h" +#include "/EgtDev/Include/EGkIntersCurveSurfTm.h" +#include "/EgtDev/Include/EGkIntersSurfTmSurfTm.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EgtNumUtils.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -190,63 +193,9 @@ MyLineSurfTmInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRef ILSIVECTOR vInfo ; if ( ! IntersLineSurfTm( ptPL, vtDirL, dLen, *pStm, vInfo, false)) return false ; - // ciclo sulle intersezioni - for ( const auto& Info : vInfo) { - // se intersezione puntuale - if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) { - int nFlag = SLT_TOUCH ; - if ( Info.dCosDN > EPS_ZERO) - nFlag = SLT_OUT ; - else if ( Info.dCosDN < -EPS_ZERO) - nFlag = SLT_IN ; - vInters.emplace_back( nFlag, Info.dU) ; - } - // se altrimenti intersezione con coincidenza - else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { - vInters.emplace_back( SLT_TG_INI, Info.dU) ; - vInters.emplace_back( SLT_TG_FIN, Info.dU2) ; - } - } - // elimino intersezioni ripetute - for ( size_t j = 1 ; j < vInters.size() ; ) { - // intersezione precedente - size_t i = j - 1 ; - // se hanno lo stesso parametro - if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) { - // se sono entrambe entranti o uscenti, elimino la seconda - if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_IN) || - ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_OUT)) { - vInters.erase( vInters.begin() + j) ; - continue ; - } - // se una entrante e l'altra uscente, cambio in touch ed elimino la seconda - else if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_OUT) || - ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_IN)) { - vInters[i].first = SLT_TOUCH ; - vInters.erase( vInters.begin() + j) ; - continue ; - } - // se una puntuale e l'altra inizio di coincidenza, elimino la prima - else if ( ( vInters[i].first == SLT_IN || vInters[i].first == SLT_OUT || vInters[i].first == SLT_TOUCH) && vInters[j].first == SLT_TG_INI) { - vInters.erase( vInters.begin() + i) ; - continue ; - } - // se una fine di coincidenza e l'altra puntuale, elimino la seconda - else if ( vInters[i].first == SLT_TG_FIN && ( vInters[j].first == SLT_IN || vInters[j].first == SLT_OUT || vInters[j].first == SLT_TOUCH)) { - vInters.erase( vInters.begin() + j) ; - continue ; - } - // se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe - else if ( i > 0 && vInters[i].first == SLT_TG_FIN && vInters[j].first == SLT_TG_INI) { - vInters.erase( vInters.begin() + j) ; - vInters.erase( vInters.begin() + i) ; - -- j ; - continue ; - } - } - // passo alla successiva - ++ j ; - } + + // filtro le intersezioni + FilterLineSurfTmInters( vInfo, vInters) ; return true ; } @@ -273,7 +222,8 @@ ExeLineSurfTmInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRe //------------------------------------------------------------------------------- static bool -MyLineVolZmapInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType, INTDBLVECTOR& vInters) +MyLineVolZmapInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType, + INTDBLVECTOR& vInters) { vInters.clear() ; IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -290,78 +240,21 @@ MyLineVolZmapInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRe Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frZmap) ; Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frZmap) ; vtDirL.Normalize() ; - // calcolo l'ingombro dello Zmap - BBox3d b3Surf ; - if ( ! pVZM->GetLocalBBox( b3Surf)) - return false ; // calcolo l'intersezione ILZIVECTOR vInfo ; - if ( ! pVZM->GetLineIntersection( ptPL, vtDirL, vInfo)) + if ( ! IntersLineVolZmap( ptPL, vtDirL, *pVZM, vInfo)) return false ; - // ciclo sulle intersezioni - for ( const auto& Info : vInfo) { - // se intersezione puntuale - if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) { - int nFlag = SLT_TOUCH ; - if ( vtDirL * Info.trTria.GetN() > EPS_ZERO) - nFlag = SLT_OUT ; - else if ( vtDirL * Info.trTria.GetN() < -EPS_ZERO) - nFlag = SLT_IN ; - vInters.emplace_back( nFlag, Info.dU) ; - } - // se altrimenti intersezione con coincidenza - else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { - vInters.emplace_back( SLT_TG_INI, Info.dU) ; - vInters.emplace_back( SLT_TG_FIN, Info.dU2) ; - } - } - // elimino intersezioni ripetute - for ( size_t j = 1 ; j < vInters.size() ; ) { - // intersezione precedente - size_t i = j - 1 ; - // se hanno lo stesso parametro - if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) { - // se sono entrambe entranti o uscenti, elimino la seconda - if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_IN) || - ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_OUT)) { - vInters.erase( vInters.begin() + j) ; - continue ; - } - // se una entrante e l'altra uscente, cambio in touch ed elimino la seconda - else if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_OUT) || - ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_IN)) { - vInters[i].first = SLT_TOUCH ; - vInters.erase( vInters.begin() + j) ; - continue ; - } - // se una puntuale e l'altra inizio di coincidenza, elimino la prima - else if ( ( vInters[i].first == SLT_IN || vInters[i].first == SLT_OUT || vInters[i].first == SLT_TOUCH) && vInters[j].first == SLT_TG_INI) { - vInters.erase( vInters.begin() + i) ; - continue ; - } - // se una fine di coincidenza e l'altra puntuale, elimino la seconda - else if ( vInters[i].first == SLT_TG_FIN && ( vInters[j].first == SLT_IN || vInters[j].first == SLT_OUT || vInters[j].first == SLT_TOUCH)) { - vInters.erase( vInters.begin() + j) ; - continue ; - } - // se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe - else if ( i > 0 && vInters[i].first == SLT_TG_FIN && vInters[j].first == SLT_TG_INI) { - vInters.erase( vInters.begin() + j) ; - vInters.erase( vInters.begin() + i) ; - -- j ; - continue ; - } - } - // passo alla successiva - ++ j ; - } + + // filtro le intersezioni + FilterLineVolZmapInters( vInfo, vInters) ; return true ; } //------------------------------------------------------------------------------- bool -ExeLineVolZmapInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType, INTDBLVECTOR& vInters) +ExeLineVolZmapInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType, + INTDBLVECTOR& vInters) { // eseguo bool bOk = MyLineVolZmapInters( ptP, vtDir, nId, nRefType, vInters) ; @@ -1020,7 +913,7 @@ MyPlaneVolZmapInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDe // recupero lo Zmap e calcolo l'intersezione IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; ICURVEPOVECTOR vpLoop ; - if ( pVZM == nullptr || ! pVZM->GetPlaneIntersection( plPlane, vpLoop)) + if ( pVZM == nullptr || ! IntersPlaneVolZmap( plPlane, *pVZM, vpLoop)) return GDB_ID_NULL ; // inserisco le curve nel gruppo destinazione int nFirstId = GDB_ID_NULL ; @@ -1159,6 +1052,133 @@ ExeCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int* return nFirstId ; } +//------------------------------------------------------------------------------- +static string +GetCurveSurfTmIntersType( int nFlag) +{ + switch ( nFlag) { + case CSIT_OUT_IN : return "OUT->IN" ; + case CSIT_IN_OUT : return "IN->OUT" ; + case CSIT_IN_IN : return "IN->IN" ; + case CSIT_OUT_OUT : return "OUT->OUT" ; + case CSIT_IN_ON : return "IN->ON" ; + case CSIT_ON_IN : return "ON->IN" ; + case CSIT_OUT_ON : return "OUT->ON" ; + case CSIT_ON_OUT : return "ON->OUT" ; + } + return "NONE" ; +} + +//------------------------------------------------------------------------------- +static int +MyCurveSurfTmInters( const int nCrvId, const int nId2, const int nDestGrpId, int& nPntCount, int& nCrvCount) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + int nFirstId = GDB_ID_NULL ; + + // recupero il riferimento del gruppo di destinazione + Frame3d frDest ; + if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) + return GDB_ID_NULL ; + + // recupero la curva e la superficie in locale al gruppo destinazione + CurveLocal CrvLoc( pGeomDB, nCrvId, frDest) ; + const ICurve* pCrv = GetCurve( CrvLoc) ; + if ( pCrv == nullptr) + return GDB_ID_NULL ; + SurfLocal StmLoc( pGeomDB, nId2, frDest) ; + const ISurfTriMesh* pStm = GetSurfTriMesh( StmLoc) ; + if ( pStm == nullptr) + return GDB_ID_NULL ; + + // intersezione filtrata tra la curva e la superficie locali + INTDBLVECTOR vInters ; + if ( ! IntersCurveSurfTmExt( *pCrv, *pStm, 10 * EPS_SMALL, vInters)) + return GDB_ID_NULL ; + + // recupero i punti e le curve risultanti + for ( int i = 0 ; i < int( vInters.size()) ; i++) { + // verifico se punto + if ( vInters[i].first == CSIT_OUT_IN || vInters[i].first == CSIT_IN_OUT || + vInters[i].first == CSIT_IN_IN || vInters[i].first == CSIT_OUT_OUT || vInters[i].first == CSIT_NONE) { + PtrOwner pGeoPnt( CreateGeoPoint3d()) ; + if ( IsNull( pGeoPnt)) + return GDB_ID_NULL ; + Point3d ptP ; + pCrv->GetPointD1D2( vInters[i].second, ICurve::FROM_MINUS, ptP) ; + pGeoPnt->Set( ptP) ; + // lo inserisco nel DB geometrico + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoPnt)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + // aggiorno parametri + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nPntCount ; + // assegno info di tipo + pGeomDB->SetInfo( nNewId, "CSI", GetCurveSurfTmIntersType( vInters[i].first) + + " (" + ToString( vInters[i].second) + ")") ; + } + // altrimenti dovrebbe essere sovrapposizione + else { + // indice di inizio + int h = ( i > 0 ? i - 1 : int( vInters.size()) - 1) ; + // verifico se sovrapposizione + if ( ( vInters[h].first == CSIT_IN_ON || vInters[h].first == CSIT_OUT_ON) && + ( vInters[i].first == CSIT_ON_IN || vInters[i].first == CSIT_ON_OUT)) { + PtrOwner pCrvRes( pCrv->CopyParamRange( vInters[h].second, vInters[i].second)) ; + if ( IsNull( pCrvRes)) + return GDB_ID_NULL ; + // lo inserisco nel DB geometrico + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvRes)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + // aggiorno parametri + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nCrvCount ; + // assegno info di tipo + pGeomDB->SetInfo( nNewId, "CSI_INI", GetCurveSurfTmIntersType( vInters[h].first) + + " (" + ToString( vInters[h].second) + ")") ; + pGeomDB->SetInfo( nNewId, "CSI_FIN", GetCurveSurfTmIntersType( vInters[i].first) + + " (" + ToString( vInters[i].second) + ")") ; + } + } + } + + return nFirstId ; +} + +//------------------------------------------------------------------------------- +int +ExeCurveSurfTmInters( const int nCrvId, const int nStmId, const int nDestGrpId, int* pnPntCount, int* pnCrvCount) +{ + // eseguo + int nPntCount{ 0}, nCrvCount{ 0} ; + int nFirstId = MyCurveSurfTmInters( nCrvId, nStmId, nDestGrpId, nPntCount, nCrvCount) ; + // aggiorno contatori + if ( nFirstId != GDB_ID_NULL) { + if ( pnPntCount != nullptr) + *pnPntCount = nPntCount ; + if ( pnCrvCount != nullptr) + *pnCrvCount = nCrvCount ; + ExeSetModified() ; + } + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtCurveSurfTmInters(" + ToString( nCrvId) + "," + + ToString( nStmId) + "," + + ToString( nDestGrpId) + ")" + + " -- Id=" + ToString( nFirstId) + ", nPntCnt=" + ToString( nPntCount) + ", nCrvCnt=" + ToString( nCrvCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} + //------------------------------------------------------------------------------- static bool MyChainCurvesForSurfSurfInters( const BIPNTVECTOR& vBpt, IGeomDB* pGeomDB, int nDestGrpId, int nId1, double dToler, diff --git a/LUA_GeoInters.cpp b/LUA_GeoInters.cpp index a4c9eca..1fe22cf 100644 --- a/LUA_GeoInters.cpp +++ b/LUA_GeoInters.cpp @@ -341,6 +341,32 @@ LuaCurveCurveInters( lua_State* L) return 3 ; } +//---------------------------------------------------------------------------- +static int +LuaCurveSurfTmInters( lua_State* L) +{ + // 3 parametri : nCrvId, nStmId, nDestGrpId + int nCrvId ; + LuaCheckParam( L, 1, nCrvId) + int nStmId ; + LuaCheckParam( L, 2, nStmId) + int nDestGrpId ; + LuaCheckParam( L, 3, nDestGrpId) ; + LuaClearStack( L) ; + // eseguo l'intersezione + int nPntCount = 0 ; + int nCrvCount = 0 ; + int nNewId = ExeCurveSurfTmInters( nCrvId, nStmId, nDestGrpId, &nPntCount, &nCrvCount) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + LuaSetParam( L, nPntCount) ; + LuaSetParam( L, nCrvCount) ; + return 3 ; +} + //---------------------------------------------------------------------------- static int LuaSurfTmSurfTmInters( lua_State* L) @@ -386,6 +412,7 @@ LuaInstallGeoInters( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtParPlanesSurfTmInters", LuaParPlanesSurfTmInters) ; bOk = bOk && luaMgr.RegisterFunction( "EgtPlaneVolZmapInters", LuaPlaneVolZmapInters) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCurveInters", LuaCurveCurveInters) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCurveSurfTmInters", LuaCurveSurfTmInters) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSurfTmInters", LuaSurfTmSurfTmInters) ; return bOk ; }