EgtMachKernel :

- Aggiunte Feed e migliorie su lati aperti per Sgrossature.
This commit is contained in:
Riccardo Elitropi
2024-07-03 13:25:06 +02:00
parent 6f7adce5e2
commit 2cea265ce3
2 changed files with 55 additions and 114 deletions
+53 -104
View File
@@ -88,27 +88,34 @@ using namespace std ;
static string KEY_SURF_POCK = "SurfPock_" ;
static string KEY_SURF_LIMIT = "SurfLimit_" ;
static const bool ENABLE_DEBUG = false ;
static string _DEBUG_GROUP_TERRACE = "Terraces" ;
static string _DEBUG_GROUP_FEED = "Feeds" ;
/* start debug functions */
static PerformanceCounter s_Counter ;
/*
s_Counter.Start() ;
double dTime = s_Counter.Stop() ;
LOG_ERROR( GetEMkLogger(), ( "1) regione estesa :" + to_string( dTime)).c_str()) ;
*/
void
SurfRoughing::DrawLoopsSurf( const ISurfFlatRegion* pSfr, bool bWithSurf, Color Col, bool bAlphaCoverage) {
if ( bWithSurf)
DrawSimpleSurf( pSfr, Col) ;
SurfRoughing::DrawLoopsSurf( const ISurfFlatRegion* pSfr, bool bWithSurf, Color Col, bool bAlphaCoverage, int nStep)
{
int myId = m_pGeomDB->GetFirstNameInGroup( GDB_ID_ROOT, _DEBUG_GROUP_TERRACE) ;
if ( myId == GDB_ID_NULL) {
myId = m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, GLOB_FRM) ;
m_pGeomDB->SetName( myId, _DEBUG_GROUP_TERRACE) ;
}
else {
if ( nStep == 0)
m_pGeomDB->EmptyGroup( myId) ;
}
int myStepId = m_pGeomDB->AddGroup( GDB_ID_NULL, myId, GLOB_FRM) ;
m_pGeomDB->SetName( myStepId, "Step " + ToString( nStep)) ;
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, myStepId, pSfr->Clone()) ;
m_pGeomDB->SetMaterial( nInd, Col) ;
for ( int c = 0 ; c < pSfr->GetChunkCount() ; ++ c) {
for ( int l = 0 ; l < pSfr->GetLoopCount( c) ; ++ l) {
PtrOwner<ICurveComposite> pCrvCompo( GetCurveComposite( pSfr->GetLoop( c, l))) ;
for ( int u = 0 ; u < pCrvCompo->GetCurveCount() ; ++ u) {
int nProp0 ; pCrvCompo->GetCurveTempProp( u, nProp0, 0) ;
int nProp1 ; pCrvCompo->GetCurveTempProp( u, nProp1, 1) ;
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvCompo->GetCurve( u)->Clone()) ;
nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, myStepId, pCrvCompo->GetCurve( u)->Clone()) ;
m_pGeomDB->SetMaterial( nInd, nProp0 == 0 ? ! bAlphaCoverage ? BLUE : AQUA : ! bAlphaCoverage ? RED : ORANGE) ;
}
}
@@ -117,95 +124,26 @@ SurfRoughing::DrawLoopsSurf( const ISurfFlatRegion* pSfr, bool bWithSurf, Color
}
void
SurfRoughing::DrawSimpleSurf( const ISurfFlatRegion* pSfr, Color Col)
SurfRoughing::DrawFeed( const ICurveComposite* pCrv, int nStep)
{
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfr->Clone()) ;
m_pGeomDB->SetMaterial( nInd, Col) ;
return ;
}
void
SurfRoughing::DrawVectorCurves( const ICRVCOMPOPOVECTOR& vCrv)
{
for ( int l = 0 ; l < int( vCrv.size()) ; ++ l) {
for ( int u = 0 ; u < vCrv[l]->GetCurveCount() ; ++ u) {
int nProp0 ; vCrv[l]->GetCurveTempProp( u, nProp0, 0) ;
int nProp1 ; vCrv[l]->GetCurveTempProp( u, nProp1, 1) ;
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, vCrv[l]->GetCurve( u)->Clone()) ;
m_pGeomDB->SetMaterial( nInd, nProp0 == 0 ? BLUE : RED) ;
}
int myId = m_pGeomDB->GetFirstNameInGroup( GDB_ID_ROOT, _DEBUG_GROUP_FEED) ;
if ( myId == GDB_ID_NULL) {
myId = m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, GLOB_FRM) ;
m_pGeomDB->SetName( myId, _DEBUG_GROUP_FEED) ;
}
return ;
}
void
SurfRoughing::DrawSimpleCurve( const ICurveComposite* pCrv, bool bUniform, Color Col)
{
for ( int u = 0 ; u < pCrv->GetCurveCount() ; ++ u) {
int nProp0 ; pCrv->GetCurveTempProp( u, nProp0, 0) ;
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrv->GetCurve( u)->Clone()) ;
m_pGeomDB->SetMaterial( nInd, ! bUniform ? nProp0 == 0 ? BLUE : nProp0 == 1 ? RED : WHITE : Col) ;
else {
if ( nStep == 0)
m_pGeomDB->EmptyGroup( myId) ;
}
return ;
}
void
SurfRoughing::DrawCompoCurve( const ICurveComposite* pCrv, Color Col)
{
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrv->Clone()) ;
m_pGeomDB->SetMaterial( nInd, Col) ;
return ;
}
void
SurfRoughing::DrawSimpleTriMesh( const ISurfTriMesh* pStm, Color Col)
{
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStm->Clone()) ;
m_pGeomDB->SetMaterial( nInd, Col) ;
return ;
}
void
SurfRoughing::DrawSimplePoint( const Point3d& pT, Color Col)
{
PtrOwner<IGeoPoint3d> ptGeo( CreateGeoPoint3d()) ;
ptGeo->Set( pT) ;
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ptGeo->Clone()) ;
m_pGeomDB->SetMaterial( nInd, Col) ;
return ;
}
void
SurfRoughing::DrawSimpleVector( const Vector3d& vT, Point3d ptPos, Color Col)
{
PtrOwner<IGeoVector3d> vtGeo( CreateGeoVector3d()) ;
vtGeo->Set( vT) ;
vtGeo->Translate( ptPos - ORIG) ;
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, vtGeo->Clone()) ;
m_pGeomDB->SetMaterial( nInd, Col) ;
return ;
}
void
SurfRoughing::DrawFeed( const ICurveComposite* pCrv)
{
int myStepId = m_pGeomDB->AddGroup( GDB_ID_NULL, myId, GLOB_FRM) ;
m_pGeomDB->SetName( myStepId, "Step " + ToString( nStep)) ;
for ( int u = 0 ; u < pCrv->GetCurveCount() ; ++ u) {
double myAngle = 120 * ( pCrv->GetCurve( u)->GetTempParam( 0) / 1000.) ;
DrawCompoCurve( ConvertCurveToComposite( pCrv->GetCurve( u)->Clone()),
GetColorFromHSV( HSV( myAngle, 1., 1.))) ;
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, myStepId, pCrv->GetCurve( u)->Clone()) ;
m_pGeomDB->SetMaterial( nInd, GetColorFromHSV( HSV( myAngle, 1., 1.))) ;
}
return ;
}
void
SurfRoughing::DrawSingleCurveFeed( const ICurve* pCrv)
{
double myAngle = 120 * ( pCrv->GetTempParam( 0) / 1000.) ;
int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrv->Clone()) ;
m_pGeomDB->SetMaterial( nInd, GetColorFromHSV( HSV( myAngle, 1., 1.))) ;
return ;
}
/* end debug functions */
@@ -1405,9 +1343,9 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
vector< myStepInfo> vStepInfo ;
// inserisco prima gli step...
for ( int i = 0 ; i < nStep ; ++ i) {
for ( int i = 0 ; i < nStep ; ++ i)
vStepInfo.emplace_back( i, -1, - ( i + 1) * dStep, false, nullptr) ;
}
// ... e poi gli step intermedi ( se presenti e non coincidenti con gli Step base)
int nIndRef = 0 ; // ( step base sottostante allo step intermedio corrente )
// creo un vettore di step intermedi presenti tra lo step base ( nIndRef-1)-esimo e nIndRef-esimo
@@ -1789,6 +1727,8 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
double dAppr = m_Params.m_dStartPos ;
// recupero il tipo di svuotatura
int nSubType = m_Params.m_nSubType ;
// numero di Step corrente
int nCurrStep = 0 ;
// ciclo sulle regioni
bool bStart = true ;
@@ -1813,7 +1753,9 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
if ( ! bIsSubStep)
++ nBasicStep ;
DrawLoopsSurf( pSfrPock, true, Color( 1., 1., 1., .1), bIsSubStep) ;
if ( ENABLE_DEBUG) {
DrawLoopsSurf( pSfrPock, true, Color( 1., 1., 1., .1), bIsSubStep, nCurrStep) ;
}
ICRVCOMPOPOVECTOR vpCrvs ; // percorso di svuotatura
// se si tratta di uno step base, allora lavoro l'intera superficie
@@ -1836,9 +1778,18 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
// ciclo sui percorsi
for ( int k = 0 ; k < int( vpCrvs.size()) ; ++ k) {
if ( ENABLE_DEBUG) {
DrawFeed( vpCrvs[k], nCurrStep) ;
}
// controllo se il percorso ha un ingresso presso un lato aperto
bool bOutStart = ( vpCrvs[k]->GetCurveCount() > 0 && vpCrvs[k]->GetCurve( 0)->GetTempProp( 0) == 2) ;
// inizializzo la curva di Ritorno per LeadIn/LeadOut
// controllo se il percorso è formato da una singola curva seguente il lato chiuso
bool bSingleCrv = ( vpCrvs[k]->GetCurveCount() > 0 && vpCrvs[k]->GetTempProp( 0) == 3) ;
// controllo se caso ottimizzato a trapezio
bool bOptTrap = ( vpCrvs[k]->GetCurveCount() > 0 && vpCrvs[k]->GetTempProp( 0) == 4) ;
// inizializzo la curva di Ritorno per LeadIn/LeadOut
PtrOwner<ICurveComposite> pRCrv( CreateCurveComposite()) ;
if ( IsNull( pRCrv))
return false ;
@@ -1860,9 +1811,9 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
pCurve->GetStartDir( vtStart) ;
// calcolo la curva pRCrv associata
Point3d ptUp = ptStart ;
if ( bOutStart)
if ( bOutStart || bOptTrap)
pCurve->GetEndPoint( ptUp) ;
else if ( nSubType == SURFROU_SUB_SPIRALIN)
else if ( ! bSingleCrv && nSubType == SURFROU_SUB_SPIRALIN)
if ( ! CalcRetCrv( vpCrvs[k], ptUp, bOutStart, pRCrv))
return false ;
// determino inizio attacco
@@ -1918,7 +1869,7 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pCompo,
( ( nSubType == SURFROU_SUB_SPIRALIN || nSubType == SURFROU_SUB_SPIRALOUT)) ? Get( pRCrv) : nullptr,
( nSubType == SURFROU_SUB_SPIRALOUT) ? m_Params.m_bInvert : ! m_Params.m_bInvert,
bSplitArcs, bOutStart, false)) {
bSplitArcs, ( bOutStart || bSingleCrv || bOptTrap), false)) {
m_pMchMgr->SetLastError( 3013, "Error in SurfRoughing : LeadIn not computable") ;
return false ;
}
@@ -1933,7 +1884,6 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
ICurveLine* pLine = GetCurveLine( pCurve) ;
Point3d ptP3 = pLine->GetEnd() ;
Vector3d vtMove ; pLine->GetStartDir( vtMove) ;
//SetFeed( GetRightFeed( vtMove, vtTool)) ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
}
@@ -1944,11 +1894,9 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
Vector3d vtN = pArc->GetNormVersor() ;
Point3d ptP3 ;
pArc->GetEndPoint( ptP3) ;
//SetFeed( GetFeed()) ;
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
return false ;
}
DrawSingleCurveFeed( pCurve) ;
// se ultima entità
if ( i == nMaxInd) {
// dati fine entità
@@ -1984,6 +1932,7 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
}
}
}
++ nCurrStep ;
}
return true ;
+2 -10
View File
@@ -135,16 +135,8 @@ class SurfRoughing : public Machining
return m_Params.m_nLeadOutType ; }
/* debug functions */
void DrawLoopsSurf( const ISurfFlatRegion* pSfr, bool bWithSurf, Color Col, bool bAlphaCoverage) ;
void DrawSimpleSurf( const ISurfFlatRegion* pSfr, Color Col) ;
void DrawVectorCurves( const ICRVCOMPOPOVECTOR& vCrv) ;
void DrawSimpleCurve( const ICurveComposite* pCrv, bool bUniform, Color Col) ;
void DrawCompoCurve( const ICurveComposite* pCrv, Color Col) ;
void DrawSimpleTriMesh( const ISurfTriMesh* pStm, Color Col) ;
void DrawSimplePoint( const Point3d& pT, Color Col) ;
void DrawSimpleVector( const Vector3d& vT, Point3d ptPos, Color Col) ;
void DrawFeed( const ICurveComposite* pCrv) ;
void DrawSingleCurveFeed( const ICurve* pCrv) ;
void DrawLoopsSurf( const ISurfFlatRegion* pSfr, bool bWithSurf, Color Col, bool bAlphaCoverage, int nStep) ;
void DrawFeed( const ICurveComposite* pCrv, int nStep) ;
/* end debug functions */
private :