EgtMachKernel :
- prime prove per extra steps.
This commit is contained in:
+126
-15
@@ -9459,6 +9459,11 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
if ( IsNull( pSrfChunk_c) || ! pSrfChunk_c->IsValid() || pSrfChunk_c->GetChunkCount() == 0)
|
||||
return false ;
|
||||
|
||||
// creazione di un vettore con gli step ( caso base)
|
||||
VCT3DVECTOR vtVtTrasl ;
|
||||
for ( int j = 1 ; j <= nStep ; ++ j)
|
||||
vtVtTrasl.push_back( - vtTool * ( dDepth - dElev + j * dStep)) ;
|
||||
|
||||
// ================================ RECUPERO DELLA TRIMESH (se selezionata) ==============================
|
||||
// recupero il bordo della superficie
|
||||
PtrOwner<ICurveComposite> pCrvBorder( GetCurveComposite( pSrfChunk_c->GetLoop( 0, 0))) ;
|
||||
@@ -9476,11 +9481,21 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
! pStmORIG->AdjustTopology() ||
|
||||
! GetSelectedStm( pCrvBorder, GLOB_FRM, bIsStm, pStmORIG))
|
||||
return false ;
|
||||
//========================================================================================================
|
||||
|
||||
// ============= SE TRIMESH SELEZIONATA, ALLORA RICAVO REGIONE MASSIMA ===================================
|
||||
// DI PROEIZIONE E RICALCOLO EVENTUALI STEPS EXTRA
|
||||
if ( bIsStm) {
|
||||
// se la geometria selezionata è una Trimesh, allora controllo se ci sono delle facce da proiettare
|
||||
// se la geometria selezionata è una Trimesh, allora :
|
||||
// 1) controllo se ci sono delle facce da proiettare
|
||||
if ( ! ProjectEdgesOfSelectedStm( pSrfChunk_c, pStmORIG, pSfrExtended))
|
||||
return false ;
|
||||
|
||||
// 2) controllo se ci sono degli step extra ( aggiornando il vettore degli step)
|
||||
if ( ! CalcExtraSteps( pSrfChunk_c, pStmORIG, vtTool, dElev, dDepth, nStep, dStep, vtVtTrasl))
|
||||
return false ;
|
||||
vSrfSliced.resize(( int)vtVtTrasl.size()) ;
|
||||
vCrvOEWithFlags.resize(( int)vtVtTrasl.size()) ;
|
||||
vbChangedPrec.resize(( int)vtVtTrasl.size()) ;
|
||||
}
|
||||
// ======================================================================================
|
||||
|
||||
@@ -9498,11 +9513,12 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
// ======================================================================================
|
||||
|
||||
// ======================== AD OGNI STEP ADATTO LA SUPERIFICIE ==========================
|
||||
// ========= ADATTAMENTO A TRIMESH ( se necessario), INTERSEZIONE, PROIEZIONE ===========
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
// ADATTAMENTO A TRIMESH ( se necessario), INTERSEZIONE, PROIEZIONE
|
||||
// ED ESTENSIONE PRESSO LATI APERTI
|
||||
for ( int j = 1 ; j <= int( vtVtTrasl.size()) ; ++ j) {
|
||||
|
||||
// vettore traslazione corrente allo step j-esimo
|
||||
Vector3d vtTrasl = - vtTool * ( dDepth - dElev + j * dStep) ;
|
||||
// vettore traslazione corrente
|
||||
Vector3d vtTrasl = vtVtTrasl[j-1] ;
|
||||
// vettore delle curve con Flag per lati aperti
|
||||
ICRVCOMPOPOVECTOR vCrvOEF ;
|
||||
// flag se la superificie è cambiata
|
||||
@@ -9550,6 +9566,101 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
return true ;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::CalcExtraSteps( const ISurfFlatRegion* pSfrAct, const ISurfTriMesh* pStmORIG,
|
||||
const Vector3d vtTool, const double& dElev, const double& dDepth, const int& nStep,
|
||||
const double& dStep, VCT3DVECTOR& vtVtTrasl)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pSfrAct == nullptr || ! pSfrAct->IsValid() || pSfrAct->GetChunkCount() == 0 ||
|
||||
pStmORIG == nullptr || ! pStmORIG->IsValid())
|
||||
return false ;
|
||||
vtVtTrasl.clear() ;
|
||||
|
||||
// 0) scorro tutti gli steps
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
// 1) clono la superficie TriMesh originale
|
||||
PtrOwner<ISurfTriMesh> pStmORIG_c( CloneSurfTriMesh( pStmORIG)) ;
|
||||
if ( IsNull( pStmORIG_c) || ! pStmORIG_c->IsValid())
|
||||
return false ;
|
||||
|
||||
// 2) ricavo il vettore di Traslazione attuale e il precedente ( salvo l'attuale)
|
||||
Vector3d vtActTrasl = - vtTool * ( dDepth - dElev + j * dStep) ;
|
||||
vtVtTrasl.push_back( vtActTrasl) ;
|
||||
Vector3d vtPrecTrasl = - vtTool * ( dDepth - dElev + ( j-1) * dStep) ;
|
||||
|
||||
// 2) Ricavo i piani di taglio
|
||||
Point3d ptC ; pSfrAct->GetCentroid( ptC) ;
|
||||
Vector3d vtN = pSfrAct->GetNormVersor() ;
|
||||
Plane3d plNear ; plNear.Set( ptC + vtActTrasl, -vtN) ;
|
||||
Plane3d plFar ; plFar.Set( ptC + vtPrecTrasl, vtN) ;
|
||||
if ( ! plNear.IsValid() || ! plFar.IsValid())
|
||||
return false ;
|
||||
|
||||
// 3) taglio la Trimesh con questi piani
|
||||
if ( ! pStmORIG_c->Cut( plNear, true) ||
|
||||
! pStmORIG_c->Cut( plFar, true))
|
||||
return false ;
|
||||
if ( ! pStmORIG_c->IsValid())
|
||||
continue ;
|
||||
//int G = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmORIG_c->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( G, GRAY) ;
|
||||
|
||||
// 4) Cerco se ci sono delle facce che presentano una normale parallela al versore di svuotatura
|
||||
vector<double> vdDists ;
|
||||
for ( int f = 0 ; f < pStmORIG_c->GetFacetCount() ; ++ f) {
|
||||
Vector3d vtN_Check ; pStmORIG_c->GetFacetNormal( f, vtN_Check) ;
|
||||
if ( ! AreSameOrOppositeVectorApprox( vtN_Check, vtN))
|
||||
continue ;
|
||||
|
||||
//int Y = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmORIG_c->CloneFacet( f)) ;
|
||||
//m_pGeomDB->SetMaterial( Y, YELLOW) ;
|
||||
|
||||
// 5) se faccia trovata, allora calcolo la distanza tra il piano far e la faccia
|
||||
Point3d ptC_f ; pStmORIG_c->GetFacetCenter( f, ptC_f, vtN) ;
|
||||
double dCurrDist = abs( DistPointPlane( ptC_f, plFar)) ;
|
||||
if ( dCurrDist < 100 * EPS_SMALL || abs( dCurrDist - dStep) < 100 * EPS_SMALL) // andava già bene lo step deciso a priori ;)
|
||||
continue ;
|
||||
|
||||
// 6) inserisco uno step se tale distanza non è già ( in maniera approssimativa) contenuta nel vettore
|
||||
// delle distanze
|
||||
bool bInsert = true ;
|
||||
for ( int d = 0 ; d < ( int)vdDists.size() && bInsert ; ++ d) {
|
||||
if ( abs( dCurrDist - vdDists[d]) < 100 * EPS_SMALL * dStep)
|
||||
bInsert = false ;
|
||||
}
|
||||
if ( bInsert) {
|
||||
// 6.1) aggiorno il vettore delle distanze
|
||||
vdDists.push_back( dCurrDist) ;
|
||||
// 6.2) ricavo il vettore traslazione extra
|
||||
Vector3d vtTraslExtra = vtPrecTrasl - vtTool * dCurrDist ;
|
||||
// 6.3) inserisco nel vettore traslazione il nuovo step ricavato
|
||||
vtVtTrasl.push_back( vtTraslExtra) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 7) ora riodino il vettore ( le facce f ricavate non sono per forza ordinate rispetto al versore di svuotatura)
|
||||
// 7.1) creo un frame locale per confrontare solo i valori lungo Z
|
||||
Frame3d frPock ;
|
||||
Point3d ptORIG ; pSfrAct->GetCentroid( ptORIG) ;
|
||||
frPock.Set( ptORIG, pSfrAct->GetNormVersor()) ;
|
||||
if ( ! frPock.IsValid())
|
||||
return false ;
|
||||
// 7.2) porto in locale il vettore delle traslazioni
|
||||
for ( int v = 0 ; v < ( int)vtVtTrasl.size() ; ++ v)
|
||||
vtVtTrasl[v].ToLoc( frPock) ;
|
||||
// 7.3) confronto i valori di Z ( ordine decrescente)
|
||||
sort( vtVtTrasl.begin(), vtVtTrasl.end(), []( Vector3d &a, Vector3d &b){ return a.z > b.z ; }) ;
|
||||
// 7.4) riporto il vettore nel frame globale
|
||||
for ( int v = 0 ; v < ( int)vtVtTrasl.size() ; ++ v)
|
||||
vtVtTrasl[v].ToGlob( frPock) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::GetSelectedStm( const ICurveComposite* pCvrBorder, Frame3d frPocket, bool& bIsStm, ISurfTriMesh* pStmOrig)
|
||||
@@ -9764,8 +9875,8 @@ Pocketing::GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSrfExtended, const IS
|
||||
if ( ! GetSfrByStm( pStmExtended, pSfrExtended, plProj, vtExtr, dThick))
|
||||
return false ;
|
||||
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrProjUP->Clone()) ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrExtended->Clone()) ;
|
||||
m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrProjUP->Clone()) ;
|
||||
m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrExtended->Clone()) ;
|
||||
|
||||
// controllo se la FlatRegion estesa fino alla Trimesh non sia più piccola della parte proiettata
|
||||
|
||||
@@ -9848,8 +9959,8 @@ Pocketing::ProjectStmOnPlane( const ISurfTriMesh* pStmAbove, const Plane3d plPoc
|
||||
if ( ! pStmRef->Scale( frPlane, 1., 1., 0.))
|
||||
return false ;
|
||||
|
||||
int p = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmRef->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( p, PURPLE) ;
|
||||
//int p = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmRef->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( p, PURPLE) ;
|
||||
|
||||
// 4) controllo la validità della superficie ottenuta
|
||||
if ( IsNull( pStmRef) || ! pStmRef->IsValid() || pStmRef->GetTriangleCount() == 0)
|
||||
@@ -9910,11 +10021,11 @@ Pocketing::ProjectStmOnPlane( const ISurfTriMesh* pStmAbove, const Plane3d plPoc
|
||||
pSfrProj->CopyFrom( pSfrUp1) ;
|
||||
}
|
||||
|
||||
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrUp->Clone()) ;
|
||||
int o = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrUp1->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( r, RED) ;
|
||||
m_pGeomDB->SetMaterial( o, ORANGE) ;
|
||||
m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrProj->Clone()) ;
|
||||
//int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrUp->Clone()) ;
|
||||
//int o = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrUp1->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( r, RED) ;
|
||||
//m_pGeomDB->SetMaterial( o, ORANGE) ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrProj->Clone()) ;
|
||||
|
||||
return pSfrProj != nullptr && pSfrProj->IsValid() && pSfrProj->GetChunkCount() != 0 ;
|
||||
}
|
||||
|
||||
@@ -103,6 +103,9 @@ class Pocketing : public Machining
|
||||
bool GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSfrExtended, const ISurfFlatRegion* pSfrORIG,
|
||||
const ISurfTriMesh* pStmORIG, const Vector3d& vtTrasl, ISurfFlatRegion* pNewSrfPock) ;
|
||||
bool ProjectStmOnPlane( const ISurfTriMesh* pStmAbove, const Plane3d plPock, ISurfFlatRegion* pSfrProj) ;
|
||||
bool CalcExtraSteps( const ISurfFlatRegion* pSfrAct, const ISurfTriMesh* pStmORIG,
|
||||
const Vector3d vtTool, const double& dElev, const double& dDepth, const int& nStep,
|
||||
const double& dStep, VCT3DVECTOR& vtVtTrasl) ;
|
||||
bool AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMesh* pStmRaw, const double& dRawSecLen,
|
||||
ICRVCOMPOPOVECTOR& vCrvOEFlags, bool& bChanged, int nStep, double dStep,
|
||||
double dAreaToll = 500 * EPS_SMALL) ;
|
||||
|
||||
Reference in New Issue
Block a user