EgtExecutor :

- piccole migliorie a Exe/Lua CreateSurfBezierLeaves.
This commit is contained in:
Dario Sassi
2023-11-13 08:49:49 +01:00
parent 246aa6e3ed
commit 51b388db06
2 changed files with 67 additions and 48 deletions
+51 -39
View File
@@ -1716,56 +1716,68 @@ ExeCreateSurfBezierRational( int nParentId, int nDegU, int nDegV, int nSpanU, in
//-------------------------------------------------------------------------------
int
ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight, bool bShowTrim)
ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight, bool bShowTrim, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
ISurfBezier* pSurfBez = GetSurfBezier( pGeomDB->GetGeoObj( nSurfBzId)) ;
nParentId = AdjustId( nParentId) ;
// recupero la superficie
const 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
return GDB_ID_NULL ;
// 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) ;
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int k = 0 ; k < (int)vLeaves.size() ; ++ k) {
Point3d ptBL = get<1>( vLeaves[k]) * dFactor ;
Point3d ptTR = 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( 1, ptBR) ;
PL.AddUPoint( 2, ptTR) ;
PL.AddUPoint( 3, ptTl) ;
PL.AddUPoint( 4, ptBL) ;
// creo la curva e la inserisco nel GDB
PL.AddUPoint( 3, ptTL) ;
PL.Close() ;
// 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) ;
if ( IsNull( pCrvCompo) || ! pCrvCompo->FromPolyLine( PL) || ! pCrvCompo->SetExtrusion( Z_AX))
return GDB_ID_NULL ;
// inserisco la curva composita nel DB
int nCrvId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ;
if ( nCrvId == GDB_ID_NULL)
return GDB_ID_NULL ;
++ nCount ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nCrvId ;
// creo il testo e lo riempio
string sText = ToString( get<0>( vLeaves[k])) ;
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) ;
if ( IsNull( pTXT) || ! pTXT->Set( ptCenter, Z_AX, X_AX, sText, "", false, nTextHeight))
return GDB_ID_NULL ;
// inserisco il testo nel DB
int nTxtId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) ;
if ( nTxtId == GDB_ID_NULL)
return GDB_ID_NULL ;
++ nCount ;
}
PtrOwner<ISurfFlatRegion> pTrimReg( pSurfBez->GetTrimRegion()->Clone()) ;
if ( bShowTrim && ! IsNull( pTrimReg))
nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTrimReg)) : -1 ) ;
return nId ;
// se richiesto disegno la regione di trim
const ISurfFlatRegion* pSfr = pSurfBez->GetTrimRegion() ;
if ( bShowTrim && pSfr != nullptr) {
PtrOwner<ISurfFlatRegion> pTrimReg( pSfr->Clone()) ;
if ( ! IsNull( pTrimReg)) {
int nTrimId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTrimReg)) ;
if ( nTrimId == GDB_ID_NULL)
return GDB_ID_NULL ;
++ nCount ;
}
}
// restituisco i risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}