EgtExecutor 1.6o4 :

- aggiunte in EXE e Lua SplitCurveAtParam e SplitCurveAtCorners
- aggiunte in EXE e Lua AddMachining e CreateMachining
- migliorata gestione contorni di NstFlatParts.
This commit is contained in:
Dario Sassi
2016-04-06 06:37:21 +00:00
parent abb5c40de9
commit bb5feba6c4
8 changed files with 365 additions and 35 deletions
+119 -12
View File
@@ -735,6 +735,111 @@ ExeSplitCurveAtPoint( int nId, const Point3d& ptOn, int nRefType)
return nNewId ;
}
//----------------------------------------------------------------------------
int
ExeSplitCurveAtParam( int nId, double dParam)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// verifico che il punto di taglio sia interno alla curva
bool bIsInside = false ;
if ( bOk) {
// determino lunghezza totale della curva
double dLen ;
bOk = bOk && pCurve->GetLength( dLen) ;
// determino lunghezza al parametro di taglio
double dCutLen ;
bOk = bOk && pCurve->GetLengthAtParam( dParam, dCutLen) ;
// interno se la lunghezza al parametro e la lunghezza rimanente sono entrambe significative
if ( bOk && dCutLen > EPS_SMALL && dLen - dCutLen > EPS_SMALL)
bIsInside = true ;
}
// se il punto di taglio è interno, devo realmente tagliare
int nNewId = GDB_ID_NULL ;
if ( bIsInside) {
// copio la curva
nNewId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER) ;
ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nNewId)) ;
bOk = bOk && ( pCopyCrv != nullptr) ;
// tengo la prima parte dell'originale e la seconda parte della copia
bOk = bOk && pCurve->TrimEndAtParam( dParam) ;
bOk = bOk && pCopyCrv->TrimStartAtParam( dParam) ;
}
nNewId = ( bOk ? nNewId : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSplitCurveAtParam(" + ToString( nId) + "," +
ToString( dParam) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return nNewId ;
}
//----------------------------------------------------------------------------
int
ExeSplitCurveAtCorners( int nId, double dTgAngToler, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// !!! deve essere fatta anche sulle curve di Bezier !!!
// recupero la curva composita
ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCompo != nullptr) ;
// calcolo i punti di perdita di tangenza
DBLVECTOR vU ;
double dMinCos = cos( dTgAngToler * DEGTORAD) ;
for ( int i = 1 ; i < pCompo->GetCurveCount() ; ++ i) {
Point3d ptPrev, ptNext ;
Vector3d vtPrev, vtNext ;
if ( pCompo->GetPointTang( i, ICurve::FROM_MINUS, ptPrev, vtPrev) &&
pCompo->GetPointTang( i, ICurve::FROM_PLUS, ptNext, vtNext) &&
vtPrev * vtNext < dMinCos)
vU.push_back( i) ;
}
// recupero un intervallo di id contigui per tutte le parti
int nFirstId = pGeomDB->GetNewId() ;
bOk = bOk && pGeomDB->ChangeId( nId, nFirstId) ;
int nCurrId = nFirstId ;
// eseguo la divisione
int nCount = 1 ;
double dUPrev = 0 ;
for ( int i = 0 ; i < int( vU.size()) ; ++ i) {
// copio la curva
int nCopyId = pGeomDB->Copy( nCurrId, GDB_ID_NULL, nCurrId, GDB_AFTER) ;
ICurveComposite* pCopyCrv = GetCurveComposite( pGeomDB->GetGeoObj( nCopyId)) ;
bOk = bOk && ( pCopyCrv != nullptr) ;
++ nCount ;
// trimmo l'originale
bOk = bOk && pCompo->TrimStartEndAtParam( dUPrev, vU[i]) ;
// la copia diventa il nuovo corrente
nCurrId = nCopyId ;
pCompo = pCopyCrv ;
dUPrev = vU[i] ;
}
// se fatta almeno una suddivisione, trimmo l'ultima parte
if ( dUPrev > EPS_PARAM)
bOk = bOk && pCompo->TrimStartAtParam( dUPrev) ;
nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSplitCurveAtCorners(" + ToString( nId) + "," +
ToString( dTgAngToler) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
int
ExeSplitCurveAtSelfInters( int nId, int* pnCount)
@@ -745,19 +850,21 @@ ExeSplitCurveAtSelfInters( int nId, int* pnCount)
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// calcolo le auto-intersezioni
SelfIntersCurve sintC( *pCurve) ;
DBLVECTOR vU ;
IntCrvCrvInfo iccInfo ;
for ( int i = 0 ; sintC.GetIntCrvCrvInfo( i, iccInfo) ; ++ i) {
if ( ! iccInfo.bOverlap) {
vU.push_back( iccInfo.IciA[0].dU) ;
vU.push_back( iccInfo.IciB[0].dU) ;
}
else {
vU.push_back( iccInfo.IciA[0].dU) ;
vU.push_back( iccInfo.IciA[1].dU) ;
vU.push_back( iccInfo.IciB[0].dU) ;
vU.push_back( iccInfo.IciB[1].dU) ;
if ( bOk) {
SelfIntersCurve sintC( *pCurve) ;
IntCrvCrvInfo iccInfo ;
for ( int i = 0 ; sintC.GetIntCrvCrvInfo( i, iccInfo) ; ++ i) {
if ( ! iccInfo.bOverlap) {
vU.push_back( iccInfo.IciA[0].dU) ;
vU.push_back( iccInfo.IciB[0].dU) ;
}
else {
vU.push_back( iccInfo.IciA[0].dU) ;
vU.push_back( iccInfo.IciA[1].dU) ;
vU.push_back( iccInfo.IciB[0].dU) ;
vU.push_back( iccInfo.IciB[1].dU) ;
}
}
}
// ordino il vettore in senso crescente