EgtExecutor 1.6n12 :
- aggiunta gestione aree rovinate in nesting.
This commit is contained in:
+133
-19
@@ -115,28 +115,29 @@ ExeCreateOutRegion( int nParentId, double dXmin, double dYmin, double dXmax, dou
|
||||
// la converto in curva composita
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// costruisco la regione piana
|
||||
SurfFlatRegionByContours SfrCntr ;
|
||||
SfrCntr.AddCurve( Release( pCompo)) ;
|
||||
ISurfFlatRegion* pSfr = SfrCntr.GetSurf() ;
|
||||
if ( pSfr == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// recupero il riferimento del gruppo di inserimento
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// porto la regione nel riferimento
|
||||
pSfr->ToLoc( frLoc) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSfr) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// assegno nome e la dichiaro di sistema e invisibile
|
||||
pGeomDB->SetName( nId, NST_SHEET_OUTREG) ;
|
||||
pGeomDB->SetLevel( nId, GDB_LV_SYSTEM) ;
|
||||
pGeomDB->SetMaterial( nId, INVISIBLE) ;
|
||||
return ( nId != GDB_ID_NULL) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -154,16 +155,16 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId)
|
||||
// recupero la curva
|
||||
ICurve* pOutCrv = GetCurve( pGeomDB->GetGeoObj( nOutCrvId)) ;
|
||||
if ( pOutCrv == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// verifico sia chiusa
|
||||
if ( ! pOutCrv->IsClosed())
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// la approssimo con linee
|
||||
const double LIN_TOL_STD = 0.1 ;
|
||||
const double ANG_TOL_STD_DEG = 15 ;
|
||||
PolyLine PL ;
|
||||
if ( ! pOutCrv->ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// porto la polilinea in globale
|
||||
Frame3d frOutCrv ;
|
||||
pGeomDB->GetGlobFrame( nOutCrvId, frOutCrv) ;
|
||||
@@ -171,7 +172,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId)
|
||||
// se antioraria la inverto
|
||||
double dArea ;
|
||||
if ( ! PL.GetAreaXY( dArea))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
if ( dArea > 0)
|
||||
PL.Invert() ;
|
||||
// la appiattisco sulla Z iniziale
|
||||
@@ -181,7 +182,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId)
|
||||
// la converto in curva composita
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// ne ricavo il bbox e lo ingrandisco
|
||||
BBox3d b3Box ;
|
||||
pCompo->GetLocalBBox( b3Box) ;
|
||||
@@ -192,7 +193,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId)
|
||||
DistPointCurve distPC( b3Box.GetMax(), *Get( pCompo)) ;
|
||||
if ( ! distPC.GetParamAtMinDistPoint( 0, dU, nFlag) ||
|
||||
! pCompo->ChangeStartPoint( dU))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// accorcio inizio
|
||||
pCompo->TrimStartAtLen( 5 * EPS_SMALL) ;
|
||||
// creo curva della parte esterna
|
||||
@@ -211,31 +212,103 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId)
|
||||
// la converto in curva composita
|
||||
PtrOwner<ICurveComposite> pCompo2( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo2) || ! pCompo2->FromPolyLine( PL2))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// unisco le due curve composite
|
||||
if ( ! pCompo->AddCurve( Release( pCompo2)))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// costruisco la regione piana
|
||||
SurfFlatRegionByContours SfrCntr ;
|
||||
SfrCntr.AddCurve( Release( pCompo)) ;
|
||||
ISurfFlatRegion* pSfr = SfrCntr.GetSurf() ;
|
||||
if ( pSfr == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// recupero il riferimento del gruppo di inserimento
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// porto la regione nel riferimento
|
||||
pSfr->ToLoc( frLoc) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSfr) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// assegno nome e la dichiaro di sistema e invisibile
|
||||
pGeomDB->SetName( nId, NST_SHEET_OUTREG) ;
|
||||
pGeomDB->SetLevel( nId, GDB_LV_SYSTEM) ;
|
||||
pGeomDB->SetMaterial( nId, INVISIBLE) ;
|
||||
return ( nId != GDB_ID_NULL) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCreateDamagedRegion( int nParentId, int nDmgCrvId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// verifico se esiste già la regione associata
|
||||
int nRegId = pGeomDB->GetFirstNameInGroup( nParentId, NST_DAMAGED_REG) ;
|
||||
while ( nRegId != GDB_ID_NULL) {
|
||||
// recupero l'indice della curva di origine
|
||||
int nOriId ;
|
||||
if ( pGeomDB->GetInfo( nRegId, CRV_ORIG, nOriId) && nOriId == nDmgCrvId)
|
||||
return true ;
|
||||
// passo alla regione successiva
|
||||
nRegId = pGeomDB->GetNextName( nRegId, NST_DAMAGED_REG) ;
|
||||
}
|
||||
|
||||
// recupero la curva e verifico sia chiusa
|
||||
ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nDmgCrvId)) ;
|
||||
if ( pCrv == nullptr || ! pCrv->IsClosed())
|
||||
return false ;
|
||||
// la approssimo con linee
|
||||
const double LIN_TOL_STD = 0.1 ;
|
||||
const double ANG_TOL_STD_DEG = 15 ;
|
||||
PolyLine PL ;
|
||||
if ( ! pCrv->ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
return GDB_ID_NULL ;
|
||||
// porto la polilinea in globale
|
||||
Frame3d frDmgCrv ;
|
||||
pGeomDB->GetGlobFrame( nDmgCrvId, frDmgCrv) ;
|
||||
PL.ToGlob( frDmgCrv) ;
|
||||
// se oraria la inverto
|
||||
double dArea ;
|
||||
if ( ! PL.GetAreaXY( dArea))
|
||||
return false ;
|
||||
if ( dArea < 0)
|
||||
PL.Invert() ;
|
||||
// la appiattisco sulla Z iniziale
|
||||
Point3d ptP ;
|
||||
PL.GetFirstPoint( ptP) ;
|
||||
PL.Flatten( ptP.z) ;
|
||||
// la converto in curva composita
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL))
|
||||
return false ;
|
||||
// costruisco la regione piana
|
||||
SurfFlatRegionByContours SfrCntr ;
|
||||
SfrCntr.AddCurve( Release( pCompo)) ;
|
||||
ISurfFlatRegion* pSfr = SfrCntr.GetSurf() ;
|
||||
if ( pSfr == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento del gruppo di inserimento
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
||||
return false ;
|
||||
// porto la regione nel riferimento
|
||||
pSfr->ToLoc( frLoc) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSfr) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// assegno nome, id curva di origine e la dichiaro di sistema e invisibile
|
||||
pGeomDB->SetName( nId, NST_DAMAGED_REG) ;
|
||||
pGeomDB->SetInfo( nId, CRV_ORIG, nDmgCrvId) ;
|
||||
pGeomDB->SetLevel( nId, GDB_LV_SYSTEM) ;
|
||||
pGeomDB->SetMaterial( nId, INVISIBLE) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -316,6 +389,22 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d&
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Verifico con le eventuali aree danneggiate
|
||||
// recupero le aree
|
||||
INTVECTOR vDmgReg ;
|
||||
int nId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_DAMAGED_REG) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
vDmgReg.emplace_back( nId) ;
|
||||
nId = pGeomDB->GetNextName( nId, NST_DAMAGED_REG) ;
|
||||
}
|
||||
// regioni dei pezzi rispetto alle regioni delle aree danneggiate
|
||||
for ( int nRegId : vReg) {
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nDmgRegId, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse
|
||||
INTVECTOR vOthReg ;
|
||||
INTVECTOR vOthCutReg ;
|
||||
@@ -702,6 +791,14 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
|
||||
if ( nBoxId == GDB_ID_NULL || ! pGeomDB->GetGlobalBBox( nBoxId, b3Region))
|
||||
return false ;
|
||||
|
||||
// Recupero le eventuali aree danneggiate
|
||||
INTVECTOR vDmgReg ;
|
||||
int nId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_DAMAGED_REG) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
vDmgReg.emplace_back( nId) ;
|
||||
nId = pGeomDB->GetNextName( nId, NST_DAMAGED_REG) ;
|
||||
}
|
||||
|
||||
// Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse
|
||||
INTVECTOR vOthReg ;
|
||||
INTVECTOR vOthCutReg ;
|
||||
@@ -725,7 +822,7 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
|
||||
nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ;
|
||||
}
|
||||
|
||||
// Verifico movimento dei pezzi del cluster rispetto agli altri pezzi
|
||||
// Verifico movimento dei pezzi del cluster rispetto al contorno, alle aree danneggiate e agli altri pezzi
|
||||
bool bOk = true ;
|
||||
double dLen = vtMoveXY.Len() ;
|
||||
double dPrevLen = dLen ;
|
||||
@@ -742,6 +839,11 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
|
||||
// la confronto con il box
|
||||
MySurfFrMoveSimpleNoCollision( nRegId, nBoxId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nBoxId, false, false, scInfoCurr) ;
|
||||
// la confronto con le aree danneggiate
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
MySurfFrMoveSimpleNoCollision( nRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nDmgRegId, false, false, scInfoCurr) ;
|
||||
}
|
||||
// la confronto con le regioni degli altri pezzi
|
||||
for ( int nOthRegId : vOthReg) {
|
||||
MySurfFrMoveSimpleNoCollision( nRegId, nOthRegId, vtDir, dLen, scInfoCurr) ;
|
||||
@@ -873,6 +975,14 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
if ( nBoxId == GDB_ID_NULL || ! pGeomDB->GetGlobalBBox( nBoxId, b3Region))
|
||||
return false ;
|
||||
|
||||
// Recupero le eventuali aree danneggiate
|
||||
INTVECTOR vDmgReg ;
|
||||
int nId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_DAMAGED_REG) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
vDmgReg.emplace_back( nId) ;
|
||||
nId = pGeomDB->GetNextName( nId, NST_DAMAGED_REG) ;
|
||||
}
|
||||
|
||||
// Determino le regioni di tutti gli altri pezzi compresi nella regione di interesse
|
||||
INTVECTOR vReg ;
|
||||
INTVECTOR vCutReg ;
|
||||
@@ -896,7 +1006,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ;
|
||||
}
|
||||
|
||||
// Verifico rotazione dei pezzi del cluster rispetto agli altri pezzi
|
||||
// Verifico rotazione dei pezzi del cluster rispetto al contorno, alle aree danneggiate e agli altri pezzi
|
||||
bool bOk = true ;
|
||||
double dAng = dRotAngDeg ;
|
||||
for ( auto nTrueId : vTrueIds) {
|
||||
@@ -908,6 +1018,10 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
}
|
||||
// la confronto con il box
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nBoxId, ptCen, dAng, RTY_GLOB) ;
|
||||
// la confronto con le aree danneggiate
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nDmgRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
}
|
||||
// la confronto con le regioni degli altri pezzi
|
||||
for ( int nOthRegId : vReg) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nOthRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
|
||||
Reference in New Issue
Block a user