diff --git a/WaterJetting.cpp b/WaterJetting.cpp index f22e32f..232524f 100644 --- a/WaterJetting.cpp +++ b/WaterJetting.cpp @@ -1205,9 +1205,6 @@ WaterJetting::Chain( int nGrpDestId) // vettore puntatori alle curve ICURVEPOVECTOR vpCrvs ; vpCrvs.reserve( m_vId.size()) ; - // vettore selettori delle curve originali - SELVECTOR vInds ; - vInds.reserve( m_vId.size()) ; // recupero tutte le curve e le porto in globale for ( const auto& Id : m_vId) { // prendo le curve @@ -1217,14 +1214,16 @@ WaterJetting::Chain( int nGrpDestId) m_pMchMgr->SetWarning( 3251, sInfo) ; } for ( auto pCrv : lstPC) { + // salvo l'id geometrico della curva nelle sue temp prop per i conti successivi + pCrv->SetTempProp( Id.nId, 0) ; + pCrv->SetTempProp( Id.nSub, 1) ; vpCrvs.emplace_back( pCrv) ; - vInds.emplace_back( Id) ; } } - // verifico se sono necessarie sistemazioni per collegamenti (bridges) + // verifico se sono necessarie sistemazioni per collegamenti ( bridges) if ( abs( m_Params.m_dSideAngle) < EPS_ANG_SMALL && m_pGeomDB->GetFirstNameInGroup( m_pMchMgr->GetCurrMachGroup(), MACH_BRIDGES_GROUP) != GDB_ID_NULL) { - AdjustCurvesForBridges( vpCrvs, vInds) ; + AdjustCurvesForBridges( vpCrvs) ; } // preparo i dati per il concatenamento bool bFirst = true ; @@ -1253,8 +1252,8 @@ WaterJetting::Chain( int nGrpDestId) } // recupero i percorsi concatenati int nCount = 0 ; - INTVECTOR vnId2 ; - while ( chainC.GetChainFromNear( ptNear, false, vnId2)) { + INTVECTOR vnId ; + while ( chainC.GetChainFromNear( ptNear, false, vnId)) { // creo una curva composita PtrOwner pCrvCompo( CreateCurveComposite()) ; if ( IsNull( pCrvCompo)) @@ -1263,18 +1262,18 @@ WaterJetting::Chain( int nGrpDestId) Vector3d vtExtr = Z_AX ; double dThick = 0 ; // vettore Id originali - SELVECTOR vId2 ; - vId2.reserve( vnId2.size()) ; + SELVECTOR vOrigId ; + vOrigId.reserve( vnId.size()) ; // recupero le curve semplici e le inserisco nella curva composita - for ( size_t i = 0 ; i < vnId2.size() ; ++ i) { - int nId = abs( vnId2[i]) - 1 ; - bool bInvert = ( vnId2[i] < 0) ; - vId2.emplace_back( vInds[nId]) ; + for ( int i = 0 ; i < int( vnId.size()) ; ++ i) { + int nId = abs( vnId[i]) - 1 ; + bool bInvert = ( vnId[i] < 0) ; // recupero la curva ICurve* pCrv = vpCrvs[nId] ; + vOrigId.emplace_back( pCrv->GetTempProp( 0), pCrv->GetTempProp( 1)) ; // se necessario, la inverto if ( bInvert) - pCrv->Invert() ; + pCrv->Invert() ; // recupero eventuali estrusione e spessore Vector3d vtTemp ; if ( pCrv->GetExtrusion( vtTemp)) { @@ -1303,7 +1302,7 @@ WaterJetting::Chain( int nGrpDestId) if ( nPathId == GDB_ID_NULL) return false ; m_pGeomDB->SetName( nPathId, MCH_PATH + ToString( ++ nCount)) ; - m_pGeomDB->SetInfo( nPathId, KEY_IDS, ToString( vId2)) ; + m_pGeomDB->SetInfo( nPathId, KEY_IDS, ToString( vOrigId)) ; // inserisco la curva composita nel gruppo destinazione int nNewId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, ::Release( pCrvCompo)) ; if ( nNewId == GDB_ID_NULL) @@ -1314,7 +1313,7 @@ WaterJetting::Chain( int nGrpDestId) //---------------------------------------------------------------------------- bool -WaterJetting::AdjustCurvesForBridges( ICURVEPOVECTOR& vpCrvs, SELVECTOR& vInds) +WaterJetting::AdjustCurvesForBridges( ICURVEPOVECTOR& vpCrvs) { // Gruppo dei collegamenti struct Bridge { @@ -1345,44 +1344,49 @@ WaterJetting::AdjustCurvesForBridges( ICURVEPOVECTOR& vpCrvs, SELVECTOR& vInds) } // Verifico i collegamenti che interessano le geometrie della lavorazione + double const DIST_MAX = 5 ; for ( int i = 0 ; i < int( vBridges.size()) ; ++ i) { - // cerco le due curve interessate dal collegamento + // cerco le due curve interessate dal collegamento calcolando e verificando anche la posizione dei punti di collegamento sulle + // due curve + double dMinLen = vBridges[i].dWidth + m_TParams.m_dDiam ; int nI1 = -1 ; - for ( int j = 0 ; j < int( vInds.size()) ; ++ j) { - if ( vInds[j].nId == vBridges[i].nEnt1) { - nI1 = j ; - break ; + double dDist1, dU1, dLenP1, dLen1 ; int nF1 ; + for ( int j = 0 ; j < int( vpCrvs.size()) ; ++ j) { + // recupero l'id geometrico della curva dalla sua temp prop + int nCrvId = vpCrvs[j]->GetTempProp() ; + if ( nCrvId == vBridges[i].nEnt1) { + DistPointCurve distPC1( vBridges[i].ptP1, *vpCrvs[j]) ; + if ( distPC1.GetDist( dDist1) && dDist1 < DIST_MAX && + distPC1.GetParamAtMinDistPoint( 0, dU1, nF1) && + vpCrvs[j]->GetLengthAtParam( dU1, dLenP1) && + vpCrvs[j]->GetLength( dLen1) && + dLenP1 > dMinLen - EPS_SMALL && + ( dLen1 - dLenP1) > dMinLen - EPS_SMALL) { + nI1 = j ; + break ; + } } } int nI2 = -1 ; - for ( int j = 0 ; j < int( vInds.size()) ; ++ j) { - if ( vInds[j].nId == vBridges[i].nEnt2) { - nI2 = j ; - break ; + double dDist2, dU2, dLenP2, dLen2 ; int nF2 ; + for ( int j = 0 ; j < int( vpCrvs.size()) ; ++ j) { + int nCrvId = vpCrvs[j]->GetTempProp() ; + if ( nCrvId == vBridges[i].nEnt2) { + DistPointCurve distPC2( vBridges[i].ptP2, *vpCrvs[j]) ; + if ( distPC2.GetDist( dDist2) && dDist2 < DIST_MAX && + distPC2.GetParamAtMinDistPoint( 0, dU2, nF2) && + vpCrvs[j]->GetLengthAtParam( dU2, dLenP2) && + vpCrvs[j]->GetLength( dLen2) && + dLenP2 > dMinLen - EPS_SMALL && + ( dLen2 - dLenP2) > dMinLen - EPS_SMALL) { + nI2 = j ; + break ; + } } } if ( nI1 == -1 || nI2 == -1) continue ; - // calcolo e verifico la posizione dei punti di collegamento sulle due curve - double const DIST_MAX = 5 ; - double dDist1, dU1, dLenP1, dLen1 ; int nF1 ; - DistPointCurve distPC1( vBridges[i].ptP1, *vpCrvs[nI1]) ; - if ( ! distPC1.GetDist( dDist1) || dDist1 > DIST_MAX || - ! distPC1.GetParamAtMinDistPoint( 0, dU1, nF1) || - ! vpCrvs[nI1]->GetLengthAtParam( dU1, dLenP1) || - ! vpCrvs[nI1]->GetLength( dLen1) || - dLenP1 < vBridges[i].dWidth + m_TParams.m_dDiam || - ( dLen1 - dLenP1) < vBridges[i].dWidth + m_TParams.m_dDiam) - continue ; - double dDist2, dU2, dLenP2, dLen2 ; int nF2 ; - DistPointCurve distPC2( vBridges[i].ptP2, *vpCrvs[nI2]) ; - if ( ! distPC2.GetDist( dDist2) || dDist2 > DIST_MAX || - ! distPC2.GetParamAtMinDistPoint( 0, dU2, nF2) || - ! vpCrvs[nI2]->GetLengthAtParam( dU2, dLenP2) || - ! vpCrvs[nI2]->GetLength( dLen2) || - dLenP2 < vBridges[i].dWidth + m_TParams.m_dDiam || - ( dLen2 - dLenP2) < vBridges[i].dWidth + m_TParams.m_dDiam) - continue ; + // spezzo le curve nei punti del collegamento e creo i segmenti di collegamento PtrOwner pCopy1( vpCrvs[nI1]->Clone()) ; PtrOwner pCopy2( vpCrvs[nI2]->Clone()) ; @@ -1400,15 +1404,11 @@ WaterJetting::AdjustCurvesForBridges( ICURVEPOVECTOR& vpCrvs, SELVECTOR& vInds) Point3d ptBs ; vpCrvs[nI2]->GetEndPoint( ptBs) ; Point3d ptBe ; pCopy1->GetStartPoint( ptBe) ; pLinkB->Set( ptBs, ptBe) ; - // inserisco le nuove curve nel vettore delle curve e aggiorno il vettore degli indici + // inserisco le nuove curve nel vettore delle curve vpCrvs.emplace_back( Release( pCopy1)) ; - vInds.emplace_back( vInds[nI1]) ; vpCrvs.emplace_back( Release( pCopy2)) ; - vInds.emplace_back( vInds[nI2]) ; vpCrvs.emplace_back( Release( pLinkA)) ; - vInds.emplace_back( 0, 0) ; vpCrvs.emplace_back( Release( pLinkB)) ; - vInds.emplace_back( 0, 0) ; } return true ; diff --git a/WaterJetting.h b/WaterJetting.h index 43b55a4..6f81526 100644 --- a/WaterJetting.h +++ b/WaterJetting.h @@ -78,7 +78,7 @@ class WaterJetting : public Machining bool VerifyGeometry( SelData Id, int& nSubs, int& nType) ; bool GetCurves( SelData Id, ICURVEPLIST& lstPC) ; bool Chain( int nGrpDestId) ; - bool AdjustCurvesForBridges( ICURVEPOVECTOR& vpCrvs, SELVECTOR& vInds) ; + bool AdjustCurvesForBridges( ICURVEPOVECTOR& vpCrvs) ; bool VerifySideAngle( void) ; bool ProcessPath( int nPathId, int nPvId, int nClId) ; bool AdjustPathForInternalAngles( ICurveComposite* pCompo) ;