This commit is contained in:
Daniele Bariletti
2026-07-23 17:38:03 +02:00
2 changed files with 66 additions and 4 deletions
+38
View File
@@ -491,6 +491,44 @@ ExeSurfFrRotateSimpleNoCollision( int nId1, int nId2, const Point3d& ptCen, doub
return ( bOk && CAvSimpleSurfFrMove( *pSfr1, *pSfr2L).Rotate(ptCenL, dAngDeg)) ;
}
//-------------------------------------------------------------------------------
bool
ExeCutSurfFrPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, bool bInVsOut, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la regione piana
ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pSfr != nullptr) ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ;
// porto in locale il punto e la normale del piano
Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ;
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ;
// calcolo il piano di taglio
Plane3d plPlane ;
bOk = bOk && plPlane.Set( ptOnL, vtNL) ;
// se la parte da conservare è Out, allora inverto il piano
if ( ! bInVsOut)
plPlane.Invert() ;
// eseguo il taglio
bOk = bOk && pSfr->Cut( plPlane) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCutSurfFrPlane(" + IdToString( nId) + ",{" +
ToString( ptOn) + "},{" +
ToString( vtN) + "}," +
( bInVsOut ? "true" : "false") + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
}
//-------------------------------------------------------------------------------
bool
ExeSurfTmMoveVertex( int nId, int nVert, const Point3d& ptNewVert, int nRefType, bool bUpdate)
+28 -4
View File
@@ -77,11 +77,34 @@ LuaApproxSurf( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCutSurfFrPlane( lua_State* L)
{
// 4 o 5 parametri : SfrId, ptOn, vtN, bInVsOut [, nRefType]
int nSfrId ;
LuaCheckParam( L, 1, nSfrId)
Point3d ptOn ;
LuaCheckParam( L, 2, ptOn)
Vector3d vtN ;
LuaCheckParam( L, 3, vtN)
bool bInVsOut ;
LuaGetParam( L, 4, bInVsOut) ;
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 5, nRefType) ;
LuaClearStack( L) ;
// taglio la regione con ilpiano
bool bOk = ExeCutSurfFrPlane( nSfrId, ptOn, vtN, bInVsOut, nRefType) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSurfFrAdd( lua_State* L)
{
// 2 parametro : Id1, Id2
// 2 parametri : Id1, Id2
int nId1 ;
LuaCheckParam( L, 1, nId1)
int nId2 ;
@@ -686,15 +709,16 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtInvertSurf", LuaInvertSurf) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeSurf", LuaExplodeSurf) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtApproxSurf", LuaApproxSurf) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfFrPlane", LuaCutSurfFrPlane) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrAdd", LuaSurfFrAdd) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrSubtract", LuaSurfFrSubtract) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrIntersect", LuaSurfFrIntersect) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrOffset", LuaSurfFrOffset) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrOffsetAdv", LuaSurfFrOffsetAdv) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrEraseChunk", LuaSurfFrEraseChunk) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmMoveVertex", LuaSurfTmMoveVertex) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmMoveFacet", LuaSurfTmMoveFacet) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmToTriangles", LuaSurfTmToTriangles) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmMoveVertex", LuaSurfTmMoveVertex) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmMoveFacet", LuaSurfTmMoveFacet) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmToTriangles", LuaSurfTmToTriangles) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRemoveFacet", LuaSurfTmRemoveFacet) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSwapFacets", LuaSurfTmSwapFacets) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRemovePart", LuaSurfTmRemovePart) ;