diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 7ab640e..4e8fe44 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -2141,7 +2141,7 @@ ExeCreateSurfBzByRegion( int nParentId, const INTVECTOR& vCrvIds, double dLinTol { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; @@ -2182,11 +2182,11 @@ ExeCreateSurfBzByRegion( int nParentId, const INTVECTOR& vCrvIds, double dLinTol //------------------------------------------------------------------------------- int ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, bool bCapEnds, - double dLinTol, int nRefType) + double dLinTol, int nRefType, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; @@ -2200,7 +2200,6 @@ ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, b // porto in locale il vettore estrusione Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr, nRefType, frLoc) ; // creo la superficie e la inserisco nel DB - int nFirstId = GDB_ID_NULL ; double dAndTolStdDeg = 15 ; Plane3d plPlane ; double dArea ; @@ -2208,7 +2207,7 @@ ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, b pCrv->ApproxWithLines( dLinTol, dAndTolStdDeg, ICurve::APL_STD, plApprox) ; double dOrthoExtr = 0 ; if ( bCapEnds && plApprox.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)){ - dOrthoExtr = plPlane.GetVersN() * vtExtr ; + dOrthoExtr = plPlane.GetVersN() * vtExtrL ; if ( ( abs( dOrthoExtr) < EPS_SMALL)) return GDB_ID_NULL ; if ( dOrthoExtr < 0) @@ -2218,21 +2217,31 @@ ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, b PtrOwner pSbz( bOk ? GetSurfBezierByExtrusion( pCrv, vtExtrL, false, dLinTol) : nullptr ) ; bOk = bOk && ! IsNull( pSbz) ; // inserisco la superficie nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ; - bOk = bOk && ( nNewId != GDB_ID_NULL) ; - + int nFirstId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ; + bOk = bOk && ( nFirstId != GDB_ID_NULL) ; + int nCount = ( bOk ? 1 : 0) ; // se richiesta chiusura agli estremi - if ( bCapEnds && bOk) { + if ( bOk && bCapEnds) { PtrOwner pSrfBzTop( CreateSurfBezier()) ; - pSrfBzTop->CreateByFlatContour( plApprox) ; - pSrfBzTop->Translate( vtExtrL) ; - pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ; + bOk = ( ! IsNull( pSrfBzTop) && + pSrfBzTop->CreateByFlatContour( plApprox) && + pSrfBzTop->Translate( vtExtrL)) ; + int nTopId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) : GDB_ID_NULL) ; PtrOwner pSrfBzBottom( CreateSurfBezier()) ; - pSrfBzBottom->CreateByFlatContour( plApprox) ; - pSrfBzBottom->Invert() ; - pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ; + bOk = ( ! IsNull( pSrfBzBottom) && + pSrfBzBottom->CreateByFlatContour( plApprox) && + pSrfBzBottom->Invert()) ; + int nBotId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) : GDB_ID_NULL) ; + if ( nTopId == GDB_ID_NULL || nBotId == GDB_ID_NULL) { + pGeomDB->Erase( nFirstId) ; + pGeomDB->Erase( nTopId) ; + pGeomDB->Erase( nBotId) ; + nFirstId = GDB_ID_NULL ; + nCount = 0 ; + } } - + if ( pnCount != nullptr) + *pnCount = nCount ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -2242,7 +2251,7 @@ ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, b ( bCapEnds ? "true" : "false") + "," + ToString( dLinTol) + "," + RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nFirstId) ; + " -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo della nuova entità diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 3473e12..5a3e372 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 2d88ffc..a96b2c0 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -1165,7 +1165,7 @@ LuaCreateSurfBzByRegion( lua_State* L) static int LuaCreateSurfBzByExtrusion( lua_State* L) { - // 3 o 4 o 5 o 6 parametri : ParentId, CrvId, vtExtr [, bool bCapEnds] [, dTol] [, nRefType] + // 3 o 4 o 5 o 6 parametri : ParentId, CrvId, vtExtr [, bool bCapEnds] [, dTol] [, nRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; @@ -1182,14 +1182,16 @@ LuaCreateSurfBzByExtrusion( lua_State* L) int nRefType = RTY_DEFAULT ; LuaGetParam( L, nPar, nRefType) ; LuaClearStack( L) ; - // creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi - int nId = ExeCreateSurfBzByExtrusion( nParentId, nCrvId, vtExtr, bCapEnds, dLinTol, nRefType) ; + // creo SurfBezier estrudendo un percorso, se piano si possono mettere i tappi + int nCount = 0 ; + int nId = ExeCreateSurfBzByExtrusion( nParentId, nCrvId, vtExtr, bCapEnds, dLinTol, nRefType, &nCount) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; else LuaSetParam( L) ; - return 1 ; + LuaSetParam( L, nCount) ; + return 2 ; } //-------------------------------------------------------------------------------