EgtExecutor :

- aggiunta funzione per la creazione della surf bezier ruled guided.
This commit is contained in:
Daniele Bariletti
2025-11-12 09:40:48 +01:00
parent d41edd344a
commit ee55f97b3a
2 changed files with 114 additions and 1 deletions
+82
View File
@@ -2668,6 +2668,88 @@ ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, b
return nNewId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, int nLayGuides, bool bCapEnds, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero le curve in locale
CurveLocal CrvLoc1( pGeomDB, nCrvId1, frLoc) ;
bOk = bOk && ( CrvLoc1.Get() != nullptr) ;
CurveLocal CrvLoc2( pGeomDB, nCrvId2, frLoc) ;
bOk = bOk && ( CrvLoc2.Get() != nullptr) ;
ICURVEPOVECTOR vCrv ;
int nId = pGeomDB->GetFirstInGroup( nLayGuides) ;
while( nId != GDB_ID_NULL && bOk) {
CurveLocal CrvLocGuide( pGeomDB, nId, frLoc) ;
bOk = bOk && ( CrvLocGuide.Get() != nullptr) ;
vCrv.emplace_back( CrvLocGuide.Get()->Clone()) ;
nId = pGeomDB->GetNext( nId) ;
}
// calcolo la superficie
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierRuledGuided( CrvLoc1, CrvLoc2, vCrv, dLinTol) : nullptr) ;
bOk = bOk && ! IsNull( pSbz) ;
// verifiche per orientamento se con tappi
bool bWithCaps = false ;
bool bStdOrient = true ;
Plane3d plPlane1, plPlane2 ;
double dArea1, dArea2 ;
if ( bOk && bCapEnds &&
CrvLoc1->IsClosed() && CrvLoc2->IsClosed() && CrvLoc1->GetArea( plPlane1, dArea1) && CrvLoc2->GetArea( plPlane2, dArea2)) {
bWithCaps = true ;
Point3d ptStart1 ; CrvLoc1->GetStartPoint( ptStart1) ;
Point3d ptStart2 ; CrvLoc2->GetStartPoint( ptStart2) ;
Vector3d vtRuling = ptStart2 - ptStart1 ;
bStdOrient = ( vtRuling * plPlane1.GetVersN() > 0) ;
if ( ! bStdOrient)
pSbz->Invert() ;
}
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
// se richiesto inserisco anche il cap
if ( bOk && bWithCaps) {
// costruisco la superficie dalla curva 1
PtrOwner<ISurfBezier> pSbzFlat1( CreateSurfBezier()) ;
double dAngTolDeg = 5 ;
PolyLine pl1 ; CrvLoc1->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, pl1) ;
pSbzFlat1->CreateByFlatContour( pl1) ;
if ( bStdOrient)
pSbzFlat1->Invert() ;
// inserisco la superficie nel DB
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbzFlat1)) ;
// costruisco la superficie dalla curva 2
PtrOwner<ISurfBezier> pSbzFlat2( CreateSurfBezier()) ;
PolyLine pl2 ; CrvLoc2->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, pl2) ;
pSbzFlat2->CreateByFlatContour( pl2) ;
if ( ! bStdOrient)
pSbzFlat2->Invert() ;
// inserisco la superficie nel DB
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbzFlat2)) ;
}
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfBzRuledGuided(" + IdToString( nParentId) + "," +
ToString( nCrvId1) + "," +
ToString( nCrvId2) + "," +
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateSurfBzSkinned( int nParentId, const INTVECTOR& vCrvIds, bool bCapEnds, double dLinTol)