Compare commits

...

2 Commits

Author SHA1 Message Date
Daniele Bariletti e989b88dd4 Merge remote-tracking branch 'origin/HEAD' into Bezier_trim&mesh 2023-06-21 09:36:55 +02:00
Daniele Bariletti 4b58f4f522 EgtExecutor :
- aggiunta funzione per il trim delle superfici di Bezier
- aggiunta funzione per vedere la divione di in celle di una superficie
di Bezier durante la costruzione della trimesh (per debug).
2023-06-21 09:36:41 +02:00
4 changed files with 139 additions and 1 deletions
+54 -1
View File
@@ -32,7 +32,7 @@
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EGkCurveLocal.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EGkExtText.h"
using namespace std ;
//-------------------------------------------------------------------------------
@@ -1623,3 +1623,56 @@ ExeCreateSurfBezierRational( int nParentId, int nDegU, int nDegV, int nSpanU, in
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
ISurfBezier* pSurfBez = GetSurfBezier( pGeomDB->GetGeoObj( nSurfBzId)) ;
if ( pSurfBez == nullptr)
return false ;
// recupero il riferimento della superficie
Frame3d frSurf ;
if ( ! pGeomDB->GetGlobFrame( nSurfBzId, frSurf))
return false ;
bool bOk = true ;
//disegno le foglie
vector<tuple<int,Point3d,Point3d>> vLeaves ;
pSurfBez->GetLeaves( vLeaves) ;
double dFactor = 1 ;
int nId ;
for ( int k = 0 ; k < (int)vLeaves.size() ; ++k ) {
Point3d ptBL = std::get<1>(vLeaves[k]) * dFactor ;
Point3d ptTR = std::get<2>(vLeaves[k]) * dFactor ;
Point3d ptBr( ptTR.x, ptBL.y) ;
Point3d ptTl( ptBL.x, ptTR.y) ;
PolyLine PL ;
PL.AddUPoint( 0, ptBL) ;
PL.AddUPoint( 1, ptBr) ;
PL.AddUPoint( 2, ptTR) ;
PL.AddUPoint( 3, ptTl) ;
PL.AddUPoint( 4, ptBL) ;
// creo la curva e la inserisco nel GDB
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
bOk = bOk && ! IsNull( pCrvCompo) ;
// inserisco i segmenti che uniscono i punti
bOk = bOk && pCrvCompo->FromPolyLine( PL) ;
// assegno il versore estrusione
bOk = bOk && pCrvCompo->SetExtrusion( Z_AX) ;
// inserisco la curva composita nel DB
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
string sText = ToString( std::get<0>(vLeaves[k])) ;
// creo il testo e lo riempio
Point3d ptCenter( (ptBL + ptTR) / 2) ;
PtrOwner<IExtText> pTXT( CreateExtText()) ;
bOk = bOk && ! IsNull( pTXT) ;
bOk = bOk && pTXT->Set( ptCenter, Z_AX, X_AX, sText, "", false, nTextHeight) ;
// inserisco il testo nel DB
nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)): GDB_ID_NULL) ;
}
return nId ;
}
+44
View File
@@ -887,3 +887,47 @@ ExeSurfTmCut( int nId, int nCutterId, bool bInVsOut, bool bSaveOnEq)
}
return bOk ;
}
//----------------------------------------------------------------------------
static bool
MySurfBzTrim( int nId, int nTrimmerId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la superficie Bezier da trimmare
ISurfBezier* pSrfBz = GetSurfBezier( pGeomDB->GetGeoObj( nId)) ;
if ( pSrfBz == nullptr)
return false ;
// recupero il riferimento della superficie
Frame3d frSurf ;
if ( ! pGeomDB->GetGlobFrame( nId, frSurf))
return false ;
// recupero la superficie TriMesh divisore in locale alla prima
SurfLocal SurfCLoc( pGeomDB, nTrimmerId, frSurf) ;
//const ISurfTriMesh* pStmCLoc = GetSurfTriMesh( SurfCLoc) ;
const ISurfFlatRegion* pSrfFr = GetSurfFlatRegion( SurfCLoc) ;
if ( pSrfFr == nullptr)
return false ;
PtrOwner<ISurfFlatRegion> pSrfFrCopy( pSrfFr->Clone()) ;
if ( ! pSrfFr->GetNormVersor().IsZplus())
pSrfFrCopy->Invert() ;
// eseguo il taglio
return pSrfBz->SetTrimRegion( *pSrfFrCopy) ;
}
//----------------------------------------------------------------------------
bool
ExeSurfBzTrim( int nId, int nCutterId)
{
bool bOk = MySurfBzTrim( nId, nCutterId) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfTmCut(" + ToString( nId) + "," +
ToString( nCutterId) + "," +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
+23
View File
@@ -816,6 +816,28 @@ LuaCreateSurfBezierRational( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateSurfBezierLeaves( lua_State* L)
{
// 3 parametri : ParentId, nId, nTextHeight
int nParentId ;
LuaCheckParam( L, 1, nParentId)
int nSurfBzId ;
LuaCheckParam( L, 2, nSurfBzId)
int nTextHeight ;
LuaCheckParam( L, 3, nTextHeight)
LuaClearStack( L) ;
// creo la superficie
int nId = ExeCreateSurfBezierLeaves( nParentId, nSurfBzId, nTextHeight) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
@@ -850,5 +872,6 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByVolZmap", LuaCreateSurfTmByVolZmap) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezier", LuaCreateSurfBezier) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierRat", LuaCreateSurfBezierRational) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierLeaves", LuaCreateSurfBezierLeaves) ;
return bOk ;
}
+18
View File
@@ -364,6 +364,23 @@ LuaSurfTmCut( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSurfBzTrim( lua_State* L)
{
// 2 parametri : nId, nCutterId
int nId ;
LuaCheckParam( L, 1, nId)
int nCutterId ;
LuaCheckParam( L, 2, nCutterId)
LuaClearStack( L) ;
// taglio la prima superficie in base alla seconda
//bool bOk = ExeSurfTmCut( nId, nCutterId, bInVsOut, bOn) ;
bool bOk = ExeSurfBzTrim( nId, nCutterId) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbModifySurf( LuaMgr& luaMgr)
@@ -388,5 +405,6 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmResetTwoColors", LuaSurfTmResetTwoColors) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSplit", LuaSurfTmSplit) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCut", LuaSurfTmCut) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzTrim", LuaSurfBzTrim) ;
return bOk ;
}