EgtExecutor 1.9g1 :
- aggiunta gestione import punti in Exe e LUA - corretta gestione regione sotto con lati inclinati interni di pezzi piatti (flatParts) - aggiunta funzione Exe e Lua CAvGetToolOutline per avere profilo di utensile in uso nella CollisionAvoidance.
This commit is contained in:
+131
-62
@@ -520,7 +520,7 @@ VerifyAndAdjustFlatParts( void)
|
||||
if ( ! IsNull( pOutCrv)) {
|
||||
int nOutLoopId = ExeCreateGroup( pPar->GetId(), Frame3d(), RTY_GLOB) ;
|
||||
bOk = bOk && nOutLoopId != GDB_ID_NULL ;
|
||||
bOk = bOk && pGeomDB->SetName( nOutLoopId, NST_EXT_LAYER) ;
|
||||
bOk = bOk && pGeomDB->SetName( nOutLoopId, NST_OUT_LAYER) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nOutLoopId, Release( pOutCrv)) ;
|
||||
}
|
||||
// creo nuovi layer in cui copiare gli eventuali contorni interni
|
||||
@@ -832,7 +832,7 @@ ExeCalcFlatPartUpRegion( int nPartId, bool bCalc)
|
||||
return true ;
|
||||
|
||||
// recupero il layer esterno
|
||||
int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER) ;
|
||||
int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_OUT_LAYER) ;
|
||||
if ( nOlId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// se il pezzo non ha lati esterni con offset negativo non devo fare alcunchè
|
||||
@@ -926,60 +926,31 @@ ExeCalcFlatPartUpRegion( int nPartId, bool bCalc)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCalcFlatPartDownRegion( int nPartId, double dH)
|
||||
static bool
|
||||
AdjustLayerForSideAngle( IGeomDB* pGeomDB, int nLayOrigId, const string& sLayOrig, int nLayReg, double dH)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// ripristino lo stato originale
|
||||
pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_PARTDOWNREG_LAYER)) ;
|
||||
int nOlOrigId = pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_ORIG_LAYER) ;
|
||||
if ( nOlOrigId != GDB_ID_NULL) {
|
||||
pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER)) ;
|
||||
pGeomDB->SetName( nOlOrigId, NST_EXT_LAYER) ;
|
||||
pGeomDB->SetStatus( nOlOrigId, GDB_ST_ON) ;
|
||||
}
|
||||
// se spessore nullo, non devo fare altro
|
||||
if ( dH < EPS_SMALL)
|
||||
return true ;
|
||||
// recupero il layer esterno
|
||||
int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER) ;
|
||||
if ( nOlId == GDB_ID_NULL)
|
||||
// creo una copia del layer
|
||||
int nLayId = pGeomDB->Copy( nLayOrigId, GDB_ID_NULL, nLayOrigId, GDB_AFTER) ;
|
||||
if ( nLayId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// se il pezzo non ha lati esterni inclinati non devo fare alcunchè
|
||||
bool bAllVertSides = true ;
|
||||
int nCrvId = pGeomDB->GetFirstInGroup( nOlId) ;
|
||||
while ( nCrvId != GDB_ID_NULL) {
|
||||
double dSideAng ;
|
||||
if ( pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG, dSideAng) && abs( dSideAng) > EPS_ANG_SMALL) {
|
||||
bAllVertSides = false ;
|
||||
break ;
|
||||
}
|
||||
nCrvId = pGeomDB->GetNext( nCrvId) ;
|
||||
}
|
||||
if ( bAllVertSides)
|
||||
return true ;
|
||||
|
||||
// creo una copia del layer esterno
|
||||
nOlOrigId = pGeomDB->Copy( nOlId, GDB_ID_NULL, nOlId, GDB_AFTER) ;
|
||||
if ( nOlOrigId == GDB_ID_NULL)
|
||||
pGeomDB->SetName( nLayOrigId, sLayOrig) ;
|
||||
pGeomDB->SetInfo( nLayOrigId, NST_KEY_COPY, nLayId) ;
|
||||
pGeomDB->SetStatus( nLayOrigId, GDB_ST_OFF) ;
|
||||
// creo un layer temporaneo
|
||||
const string sTmpLayName = "TmpLay" ;
|
||||
Frame3d frLay ;
|
||||
pGeomDB->GetGroupFrame( nLayId, frLay) ;
|
||||
int nTmpLayId = pGeomDB->AddGroup( GDB_ID_NULL, pGeomDB->GetParentId( nLayId), frLay) ;
|
||||
if ( nTmpLayId == GDB_ID_NULL)
|
||||
return false ;
|
||||
pGeomDB->SetName( nOlOrigId, NST_EXT_ORIG_LAYER) ;
|
||||
pGeomDB->SetStatus( nOlOrigId, GDB_ST_OFF) ;
|
||||
// creo il layer per la regione sotto (con il medesimo riferimento del layer esterno)
|
||||
Frame3d frOl ;
|
||||
pGeomDB->GetGroupFrame( nOlId, frOl) ;
|
||||
int nDwnRegId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, frOl) ;
|
||||
if ( nDwnRegId == GDB_ID_NULL)
|
||||
return false ;
|
||||
pGeomDB->SetName( nDwnRegId, NST_PARTDOWNREG_LAYER) ;
|
||||
pGeomDB->SetName( nTmpLayId, sTmpLayName) ;
|
||||
pGeomDB->SetLevel( nTmpLayId, GDB_LV_TEMP) ;
|
||||
|
||||
// copio le entità del contorno esterno e le offsetto opportunamente
|
||||
nCrvId = pGeomDB->GetFirstInGroup( nOlId) ;
|
||||
int nCrvId = pGeomDB->GetFirstInGroup( nLayId) ;
|
||||
while ( nCrvId != GDB_ID_NULL) {
|
||||
// copio la curva nel gruppo downregion
|
||||
int nNewId = pGeomDB->CopyGlob( nCrvId, GDB_ID_NULL, nDwnRegId) ;
|
||||
// copio la curva nel gruppo temporaneo
|
||||
int nNewId = pGeomDB->CopyGlob( nCrvId, GDB_ID_NULL, nTmpLayId) ;
|
||||
if ( nNewId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// determino ed eseguo offset
|
||||
@@ -997,7 +968,7 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH)
|
||||
nCrvId = pGeomDB->GetNext( nCrvId) ;
|
||||
}
|
||||
// aggiusto tra loro le entità offsettate
|
||||
int nFirstCrvId = pGeomDB->GetFirstInGroup( nDwnRegId) ;
|
||||
int nFirstCrvId = pGeomDB->GetFirstInGroup( nTmpLayId) ;
|
||||
ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nFirstCrvId)) ;
|
||||
int nNextCrvId = pGeomDB->GetNext( nFirstCrvId) ;
|
||||
ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nNextCrvId)) ;
|
||||
@@ -1015,8 +986,8 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH)
|
||||
if ( pCrv1 == nullptr || pCrv2 == nullptr || ! AdjustCurves( pCrv1, pCrv2))
|
||||
return false ;
|
||||
|
||||
// eventuali allungamenti per le curve del loop esterno
|
||||
for ( int nCrvId = pGeomDB->GetFirstInGroup( nOlId) ;
|
||||
// eventuali allungamenti/accorciamenti per le curve del loop
|
||||
for ( int nCrvId = pGeomDB->GetFirstInGroup( nLayId) ;
|
||||
nCrvId != GDB_ID_NULL ;
|
||||
nCrvId = pGeomDB->GetNext( nCrvId)) {
|
||||
// recupero il nome
|
||||
@@ -1024,7 +995,7 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH)
|
||||
if ( ! pGeomDB->GetName( nCrvId, sName))
|
||||
continue ;
|
||||
// recupero curva con lo stesso nome nel gruppo della regione sotto
|
||||
int nCrvDrId = pGeomDB->GetFirstNameInGroup( nDwnRegId, sName) ;
|
||||
int nCrvDrId = pGeomDB->GetFirstNameInGroup( nTmpLayId, sName) ;
|
||||
if ( nCrvDrId == GDB_ID_NULL)
|
||||
continue ;
|
||||
// verifico siano curve
|
||||
@@ -1072,24 +1043,122 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// creo la regione
|
||||
// concateno le curve del layer temporaneo
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
for ( int nCrvId = pGeomDB->GetFirstInGroup( nTmpLayId) ;
|
||||
nCrvId != GDB_ID_NULL ;
|
||||
nCrvId = pGeomDB->GetFirstInGroup( nTmpLayId)) {
|
||||
ICurve* pCrv = GetCurve( pGeomDB->RemoveGeoObjAndErase( nCrvId)) ;
|
||||
if ( pCrv != nullptr)
|
||||
pCompo->AddCurve( pCrv) ;
|
||||
else
|
||||
pGeomDB->Erase( nCrvId) ;
|
||||
}
|
||||
// cancello il layer temporaneo
|
||||
pGeomDB->Erase( nTmpLayId) ;
|
||||
// inserisco la curva concatenata nel layer della regione
|
||||
if ( pGeomDB->AddGeoObj( GDB_ID_NULL, nLayReg, Release( pCompo)) == GDB_ID_NULL)
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCalcFlatPartDownRegion( int nPartId, double dH)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// ripristino lo stato originale
|
||||
pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_PARTDOWNREG_LAYER)) ;
|
||||
int nOlOrigId = pGeomDB->GetFirstNameInGroup( nPartId, NST_OUT_ORIG_LAYER) ;
|
||||
if ( nOlOrigId != GDB_ID_NULL) {
|
||||
pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_OUT_LAYER)) ;
|
||||
pGeomDB->SetName( nOlOrigId, NST_OUT_LAYER) ;
|
||||
pGeomDB->SetStatus( nOlOrigId, GDB_ST_ON) ;
|
||||
}
|
||||
for ( int nIlOrigId = pGeomDB->GetFirstNameInGroup( nPartId, NST_IN_ORIG_LAYER) ;
|
||||
nIlOrigId != GDB_ID_NULL ;
|
||||
nIlOrigId = pGeomDB->GetFirstNameInGroup( nPartId, NST_IN_ORIG_LAYER)) {
|
||||
int nCopyId = GDB_ID_NULL ;
|
||||
pGeomDB->GetInfo( nIlOrigId, NST_KEY_COPY, nCopyId) ;
|
||||
if ( nCopyId != GDB_ID_NULL)
|
||||
pGeomDB->Erase( nCopyId) ;
|
||||
pGeomDB->SetName( nIlOrigId, NST_IN_LAYER) ;
|
||||
pGeomDB->SetStatus( nIlOrigId, GDB_ST_ON) ;
|
||||
}
|
||||
|
||||
// se spessore nullo, non devo fare altro
|
||||
if ( dH < EPS_SMALL)
|
||||
return true ;
|
||||
|
||||
// recupero i layer esterno ed interni (primo sempre esterno)
|
||||
INTVECTOR vLayId ;
|
||||
int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_OUT_LAYER) ;
|
||||
if ( nOlId == GDB_ID_NULL)
|
||||
return false ;
|
||||
vLayId.push_back( nOlId) ;
|
||||
for ( int nIlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_IN_LAYER) ;
|
||||
nIlId != GDB_ID_NULL ;
|
||||
nIlId = pGeomDB->GetNextName( nIlId, NST_IN_LAYER))
|
||||
vLayId.push_back( nIlId) ;
|
||||
// se il pezzo non ha lati esterni o interni inclinati all'infuori non devo fare alcunchè
|
||||
bool bAllVertSides = true ;
|
||||
for ( size_t i = 0 ; i < vLayId.size() ; ++ i) {
|
||||
int nCrvId = pGeomDB->GetFirstInGroup( vLayId[i]) ;
|
||||
while ( nCrvId != GDB_ID_NULL) {
|
||||
double dSideAng ;
|
||||
if ( pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG, dSideAng) && abs( dSideAng) > EPS_ANG_SMALL) {
|
||||
bAllVertSides = false ;
|
||||
break ;
|
||||
}
|
||||
nCrvId = pGeomDB->GetNext( nCrvId) ;
|
||||
}
|
||||
}
|
||||
if ( bAllVertSides)
|
||||
return true ;
|
||||
|
||||
// assegno un nome alle curve dei layer che ne sono prive
|
||||
for ( size_t i = 0 ; i < vLayId.size() ; ++ i) {
|
||||
int nCnt = 0 ;
|
||||
for ( int nCrvId = pGeomDB->GetFirstInGroup( vLayId[i]) ;
|
||||
nCrvId != GDB_ID_NULL ;
|
||||
nCrvId = pGeomDB->GetNext( nCrvId)) {
|
||||
if ( ! pGeomDB->ExistsName( nCrvId) && ( pGeomDB->GetGeoType( nCrvId) & GEO_CURVE) != 0) {
|
||||
++ nCnt ;
|
||||
pGeomDB->SetName( nCrvId, "B" + ToString( nCnt)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// creo il layer per la regione sotto (con il medesimo riferimento del layer esterno)
|
||||
Frame3d frOl ;
|
||||
pGeomDB->GetGroupFrame( nOlId, frOl) ;
|
||||
int nDwnRegId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, frOl) ;
|
||||
if ( nDwnRegId == GDB_ID_NULL)
|
||||
return false ;
|
||||
pGeomDB->SetName( nDwnRegId, NST_PARTDOWNREG_LAYER) ;
|
||||
|
||||
// modifico i layer e creo i contorni per la nuova regione
|
||||
for ( size_t i = 0 ; i < vLayId.size() ; ++ i) {
|
||||
string sLayOrig = ( i == 0 ? NST_OUT_ORIG_LAYER : NST_IN_ORIG_LAYER) ;
|
||||
if ( ! AdjustLayerForSideAngle( pGeomDB, vLayId[i], sLayOrig, nDwnRegId, dH))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// creo la regione
|
||||
SurfFlatRegionByContours SfrCntr( false) ;
|
||||
for ( int nCrvId = pGeomDB->GetFirstInGroup( nDwnRegId) ;
|
||||
nCrvId != GDB_ID_NULL ;
|
||||
nCrvId = pGeomDB->GetFirstInGroup( nDwnRegId)) {
|
||||
ICurve* pCrv = GetCurve( pGeomDB->RemoveGeoObjAndErase( nCrvId)) ;
|
||||
if ( pCrv != nullptr) {
|
||||
pCompo->AddCurve( pCrv) ;
|
||||
pGeomDB->RemoveGeoObjAndErase( nCrvId) ;
|
||||
}
|
||||
if ( pCrv != nullptr)
|
||||
SfrCntr.AddCurve( pCrv) ;
|
||||
else
|
||||
pGeomDB->Erase( nCrvId) ;
|
||||
}
|
||||
SurfFlatRegionByContours SfrCntr( false) ;
|
||||
SfrCntr.AddCurve( Release( pCompo)) ;
|
||||
int nSfrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDwnRegId, SfrCntr.GetSurf()) ;
|
||||
if ( nSfrId == GDB_ID_NULL)
|
||||
return false ;
|
||||
|
||||
Reference in New Issue
Block a user