diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 8993009..c22f97b 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -1,4 +1,4 @@ -//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- // EgalTech 2014-2015 //---------------------------------------------------------------------------- // File : EXE_GdbCreateSurf.cpp Data : 04.05.15 Versione : 1.6e1 @@ -81,7 +81,7 @@ ExeCreateSurfFrRectangle( int nParentId, const Point3d& ptIni, const Point3d& pt " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -132,7 +132,7 @@ ExeCreateSurfFrRectangle3P( int nParentId, const Point3d& ptIni, " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -181,7 +181,7 @@ ExeCreateSurfFrStadium( int nParentId, const Point3d& ptIni, const Point3d& ptCr " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -198,7 +198,7 @@ ExeCreateSurfFrDisk( int nParentId, const Point3d& ptOrig, double dRad, int nRef // porto in locale il punto e calcolo la normale in locale Point3d ptOrigL = GetPointLocal( pGeomDB, ptOrig, nRefType, frLoc) ; Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; - // calcolo riferimento per l'entità + // calcolo riferimento per l'entità Frame3d frEnt ; bOk = bOk && frEnt.Set( ptOrigL, vtNL) ; // creo il disco nel suo riferimento intrinseco @@ -218,7 +218,7 @@ ExeCreateSurfFrDisk( int nParentId, const Point3d& ptOrig, double dRad, int nRef " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -262,7 +262,7 @@ ExeCreateSurfFrFatCurve( int nParentId, int nCrvId, double dRad, bool bSquaredEn " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -318,7 +318,7 @@ MyCreateSurfFlatRegion( int nParentId, const INTVECTOR& vCrvIds, int* pnCount) // recupero la prossima superficie pSfr = SfrCntr.GetSurf() ; } - // restituisco l'identificativo della prima nuova entità + // restituisco l'identificativo della prima nuova entità if ( pnCount != nullptr) *pnCount = nCount ; return nFirstId ; @@ -341,7 +341,7 @@ ExeCreateSurfFlatRegion( int nParentId, const INTVECTOR& vCrvIds, int* pnCount) " -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nFirstId ; } @@ -390,7 +390,7 @@ ExeCreateSurfTmPlaneInBBox( int nParentId, const Point3d& ptP, const Vector3d& v " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -451,7 +451,7 @@ MyCreateSewPolygon( ISurfTriMesh* pStm, const Polygon3d& Polyg) // verifico esistenza superficie if ( pStm == nullptr) return false ; - // se poligono vuoto, non devo fare alcunché + // se poligono vuoto, non devo fare alcunché if ( Polyg.GetSideCount() == 0) return true ; // creo la superficie trimesh del poligono @@ -581,7 +581,7 @@ ExeCreateSurfTmConvexHullInBBox( int nParentId, int nId, const BBox3d& b3Box, in " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -629,7 +629,7 @@ ExeCreateSurfTmBBox( int nParentId, const BBox3d& b3Box, bool bRegular, int nRef " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -684,7 +684,7 @@ ExeCreateSurfTmBox( int nParentId, const Point3d& ptIni, const Point3d& ptCross, " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -741,7 +741,7 @@ ExeCreateSurfTmPyramid( int nParentId, const Point3d& ptIni, const Point3d& ptCr " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -783,7 +783,7 @@ ExeCreateSurfTmCylinder( int nParentId, const Point3d& ptOrig, const Vector3d& v " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -825,7 +825,7 @@ ExeCreateSurfTmCone( int nParentId, const Point3d& ptOrig, const Vector3d& vtN, " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -861,7 +861,7 @@ ExeCreateSurfTmSphere( int nParentId, const Point3d& ptOrig, " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -903,7 +903,7 @@ ExeCreateSurfTmTriangle( int nParentId, const Point3d& ptP1, const Point3d& ptP2 " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -952,7 +952,7 @@ ExeCreateSurfTmRectangle( int nParentId, const Point3d& ptO, const Point3d& ptL, " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -983,7 +983,7 @@ ExeCreateSurfTmByFlatContour( int nParentId, int nCrvId, double dLinTol) " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -1029,7 +1029,7 @@ ExeCreateSurfTmByRegion( int nParentId, const INTVECTOR& vCrvIds, double dLinTol " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -1084,7 +1084,7 @@ ExeCreateSurfTmByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vecto " -- Id=" + ToString( nFirstId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nFirstId ; } @@ -1128,7 +1128,7 @@ ExeCreateSurfTmByRegionExtrusion( int nParentId, const INTVECTOR& vCrvIds, const " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -1168,7 +1168,7 @@ ExeCreateSurfTmByRevolve( int nParentId, int nCrvId, " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -1210,7 +1210,7 @@ ExeCreateSurfTmByScrewing( int nParentId, int nCrvId, " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -1247,13 +1247,13 @@ ExeCreateSurfTmRectSwept( int nParentId, double dDimH, double dDimV, double dBev " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } //------------------------------------------------------------------------------- int -ExeCreateSurfTmSwept( int nParentId, int nSectId, int nGuideId, bool bCapEnds, double dLinTol) +ExeCreateSurfTmSwept( int nParentId, int nSectId, int nGuideId, bool bCapEnds, double dLinTol, Vector3d* vtStatic) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -1262,17 +1262,40 @@ ExeCreateSurfTmSwept( int nParentId, int nSectId, int nGuideId, bool bCapEnds, d // recupero il riferimento locale Frame3d frLoc ; bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // recupero la sezione in locale - CurveLocal CrvSect( pGeomDB, nSectId, frLoc) ; - bOk = bOk && ( CrvSect.Get() != nullptr) ; // recupero la guida in locale CurveLocal CrvGuide( pGeomDB, nGuideId, frLoc) ; bOk = bOk && ( CrvGuide.Get() != nullptr) ; - // creo la superficie trimesh + // inizializzazione superficie e suo Id ISurfTriMesh* pSTM = nullptr ; - pSTM = ( bOk ? GetSurfTriMeshSwept( CrvSect, CrvGuide, bCapEnds, dLinTol) : nullptr) ; - // inserisco la superficie trimesh nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; + int nNewId = GDB_ID_NULL ; + // recupero il tipo di entità della sezione + int nSecType = pGeomDB->GetGeoType( nSectId) ; + + // controllo se la sezione è definita da una curva + if ( nSecType == CRV_LINE || nSecType == CRV_ARC || + nSecType == CRV_BEZIER || nSecType == CRV_COMPO) { + // recupero la sezione in locale + CurveLocal CrvSect( pGeomDB, nSectId, frLoc) ; + bOk = bOk && ( CrvSect.Get() != nullptr) ; + // calcolo la Swept + pSTM = ( bOk ? GetSurfTriMeshSwept( CrvSect, CrvGuide, bCapEnds, dLinTol, vtStatic) : nullptr) ; + // inserisco la superficie trimesh nel DB + nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; + } + // controllo se la sezione è definita da una regione piana + else if ( nSecType == SRF_FLATRGN) { + // recupero la sezione e la porto nel frame corrente + PtrOwner pSfrSec( CloneSurfFlatRegion( pGeomDB->GetGeoObj( nSectId))) ; + Frame3d frSec ; + if ( ! IsNull( pSfrSec) && pGeomDB->GetGlobFrame( nSectId, frSec) && + pSfrSec->LocToLoc( frSec, frLoc)) { + // calcolo la Swept + pSTM = ( bOk ? GetSurfTriMeshSwept( pSfrSec, CrvGuide, bCapEnds, dLinTol, vtStatic) : nullptr) ; + // inserisco la superficie trimesh nel DB + nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; + } + } + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -1284,7 +1307,7 @@ ExeCreateSurfTmSwept( int nParentId, int nSectId, int nGuideId, bool bCapEnds, d " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -1321,7 +1344,7 @@ ExeCreateSurfTmTransSwept( int nParentId, int nSectId, int nGuideId, bool bCapEn " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -1338,7 +1361,7 @@ ExeCreateSurfTmRuled( int nParentId, int nPtOrCrvId1, int nPtOrCrvId2, int nType bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; // creo la superficie trimesh ISurfTriMesh* pSTM = nullptr ; - // se la prima entità è un punto e la seconda una curva + // se la prima entità è un punto e la seconda una curva if ( pGeomDB->GetGeoType( nPtOrCrvId1) == GEO_PNT3D && ( pGeomDB->GetGeoType( nPtOrCrvId2) & GEO_CURVE) != 0) { // recupero il punto in locale @@ -1354,7 +1377,7 @@ ExeCreateSurfTmRuled( int nParentId, int nPtOrCrvId1, int nPtOrCrvId2, int nType // calcolo la superficie pSTM = ( bOk ? GetSurfTriMeshRuled( ptP, CrvLoc, dLinTol) : nullptr) ; } - // se la prima entità è una curva e la seconda un punto + // se la prima entità è una curva e la seconda un punto else if ( ( pGeomDB->GetGeoType( nPtOrCrvId1) & GEO_CURVE) != 0 && pGeomDB->GetGeoType( nPtOrCrvId2) == GEO_PNT3D) { // recupero la curva in locale @@ -1398,7 +1421,7 @@ ExeCreateSurfTmRuled( int nParentId, int nPtOrCrvId1, int nPtOrCrvId2, int nType " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -1509,7 +1532,7 @@ ExeCreateSurfTmBySewing( int nParentId, const INTVECTOR& vIds, bool bErase) bOk = bOk && pGeomDB->GetGlobFrame( nId, frStmS) ; // lo esprimo rispetto a quello della prima superficie frStmS.ToLoc( frLoc) ; - // se è la prima, copio + // se è la prima, copio if ( bFirst) { bOk = bOk && pStm->CopyFrom( pStmS) ; bOk = bOk && pStm->ToGlob( frStmS) ; @@ -1700,7 +1723,7 @@ ExeCreateSurfBezier( int nParentId, int nDegU, int nDegV, int nSpanU, int nSpanV " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nId ; } @@ -1754,7 +1777,7 @@ ExeCreateSurfBezierRational( int nParentId, int nDegU, int nDegV, int nSpanU, in " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nId ; } @@ -1920,6 +1943,6 @@ ExeCreateBezierSphere( int nParentId, const Point3d& ptCenter, double dR, int nR " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // resituisco l'identificativo dell'entità creata + // resituisco l'identificativo dell'entit� creata return nId ; } diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index f0c8cbc..1170fac 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -660,7 +660,7 @@ LuaCreateSurfTmRectSwept( lua_State* L) static int LuaCreateSurfTmSwept( lua_State* L) { - // 4 o 5 parametri : ParentId, SectId, GuideId, bCapEnds [, dTol] + // 4, 5 o 6 parametri : ParentId, SectId, GuideId, bCapEnds [, dTol] [, vtStatic] int nParentId ; LuaCheckParam( L, 1, nParentId) int nSectId ; @@ -670,10 +670,14 @@ LuaCreateSurfTmSwept( lua_State* L) bool bCapEnds ; LuaCheckParam( L, 4, bCapEnds) double dLinTol = LIN_TOL_SRF ; - LuaGetParam( L, 5, dLinTol) ; + Vector3d vtStatic = V_INVALID ; + if ( LuaGetParam( L, 5, dLinTol)) { + LuaGetParam( L, 6, vtStatic) ; + } LuaClearStack( L) ; // creo STM swept - int nId = ExeCreateSurfTmSwept( nParentId, nSectId, nGuideId, bCapEnds, dLinTol) ; + int nId = ExeCreateSurfTmSwept( nParentId, nSectId, nGuideId, bCapEnds, dLinTol, + vtStatic.IsValid() ? &vtStatic : nullptr) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ;