From 560d7af7009ce333616318a9f5f5219d63316863 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Mon, 15 Jul 2024 17:34:32 +0200 Subject: [PATCH 1/5] EgtExecutor 2.6g4 : - aggiornamento versione. --- EgtExecutor.rc | Bin 18890 -> 18890 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 3f7c8f03e1dc3a0b283e995656da51d405cbb15b..983c7e1710e8d0e94a70693f55558977ba1f9219 100644 GIT binary patch delta 97 zcmX>#neo(Q#tq-t7)>^RXLDs{G@0xusJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlClnT@VP<|hX delta 97 zcmX>#neo(Q#tq-t7>zf7XLDs{G@k4zsJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlClnT@VPU0Vc From ddbc2a81e6ed762ae7a3ce4da7aa6f2660ccdbcb Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Tue, 16 Jul 2024 11:22:58 +0200 Subject: [PATCH 2/5] EgtExecutor : - piccole aggiunte alla chiamata delle funzioni per le bezier - aggiunta della chiamata alla funzione SurfBzByPointCurve. --- EXE_GdbCreateSurf.cpp | 37 +++++++++++++++++++++++++++++++++++++ EXE_GdbGetCurve.cpp | 15 ++++++++++++++- EXE_GdbGetSurf.cpp | 15 ++++++++++++--- EXE_GdbModifyCurve.cpp | 4 ++-- LUA_GdbCreateSurf.cpp | 13 ++++++------- LUA_GdbGetCurve.cpp | 8 +++++--- LUA_GdbGetSurf.cpp | 8 +++++--- 7 files changed, 81 insertions(+), 19 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index b31023f..32a5a59 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -1174,6 +1174,43 @@ ExeCreateSurfTmByRevolve( int nParentId, int nCrvId, return nNewId ; } +//------------------------------------------------------------------------------- +int +ExeCreateSurfBzByPointCurve( int nParentId, int nCrvId, const Point3d& ptTop, + bool bCapEnds, double dLinTol, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + bool bOk = true ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // recupero la curva in locale + CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ; + bOk = bOk && ( CrvLoc.Get() != nullptr) ; + // porto in locale punto e vettore asse + Point3d ptAxL = GetPointLocal( pGeomDB, ptTop, nRefType, frLoc) ; + // calcolo la superficie + ISurfBezier* pSTM = ( bOk ? GetSurfBezierRuled( ptTop, CrvLoc, dLinTol) : nullptr) ; + // inserisco la superficie nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfBzByPointCurve(" + IdToString( nParentId) + "," + + ToString( nCrvId) + ",{" + + ToString( ptTop) + "},{" + + ( bCapEnds ? "true" : "false") + "," + + ToString( dLinTol) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} + //------------------------------------------------------------------------------- int ExeCreateSurfTmByScrewing( int nParentId, int nCrvId, diff --git a/EXE_GdbGetCurve.cpp b/EXE_GdbGetCurve.cpp index ffc188d..68c9674 100644 --- a/EXE_GdbGetCurve.cpp +++ b/EXE_GdbGetCurve.cpp @@ -739,12 +739,23 @@ ExeCurveCompoGetTempParam( int nId, DBLVECTOR& vParam, int nParamInd) //---------------------------------------------------------------------------- int -ExeShowCurveBezierControlPoints( int nCrvId, int* pnCount) +ExeShowCurveBezierControlPoints( int nCrvId, int nDestGrpId, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) // recupero la curva di bezier IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nCrvId) ; + if ( pGeoObj->GetType() != CRV_BEZIER) + return GDB_ID_NULL ; + // recupero il riferimento della curva + Frame3d frCrv ; + bool bOk = true ; + bOk = bOk && pGeomDB->GetGlobFrame( nCrvId, frCrv) ; + // recupero il riferimento di destinazione + Frame3d frDest ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ; + if ( ! bOk) + return GDB_ID_NULL ; int nType = pGeoObj->GetType() ; if ( nType == CRV_COMPO) { const ICurveComposite* pCrvCompo = GetCurveComposite( pGeoObj) ; @@ -769,6 +780,7 @@ ExeShowCurveBezierControlPoints( int nCrvId, int* pnCount) //else // pGeoPt->Set( pCrvBezier->GetControlPoint( i) * pCrvBezier->GetControlWeight( i)) ; pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ; + pGeoPt->LocToLoc( frCrv, frDest) ; int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParent, pGeoPt) ; if ( nFirstId == GDB_ID_NULL) nFirstId = nId ; @@ -797,6 +809,7 @@ ExeShowCurveBezierControlPoints( int nCrvId, int* pnCount) //else // pGeoPt->Set( pCrvBezier->GetControlPoint( i) * pCrvBezier->GetControlWeight( i)) ; pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ; + pGeoPt->LocToLoc( frCrv, frDest) ; int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParent, pGeoPt) ; if ( nFirstId == GDB_ID_NULL) nFirstId = nId ; diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index 7375c6a..d12a755 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -1727,7 +1727,7 @@ ExeExtractSurfBezierLoops( int nId, int nDestGrpId, int* pnCount) //---------------------------------------------------------------------------- int -ExeShowSurfBezierControlPoints( int nSrfId, int* pnCount) +ExeShowSurfBezierControlPoints( int nSrfId, int nDestGrpId, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) @@ -1736,6 +1736,15 @@ ExeShowSurfBezierControlPoints( int nSrfId, int* pnCount) IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nSrfId) ; if ( pGeoObj->GetType() != SRF_BEZIER) return GDB_ID_NULL ; + // recupero il riferimento della superficie + Frame3d frSurf ; + bool bOk = true ; + bOk = bOk && pGeomDB->GetGlobFrame( nSrfId, frSurf) ; + // recupero il riferimento di destinazione + Frame3d frDest ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ; + if ( ! bOk) + return GDB_ID_NULL ; int nDegU = - 1, nDegV = - 1, nSpanU = - 1, nSpanV = - 1 ; bool bRat = false, bTrimmed = false ; ISurfBezier* pSrfBez = GetSurfBezier( pGeoObj) ; @@ -1743,10 +1752,10 @@ ExeShowSurfBezierControlPoints( int nSrfId, int* pnCount) int nFirstId = -1 ; int nCount = 0 ; for ( int i = 0 ; i < (nDegU * nSpanU + 1) * ( nDegV * nSpanV + 1) ; ++i) { - bool bOk = true ; IGeoPoint3d* pGeoPt( CreateGeoPoint3d()) ; pGeoPt->Set( pSrfBez->GetControlPoint( i, &bOk)) ; - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParent, pGeoPt) ; + pGeoPt->LocToLoc( frSurf, frDest) ; + int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, pGeoPt) ; if ( nFirstId == GDB_ID_NULL) nFirstId = nId ; if ( nId != GDB_ID_NULL) diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index c3d3c67..39bd86b 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -2921,7 +2921,7 @@ ExeCurveBezierIncreaseDegree( int nCrvId) // recupero la curva const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ; if ( pCrv == nullptr) - return GDB_ID_NULL ; + return false ; //// recupero il riferimento della curva //Frame3d frCrv ; //if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv)) @@ -2961,7 +2961,7 @@ ExeCurveBezierDecreaseDegree( int nCrvId, double dTol) // recupero la curva const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ; if ( pCrv == nullptr) - return GDB_ID_NULL ; + return false ; //// recupero il riferimento della curva //Frame3d frCrv ; //if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv)) diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 3c74398..bde8c3a 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -1128,16 +1128,14 @@ LuaCreateSurfBzByRevolve( lua_State* L) static int LuaCreateSurfBzByPointCurve( lua_State* L) { - // 4 o 5 o 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx [, bCapEnds] [, dTol] [, nRefType] + // 3 o 4 o 5 o 6 parametri : ParentId, CrvId, ptAx, vtAx [, bCapEnds] [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; LuaCheckParam( L, 2, nCrvId) - Point3d ptAx ; - LuaCheckParam( L, 3, ptAx) - Vector3d vtAx ; - LuaCheckParam( L, 4, vtAx) - int nPar = 5 ; + Point3d ptTop ; + LuaCheckParam( L, 3, ptTop) + int nPar = 4 ; bool bCapEnds = false ; if ( LuaGetParam( L, nPar, bCapEnds)) ++ nPar ; @@ -1149,7 +1147,7 @@ LuaCreateSurfBzByPointCurve( lua_State* L) ++ nPar ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano - int nId = ExeCreateSurfBzByRevolve( nParentId, nCrvId, ptAx, vtAx, bCapEnds, dLinTol, nRefType) ; + int nId = ExeCreateSurfBzByPointCurve( nParentId, nCrvId, ptTop, bCapEnds, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; @@ -1228,6 +1226,7 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByExtrusion", LuaCreateSurfBzByExtrusion) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByScrewing", LuaCreateSurfBzByScrewing) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByRevolve", LuaCreateSurfBzByRevolve) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByPointCurve", LuaCreateSurfBzByPointCurve) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzRuled", LuaCreateSurfBzRuled) ; return bOk ; } diff --git a/LUA_GdbGetCurve.cpp b/LUA_GdbGetCurve.cpp index d779ee5..657dd40 100644 --- a/LUA_GdbGetCurve.cpp +++ b/LUA_GdbGetCurve.cpp @@ -588,12 +588,14 @@ LuaCurveCompoGetTempParam( lua_State* L) static int LuaShowCurveBezierControlPoints( lua_State* L) { - // 1 parametro : nCrvId + // 2 parametri : nCrvId, nDestGrpId int nCrvId ; LuaCheckParam( L, 1, nCrvId) - LuaClearStack( L) ; + int nDestGrpId ; + LuaCheckParam( L, 2, nDestGrpId) + LuaClearStack( L) ; int nCount = 0 ; - int nId = ExeShowCurveBezierControlPoints( nCrvId, &nCount) ; + int nId = ExeShowCurveBezierControlPoints( nCrvId, nDestGrpId, &nCount) ; // restituisco il risultato if ( nId != GDB_ID_NULL) { LuaSetParam( L, nId) ; diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index a49ea43..f78fb23 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -1192,12 +1192,14 @@ LuaExtractSurfBezierLoops( lua_State* L) static int LuaShowSurfBezierControlPoints( lua_State* L) { - // 1 parametro : nCrvId + // 2 parametri : nCrvId, nDestGrpId int nCrvId ; LuaCheckParam( L, 1, nCrvId) - LuaClearStack( L) ; + int nDestGrpId ; + LuaCheckParam( L, 2, nDestGrpId) + LuaClearStack( L) ; int nCount = 0 ; - int nId = ExeShowSurfBezierControlPoints( nCrvId, &nCount) ; + int nId = ExeShowSurfBezierControlPoints( nCrvId, nDestGrpId, &nCount) ; // restituisco il risultato if ( nId != GDB_ID_NULL) { LuaSetParam( L, nId) ; From 9bc89dfc35a4eb5bc31fe7bd354793d2be989b80 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Tue, 16 Jul 2024 12:00:59 +0200 Subject: [PATCH 3/5] EgtExecutor : - piccole modifiche. --- EXE_GdbCreateSurf.cpp | 4 ++-- LUA_GdbModifyCurve.cpp | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 32a5a59..a3031a3 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -1190,9 +1190,9 @@ ExeCreateSurfBzByPointCurve( int nParentId, int nCrvId, const Point3d& ptTop, CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ; bOk = bOk && ( CrvLoc.Get() != nullptr) ; // porto in locale punto e vettore asse - Point3d ptAxL = GetPointLocal( pGeomDB, ptTop, nRefType, frLoc) ; + Point3d ptTopL = GetPointLocal( pGeomDB, ptTop, nRefType, frLoc) ; // calcolo la superficie - ISurfBezier* pSTM = ( bOk ? GetSurfBezierRuled( ptTop, CrvLoc, dLinTol) : nullptr) ; + ISurfBezier* pSTM = ( bOk ? GetSurfBezierRuled( ptTopL, CrvLoc, dLinTol) : nullptr) ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; ExeSetModified() ; diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 859d671..4c24935 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -1174,7 +1174,6 @@ LuaCurveBezierIncreaseDegree( lua_State* L) LuaCheckParam( L, 1, nId) LuaClearStack( L) ; // eseguo - int nCount = 0 ; bool bOk = ExeCurveBezierIncreaseDegree( nId) ; LuaSetParam( L, bOk) ; @@ -1190,7 +1189,6 @@ LuaCurveBezierDecreaseDegree( lua_State* L) LuaCheckParam( L, 1, nId) LuaClearStack( L) ; // eseguo - int nCount = 0 ; bool bOk = ExeCurveBezierDecreaseDegree( nId) ; LuaSetParam( L, bOk) ; From 2fc0e4994d3a704a7579ec5c317a07946f6f16cf Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 17 Jul 2024 09:14:03 +0200 Subject: [PATCH 4/5] EgtExecutor : - aggiunta del cap alla funzione Bez by extrusion. --- EXE_GdbCreateSurf.cpp | 75 +++++++++++++++++++++++++++++++++++++++++-- EXE_GdbGetSurf.cpp | 1 - LUA_GdbCreateSurf.cpp | 12 ++++--- 3 files changed, 80 insertions(+), 8 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index a3031a3..48efc98 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -2025,7 +2025,7 @@ ExeCreateSurfBzByRegion( int nParentId, const INTVECTOR& vCrvIds, double dLinTol //------------------------------------------------------------------------------- int -ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vector3d& vtExtr, +ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vector3d& vtExtr, bool bCapEnds, double dLinTol, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -2038,7 +2038,7 @@ ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vecto // recupero le curve in locale CURVELOCALVECTOR vCrvLoc ; vCrvLoc.reserve( vCrvIds.size()) ; - ICURVEPVECTOR vCrvP ; + CICURVEPVECTOR vCrvP ; vCrvP.reserve( vCrvIds.size()) ; for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) { int nId = (( vCrvIds[i] != GDB_ID_SEL) ? vCrvIds[i] : pGeomDB->GetFirstSelectedObj()) ; @@ -2063,6 +2063,47 @@ ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vecto if ( bOk && nFirstId == GDB_ID_NULL) nFirstId = nNewId ; } + // se richiesta chiusura agli estremi + if ( bCapEnds) { + // verifico che la curva sia chiusa e piatta + Plane3d plPlane ; + double dArea ; + PolyLine plApprox ; + double dAndTolDeg = 5 ; + vCrvP[0]->ApproxWithLines( dLinTol, dAndTolDeg, ICurve::APL_STD, plApprox) ; + if ( plApprox.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)) { + // componente dell'estrusione perpendicolare al piano della curva + double dOrthoExtr = plPlane.GetVersN() * vtExtr ; + if ( ( abs( dOrthoExtr) > EPS_SMALL)) { + if( vCrvIds.size() == 1) { + PtrOwner pSrfBzTop( CreateSurfBezier()) ; + pSrfBzTop->CreateByFlatContour( plApprox) ; + pSrfBzTop->Translate( vtExtrL) ; + pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ; + PtrOwner pSrfBzBottom( CreateSurfBezier()) ; + pSrfBzBottom->CreateByFlatContour( plApprox) ; + pSrfBzBottom->Invert() ; + pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ; + } + else { + // riordino le curve in modo che la prima sia quella esterna e tutte le altre dopo + POLYLINEVECTOR vPL ; + Vector3d vtN ; + if ( ! CalcRegionPolyLines( vCrvP, dLinTol, vPL, vtN)) + return nFirstId ; + PtrOwner pSrfBzTop( CreateSurfBezier()) ; + pSrfBzTop->CreateByRegion( vPL) ; + pSrfBzTop->Translate( vtExtrL) ; + pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ; + PtrOwner pSrfBzBottom( CreateSurfBezier()) ; + pSrfBzBottom->CreateByRegion( vPL) ; + pSrfBzBottom->Invert() ; + pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ; + } + } + } + } + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -2141,6 +2182,36 @@ ExeCreateSurfBzByRevolve( int nParentId, int nCrvId, Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ; // calcolo la superficie ISurfBezier* pSbz = ( bOk ? GetSurfBezierByRevolve( CrvLoc, ptAxL, vtAxL, bCapEnds, dLinTol) : nullptr) ; + //// finché non ho le SurfCompo creo qui i cap + //if ( bCapEnds) { + // // calcola la bbox della superficie + // BBox3d bbox3dSurf ; + // int nDegU, nDegV, nSpanU, nSpanV ; + // bool bTrim, bRat ; + // pSbz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bTrim, bRat) ; + // int nPointCount = ( nDegU * nSpanU + 1) * ( nDegV * nSpanV + 1) ; + // for ( int p = 0 ; p < nPointCount ; ++p) { + // bool bPointOk = true ; + // Point3d ptCtrl = pSbz->GetControlPoint( p, &bPointOk) ; + // bbox3dSurf.Add( ptCtrl) ; + // } + // // recupero i loop + // ICRVCOMPOPOVECTOR vCCLoop ; + // pSbz->GetLoops( vCCLoop, true) ; + // // devo distinguere tra il loop superiore e quello inferiore + // double dAngTolDeg = 5 ; + // PolyLine plEdge ; vCCLoop[0]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge) ; + // Plane3d plPlane ; double dArea ; + // bOk = bOk && ! plEdge.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ; + // Vector3d vtN = plPlane.GetVersN() ; + // // vedo come questa normale è orientata rispetto alla bbox della superficie + // Point3d ptCen ; vCCLoop[0]->GetCentroid( ptCen) ; + // double dDist = bbox3dSurf.DistFromPoint( ptCen) ; // questa mi dà anche valori negativi????? sennò è inutile + + // PtrOwner pSrfBzTop( CreateSurfBezier()) ; + // pSrfBzTop->CreateByFlatContour( ) + //} + // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ; ExeSetModified() ; diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index d12a755..4451afe 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -1731,7 +1731,6 @@ ExeShowSurfBezierControlPoints( int nSrfId, int nDestGrpId, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - int nParent = pGeomDB->GetParentId( nSrfId) ; // recupero la superficie di bezier IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nSrfId) ; if ( pGeoObj->GetType() != SRF_BEZIER) diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index bde8c3a..7c5f287 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -1028,22 +1028,24 @@ LuaCreateSurfBzByRegion( lua_State* L) static int LuaCreateSurfBzByExtrusion( lua_State* L) { - // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, nRefType] + // 4 o 5 o 6 parametri : ParentId, CrvIds, vtExtr, bool bCapEnds [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) INTVECTOR vCrvIds ; LuaCheckParam( L, 2, vCrvIds) Vector3d vtExtr ; LuaCheckParam( L, 3, vtExtr) + bool bCapEnds = false ; + LuaCheckParam( L, 4, bCapEnds) double dLinTol = LIN_TOL_SRF ; int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 4, dLinTol)) - LuaGetParam( L, 5, nRefType) ; + if ( LuaGetParam( L, 5, dLinTol)) + LuaGetParam( L, 6, nRefType) ; else - LuaGetParam( L, 4, nRefType) ; + LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi - int nId = ExeCreateSurfBzByExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; + int nId = ExeCreateSurfBzByExtrusion( nParentId, vCrvIds, vtExtr, bCapEnds, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; From d6cd16b86033340ef593e5783c02cb6902bd80c1 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 17 Jul 2024 16:16:47 +0200 Subject: [PATCH 5/5] EgtExecutor : - cap come superfici separate per BezierByCurves. --- EXE_GdbCreateSurf.cpp | 73 ++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 48efc98..420a4ae 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -2182,35 +2182,52 @@ ExeCreateSurfBzByRevolve( int nParentId, int nCrvId, Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ; // calcolo la superficie ISurfBezier* pSbz = ( bOk ? GetSurfBezierByRevolve( CrvLoc, ptAxL, vtAxL, bCapEnds, dLinTol) : nullptr) ; - //// finché non ho le SurfCompo creo qui i cap - //if ( bCapEnds) { - // // calcola la bbox della superficie - // BBox3d bbox3dSurf ; - // int nDegU, nDegV, nSpanU, nSpanV ; - // bool bTrim, bRat ; - // pSbz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bTrim, bRat) ; - // int nPointCount = ( nDegU * nSpanU + 1) * ( nDegV * nSpanV + 1) ; - // for ( int p = 0 ; p < nPointCount ; ++p) { - // bool bPointOk = true ; - // Point3d ptCtrl = pSbz->GetControlPoint( p, &bPointOk) ; - // bbox3dSurf.Add( ptCtrl) ; - // } - // // recupero i loop - // ICRVCOMPOPOVECTOR vCCLoop ; - // pSbz->GetLoops( vCCLoop, true) ; - // // devo distinguere tra il loop superiore e quello inferiore - // double dAngTolDeg = 5 ; - // PolyLine plEdge ; vCCLoop[0]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge) ; - // Plane3d plPlane ; double dArea ; - // bOk = bOk && ! plEdge.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ; - // Vector3d vtN = plPlane.GetVersN() ; - // // vedo come questa normale è orientata rispetto alla bbox della superficie - // Point3d ptCen ; vCCLoop[0]->GetCentroid( ptCen) ; - // double dDist = bbox3dSurf.DistFromPoint( ptCen) ; // questa mi dà anche valori negativi????? sennò è inutile + // finché non ho le SurfCompo creo qui i cap + if ( bCapEnds) { + // calcola la bbox della superficie + BBox3d bbox3dSurf ; + int nDegU, nDegV, nSpanU, nSpanV ; + bool bTrim, bRat ; + pSbz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bTrim, bRat) ; + int nPointCount = ( nDegU * nSpanU + 1) * ( nDegV * nSpanV + 1) ; + for ( int p = 0 ; p < nPointCount ; ++p) { + bool bPointOk = true ; + Point3d ptCtrl = pSbz->GetControlPoint( p, &bPointOk) ; + bbox3dSurf.Add( ptCtrl) ; + } + // recupero i loop + ICRVCOMPOPOVECTOR vCCLoop ; + pSbz->GetLoops( vCCLoop, true) ; + // il getLoops per superfici non trimmate restituisce 1 elemento per ogni lato dello spazio parametrico. + // in questo caso la superficie è chiusa lungo il parametro V, quindi i lati 0 e 2 saranno null. + double dAngTolDeg = 5 ; + PolyLine plEdge1 ; vCCLoop[1]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge1) ; + PolyLine plEdge3 ; vCCLoop[3]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge3) ; + plEdge3.Invert() ; - // PtrOwner pSrfBzTop( CreateSurfBezier()) ; - // pSrfBzTop->CreateByFlatContour( ) - //} + //// devo distinguere tra il loop superiore e quello inferiore + //PolyLine plEdge0 ; vCCLoop[0]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge0) ; + //Plane3d plPlane ; double dArea ; + //bOk = bOk && ! plEdge0.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ; + //Vector3d vtN = plPlane.GetVersN() ; + //// vedo come questa normale è orientata rispetto alla bbox della superficie + //Point3d ptCen ; vCCLoop[0]->GetCentroid( ptCen) ; + //ptCen += vtN ; + //PolyLine plEdge1 ; vCCLoop[1]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge1) ; + //// inverto uno dei due bordi + //if ( bbox3dSurf.Encloses( ptCen)) + // plEdge0.Invert() ; + //else + // plEdge1.Invert() ; + + // creo le superfici e le inserisco nel DB + PtrOwner pSrfBzCap1( CreateSurfBezier()) ; + pSrfBzCap1->CreateByFlatContour( plEdge1) ; + pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzCap1)) ; + PtrOwner pSrfBzCap3( CreateSurfBezier()) ; + pSrfBzCap3->CreateByFlatContour( plEdge3) ; + pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzCap3)) ; + } // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;