EgtExecutor :

- aggiunta ExeGetCurveCompoJointCount
- migliorata ExePackPartCluster.
This commit is contained in:
Dario Sassi
2016-02-22 18:35:57 +00:00
parent 28f6f1240f
commit 3bfb359101
2 changed files with 55 additions and 17 deletions
+38 -17
View File
@@ -57,7 +57,7 @@ AdjustClusterObjIds( IGeomDB* pGeomDB, const INTVECTOR& vIds, INTVECTOR& vTrueId
if ( pGeomDB == nullptr)
return false ;
// Flag per calcolo box
const int BBF_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
const int BBF_PART_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
// Risolvo eventuali riferimenti a oggetti selezionati
vTrueIds.clear() ;
vTrueIds.reserve( vIds.size()) ;
@@ -66,7 +66,7 @@ AdjustClusterObjIds( IGeomDB* pGeomDB, const INTVECTOR& vIds, INTVECTOR& vTrueId
int nTrueId = (( nId != GDB_ID_SEL) ? nId : pGeomDB->GetFirstSelectedObj()) ;
while ( nTrueId != GDB_ID_NULL) {
BBox3d b3Part ;
if ( pGeomDB->GetGlobalBBox( nTrueId, b3Part, BBF_MY_FLAG)) {
if ( pGeomDB->GetGlobalBBox( nTrueId, b3Part, BBF_PART_MY_FLAG)) {
// inserisco l'identificativo nel vettore dei validi
vTrueIds.push_back( nTrueId) ;
// aggiorno il box del cluster
@@ -277,7 +277,7 @@ static bool
MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& b3Cluster, bool bReducedCut)
{
// Flag per calcolo box
const int BBF_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
const int BBF_PART_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
// Determino le regioni dei pezzi
INTVECTOR vReg ;
@@ -287,7 +287,7 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d&
// recupero regione del pezzo
int nRegId = GetFlatPartRegion( pGeomDB, nId) ;
BBox3d b3Reg ;
if ( pGeomDB->GetGlobalBBox( nRegId, b3Reg, BBF_MY_FLAG)) {
if ( pGeomDB->GetGlobalBBox( nRegId, b3Reg, BBF_PART_MY_FLAG)) {
vReg.emplace_back( nRegId) ;
b3RegCluster.Add( b3Reg) ;
}
@@ -323,7 +323,7 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d&
while ( nId2 != GDB_ID_NULL) {
if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) {
BBox3d b3Part2 ;
if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_MY_FLAG) &&
if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_PART_MY_FLAG) &&
b3Cluster.OverlapsXY( b3Part2)) {
// recupero regione del pezzo
int nRegId = GetFlatPartRegion( pGeomDB, nId2) ;
@@ -398,7 +398,7 @@ MyPackPartCluster( const INTVECTOR& vTrueIds, bool bReducedCut,
// Box della regione di interesse
BBox3d b3Region( dXmin, dYmin, 0, dXmax, dYmax, 0) ;
// Flag per calcolo box
const int BBF_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
const int BBF_PART_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
// Determino tutti gli altri pezzi compresi nella regione di interesse
INTVECTOR vOtherIds ;
@@ -406,7 +406,7 @@ MyPackPartCluster( const INTVECTOR& vTrueIds, bool bReducedCut,
while ( nId2 != GDB_ID_NULL) {
if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) {
BBox3d b3Part2 ;
if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_MY_FLAG) &&
if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_PART_MY_FLAG) &&
b3Region.OverlapsXY( b3Part2)) {
vOtherIds.emplace_back( nId2) ;
}
@@ -515,10 +515,29 @@ ExePackPartCluster( const INTVECTOR& vIds, bool bReducedCut, bool bBottomUp)
return false ;
b3Box.Expand( - SPESS, - SPESS, 0) ;
// Flag per calcolo box
const int BBF_PART_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
// Calcolo il box di ingombro delle regioni dei pezzi
BBox3d b3RegCluster ;
for ( int nId : vTrueIds) {
// recupero regione del pezzo
int nRegId = GetFlatPartRegion( pGeomDB, nId) ;
BBox3d b3Reg ;
if ( pGeomDB->GetGlobalBBox( nRegId, b3Reg, BBF_PART_MY_FLAG)) {
b3RegCluster.Add( b3Reg) ;
}
else
return false ;
}
double dRegClDimX = b3RegCluster.GetMax().x - b3RegCluster.GetMin().x ;
double dRegClDimY = b3RegCluster.GetMax().y - b3RegCluster.GetMin().y ;
// Procedo per tentativi
const double STEP = 50 ;
bool bFit = false ;
Point3d ptOrig = b3Cluster.GetMin() ;
Point3d ptLineStart = b3Box.GetMin() ;
Point3d ptLineStart = ( bBottomUp ? b3Box.GetMin() : b3Box.GetMax() - Vector3d(0, -dRegClDimY, 0)) ;
Point3d ptIns = ptLineStart ;
while ( true) {
// porto nella posizione di prova
@@ -533,11 +552,11 @@ ExePackPartCluster( const INTVECTOR& vIds, bool bReducedCut, bool bBottomUp)
break ;
}
// nuova posizione di inserimento (incrementando X)
ptIns += Vector3d( 50, 0, 0) ;
ptIns += Vector3d( STEP, 0, 0) ;
// se esco dal box torno all'inizio e incremento Y
if ( ! b3Box.EnclosesXY( ptIns)) {
ptLineStart += Vector3d( 0, 50, 0) ;
if ( ( ! b3Box.EnclosesXY( ptLineStart)))
if ( ! b3Box.EnclosesXY( ptIns + Vector3d( dRegClDimX, 0, 0))) {
ptLineStart += Vector3d( 0, ( bBottomUp ? STEP : - STEP), 0) ;
if ( ( ! b3Box.EnclosesXY( ptLineStart + Vector3d( 0, dRegClDimY, 0))))
break ;
ptIns = ptLineStart ;
}
@@ -651,8 +670,8 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
if ( vtMoveXY.IsSmall())
return true ;
// Flag per calcolo box
const int BBF_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
// Flag per calcolo box pezzi
const int BBF_PART_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
// Verifico se pezzi sotto la radice o pezzi in altro gruppo
int nGroupId = pGeomDB->GetParentId( vTrueIds[0]) ;
@@ -671,7 +690,7 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster
while ( nId2 != GDB_ID_NULL) {
if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) {
BBox3d b3Part2 ;
if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_MY_FLAG) &&
if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_PART_MY_FLAG) &&
b3Region.OverlapsXY( b3Part2)) {
// recupero regione del pezzo
int nRegId = GetFlatPartRegion( pGeomDB, nId2) ;
@@ -821,7 +840,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
// Rotazione nel piano XY globale
// Flag per calcolo box
const int BBF_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
const int BBF_PART_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ;
// Verifico se pezzi sotto la radice o pezzi in altro gruppo
int nGroupId = pGeomDB->GetParentId( vTrueIds[0]) ;
@@ -840,7 +859,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus
while ( nId2 != GDB_ID_NULL) {
if ( find( vTrueIds.begin(), vTrueIds.end(), nId2) == vTrueIds.end()) {
BBox3d b3Part2 ;
if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_MY_FLAG) &&
if ( pGeomDB->GetGlobalBBox( nId2, b3Part2, BBF_PART_MY_FLAG) &&
b3Region.OverlapsXY( b3Part2)) {
// recupero regione del pezzo
int nRegId = GetFlatPartRegion( pGeomDB, nId2) ;
@@ -990,6 +1009,8 @@ ExeAlignPartClusterOnCollision( const INTVECTOR& vIds, bool bReducedCut, bool& b
double dU ;
if ( ! pCrv->GetParamAtPoint( ptCntL, dU, 10 * EPS_SMALL))
return false ;
if ( fabs( dU - round( dU)) < 100 * EPS_PARAM)
dU = round( dU) ;
Point3d ptPp ;
Vector3d vtTp ;
if ( ! pCrv->GetPointTang( dU, ICurve::FROM_MINUS, ptPp, vtTp))