EgtExecutor 1.6u4 :
- aggiunto nesting con regione di riferimento (a forma di L).
This commit is contained in:
@@ -241,6 +241,141 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCreateReferenceRegion( int nParentId, int nOutCrvId, bool bBottomUp)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
// se già esiste, posso uscire
|
||||
int nRegId = pGeomDB->GetFirstNameInGroup( nParentId, NST_REFERENCE_REG) ;
|
||||
if ( nRegId != GDB_ID_NULL)
|
||||
return true ;
|
||||
|
||||
// recupero la curva
|
||||
ICurve* pOutCrv = GetCurve( pGeomDB->GetGeoObj( nOutCrvId)) ;
|
||||
if ( pOutCrv == nullptr)
|
||||
return false ;
|
||||
// verifico sia chiusa
|
||||
if ( ! pOutCrv->IsClosed())
|
||||
return false ;
|
||||
// la approssimo con linee
|
||||
PolyLine PL ;
|
||||
if ( ! pOutCrv->ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||
return false ;
|
||||
// porto la polilinea in globale
|
||||
Frame3d frOutCrv ;
|
||||
pGeomDB->GetGlobFrame( nOutCrvId, frOutCrv) ;
|
||||
PL.ToGlob( frOutCrv) ;
|
||||
// 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) ;
|
||||
// ne ricavo il bbox
|
||||
BBox3d b3Box ;
|
||||
PL.GetLocalBBox( b3Box) ;
|
||||
// cerco i punti più vicini ai quattro vertici (0=BL, 1=BR, 2=TR, 3=TL)
|
||||
double dU[4] = { -1, -1, -1, -1} ;
|
||||
double dMinSqDist[4] = {INFINITO*INFINITO, INFINITO*INFINITO, INFINITO*INFINITO, INFINITO*INFINITO} ;
|
||||
Point3d ptVert[4] ;
|
||||
ptVert[0] = b3Box.GetMin() ;
|
||||
ptVert[2] = b3Box.GetMax() ;
|
||||
ptVert[1] = ptVert[0] ; ptVert[1].x = ptVert[2].x ;
|
||||
ptVert[3] = ptVert[0] ; ptVert[3].y = ptVert[2].y ;
|
||||
Point3d ptQ ; double dPar ;
|
||||
bool bFound = PL.GetFirstUPoint( &dPar, &ptQ, true) ;
|
||||
while ( bFound) {
|
||||
for ( int i = 0 ; i < 4 ; ++ i) {
|
||||
double dSqDist = SqDistXY( ptQ, ptVert[i]) ;
|
||||
if ( dSqDist < dMinSqDist[i]) {
|
||||
dMinSqDist[i] = dSqDist ;
|
||||
dU[i] = dPar ;
|
||||
}
|
||||
}
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptQ, true) ;
|
||||
}
|
||||
for ( int i = 0 ; i < 4 ; ++ i) {
|
||||
if ( dU[i] == - 1)
|
||||
return false ;
|
||||
if ( abs( dU[i] - dU[( i > 0 ? i-1 : 3)]) < EPS_SMALL)
|
||||
return false ;
|
||||
}
|
||||
// calcolo i box dei tre lati di interesse
|
||||
BBox3d b3Down ;
|
||||
BBox3d b3Left ;
|
||||
BBox3d b3Up ;
|
||||
bFound = PL.GetFirstUPoint( &dPar, &ptQ, true) ;
|
||||
while ( bFound) {
|
||||
// per lato sotto ( 0 -> 1)
|
||||
if ( ( dU[1] > dU[0] && dPar > dU[0] - EPS_ZERO && dPar < dU[1] + EPS_ZERO) ||
|
||||
( dU[1] < dU[0] && ( dPar > dU[0] - EPS_ZERO || dPar < dU[1] + EPS_ZERO)))
|
||||
b3Down.Add( ptQ) ;
|
||||
// per lato sopra ( 2 -> 3)
|
||||
if ( ( dU[3] > dU[2] && dPar > dU[2] - EPS_ZERO && dPar < dU[3] + EPS_ZERO) ||
|
||||
( dU[3] < dU[2] && ( dPar > dU[2] - EPS_ZERO || dPar < dU[3] + EPS_ZERO)))
|
||||
b3Up.Add( ptQ) ;
|
||||
// per lato a sinistra ( 3 -> 0)
|
||||
if ( ( dU[0] > dU[3] && dPar > dU[3] - EPS_ZERO && dPar < dU[0] + EPS_ZERO) ||
|
||||
( dU[0] < dU[3] && ( dPar > dU[3] - EPS_ZERO || dPar < dU[0] + EPS_ZERO)))
|
||||
b3Left.Add( ptQ) ;
|
||||
// prossimo punto
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptQ, true) ;
|
||||
}
|
||||
// costruisco la regione di riferimento
|
||||
PolyLine PL2 ;
|
||||
if ( bBottomUp) {
|
||||
PL2.AddUPoint( 0, Point3d( b3Box.GetMin().x - SPESS, b3Box.GetMin().y - SPESS, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 1, Point3d( b3Box.GetMax().x + SPESS, b3Box.GetMin().y - SPESS, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 2, Point3d( b3Box.GetMax().x + SPESS, b3Down.GetMax().y, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 3, Point3d( b3Left.GetMax().x, b3Down.GetMax().y, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 4, Point3d( b3Left.GetMax().x, b3Box.GetMax().y + SPESS, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 5, Point3d( b3Box.GetMin().x - SPESS, b3Box.GetMax().y + SPESS, b3Box.GetMin().z)) ;
|
||||
PL2.Close() ;
|
||||
}
|
||||
else {
|
||||
PL2.AddUPoint( 0, Point3d( b3Box.GetMin().x - SPESS, b3Box.GetMin().y - SPESS, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 1, Point3d( b3Left.GetMax().x, b3Box.GetMin().y - SPESS, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 2, Point3d( b3Left.GetMax().x, b3Up.GetMin().y, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 3, Point3d( b3Box.GetMax().x + SPESS, b3Up.GetMin().y, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 4, Point3d( b3Box.GetMax().x + SPESS, b3Box.GetMax().y + SPESS, b3Box.GetMin().z)) ;
|
||||
PL2.AddUPoint( 5, Point3d( b3Box.GetMin().x - SPESS, b3Box.GetMax().y + SPESS, b3Box.GetMin().z)) ;
|
||||
PL2.Close() ;
|
||||
}
|
||||
// la converto in curva composita
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL2))
|
||||
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 e la dichiaro di sistema e invisibile
|
||||
pGeomDB->SetName( nId, NST_REFERENCE_REG) ;
|
||||
pGeomDB->SetLevel( nId, GDB_LV_SYSTEM) ;
|
||||
pGeomDB->SetMaterial( nId, INVISIBLE) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCreateDamagedRegion( int nParentId, int nDmgCrvId)
|
||||
@@ -357,6 +492,7 @@ class TrimLine {
|
||||
IGeomDB* m_pGeomDB ;
|
||||
int m_nBoxId ;
|
||||
BBox3d m_b3Box ;
|
||||
int m_nRefReg ;
|
||||
INTVECTOR m_vDmgReg ;
|
||||
INTVECTOR m_vOthReg ;
|
||||
INTVECTOR m_vOthDwnReg ;
|
||||
@@ -381,6 +517,10 @@ TrimLine::Init( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, bool bReducedCut)
|
||||
m_nBoxId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_SHEET_OUTREG) ;
|
||||
if ( m_nBoxId == GDB_ID_NULL || ! pGeomDB->GetGlobalBBox( m_nBoxId, m_b3Box))
|
||||
return false ;
|
||||
// Recupero la regione di riferimento e verifico se disabilitata
|
||||
m_nRefReg = pGeomDB->GetFirstNameInGroup( nGroupId, NST_REFERENCE_REG) ;
|
||||
if ( pGeomDB->ExistsInfo( m_nRefReg, KEY_NST_OFF))
|
||||
m_nRefReg = GDB_ID_NULL ;
|
||||
// Recupero le aree danneggiate
|
||||
int nId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_DAMAGED_REG) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
@@ -432,6 +572,14 @@ TrimLine::Verify( double dLineY, Intervals& inOk)
|
||||
if ( ! TrimLineWithRegion( pLine, m_nBoxId, true, inOk))
|
||||
return false ;
|
||||
|
||||
// Verifico con la regione di riferimento
|
||||
if ( m_nRefReg != GDB_ID_NULL) {
|
||||
Intervals inOut ;
|
||||
if ( ! TrimLineWithRegion( pLine, m_nRefReg, true, inOut))
|
||||
return false ;
|
||||
inOk.Intersect( inOut) ;
|
||||
}
|
||||
|
||||
// Verifico con le eventuali aree danneggiate
|
||||
for ( int nDmgRegId : m_vDmgReg) {
|
||||
Intervals inOut ;
|
||||
@@ -565,6 +713,25 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d&
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Verifico con l'eventuale regione di riferimento
|
||||
// recupero la regione
|
||||
int nRefReg = pGeomDB->GetFirstNameInGroup( nGroupId, NST_REFERENCE_REG) ;
|
||||
if ( pGeomDB->ExistsInfo( nRefReg, KEY_NST_OFF))
|
||||
nRefReg = GDB_ID_NULL ;
|
||||
if ( nRefReg != GDB_ID_NULL) {
|
||||
// regioni dei pezzi rispetto alla regione di riferimento
|
||||
for ( int nRegId : vReg) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nRefReg, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
for ( int nDwnRegId : vDwnReg) {
|
||||
if ( nDwnRegId != GDB_ID_NULL) {
|
||||
if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nRefReg, 0) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Verifico con le eventuali aree danneggiate
|
||||
// recupero le aree
|
||||
INTVECTOR vDmgReg ;
|
||||
@@ -1055,6 +1222,11 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
|
||||
if ( nBoxId == GDB_ID_NULL || ! pGeomDB->GetGlobalBBox( nBoxId, b3Region))
|
||||
return false ;
|
||||
|
||||
// Recupero eventuale regione di riferimento
|
||||
int nRefReg = pGeomDB->GetFirstNameInGroup( nGroupId, NST_REFERENCE_REG) ;
|
||||
if ( pGeomDB->ExistsInfo( nRefReg, KEY_NST_OFF))
|
||||
nRefReg = GDB_ID_NULL ;
|
||||
|
||||
// Recupero le eventuali aree danneggiate
|
||||
INTVECTOR vDmgReg ;
|
||||
int nId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_DAMAGED_REG) ;
|
||||
@@ -1111,6 +1283,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 la regione di riferimento
|
||||
if ( nRefReg != GDB_ID_NULL) {
|
||||
MySurfFrMoveSimpleNoCollision( nRegId, nRefReg, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nRefReg, false, false, scInfoCurr) ;
|
||||
}
|
||||
// la confronto con le aree danneggiate
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
MySurfFrMoveSimpleNoCollision( nRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ;
|
||||
@@ -1134,6 +1311,11 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
|
||||
MySurfFrMoveSimpleNoCollision( nDwnRegId, nBoxId, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nBoxId, false, false, scInfoCurr) ;
|
||||
}
|
||||
// la confronto con la regione di riferimento
|
||||
if ( nDwnRegId != GDB_ID_NULL && nRefReg != GDB_ID_NULL) {
|
||||
MySurfFrMoveSimpleNoCollision( nDwnRegId, nRefReg, vtDir, dLen, scInfoCurr) ;
|
||||
dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nRefReg, false, false, scInfoCurr) ;
|
||||
}
|
||||
// la confronto con le aree danneggiate
|
||||
if ( nDwnRegId != GDB_ID_NULL) {
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
@@ -1299,6 +1481,11 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
if ( nBoxId == GDB_ID_NULL || ! pGeomDB->GetGlobalBBox( nBoxId, b3Region))
|
||||
return false ;
|
||||
|
||||
// Recupero eventuale regione di riferimento
|
||||
int nRefReg = pGeomDB->GetFirstNameInGroup( nGroupId, NST_REFERENCE_REG) ;
|
||||
if ( pGeomDB->ExistsInfo( nRefReg, KEY_NST_OFF))
|
||||
nRefReg = GDB_ID_NULL ;
|
||||
|
||||
// Recupero le eventuali aree danneggiate
|
||||
INTVECTOR vDmgReg ;
|
||||
int nId = pGeomDB->GetFirstNameInGroup( nGroupId, NST_DAMAGED_REG) ;
|
||||
@@ -1350,6 +1537,10 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
}
|
||||
// la confronto con il box
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nBoxId, ptCen, dAng, RTY_GLOB) ;
|
||||
// la confronto con la regione di riferimento
|
||||
if ( nRefReg != GDB_ID_NULL) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nRefReg, ptCen, dAng, RTY_GLOB) ;
|
||||
}
|
||||
// la confronto con le aree danneggiate
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nRegId, nDmgRegId, ptCen, dAng, RTY_GLOB) ;
|
||||
@@ -1368,6 +1559,10 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
|
||||
// la confronto con il box
|
||||
if ( nDwnRegId != GDB_ID_NULL)
|
||||
ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nBoxId, ptCen, dAng, RTY_GLOB) ;
|
||||
// la confronto con la regione di riferimento
|
||||
if ( nRefReg != GDB_ID_NULL) {
|
||||
ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nRefReg, ptCen, dAng, RTY_GLOB) ;
|
||||
}
|
||||
// la confronto con le aree danneggiate
|
||||
if ( nDwnRegId != GDB_ID_NULL) {
|
||||
for ( int nDmgRegId : vDmgReg) {
|
||||
|
||||
Reference in New Issue
Block a user