From 4f42606cd3adcea2735748414e0f61d8a32aed52 Mon Sep 17 00:00:00 2001 From: SaraP Date: Tue, 31 Jan 2023 15:35:43 +0100 Subject: [PATCH] EgtExecutor 2.5a5 : - aggiunta funzione Exe e Lua CurveCurveInters. --- EXE_GeoInters.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++++ EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_GeoInters.cpp | 25 ++++++++++++++ 3 files changed, 111 insertions(+) diff --git a/EXE_GeoInters.cpp b/EXE_GeoInters.cpp index 822a7eb..82903ca 100644 --- a/EXE_GeoInters.cpp +++ b/EXE_GeoInters.cpp @@ -1005,6 +1005,92 @@ ExePlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, co return nFirstId ; } +//------------------------------------------------------------------------------- +int +MyCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int& nCount) +{ + 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 le curve e le porto nel riferimento del gruppo di destinazione + PtrOwner pCrv1( GetCurve( pGeomDB->GetGeoObj( nId1))->Clone()) ; + if ( IsNull( pCrv1)) + return GDB_ID_NULL ; + Frame3d frCrv1 ; + if ( ! pGeomDB->GetGlobFrame( nId1, frCrv1)) + return GDB_ID_NULL ; + pCrv1->LocToLoc( frCrv1, frDest) ; + + PtrOwner pCrv2( GetCurve( pGeomDB->GetGeoObj( nId2))->Clone()) ; + if ( IsNull( pCrv2)) + return GDB_ID_NULL ; + Frame3d frCrv2 ; + if ( ! pGeomDB->GetGlobFrame( nId2, frCrv2)) + return GDB_ID_NULL ; + pCrv2->LocToLoc( frCrv2, frDest) ; + + // intersezione fra le curve nel piano XY locale + IntersCurveCurve intCC( *pCrv1, *pCrv2, true) ; + int nInters = intCC.GetIntersCount() ; + // recupero i risultati + for ( int i = 0 ; i < nInters ; i++) { + + int nNewId = GDB_ID_NULL ; + IntCrvCrvInfo aInfo ; + intCC.GetIntCrvCrvInfo( i, aInfo) ; + if ( aInfo.bOverlap) { + // è un tratto di curva + PtrOwner pCrvRes( pCrv1->CopyParamRange( aInfo.IciA[0].dU, aInfo.IciA[1].dU)) ; + if ( IsNull( pCrvRes)) + return GDB_ID_NULL ; + // lo inserisco nel DB geometrico + nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvRes)) ; + } + else { + // è un punto + PtrOwner pGeoPnt( CreateGeoPoint3d()) ; + if ( IsNull( pGeoPnt)) + return GDB_ID_NULL ; + pGeoPnt->Set( aInfo.IciA[0].ptI) ; + // lo inserisco nel DB geometrico + nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoPnt)) ; + } + + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nCount ; + } + + return nFirstId ; +} + +//------------------------------------------------------------------------------- +int +ExeCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int* pnCount) +{ + // eseguo + int nCount{ 0 } ; + int nFirstId = MyCurveCurveInters( nId1, nId2, nDestGrpId, nCount) ; + // aggiorno contatori + if ( nFirstId != GDB_ID_NULL) { + if ( pnCount != nullptr) + *pnCount = nCount ; + ExeSetModified() ; + } + + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} + //------------------------------------------------------------------------------- static bool MyLineVolZmapInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType, INTDBLVECTOR& vInters) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index ec04b433e114caaee4a722e12fb1b9d07cdd9334..4ba1e121e974baa9d964d664e702e19dfb98c707 100644 GIT binary patch delta 236 zcmX>#neo(Q#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|Hz4<1yA~U1u z=HG0tAj*+zISZI~oN4j~!74`6$&OsfoBM=pK%%F`z-k1g5Na9}VQS)(_~ePTbn;DR v>B%45mQCh!STy;UlYn48*nys42j&1BmIzeQx_OSX4l`CM>CGS9ZZQD>u);vq delta 249 zcmX>#neo(Q#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+ghlj4}o{f@