80 Commits

Author SHA1 Message Date
Riccardo Elitropi ca72ddf1a4 EgtMachKernel :
- aggiunto utensile Vmill Additivo.
2024-04-22 13:22:50 +02:00
Dario Sassi d1406baa2e EgtMachKernel :
- corretto passaggio parametri spezzatura in pocketing e milling (correzione #1765).
2024-04-17 11:39:10 +02:00
Dario Sassi 89d46baf43 EgtMachKernel 2.6d4 :
- aggiunta gestione riferimento canonico per calcolo cinematica robot comunque disposto nello spazio
- adattamento funzioni di calcolo posizione, direzione utensile e ausiliaria da questi angoli
- in svuotatura corretta mancata esplosione di archi in rette sui percorsi di ritorno quando richiesta.
2024-04-17 06:58:27 +02:00
Dario Sassi 1f57693da8 EgtMachKernel :
- in foratura corretta segnalazione di errore fuorviante
- in fresatura sistemata gestione direzioni inizio e fine con percorrenze in direzione inversa
- in link tra percorsi di lavorazione per robot aggiunta posizione iniziale a Zmax dopo inserimento di risalita a Zmax in percorso immediatamente precedente.
2024-04-13 17:44:30 +02:00
Dario Sassi 010f676234 EgtMachKernel :
- modifiche a fresature per direzioni di riferimento di attacchi e uscite come inizio e fine dei percorsi originali
- migliorata in fresatura visualizzazione movimento lame quando interessano 2 o 3 curve di lavoro.
2024-04-11 00:24:09 +02:00
SaraP 1839b45e96 EgtMachKernel 2.6d3 :
- in WaterJet modificati anelli per angoli esterni
- spezzatura movimenti per robot.
2024-04-10 12:04:10 +02:00
Dario Sassi 9bc699be18 EgtMachKernel 2.6d2 :
- ricompilazione per modifiche a EgtLock.
2024-04-09 14:49:50 +02:00
Dario Sassi f701828a25 EgtMachKernel :
- aggiunta a MachMgr funzione GetClEntAxesMask
- gestione emissione in generazione/simulazione/stima di tutti gli assi rotanti del robot.
2024-04-03 08:14:20 +02:00
Dario Sassi f8d2f26692 EgtMachKernel 2.6d1 :
- se robot sempre spezzatura
- spezzatura movimenti per robot
- in tagli con lama, tolto da Apply preview.
2024-04-02 15:37:22 +02:00
Dario Sassi 4e3079e504 EgtMachKernel :
- in fresature aggiunte inserzioni ed estrazioni su link di percorsi OneWay con lame o utensili che non tagliano di testa.
2024-03-26 17:32:56 +01:00
Dario Sassi 0d0f195d8b EgtMachKernel :
- modifiche a fresature per approcci/retrazioni con frese che non lavorano di testa.
2024-03-26 13:32:13 +01:00
Dario Sassi 7fbce2b593 EgtMachKernel :
- aggiunta gestione oggetti per verifica collisioni nei link tra lavorazioni anche nelle tavole
- in fresatura standard migliorati approcci e retrazioni per frese che non lavorano di testa
- in simulazione migliorata gestione comandi ausiliari di start in Disposizioni senza movimenti.
2024-03-19 18:11:50 +01:00
Dario Sassi 74b2874f56 EgtMachKernel :
- correzione a gestione visualizzazione tavola corrente.
2024-03-16 10:32:57 +01:00
SaraP 9540563a87 EgtMachKernel 2.6c3 :
- modifiche allo split nei grezzi con lavorazioni per gestire tagli inclinati
- introdotte regioni up e down per i grezzi
- nelle preview di sawing e milling aggiunte superfici di lavorazione in corrispondenza delle facce del grezzo.
2024-03-14 10:30:37 +01:00
Dario Sassi 8eeca04757 EgtMachKernel 2.6c2 :
- ricompilazione con cambio versione.
2024-03-10 10:26:06 +01:00
Dario Sassi db6ae7538f EgtMachKernel 2.6c1 :
- migliorato calcolo collegamento tra passate di fresature a step OneWay.
2024-03-05 08:57:15 +01:00
Dario Sassi 839639fcc8 EgtMachKernel :
- eliminate alcune variabili non usate.
2024-02-27 18:36:32 +01:00
Dario Sassi c3729befbb EgtMachKernel :
- modifiche e correzioni per flag di fine passata (301) in fresatura con lama a ZigZag e OneWay.
2024-02-27 10:36:52 +01:00
Dario Sassi a79d9c9fe8 EgtMachKernel :
- piccola correzione a fresature con attacco/uscita a scivolo.
2024-02-26 18:06:22 +01:00
Dario Sassi d3b281a858 EgtMachKernel :
- migliorata fresatura di lato con lama con più passaggi (ZigZag e OneWay) con note utente
      SideElev anche negativa per avere controllo MaxMat con Step
      TrimExt=nClosedStmId per definire superficie chiusa con cui estendere/trimmare il percorso di lavoro.
2024-02-26 15:15:07 +01:00
Dario Sassi 37d0b8f552 EgtMachKernel :
- in Milling corretto calcolo punto inizio attacco nel caso percorso invertito per ZigZag o similare.
2024-02-22 16:59:14 +01:00
Dario Sassi 737124b0bd EgtMachKernel :
- modifiche per configurazione canonica robot da ZYY-ZYZ a ZYY-XYX.
2024-02-20 10:52:23 +01:00
Dario Sassi 09bdd4852d EgtMachKernel :
- corretto controllo catena cinematica in assenza di assi lineari (eliminato anche possibile crash).
2024-02-19 17:16:14 +01:00
Dario Sassi 1d3c722fd3 EgtMachKernel 2.6b4 :
- in simulazione aggiunti eventi Init e Exit a cui possono rispondere le funzioni lua OnSimulInit e OnSimulExit.
2024-02-19 14:54:50 +01:00
Dario Sassi 3ca2db72e9 EgtMachKernel 2.6b3 :
- adattamenti per modifiche a funzioni di Collision Detection.
2024-02-16 08:47:33 +01:00
Dario Sassi 028a5b7bba EgtMachKernel :
- aggiunta gestione macchine di tipo Robot, le altre sono ora definite di tipo Center.
2024-02-13 11:45:05 +01:00
Dario Sassi 1179ad7e84 EgtMachKernel 2.6b1 :
- migliorato controlli su testa e suo attrezzaggio per MultipleDrill.
2024-02-02 16:20:05 +01:00
Dario Sassi d8c5fe0ea7 EgtMachkernel :
- ora vengono restituiti ThDiam e ThLength anche per le mortasatrici/seghe a catena (ovviamente vanno considerati nella direzione dell'utensile).
2024-01-29 19:54:17 +01:00
Dario Sassi a21be79df8 EgtMachKernel 2.6a2 :
- modificato controllo parametri in LuaEmtMoveAxes per evitare crash in R64
- piccole migliorie.
2024-01-25 08:35:26 +01:00
Dario Sassi d66cc47936 EgtMachKernel :
- aggiunta funzione ChangeMachGroupName di MachMgr.
2024-01-16 19:44:30 +01:00
Dario Sassi cd2315af46 EgtMachKernel 2.6a1 :
- ricompilazione con cambio versione.
2024-01-16 15:50:38 +01:00
Dario Sassi 204d63b7c9 EgtMachKernel :
- modifiche per gestione teste multiple in foratura con modalità fissa, singola o multipla.
2024-01-16 09:35:21 +01:00
Dario Sassi 5a5b48326f EgtMachKernel :
- in foratura con testa multiuscite senza assi rotanti tolta necessità di presenza Asse Ausiliario.
2024-01-15 17:21:54 +01:00
Dario Sassi bd448babd9 EgtMachKernel 2.5l6 :
- aggiunta gestione script opzionale OnSpecialTestCollisionAvoid per avere un test custom di verifica collisione nei movimenti link tra le lavorazioni.
2024-01-15 15:06:50 +01:00
Dario Sassi 73ba4eb93a EgtMachKernel :
- allo script di aggiornamento utensili custom ora viene passata anche la SPEED (per permettere di sistemare il senso di rotazione indicato)
- nelle fresature in approccio e retrazione aggiunta gestione extra tra lunghezza di lavoro e lunghezza totale.
2024-01-06 15:47:57 +01:00
Dario Sassi 268fa05cc0 EgtMachKernel 2.5l5 :
- correzioni per forature semplici con rinvii
- correzioni per forature con aggregato da sotto.
2024-01-05 19:09:39 +01:00
Dario Sassi b5ef9ae6dc EgtMachKernel :
- aggiunto nuovo calcolo elevazione per un segmento dati gli estremi
- in fresatura migliorato approccio e retrazione per lame e frese che non lavorano di testa e non considerate fuori completamente dal pezzo.
2024-01-02 16:00:59 +01:00
Dario Sassi fcaf15cbe1 EgtMachKernel :
- in generazione CN e stima si imposta fase a 1 prima dell'inizio e al termine
- in simulazione aggiunta gestione errore in evento OnToolSelect.
2023-12-29 13:08:21 +01:00
Dario Sassi ab84757a80 EgtMachKernel 2.5l4 :
- piccole migliorie e correzioni a forature multiple con aggregato.
2023-12-20 17:37:34 +01:00
Dario Sassi 0fab073568 Merge remote-tracking branch 'origin/Drilling' 2023-12-20 08:22:21 +01:00
Dario Sassi 4d29452c2d EgtMachKernel :
- in fresatura aggiunta gestione movimento compensazione raggio utensile in ingressi e uscite lineari e tangenti anche senza correzione raggio fresa in macchina.
2023-12-19 16:47:43 +01:00
Dario Sassi 1bcff0eb79 EgtMachKernel :
- in svuotatura cambiato calcolo elevazione.
2023-12-18 09:31:31 +01:00
Dario Sassi 52bcc69023 EgtMachKernel 2.5l3 :
- in fresature migliorato calcolo di retrazione orizzontale quando quasi sotto il pezzo con utensile lama o fresa notip.
2023-12-15 19:57:55 +01:00
Dario Sassi 18ccead437 EgtMachKernel 2.5l2 :
- rimossa costante non più utilizzata.
2023-12-11 10:28:31 +01:00
Dario Sassi d49f198720 EgtMachKernel :
- ulteriori migliorie nel calcolo dell'elevazione.
2023-12-07 11:00:26 +01:00
Dario Sassi 368721dcaa EgtMachKernel 2.5l1 :
- elevation ora viene calcolato più precisamente tramite Collision Avoid.
2023-12-01 16:51:48 +01:00
Dario Sassi c8c8d9e2a5 EgtMachKernel :
- preparazione nuova gestione calcolo elevazioni.
2023-11-28 09:39:06 +01:00
Dario Sassi d5c39485ea EgtMachKernel 2.5k3 :
- aggiunta la possibilità di forzare sempre la visualizzazione del versore fresa negli oggetti CamData
- le funzioni lua EmtAddRapidStart, EmtAddRapidMove, EmtAddLinearMove e EmtAddArcMove ora hanno un parametro opzionale in più per forzare la visualizzazione della direzione utensile
- agli script per Lavorazioni Generiche ora sono passati parecchi dati geometrici e non dell'utensile utilizzato
- in visualizzazione dei percorsi in Doppio ora si tiene conto anche del parametro opzionale DeltaZ.
2023-11-22 20:31:38 +01:00
Dario Sassi e14c8eb8b3 EgtMachKernel 2.5k2 :
- correzioni a CalculateClPathAxesValues per lavorazioni 5 assi in continuo.
2023-11-16 18:59:46 +01:00
Dario Sassi d5638e192c EgtMachKernel :
- corretta GetDistanceFromRawSide per sapere quanto una posizione è all'interno del grezzo (sbagliava se posizione sul bordo e direzione di fuga tangente al bordo).
2023-11-06 11:10:41 +01:00
Dario Sassi 85cdb84a5a EgtMachKernel :
- corretto crash in simulazione con posizione Tc vuota dovuto a modifiche commit precedente.
2023-11-06 09:33:17 +01:00
Dario Sassi 63a71db7ff EgtMachKernel :
- modifiche per gestire aggregati di utensili su tool changer.
2023-11-06 08:49:27 +01:00
Dario Sassi aa369739c9 EgtMachKernel 2.5k1 :
- ricompilazione con cambio versione.
2023-11-03 17:24:28 +01:00
Dario Sassi d19dfc5f8f EgtMachKernel 2.5j5 :
- migliorato calcolo approcci di fresature e svuotature
- in fresatura e svuotatura ora attacchi elica, zigzag e inseguimento partono 2mm sopra il materiale
- in fresatura migliorato passaggio ad inseguimento tra uno step e il successivo.
2023-11-01 19:21:28 +01:00
Dario Sassi d874e30288 EgtMachKernel 2.5j4 :
- aggiunte a interfaccia di MachMgr le funzioni GetClEntAxesVal, GetToolSetupPosInCurrSetup e GetAllCurrAxesName.
2023-10-28 18:13:56 +02:00
Dario Sassi 4047b8385e EgtMachKernel :
- aggiunto messaggio di log nel caso di utensile non caricato perchè l'insieme tavola-testa non ha tre assi lineari.
2023-10-24 11:52:23 +02:00
Dario Sassi 63e95ab2fe EgtMachKernel 2.5j3 :
- migliorata simulazione con assi principali che non fanno movimento mentre lo fanno gli ausiliari (per controllo collisioni)
- la funzione EmtMoveAxes base per SimulMoveAxes ora gestisce fino a 10 assi in contemporanea.
2023-10-22 15:58:36 +02:00
Dario Sassi 93a5bd72c7 EgtMachKernel 2.5j2 :
- in creazione disegno utensile si nascondono eventuali Carter se è per visualizzazione in gestione DB utensili
- in OnToolData per generazione aggiunto parametro tipo utensile EMT.TTYPE
- in simulazione si lancia UpdateCurrSetup solo al primo avvio.
2023-10-16 16:10:24 +02:00
Dario Sassi b3a1ee8e6c EgtMachKernel 2.5j1 :
- ricompilazione con cambio versione.
2023-10-09 13:02:22 +02:00
Dario Sassi 562e8342c3 EgtMachKernel 2.5i6 :
- in fresatura e svuotatura modificati approcci e retrazioni per macchine con TiltingTable (TURN) per stare più lontani dal materiale.
2023-09-27 21:11:18 +02:00
Dario Sassi 8c821750ba EgtMachKernel 2.5i5 :
- ricompilazione a 64bit con Enable Enhanced Instruction Set = Not Set.
2023-09-21 15:26:02 +02:00
Dario Sassi 6669fdc7a9 EgtMachKernel :
- migliorato log di virtual  milling in simulazione.
2023-09-18 08:15:19 +02:00
Dario Sassi e2043a7e3a EgtMachKerenl :
- piccole migliorie a simulazione (aumento velocità in rapidi e log).
2023-09-14 17:25:44 +02:00
Dario Sassi f92cec9d3d EgtMachKernel 2.5i1 :
- aggiunta visualizzazione geometria di lavorazione in doppio per Drill, Pocketing e Milling
- a OnSetHead passata anche variabile globale EMC.USERNOTES con note utente dell'utensile
- in Simulazione corretto richiamo impostazione virtual milling su utensili con raggio maggiore del massimo gambo ammesso dal portautensile.
2023-09-11 10:47:42 +02:00
Dario Sassi f30f028b17 EgtMachKernel 2.5h3 :
- aggiunta possibilità di copiare un gruppo di lavoro.
2023-08-27 18:30:01 +02:00
Dario Sassi 1adcb2991c EgtMachKernel :
- in SurfFinishing possibilità di invertire anche percorso di lavorazione a ZigZag.
2023-08-25 10:42:53 +02:00
Dario Sassi 285e0ce910 EgtMachKernel 2.5h2 :
- aggiunta definizione EMC.VER con versione della dll a OnSetTable, OnSetHead e OnVerifyProtectedAreas
- alla modifica di posizione o direzione di un asse si sistema anche la geometria per la simulazione
- alla modifica della posizione di una uscita si sistema anche la geometria per la simulazione
- corretto carico uscite di una testa per direzioni poco discoste da quelle canoniche non correttamente assegnate.
2023-08-19 11:53:38 +02:00
Dario Sassi 652aa35aaa EgtMachKernel 2.5h1 :
- alla info di testa ZMAXONROT aggiunto parametro opzionale (3°) che indica lo spessore dei pezzi oltre il quale applicare la prescrizione.
2023-08-02 20:02:50 +02:00
DarioS 2b5aacc160 EgtMachKernel 2.5g3 :
- corretta fresatura zigzag con attacco con componente in direzione utensile (poteva risultare movimento nullo con conseguente erore)
- modificato controllo indeterminazione angoli su primo asse rotante per gestire correttamente macchina Multiax C1522 con rinvio da sotto.
2023-07-27 09:31:59 +02:00
DarioS 1097f2a19f EgtMachKernel :
- semplificazioni con utilizzo di ConvertCurveToComposite.
2023-07-21 15:12:35 +02:00
DarioS 8c1b61b6b8 EgtMachKernel 2.5g2 :
- prima di fare il calcolo degli assi nell'update delle lavorazioni si cancellano le entità di tipo CLIMB, RISE e HOME che potrebbero dare errori come extra-corse e che in ogni caso verrebbero cancellate e ricalcolate subito dopo con la funzione AdjustStartEndMovements.
2023-07-20 20:43:33 +02:00
DarioS 80363af1f6 EgtMachKernel :
- piccola miglioria stilistica.
2023-07-19 09:54:12 +02:00
DarioS 9b5adeaeb3 EgtMachKernel :
- i movimenti in rapido sono disegnati tratteggiati.
2023-07-10 11:17:59 +02:00
DarioS 01854f30ed EgtMachKernel 2.5g1 :
- in svuotatura corretta gestione forzatura contorni chiusi (Open=0 in UserNotes della lavorazione) con i casi ottimizzati.
2023-07-07 17:08:56 +02:00
DarioS cdb35b4c38 EgtMachKernel 2.5f3 :
- dove possibile e sicuro sostituiti dynamic_cast con static_cast.
2023-06-30 11:51:03 +02:00
DarioS 994658da16 EgtMachKernel :
- in simulazione aggiunta gestione collisione anche con poliedri.
2023-06-19 08:12:03 +02:00
DarioS 135c0bda51 EgtMachKernel 2.5f2 :
- correzione in fresatura per approccio con lame/frese notip.
2023-06-14 15:05:46 +02:00
DarioS d927848815 EgtMachKernel :
- in milling corretto approccio/retrazione di frese che non lavorano di testa.
2023-06-09 16:05:28 +02:00
DarioS 7b91c17cb3 EgtMachKernel :
- nell'interpretazione degli assi rotanti bloccati e degli angoli suggeriti dal token asse si toglie eventuale '=' finale che non può essere gestito nelle note utente della lavorazione.
2023-06-08 10:16:57 +02:00
DarioS 3851bdcecb EgtMachKernel 2.5f1 :
- in svuotature modificata gestione lati aperti, ora vengono lavorati con affondo laterali pari al passo di lato.
2023-06-08 08:17:54 +02:00
70 changed files with 5566 additions and 2549 deletions
+16 -13
View File
@@ -17,9 +17,11 @@
#include "Axis.h"
#include "MachConst.h"
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkGeoVector3d.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h"
#include "/EgtDev/Include/EgtNumUtils.h"
using namespace std ;
@@ -137,9 +139,8 @@ Axis::Set( const string& sName, const string& sToken, bool bInvert, double dOffs
bool
Axis::Modify( const Point3d& ptPos, double dAxisMaxAdjust)
{
// Verifico che lo spostamento non superi il massimo ammesso
Vector3d vtDelta = ptPos - m_ptPos ;
Vector3d vtDeltaPerp = vtDelta - ( vtDelta * m_vtDir) * m_vtDir ;
// Verifico che lo spostamento perpendicolare alla sua direzione non superi il massimo ammesso
Vector3d vtDeltaPerp = OrthoCompo( ptPos - m_ptPos, m_vtDir) ;
if ( vtDeltaPerp.Len() > dAxisMaxAdjust) {
string sOut = " Modify Axis " + m_sName + " Position (" + ToString( ptPos) + ") failed" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
@@ -147,6 +148,11 @@ Axis::Modify( const Point3d& ptPos, double dAxisMaxAdjust)
}
// Assegno la nuova posizione
m_ptPos = ptPos ;
// Sistemo la geometria dell'asse
int nV = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, m_sName) ;
IGeoVector3d* pGV = GetGeoVector3d( m_pGeomDB->GetGeoObj( nV)) ;
if ( pGV != nullptr)
pGV->ChangeBase( m_ptPos) ;
return true ;
}
@@ -164,6 +170,11 @@ Axis::Modify( const Vector3d& vtDir, double dAxisMaxRotAdj)
}
// Assegno la nuova direzione
m_vtDir = vtDirN ;
// Sistemo la geometria dell'asse
int nV = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, m_sName) ;
IGeoVector3d* pGV = GetGeoVector3d( m_pGeomDB->GetGeoObj( nV)) ;
if ( pGV != nullptr)
pGV->ChangeVector( m_vtDir) ;
return true ;
}
@@ -172,10 +183,7 @@ bool
Axis::Modify( const STROKE& Stroke)
{
m_Stroke = Stroke ;
if ( m_dHomeVal < m_Stroke.Min)
m_dHomeVal = m_Stroke.Min ;
else if ( m_dHomeVal > m_Stroke.Max)
m_dHomeVal = m_Stroke.Max ;
m_dHomeVal = Clamp( m_dHomeVal, m_Stroke.Min, m_Stroke.Max) ;
return true ;
}
@@ -183,12 +191,7 @@ Axis::Modify( const STROKE& Stroke)
bool
Axis::Modify( double dHome)
{
if ( dHome < m_Stroke.Min)
m_dHomeVal = m_Stroke.Min ;
else if ( dHome > m_Stroke.Max)
m_dHomeVal = m_Stroke.Max ;
else
m_dHomeVal = dHome ;
m_dHomeVal = Clamp( dHome, m_Stroke.Min, m_Stroke.Max) ;
return true ;
}
+27 -6
View File
@@ -1,13 +1,14 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2016
// EgalTech 2015-2023
//----------------------------------------------------------------------------
// File : CamData.cpp Data : 24.02.16 Versione : 1.6n8
// File : CamData.cpp Data : 22.11.23 Versione : 2.5k3
// Contenuto : Implementazione informazioni Cam di ogni movimento.
//
//
//
// Modifiche : 10.06.15 DS Creazione modulo.
// 24.02.16 DS Versione 2 (aggiunti m_nMove e m_ptCen).
// 22.11.23 DS Aggiunto flag ToolShow (forza in ogni caso la visualizzazione della direzione utensile).
//
//----------------------------------------------------------------------------
@@ -53,7 +54,9 @@ static int CAM_PARAM_V7 = 22 ;
static string CAM_ORIGFEED = "OrFeed" ;
static int CAM_PARAM_V8 = 23 ;
static string CAM_FLAG2 = "Flg2" ;
static int CAM_TOTPARAM =CAM_PARAM_V8 ;
static int CAM_PARAM_V9 = 24 ;
static string CAM_TOOLSHOW = "TSh" ;
static int CAM_TOTPARAM = CAM_PARAM_V9 ;
//----------------------------------------------------------------------------
@@ -79,6 +82,7 @@ CamData::Clone( void) const
pCam->m_pGeomDB = nullptr ;
pCam->m_nMove = m_nMove ;
pCam->m_nCorre = m_nCorre ;
pCam->m_bToolShow = m_bToolShow ;
pCam->m_vtTool = m_vtTool ;
pCam->m_vtCorr = m_vtCorr ;
pCam->m_vtAux = m_vtAux ;
@@ -139,6 +143,7 @@ CamData::Dump( string& sOut, bool bMM, const char* szNewLine) const
sOut += CAM_AXND + "=" + ToString( m_vtMachN) + szNewLine ;
sOut += CAM_NDLT + "=" + ToString( m_dDeltaN) + szNewLine ;
sOut += CAM_BDIR + "=" + ToString( m_vtBackAux) + szNewLine ;
sOut += CAM_TOOLSHOW + "=" + ToString( m_bToolShow) + szNewLine ;
return true ;
}
@@ -149,6 +154,8 @@ CamData::SetOwner( int nId, IGeomDB* pGDB)
{
m_nOwnerId = nId ;
m_pGeomDB = pGDB ;
if ( m_pGeomDB != nullptr)
m_pGeomDB->SetStipple( m_nOwnerId, ( m_nMove == 0 ? 3 : 0), 0x8C8C) ;
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
}
@@ -203,6 +210,8 @@ CamData::Save( int nBaseId, STRVECTOR& vString) const
vString[++k] = CAM_ORIGFEED + "=" + ToString( m_dOrigFeed) ;
// parametri aggiunti V8
vString[++k] = CAM_FLAG2 + "=" + ToString( m_nFlag2) ;
// parametri aggiunti V9
vString[++k] = CAM_TOOLSHOW + "=" + ToString( m_bToolShow) ;
}
catch( ...) {
return false ;
@@ -295,6 +304,14 @@ CamData::Load( const STRVECTOR& vString, int nBaseGdbId)
else {
m_nFlag2 = 0 ;
}
// parametri aggiunti V9
if ( int( vString.size()) >= CAM_PARAM_V9) {
if ( ! GetVal( vString[++k], CAM_TOOLSHOW, m_bToolShow))
return false ;
}
else {
m_bToolShow = false ;
}
return true ;
}
@@ -311,7 +328,7 @@ CamData::GetDrawPolyLines( POLYLINELIST& lstPL) const
PolyLine& PL = lstPL.back() ;
// dimensioni
const double TLEN = 40 ;
const double ALEN = 4 ;
const double ALEN = 1 ;
// inserisco disegno nella polilinea
PL.AddUPoint( 0, m_ptEnd) ;
Point3d ptTip = m_ptEnd + m_vtTool * TLEN ;
@@ -333,6 +350,9 @@ CamData::GetDrawPolyLines( POLYLINELIST& lstPL) const
ptP6.ToGlob( frF) ;
PL.AddUPoint( 6, ptP6) ;
PL.AddUPoint( 6, ptTip) ;
// da visualizzare sempre se richiesto
if ( m_bToolShow)
PL.SetTempProp( 1) ;
}
// se vettore correzione non nullo
if ( ! m_vtCorr.IsSmall()) {
@@ -342,7 +362,7 @@ CamData::GetDrawPolyLines( POLYLINELIST& lstPL) const
PolyLine& PL = lstPL.back() ;
// dimensioni
const double CLEN = 20 ;
const double ALEN = 2 ;
const double ALEN = 1 ;
// inserisco disegno nella polilinea
PL.AddUPoint( 0, m_ptEnd) ;
Point3d ptTip = m_ptEnd + m_vtCorr * CLEN ;
@@ -371,7 +391,7 @@ CamData::GetDrawPolyLines( POLYLINELIST& lstPL) const
PolyLine& PL = lstPL.back() ;
// dimensioni
const double CLEN = 20 ;
const double ALEN = 2 ;
const double ALEN = 1 ;
// inserisco disegno nella polilinea
PL.AddUPoint( 0, m_ptEnd) ;
Point3d ptTip = m_ptEnd + m_vtAux * CLEN ;
@@ -546,6 +566,7 @@ CamData::CamData( void)
m_pGeomDB = nullptr ;
m_nMove = 0 ;
m_nCorre = 0 ;
m_bToolShow = false ;
m_dAngCen = 0 ;
m_dDeltaN = 0 ;
m_dFeed = 0 ;
+10 -5
View File
@@ -68,11 +68,13 @@ class CamData : public IUserObj
bool SetAxesAngCen( double dAngCen) ;
bool SetAxesNormDir( const Vector3d& vtDir) ;
bool SetBackAuxDir( const Vector3d& vtDir) ;
const int GetMoveType( void) const
bool SetToolShow( bool bShow)
{ m_bToolShow = bShow ; return true ; }
int GetMoveType( void) const
{ return m_nMove ; }
const bool IsLine( void) const
bool IsLine( void) const
{ return ( m_nMove == 0 || m_nMove == 1) ; }
const bool IsArc( void) const
bool IsArc( void) const
{ return ( m_nMove == 2 || m_nMove == 3) ; }
const Vector3d& GetToolDir( void) const
{ return m_vtTool ; }
@@ -108,14 +110,16 @@ class CamData : public IUserObj
{ return m_vMachAxes ; }
const Point3d& GetAxesCen( void) const
{ return m_ptMachCen ; }
const double GetAxesRad( void) const
double GetAxesRad( void) const
{ return m_dMachRad ; }
const double GetAxesAngCen( void) const
double GetAxesAngCen( void) const
{ return m_dMachAngCen ; }
const Vector3d& GetAxesNormDir( void) const
{ return m_vtMachN ; }
const Vector3d& GetBackAuxDir( void) const
{ return m_vtBackAux ; }
bool GetToolShow( void) const
{ return m_bToolShow ; }
public :
enum { AS_NONE = 0,
@@ -139,6 +143,7 @@ class CamData : public IUserObj
IGeomDB* m_pGeomDB ;
int m_nMove ; // tipo movimento (0=rapido, 1=lineare, 2=arco CW, 3=arco CCW)
int m_nCorre ; // tipo correzione (0, 41, 42, 141, 142, 40)
bool m_bToolShow ; // flag per forzare la visualizzazione della direzione utensile in ogni caso
Vector3d m_vtTool ; // versore fresa
Vector3d m_vtCorr ; // versore correzione
Vector3d m_vtAux ; // versore ausiliario
+5 -2
View File
@@ -595,6 +595,9 @@ Chiseling::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
SetBlockedRotAxis( m_Params.m_sBlockedAxis) ;
@@ -1033,8 +1036,8 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC)
for ( int nC = nCstart ; nC < nCend ; ++ nC) {
// recupero i contorni del chunk
for ( int nL = 0 ; nL < pReg->GetLoopCount( nC) ; ++ nL) {
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo) || ! pCrvCompo->AddCurve( pReg->GetLoop( nC, nL)))
PtrOwner<ICurveComposite> pCrvCompo ;
if ( ! pCrvCompo.Set( ConvertCurveToComposite( pReg->GetLoop( nC, nL))))
return false ;
// assegno l'estrusione dalla normale alla regione
pCrvCompo->SetExtrusion( vtN) ;
+6 -2
View File
@@ -71,6 +71,10 @@ struct ChiselingData : public MachiningData
//----------------------------------------------------------------------------
inline const ChiselingData* GetChiselingData( const MachiningData* pMdata)
{ return (dynamic_cast<const ChiselingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_CHISELING)
return nullptr ;
return ( static_cast<const ChiselingData*>( pMdata)) ; }
inline ChiselingData* GetChiselingData( MachiningData* pMdata)
{ return (dynamic_cast<ChiselingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_CHISELING)
return nullptr ;
return ( static_cast<ChiselingData*>( pMdata)) ; }
+19
View File
@@ -86,6 +86,8 @@ Disposition::Clone( void) const
// eseguo copia dei dati
if ( pDisp != nullptr) {
try { pDisp->m_sTabName = m_sTabName ;
pDisp->m_pMchMgr = m_pMchMgr ;
pDisp->m_nPhase = m_nPhase ;
pDisp->m_ptRef1 = m_ptRef1 ;
pDisp->m_b3Area1 = m_b3Area1 ;
pDisp->m_dAreaOffset = m_dAreaOffset ;
@@ -1205,6 +1207,23 @@ Disposition::InsertMoveInfoInList( int nRawId, int nType, const Point3d& ptP, in
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::UpdateRawPartId( int nRawId, int nNewRawId)
{
// aggiorno i movimenti registrati per questo grezzo
while ( true) {
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
[ nRawId]( const MoveRawData& Mrv)
{ return ( Mrv.nRawId == nRawId) ; }) ;
if ( iIter == m_vMvrData.end())
break ;
else
iIter->nRawId = nNewRawId ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::RemoveRawPart( int nRawId)
+1
View File
@@ -102,6 +102,7 @@ class Disposition : public Operation
bool MoveRawPart( int nRawId, const Vector3d& vtMove) ;
bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ;
bool ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADeg, double dAngC1Deg, bool bAddToList = true) ;
bool UpdateRawPartId( int nRawId, int nNewRawId) ;
bool RemoveRawPart( int nRawId) ;
bool GetFixtureData( int nInd, std::string& sName, int& nId, Point3d& ptPos,
double& dAngDeg, double& dMov) const ;
+293 -217
View File
@@ -1,13 +1,14 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2023
//----------------------------------------------------------------------------
// File : Drilling.cpp Data : 21.05.15 Versione : 1.6e7
// File : Drilling.cpp Data : 20.12.23 Versione : 2.5l47
// Contenuto : Implementazione gestione forature.
//
// Note : Questa lavorazione è sempre espressa nel riferimento globale.
//
// Modifiche : 21.05.15 DS Creazione modulo.
//
// 20.12.23 RE Forature multiple con aggregati.
//
//
//----------------------------------------------------------------------------
@@ -47,6 +48,10 @@ using namespace std ;
// 2112 = "Error in Drilling : link outstroke xx"
// 2113 = "Error in Drilling : post apply not calculable"
// 2114 = "Error in Drilling : blind hole not reversible"
// 2115 = "Error in Drilling : Mirror for Double calculation failed"
// 2116 = "Error in Drilling : multi drilling head without valid tools"
// 2117 = "Error in Drilling : incorrect multi drilling head"
// 2118 = "Error in Drilling : Tool loading failed"
// 2151 = "Warning in Drilling : Skipped entity (xx)"
// 2152 = "Warning in Drilling : No machinable path"
// 2153 = "Warning in Drilling : Tool name changed (xx)"
@@ -71,32 +76,35 @@ struct Hole
} ;
struct MHDrill {
int nInd_id_hole ; // indice id foro
int nInd_id_hole ; // indice foro
Vector3d vtAux ; // vettore ausiliario per tale foratura
} ;
struct HoleInfo {
Hole hole ; // foro
bool bDrill = false ; // se alla fine verrà svuotato
bool bTempDrill = false ; // per test maschera (se durante un test viene svuotato o no)
int nTempTool = -1 ; // per test maschera ( indice utensile che lo svuota durante un test)
bool bSkipToAngle = false ; // nel caso di più assi rotanti, se foro già svuotato con testa orientata
bool bForToolM = false ; // se tool main svuoterà questo foro
bool bDrill = false ; // se alla fine verrà lavorato
bool bTempDrill = false ; // per test maschera (se durante un test viene lavorato o no)
int nTempTool = -1 ; // per test maschera ( indice utensile che lo lavora durante un test)
bool bSkipToAngle = false ; // nel caso di più assi rotanti, se foro già lavorato con testa orientata
bool bForToolM = false ; // se tool main lavorerà questo foro
int nIndHoleToolM = -1 ; // indice del foro che lo svuoterà inserendo il primo tool in esso
INTVECTOR vToolHole ; // vettore di indici dei fori ai quali inserire l'ultim punta per lavorare il foro corrente
INTVECTOR vIndTools ; // vettore dei tool associati ad ogni svuotatura in vToolHole (ordinati)
VCT3DVECTOR vVtAux ; // vettore dei vtAux ausiliari del tool principale per svuotare questo foro (ordinati)
int nIndTool = -1 ; // indice del tool che alla fine svuoterà il foro
Vector3d vtAux ; // vettore ausiliario del tool principale che permette al tool principale di svuotare questo foro
INTVECTOR vIndTools ; // vettore dei tool associati ad ogni lavorazione in vToolHole (ordinati)
VCT3DVECTOR vVtAux ; // vettore dei vtAux ausiliari del tool principale per lavorare questo foro (ordinati)
int nIndTool = -1 ; // indice del tool che alla fine lavorerà il foro
Vector3d vtAux ; // vettore ausiliario del tool principale che permette al tool principale di lavorare questo foro
Point3d ptBtn ; // punto interno alla base del foro
int nIndInSelVector = 0 ; // indice nel vettore m_vId (id fori selezionati)
} ;
struct ToolInfo
{
ToolData* pTool ; // 1) puntatore per utensile (nullo se utensile non presente)
Point3d ptETool ; // 2) punto finale del tool (per ptBtn del foro)
const ToolData* pTool ; // puntatore per utensile (nullo se utensile non presente)
Point3d ptToolTip ; // punto finale del tool (per ptBtn del foro)
ToolInfo( void)
: pTool( nullptr) {}
ToolInfo( const ToolData* pT)
: pTool( pT) {}
} ;
//----------------------------------------------------------------------------
@@ -601,6 +609,19 @@ Drilling::Apply( bool bRecalc, bool bPostApply)
else
m_pGeomDB->EmptyGroup( nClId) ;
// elimino eventuale gruppo geometria simmetrica per lavorazione in doppio
int nDblId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_DBL) ;
if ( nDblId != GDB_ID_NULL) {
m_pGeomDB->Erase( nDblId) ;
nDblId = GDB_ID_NULL ;
}
// rendo corrente l'utensile usato nella lavorazione
if ( ! m_pMchMgr->SetCalcTool( m_TParams.m_sName, m_TParams.m_sHead, m_TParams.m_nExit)) {
m_pMchMgr->SetLastError( 2118, "Error in Drilling : Tool loading failed") ;
return false ;
}
// se lavorazione standard
if ( m_Params.m_nSubType == DRI_SUB_STD) {
if ( ! StandardProcess( bRecalc, GDB_ID_NULL, nClId))
@@ -621,7 +642,13 @@ Drilling::Apply( bool bRecalc, bool bPostApply)
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
// se lavorazione in doppio, aggiungo geometria della parte simmetrica
if ( ! CalcMirrorByDouble( nClId, m_Params.m_sUserNotes)) {
m_pMchMgr->SetLastError( 2115, "Error in Drilling : Mirror for Double calculation failed") ;
return false ;
}
// aggiorno stato della lavorazione
m_nStatus = ( bPostApply ? MCH_ST_OK : MCH_ST_NO_POSTAPPL) ;
// dichiaro successiva da aggiornare
@@ -646,6 +673,9 @@ Drilling::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
SetBlockedRotAxis( m_Params.m_sBlockedAxis) ;
@@ -688,28 +718,57 @@ Drilling::Update( bool bPostApply)
return true ;
}
//----------------------------------------------------------------------------
bool
Drilling::VerifyMultiParallelFixedDrills( void)
{
// se aggregato da sotto, sicuramente con una sola punta
bool bAggrBottom = IsAggrBottom( m_TParams.m_sHead) ;
if ( bAggrBottom)
return false ;
// se una sola uscita, inutile continuare
int nExitCnt = m_pMchMgr->GetCurrMachine()->GetHeadExitCount( m_TParams.m_sHead) ;
if ( nExitCnt == 1)
return false ;
// verifico che le uscite siano fisse
int nSelectType = m_pMchMgr->GetCurrMachine()->GetHeadSelectType( m_TParams.m_sHead) ;
if ( nSelectType != MCH_SLT_FIXEDEXITS)
return false ;
// recupero la direzione dell'utensile principale
Point3d ptMainExit ; Vector3d vtMainTool, vtMainAux ;
m_pMchMgr->GetCurrMachine()->GetHeadExitPosDirAux( m_TParams.m_sHead, m_TParams.m_nExit, ptMainExit, vtMainTool, vtMainAux) ;
// verifico ci sia almeno un'altra uscita attrezzata parallela a quella principale
for ( int nT = 0 ; nT < nExitCnt ; ++ nT) {
if ( nT + 1 == m_TParams.m_nExit)
continue ;
string sToolName ;
if ( m_pMchMgr->GetLoadedTool( m_TParams.m_sHead, nT + 1, sToolName) && ! sToolName.empty()) {
Point3d ptExit ; Vector3d vtTool, vtAux ;
if ( m_pMchMgr->GetCurrMachine()->GetHeadExitPosDirAux(m_TParams.m_sHead, nT + 1, ptExit, vtTool, vtAux) &&
AreSameVectorApprox( vtTool, vtMainTool))
return true ;
}
}
// non è stato trovato niente
return false ;
}
//----------------------------------------------------------------------------
bool
Drilling::StandardProcess( bool bRecalc, int nPvId, int nClId)
{
// controllo se ho più uscite
string sCurrHead ;
if ( ! m_pMchMgr->GetCurrMachine()->GetCurrHead( sCurrHead))
return false ;
int nExit = m_pMchMgr->GetCurrMachine()->GetHeadExitCount( sCurrHead) ;
TABMHDRILL tabDrills ;
double dMHOff = 0 ;
// se ho più uscite...
if ( nExit > 1) {
if ( ! MultiHeadDrilling( nExit, m_vId, nClId, tabDrills, dMHOff))
// se ho almeno un'altra punta fissa parallela alla principale ...
if ( VerifyMultiParallelFixedDrills()) {
TABMHDRILL tabDrills ;
double dMHOff = 0 ;
if ( ! MultiHeadDrilling( m_vId, nClId, tabDrills, dMHOff))
return false ;
if( tabDrills.size() == 0)
if ( tabDrills.empty())
return true ;
int j = 0 ;
for ( int i = 0 ; i < ( int)tabDrills.size() ; ++i) {
// se richiesto preview
if ( nPvId != GDB_ID_NULL) {
if ( ! GenerateHolePv( j, m_vId[tabDrills[i][0].nInd_id_hole], MCH_PATH, nClId))
if ( ! GenerateHolePv( i, m_vId[tabDrills[i][0].nInd_id_hole], MCH_PATH, nClId))
return false ;
// creo la regione di ingombro del foro
int nDriId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetLastGroupInGroup( nPvId)) ;
@@ -717,17 +776,15 @@ Drilling::StandardProcess( bool bRecalc, int nPvId, int nClId)
}
// se richiesta lavorazione
if ( nClId != GDB_ID_NULL) {
if ( ! GenerateHoleCl( j, m_vId[tabDrills[i][0].nInd_id_hole], MCH_PATH, nClId, dMHOff, tabDrills[i][0].vtAux))
if ( ! GenerateHoleCl( i, m_vId[tabDrills[i][0].nInd_id_hole], MCH_PATH, nClId, dMHOff, tabDrills[i][0].vtAux))
return false ;
}
// incremento indice
++j ;
}
return true ;
}
// ... altrimenti elaboro i singoli fori
int i = 0 ;
for ( const auto& vId : m_vId) {
for ( int i = 0 ; i < int( m_vId.size()) ; ++ i) {
const auto& vId = m_vId[i] ;
// se richiesto preview
if ( nPvId != GDB_ID_NULL) {
if ( ! GenerateHolePv( i, vId, MCH_PATH, nPvId))
@@ -741,8 +798,6 @@ Drilling::StandardProcess( bool bRecalc, int nPvId, int nClId)
if ( ! GenerateHoleCl( i, vId, MCH_PATH, nClId))
return false ;
}
// incremento indice
++i ;
}
return true ;
@@ -750,83 +805,85 @@ Drilling::StandardProcess( bool bRecalc, int nPvId, int nClId)
//----------------------------------------------------------------------------
bool
Drilling::MultiHeadDrilling( int nExit, const SELVECTOR& vId, int nClId, TABMHDRILL& tabDrills, double& dMHOff, bool bOrd) {
Drilling::MultiHeadDrilling( const SELVECTOR& vId, int nClId, TABMHDRILL& tabDrills, double& dMHOff, bool bOrd)
{
// controllo parametri
tabDrills.clear() ;
if (( int)vId.size() == 0)
if ( vId.empty())
return true ;
// recupero il nome della testa
string sHead ;
m_pMchMgr->GetCurrMachine()->GetCurrHead( sHead) ;
// gestore dei tool corrente
// gestore degli utensili
ToolsMgr* pTMgr = m_pMchMgr->GetCurrToolsMgr() ;
// ------------------------------ Tools ------------------------------------------
// ciclo tutti i tools salvando le loro geometrie
typedef vector<ToolInfo> VECTORTOOL ;
VECTORTOOL vTools ; vTools.reserve( nExit) ;
int nNullTools = 0 ; // numero di utensili non attivi
int nIndMainTool = 0 ; // Main Tool ( non nullo )
bool bToolValid = false ; // se il Tool attuale è valido ( non nullo )
for ( int t = 0 ; t < nExit ; ++t) { // recupero l'utensile sulle uscite
string sToolName ;
ToolInfo TInf ;
if( ! m_pMchMgr->GetLoadedTool( sHead, t + 1, sToolName) || sToolName.empty()) {
TInf.pTool = nullptr ; // se non attivo ( nullo )
vTools.push_back( TInf) ;
++nNullTools ;
continue ;
}
// se attivo ( non nullo )
TInf.pTool = (( ToolData*)pTMgr->GetTool( sToolName)) ;
vTools.push_back( TInf) ;
// imposto il tool di riferimento come il tool m_TParams
if( TInf.pTool->m_Uuid == m_TParams.m_Uuid)
nIndMainTool = t ;
}
if ( nNullTools == nExit || vTools.size() == 0) // se non ho utensili attivi o validi...
if ( pTMgr == nullptr)
return false ;
Point3d PtEndTool ; // punto finale del tool
Vector3d vtDirPrec, vtDirAct, vtAux ; // per controllare direzioni dei tool ( T )
Vector3d vtT, vtA ; // versore T e A per sistema di riferimento del tool
// recupero il nome della testa e il numero di uscite
string sHead ;
m_pMchMgr->GetCurrMachine()->GetCurrHead( sHead) ;
int nExitCnt = m_pMchMgr->GetCurrMachine()->GetHeadExitCount( sHead) ;
bToolValid = false ;
for ( int t = 0 ; t < nExit ; ++t) { // controllo direzioni ( T ) e punto finale all'estremità
if ( vTools[t].pTool == nullptr)
// Recupero i dati degli utensili montati sulla testa
int nMainToolInd = -1 ;
VECTORTOOL vTools ; vTools.reserve( nExitCnt) ;
// ricavo gli utensili presenti sulle uscite
for ( int nT = 0 ; nT < nExitCnt ; ++ nT) {
string sToolName ;
if ( ! m_pMchMgr->GetLoadedTool( sHead, nT + 1, sToolName) || sToolName.empty()) {
// non c'è utensile
vTools.emplace_back( nullptr) ;
continue ;
m_pMchMgr->GetCurrMachine()->GetHeadExitPosDirAux( sHead, t + 1, PtEndTool, vtDirAct, vtAux) ;
if ( ! bToolValid) {
bToolValid = true ;
vtDirPrec = vtDirAct ;
}
else {
// controllo che le direzioni dei tool siano tutte parallele tra loro
if ( ! AreSameVectorApprox( vtDirAct, vtDirPrec))
return false ;
}
if ( t == nIndMainTool) { // per il sistema di riferiemento centrato sul tool principale
vtT = vtDirAct ;
vtA = vtAux ;
}
PtEndTool.Translate( - vtDirAct * ( vTools[t].pTool->m_dLen)) ;
vTools[t].ptETool = PtEndTool ;
// se presente e valido
const ToolData* pTdata = pTMgr->GetTool( sToolName) ;
vTools.emplace_back( pTdata) ;
// imposto il tool di riferimento come il tool m_TParams
if ( pTdata->m_Uuid == m_TParams.m_Uuid)
nMainToolInd = nT ;
}
// se non ho utensili attivi o validi, errore
if ( nMainToolInd == -1 || vTools.empty()) {
m_pMchMgr->SetLastError( 2116, "Error in Drilling : multi drilling head without valid tools") ;
return false ;
}
// ------------------------------ Holes ------------------------------------------
// ciclo tutti i fori salvando le loro geometrie
typedef vector<HoleInfo> VECTORHOLE ;
VECTORHOLE vHoles(( int)vId.size()) ; // vettore dei fori
bool bOKHole = false ; // validità di almeno un foro
// recupero i dati dell'uscita dell'utensile principale
Vector3d vtTool, vtAux ;
Point3d ptExit ;
m_pMchMgr->GetCurrMachine()->GetHeadExitPosDirAux( sHead, nMainToolInd + 1, ptExit, vtTool, vtAux) ;
vTools[nMainToolInd].ptToolTip = ptExit - vtTool * vTools[nMainToolInd].pTool->m_dLen ;
if ( vtAux.IsSmall() && m_pMchMgr->GetCurrMachine()->GetCurrRotAxes() == 0)
vtAux = FromUprightOrtho( vtTool) ;
if ( vtTool.IsSmall() || vtAux.IsSmall()) {
m_pMchMgr->SetLastError( 2117, "Error in Drilling : incorrect multi drilling head") ;
return false ;
}
for ( int h = 0 ; h < ( int)vId.size() ; ++h) {
// carico gli altri dati della testa con le sue uscite
for ( int nT = 0 ; nT < nExitCnt ; ++ nT) {
// se utensile principale, salto al successivo
if ( nT == nMainToolInd)
continue ;
// se non attrezzato, salto al successivo
if ( vTools[nT].pTool == nullptr)
continue ;
// recupero i dati dell'uscita
Point3d ptExit ;
Vector3d vtCurrDir, vtCurrAux ;
m_pMchMgr->GetCurrMachine()->GetHeadExitPosDirAux( sHead, nT + 1, ptExit, vtCurrDir, vtCurrAux) ;
// controllo abbia la stessa direzione del principale, altrimenti disattrezzo
if ( ! AreSameVectorApprox( vtCurrDir, vtTool)) {
vTools[nT].pTool = nullptr ;
continue ;
}
// assegno tip utensile
vTools[nT].ptToolTip = ptExit - vtCurrDir * vTools[nT].pTool->m_dLen ;
}
// Recupero le geometrie dei fori
bool bSomeHoleOk = false ;
VECTORHOLE vHoles( vId.size()) ;
for ( int h = 0 ; h < ( int)vId.size() ; ++ h) {
Hole hole ;
if ( ! GetHoleData( m_vId[h], hole)) {
string sInfo = "Warning in Drilling : Skipped entity " + ToString( m_vId[h]) ;
@@ -850,45 +907,54 @@ Drilling::MultiHeadDrilling( int nExit, const SELVECTOR& vId, int nClId, TABMHDR
vHoles[h].hole = hole ;
vHoles[h].nIndInSelVector = h ;
bOKHole = true ;
bSomeHoleOk = true ;
}
if ( vHoles.size() == 0 || ! bOKHole) // se non ho fori...
if ( ! bSomeHoleOk)
return true ;
// calcolo la maschera tra tools e holes
if( ! CalcMask( vHoles, vTools, nIndMainTool, vtT, vtA))
// calcolo la corrispondenza tra utensili e fori
if ( ! CalcMask( vHoles, vTools, nMainToolInd, vtTool, vtAux))
return false ;
// i fori con dimensione 0 del vettore vToolHole non possono essere svuotati
// i fori con dimensione 0 del vettore vToolHole non possono essere lavorati
int nNoDrillHoles = 0 ;
for ( int i = 0 ; i < ( int)vHoles.size() ; ++i) {
if ( vHoles[i].vToolHole.size() == 0)
++nNoDrillHoles ;
for ( int i = 0 ; i < ( int)vHoles.size() ; ++ i) {
if ( vHoles[i].vToolHole.empty())
++ nNoDrillHoles ;
}
// resetto le variabili di controllo di svuotatura temporanea per tutti i fori
// resetto le variabili di controllo di lavorazione temporanea per tutti i fori
for ( int k = 0 ; k < ( int)vHoles.size() ; ++k)
vHoles[k].bTempDrill = false ;
// numero di fori svuotati
// numero di fori lavorati
int nOkHole = 0 ;
// se c'è un solo foro va sicuramente bene
if ( vHoles.size() == 1 && ! vHoles[0].vVtAux.empty()) {
vHoles[0].bForToolM = true ;
vHoles[0].nIndTool = nMainToolInd ;
vHoles[0].nIndHoleToolM = 0 ;
vHoles[0].vtAux = vHoles[0].vVtAux[0] ;
}
// decido in quali fori inserire il tool principale
for ( int nCheck = 1 ; nCheck < ( int)vHoles.size() && nOkHole < ( int)vHoles.size() - nNoDrillHoles ; ++nCheck) {
for ( int nCheck = 1 ; nCheck < ( int)vHoles.size() && nOkHole < ( int)vHoles.size() - nNoDrillHoles ; ++ nCheck) {
for ( int i = 0 ; i < ( int)vHoles.size() ; ++i) {
if ( vHoles[i].vToolHole.size() == nCheck && ! vHoles[i].bDrill) { // prendo tutti i fori con vToolHope di lunghezza nCheck non già svuotati
// prendo tutti i fori con vToolHope di lunghezza nCheck non già lavorati
if ( vHoles[i].vToolHole.size() == nCheck && ! vHoles[i].bDrill) {
vHoles[vHoles[i].vToolHole[0]].bForToolM = true ;
vHoles[vHoles[i].vToolHole[0]].nIndTool = nIndMainTool ;
vHoles[vHoles[i].vToolHole[0]].nIndTool = nMainToolInd ;
vHoles[vHoles[i].vToolHole[0]].nIndHoleToolM = vHoles[i].vToolHole[0] ;
vHoles[vHoles[i].vToolHole[0]].vtAux = vHoles[i].vVtAux[0] ;
for ( int k = 0 ; k < ( int)vHoles.size() ; ++k) {
for( int l = 0 ; l < ( int)vHoles[k].vToolHole.size() ; ++l) {
for ( int l = 0 ; l < ( int)vHoles[k].vToolHole.size() ; ++l) {
if ( vHoles[k].vToolHole[l] == vHoles[i].vToolHole[0] && ! vHoles[k].bDrill) {
vHoles[k].bDrill = true ;
vHoles[k].nIndTool = vHoles[k].vIndTools[0] ;
vHoles[k].nIndHoleToolM = vHoles[vHoles[i].vToolHole[0]].nIndHoleToolM ;
vHoles[k].vtAux = vHoles[k].vVtAux[l] ;
++nOkHole ;
++ nOkHole ;
break ;
}
}
@@ -898,42 +964,42 @@ Drilling::MultiHeadDrilling( int nExit, const SELVECTOR& vId, int nClId, TABMHDR
}
// calcolo la massima differenza di lunghezza tra il primo tool e gli altri ( così l'elevazione finale rimane compatibile)
double dRefLen = vTools[nIndMainTool].pTool->m_dTLen ;
double dRefLen = vTools[nMainToolInd].pTool->m_dTLen ;
double dOffMax = 0 ;
for ( int t = 0 ; t < ( int)vTools.size() && nNoDrillHoles != (int)vHoles.size() ; ++t) {
if ( vTools[t].pTool == nullptr || t == nIndMainTool)
for ( int nT = 0 ; nT < ( int)vTools.size() && nNoDrillHoles != (int)vHoles.size() ; ++ nT) {
if ( vTools[nT].pTool == nullptr || nT == nMainToolInd)
continue ;
if ( vTools[t].pTool->m_dTLen > dRefLen + dOffMax) {
dOffMax = vTools[t].pTool->m_dTLen - dRefLen ;
if ( vTools[nT].pTool->m_dTLen > dRefLen + dOffMax) {
dOffMax = vTools[nT].pTool->m_dTLen - dRefLen ;
}
}
dMHOff = dOffMax ;
// riempio la maschera
VCT3DVECTOR vVtA ;
for ( int i = 0 ; i < ( int)vHoles.size() && nNoDrillHoles != ( int)vHoles.size() ; ++i) {
for ( int i = 0 ; i < ( int)vHoles.size() && nNoDrillHoles != ( int)vHoles.size() ; ++ i) {
if ( ! vHoles[i].bForToolM)
continue ;
// per tutti i fori che vengono svuotati da un tool t-esimo conto quanti versori A diversi tra loro trovo
for( int j = 0 ; j < ( int)vHoles.size() ; ++j) {
for ( int j = 0 ; j < ( int)vHoles.size() ; ++j) {
if ( vHoles[j].nIndHoleToolM != i)
continue ;
if (( int)vVtA.size() == 0)
if ( vVtA.empty())
vVtA.push_back( vHoles[j].vtAux) ;
else {
bool bPush = true ;
for( int v = 0 ; v < ( int)vVtA.size() ; ++v )
if( AreSameVectorApprox( vHoles[j].vtAux, vVtA[v])) {
for ( int v = 0 ; v < ( int)vVtA.size() ; ++ v) {
if ( AreSameVectorApprox( vHoles[j].vtAux, vVtA[v])) {
bPush = false ;
break ;
}
if( bPush)
}
if ( bPush)
vVtA.push_back( vHoles[j].vtAux) ;
}
}
for( int v = 0 ; v < ( int)vVtA.size() ; ++v) {
for ( int v = 0 ; v < ( int)vVtA.size() ; ++ v) {
vector<MHDrill> vRowDrill ;
MHDrill FirstMHDrill ;
FirstMHDrill.nInd_id_hole = i ;
@@ -943,19 +1009,18 @@ Drilling::MultiHeadDrilling( int nExit, const SELVECTOR& vId, int nClId, TABMHDR
}
vVtA.clear() ;
}
if ( tabDrills.size() == 0) // se non trovo corrispondenze ...
// se non trovo corrispondenze ...
if ( tabDrills.empty())
return true ;
// se devo riordinare
// se devo riordinare
if ( bOrd) {
struct Order
{
struct Order {
int nInd_id_hole ;
Point3d ptIni ;
} ;
typedef vector<Order> VECTORORDER ;
VECTORORDER vOrder ;
for ( int i = 0 ; i < ( int)tabDrills.size() ; ++i) {
vector<Order> vOrder ;
for ( int i = 0 ; i < ( int)tabDrills.size() ; ++ i) {
Order newOrder ;
newOrder.nInd_id_hole = tabDrills[i][0].nInd_id_hole ;
newOrder.ptIni = vHoles[tabDrills[i][0].nInd_id_hole].hole.ptIni ;
@@ -966,8 +1031,8 @@ Drilling::MultiHeadDrilling( int nExit, const SELVECTOR& vId, int nClId, TABMHDR
Point3d ptRef = vOrder[0].ptIni ;
double dMinDist = INFINITO ;
int nIndexSwitch = -1 ;
for ( int i = 0 ; i < ( int)vOrder.size() - 1 ; ++i) {
for ( int j = i + 1 ; j < ( int)vOrder.size() ; ++j) {
for ( int i = 0 ; i < ( int)vOrder.size() - 1 ; ++ i) {
for ( int j = i + 1 ; j < ( int)vOrder.size() ; ++ j) {
Point3d ptS = vOrder[j].ptIni ;
if ( Dist( ptS, ptRef) < dMinDist) {
dMinDist = Dist( ptS, ptRef) ;
@@ -989,34 +1054,34 @@ Drilling::MultiHeadDrilling( int nExit, const SELVECTOR& vId, int nClId, TABMHDR
//----------------------------------------------------------------------------
bool
Drilling::CalcMask( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndMT, Vector3d vtT, Vector3d vtA) {
// recupero il valore di tolleranza sul diametro
double dDiamTol = m_pMchMgr->GetCurrMachiningsMgr()->GetHoleDiamToler() ;
Drilling::CalcMask( VECTORHOLE& vHoles, const VECTORTOOL& vTools, int nIndMT, const Vector3d& vtTool, const Vector3d& vtAux)
{
// controllo dei parametri
if (( int)vHoles.size() <= 0 || ( int)vTools.size() <= 0)
if ( vHoles.empty() || vTools.empty())
return false ;
int nExit = ( int)vTools.size() ;
// recupero il valore di tolleranza sul diametro
double dDiamToler = m_pMchMgr->GetCurrMachiningsMgr()->GetHoleDiamToler() ;
int nExitCnt = ( int)vTools.size() ;
int nNullTools = 0 ;
for( int i = 0 ; i < ( int)vTools.size() ; ++i){
if( vTools[i].pTool == nullptr)
++nNullTools ;
for ( int i = 0 ; i < ( int)vTools.size() ; ++ i) {
if ( vTools[i].pTool == nullptr)
++ nNullTools ;
}
// in ogni foro i-esimo inserisco il Tool principale
for( int i = 0 ; i < ( int)vHoles.size() ; ++i){
for ( int i = 0 ; i < ( int)vHoles.size() ; ++ i) {
// resetto le veriabili di controllo di svuotatura temporanea per tutti i fori
for ( int k = 0 ; k < ( int)vHoles.size() ; ++k) {
for ( int k = 0 ; k < ( int)vHoles.size() ; ++ k) {
vHoles[k].bTempDrill = false ;
vHoles[k].nTempTool = -1 ;
}
// verifica validità del foro i-esimo per il Tool principale
Hole Hole_i = vHoles[i].hole ;
if ( ! MultiHeadVerifyHole( Hole_i, vTools[nIndMT].pTool, dDiamTol, m_vId[vHoles[i].nIndInSelVector]))
if ( ! MultiHeadVerifyHole( Hole_i, vTools[nIndMT].pTool, dDiamToler, m_vId[vHoles[i].nIndInSelVector]))
continue ;
int nStat ;
@@ -1032,17 +1097,19 @@ Drilling::CalcMask( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndMT, Vector3d
// nuova configurazione del versore A ottenuta
if ( ! m_pMchMgr->GetCalcAuxDirFromAngles( vAng1, vtAnew))
continue ;
if ( vtAnew.IsSmall() && m_pMchMgr->GetCurrMachine()->GetCurrRotAxes() == 0)
vtAnew = vtAux ;
// creo un nuovo sistema di riferimento centrato nel Tool principale
Frame3d frMT ;
frMT.Set( vTools[nIndMT].ptETool, vtT, vtA) ;
if( ! frMT.IsValid())
frMT.Set( vTools[nIndMT].ptToolTip, vtTool, vtAux) ;
if ( ! frMT.IsValid())
return false ;
// creo un frame nel foro i-esimo orientato come il frame sul tool principale ( origine nella base interna del foro)
Frame3d frHMT ;
frHMT.Set( Hole_i.ptIni - Hole_i.vtDir * Hole_i.dLen, vtTnew, vtAnew) ;
if( ! frHMT.IsValid())
if ( ! frHMT.IsValid())
return false ;
// numero di svuotature inserendo il Tool principale nel foro i-esimo
@@ -1052,11 +1119,11 @@ Drilling::CalcMask( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndMT, Vector3d
vHoles[i].nTempTool = nIndMT ;
// controllo la compatibilità tra le geometrie dei Tool e dei fori
CheckOtherHolesWithTools( vHoles, vTools, nIndMT, i, Hole_i, frMT, frHMT, dDiamTol, nDrills) ;
CheckOtherHolesWithTools( vHoles, vTools, nIndMT, i, Hole_i, frMT, frHMT, dDiamToler, nDrills) ;
// controllo quanti fori sono riuscito a svuotare e setto i loro parametri di foratura
if ( nDrills == nExit - nNullTools) { // se ho svuotato il numero corretto di fori ...
for ( int d = 0 ; d < ( int)vHoles.size() ; ++d) {
if ( nDrills == nExitCnt - nNullTools) { // se ho svuotato il numero corretto di fori ...
for ( int d = 0 ; d < ( int)vHoles.size() ; ++ d) {
if ( vHoles[d].bTempDrill) {
vHoles[d].vToolHole.push_back( i) ; // indice del foro per il tool principale
vHoles[d].vIndTools.push_back( vHoles[d].nTempTool) ; // indice del tool che svuota questo foro
@@ -1065,44 +1132,47 @@ Drilling::CalcMask( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndMT, Vector3d
}
}
else {
for( int d = 0 ; d < ( int)vHoles.size() ; ++d)
if( vHoles[d].bTempDrill)
for ( int d = 0 ; d < ( int)vHoles.size() ; ++ d)
if ( vHoles[d].bTempDrill)
vHoles[d].bTempDrill = false ;
}
if ( nStat < 0) { // se la testa può ruotare
// se la testa può ruotare
if ( nStat < 0) {
// inizio a scorrere tutti i tools
for ( int t = 0 ; t < ( int)vTools.size() ; ++t) {
for ( int t = 0 ; t < ( int)vTools.size() ; ++ t) {
if ( vTools[t].pTool == nullptr || t == nIndMT)
continue ;
// cerco se ho un foro j-esimo adatto per quella punta
for ( int j = 0 ; j < ( int)vHoles.size() ; ++j) {
for ( int j = 0 ; j < ( int)vHoles.size() ; ++ j) {
Hole Hole_j = vHoles[j].hole ;
if ( i == j
|| vHoles[j].bSkipToAngle
|| ! AreSameVectorApprox( Hole_j.vtDir, Hole_i.vtDir)
|| ! MultiHeadVerifyHole( Hole_j, vTools[t].pTool, dDiamTol, m_vId[vHoles[j].nIndInSelVector]))
if ( i == j ||
vHoles[j].bSkipToAngle ||
! AreSameVectorApprox( Hole_j.vtDir, Hole_i.vtDir) ||
! MultiHeadVerifyHole( Hole_j, vTools[t].pTool, dDiamToler, m_vId[vHoles[j].nIndInSelVector]))
continue ;
// resetto le veriabili di controllo di svuotatura temporanea per tutti i fori
for ( int k = 0 ; k < ( int)vHoles.size() ; ++k) {
for ( int k = 0 ; k < ( int)vHoles.size() ; ++ k) {
vHoles[k].bTempDrill = false ;
vHoles[k].nTempTool = -1 ;
}
Vector3d vtRefT = vTools[t].ptETool - vTools[nIndMT].ptETool ;
Vector3d vtRefT = vTools[t].ptToolTip - vTools[nIndMT].ptToolTip ;
Vector3d vtRefH = Hole_j.ptIni - Hole_j.vtDir * Hole_j.dLen -
( Hole_i.ptIni - Hole_i.vtDir * Hole_i.dLen) ;
if(( vtRefH.Len() - vtRefT.Len()) < EPS_SMALL) { // se le distanze sono compatibili
// se le distanze sono compatibili
if ( abs( vtRefH.Len() - vtRefT.Len()) < EPS_SMALL) {
// rioriento il frame sul foro i-esimo
Point3d ptHj = Hole_j.ptIni - Hole_j.vtDir * Hole_j.dLen ;
ptHj.ToLoc( frHMT) ;
Vector3d vtProjB( ptHj.x, ptHj.y, 0) ;
Point3d ptTt = vTools[t].ptETool ;
Point3d ptTt = vTools[t].ptToolTip ;
ptTt.ToLoc( frMT) ;
Vector3d vtProjA( ptTt.x, ptTt.y, 0) ;
@@ -1110,15 +1180,15 @@ Drilling::CalcMask( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndMT, Vector3d
frHMT.Rotate( frHMT.Orig(), frHMT.VersZ(), dAngle) ;
nDrills = 1 ; // foratura nel foro i-esimo e j-esimo
CheckOtherHolesWithTools( vHoles, vTools, nIndMT, i, Hole_i, frMT, frHMT, dDiamTol, nDrills) ;
CheckOtherHolesWithTools( vHoles, vTools, nIndMT, i, Hole_i, frMT, frHMT, dDiamToler, nDrills) ;
// setto le variabili temporanee per il foro i-esimo
vHoles[i].bTempDrill = true ;
vHoles[i].nTempTool = nIndMT ;
// controllo quanti fori sono riuscito a svuotare in questo nuovo sistema di riferimento
if ( nDrills == nExit - nNullTools) {
for ( int d = 0 ; d < ( int)vHoles.size() ; ++d) {
if ( nDrills == nExitCnt - nNullTools) {
for ( int d = 0 ; d < ( int)vHoles.size() ; ++ d) {
if ( vHoles[d].bTempDrill) {
vHoles[d].vToolHole.push_back( i) ; // indice del foro per il tool principale
vHoles[d].vIndTools.push_back( vHoles[d].nTempTool) ; // indice del tool che svuota questo foro
@@ -1128,8 +1198,8 @@ Drilling::CalcMask( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndMT, Vector3d
}
}
else {
for( int d = 0 ; d < ( int)vHoles.size() ; ++d)
if( vHoles[d].bTempDrill)
for ( int d = 0 ; d < ( int)vHoles.size() ; ++ d)
if ( vHoles[d].bTempDrill)
vHoles[d].bTempDrill = false ;
}
@@ -1145,38 +1215,38 @@ Drilling::CalcMask( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndMT, Vector3d
//----------------------------------------------------------------------------
bool
Drilling::CheckOtherHolesWithTools( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndTM, int nIndHTM, Hole holeICP, Frame3d frMT,
Frame3d frHMT, double dDiamTol, int& nDrills) {
Drilling::CheckOtherHolesWithTools( VECTORHOLE& vHoles, const VECTORTOOL& vTools, int nIndTM, int nIndHTM, Hole holeICP,
const Frame3d& frMT, const Frame3d& frHMT, double dDiamToler, int& nDrills)
{
// controllo parametri
if(( int)vHoles.size() < 1 || vTools.size() < 1)
if ( vHoles.empty() || vTools.empty())
return true ;
if( nIndTM >= ( int)vTools.size() || nIndTM < 0
|| nIndHTM >= ( int)vHoles.size() || nIndHTM < 0
|| ! frMT.IsValid() || ! frHMT.IsValid()
|| nDrills < 0 || nDrills > max(( int)vHoles.size(), ( int)vTools.size()))
if ( nIndTM < 0 || nIndTM >= ( int)vTools.size() ||
nIndHTM < 0 || nIndHTM >= ( int)vHoles.size() ||
! frMT.IsValid() || ! frHMT.IsValid() ||
nDrills < 0 || nDrills > max( ( int)vHoles.size(), ( int)vTools.size()))
return false ;
// definisco il punto dove cade il tool principale
Hole holeTM = holeICP ; // copia del foro i-esimo
// ciclo su tutti i tools
for ( int t = 0 ; t < ( int)vTools.size() ; ++t) {
for ( int t = 0 ; t < ( int)vTools.size() ; ++ t) {
if ( vTools[t].pTool == nullptr || t == nIndTM)
continue ;
// esprimo il punto finale del tool t-esimo nel sistema di riferimento del Tool principale
Point3d ptETt = vTools[t].ptETool ;
Point3d ptETt = vTools[t].ptToolTip ;
ptETt.ToLoc( frMT) ;
// cerco se ho un foro j-esimo adatto per quella punta
for ( int j = 0 ; j < ( int)vHoles.size() ; ++j) {
for ( int j = 0 ; j < ( int)vHoles.size() ; ++ j) {
Hole Hole_j = vHoles[j].hole ; // copia del foro j-esimo
// controllo che il foro j-esimo non sia l'i-esimo, che non sia stato già precedentemente svuotato da un altro tool t'-esimo ...
// ... che vtDir del foro i-esimo coincida con vtDir del foro j-esimo e che il tool t-esimo sia compatibile con il foro j-esimo
if ( nIndHTM == j
|| vHoles[j].bTempDrill
|| ! AreSameVectorApprox( Hole_j.vtDir, holeTM.vtDir)
|| ! MultiHeadVerifyHole( Hole_j, vTools[t].pTool, dDiamTol, m_vId[vHoles[j].nIndInSelVector]))
if ( nIndHTM == j ||
vHoles[j].bTempDrill ||
! AreSameVectorApprox( Hole_j.vtDir, holeTM.vtDir) ||
! MultiHeadVerifyHole( Hole_j, vTools[t].pTool, dDiamToler, m_vId[vHoles[j].nIndInSelVector]))
continue ;
// esprimo il foro j-esimo nel sistema di riferimento del Tool principale centrato nel foro i-esimo
@@ -1185,11 +1255,13 @@ Drilling::CheckOtherHolesWithTools( VECTORHOLE& vHoles, VECTORTOOL& vTools, int
// controllo la compatibilità
if ( AreSamePointApprox( ptHj, ptETt)) {
++nDrills ; // un foro in più svuotato
// un foro in più lavorato
++ nDrills ;
// aggiorno le variabili temporanee
vHoles[j].bTempDrill = true ;
vHoles[j].nTempTool = t ;
break ; // non controllo gli altri vertici per la punta t-esima
// non controllo gli altri vertici per la punta t-esima
break ;
}
}
}
@@ -1199,10 +1271,10 @@ Drilling::CheckOtherHolesWithTools( VECTORHOLE& vHoles, VECTORTOOL& vTools, int
//----------------------------------------------------------------------------
bool
Drilling::MultiHeadVerifyHole( Hole& hole, const ToolData* Tool, double dDiamTol, SelData Id) {
Drilling::MultiHeadVerifyHole( Hole& hole, const ToolData* Tool, double dDiamToler, SelData Id)
{
// verifico che il diamtro del tool sia compatibile con quello del foro
if ( ! VerifyDiameter( hole.dDiam, Tool->m_dDiam, dDiamTol))
if ( ! VerifyDiameter( hole.dDiam, Tool->m_dDiam, dDiamToler))
return false ;
// imposto elevazione da lunghezza foro con possibilità di sovrascrittura da info
double dElev = hole.dLen ;
@@ -1214,7 +1286,7 @@ Drilling::MultiHeadVerifyHole( Hole& hole, const ToolData* Tool, double dDiamTol
}
// limito lunghezza foro a massima lavorazione della punta
double dAddLen = ( hole.bBlind ? 0 : m_Params.m_dThroughAddLen) ;
if (( dElev + dAddLen) > Tool->m_dMaxMat + EPS_SMALL) {
if ( ( dElev + dAddLen) > Tool->m_dMaxMat + EPS_SMALL) {
hole.dLen = Tool->m_dMaxMat + max( hole.dLen - dElev, 0.) ;
hole.bBlind = true ;
}
@@ -2038,6 +2110,8 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double
GetElevation( m_nPhase, hole.ptIni, hole.vtDir, m_TParams.m_dDiam / 2, hole.vtDir, dElev) ;
// determino alcune caratteristiche dell'utensile
double dTExtrLen = max( 0.0, m_TParams.m_dTLen - m_TParams.m_dLen) ;
// necessità di spezzatura per robot
bool bSplitArcs = GetSplitArcs( V_NULL) ;
// imposto dati comuni
SetPathId( nPathId) ;
SetToolDir( hole.vtDir) ;
@@ -2059,7 +2133,7 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double
return false ;
SetAuxDir( m_vtAggrBottom) ;
SetFlag( 0) ;
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
if ( AddRapidMove( ptP0, bSplitArcs, MCH_CL_AGB_IN) == GDB_ID_NULL)
return false ;
}
// altrimenti rinvio normale
@@ -2069,7 +2143,7 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double
return false ;
SetFlag( 0) ;
}
if ( AddRapidMove( ptP1) == GDB_ID_NULL)
if ( AddRapidMove( ptP1, bSplitArcs) == GDB_ID_NULL)
return false ;
}
else {
@@ -2082,7 +2156,7 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double
// 2 -> punto fuori (se diverso dal precedente)
if ( m_Params.m_dStartPos < dAppr) {
Point3d ptP2 = hole.ptIni + hole.vtDir * ( m_Params.m_dStartPos + dTExtrLen) ;
if ( AddRapidMove( ptP2) == GDB_ID_NULL)
if ( AddRapidMove( ptP2, bSplitArcs) == GDB_ID_NULL)
return false ;
}
// 3 -> punto termine velocità ridotta iniziale (se previsto)
@@ -2093,7 +2167,7 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double
Point3d ptP3 = hole.ptIni - hole.vtDir * dStartSlowLen ;
if ( ! bStd && ! bEndSlow)
ptP3 -= hole.vtDir * dAddLen ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
if ( AddLinearMove( ptP3, bSplitArcs) == GDB_ID_NULL)
return false ;
}
// 4 -> punto termine velocità standard (se risulta)
@@ -2104,7 +2178,7 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double
Point3d ptP4 = hole.ptIni - hole.vtDir * ( hole.dLen - dEndSlowLen) ;
if ( ! bEndSlow)
ptP4 -= hole.vtDir * dAddLen ;
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
if ( AddLinearMove( ptP4, bSplitArcs) == GDB_ID_NULL)
return false ;
}
// 5 -> punto termine velocità finale ridotta (se previsto)
@@ -2112,27 +2186,27 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double
SetFeed( GetTipFeed()) ;
SetFlag( 101) ; // fondo del foro
Point3d ptP5 = hole.ptIni - hole.vtDir * ( hole.dLen + dAddLen) ;
if ( AddLinearMove( ptP5) == GDB_ID_NULL)
if ( AddLinearMove( ptP5, bSplitArcs) == GDB_ID_NULL)
return false ;
}
// 6 -> ritorno all'approccio del foro
SetFeed( GetEndFeed()) ;
SetFlag( 104) ; // risalita sopra il foro
if ( AddLinearMove( ptP1) == GDB_ID_NULL)
if ( AddLinearMove( ptP1, bSplitArcs) == GDB_ID_NULL)
return false ;
// 7 -> punto fuori (se uso aggregato da sotto)
if ( m_bAggrBottom) {
SetFlag( 0) ;
Point3d ptP0 = ptP1 + m_vtAggrBottom * ( m_dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
if ( AddRapidMove( ptP0, MCH_CL_AGB_OUT) == GDB_ID_NULL)
if ( AddRapidMove( ptP0, bSplitArcs, MCH_CL_AGB_OUT) == GDB_ID_NULL)
return false ;
// se rinvio da sotto che richiede speciale rotazione
if ( m_AggrBottom.nType == 1) {
Vector3d vtAux = m_vtAggrBottom ;
vtAux.Rotate( Z_AX, 0, 1) ;
SetAuxDir( vtAux) ;
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
if ( AddRapidMove( ptP00, bSplitArcs, MCH_CL_AGB_UP) == GDB_ID_NULL)
return false ;
}
}
@@ -2169,6 +2243,8 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
GetElevation( m_nPhase, hole.ptIni, hole.vtDir, m_TParams.m_dDiam / 2, hole.vtDir, dElev) ;
// determino alcune caratteristiche dell'utensile
double dTExtrLen = max( 0.0, m_TParams.m_dTLen - m_TParams.m_dLen) ;
// necessità di spezzatura per robot
bool bSplitArcs = GetSplitArcs( V_NULL) ;
// imposto dati comuni
SetPathId( nPathId) ;
SetToolDir( hole.vtDir) ;
@@ -2190,7 +2266,7 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
return false ;
SetFlag( 0) ;
SetAuxDir( m_vtAggrBottom) ;
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
if ( AddRapidMove( ptP0, bSplitArcs, MCH_CL_AGB_IN) == GDB_ID_NULL)
return false ;
}
// altrimenti rinvio normale
@@ -2200,7 +2276,7 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
return false ;
SetFlag( 0) ;
}
if ( AddRapidMove( ptP1) == GDB_ID_NULL)
if ( AddRapidMove( ptP1, bSplitArcs) == GDB_ID_NULL)
return false ;
}
else {
@@ -2211,7 +2287,7 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
// 2 -> punto fuori (se diverso dal precedente)
if ( m_Params.m_dStartPos < dAppr) {
Point3d ptP2 = hole.ptIni + hole.vtDir * ( m_Params.m_dStartPos + dTExtrLen) ;
if ( AddRapidMove( ptP2) == GDB_ID_NULL)
if ( AddRapidMove( ptP2, bSplitArcs) == GDB_ID_NULL)
return false ;
}
// ciclo di affondamento a step
@@ -2231,13 +2307,13 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
SetFeed( GetEndFeed()) ;
SetFlag( 103) ; // punto di scarico truciolo
Point3d ptPr = hole.ptIni + hole.vtDir * dReturnPos ;
if ( AddLinearMove( ptPr) == GDB_ID_NULL)
if ( AddLinearMove( ptPr, bSplitArcs) == GDB_ID_NULL)
return false ;
// riaffondo
SetFeed( GetEndFeed()) ;
SetFlag( 0) ;
Point3d ptPa = hole.ptIni - hole.vtDir * ( dCurrLen - APPR_STEP) ;
if ( AddLinearMove( ptPa) == GDB_ID_NULL)
if ( AddLinearMove( ptPa, bSplitArcs) == GDB_ID_NULL)
return false ;
}
// lunghezza di fine step
@@ -2260,7 +2336,7 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
Point3d ptP3 = hole.ptIni - hole.vtDir * dLen ;
if ( bHoleEnd)
ptP3 -= hole.vtDir * dAddLen ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
if ( AddLinearMove( ptP3, bSplitArcs) == GDB_ID_NULL)
return false ;
// aggiorno posizione e verifico se step completato
dCurrLen = dLen ;
@@ -2285,7 +2361,7 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
Point3d ptP4 = hole.ptIni - hole.vtDir * dLen ;
if ( bHoleEnd)
ptP4 -= hole.vtDir * dAddLen ;
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
if ( AddLinearMove( ptP4, bSplitArcs) == GDB_ID_NULL)
return false ;
// aggiorno posizione e verifico se step completato
dCurrLen = dLen ;
@@ -2309,7 +2385,7 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
Point3d ptP5 = hole.ptIni - hole.vtDir * dLen ;
if ( bHoleEnd)
ptP5 -= hole.vtDir * dAddLen ;
if ( AddLinearMove( ptP5) == GDB_ID_NULL)
if ( AddLinearMove( ptP5, bSplitArcs) == GDB_ID_NULL)
return false ;
// aggiorno posizione
dCurrLen = dLen ;
@@ -2319,7 +2395,7 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
// 6 -> ritorno all'approccio del foro
SetFeed( GetEndFeed()) ;
SetFlag( 104) ; // risalita sopra il foro
if ( AddLinearMove( ptP1) == GDB_ID_NULL)
if ( AddLinearMove( ptP1, bSplitArcs) == GDB_ID_NULL)
return false ;
// 7 -> punto fuori (se uso aggregato da sotto)
@@ -2327,14 +2403,14 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
SetFlag( 0) ;
Point3d ptP0 = ptP1 + m_vtAggrBottom * ( m_dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
if ( AddRapidMove( ptP0, MCH_CL_AGB_OUT) == GDB_ID_NULL)
if ( AddRapidMove( ptP0, bSplitArcs, MCH_CL_AGB_OUT) == GDB_ID_NULL)
return false ;
// se rinvio da sotto che richiede speciale rotazione
if ( m_AggrBottom.nType == 1) {
Vector3d vtAux = m_vtAggrBottom ;
vtAux.Rotate( Z_AX, 0, 1) ;
SetAuxDir( vtAux) ;
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
if ( AddRapidMove( ptP00, bSplitArcs, MCH_CL_AGB_UP) == GDB_ID_NULL)
return false ;
}
}
+6 -5
View File
@@ -86,11 +86,12 @@ class Drilling : public Machining
bool VerifyHoleFromBottom( const Hole& hole, SelData Id) ;
bool DoStandardDrilling( const Hole& hole, SelData Id, int nPathId, double nMHOff, Vector3d vtA) ;
bool DoPeckDrilling( const Hole& hole, SelData Id, int nPathId) ;
bool MultiHeadDrilling( int nExit, const SELVECTOR& vId, int nClId, TABMHDRILL& vDrills, double& dMHOff, bool bOrd = true) ;
bool MultiHeadVerifyHole( Hole& hole, const ToolData* Tool, double dDiamTol, SelData Id) ;
bool CalcMask( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndMT, Vector3d vtT, Vector3d vtA) ;
bool CheckOtherHolesWithTools( VECTORHOLE& vHoles, VECTORTOOL& vTools, int nIndTM, int nIndHTM, Hole holeICP, Frame3d frHTM,
Frame3d frHMTOP, double dDiamTol, int& nDrills) ;
bool MultiHeadDrilling( const SELVECTOR& vId, int nClId, TABMHDRILL& vDrills, double& dMHOff, bool bOrd = true) ;
bool CalcMask( VECTORHOLE& vHoles, const VECTORTOOL& vTools, int nIndMT, const Vector3d& vtTool, const Vector3d& vtAux) ;
bool CheckOtherHolesWithTools( VECTORHOLE& vHoles, const VECTORTOOL& vTools, int nIndTM, int nIndHTM, Hole holeICP,
const Frame3d& frHTM, const Frame3d& frHMTOP, double dDiamToler, int& nDrills) ;
bool MultiHeadVerifyHole( Hole& hole, const ToolData* Tool, double dDiamToler, SelData Id) ;
bool VerifyMultiParallelFixedDrills( void) ;
private :
double GetSpeed() const
+6 -2
View File
@@ -75,6 +75,10 @@ struct DrillingData : public MachiningData
//----------------------------------------------------------------------------
inline const DrillingData* GetDrillingData( const MachiningData* pMdata)
{ return (dynamic_cast<const DrillingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_DRILLING)
return nullptr ;
return ( static_cast<const DrillingData*>( pMdata)) ; }
inline DrillingData* GetDrillingData( MachiningData* pMdata)
{ return (dynamic_cast<DrillingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_DRILLING)
return nullptr ;
return ( static_cast<DrillingData*>( pMdata)) ; }
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -195,7 +195,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>WIN32;_WINDOWS;I_AM_EMK;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<OpenMPSupport>false</OpenMPSupport>
<PrecompiledHeader>Use</PrecompiledHeader>
<CompileAs>CompileAsCpp</CompileAs>
+3
View File
@@ -124,6 +124,9 @@ Exit::Modify( const Point3d& ptPos, double dExitMaxAdjust)
}
// Assegno la nuova posizione
m_ptPos = ptPos ;
// Sistemo la geometria dell'uscita
if ( ! vtDelta.IsZero())
m_pGeomDB->Translate( m_nOwnerId, vtDelta) ;
return true ;
}
+36
View File
@@ -55,6 +55,17 @@ static const string EVAR_STARTPOS = ".STARTPOS" ; // IN (num) quota di inizio l
static const string EVAR_OFFSR = ".OFFSR" ; // IN (num) offset radiale
static const string EVAR_OFFSL = ".OFFSL" ; // IN (num) offset longitudinale
static const string EVAR_TOOL = ".TOOL" ; // IN (string) nome dell'utensile
static const string EVAR_HEAD = ".HEAD" ; // IN (string) nome testa
static const string EVAR_EXIT = ".EXIT" ; // IN (int) indice uscita
static const string EVAR_TTYPE = ".TTYPE" ; // IN (int) tipo utensile
static const string EVAR_TMAXMAT = ".TMAXMAT" ; // IN (num) massimo materiale
static const string EVAR_TDIAM = ".TDIAM" ; // IN (num) diametro utensile
static const string EVAR_TTOTDIAM = ".TTOTDIAM" ; // IN (num) diametro totale utensile
static const string EVAR_TLEN = ".TLEN" ; // IN (num) lunghezza utensile
static const string EVAR_TTOTLEN = ".TTOTLEN" ; // IN (num) lunghezza totale utensile
static const string EVAR_TTHICK = ".THICK" ; // IN (num) spessore per lame o altezza taglienti
static const string EVAR_TCORNRAD = ".TCORNRAD" ; // IN (num) raggio corner
static const string EVAR_TSIDEANG = ".TSIDEANG" ; // IN (num) angolo del fianco rispetto all'asse
static const string EVAR_FEED = ".FEED" ; // IN (num) feed dell'utensile
static const string EVAR_STARTFEED = ".STARTFEED" ;// IN (num) feed di inizio dell'utensile
static const string EVAR_ENDFEED = ".ENDFEED" ; // IN (num) feed di fine dell'utensile
@@ -481,6 +492,17 @@ GenMachining::Preview( bool bRecalc)
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_OFFSR, GetOffsR()) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_OFFSL, GetOffsL()) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TOOL, m_TParams.m_sName) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_HEAD, m_TParams.m_sHead) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_EXIT, m_TParams.m_nExit) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TTYPE, m_TParams.m_nType) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TMAXMAT, m_TParams.m_dMaxMat) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TDIAM, m_TParams.m_dDiam) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TTOTDIAM, m_TParams.m_dTDiam) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TLEN, m_TParams.m_dLen) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TTOTLEN, m_TParams.m_dTLen) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TTHICK, m_TParams.m_dThick) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TCORNRAD, m_TParams.m_dCornRad) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TSIDEANG, m_TParams.m_dSideAng) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_FEED, GetFeed()) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_STARTFEED, GetStartFeed()) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_ENDFEED, GetEndFeed()) ;
@@ -584,6 +606,17 @@ GenMachining::Apply( bool bRecalc, bool bPostApply)
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_OFFSR, GetOffsR()) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_OFFSL, GetOffsL()) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TOOL, m_TParams.m_sName) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_HEAD, m_TParams.m_sHead) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_EXIT, m_TParams.m_nExit) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TTYPE, m_TParams.m_nType) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TMAXMAT, m_TParams.m_dMaxMat) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TDIAM, m_TParams.m_dDiam) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TTOTDIAM, m_TParams.m_dTDiam) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TLEN, m_TParams.m_dLen) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TTOTLEN, m_TParams.m_dTLen) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TTHICK, m_TParams.m_dThick) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TCORNRAD, m_TParams.m_dCornRad) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TSIDEANG, m_TParams.m_dSideAng) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_FEED, GetFeed()) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_STARTFEED, GetStartFeed()) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_ENDFEED, GetEndFeed()) ;
@@ -636,6 +669,9 @@ GenMachining::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
SetBlockedRotAxis( m_Params.m_sBlockedAxis) ;
+6 -2
View File
@@ -67,6 +67,10 @@ struct GenMachiningData : public MachiningData
//----------------------------------------------------------------------------
inline const GenMachiningData* GetGenMachiningData( const MachiningData* pMdata)
{ return (dynamic_cast<const GenMachiningData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_GENMACHINING)
return nullptr ;
return ( static_cast<const GenMachiningData*>( pMdata)) ; }
inline GenMachiningData* GetGenMachiningData( MachiningData* pMdata)
{ return (dynamic_cast<GenMachiningData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_GENMACHINING)
return nullptr ;
return ( static_cast<GenMachiningData*>( pMdata)) ; }
+3 -1
View File
@@ -19,8 +19,10 @@
//----------- Costanti per approssimazioni con polilinee o poliarchi --------
const double LIN_TOL_STD = 0.1 ;
const double LIN_TOL_MID = 0.05 ;
const double ANG_TOL_MAX_DEG = 90 ;
const double LIN_TOL_RAW = 0.5 ;
const double ANG_TOL_STD_DEG = 15 ;
const double ANG_TOL_MID_DEG = 45 ;
const double ANG_TOL_MAX_DEG = 90 ;
const double LIN_FEA_STD = 20 ;
//----------- Costante per offset salva spigoli di lama su cornici curve ----
+8 -2
View File
@@ -52,6 +52,7 @@ Head::Clone( void) const
pHead->m_bMaxDeltaR2On1 = m_bMaxDeltaR2On1 ;
pHead->m_Rot2Stroke = m_Rot2Stroke ;
pHead->m_nSolCh = m_nSolCh ;
pHead->m_vsOtherColl = m_vsOtherColl ;
}
catch( ...) {
delete pHead ;
@@ -73,6 +74,7 @@ Head::Dump( string& sOut, bool bMM, const char* szNewLine) const
sOut += "ExitCount=" + ToString( m_nExitCount) + szNewLine ;
sOut += "HSet=" + ToString( m_vsHSet) + szNewLine ;
sOut += "ADir=" + ToString( m_vtADir) + szNewLine ;
sOut += "OtherColl=" + ToString( m_vsOtherColl) + szNewLine ;
return true ;
}
@@ -103,7 +105,7 @@ Head::GetGeomDB( void) const
//----------------------------------------------------------------------------
Head::Head( void)
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr), m_nType( MCH_HT_NONE), m_nExitCount( 0),
m_dRot1W( 1), m_bMaxDeltaR2On1( true), m_nSolCh( MCH_SCC_NONE)
m_nSelectType( MCH_SLT_FIXEDEXITS), m_dRot1W( 1), m_bMaxDeltaR2On1( true), m_nSolCh( MCH_SCC_NONE)
{
m_Rot2Stroke.Min = - INFINITO ;
m_Rot2Stroke.Max = INFINITO ;
@@ -111,7 +113,7 @@ Head::Head( void)
//----------------------------------------------------------------------------
bool
Head::Set( const string& sName, int nType, int nExitCount, const string& sHSet, const Vector3d& vtADir,
Head::Set( const string& sName, int nType, int nExitCount, const string& sHSet, int nSelectType, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl)
{
m_sName = sName ;
@@ -122,6 +124,10 @@ Head::Set( const string& sName, int nType, int nExitCount, const string& sHSet,
m_nExitCount = 1 ;
m_vsHSet.clear() ;
m_vsHSet.push_back( sHSet) ;
if ( nSelectType == MCH_SLT_FIXEDEXITS || nSelectType == MCH_SLT_ONEEXIT || nSelectType == MCH_SLT_MULTIEXITS)
m_nSelectType = nSelectType ;
else
m_nSelectType = MCH_SLT_FIXEDEXITS ;
m_vtADir = vtADir ;
m_vtADir.Normalize() ;
m_dRot1W = dRot1W ;
+4 -1
View File
@@ -30,7 +30,7 @@ class Head : public IUserObj
public :
Head( void) ;
bool Set( const std::string& sName, int nType, int nExitCount, const std::string& sHSet,
bool Set( const std::string& sName, int nType, int nExitCount, const std::string& sHSet, int nSelectType,
const Vector3d& vtADir, double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh,
const STRVECTOR& vsOthColl) ;
bool AddHeadToHSet( const std::string& sHead) ;
@@ -43,6 +43,8 @@ class Head : public IUserObj
{ return m_nExitCount ; }
const STRVECTOR& GetHSet(void) const
{ return m_vsHSet ; }
int GetSelectType( void) const
{ return m_nSelectType ; }
const Vector3d& GetADir( void) const
{ return m_vtADir ; }
double GetRot1W( void) const
@@ -63,6 +65,7 @@ class Head : public IUserObj
int m_nType ;
int m_nExitCount ;
STRVECTOR m_vsHSet ;
int m_nSelectType ;
Vector3d m_vtADir ;
double m_dRot1W ;
bool m_bMaxDeltaR2On1 ;
+5
View File
@@ -47,6 +47,10 @@ const std::string MACH_RAW_SOLID = "RawSolid" ;
const std::string MACH_RAW_CENTER = "RawCenter" ;
// Nome del contorno esterno del grezzo
const std::string MACH_RAW_OUTLINE = "RawOutline" ;
// Nome della regione superiore del grezzo
const std::string MACH_RAW_UP_REG = "RawUpReg" ;
// Nome della regione inferiore del grezzo
const std::string MACH_RAW_DOWN_REG = "RawDwnReg" ;
// Nome del kerf del grezzo
const std::string MACH_RAW_KERF = "Kerf" ;
@@ -131,6 +135,7 @@ const double LIO_ELEV_TOL = 2.0 ;
//----------------------------------------------------------------------------
// Per FlatParts (vedi Nesting di EgtExecutor)
const std::string NST_EXT_LAYER = "OutLoop" ;
const std::string NST_PARTREG_LAYER = "Region" ;
//----------------------------------------------------------------------------
// Minima componente zeta di versore utensile per lavorazione da sopra (-45deg)
+18 -4
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2022
// EgalTech 2015-2024
//----------------------------------------------------------------------------
// File : MachMgr.h Data : 21.09.22 Versione : 2.4i4
// File : MachMgr.h Data : 02.04.24 Versione : 2.6d1
// Contenuto : Dichiarazione della classe MachMgr.
//
//
@@ -11,6 +11,10 @@
// 17.08.20 DS Aggiunte GetAxisMin e GetAxisMax.
// 17.03.21 DS Aggiunte funzioni per import/export utensili.
// 21.09.22 DS Aggiunta GetAxisOffset.
// 25.08.23 DS Aggiunta CopyMachGroup.
// 28.10.23 DS Aggiunte GetClEntAxesVal e GetToolSetupPosInCurrSetup.
// 30.03.24 DS Aggiunte GetAllAxesNames e GetCalcTable.
// 02.04.24 DS Aggiunta GetClEntAxesMask.
//
//----------------------------------------------------------------------------
@@ -95,7 +99,9 @@ class MachMgr : public IMachMgr
int GetPrevMachGroup( int nId) const override ;
bool GetMachGroupNewName( std::string& sName) const override ;
int AddMachGroup( const std::string& sName, const std::string& sMachineName) override ;
int CopyMachGroup( const std::string& sSouName, const std::string& sName) override ;
bool RemoveMachGroup( int nId) override ;
bool ChangeMachGroupName( int nId, const std::string& sNewName) override ;
std::string GetMachGroupName( int nId) const override ;
std::string GetMachGroupMachineName( int nId) const override ;
int GetMachGroupId( const std::string& sName) const override ;
@@ -203,6 +209,7 @@ class MachMgr : public IMachMgr
bool ImportSetup( const std::string& sName) override ;
bool VerifyCurrSetup( STRVECTOR& vsErrors) override ;
bool FindToolInCurrSetup( const std::string& sTool) override ;
bool GetToolSetupPosInCurrSetup( const std::string& sTool, std::string& sTcPos) override ;
bool GetToolsInCurrSetupPos( const std::string& sTcPos, STRVECTOR& vsTools) override ;
bool UpdateCurrSetup( void) override ;
bool EraseCurrSetup( void) override ;
@@ -301,8 +308,10 @@ class MachMgr : public IMachMgr
bool GetMachiningEndPoint( Point3d& ptEnd) const override ;
// CL Entities Interrogations
bool GetClEntMove( int nEntId, int& nMove) const override ;
bool GetClEntFlag( int nEntId, int& nFlag) const override ;
bool GetClEntFlag( int nEntId, int& nFlag, int& nFlag2) const override ;
bool GetClEntIndex( int nEntId, int& nIndex) const override ;
bool GetClEntAxesMask( int nEntId, int& nMask) const override ;
bool GetClEntAxesVal( int nEntId, DBLVECTOR& vAxes) const override ;
// Simulation
bool SimInit( void) override ;
bool SimStart( bool bFirst) override ;
@@ -321,8 +330,10 @@ class MachMgr : public IMachMgr
// Machine Calc
bool SetCalcTable( const std::string& sTable) override ;
bool SetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) override ;
bool GetAllCurrAxesNames( STRVECTOR& vAxName) const override ;
bool SetRotAxisBlock( const std::string& sAxis, double dVal) override ;
bool GetRotAxisBlocked( int nInd, std::string& sAxis, double& dVal) const override ;
bool GetCalcTable( std::string& sTable) const override ;
bool GetCalcTool( std::string& sTool) const override ;
bool GetCalcHead( std::string& sHead) const override ;
bool GetCalcExit( int& nExit) const override ;
@@ -363,6 +374,7 @@ class MachMgr : public IMachMgr
bool ResetAxisPos( const std::string& sAxis) override ;
bool ResetAllAxesPos( void) override ;
bool GetAllTablesNames( STRVECTOR& vNames) const override ;
bool GetAllAxesNames( STRVECTOR& vNames) const override ;
bool GetAllHeadsNames( STRVECTOR& vNames) const override ;
bool GetAllTcPosNames( STRVECTOR& vNames) const override ;
bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) override ;
@@ -430,10 +442,11 @@ class MachMgr : public IMachMgr
// MachineCalc
int GetCurrLinAxes( void) const ;
int GetCurrRotAxes( void) const ;
bool GetAllCurrAxesName( STRVECTOR& vAxName) const ;
bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ;
bool GetCurrAxisHomePos( int nInd, double& dHome) const ;
const Frame3d& GetCurrLinAxesFrame( void) const ;
bool GetCurrIsCenter( void) const ;
bool GetCurrIsRobot( void) const ;
bool ApplyRotAxisBlock( void) ;
void ClearRotAxisBlock( void)
{ m_vAxisBlock.clear() ; }
@@ -486,6 +499,7 @@ class MachMgr : public IMachMgr
// RawParts
int AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight, Color cCol) ;
int AddRawPart( int nSurfId, Color cCol) ;
int AddRawPart( int nSurfUpId, int nSurfDownId, double dHeight, Color cCol) ;
bool SetRawPartCenter( int nRawId) ;
bool ResetRawPartCenter( int nRawId) ;
// Parts
+42 -4
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2019-2019
// EgalTech 2019-2023
//----------------------------------------------------------------------------
// File : MachMgrClEntities.cpp Data : 15.10.19 Versione : 2.1j4
// File : MachMgrClEntities.cpp Data : 27.10.23 Versione : 2.5j4
// Contenuto : Implementazione interrogazione entità CL della classe MachMgr.
//
//
@@ -39,10 +39,11 @@ MachMgr::GetClEntMove( int nEntId, int& nMove) const
//----------------------------------------------------------------------------
bool
MachMgr::GetClEntFlag( int nEntId, int& nFlag) const
MachMgr::GetClEntFlag( int nEntId, int& nFlag, int& nFlag2) const
{
// default
nFlag = 0 ;
nFlag2 = 0 ;
// verifico validita GeomDB
if ( m_pGeomDB == nullptr)
return false ;
@@ -50,8 +51,9 @@ MachMgr::GetClEntFlag( int nEntId, int& nFlag) const
const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ;
if ( pCamData == nullptr)
return false ;
// recupero il flag
// recupero i flag
nFlag = pCamData->GetFlag() ;
nFlag2 = pCamData->GetFlag2() ;
return true ;
}
@@ -72,3 +74,39 @@ MachMgr::GetClEntIndex( int nEntId, int& nIndex) const
nIndex = pCamData->GetIndex() ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetClEntAxesMask( int nEntId, int& nMask) const
{
// default
nMask = 0 ;
// verifico validita GeomDB
if ( m_pGeomDB == nullptr)
return false ;
// recupero l'oggetto CamData
const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ;
if ( pCamData == nullptr)
return false ;
// recupero il tipo di movimento
nMask = pCamData->GetAxesMask() ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetClEntAxesVal( int nEntId, DBLVECTOR& vAxes) const
{
// default
vAxes.clear() ;
// verifico validita GeomDB
if ( m_pGeomDB == nullptr)
return false ;
// recupero l'oggetto CamData
const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ;
if ( pCamData == nullptr)
return false ;
// recupero i valori degli assi
vAxes = pCamData->GetAxesVal() ;
return true ;
}
+7 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2024
//----------------------------------------------------------------------------
// File : MachMgrDBMachinings.cpp Data : 11.11.15 Versione : 1.6k5
// File : MachMgrDBMachinings.cpp Data : 29.03.24 Versione : 2.6d1
// Contenuto : Implementazione gestione DB lavorazioni della classe MachMgr.
//
//
@@ -304,6 +304,8 @@ MachMgr::MdbSetGeneralParam( int nType, double dVal)
return pMsMgr->SetSafeAggrBottZ( dVal) ;
case MGP_MAXDEPTHSAFE :
return pMsMgr->SetMaxDepthSafe( dVal) ;
case MGP_APPROXLINTOL :
return pMsMgr->SetApproxLinTol( dVal) ;
}
return false ;
}
@@ -379,6 +381,9 @@ MachMgr::MdbGetGeneralParam( int nType, double& dVal) const
case MGP_MAXDEPTHSAFE :
dVal = pMsMgr->GetMaxDepthSafe() ;
return true ;
case MGP_APPROXLINTOL :
dVal = pMsMgr->GetApproxLinTol() ;
return true ;
}
return false ;
}
+14 -1
View File
@@ -721,7 +721,7 @@ MachMgr::UpdateStandardToolDraw( const ToolData* pTdata, int nGenCtx, int nToolC
if ( ! ExeLuaGetGlobIntVar( "TOOL.ERR", &nErr) || nErr != 0)
return nErr ;
// Se per salvataggio
if ( bOk && bToSave) {
if ( bOk && bToSave) {
// Nascondo layer ausiliario
int nAuxId = ExeGetFirstNameInGroup( ExeGetFirstGroupInGroup( GDB_ID_ROOT), "AUX") ;
ExeSetStatus( { nAuxId}, GDB_ST_OFF) ;
@@ -731,6 +731,16 @@ MachMgr::UpdateStandardToolDraw( const ToolData* pTdata, int nGenCtx, int nToolC
ExeRotate( { nPartId}, ORIG, Z_AX, -90, RTY_GLOB) ;
}
}
// altrimenti per visualizzazione
else if ( bOk) {
// Nascondo oggetto/i Carter
int nSolidId = ExeGetFirstNameInGroup( ExeGetFirstGroupInGroup( GDB_ID_ROOT), "SOLID") ;
int nCarterId = ExeGetFirstNameInGroup( nSolidId, "Carter") ;
while ( nCarterId != GDB_ID_NULL) {
ExeSetStatus( { nCarterId}, GDB_ST_OFF) ;
nCarterId = ExeGetNextName( nCarterId, "Carter") ;
}
}
return ( bOk ? 0 : TD_INT_ERR) ;
}
@@ -750,6 +760,8 @@ MachMgr::UpdateCustomToolDraw( const ToolData* pTdata, int nGenCtx, int nToolCtx
pTdata->GetParam( TPA_DIAM, dDiam) ;
double dDist = 0 ;
pTdata->GetParam( TPA_DIST, dDist) ;
double dSpeed = 0 ;
pTdata->GetParam( TPA_SPEED, dSpeed) ;
// Imposto contesto per il disegno utensile
if ( ! ExeSetCurrentContext( nToolCtx))
return TD_INT_ERR ;
@@ -759,6 +771,7 @@ MachMgr::UpdateCustomToolDraw( const ToolData* pTdata, int nGenCtx, int nToolCtx
bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.LEN", dLen) ;
bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.DIAM", dDiam) ;
bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.DIST", dDist) ;
bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.SPEED", dSpeed) ;
// Eseguo aggiornamento utensile
bOk = bOk && ExeLuaCallFunction( "AdjustCustomTool") ;
// Recupero errore
+80 -21
View File
@@ -182,6 +182,52 @@ MachMgr::AddMachGroup( const string& sName, const string& sMachineName)
return nNewId ;
}
//----------------------------------------------------------------------------
int
MachMgr::CopyMachGroup( const string& sSouName, const string& sName)
{
// recupero il gruppo sorgente
int nSouMGrpId = GetMachGroupId( sSouName) ;
if ( nSouMGrpId == GDB_ID_NULL)
return GDB_ID_NULL ;
// verifico esista la sua macchina
string sMachineName ;
m_pGeomDB->GetInfo( nSouMGrpId, MACH_MACHINE_KEY, sMachineName) ;
if ( sMachineName.empty() || ! LoadMachine( sMachineName))
return GDB_ID_NULL ;
// verifico nome nuovo gruppo (non deve essere vuoto e non deve esserci già un gruppo con questo nome)
if ( &sName == nullptr || sName.empty() || GetMachGroupId( sName) != GDB_ID_NULL)
return GDB_ID_NULL ;
// reset gruppo corrente
ResetCurrMachGroup() ;
// eseguo la copia del gruppo sorgente e la metto in coda
int nNewMGrpId = m_pGeomDB->Copy( nSouMGrpId, GDB_ID_NULL, m_nMachBaseId) ;
if ( nNewMGrpId == GDB_ID_NULL)
return GDB_ID_NULL ;
// assegno il nome
m_pGeomDB->SetName( nNewMGrpId, sName) ;
// converto opportunamente gli indicativi dei grezzi nelle disposizioni
int nSouRawPartId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( nSouMGrpId, MACH_RAW_GROUP)) ;
int nNewRawPartId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( nNewMGrpId, MACH_RAW_GROUP)) ;
while ( nSouRawPartId != GDB_ID_NULL && nNewRawPartId != GDB_ID_NULL) {
// ciclo sulle disposizioni del nuovo gruppo di lavoro
int nOperId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( nNewMGrpId, MACH_OPER_GROUP)) ;
while ( nOperId != GDB_ID_NULL) {
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( nOperId)) ;
if ( pDisp != nullptr)
pDisp->UpdateRawPartId( nSouRawPartId, nNewRawPartId) ;
nOperId = m_pGeomDB->GetNextGroup( nOperId) ;
}
// passo alla coppia successiva
nSouRawPartId = m_pGeomDB->GetNextGroup( nSouRawPartId) ;
nNewRawPartId = m_pGeomDB->GetNextGroup( nNewRawPartId) ;
}
// lo rendo corrente
SetCurrMachGroup( nNewMGrpId) ;
// restituisco l'identificativo del gruppo
return nNewMGrpId ;
}
//----------------------------------------------------------------------------
bool
MachMgr::RemoveMachGroup( int nId)
@@ -222,44 +268,60 @@ MachMgr::VerifyMachGroup( int nId, MachGrp& mgData) const
// verifica della macchina
bool bMName = m_pGeomDB->GetInfo( nId, MACH_MACHINE_KEY, mgData.MGeoName) ;
// scansiono i sottogruppi
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter))
return false ;
bool bSetup = false ;
bool bFixt = false ;
bool bRaw = false ;
bool bOper = false ;
bool bIter = pIter->GoToFirstGroupInGroup( nId) ;
while ( bIter) {
int nGrpId = m_pGeomDB->GetFirstGroupInGroup( nId) ;
while ( nGrpId != GDB_ID_NULL) {
string sName ;
if ( pIter->GetName( sName)) {
if ( m_pGeomDB->GetName( nGrpId, sName)) {
if ( sName == MACH_SETUP_GROUP) {
if ( ! bSetup)
mgData.SetupGroupId = pIter->GetId() ;
mgData.SetupGroupId = nGrpId ;
bSetup = true ;
}
else if ( sName == MACH_FIXT_GROUP) {
if ( ! bFixt)
mgData.FixtGroupId = pIter->GetId() ;
mgData.FixtGroupId = nGrpId ;
bFixt = true ;
}
else if ( sName == MACH_RAW_GROUP) {
if ( ! bRaw)
mgData.RawGroupId = pIter->GetId() ;
mgData.RawGroupId = nGrpId ;
bRaw = true ;
}
else if ( sName == MACH_OPER_GROUP) {
if ( ! bOper)
mgData.OperGroupId = pIter->GetId() ;
mgData.OperGroupId = nGrpId ;
bOper = true ;
}
}
// passo al successivo
bIter = pIter->GoToNextGroup() ;
nGrpId = m_pGeomDB->GetNextGroup( nGrpId) ;
}
return ( bMName && bSetup && bRaw && bOper) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ChangeMachGroupName( int nId, const string& sNewName)
{
// verifica del gruppo base per le lavorazioni
if ( ! VerifyMachBase())
return false ;
// verifico che il gruppo ricevuto sia corretto
if ( m_pGeomDB->GetParentId( nId) != m_nMachBaseId)
return false ;
// verifico nome non vuoto e non esista già un gruppo con lo stesso nome
if ( &sNewName == nullptr || sNewName.empty() || GetMachGroupId( sNewName) != GDB_ID_NULL)
return false ;
// cambio il nome del gruppo di lavoro
if ( ! m_pGeomDB->SetName( nId, sNewName))
return false ;
return true ;
}
//----------------------------------------------------------------------------
string
MachMgr::GetMachGroupName( int nId) const
@@ -298,22 +360,19 @@ MachMgr::GetMachGroupId( const string& sName) const
{
// verifica dei parametri
if ( &sName == nullptr || sName.empty())
return false ;
return GDB_ID_NULL ;
// verifica del gruppo base per le lavorazioni
if ( ! VerifyMachBase())
return false ;
return GDB_ID_NULL ;
// recupero l'identificativo del gruppo con il nome indicato
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter))
return false ;
bool bIter = pIter->GoToFirstGroupInGroup( m_nMachBaseId) ;
while( bIter) {
int nGrpId = m_pGeomDB->GetFirstGroupInGroup( m_nMachBaseId) ;
while ( nGrpId != GDB_ID_NULL) {
// verifico il nome
string sMGroupName ;
if ( pIter->GetName( sMGroupName) && EqualNoCase( sMGroupName, sName))
return pIter->GetId() ;
if ( m_pGeomDB->GetName( nGrpId, sMGroupName) && EqualNoCase( sMGroupName, sName))
return nGrpId ;
// passo al successivo
bIter = pIter->GoToNextGroup() ;
nGrpId = m_pGeomDB->GetNextGroup( nGrpId) ;
}
return GDB_ID_NULL ;
}
+42 -3
View File
@@ -356,7 +356,7 @@ bool
MachMgr::SetAxisPos( const string& sAxis, double dVal, double* pdNewVal)
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->SetAxisPos( sAxis, dVal, pdNewVal) : false) ;
return ( ( pMch != nullptr) ? pMch->SetAxisPos( sAxis, dVal, true, pdNewVal) : false) ;
}
//----------------------------------------------------------------------------
@@ -534,6 +534,14 @@ MachMgr::SetCalcSolCh( int nScc, bool bExact)
return pMch->SetSolCh( nScc, bExact) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcTable( string& sTable) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetCurrTable( sTable) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcTool( string& sTool) const
@@ -609,6 +617,17 @@ MachMgr::GetAllTablesNames( STRVECTOR& vNames) const
return ( ( pMch != nullptr) ? pMch->GetAllTablesNames( vNames) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAllAxesNames( STRVECTOR& vNames) const
{
// pulisco il vettore
vNames.clear() ;
// richiedo elenco assi alla macchina corrente
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllAxesNames( vNames) : false) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetAllHeadsNames( STRVECTOR& vNames) const
@@ -649,10 +668,10 @@ MachMgr::GetCurrRotAxes( void) const
//----------------------------------------------------------------------------
bool
MachMgr::GetAllCurrAxesName( STRVECTOR& vAxName) const
MachMgr::GetAllCurrAxesNames( STRVECTOR& vAxName) const
{
Machine* pMch = GetCurrMachine() ;
return ( ( pMch != nullptr) ? pMch->GetAllCurrAxesName( vAxName) : false) ;
return ( ( pMch != nullptr) ? pMch->GetAllCurrAxesNames( vAxName) : false) ;
}
//----------------------------------------------------------------------------
@@ -683,6 +702,26 @@ MachMgr::GetCurrLinAxesFrame( void) const
return pMch->GetCurrLinAxesFrame() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCurrIsCenter( void) const
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
return ( pMch->GetCurrKinematicChainType() == KIN_CHAIN_CENTER) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCurrIsRobot( void) const
{
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
return ( pMch->GetCurrKinematicChainType() == KIN_CHAIN_ROBOT) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
+410 -134
View File
@@ -29,6 +29,7 @@
#include "/EgtDev/Include/EGkStmStandard.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EXeConst.h"
using namespace std ;
@@ -96,7 +97,7 @@ MachMgr::AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double d
m_pGeomDB->SetInfo( nRawId, MACH_RAW_PHASE, m_nCurrPhase) ;
// creo solido e outline
bOk = bOk && ModifyRawPart( nRawId, ptOrig, dLen, dWidth, dHeight, cCol) ;
// se qualcosa è andato storto, cancello tutto
// se qualcosa è andato storto, cancello tutto
if ( ! bOk) {
m_pGeomDB->Erase( nRawId) ;
return GDB_ID_NULL ;
@@ -112,7 +113,7 @@ MachMgr::ModifyRawPart( int nRawId, const Point3d& ptOrig, double dLen, double d
// le dimensioni non possono essere nulle
if ( dLen < EPS_SMALL || dWidth < EPS_SMALL || dHeight < EPS_SMALL)
return false ;
// verifica validità grezzo
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// creo il solido
@@ -171,7 +172,7 @@ MachMgr::AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color
// verifico il gruppo dei grezzi nella macchinata corrente
if ( GetCurrRawGroupId() == GDB_ID_NULL)
return GDB_ID_NULL ;
// verifico che il pezzo non sia già usato nella macchinata corrente
// verifico che il pezzo non sia già usato nella macchinata corrente
if ( m_pGeomDB->GetParentId( nPartId) != GDB_ID_ROOT)
return GDB_ID_NULL ;
// recupero il tipo di oggetto per definire il grezzo
@@ -180,7 +181,7 @@ MachMgr::AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color
Point3d ptRef ;
// costruzione del grezzo
int nRawId = GDB_ID_NULL ;
// se grezzo da superficie (per ora senza possibilità di offset)
// se grezzo da superficie (per ora senza possibilità di offset)
if ( ( nGtype & GEO_SURF) != 0) {
// inserisco il grezzo
nRawId = AddRawPart( nCrvSrfId, cCol) ;
@@ -284,7 +285,7 @@ MachMgr::AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight,
m_pGeomDB->SetInfo( nRawId, MACH_RAW_PHASE, m_nCurrPhase) ;
// creo solido e outline
bOk = bOk && ModifyRawPart( nRawId, nCrvId, dOverMat, dZmin, dHeight, cCol) ;
// se qualcosa è andato storto, cancello tutto
// se qualcosa è andato storto, cancello tutto
if ( ! bOk) {
m_pGeomDB->Erase( nRawId) ;
return GDB_ID_NULL ;
@@ -297,7 +298,7 @@ MachMgr::AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight,
bool
MachMgr::ModifyRawPart( int nRawId, int nCrvId, double dOverMat, double dZmin, double dHeight, Color cCol)
{
// verifica validità grezzo
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// recupero il riferimento della curva
@@ -321,7 +322,7 @@ MachMgr::ModifyRawPart( int nRawId, int nCrvId, double dOverMat, double dZmin, d
// la schiaccio a Z = 0
if ( ! pMyCrv->Scale( Frame3d(), 1, 1, 0))
return false ;
// se non è chiusa, la chiudo
// se non è chiusa, la chiudo
pMyCrv->Close() ;
// la oriento in senso CCW
double dAreaXY ;
@@ -375,11 +376,11 @@ MachMgr::AddRawPart( int nSurfId, Color cCol)
if ( nRawGroupId == GDB_ID_NULL)
return GDB_ID_NULL ;
// recupero l'ingombro della superficie in globale
BBox3d b3Crv ;
if ( ! m_pGeomDB->GetGlobalBBox( nSurfId, b3Crv))
BBox3d b3Surf ;
if ( ! m_pGeomDB->GetGlobalBBox( nSurfId, b3Surf))
return GDB_ID_NULL ;
// inserisco il gruppo del grezzo nella macchinata
Frame3d frRaw( b3Crv.GetMin()) ;
Frame3d frRaw( b3Surf.GetMin()) ;
int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, frRaw) ;
if ( nRawId == GDB_ID_NULL)
return GDB_ID_NULL ;
@@ -456,11 +457,11 @@ MachMgr::AddRawPart( int nSurfId, Color cCol)
int nCrvId = ( bOk ? m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pCrvCompo)) : GDB_ID_NULL) ;
bOk = bOk && ( nCrvId != GDB_ID_NULL) ;
// assegno il nome alla curva
bOk = bOk && m_pGeomDB->SetName( nCrvId, MACH_RAW_SOLID) ;
bOk = bOk && m_pGeomDB->SetName( nCrvId, MACH_RAW_OUTLINE) ;
// assegno il colore alla curva
bOk = bOk && m_pGeomDB->SetMaterial( nCrvId, cCol) ;
bOk = bOk && m_pGeomDB->SetMaterial( nCrvId, cCol) ;
}
// se qualcosa è andato storto, cancello tutto
// se qualcosa è andato storto, cancello tutto
if ( ! bOk) {
m_pGeomDB->Erase( nRawId) ;
return GDB_ID_NULL ;
@@ -471,6 +472,156 @@ MachMgr::AddRawPart( int nSurfId, Color cCol)
return nRawId ;
}
//----------------------------------------------------------------------------
int
MachMgr::AddRawPart( int nSfrUpId, int nSfrDownId, double dHeight, Color cCol)
{
// recupero il gruppo dei grezzi nella macchinata corrente
int nRawGroupId = GetCurrRawGroupId() ;
if ( nRawGroupId == GDB_ID_NULL)
return GDB_ID_NULL ;
// recupero l'ingombro della superficie up in globale
BBox3d b3Surf ;
if ( ! m_pGeomDB->GetGlobalBBox( nSfrUpId, b3Surf))
return GDB_ID_NULL ;
// inserisco il gruppo del grezzo nella macchinata
Frame3d frRaw( b3Surf.GetMin()) ;
int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, frRaw) ;
if ( nRawId == GDB_ID_NULL)
return GDB_ID_NULL ;
// assegno il nome al gruppo
bool bOk = m_pGeomDB->SetName( nRawId, MACH_RAW_PART) ;
// assegno la fase al gruppo
bOk = bOk && m_pGeomDB->SetInfo( nRawId, MACH_RAW_PHASE, m_nCurrPhase) ;
// recupero il frame originale della superficie up ( deve essere lo stesso della down)
Frame3d frSurf ;
bOk = bOk && m_pGeomDB->GetGlobFrame( nSfrUpId, frSurf) ;
// creo il volume in modo approssimativo a partire dalle due superfici considerando soltanto un'approssimazione dei bordi esterni
// regione up
PtrOwner<ISurfFlatRegion> pSurfUp( CloneSurfFlatRegion( m_pGeomDB->GetGeoObj( nSfrUpId))) ;
bOk = bOk && ( ! IsNull( pSurfUp)) ;
// calcolo offset e contro-offset per unificare i chunk ed eliminare eventuali rientranze nella superficie
double dOffs = 8 ;
bOk = bOk && pSurfUp->Offset( dOffs, ICurve::OFF_FILLET) ;
bOk = bOk && pSurfUp->Offset( -dOffs, ICurve::OFF_FILLET) ;
// recupero il chunk di area maggiore
int nKMax = 0 ;
if ( bOk && pSurfUp->GetChunkCount() > 1) {
double dAreaMax = -1 ;
for ( int k = 0 ; k < pSurfUp->GetChunkCount() ; k ++) {
PtrOwner<ISurfFlatRegion> pSfrChunk( pSurfUp->CloneChunk( k)) ;
double dArea = -1 ; pSfrChunk->GetGrossArea( dArea) ;
if ( dArea > dAreaMax) {
nKMax = k ;
dAreaMax = dArea ;
}
}
}
PtrOwner<ICurve> pCrvUp ;
bOk = bOk && pCrvUp.Set( pSurfUp->GetLoop( nKMax, 0)) ;
bOk = bOk && ( ! IsNull( pCrvUp)) ;
// regione down
PtrOwner<ISurfFlatRegion> pSurfDown( CloneSurfFlatRegion( m_pGeomDB->GetGeoObj( nSfrDownId))) ;
bOk = bOk && ( ! IsNull( pSurfDown)) ;
bOk = bOk && pSurfDown->Offset( dOffs, ICurve::OFF_FILLET) ;
bOk = bOk && pSurfDown->Offset( -dOffs, ICurve::OFF_FILLET) ;
nKMax = 0 ;
if ( bOk && pSurfDown->GetChunkCount() > 1) {
double dAreaMax = -1 ;
for ( int k = 0 ; k < pSurfDown->GetChunkCount() ; k ++) {
PtrOwner<ISurfFlatRegion> pSfrChunk( pSurfDown->CloneChunk( k)) ;
double dArea = -1 ; pSfrChunk->GetGrossArea( dArea) ;
if ( dArea > dAreaMax) {
nKMax = k ;
dAreaMax = dArea ;
}
}
}
PtrOwner<ICurveComposite> pCrvDown ;
bOk = bOk && pCrvDown.Set( ConvertCurveToComposite( pSurfDown->GetLoop( nKMax, 0))) ;
bOk = bOk && ( ! IsNull( pCrvDown)) ;
// sposto il punto di inizio il più vicino possibile a quello della curva up per migliorare il calcolo della rigata
if ( bOk) {
Point3d ptS ; pCrvUp->GetStartPoint( ptS) ;
DistPointCurve distPC( ptS, *pCrvDown) ;
double dPar ; int nFlag ;
bOk = bOk && distPC.GetParamAtMinDistPoint( 0, dPar, nFlag) ;
bOk = bOk && pCrvDown->ChangeStartPoint( dPar) ;
}
// volume
PtrOwner<ISurfTriMesh> pStmRaw ;
bOk = bOk && pStmRaw.Set( GetSurfTriMeshByFlatContour( pCrvUp)) ;
bOk = bOk && ( ! IsNull( pStmRaw)) ;
PtrOwner<ISurfTriMesh> pStmLat ;
bOk = bOk && pStmLat.Set( GetSurfTriMeshRuled( pCrvDown, pCrvUp, ISurfTriMesh::RLT_MINDIST)) ;
bOk = bOk && ( ! IsNull( pStmLat)) ;
bOk = bOk && pStmRaw->DoSewing( *pStmLat) ;
PtrOwner<ISurfTriMesh> pStmDown ;
bOk = bOk && pStmDown.Set( GetSurfTriMeshByFlatContour( pCrvDown)) ;
bOk = bOk && pStmDown->Invert() ;
bOk = bOk && pStmRaw->DoSewing( *pStmDown) ;
bOk = bOk && pStmRaw->DoCompacting() ;
bOk = bOk && pStmRaw->Repair() ;
bOk = bOk && pStmRaw->LocToLoc( frSurf, frRaw) ;
int nId = bOk ? m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pStmRaw)) : GDB_ID_NULL ;
bOk = bOk && ( nId != GDB_ID_NULL) ;
// assegno il nome al solido
bOk = bOk && m_pGeomDB->SetName( nId, MACH_RAW_SOLID) ;
// assegno il colore al solido
bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ;
// rendo visibile il solido
bOk = bOk && m_pGeomDB->SetStatus( nId, GDB_ST_ON) ;
// calcolo il punto centro del solido
bOk = bOk && SetRawPartCenter( nRawId) ;
if ( bOk) {
// costruisco la curva di contorno
PtrOwner<ISurfFlatRegion> pSfrUp( CloneSurfFlatRegion( m_pGeomDB->GetGeoObj( nSfrUpId))) ;
PtrOwner<ISurfFlatRegion> pSfrDown( CloneSurfFlatRegion( m_pGeomDB->GetGeoObj( nSfrDownId))) ;
bOk = bOk && ( ! IsNull( pSfrUp)) && ( ! IsNull( pSfrDown)) ;
if ( bOk)
pSfrUp->Add( *pSfrDown) ;
PtrOwner<ICurve> pCrv ;
bOk = bOk && pCrv.Set( pSfrUp->GetLoop( 0, 0)) ;
bOk = bOk && ( ! IsNull( pCrv)) ;
bOk = bOk && pCrv->LocToLoc( frSurf, frRaw) ;
int nLoop = bOk ? m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pCrv)) : GDB_ID_NULL ;
bOk = bOk && ( nLoop != GDB_ID_NULL) ;
bOk = bOk && ExeMove( {nLoop}, -dHeight * Z_AX, RTY_LOC) ;
// assegno il nome alla curva
bOk = bOk && m_pGeomDB->SetName( nLoop, MACH_RAW_OUTLINE) ;
// assegno il colore alla curva
bOk = bOk && m_pGeomDB->SetMaterial( nLoop, cCol) ;
// recupero le superfici up e down
int nSurfUpId = ( bOk ? m_pGeomDB->CopyGlob( nSfrUpId, GDB_ID_NULL, nRawId) : GDB_ID_NULL) ;
bOk = bOk && ( nSurfUpId != GDB_ID_NULL) ;
bOk = bOk && m_pGeomDB->SetName( nSurfUpId, MACH_RAW_UP_REG) ;
bOk = bOk && m_pGeomDB->SetMaterial( nSurfUpId, cCol) ;
bOk = bOk && m_pGeomDB->SetStatus( nSurfUpId, GDB_ST_OFF) ;
int nSurfDownId = ( bOk ? m_pGeomDB->CopyGlob( nSfrDownId, GDB_ID_NULL, nRawId) : GDB_ID_NULL) ;
bOk = bOk && ( nSurfDownId != GDB_ID_NULL) ;
bOk = bOk && m_pGeomDB->SetName( nSurfDownId, MACH_RAW_DOWN_REG) ;
bOk = bOk && m_pGeomDB->SetMaterial( nSurfDownId, cCol) ;
bOk = bOk && m_pGeomDB->SetStatus( nSurfDownId, GDB_ST_OFF) ;
}
// se qualcosa è andato storto, cancello tutto
if ( ! bOk) {
m_pGeomDB->Erase( nRawId) ;
return GDB_ID_NULL ;
}
// tutto ok
return nRawId ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight)
@@ -478,7 +629,7 @@ MachMgr::ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dH
// le nuove dimensioni non possono essere nulle
if ( dLength < EPS_SMALL || dWidth < EPS_SMALL || dHeight < EPS_SMALL)
return false ;
// verifica validità grezzo
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// recupero il solido del grezzo
@@ -520,10 +671,10 @@ MachMgr::ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dH
bool
MachMgr::ModifyRawPartHeight( int nRawId, double dHeight)
{
// la nuova altezza non può essere nulla
// la nuova altezza non può essere nulla
if ( dHeight < EPS_SMALL)
return false ;
// verifica validità grezzo
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// recupero il solido del grezzo
@@ -552,10 +703,10 @@ MachMgr::GetRawPartPhases( int nRawId, INTVECTOR& vPhase) const
{
// pulisco parametro di ritorno
vPhase.clear() ;
// verifica validità grezzo
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// recupero le fasi in cui è presente il grezzo (se manca è fase 1)
// recupero le fasi in cui è presente il grezzo (se manca è fase 1)
if ( ! m_pGeomDB->GetInfo( nRawId, MACH_RAW_PHASE, vPhase) || vPhase.empty())
vPhase.emplace_back( 1) ;
return true ;
@@ -565,11 +716,11 @@ MachMgr::GetRawPartPhases( int nRawId, INTVECTOR& vPhase) const
bool
MachMgr::KeepRawPart( int nRawId, int nSouPhase)
{
// verifico validità e recupero fasi in cui è presente
// verifico validità e recupero fasi in cui è presente
INTVECTOR vPhase ;
if ( ! GetRawPartPhases( nRawId, vPhase))
return false ;
// se fase corrente già presente, non devo fare alcunché
// se fase corrente già presente, non devo fare alcunché
if ( find( vPhase.begin(), vPhase.end(), m_nCurrPhase) != vPhase.end())
return true ;
// aggiungo la fase corrente
@@ -621,10 +772,11 @@ MachMgr::KeepRawPart( int nRawId, int nSouPhase)
bool
MachMgr::VerifyRawPartPhase( int nRawId, int nPhase) const
{
// verifico validità e recupero fasi in cui è presente
// verifico validità e recupero fasi in cui è presente
INTVECTOR vPhase ;
if ( ! GetRawPartPhases( nRawId, vPhase))
return false ;
// verifico presenza nella fase indicata
return ( find( vPhase.begin(), vPhase.end(), nPhase) != vPhase.end()) ;
}
@@ -632,11 +784,11 @@ MachMgr::VerifyRawPartPhase( int nRawId, int nPhase) const
bool
MachMgr::RemoveRawPartFromCurrPhase( int nRawId)
{
// verifico validità e recupero fasi in cui è presente
// verifico validità e recupero fasi in cui è presente
INTVECTOR vPhase ;
if ( ! GetRawPartPhases( nRawId, vPhase))
return false ;
// se non appartiene alla fase corrente, non devo fare alcunché
// se non appartiene alla fase corrente, non devo fare alcunché
auto iIter = find( vPhase.begin(), vPhase.end(), m_nCurrPhase) ;
if ( iIter == vPhase.end())
return true ;
@@ -663,7 +815,7 @@ MachMgr::RemoveRawPartFromCurrPhase( int nRawId)
bool
MachMgr::RemoveRawPart( int nRawId)
{
// verifica validità grezzo
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// tolgo dalle disposizioni in cui compare gli eventuali movimenti registrati di questo grezzo
@@ -687,7 +839,7 @@ MachMgr::VerifyRawPart( int nRawId, bool bLinkedAllowed) const
int nRawGroupId = GetCurrRawGroupId() ;
if ( nRawGroupId != GDB_ID_NULL && m_pGeomDB->GetParentId( nRawId) == nRawGroupId)
return true ;
// se consentito linkaggio ed il grezzo è linkato ad un gruppo della macchina corrente, va bene
// se consentito linkaggio ed il grezzo è linkato ad un gruppo della macchina corrente, va bene
if ( bLinkedAllowed) {
Machine* pMch = GetCurrMachine() ;
if ( pMch != nullptr && pMch->IsLinkedRawPart( nRawId))
@@ -807,12 +959,12 @@ MachMgr::ResetRawPartCenter( int nRawId)
bool
MachMgr::GetRawPartCenter( int nRawId, Point3d& ptCen)
{
// verifica validità grezzo
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// cerco di recuperare l'oggetto
int nGPntId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_CENTER) ;
// ne verifico la validità
// ne verifico la validità
int nMode ;
if ( nGPntId == GDB_ID_NULL ||
! m_pGeomDB->GetMode( nGPntId, nMode) || nMode != GDB_MD_STD) {
@@ -840,7 +992,7 @@ MachMgr::GetRawPartCenter( int nRawId, Point3d& ptCen)
bool
MachMgr::GetRawPartBBox( int nRawId, BBox3d& b3Raw)
{
// verifica validità grezzo
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// recupero solido del grezzo
@@ -848,6 +1000,103 @@ MachMgr::GetRawPartBBox( int nRawId, BBox3d& b3Raw)
return m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) ;
}
//---------------------------------------------------------------------------
static bool
AssociateSurfs( IGeomDB* pGeomDB, int nSurfUpId, int nSurfDownId, vector<pair<int,int>>& vRawSurfs)
{
// vRawSurfs contiene tutte le coppie ( id regioneUp, id regioneDown) che definiscono i nuovi grezzi
vRawSurfs.clear() ;
int nUpCnt = ExeSurfFrChunkCount( nSurfUpId) ;
int nDownCnt = ExeSurfFrChunkCount( nSurfDownId) ;
// se non sono stati creati più grezzi
if ( nUpCnt == 1 || nDownCnt == 1) {
vRawSurfs.emplace_back( nSurfUpId, nSurfDownId) ;
return true ;
}
int nUpFirstId = ExeExplodeSurface( nSurfUpId, &nUpCnt) ;
int nDownFirstId = ExeExplodeSurface( nSurfDownId, &nDownCnt) ;
// ad ogni chunk della regione up associo i chunk corrispondenti della regione down
INTVECTOR vChunks( nUpCnt, GDB_ID_NULL) ;
for ( int nIdD = nDownFirstId ; nIdD < nDownFirstId + nDownCnt ; nIdD ++) {
ISurfFlatRegion* pSfrD = GetSurfFlatRegion( pGeomDB->GetGeoObj( nIdD)) ;
if ( pSfrD == nullptr)
return false ;
BBox3d bBoxD ; ExeGetBBox( nIdD, BBF_STANDARD, bBoxD) ;
// inidividuo il chunk della superficie up che interagisce maggiormente con il chunk corrente della superficie down
int k = -1 ;
double dMaxArea = -1 ;
for ( int j = 0 ; j < nUpCnt ; j ++) {
BBox3d bBoxU ; ExeGetBBox( nUpFirstId + j, BBF_STANDARD, bBoxU) ;
if ( bBoxU.OverlapsXY( bBoxD)) {
PtrOwner<ISurfFlatRegion> pSfrU( CloneSurfFlatRegion( pGeomDB->GetGeoObj( nUpFirstId + j))) ;
if ( IsNull( pSfrU))
return false ;
// le due superfici sono nello stesso frame
pSfrU->Intersect( *pSfrD) ;
double dArea = -1 ; pSfrU->GetArea( dArea) ;
if ( dArea > dMaxArea) {
k = j ;
dMaxArea = dArea ;
}
}
}
// aggiorno le superfici con l'associazione trovata
if ( k == -1)
return false ;
if ( vChunks[k] == GDB_ID_NULL)
vChunks[k] = nIdD ;
else {
ExeSurfFrAdd( vChunks[k], nIdD) ;
ExeErase( {nIdD}) ;
}
}
// controllo per ogni chunk della superficie up il corrispondente della nuova superficie down
for ( int i = 0 ; i < nUpCnt ; i ++) {
ISurfFlatRegion* pSfrU = GetSurfFlatRegion( pGeomDB->GetGeoObj( nUpFirstId + i)) ;
if ( pSfrU == nullptr)
return false ;
BBox3d bBoxU ; ExeGetBBox( nUpFirstId + i, BBF_STANDARD, bBoxU) ;
// individuo il chunk della superficie down che interagisce maggiormente con il chunk corrente della superficie up
int k = -1 ;
double dMaxArea = -1 ;
for ( int j = 0 ; j < int( vChunks.size()) ; j ++) {
BBox3d bBoxD ; ExeGetBBox( vChunks[j], BBF_STANDARD, bBoxD) ;
// se i box interferiscono allora verifico di quanto si sovrappongono le due regioni
if ( bBoxD.OverlapsXY( bBoxU)) {
PtrOwner<ISurfFlatRegion> pSfrD( CloneSurfFlatRegion( pGeomDB->GetGeoObj( vChunks[j]))) ;
if ( IsNull( pSfrD))
return false ;
pSfrD->Intersect( *pSfrU) ;
double dArea = -1 ; pSfrD->GetArea( dArea) ;
if ( dArea > dMaxArea) {
k = j ;
dMaxArea = dArea ;
}
}
}
if ( k == -1)
return false ;
// se è la stessa associazione individuata da vChunks allora aggiorno il vettore finale dei grezzi
if ( k == i)
vRawSurfs.emplace_back( nUpFirstId + i, vChunks[i]) ;
else {
// altrimenti unisco le regioni associate appena individuate sia per la superficie up sia per la down
ExeSurfFrAdd( nUpFirstId + k, nUpFirstId + i) ;
ExeErase( {nUpFirstId + i}) ;
ExeSurfFrAdd( vChunks[k], vChunks[i]) ;
ExeErase( {vChunks[i]}) ;
}
}
return true ;
}
//----------------------------------------------------------------------------
int
MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
@@ -871,7 +1120,6 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
BBox3d b3Raw ;
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw))
return GDB_ID_NULL ;
double dZmin = b3Raw.GetMin().z ;
double dHeight = b3Raw.GetMax().z - b3Raw.GetMin().z ;
// il colore del grezzo
Color cCol = AQUA ;
@@ -880,19 +1128,31 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
Frame3d frRaw ;
if ( ! m_pGeomDB->GetGroupGlobFrame( nRawId, frRaw))
return GDB_ID_NULL ;
// creo la regione del grezzo a partire dal suo contorno
// recupero il contorno
int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_OUTLINE) ;
if ( nOutCrvId == GDB_ID_NULL)
return GDB_ID_NULL ;
// creo la regione
INTVECTOR vCrvIds ;
vCrvIds.emplace_back( nOutCrvId) ;
int nSfrId = ExeCreateSurfFlatRegion( nRawId, vCrvIds, nullptr) ;
if ( nSfrId == GDB_ID_NULL)
return GDB_ID_NULL ;
m_pGeomDB->SetLevel( nSfrId, GDB_LV_TEMP) ;
// creo le regioni inferiore e superiore del grezzo da aggiornare con le lavorazioni
int nSfrDownId = GDB_ID_NULL, nSfrUpId = GDB_ID_NULL ;
int nSfrDownOrigId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_DOWN_REG) ;
int nSfrUpOrigId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_UP_REG) ;
if ( nSfrDownOrigId == GDB_ID_NULL || nSfrUpOrigId == GDB_ID_NULL) {
// se le regioni del grezzo di partenza non sono definite, le creo a partire dall'outline
nSfrDownId = ExeCreateSurfFlatRegion( nRawId, {nOutCrvId}, nullptr) ;
if ( nSfrDownId == GDB_ID_NULL)
return GDB_ID_NULL ;
nSfrUpId = ExeCopyGlob( nSfrDownId, nRawId, GDB_LAST_SON) ;
if ( nSfrUpId == GDB_ID_NULL)
return GDB_ID_NULL ;
ExeMove( { nSfrUpId}, dHeight * Z_AX, RTY_LOC) ;
}
else {
nSfrDownId = ExeCopyGlob( nSfrDownOrigId, nRawId, GDB_LAST_SON) ;
nSfrUpId = ExeCopyGlob( nSfrUpOrigId, nRawId, GDB_LAST_SON) ;
if ( nSfrDownId == GDB_ID_NULL || nSfrUpId == GDB_ID_NULL)
return GDB_ID_NULL ;
}
// se esiste il kerf, ne creo la regione
PtrOwner<ISurfFlatRegion> pSfrKerf ;
@@ -907,7 +1167,8 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
}
// recupero le regioni delle lavorazioni
INTVECTOR vMchRReg ;
INTVECTOR vMchRRegUp ;
INTVECTOR vMchRRegDown ;
for ( auto nMchId : vMchId) {
// recupero gruppo preview lavorazioni nella lavorazione
int nPVGrp = m_pGeomDB->GetFirstNameInGroup( nMchId, MCH_PV) ;
@@ -915,94 +1176,110 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
return GDB_ID_NULL ;
// se vuoto, cerco il rimando al preview nel pezzo
if ( m_pGeomDB->GetGroupObjs( nPVGrp) == 0 &&
! m_pGeomDB->GetInfo( nPVGrp, MCH_PV_KEY_RELOCATE, nPVGrp))
! m_pGeomDB->GetInfo( nPVGrp, MCH_PV_KEY_RELOCATE, nPVGrp))
return GDB_ID_NULL ;
// ciclo sui percorsi utensile (CL)
int nClId = m_pGeomDB->GetFirstGroupInGroup( nPVGrp) ;
while ( nClId != GDB_ID_NULL) {
// tagli ridotti
int nCrId = m_pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_RRCUT) ;
while ( nCrId != GDB_ID_NULL) {
vMchRReg.emplace_back( nCrId) ;
nCrId = m_pGeomDB->GetNextName( nCrId, MCH_PV_RRCUT) ;
}
// lavorazioni per regione inferiore
int nCrDownId = m_pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_DOWN_RAWCUT) ;
// se non esiste la regione inferiore la lavorazione non è passante quindi può essere ignorata
if ( nCrDownId != GDB_ID_NULL) {
while ( nCrDownId != GDB_ID_NULL) {
vMchRRegDown.emplace_back( nCrDownId) ;
nCrDownId = m_pGeomDB->GetNextName( nCrDownId, MCH_PV_DOWN_RAWCUT) ;
}
// lavorazioni per regione superiore
int nCrUpId = m_pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_UP_RAWCUT) ;
while ( nCrUpId != GDB_ID_NULL) {
vMchRRegUp.emplace_back( nCrUpId) ;
nCrUpId = m_pGeomDB->GetNextName( nCrUpId, MCH_PV_UP_RAWCUT) ;
}
}
// passo al successivo percorso utensile
nClId = m_pGeomDB->GetNextGroup( nClId) ;
}
}
// sottraggo queste regioni a quella del grezzo
for ( auto nMchRReg : vMchRReg) {
ExeSurfFrSubtract( nSfrId, nMchRReg) ;
}
// sottraggo le lavorazioni alle superfici del grezzo
for ( auto nMchRReg : vMchRRegUp)
ExeSurfFrSubtract( nSfrUpId, nMchRReg) ;
for ( auto nMchRReg : vMchRRegDown)
ExeSurfFrSubtract( nSfrDownId, nMchRReg) ;
// classifico i chunks della regione up e down per individuare le regioni che definiscono i nuovi grezzi
vector<pair<int,int>> vSurfRaws ;
AssociateSurfs( m_pGeomDB, nSfrUpId, nSfrDownId, vSurfRaws) ;
// creo i grezzi risultanti
// creo i nuovi grezzi
INTVECTOR vNewIds ;
int nCount ;
int nChunk = 0 ;
int nFirstLoopId = ExeExtractSurfFrChunkLoops( nSfrId, nChunk, nRawId, &nCount) ;
while ( nFirstLoopId != GDB_ID_NULL) {
// !!! in attesa di gestire i grezzi con i buchi !!!
// cancello le eventuali curve successive (sono i loop interni ovvero i buchi)
for ( int i = 1 ; i < nCount ; ++ i) {
m_pGeomDB->Erase( nFirstLoopId + i) ;
}
// dichiaro temporanea la curva
m_pGeomDB->SetLevel( nFirstLoopId, GDB_LV_TEMP) ;
// creo il grezzo
int nId = AddRawPart( nFirstLoopId, 0, dZmin, dHeight, cCol) ;
if ( nId == GDB_ID_NULL)
return GDB_ID_NULL ;
vNewIds.emplace_back( nId) ;
// imposto lo stato del contorno di questo grezzo come quello del grezzo di partenza
int nStat = GDB_ST_ON ;
if ( m_pGeomDB->GetStatus( nOutCrvId, nStat) && nStat == GDB_ST_OFF)
m_pGeomDB->SetStatus( m_pGeomDB->GetFirstNameInGroup( nId, MACH_RAW_OUTLINE), nStat) ;
// assegno la fase al gruppo
m_pGeomDB->SetInfo( nId, MACH_RAW_PHASE, m_nCurrPhase) ;
// se esiste il kerf uso questa curva per creare il kerf del nuovo grezzo
if ( ! IsNull( pSfrKerf)) {
// creo la regione con la curva
SurfFlatRegionByContours SfrCntr ;
SfrCntr.AddCurve( GetCurve( m_pGeomDB->RemoveGeoObjAndErase( nFirstLoopId))) ;
PtrOwner<ISurfFlatRegion> pSfrNewKerf( SfrCntr.GetSurf()) ;
if ( IsNull( pSfrNewKerf))
return GDB_ID_NULL ;
// la limito con la regione di kerf precedente (va bene anche se fallisce)
pSfrNewKerf->Intersect( *pSfrKerf) ;
// se risultato non vuoto
if ( pSfrNewKerf->IsValid()) {
// riferimento del nuovo grezzo
Frame3d frNewRaw ;
if ( ! m_pGeomDB->GetGroupGlobFrame( nId, frNewRaw))
return GDB_ID_NULL ;
// la porto dal riferimento del grezzo originale al riferimento di questo grezzo
pSfrNewKerf->LocToLoc( frRaw, frNewRaw) ;
// la porto sulla faccia sopra del grezzo
pSfrNewKerf->Translate( Vector3d( 0, 0, dHeight)) ;
// recupero il contorno e lo inserisco come kerf del nuovo grezzo
PtrOwner<ICurve> pCrv( pSfrNewKerf->GetLoop( 0, 0)) ;
int nNewKerfId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nId, Release( pCrv)) ;
if ( nNewKerfId == GDB_ID_NULL)
return GDB_ID_NULL ;
m_pGeomDB->CopyMaterial( nKerfId, nNewKerfId) ;
m_pGeomDB->SetName( nNewKerfId, MACH_RAW_KERF) ;
}
}
// altrimenti la cancello
else
m_pGeomDB->Erase( nFirstLoopId) ;
// passo alla prossima curva
++ nChunk ;
nFirstLoopId = ExeExtractSurfFrChunkLoops( nSfrId, nChunk, nRawId, &nCount) ;
}
// cancello la regione
m_pGeomDB->Erase( nSfrId) ;
// verifico esista almeno un nuovo grezzo
if ( vNewIds.empty())
return GDB_ID_NULL ;
INTVECTOR vNewIds ;
for ( int i = 0 ; i < int( vSurfRaws.size()) ; i++) {
// aggiungo il grezzo
int nId = AddRawPart( vSurfRaws[i].first, vSurfRaws[i].second, dHeight, cCol) ;
m_pGeomDB->Erase( vSurfRaws[i].first) ;
m_pGeomDB->Erase( vSurfRaws[i].second) ;
if ( nId == GDB_ID_NULL)
return GDB_ID_NULL ;
vNewIds.emplace_back( nId) ;
// imposto lo stato del contorno di questo grezzo come quello del grezzo di partenza
int nStat = GDB_ST_ON ;
if ( m_pGeomDB->GetStatus( nOutCrvId, nStat) && nStat == GDB_ST_OFF)
m_pGeomDB->SetStatus( m_pGeomDB->GetFirstNameInGroup( nId, MACH_RAW_OUTLINE), nStat) ;
// assegno la fase al gruppo
m_pGeomDB->SetInfo( nId, MACH_RAW_PHASE, m_nCurrPhase) ;
// se esiste il kerf uso questa curva per creare il kerf del nuovo grezzo
if ( ! IsNull( pSfrKerf)) {
// riferimento del nuovo grezzo
Frame3d frNewRaw ;
if ( ! m_pGeomDB->GetGroupGlobFrame( nId, frNewRaw))
return GDB_ID_NULL ;
// considero il nuovo kerf come la regione superiore del nuovo grezzo
int nSfrUpId = m_pGeomDB->GetFirstNameInGroup( nId, MACH_RAW_UP_REG) ;
if ( nSfrUpId == GDB_ID_NULL)
return GDB_ID_NULL ;
PtrOwner<ISurfFlatRegion> pSfrNewKerf( CloneSurfFlatRegion( m_pGeomDB->GetGeoObj( nSfrUpId))) ;
if ( IsNull( pSfrNewKerf))
return GDB_ID_NULL ;
// porto nello stesso riferimento del grezzo originale
pSfrNewKerf->LocToLoc( frNewRaw, frRaw) ;
// la limito con la regione di kerf precedente ( va bene anche se fallisce)
pSfrNewKerf->Intersect( *pSfrKerf) ;
// se risultato non vuoto
if ( pSfrNewKerf->IsValid()) {
// la porto dal riferimento del grezzo originale al riferimento di questo grezzo
pSfrNewKerf->LocToLoc( frRaw, frNewRaw) ;
// recupero il contorno esterno del chunk più grande e lo inserisco come kerf del nuovo grezzo
double dAreaMax = -1 ;
int nKMax = 0 ;
for ( int k = 0 ; k < pSfrNewKerf->GetChunkCount() ; k ++) {
PtrOwner<ISurfFlatRegion> pSfrChunk( pSfrNewKerf->CloneChunk( k)) ;
double dArea = -1 ; pSfrChunk->GetGrossArea( dArea) ;
if ( dArea > dAreaMax) {
nKMax = k ;
dAreaMax = dArea ;
}
}
PtrOwner<ICurve> pCrv( pSfrNewKerf->GetLoop( nKMax, 0)) ;
if ( IsNull( pCrv))
return GDB_ID_NULL ;
int nNewKerfId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nId, Release( pCrv)) ;
if ( nNewKerfId == GDB_ID_NULL)
return GDB_ID_NULL ;
m_pGeomDB->CopyMaterial( nKerfId, nNewKerfId) ;
m_pGeomDB->SetName( nNewKerfId, MACH_RAW_KERF) ;
}
}
}
// cancello le regioni usate per i conti
m_pGeomDB->Erase( nSfrUpId) ;
m_pGeomDB->Erase( nSfrDownId) ;
// verifico esista almeno un nuovo grezzo
if ( vNewIds.empty())
return GDB_ID_NULL ;
// inserisco i pezzi del grezzo originale nei nuovi grezzi
int nGroupId = m_pGeomDB->GetFirstGroupInGroup( nRawId) ;
while ( nGroupId != GDB_ID_NULL) {
@@ -1012,32 +1289,31 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
// scambio con pezzo
int nPartId = SwapRawPartPart( nNewGroupId, true) ;
// verifico se il pezzo sta nel grezzo
int nLayerId = m_pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER) ;
int nLayerId = m_pGeomDB->GetFirstNameInGroup( nPartId, NST_PARTREG_LAYER) ;
if ( nLayerId == GDB_ID_NULL || m_pGeomDB->GetGdbType( nLayerId) != GDB_TY_GROUP)
nLayerId = m_pGeomDB->GetFirstGroupInGroup( nPartId) ;
int nEntId = m_pGeomDB->GetFirstInGroup( nLayerId) ;
int nEntGeoType = m_pGeomDB->GetGeoType( nEntId) ;
Point3d ptTest ;
if ( ( ( nEntGeoType & GEO_CURVE) != 0 && ExeMidPoint( nEntId, nNewId, ptTest)) ||
( ( nEntGeoType & GEO_CURVE) == 0 && ExeCenterPoint( nEntId, nNewId, ptTest))) {
// cerco la regione del pezzo
int nEntId = m_pGeomDB->GetFirstInGroup( nLayerId) ;
while ( nEntId != GDB_ID_NULL) {
int nEntGeoType = m_pGeomDB->GetGeoType( nEntId) ;
if ( nEntGeoType == SRF_FLATRGN)
break ;
nEntId = m_pGeomDB->GetNext( nEntId) ;
}
if ( nEntId != GDB_ID_NULL) {
// verifico se è interna al grezzo
int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nNewId, MACH_RAW_OUTLINE) ;
BBox3d b3Raw ; m_pGeomDB->GetGlobalBBox( nOutCrvId, b3Raw) ;
double dRawDiam = 0 ; b3Raw.GetDiameter( dRawDiam) ;
BBox3d b3Part ; m_pGeomDB->GetGlobalBBox( nEntId, b3Part) ;
double dPartDiam = 0 ; b3Part.GetDiameter( dPartDiam) ;
if ( dRawDiam > 0.9 * dPartDiam) {
ICurve* pCurve = GetCurve( m_pGeomDB->GetGeoObj( nOutCrvId)) ;
if ( pCurve != nullptr) {
int nSide ;
double dDist ;
DistPointCurve distPC( ptTest, *pCurve) ;
if ( distPC.GetDist( dDist) &&
( dDist < 100 * EPS_SMALL ||
( distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT)))
break ;
}
}
}
int nSfrUp = m_pGeomDB->GetFirstNameInGroup( nNewId, MACH_RAW_UP_REG) ;
if ( ! ExeSurfFrTestExternal( nSfrUp, nEntId, EPS_SMALL))
break ;
}
}
// altrimenti scambio pezzo ed elimino gruppo
nNewGroupId = SwapRawPartPart( nPartId, false) ;
m_pGeomDB->Erase( nNewGroupId) ;
@@ -1045,5 +1321,5 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
nGroupId = m_pGeomDB->GetNextGroup( nGroupId) ;
}
return vNewIds[0] ;
return vNewIds[0] ;
}
+7
View File
@@ -130,6 +130,13 @@ MachMgr::FindToolInCurrSetup( const string& sTool)
return m_stuMgr.FindTool( sTool) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetToolSetupPosInCurrSetup( const string& sTool, string& sTcPos)
{
return m_stuMgr.GetToolSetupPos( sTool, sTcPos) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetToolsInCurrSetupPos( const string& sTcPos, STRVECTOR& vsTools)
+1 -1
View File
@@ -198,7 +198,7 @@ MachMgr::SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
return SIM_AXMV_RES_ERR ;
// lancio movimento assi
return m_pSimul->MoveAxes( nMoveType, vAxNaEpSt) ;
}
+82 -13
View File
@@ -58,6 +58,8 @@ Machine::Machine( void)
m_nHeadRotAxes = 0 ;
m_nHeadSpecRotAxis = -1 ;
m_frLinAx.Reset( false) ;
m_frRobot.Reset( false) ;
m_nCalcChainType = KIN_CHAIN_NONE ;
m_nMachineLook = MCH_LOOK_NONE ;
}
@@ -141,6 +143,8 @@ Machine::Init( const string& sMachineName, const string& sMachineDir, MachMgr* p
m_nMachineLook = ( bOk ? MCH_LOOK_ALL : MCH_LOOK_NONE) ;
// metto tutti gli assi in posizione home
bOk = bOk && ResetAllAxesPos() ;
// reset catena cinematica corrente
m_nCalcChainType = KIN_CHAIN_NONE ;
return bOk ;
}
@@ -209,7 +213,7 @@ Machine::AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay)
bool
Machine::LoadMachineTable( const string& sName, const string& sParent, int nType,
const Point3d& ptRef1, double dCoeffX, double dCoeffY, double dCoeffZ,
const string& sGeo, const STRVECTOR& vsAux)
const STRVECTOR& vsColl, const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale della tavola
string sPart, sLay ;
@@ -248,7 +252,7 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType
Table* pTab = new(nothrow) Table ;
if ( pTab == nullptr)
return false ;
pTab->Set( sName, nType, ptRef1, b3Area1) ;
pTab->Set( sName, nType, ptRef1, b3Area1, vsColl) ;
m_pGeomDB->SetUserObj( nLay, pTab) ;
// lo inserisco nel dizionario dei gruppi della macchina
return m_mapGroups.emplace( sName, nLay).second ;
@@ -441,8 +445,16 @@ Machine::ModifyMachineAxisPosition( const string& sName, const Point3d& ptPos)
Axis* pAx = GetAxis( nAxGrp) ;
if ( pAx == nullptr)
return false ;
// se valore dell'asse non nullo, lo annullo
double dCurrVal = pAx->GetCurrVal() ;
if ( abs( dCurrVal) > EPS_ZERO)
SetAxisPos( sName, 0, false) ;
// eseguo la modifica
return pAx->Modify( ptPos, m_dAxisMaxAdjust) ;
bool bOk = pAx->Modify( ptPos, m_dAxisMaxAdjust) ;
// ripristino l'asse al valore corrente
if ( abs( dCurrVal) > EPS_ZERO)
SetAxisPos( sName, dCurrVal, false) ;
return bOk ;
}
//----------------------------------------------------------------------------
@@ -458,8 +470,16 @@ Machine::ModifyMachineAxisDirection( const string& sName, const Vector3d& vtDir)
Axis* pAx = GetAxis( nAxGrp) ;
if ( pAx == nullptr)
return false ;
// se valore dell'asse non nullo, lo annullo
double dCurrVal = pAx->GetCurrVal() ;
if ( abs( dCurrVal) > EPS_ZERO)
SetAxisPos( sName, 0, false) ;
// eseguo la modifica
return pAx->Modify( vtDir, m_dAxisMaxRotAdj) ;
bool bOk = pAx->Modify( vtDir, m_dAxisMaxRotAdj) ;
// ripristino l'asse al valore corrente
if ( abs( dCurrVal) > EPS_ZERO)
SetAxisPos( sName, dCurrVal, false) ;
return bOk ;
}
//----------------------------------------------------------------------------
@@ -528,7 +548,7 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s
Head* pHead = new(nothrow) Head ;
if ( pHead == nullptr)
return false ;
pHead->Set( sName, MCH_HT_STD, 1, sHSet, vtADir, dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl) ;
pHead->Set( sName, MCH_HT_STD, 1, sHSet, 0, vtADir, dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl) ;
m_pGeomDB->SetUserObj( nLay, pHead) ;
// aggiorno la testa capostipite
if ( ! AddHeadToSet( sHSet, sName))
@@ -548,7 +568,7 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s
//----------------------------------------------------------------------------
bool
Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const string& sHSet,
const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
int nSelectType, const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const string& sGeo, const STRVECTOR& vsAux)
{
@@ -577,7 +597,8 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const
Head* pHead = new(nothrow) Head ;
if ( pHead == nullptr)
return false ;
pHead->Set( sName, MCH_HT_MULTI, int( vMuExit.size()), sHSet, vtADir, dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl) ;
pHead->Set( sName, MCH_HT_MULTI, int( vMuExit.size()), sHSet, nSelectType,
vtADir, dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl) ;
m_pGeomDB->SetUserObj( nLay, pHead) ;
// aggiorno la testa capostipite
if ( ! AddHeadToSet( sHSet, sName))
@@ -624,7 +645,7 @@ Machine::LoadMachineSpecialHead( const string& sName, const string& sParent, con
Head* pHead = new(nothrow) Head ;
if ( pHead == nullptr)
return false ;
pHead->Set( sName, MCH_HT_SPECIAL, 1, sHSet, vtADir, dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl) ;
pHead->Set( sName, MCH_HT_SPECIAL, 1, sHSet, 0, vtADir, dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl) ;
m_pGeomDB->SetUserObj( nLay, pHead) ;
// aggiorno la testa capostipite
if ( ! AddHeadToSet( sHSet, sName))
@@ -643,9 +664,9 @@ Machine::LoadMachineSpecialHead( const string& sName, const string& sParent, con
//----------------------------------------------------------------------------
bool
Machine::LoadMachineTcPos( const string& sName, const string& sParent,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
const string& sGeo, const STRVECTOR& vsAux)
Machine::LoadMachineStdTcPos( const string& sName, const string& sParent,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale della posizione nel cambio utensile
string sPart, sLay ;
@@ -685,6 +706,48 @@ Machine::LoadMachineTcPos( const string& sName, const string& sParent,
return m_mapGroups.emplace( sName, nLay).second ;
}
//----------------------------------------------------------------------------
bool
Machine::LoadMachineMultiTcPos( const string& sName, const string& sParent,
const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale della posizione nel cambio utensile
string sPart, sLay ;
Split( sGeo, "/", true, sPart, sLay) ;
// cerco il gruppo nella geometria originale
int nPart = m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sPart) ;
int nLay = m_pGeomDB->GetFirstNameInGroup( nPart, sLay) ;
if ( nLay == GDB_ID_NULL)
return false ;
// cerco il gruppo padre per spostarvelo
int nParentId = GetGroup( sParent) ;
if ( nParentId == GDB_ID_NULL ||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_LAST_SON))
return false ;
// sistemo lo stato di visualizzazione
m_pGeomDB->SetStatus( nLay, GDB_ST_ON) ;
// gli assegno il nome
m_pGeomDB->SetName( nLay, sName) ;
// sistemo la geometria ausiliaria
if ( ! AdjustAuxGeometry( vsAux, nLay))
return false ;
// installo e inizializzo il gestore della posizione nel cambio utensile
TcPos* pTcPos = new(nothrow) TcPos ;
if ( pTcPos == nullptr)
return false ;
pTcPos->Set( sName, vtADir) ;
m_pGeomDB->SetUserObj( nLay, pTcPos) ;
// sistemo il riferimento dell'uscita rispetto alla direzione ausiliaria
if ( ! AdjustExitFrames( nLay, vMuExit, vtADir))
return false ;
// trasformazione del riferimento di uscita in gruppo di uscita
if ( ! CreateExitGroups( nLay, vMuExit))
return false ;
// lo inserisco nel dizionario dei gruppi della macchina
return m_mapGroups.emplace( sName, nLay).second ;
}
//----------------------------------------------------------------------------
int
Machine::GetGroup( const string& sGroup) const
@@ -918,7 +981,7 @@ Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit)
return false ;
}
else {
Vector3d vtRotAx = vtTDir ^ vtDirN ; vtRotAx.Normalize() ;
Vector3d vtRotAx = vtTDir ^ vtDirN ; vtRotAx.Normalize( EPS_ZERO) ;
string sOut = " Exit " + sName + " rotation = (" + ToString( dAngRot) + "/" + ToString( vtRotAx) + ")" ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str()) ;
vtRotAx.ToLoc( frHead) ;
@@ -976,7 +1039,11 @@ Machine::ModifyMachineExitPosition( const string& sHead, int nExit, const Point3
if ( pExit == nullptr)
return false ;
// eseguo la modifica
return pExit->Modify( ptPos, m_dExitMaxAdjust) ;
if ( ! pExit->Modify( ptPos, m_dExitMaxAdjust))
return false ;
// eventuale aggiornamento variabile lua EMC.EXITPOS con la nuova posizione
LuaSetGlobVar( "EMC.EXITPOS", ptPos) ;
return true ;
}
//----------------------------------------------------------------------------
@@ -1000,6 +1067,8 @@ Machine::SetLook( int nFlag)
nTabId = GetFirstTable() ;
if ( nTabId == GDB_ID_NULL)
return false ;
// il gruppo tavola corrente deve essere sempre visibile
m_pGeomDB->SetStatus( nTabId, GDB_ST_ON) ;
// nascondo o visualizzo i fratelli e tutti i fratelli degli ascendenti della tavola
bool bTabOnly = ( nFlag != MCH_LOOK_ALL) ;
int nTabCurrId = nTabId ;
+25 -9
View File
@@ -53,7 +53,7 @@ class Machine
int GetHeadId( const std::string& sHead) const
{ int nId = GetGroup( sHead) ;
return ( IsHeadGroup( nId) ? nId : GDB_ID_NULL) ; }
int GetExitId( const std::string& sHead, int nExit) const
int GetExitId( const std::string& sHead, int nExit) const
{ int nHeadId = GetHeadId( sHead) ;
int nId = ( m_pGeomDB != nullptr ? m_pGeomDB->GetFirstNameInGroup( nHeadId, MCH_EXIT + ToString( nExit)) : GDB_ID_NULL) ;
return ( IsExitGroup( nId) ? nId : GDB_ID_NULL) ; }
@@ -61,12 +61,14 @@ class Machine
{ int nId = GetGroup( sTcPos) ;
return ( IsTcPosGroup( nId) ? nId : GDB_ID_NULL) ; }
bool GetAllTablesNames( STRVECTOR& vNames) const ;
bool GetAllAxesNames( STRVECTOR& vNames) const ;
bool GetAllHeadsNames( STRVECTOR& vNames) const ;
bool GetAllTcPosNames( STRVECTOR& vNames) const ;
int GetFirstTable( void) const ;
int GetHeadExitCount( const std::string& sHead) const ;
int GetHeadExitPosDirAux( const std::string& sHead, int nExit, Point3d& ptPos, Vector3d& vtDir, Vector3d& vtAux) const ;
int GetHeadSolCh( const std::string& sHead) const ;
int GetHeadSelectType(const std::string& sHead) const ;
double GetAngDeltaMinForHome( void) const
{ return m_dAngDeltaMinForHome ; }
bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ;
@@ -81,7 +83,7 @@ class Machine
bool GetAxisInvert( const std::string& sAxis, bool& bInvert) const ;
bool GetAxisOffset( const std::string& sAxis, double& dOffset) const ;
bool GetAxisType( const std::string& sAxis, bool& bLinear) const ;
bool SetAxisPos( const std::string& sAxis, double dVal, double* pdNewVal = nullptr) ;
bool SetAxisPos( const std::string& sAxis, double dVal, bool bInStroke = true, double* pdNewVal = nullptr) ;
bool GetAxisPos( const std::string& sAxis, double& dVal) const ;
bool GetAxisMin( const std::string& sAxis, double& dMin) const ;
bool GetAxisMax( const std::string& sAxis, double& dMax) const ;
@@ -96,6 +98,7 @@ class Machine
bool GetCurrTableArea1( BBox3d& b3Area1) const ;
bool GetCurrTableDeltaRef1( Vector3d& vtDelta1) const ;
bool GetCurrTableIsTilting( bool& bTilting, Vector3d& vtTiltingAx) const ;
bool GetCurrTableCollGroups( INTVECTOR& vIds) const ;
bool SetCurrTool( const std::string& sTool, const std::string& sHead, int nExit) ;
bool ResetCurrTool( void) ;
int GetCurrTool( void) const ;
@@ -120,9 +123,9 @@ class Machine
int GetCurrLinAxes( void) const ;
int GetCurrRotAxes( void) const ;
bool GetCurrAxisName( int nInd, std::string& sAxName) const ;
bool GetAllCurrAxesName( STRVECTOR& vAxName) const ;
bool GetAllCurrAxesNames( STRVECTOR& vAxName) const ;
bool GetCurrAxisToken( int nInd, std::string& sAxToken) const ;
bool GetAllCurrAxesToken( STRVECTOR& vAxToken) const ;
bool GetAllCurrAxesTokens( STRVECTOR& vAxToken) const ;
bool GetCurrAxisMin( int nInd, double& dMin) const ;
bool GetCurrAxisMax( int nInd, double& dMax) const ;
bool GetCurrAxisOffset( int nInd, double& dOffset) const ;
@@ -131,12 +134,16 @@ class Machine
bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ;
const Frame3d& GetCurrLinAxesFrame( void) const
{ return m_frLinAx ; }
int GetCurrKinematicChainType( void) const
{ return m_nCalcChainType ; }
bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const ;
bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const ;
bool GetPositions( const Point3d& ptP, const DBLVECTOR& vAng,
int& nStat, double& dX, double& dY, double& dZ) const ;
bool GetRobotAngles( const Point3d& ptP, const Vector3d& vtDirT, const Vector3d& vtDirA,
DBLVECTOR& vAng1, DBLVECTOR& vAng2) const ;
bool GetNoseFromPositions( double dX, double dY, double dZ, const DBLVECTOR& vAng,
Point3d& ptNose) const ;
bool GetTipFromPositions( double dX, double dY, double dZ, const DBLVECTOR& vAng,
@@ -192,7 +199,7 @@ class Machine
bool AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay) ;
bool LoadMachineTable( const std::string& sName, const std::string& sParent, int nType,
const Point3d& ptRef1, double dCoeffX, double dCoeffY, double dCoeffZ,
const std::string& sGeo, const STRVECTOR& vsAux) ;
const STRVECTOR& vsColl, const std::string& sGeo, const STRVECTOR& vsAux) ;
bool AdjustTable( int nLay, const Point3d& ptRef1) ;
bool LoadMachineAxis( const std::string& sName, const std::string& sParent, const std::string& sToken, bool bInvert,
double dOffset, int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke,
@@ -208,16 +215,19 @@ class Machine
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineMultiHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
int nSelectType, const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineSpecialHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineTcPos( const std::string& sName, const std::string& sParent,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineStdTcPos( const std::string& sName, const std::string& sParent,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineMultiTcPos( const std::string& sName, const std::string& sParent,
const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
const std::string& sGeo, const STRVECTOR& vsAux) ;
int GetGroup( const std::string& sGroup) const ;
bool IsBaseGroup( int nGroup) const ;
Axis* GetAxis( int nGroup) const ;
@@ -307,6 +317,10 @@ class Machine
KINAXISVECTOR m_vCalcLinAx ; // vettore assi lineari attivi per calcoli
KINAXISVECTOR m_vCalcRotAx ; // vettore assi rotanti attivi per calcoli
Frame3d m_frLinAx ; // sistema di riferimento definito dagli assi lineari
Frame3d m_frRobot ; // sistema di riferimento canonico del robot
int m_nCalcChainType ; // tipologia testa attiva (nulla, centro di lavoro o robot)
Point3d m_ptWristCen ; // centro del polso sferico nel riferimento testa/uscita di calcolo
Vector3d m_vtWristRef ; // direzione del polso sferico nel riferimento testa/uscita di calcolo
mutable OutStroke m_OutstrokeInfo ; // informazioni su ultima extra corsa
// stato di visualizzazione
int m_nMachineLook ; // stato di visualizzazione della macchina
@@ -325,6 +339,8 @@ class Machine
static int LuaEmtMultiHead( lua_State* L) ;
static int LuaEmtSpecialHead( lua_State* L) ;
static int LuaEmtTcPos( lua_State* L) ;
static int LuaEmtStdTcPos( lua_State* L) ;
static int LuaEmtMultiTcPos( lua_State* L) ;
static int LuaEmtModifyAxisPosition( lua_State* L) ;
static int LuaEmtModifyAxisDirection( lua_State* L) ;
static int LuaEmtModifyAxisStroke( lua_State* L) ;
+19 -5
View File
@@ -19,9 +19,26 @@
#include "/EgtDev/Include/EGkGeoVector3d.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgtNumUtils.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
Machine::GetAllAxesNames( STRVECTOR& vNames) const
{
// reset lista nomi
vNames.clear() ;
// ricerca degli assi
for ( const auto& snGro : m_mapGroups) {
if ( IsAxisGroup( snGro.second))
vNames.push_back( snGro.first) ;
}
// ordino alfabeticamente
sort( vNames.begin(), vNames.end()) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::GetAxisToken( const string& sAxis, string& sToken) const
@@ -88,7 +105,7 @@ Machine::GetAxisType( const string& sAxis, bool& bLinear) const
//----------------------------------------------------------------------------
bool
Machine::SetAxisPos( const string& sAxis, double dVal, double* pdNewVal)
Machine::SetAxisPos( const string& sAxis, double dVal, bool bInStroke, double* pdNewVal)
{
// controllo GeomDB
if ( m_pGeomDB == nullptr)
@@ -114,10 +131,7 @@ Machine::SetAxisPos( const string& sAxis, double dVal, double* pdNewVal)
Vector3d vtDir = pGV->GetVector() ;
vtDir.Normalize() ;
// limito il movimento alla corsa dell'asse
if ( dVal > Stroke.Max)
dVal = Stroke.Max ;
else if ( dVal < Stroke.Min)
dVal = Stroke.Min ;
dVal = Clamp( dVal, Stroke.Min, Stroke.Max) ;
// eseguo il movimento
if ( bLinear)
m_pGeomDB->TranslateGroup( nAxGrp, vtDir * ( dVal - dCurrVal)) ;
+311 -59
View File
@@ -24,11 +24,13 @@
#include "/EgtDev/Include/EGkGeoVector3d.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgtNumUtils.h"
using namespace std ;
//----------------------------------------------------------------------------
static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo
static const string EVAR_VER = ".VER" ; // (string) versione della Dll
static const string EVAR_TABNAME = ".TABNAME" ; // (string) nome della tavola macchina
static const string EVAR_HEAD = ".HEAD" ; // (string) nome della testa
static const string EVAR_EXIT = ".EXIT" ; // (int) numero dell'uscita
@@ -37,6 +39,7 @@ static const string EVAR_TOTDIAM = ".TOTDIAM" ; // (num) diametro di in
static const string EVAR_TOTLEN = ".TOTLEN" ; // (num) lunghezza di ingombro dell'utensile
static const string EVAR_DIST = ".DIST" ; // (num) distanza dell'utensile (per seghe a catena)
static const string EVAR_EXITPOS = ".EXITPOS" ; // (point) posizione attuale dell'uscita
static const string EVAR_USERNOTES = ".USERNOTES" ; // (string) note utente dell'utensile
static const string EVAR_TCPOS = ".TCPOS" ; // (string) posizione nell'attrezzaggio
static const string EVAR_L1 = ".L1" ; // (num) valore del primo asse lineare
static const string EVAR_L2 = ".L2" ; // (num) valore del secondo asse lineare
@@ -68,12 +71,15 @@ Machine::SetCurrTable( const string& sTable)
m_nCalcTabId = GDB_ID_NULL ;
return false ;
}
// il gruppo tavola corrente deve essere sempre visibile
m_pGeomDB->SetStatus( m_nCalcTabId, GDB_ST_ON) ;
// lancio eventuale funzione lua di personalizzazione
if ( LuaExistsFunction( ON_SET_TABLE)) {
// salvo eventuale variabile EMC_VAR già presente
bool bOldEMC = LuaChangeNameGlobVar( EMC_VAR, EMC_VAR_BACKUP) ;
// definisco variabili
bool bOk = LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_VER, GetEMkVer()) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_TABNAME, sTable) ;
// chiamo funzione
bOk = bOk && LuaCallFunction( ON_SET_TABLE) ;
@@ -208,6 +214,31 @@ Machine::GetCurrTableIsTilting( bool& bTilting, Vector3d& vtTiltingAx) const
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::GetCurrTableCollGroups( INTVECTOR& vIds) const
{
// controllo GeomDB
if ( m_pGeomDB == nullptr)
return false ;
// recupero la tavola corrente
Table* pTab = GetTable( m_nCalcTabId) ;
if ( pTab == nullptr)
return false ;
// recupero stringhe con gruppi ausiliari di collisione
const STRVECTOR& vsColl = pTab->GetCollGroups() ;
for ( const auto& sColl : vsColl) {
string sGrp, sSub ;
Split( sColl, "/", true, sGrp, sSub) ;
int nId = GetGroup( sGrp) ;
if ( ! sSub.empty() && nId != GDB_ID_NULL)
nId = m_pGeomDB->GetFirstNameInGroup( nId, sSub) ;
if ( nId != GDB_ID_NULL)
vIds.push_back( nId) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
@@ -245,6 +276,7 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
double dTOvLen = 0 ;
double dTOvDiam = 0 ;
double dTDist = 0 ;
string sTUserNotes = "" ;
string sTcPos = "" ;
// se definito
if ( ! sTool.empty()) {
@@ -263,7 +295,8 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
! m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, dTLen) ||
! m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, dTDiam) ||
! m_pMchMgr->TdbGetCurrToolParam( TPA_TOTLEN, dTOvLen) ||
! m_pMchMgr->TdbGetCurrToolParam( TPA_TOTDIAM, dTOvDiam))
! m_pMchMgr->TdbGetCurrToolParam( TPA_TOTDIAM, dTOvDiam) ||
! m_pMchMgr->TdbGetCurrToolParam( TPA_USERNOTES, sTUserNotes))
return false ;
m_pMchMgr->TdbGetCurrToolParam( TPA_DIST, dTDist) ; // opzionale
if ( ! m_pMchMgr->GetCurrSetupMgr().GetToolSetupPos( sTool, sTcPos))
@@ -303,6 +336,7 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
bool bOldEMC = LuaChangeNameGlobVar( EMC_VAR, EMC_VAR_BACKUP) ;
// definisco variabili
bool bOk = LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_VER, GetEMkVer()) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_HEAD, sHead) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_EXIT, nExit) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_TOOL, sTool) ;
@@ -310,6 +344,7 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_TOTDIAM, dTOvDiam) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_TOTLEN, dTOvLen) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_DIST, dTDist) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_USERNOTES, sTUserNotes) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_TCPOS, sTcPos) ;
// chiamo funzione
bOk = bOk && LuaCallFunction( ON_SET_HEAD) ;
@@ -458,14 +493,15 @@ Machine::CalculateKinematicChain( void)
m_nHeadSpecRotAxis = -1 ;
m_vCalcLinAx.clear() ;
m_vCalcRotAx.clear() ;
m_frLinAx.Reset( false) ;
m_frRobot.Reset( false) ;
m_nCalcChainType = KIN_CHAIN_NONE ;
// recupero gli assi di tavola
if ( m_nCalcTabId == GDB_ID_NULL)
return false ;
int nTParId = m_pGeomDB->GetParentId( m_nCalcTabId) ;
if ( nTParId == GDB_ID_NULL)
return false ;
m_nTabLinAxes = 0 ;
m_nTabRotAxes = 0 ;
while ( IsAxisGroup( nTParId)) {
if ( ! AddKinematicAxis( false, nTParId))
return false ;
@@ -477,14 +513,75 @@ Machine::CalculateKinematicChain( void)
int nHParId = m_pGeomDB->GetParentId( m_nCalcHeadId) ;
if ( nHParId == GDB_ID_NULL)
return false ;
m_nHeadLinAxes = 0 ;
m_nHeadRotAxes = 0 ;
while ( IsAxisGroup( nHParId)) {
if ( ! AddKinematicAxis( true, nHParId))
return false ;
nHParId = m_pGeomDB->GetParentId( nHParId) ;
}
// se non ci sono assi, né lineari né rotanti, sicuramente errore
if ( m_nTabLinAxes == 0 && m_nHeadLinAxes == 0 &&
m_nTabRotAxes == 0 && m_nHeadRotAxes == 0) {
LOG_ERROR( GetEMkLogger(), "Errors in Axes : none have been found")
return false ;
}
// se nessun asse lineare deve essere un robot (in futuro va permesso un lineare di tavola)
if ( m_nTabLinAxes == 0 && m_nHeadLinAxes == 0) {
// verifico ci siano 6 assi rotanti tutti di testa (in futuro va permesso un rotante di tavola)
if ( m_nTabRotAxes != 0 || m_nHeadRotAxes != 6) {
LOG_ERROR( GetEMkLogger(), "Robot with errors in Rotary Axes : number or type")
return false ;
}
// riordino gli assi rotanti
swap( m_vCalcRotAx[0], m_vCalcRotAx[5]) ;
swap( m_vCalcRotAx[1], m_vCalcRotAx[4]) ;
swap( m_vCalcRotAx[2], m_vCalcRotAx[3]) ;
// determino il riferimento canonico del robot
if ( ! m_frRobot.Set( m_vCalcRotAx[0].ptPos, m_vCalcRotAx[0].vtDir, m_vCalcRotAx[3].vtDir)) {
LOG_ERROR( GetEMkLogger(), "Robot with errors in Rotary Axes : impossible canonic frame")
return false ;
}
// porto tutti gli assi cinematici e i dati testa nel riferimento canonico
for ( int i = 0 ; i < m_nHeadRotAxes ; ++ i) {
m_vCalcRotAx[i].ptPos.ToLoc( m_frRobot) ;
m_vCalcRotAx[i].vtDir.ToLoc( m_frRobot) ;
}
m_ptCalcPos.ToLoc( m_frRobot) ;
m_vtCalcDir.ToLoc( m_frRobot) ;
m_vtCalcADir.ToLoc( m_frRobot) ;
// direzione assi rotanti deve essere Z Y Y X Y X
if ( ! m_vCalcRotAx[0].vtDir.IsZ() ||
! m_vCalcRotAx[1].vtDir.IsY() ||
! m_vCalcRotAx[2].vtDir.IsY() ||
! m_vCalcRotAx[3].vtDir.IsX() ||
! m_vCalcRotAx[4].vtDir.IsY() ||
! m_vCalcRotAx[5].vtDir.IsX()) {
LOG_ERROR( GetEMkLogger(), "Robot with errors in Rotary Axes : not ZYY-XYX")
return false ;
}
// verifico che gli ultimi 3 assi formino un polso sferico (ovvero passino per uno stesso punto)
if ( abs( m_vCalcRotAx[3].ptPos.y - m_vCalcRotAx[5].ptPos.y) > EPS_SMALL ||
abs( m_vCalcRotAx[3].ptPos.z - m_vCalcRotAx[5].ptPos.z) > EPS_SMALL ||
abs( m_vCalcRotAx[4].ptPos.z - m_vCalcRotAx[3].ptPos.z) > EPS_SMALL) {
LOG_ERROR( GetEMkLogger(), "Robot with errors in Rotary Axes : not spherical Wrist")
return false ;
}
// calcolo il centro del polso in coordinate globali (R5.x, R6.y, R5.z)
Point3d ptCenG( m_vCalcRotAx[4].ptPos.x, m_vCalcRotAx[5].ptPos.y, m_vCalcRotAx[4].ptPos.z) ;
// recupero il riferimento dell'uscita (da posizione, direzione utensile e direzione ausiliaria)
Frame3d frExit ;
if ( ! frExit.Set( m_ptCalcPos, m_vtCalcDir, m_vtCalcADir))
return false ;
// calcolo il centro del polso in locale a questo riferimento
m_ptWristCen = GetToLoc( ptCenG, frExit) ;
// calcolo la direzione di riferimento del polso in locale a questo riferimento
m_vtWristRef = GetToLoc( m_vCalcRotAx[5].vtDir, frExit) ;
// dichiaro tipo robot
m_nCalcChainType = KIN_CHAIN_ROBOT ;
return true ;
}
// verifiche sugli assi lineari :
// aggiusto gli indici di ordine sulla sua catena cinematica (1-based)
for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) {
@@ -494,8 +591,10 @@ Machine::CalculateKinematicChain( void)
m_vCalcLinAx[i].nInd *= -1 ;
}
// devono essere 3
if ( m_vCalcLinAx.size() != 3)
if ( m_vCalcLinAx.size() != 3) {
LOG_ERROR( GetEMkLogger(), "Linear Axes are not 3 in number")
return false ;
}
// devono essere ordinabili come XYZ
if ( ! m_vCalcLinAx[0].vtDir.IsX()) {
if ( m_vCalcLinAx[1].vtDir.IsX())
@@ -521,7 +620,6 @@ Machine::CalculateKinematicChain( void)
}
// verifiche sugli assi rotanti :
bool bOk = false ;
// aggiusto gli indici di ordine sulla sua catena cinematica (1-based)
for ( int i = 0 ; i < int( m_vCalcRotAx.size()) ; ++ i) {
if ( m_vCalcRotAx[i].bHead)
@@ -531,7 +629,7 @@ Machine::CalculateKinematicChain( void)
}
// se 0 o 1 va bene
if ( m_vCalcRotAx.size() <= 1)
bOk = true ;
;
// se 2 va bene
else if ( m_vCalcRotAx.size() == 2) {
// se entrambi di testa devo invertirne l'ordine
@@ -545,7 +643,6 @@ Machine::CalculateKinematicChain( void)
m_vCalcRotAx[1].stroke.Max = min( m_vCalcRotAx[1].stroke.Max, pHead->GetRot2Stroke().Max) ;
}
}
bOk = true ;
}
// se 3 va bene ( uno dovrà poi avere valore assegnato)
else if ( m_vCalcRotAx.size() == 3) {
@@ -568,10 +665,13 @@ Machine::CalculateKinematicChain( void)
m_vCalcRotAx[n2ndHeadRotAx].stroke.Max = min( m_vCalcRotAx[n2ndHeadRotAx].stroke.Max, pHead->GetRot2Stroke().Max) ;
}
}
bOk = true ;
}
if ( ! bOk)
// se più di 3
else {
// altrimenti non ancora gestito, quindi errore
LOG_ERROR( GetEMkLogger(), "Rotary Axes not manageable")
return false ;
}
// verifico esistenza eventuale asse rotante speciale di testa
if ( m_nHeadRotAxes > 0 && m_nHeadLinAxes > 0) {
// indice di posizione primo asse di testa
@@ -607,11 +707,9 @@ Machine::CalculateKinematicChain( void)
}
}
}
// dichiaro tipo centro di lavoro
m_nCalcChainType = KIN_CHAIN_CENTER ;
return true ;
// altrimenti non ancora gestito, quindi errore
LOG_ERROR( GetEMkLogger(), "Rotary Axes not manageable")
return false ;
}
//----------------------------------------------------------------------------
@@ -958,8 +1056,8 @@ Machine::GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
vtAx2.Invert() ;
// calcolo secondo angolo di rotazione
nStat = GetRotationComponent( vtDirHn, dCompTSuAxR1, vtAx1, vtAx2, dAngB1, dAngB2, bDet) ;
// se indeterminato con richiesta direzione ausiliaria esatta, ricalcolo con direzione aux
if ( nStat >= 1 && ! bDet && m_bSolChExact) {
// se indeterminato, provo ricalcolo con direzione aux
if ( nStat >= 1 && ! bDet) {
// componente versore ausiliario desiderato su direzione primo asse rotante
Vector3d vtSccDir ;
if ( GetSccDir( m_nCalcSolCh, vtDirAn, vtSccDir)) {
@@ -1183,6 +1281,10 @@ Machine::GetDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& v
vtNew.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ;
}
// nel caso di robot devo passare dal riferimento canonico robot a quello di macchina
if ( m_nCalcChainType == KIN_CHAIN_ROBOT)
vtNew.ToGlob( m_frRobot) ;
return true ;
}
@@ -1220,26 +1322,46 @@ Machine::GetNoseFromPositions( double dX, double dY, double dZ, const DBLVECTOR&
// la posizione deve essere espressa rispetto allo ZERO MACCHINA
// è espressa nel riferimento di macchina (tiene conto delle sole traslazioni e rotazioni di testa)
// aggiorno posizione testa a riposo mediante ciclo inverso sugli assi rotanti di testa
ptNose = m_ptCalcPos ;
for ( int i = int( m_vCalcRotAx.size()) - 1 ; i >= 0 ; -- i) {
// se asse di testa non speciale
if ( m_vCalcRotAx[i].bHead && i != m_nHeadSpecRotAxis)
ptNose.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
// verifico dimensione vettore angoli rispetto al numero di assi rotanti
if ( vAng.size() < m_vCalcRotAx.size())
return false ;
// se centro di lavoro
if ( m_nCalcChainType == KIN_CHAIN_CENTER) {
// aggiorno posizione testa a riposo mediante ciclo inverso sugli assi rotanti di testa
ptNose = m_ptCalcPos ;
for ( int i = int( m_vCalcRotAx.size()) - 1 ; i >= 0 ; -- i) {
// se asse di testa non speciale
if ( m_vCalcRotAx[i].bHead && i != m_nHeadSpecRotAxis)
ptNose.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
}
// aggiorno posizione testa con assi lineari di testa
DBLVECTOR vMov( {dX, dY, dZ}) ;
for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) {
if ( m_vCalcLinAx[i].bHead)
ptNose += m_vCalcLinAx[i].vtDir * vMov[i] ;
}
// eseguo rotazione eventuale asse rotante speciale di testa
if ( m_nHeadSpecRotAxis != -1) {
if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= int( m_vCalcRotAx.size()))
return false ;
int i = m_nHeadSpecRotAxis ;
ptNose.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
}
}
// aggiorno posizione testa con assi lineari di testa
DBLVECTOR vMov( {dX, dY, dZ}) ;
for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) {
if ( m_vCalcLinAx[i].bHead)
ptNose += m_vCalcLinAx[i].vtDir * vMov[i] ;
}
// eseguo rotazione eventuale asse rotante speciale di testa
if ( m_nHeadSpecRotAxis != -1) {
if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= int( m_vCalcRotAx.size()))
return false ;
int i = m_nHeadSpecRotAxis ;
ptNose.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
// se robot
else if ( m_nCalcChainType == KIN_CHAIN_ROBOT) {
// aggiorno posizione testa a riposo mediante ciclo inverso sugli assi rotanti di testa
ptNose = m_ptCalcPos ;
for ( int i = int( m_vCalcRotAx.size()) - 1 ; i >= 0 ; -- i) {
// se asse di testa
if ( m_vCalcRotAx[i].bHead)
ptNose.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
}
}
// altrimenti errore
else
return false ;
return true ;
}
@@ -1252,26 +1374,50 @@ Machine::GetTipFromPositions( double dX, double dY, double dZ, const DBLVECTOR&
// la posizione deve essere espressa rispetto allo ZERO MACCHINA
// è espressa nel riferimento di macchina (tiene conto delle sole rotazioni di testa)
// aggiorno posizione tip utensile a riposo mediante ciclo inverso sugli assi rotanti di testa
ptTip = m_ptCalcPos - m_vtCalcDir * m_dCalcTLen ;
for ( int i = int( m_vCalcRotAx.size()) - 1 ; i >= 0 ; -- i) {
// se asse di testa non speciale
if ( m_vCalcRotAx[i].bHead && i != m_nHeadSpecRotAxis)
ptTip.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
// verifico dimensione vettore angoli rispetto al numero di assi rotanti
if ( vAng.size() < m_vCalcRotAx.size())
return false ;
// se centro di lavoro
if ( m_nCalcChainType == KIN_CHAIN_CENTER) {
// aggiorno posizione tip utensile a riposo mediante ciclo inverso sugli assi rotanti di testa
ptTip = m_ptCalcPos - m_vtCalcDir * m_dCalcTLen ;
for ( int i = int( m_vCalcRotAx.size()) - 1 ; i >= 0 ; -- i) {
// se asse di testa non speciale
if ( m_vCalcRotAx[i].bHead && i != m_nHeadSpecRotAxis)
ptTip.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
}
// aggiorno posizione tip utensile con assi lineari di testa
DBLVECTOR vMov( {dX, dY, dZ}) ;
for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) {
if ( m_vCalcLinAx[i].bHead)
ptTip += m_vCalcLinAx[i].vtDir * vMov[i] ;
}
// eseguo rotazione eventuale asse rotante speciale di testa
if ( m_nHeadSpecRotAxis != -1) {
if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= int( m_vCalcRotAx.size()))
return false ;
int i = m_nHeadSpecRotAxis ;
ptTip.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
}
}
// aggiorno posizione tip utensile con assi lineari di testa
DBLVECTOR vMov( {dX, dY, dZ}) ;
for ( int i = 0 ; i < int( m_vCalcLinAx.size()) ; ++ i) {
if ( m_vCalcLinAx[i].bHead)
ptTip += m_vCalcLinAx[i].vtDir * vMov[i] ;
}
// eseguo rotazione eventuale asse rotante speciale di testa
if ( m_nHeadSpecRotAxis != -1) {
if ( m_nHeadSpecRotAxis < 0 || m_nHeadSpecRotAxis >= int( m_vCalcRotAx.size()))
return false ;
int i = m_nHeadSpecRotAxis ;
ptTip.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
// se robot
else if ( m_nCalcChainType == KIN_CHAIN_ROBOT) {
// aggiorno posizione tip utensile a riposo mediante ciclo inverso sugli assi rotanti di testa
ptTip = m_ptCalcPos - m_vtCalcDir * m_dCalcTLen ;
for ( int i = int( m_vCalcRotAx.size()) - 1 ; i >= 0 ; -- i) {
// se asse di testa
if ( m_vCalcRotAx[i].bHead)
ptTip.Rotate( m_vCalcRotAx[i].ptPos, m_vCalcRotAx[i].vtDir, vAng[i]) ;
}
}
// altrimenti errore
else
return false ;
// nel caso di robot devo passare dal riferimento canonico robot a quello di macchina
if ( m_nCalcChainType == KIN_CHAIN_ROBOT)
ptTip.ToGlob( m_frRobot) ;
// Se richiesto ingombro totale o punto sotto del tip utensile
if ( bOverall || bBottom) {
@@ -1481,10 +1627,7 @@ Machine::LimitAngleToStroke( int nInd, double& dAng) const
if ( nInd < 0 || nInd >= int( m_vCalcRotAx.size()))
return true ;
// se angolo fuori corsa, lo porto all'estremo più vicino
if ( dAng < m_vCalcRotAx[nInd].stroke.Min)
dAng = m_vCalcRotAx[nInd].stroke.Min ;
else if ( dAng > m_vCalcRotAx[nInd].stroke.Max)
dAng = m_vCalcRotAx[nInd].stroke.Max ;
dAng = Clamp( dAng, m_vCalcRotAx[nInd].stroke.Min, m_vCalcRotAx[nInd].stroke.Max) ;
return true ;
}
@@ -1579,6 +1722,7 @@ Machine::VerifyProtectedAreas( double dX, double dY, double dZ, const DBLVECTOR&
bool bOldEMC = LuaChangeNameGlobVar( EMC_VAR, EMC_VAR_BACKUP) ;
// definisco variabili
bOk = bOk && LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_VER, GetEMkVer()) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_L1, dX) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_L2, dY) ;
bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_L3, dZ) ;
@@ -1709,7 +1853,7 @@ Machine::GetCurrAxisName( int nInd, string& sAxName) const
//----------------------------------------------------------------------------
bool
Machine::GetAllCurrAxesName( STRVECTOR& vAxName) const
Machine::GetAllCurrAxesNames( STRVECTOR& vAxName) const
{
vAxName.clear() ;
bool bOk = true ;
@@ -1758,7 +1902,7 @@ Machine::GetCurrAxisToken( int nInd, string& sAxToken) const
//----------------------------------------------------------------------------
bool
Machine::GetAllCurrAxesToken( STRVECTOR& vAxToken) const
Machine::GetAllCurrAxesTokens( STRVECTOR& vAxToken) const
{
vAxToken.clear() ;
bool bOk = true ;
@@ -1920,3 +2064,111 @@ Machine::GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const
}
return bOk ;
}
//----------------------------------------------------------------------------
bool
Machine::GetRobotAngles( const Point3d& ptP, const Vector3d& vtDirT, const Vector3d& vtDirA,
DBLVECTOR& vAng1, DBLVECTOR& vAng2) const
{
// pulisco il risultato
vAng1.clear() ;
vAng2.clear() ;
// porto i dati nel riferimento robot
Point3d ptPL = GetToLoc( ptP, m_frRobot) ;
Vector3d vtDirTL = GetToLoc( vtDirT, m_frRobot) ;
Vector3d vtDirAL = GetToLoc( vtDirA, m_frRobot) ;
// riferimento utensile
Frame3d frTool ;
frTool.Set( ORIG, vtDirTL, vtDirAL) ;
// deduco la posizione richiesta del centro del polso
Point3d ptCen = ptPL + m_ptWristCen.x * frTool.VersX() +
m_ptWristCen.y * frTool.VersY() +
( m_dCalcTLen + m_ptWristCen.z) * frTool.VersZ() ;
// deduco la direzione richiesta del centro del polso
Vector3d vtCen = m_vtWristRef.x * frTool.VersX() +
m_vtWristRef.y * frTool.VersY() +
m_vtWristRef.z * frTool.VersZ() ;
// calcolo il primo asse rotante
Vector3d vtArm = ptCen - m_vCalcRotAx[0].ptPos ;
double dAng1 ; bool bDet1 ;
if ( ! X_AX.GetRotation( vtArm, m_vCalcRotAx[0].vtDir, EPS_SMALL, dAng1, bDet1) || ! bDet1) {
LOG_ERROR( GetEMkLogger(), "Error : direction unreachable (robot)")
return false ;
}
vAng1.push_back( dAng1) ;
vAng2.push_back( dAng1) ;
// calcolo secondo e terzo asse rotante
Point3d ptR2 = m_vCalcRotAx[1].ptPos ;
ptR2.Rotate( m_vCalcRotAx[0].ptPos, m_vCalcRotAx[0].vtDir, dAng1) ;
Vector3d vtR2 = m_vCalcRotAx[1].vtDir ;
vtR2.Rotate( m_vCalcRotAx[0].vtDir, dAng1) ;
Vector3d vtR2Cen = ptCen - ( ptR2 + ( ptCen - ptR2) * vtR2 * vtR2) ;
double dDistR2Cen = vtR2Cen.Len() ;
double dDistR2R3 = m_vCalcRotAx[2].ptPos.z - m_vCalcRotAx[1].ptPos.z ;
Vector3d vtR3R5 = m_vCalcRotAx[4].ptPos - m_vCalcRotAx[2].ptPos ; vtR3R5.y = 0 ;
double dDistR3R5 = vtR3R5.Len() ;
double dAngR3R5 = atan2( vtR3R5.z, vtR3R5.x) * RADTODEG ;
double dCosB = ( dDistR2R3 * dDistR2R3 + dDistR2Cen * dDistR2Cen - dDistR3R5 * dDistR3R5) / ( 2 * dDistR2R3 * dDistR2Cen) ;
double dCosC = ( dDistR3R5 * dDistR3R5 + dDistR2Cen * dDistR2Cen - dDistR2R3 * dDistR2R3) / ( 2 * dDistR3R5 * dDistR2Cen) ;
if ( abs( dCosB) > 1 || abs( dCosC) > 1) {
LOG_ERROR( GetEMkLogger(), "Error : position unreachable (robot)")
return false ;
}
double dAngB = acos( dCosB) * RADTODEG ;
double dAng2 ; bool bDet2 ;
if ( ! Z_AX.GetRotation( vtR2Cen, vtR2, EPS_SMALL, dAng2, bDet2) || ! bDet2) {
LOG_ERROR( GetEMkLogger(), "Error : R2 not calculable (robot)")
return false ;
}
dAng2 -= dAngB ;
vAng1.push_back( dAng2) ;
vAng2.push_back( dAng2) ;
double dAngC = acos( dCosC) * RADTODEG ;
double dAng3 = dAngB + dAngC + dAngR3R5 - ANG_RIGHT ;
vAng1.push_back( dAng3) ;
vAng2.push_back( dAng3) ;
// calcolo i primi due assi rotanti del polso
Frame3d frWrist ;
frWrist.Set( m_vCalcRotAx[3].ptPos, m_vCalcRotAx[3].vtDir, m_vCalcRotAx[4].vtDir ^ m_vCalcRotAx[3].vtDir) ;
frWrist.Rotate( m_vCalcRotAx[2].ptPos, m_vCalcRotAx[2].vtDir, dAng3) ;
frWrist.Rotate( m_vCalcRotAx[1].ptPos, m_vCalcRotAx[1].vtDir, dAng2) ;
frWrist.Rotate( m_vCalcRotAx[0].ptPos, m_vCalcRotAx[0].vtDir, dAng1) ;
Vector3d vtCenL = GetToLoc( vtCen, frWrist) ;
double dAng4, dAng5 ;
vtCenL.ToSpherical( nullptr, &dAng5, &dAng4) ;
if ( dAng4 > ANG_STRAIGHT)
dAng4 -= ANG_FULL ;
if ( dAng4 > ANG_RIGHT) {
dAng4 -= ANG_STRAIGHT ;
dAng5 = -dAng5 ;
}
else if ( dAng4 < -ANG_RIGHT) {
dAng4 += ANG_STRAIGHT ;
dAng5 = -dAng5 ;
}
vAng1.push_back( dAng4) ;
vAng1.push_back( dAng5) ;
vAng2.push_back( dAng4 + ( dAng4 > EPS_ANG_ZERO ? -ANG_STRAIGHT : ANG_STRAIGHT)) ;
vAng2.push_back( -dAng5) ;
// calcolo il terzo asse rotante del polso
Vector3d vtR6 = m_vCalcRotAx[5].vtDir ;
for ( int i = 4; i >= 0 ; --i)
vtR6.Rotate( m_vCalcRotAx[i].vtDir, vAng1[i]) ;
Vector3d vtTool = m_vtCalcDir ;
for ( int i = 4; i >= 0 ; --i)
vtTool.Rotate( m_vCalcRotAx[i].vtDir, vAng1[i]) ;
double dAng6 ; bool bDet6 ;
if ( ! vtTool.GetRotation( vtDirTL, vtR6, EPS_SMALL, dAng6, bDet6) || ! bDet6) {
Vector3d vtAux = m_vtCalcADir ;
for ( int i = 4; i >= 0 ; --i)
vtAux.Rotate( m_vCalcRotAx[i].vtDir, vAng1[i]) ;
if ( ! vtAux.GetRotation( vtDirAL, vtR6, EPS_SMALL, dAng6, bDet6) || ! bDet6) {
LOG_ERROR( GetEMkLogger(), "Error : R6 not calculable (robot)")
return false ;
}
}
vAng1.push_back( dAng6) ;
vAng2.push_back( dAng6 + ( dAng6 > EPS_ANG_ZERO ? -ANG_STRAIGHT : ANG_STRAIGHT)) ;
return true ;
}
+12
View File
@@ -98,6 +98,18 @@ Machine::GetHeadSolCh( const string& sHead) const
return pHead->GetSolCh() ;
}
//----------------------------------------------------------------------------
int
Machine::GetHeadSelectType( const string& sHead) const
{
// recupero testa
Head* pHead = GetHead( GetGroup( sHead)) ;
if ( pHead == nullptr)
return MCH_SCC_NONE ;
// recupero tipo di selezione delle uscite della testa
return pHead->GetSelectType() ;
}
//----------------------------------------------------------------------------
bool
Machine::LoadTool( const string& sHead, int nExit, const string& sTool)
+103 -19
View File
@@ -44,12 +44,14 @@ static const string FLD_INVERT = "Invert" ;
static const string FLD_AXIS_OFFSET = "Offset" ;
static const string FLD_REF1 = "Ref1" ;
static const string FLD_SCALE = "Scale" ;
static const string FLD_EXIT_NBR = "ExitNbr" ;
static const string FLD_POS = "Pos" ;
static const string FLD_DIR = "Dir" ;
static const string FLD_STROKE = "Stroke" ;
static const string FLD_HOME = "Home" ;
static const string FLD_ADJUSTAUX = "AdjustAux" ;
static const string FLD_HSET = "HSet" ;
static const string FLD_SEL_TYPE = "SelType" ;
static const string FLD_TDIR = "TDir" ;
static const string FLD_ADIR = "ADir" ;
static const string FLD_ROT1W = "Rot1W" ;
@@ -57,6 +59,7 @@ static const string FLD_MAXDELTAR2ON1 = "MaxDeltaR2OnFirst" ;
static const string FLD_ROT2STROKE = "Rot2Stroke" ;
static const string FLD_SOLCH = "SolCh" ;
static const string FLD_OTHCOLL = "OthColl" ;
static const string FLD_COLL = "Coll" ;
//----------------------------------------------------------------------------
Machine* Machine::m_pMchLua = nullptr ;
@@ -450,6 +453,9 @@ Machine::LuaEmtTable( lua_State* L)
// lettura eventuale campo 'Scale' dalla tabella
double vScale[3] = {1.0, 1.0, 1.0} ;
LuaGetTabFieldParam( L, 1, FLD_SCALE, vScale) ;
// lettura eventuale campo 'Coll' dalla tabella
STRVECTOR vsColl ;
LuaGetTabFieldParam( L, 1, FLD_COLL, vsColl) ;
// lettura campo 'Geo' dalla tabella
string sGeo ;
LuaCheckTabFieldParam( L, 1, FLD_GEO, sGeo)
@@ -467,7 +473,7 @@ Machine::LuaEmtTable( lua_State* L)
return luaL_error( L, " Unknown Machine") ;
// carico i dati della tavola
if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, Ref1, vScale[0], vScale[1], vScale[2], sGeo, vsAux))
if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, Ref1, vScale[0], vScale[1], vScale[2], vsColl, sGeo, vsAux))
return luaL_error( L, " Load Machine Table failed") ;
// restituisco l'indice della tavola
@@ -659,9 +665,12 @@ Machine::LuaEmtMultiHead( lua_State* L)
// lettura campo 'HSet' dalla tabella
string sHSet ;
LuaCheckTabFieldParam( L, 1, FLD_HSET, sHSet)
// lettura eventuale campo tipo di selezione ammessa per le uscite
int nSelectType = MCH_SLT_FIXEDEXITS ;
LuaGetTabFieldParam( L, 1, FLD_SEL_TYPE, nSelectType) ;
// lettura campo 'ExitNbr' dalla tabella
int nExitNbr ;
LuaCheckTabFieldParam( L, 1, "ExitNbr", nExitNbr)
LuaCheckTabFieldParam( L, 1, FLD_EXIT_NBR, nExitNbr)
// lettura campi 'PosN' e 'TDirN' per ogni uscita dalla tabella
MUEXITVECTOR vMuExit ;
vMuExit.reserve( nExitNbr) ;
@@ -676,7 +685,7 @@ Machine::LuaEmtMultiHead( lua_State* L)
// inserimento nell'array
vMuExit.emplace_back( ptPos, vtTDir) ;
}
// lettura campo 'ADir' dalla tabella
// lettura eventuale campo 'ADir' dalla tabella
Vector3d vtADir ;
LuaGetTabFieldParam( L, 1, FLD_ADIR, vtADir) ;
// lettura eventuale campo 'Rot1W' dalla tabella (default 1)
@@ -711,9 +720,9 @@ Machine::LuaEmtMultiHead( lua_State* L)
return luaL_error( L, " Unknown Machine") ;
// carico i dati della testa multipla
if ( ! m_pMchLua->LoadMachineMultiHead( sName, sParent, sHSet, vMuExit, vtADir,
if ( ! m_pMchLua->LoadMachineMultiHead( sName, sParent, sHSet, nSelectType, vMuExit, vtADir,
dRot1W, bMaxDeltaR2On1, Rot2Stroke, nSolCh, vsOthColl, sGeo, vsAux))
return luaL_error( L, " Load Machine Standard Head failed") ;
return luaL_error( L, " Load Machine Multi Head failed") ;
// restituisco l'indice della testa
int nHeadId = m_pMchLua->GetHeadId( sName) ;
@@ -797,6 +806,26 @@ Machine::LuaEmtSpecialHead( lua_State* L)
//----------------------------------------------------------------------------
int
Machine::LuaEmtTcPos( lua_State* L)
{
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
return luaL_error( L, " Invalid Parameter, required a table") ;
// lettura campo opzionale 'ExitNbr' dalla tabella
int nExitNbr = 1 ;
LuaGetTabFieldParam( L, 1, FLD_EXIT_NBR, nExitNbr) ;
// Procedo alla lettura a seconda del tnumero di uscite
if ( nExitNbr == 1)
return LuaEmtStdTcPos( L) ;
else if ( nExitNbr > 1)
return LuaEmtMultiTcPos( L) ;
else
return luaL_error( L, " Tc Position type unknown") ;
}
//----------------------------------------------------------------------------
int
Machine::LuaEmtStdTcPos( lua_State* L)
{
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
@@ -833,8 +862,70 @@ Machine::LuaEmtTcPos( lua_State* L)
return luaL_error( L, " Unknown Machine") ;
// carico i dati della posizione cambio utensile
if ( ! m_pMchLua->LoadMachineTcPos( sName, sParent, ptPos, vtTDir, vtADir, sGeo, vsAux))
return luaL_error( L, " Load Machine Tc Position failed") ;
if ( ! m_pMchLua->LoadMachineStdTcPos( sName, sParent, ptPos, vtTDir, vtADir, sGeo, vsAux))
return luaL_error( L, " Load Machine Standard Tc Position failed") ;
// restituisco l'indice della posizione cambio utensile
int nTcPosId = m_pMchLua->GetTcPosId( sName) ;
if ( nTcPosId != GDB_ID_NULL)
LuaSetParam( L, nTcPosId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
int
Machine::LuaEmtMultiTcPos( lua_State* L)
{
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
return luaL_error( L, " Invalid Parameter, required a table") ;
// lettura campo 'Name' dalla tabella
string sName ;
LuaCheckTabFieldParam( L, 1, FLD_NAME, sName)
// lettura campo 'Parent' dalla tabella
string sParent ;
LuaCheckTabFieldParam( L, 1, FLD_PARENT, sParent)
// lettura campo 'ExitNbr' dalla tabella
int nExitNbr ;
LuaCheckTabFieldParam( L, 1, FLD_EXIT_NBR, nExitNbr)
// lettura campi 'PosN' e 'TDirN' per ogni uscita dalla tabella
MUEXITVECTOR vMuExit ;
vMuExit.reserve( nExitNbr) ;
for ( int i = 0 ; i < nExitNbr ; ++ i) {
// lettura
string sPos = FLD_POS + ToString( i + 1) ;
Point3d ptPos ;
LuaCheckTabFieldParam( L, 1, sPos.c_str(), ptPos)
string sTDir = FLD_TDIR + ToString( i + 1) ;
Vector3d vtTDir ;
LuaCheckTabFieldParam( L, 1, sTDir.c_str(), vtTDir)
// inserimento nell'array
vMuExit.emplace_back( ptPos, vtTDir) ;
}
// lettura eventuale campo 'ADir' dalla tabella
Vector3d vtADir ;
LuaGetTabFieldParam( L, 1, FLD_ADIR, vtADir) ;
// lettura campo 'Geo' dalla tabella
string sGeo ;
LuaCheckTabFieldParam( L, 1, FLD_GEO, sGeo)
// lettura eventuale campo 'Aux' dalla tabella
STRVECTOR vsAux ;
LuaGetTabFieldParam( L, 1, FLD_AUX, vsAux) ;
LuaClearStack( L) ;
// info
string sOut = "LuaEmtTcPos : " + sName ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str())
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// carico i dati della posizione cambio utensile
if ( ! m_pMchLua->LoadMachineMultiTcPos( sName, sParent, vMuExit, vtADir, sGeo, vsAux))
return luaL_error( L, " Load Machine Multi Tc Position failed") ;
// restituisco l'indice della posizione cambio utensile
int nTcPosId = m_pMchLua->GetTcPosId( sName) ;
@@ -1395,19 +1486,12 @@ Machine::LuaEmtAddToolForVmill( lua_State* L)
int
Machine::LuaEmtMoveAxes( lua_State* L)
{
// 4, ..., 16 parametri : nMoveType, sAx1, dPos1, dStep1 [, sAx2, dPos2, dStep2] [, sAx3, dPos3, dStep3] [, sAx4, dPos4, dStep4] [, sAx5, dPos5, dStep5]
int nMoveType ;
LuaCheckParam( L, 1, nMoveType)
string sAx1 ;
LuaCheckParam( L, 2, sAx1) ;
double dEnd1 ;
LuaCheckParam( L, 3, dEnd1) ;
double dStep1 ;
LuaCheckParam( L, 4, dStep1) ;
// 4, ..., 31 parametri : nMoveType, sAx1, dPos1, dStep1 [, sAx2, dPos2, dStep2] ... [, sAx10, dPos10, dStep10]
int nMoveType = 0 ;
LuaGetParam( L, 1, nMoveType) ;
SAMVECTOR vAxNaEpSt ;
vAxNaEpSt.emplace_back( sAx1, dEnd1, dStep1) ;
for ( int i = 0 ; i < 4 ; ++ i) {
int nInd = 5 + 3 * i ;
for ( int i = 0 ; i < 10 ; ++ i) {
int nInd = 2 + 3 * i ;
string sAxN ;
double dEndN ;
double dStepN ;
+16 -4
View File
@@ -31,7 +31,7 @@ using namespace std ;
int
Machine::LuaEmtAddRapidStart( lua_State* L)
{
// 6 parametri : nPathId, ptP, vtTool, vtCorr, vtAux, nFlag
// 6 o 7 parametri : nPathId, ptP, vtTool, vtCorr, vtAux, nFlag [, bToolShow]
int nPathId ;
LuaCheckParam( L, 1, nPathId)
Point3d ptP ;
@@ -44,6 +44,8 @@ Machine::LuaEmtAddRapidStart( lua_State* L)
LuaCheckParam( L, 5, vtAux)
int nFlag ;
LuaCheckParam( L, 6, nFlag)
bool bToolShow = false ;
LuaGetParam( L, 7, bToolShow) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva valida
if ( m_pMchLua == nullptr ||
@@ -69,6 +71,7 @@ Machine::LuaEmtAddRapidStart( lua_State* L)
pCam->SetEndPoint( ptP) ;
pCam->SetFeed( 0) ;
pCam->SetFlag( nFlag) ;
pCam->SetToolShow( bToolShow) ;
// associo questo oggetto a quello geometrico
m_pMchLua->m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
}
@@ -84,7 +87,7 @@ Machine::LuaEmtAddRapidStart( lua_State* L)
int
Machine::LuaEmtAddRapidMove( lua_State* L)
{
// 7 parametri : nPathId, ptIni, ptFin, vtTool, vtCorr, vtAux, nFlag
// 7 o 8 parametri : nPathId, ptIni, ptFin, vtTool, vtCorr, vtAux, nFlag [, bToolShow]
int nPathId ;
LuaCheckParam( L, 1, nPathId)
Point3d ptIni ;
@@ -99,6 +102,8 @@ Machine::LuaEmtAddRapidMove( lua_State* L)
LuaCheckParam( L, 6, vtAux)
int nFlag ;
LuaCheckParam( L, 7, nFlag)
bool bToolShow = false ;
LuaGetParam( L, 8, bToolShow) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva valida
if ( m_pMchLua == nullptr ||
@@ -124,6 +129,7 @@ Machine::LuaEmtAddRapidMove( lua_State* L)
pCam->SetEndPoint( ptFin) ;
pCam->SetFeed( 0) ;
pCam->SetFlag( nFlag) ;
pCam->SetToolShow( bToolShow) ;
// associo questo oggetto a quello geometrico
m_pMchLua->m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
}
@@ -139,7 +145,7 @@ Machine::LuaEmtAddRapidMove( lua_State* L)
int
Machine::LuaEmtAddLinearMove( lua_State* L)
{
// 8 parametri : nPathId, ptIni, ptFin, vtTool, vtCorr, vtAux, dFeed, nFlag
// 8 o 9 parametri : nPathId, ptIni, ptFin, vtTool, vtCorr, vtAux, dFeed, nFlag [, bToolShow]
int nPathId ;
LuaCheckParam( L, 1, nPathId)
Point3d ptIni ;
@@ -156,6 +162,8 @@ Machine::LuaEmtAddLinearMove( lua_State* L)
LuaCheckParam( L, 7, dFeed)
int nFlag ;
LuaCheckParam( L, 8, nFlag)
bool bToolShow = false ;
LuaGetParam( L, 9, bToolShow) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva valida
if ( m_pMchLua == nullptr ||
@@ -181,6 +189,7 @@ Machine::LuaEmtAddLinearMove( lua_State* L)
pCam->SetEndPoint( ptFin) ;
pCam->SetFeed( dFeed) ;
pCam->SetFlag( nFlag) ;
pCam->SetToolShow( bToolShow) ;
// associo questo oggetto a quello geometrico
m_pMchLua->m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
}
@@ -196,7 +205,7 @@ Machine::LuaEmtAddLinearMove( lua_State* L)
int
Machine::LuaEmtAddArcMove( lua_State* L)
{
// 11 parametri : nPathId, ptIni, ptFin, ptCen, dAngCen, vtN, vtTool, vtCorr, vtAux, dFeed, nFlag
// 11 o 12 parametri : nPathId, ptIni, ptFin, ptCen, dAngCen, vtN, vtTool, vtCorr, vtAux, dFeed, nFlag [, bToolShow]
int nPathId ;
LuaCheckParam( L, 1, nPathId)
Point3d ptIni ;
@@ -219,6 +228,8 @@ Machine::LuaEmtAddArcMove( lua_State* L)
LuaCheckParam( L, 10, dFeed)
int nFlag ;
LuaCheckParam( L, 11, nFlag)
bool bToolShow = false ;
LuaGetParam( L, 12, bToolShow) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva valida
if ( m_pMchLua == nullptr ||
@@ -252,6 +263,7 @@ Machine::LuaEmtAddArcMove( lua_State* L)
pCam->SetNormDir( vtN) ;
pCam->SetFeed( dFeed) ;
pCam->SetFlag( nFlag) ;
pCam->SetToolShow( bToolShow) ;
// associo questo oggetto a quello geometrico
m_pMchLua->m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
}
+14 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2024
//----------------------------------------------------------------------------
// File : MachineStruConst.h Data : 25.05.15 Versione : 1.6e7
// File : MachineStruConst.h Data : 15.01.24 Versione : 2.5l6
// Contenuto : Strutture e costanti di macchina.
//
//
@@ -88,6 +88,18 @@ enum MchHeadType { MCH_HT_NONE = 0,
MCH_HT_MULTI = 2,
MCH_HT_SPECIAL = 3} ;
//----------------------------------------------------------------------------
// Tipo di selezione ammessa per le uscite
enum MchSelType { MCH_SLT_FIXEDEXITS = 0,
MCH_SLT_ONEEXIT = 1,
MCH_SLT_MULTIEXITS = 2} ;
//----------------------------------------------------------------------------
// Tipo della catena cinematica
enum KinChainType { KIN_CHAIN_NONE = 0,
KIN_CHAIN_CENTER = 1,
KIN_CHAIN_ROBOT = 2} ;
//----------------------------------------------------------------------------
// Identificativo iniziale riferimenti di tavola
const std::string MCH_TREF = "R" ;
+9
View File
@@ -148,6 +148,15 @@ Machining::PrepareToolPreview( void) const
int nId = m_pGeomDB->CopyGlob( nHeadId, GDB_ID_NULL, nStId) ;
m_pGeomDB->SetMode( nId, GDB_MD_STD) ;
m_pGeomDB->SetStatus( nId, GDB_ST_OFF) ;
// elimino eventuali gruppi opportunamente indicati
int nSubId = m_pGeomDB->GetFirstGroupInGroup( nId) ;
while ( nSubId != GDB_ID_NULL) {
int nNextSubId = m_pGeomDB->GetNextGroup( nSubId) ;
bool bShow = true ;
if ( m_pGeomDB->GetInfo( nSubId, KEY_PREVIEWSHOW, bShow) && ! bShow)
m_pGeomDB->Erase( nSubId) ;
nSubId = nNextSubId ;
}
return ( nId != GDB_ID_NULL) ;
}
+10 -1
View File
@@ -103,7 +103,11 @@ GetMachiningTitle( int nMchType)
"SawRoughing",
"SawFinishing",
"GenMachining",
"Chiseling"} ;
"Chiseling",
"SurfRoughing",
"SurfFinishing",
"Waterjetting",
"5axMachining"} ;
switch ( nMchType) {
case MT_DRILLING : return MchTitle[1] ;
case MT_SAWING : return MchTitle[2] ;
@@ -114,6 +118,11 @@ GetMachiningTitle( int nMchType)
case MT_SAWFINISHING : return MchTitle[7] ;
case MT_GENMACHINING : return MchTitle[8] ;
case MT_CHISELING : return MchTitle[9] ;
case MT_SURFROUGHING : return MchTitle[10] ;
case MT_SURFFINISHING : return MchTitle[11] ;
case MT_WATERJETTING : return MchTitle[12] ;
case MT_5AXMACHINING : return MchTitle[13] ;
}
return MchTitle[0] ;
}
+27 -3
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2022
// EgalTech 2015-2024
//----------------------------------------------------------------------------
// File : MachiningsMgr.cpp Data : 04.02.22 Versione : 2.4b1
// File : MachiningsMgr.cpp Data : 29.03.24 Versione : 2.6d1
// Contenuto : Implementazione gestore database lavorazioni.
//
//
@@ -16,6 +16,7 @@
// 22.06.20 DS Agg. per nuovi parametri attacco tagli di lama (MF_CURR_VER = 1010).
// 09.11.20 DS Agg. per nuovi parametri tagli di lama (MF_CURR_VER = 1011).
// 04.02.22 DS Agg. per nuovi parametri svuotature con epicicli (MF_CURR_VER = 1012).
// 29.03.24 DS Agg. parametro APPROX_LINTOL (MF_CURR_VER = 1013).
//
//----------------------------------------------------------------------------
@@ -42,7 +43,7 @@ const string MF_HEADER = "[HEADER]" ;
const string MF_VERSION = "VERSION" ;
const string MF_TOTAL = "TOTAL" ;
const string MF_SIZE = "SIZE" ;
const int MF_CURR_VER = 1012 ;
const int MF_CURR_VER = 1013 ;
const string MF_GENERAL = "[GENERAL]" ;
const string MF_3AXCOMP = "3AXCOMP" ;
const bool MF_CURR_3AXCOMP = false ;
@@ -64,6 +65,8 @@ const string MF_INTSAWARCMAXSIDEANG = "INTSAWARCMAXSIDEANG" ;
const double MF_CURR_INTSAWARCMAXSIDEANG = 45 ;
const string MF_SPLITARCS = "SPLITARCS" ;
const int MF_CURR_SPLITARCS = SPLAR_NEVER ;
const string MF_APPROX_LINTOL = "APPROX_LINTOL" ;
const double MF_CURR_APPROX_LINTOL = 0.05 ;
const string MF_MAXDEPTHSAFE = "MAXDEPTHSAFE" ;
const double MF_CURR_MAXDEPTHSAFE = 2.0 ;
@@ -85,6 +88,7 @@ MachiningsMgr::MachiningsMgr( void)
m_dExtSawArcMinRad = MF_CURR_EXTSAWARCMINRAD ;
m_dIntSawArcMaxSideAng = MF_CURR_INTSAWARCMAXSIDEANG ;
m_nSplitArcs = MF_CURR_SPLITARCS ;
m_dApproxLinTol = MF_CURR_APPROX_LINTOL ;
m_dMaxDepthSafe = MF_CURR_MAXDEPTHSAFE ;
}
@@ -312,6 +316,8 @@ MachiningsMgr::LoadGeneral( Scanner& TheScanner, bool& bEnd)
bOk = FromString( sVal, m_dIntSawArcMaxSideAng) ;
else if ( ToUpper( sKey) == MF_SPLITARCS)
bOk = FromString( sVal, m_nSplitArcs) ;
else if ( ToUpper( sKey) == MF_APPROX_LINTOL)
bOk = FromString( sVal, m_dApproxLinTol) ;
else if ( ToUpper( sKey) == MF_MAXDEPTHSAFE)
bOk = FromString( sVal, m_dMaxDepthSafe) ;
else
@@ -499,6 +505,10 @@ MachiningsMgr::SaveGeneral( Writer& TheWriter) const
sOut = MF_MAXDEPTHSAFE + "=" + ToString( m_dMaxDepthSafe) ;
bOk = bOk && TheWriter.OutText( sOut) ;
}
if ( m_nDbVer >= 1013) {
sOut = MF_APPROX_LINTOL + "=" + ToString( m_dApproxLinTol) ;
bOk = bOk && TheWriter.OutText( sOut) ;
}
return bOk ;
}
@@ -1175,6 +1185,20 @@ MachiningsMgr::SetSplitArcs( int nFlag)
return true ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SetApproxLinTol( double dLinTol)
{
// verifico non sia inferiore al minimo
dLinTol = max( dLinTol, EPS_SMALL) ;
// se cambiato, salvo e setto modifica
if ( abs( dLinTol - m_dApproxLinTol) > EPS_SMALL) {
m_dApproxLinTol = dLinTol ;
m_bModified = true ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SetMaxDepthSafe( double dSafe)
+6 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2024
//----------------------------------------------------------------------------
// File : MachiningsMgr.h Data : 02.06.15 Versione : 1.6f1
// File : MachiningsMgr.h Data : 29.03.24 Versione : 2.6d1
// Contenuto : Dichiarazione della classe MachiningsMgr.
//
//
@@ -79,6 +79,9 @@ class MachiningsMgr
bool SetSplitArcs( int nFlag) ;
int GetSplitArcs( void) const
{ return m_nSplitArcs ; }
bool SetApproxLinTol( double dLinTol) ;
double GetApproxLinTol( void) const
{ return m_dApproxLinTol ; }
bool SetMaxDepthSafe( double dSafe) ;
double GetMaxDepthSafe( void) const
{ return m_dMaxDepthSafe ; }
@@ -131,5 +134,6 @@ class MachiningsMgr
double m_dExtSawArcMinRad ;
double m_dIntSawArcMaxSideAng ;
int m_nSplitArcs ;
double m_dApproxLinTol ;
double m_dMaxDepthSafe ;
} ;
+1335 -762
View File
File diff suppressed because it is too large Load Diff
+23 -11
View File
@@ -85,7 +85,7 @@ class Milling : public Machining
bool AdjustPathDrawForSaw( int nClPathId) ;
bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ;
bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ;
bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) ;
bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo, double dRbDist, double dDepth) ;
bool AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ;
bool AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dElev,
@@ -96,22 +96,26 @@ class Milling : public Machining
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ;
bool AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
bool AddSawOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool,
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr, bool bOutStart, bool bAboveStart) ;
bool AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, double dSafeZ, double dStElev, double dAppr) ;
bool AddDirectApproach( const Point3d& ptP) ;
double dElev, double dAppr, bool bOutStart, bool bAboveStart, bool bFirst, bool bSplitArcs) ;
bool AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, const Vector3d& vtTool,
double dSafeZ, double dSawStElev, double dStElev, double dAppr,
bool bFirst, bool bSplitArcs, bool bAddInsert = false) ;
bool AddDirectApproach( const Point3d& ptP, bool bSplitArcs) ;
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr, bool bAboveEnd) ;
double dElev, double dAppr, bool bAboveEnd, bool bSplitArcs) ;
bool AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, const Vector3d& vtTool,
double dSafeZ, double dEndElev, double dAppr) ;
double dSafeZ, double dSawEndElev, double dEndElev, double dAppr, bool bAddExtract = false) ;
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool,
double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) const ;
double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1, Vector3d& vtDir1) const ;
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart,
const Vector3d& vtTool, bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs) ;
const Vector3d& vtTool, double dStElev, bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs) ;
bool CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool,
double dEndElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) const ;
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, double dEndElev,
bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs, Point3d& ptP1) ;
bool bInvert, const ICurveComposite* pCompo, bool bSplitArcs, Point3d& ptP1, Vector3d& vtDir1) ;
bool AdjustOscillParams( const ICurve* pCrv, bool& bPathOscEnable, double& dRampLen, double& dFlatLen) ;
bool AddOscillLine( const ICurveLine* pLine, const Vector3d& vtTool, double dRampLen, double dFlatLen) ;
bool AddOscillArc( const ICurveArc* pArc, const Vector3d& vtTool, double dRampLen, double dFlatLen) ;
@@ -120,11 +124,14 @@ class Milling : public Machining
bool AddTabsLine( const ICurveLine* pLine, const Vector3d& vtTool, const DBLVECTOR& vdTabs, const TabData& tdTabs) ;
bool AddTabsArc( const ICurveArc* pArc, const Vector3d& vtTool, const DBLVECTOR& vdTabs, const TabData& tdTabs) ;
double GetRadiusForStartEndElevation( bool bExtra = true) const ;
bool GetSimplePointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool, const Vector3d& vtCorr) const ;
bool GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, double dSafeZ) const ;
bool GetPointAboveRaw( const Point3d& ptP, const Vector3d& vtTool) const ;
bool CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU) ;
Vector3d CalcCorrDir( const ICurveComposite* pCompo, double dU) ;
bool GetPointBelowRaw( const Point3d& ptP, const Vector3d& vtTool) const ;
bool CalcAndSetCorrAuxDir( const ICurveComposite* pCompo, double dU, bool bInvertSide = false, bool bSawSpecial = false) ;
Vector3d CalcCorrDir( const ICurveComposite* pCompo, double dU, bool bInvertSide = false, bool bSawSpecial = false) ;
bool CalcOffset( ICurveComposite* pCompo, double dSignOffs) ;
bool TrimExtendCurveToClosedStm( ICurveComposite* pCompo, int nCstmId, bool bInvert) ;
private :
double GetSpeed() const
@@ -146,6 +153,9 @@ class Milling : public Machining
bool IsLeadInHelixOrZigzag() const
{ int nType = GetLeadInType() ;
return ( nType == MILL_LI_ZIGZAG || nType == MILL_LI_HELIX) ; }
bool IsLeadInHelixOrZigzagOrGlide() const
{ int nType = GetLeadInType() ;
return ( nType == MILL_LI_ZIGZAG || nType == MILL_LI_HELIX || nType == MILL_LI_GLIDE) ; }
bool LeadInRawIsOk( void) const
{ if ( ( m_TParams.m_nType & TF_SAWBLADE) != 0)
return false ;
@@ -177,4 +187,6 @@ class Milling : public Machining
double m_dCurrTabsLen ; // lunghezza corrente lungo il percorso per tabs
bool m_bStartOutRaw ; // flag forzatura inizio fuori dal grezzo
bool m_bEndOutRaw ; // flag forzatura fine fuori dal grezzo
Vector3d m_vtStartDir ; // direzione iniziale del percorso in elaborazione
Vector3d m_vtEndDir ; // direzione finale del percorso in elaborazione
} ;
+6 -2
View File
@@ -110,6 +110,10 @@ struct MillingData : public MachiningData
//----------------------------------------------------------------------------
inline const MillingData* GetMillingData( const MachiningData* pMdata)
{ return (dynamic_cast<const MillingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_MILLING)
return nullptr ;
return ( static_cast<const MillingData*>( pMdata)) ; }
inline MillingData* GetMillingData( MachiningData* pMdata)
{ return (dynamic_cast<MillingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_MILLING)
return nullptr ;
return ( static_cast<MillingData*>( pMdata)) ; }
+4 -1
View File
@@ -634,6 +634,9 @@ Mortising::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
SetBlockedRotAxis( m_Params.m_sBlockedAxis) ;
@@ -1567,7 +1570,7 @@ Mortising::GenerateOnePlungeCl( const Point3d& ptStart, const Point3d& ptEnd, co
int nFirstFlag = ( bFirst ? 1 : 0) ;
SetFlag( nFirstFlag) ;
Point3d ptP1 = ( nPlunge != MORTISE_PLUNGE_END ? ptStart : ptEnd) + vtTool * ( dDelta + dStartElev + dSafeZ) ;
int nStart = ( bFirst ? AddRapidStart( ptP1) : AddRapidMove( ptP1)) ;
int nStart = AddRapidStartOrMove( ptP1, bFirst) ;
if ( nStart == GDB_ID_NULL)
return false ;
SetFlag( 0) ;
+6 -2
View File
@@ -77,6 +77,10 @@ struct MortisingData : public MachiningData
//----------------------------------------------------------------------------
inline const MortisingData* GetMortisingData( const MachiningData* pMdata)
{ return (dynamic_cast<const MortisingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_MORTISING)
return nullptr ;
return ( static_cast<const MortisingData*>( pMdata)) ; }
inline MortisingData* GetMortisingData( MachiningData* pMdata)
{ return (dynamic_cast<MortisingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_MORTISING)
return nullptr ;
return ( static_cast<MortisingData*>( pMdata)) ; }
+1256 -528
View File
File diff suppressed because it is too large Load Diff
+56 -7
View File
@@ -14,6 +14,7 @@
#pragma once
#include "MachMgr.h"
#include "MachConst.h"
#include "MachineStruConst.h"
#include "/EgtDev/Include/EGkPoint3d.h"
@@ -21,7 +22,6 @@
#include "/EgtDev/Include/EGkSelection.h"
#include "/EgtDev/Include/EgtNumCollection.h"
class MachMgr ;
class CamData ;
class ICurve ;
class ICurveComposite ;
@@ -43,7 +43,7 @@ class Operation : public IUserObj
virtual int GetPhase( void) const
{ return m_nPhase ; }
virtual bool RemoveHome( void) ;
std::string GetName( void) const ;
std::string GetName( void) const ;
public :
virtual int GetType( void) const = 0 ;
@@ -61,6 +61,21 @@ class Operation : public IUserObj
{ return true ; }
virtual bool AdjustArcCenterForAxesCalc( const CamData* pCamData, Point3d& ptCen) const
{ return true ; }
virtual bool NeedSplit( bool bSplit = true, bool bFeed = true) const
{ return ( bSplit && ( m_pMchMgr == nullptr || m_pMchMgr->GetCurrIsRobot())) ; }
virtual double GetMaxSplitLen( bool bSplit = true, bool bFeed = true) const
{ return ( bSplit && ( m_pMchMgr == nullptr || m_pMchMgr->GetCurrIsRobot()) ? ( bFeed ? 5 : 50) : 0) ; }
virtual bool GetSplitArcs( const Vector3d& vtTool) const
{ if ( m_pMchMgr == nullptr || m_pMchMgr->GetCurrIsRobot())
return true ;
int nSplitArcs = m_pMchMgr->GetCurrMachiningsMgr()->GetSplitArcs() ;
return ( nSplitArcs == SPLAR_ALWAYS ||
( nSplitArcs == SPLAR_NO_XY_PLANE && ! vtTool.IsZplus()) ||
( nSplitArcs == SPLAR_GEN_PLANE && vtTool.IsGeneric())) ; }
virtual double GetApproxLinTol( void) const
{ if ( m_pMchMgr == nullptr)
return 50 * EPS_SMALL ;
return m_pMchMgr->GetCurrMachiningsMgr()->GetApproxLinTol() ; }
protected :
Operation( void) ;
@@ -83,6 +98,8 @@ class Operation : public IUserObj
const Vector3d& vtDir, double& dElev) const ;
bool GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, double dRad, double dLen,
const Vector3d& vtDir, double& dElev) const ;
bool GetElevation( int nPhase, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtTool, double dRad, double dLen,
const Vector3d& vtDir, double& dElev) const ;
bool GetAhPointUnderRaw( const Point3d& ptP, const Vector3d& vtTool, double dToolRad, double dToolRadForElev,
double dToolLen, bool bIsSaw, double dSafeZ, const Vector3d& vtDir, double& dElev) const ;
bool GetUhPointAboveRaw( const Point3d& ptP, const Vector3d& vtTool, double dToolRad, double dToolRadForElev,
@@ -99,15 +116,18 @@ class Operation : public IUserObj
bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist, double& dAllRbDist) const ;
bool GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw) const ;
bool GetRawGlobBox( int nPhase, const BBox3d& b3Test, double dToler, BBox3d& b3Raw) const ;
bool GetCurrRawsGlobBox( BBox3d& b3Raw) const ;
bool AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nFaceUse, double dToolThick, int nGrade = 3) ;
bool ApproxWithArcsIfUseful( ICurveComposite* pCompo, bool bCareTempProp = false) const ;
bool ApproxWithLines( ICurveComposite* pCompo) const ;
bool ApproxWithLines( ICurveComposite* pCompo, bool bFeed = true) const ;
bool VerifyArcs( ICurveComposite* pCompo, double dMaxAngCen = MAX_ANG_CEN) const ;
bool CalcAndSetBBox( int nClId) ;
bool CalcAndSetAxesBBox( void) ;
bool CalcMirrorByDouble( int nClId, const std::string& sUserNotes) ;
bool GetInitialAxesValues( bool bSkipClimb, DBLVECTOR& vAxVal) const ;
bool GetClPathInitialAxesValues( int nClPathId, bool bSkipClimb, DBLVECTOR& vAxVal) const ;
bool GetFinalAxesValues( bool bSkipRise, DBLVECTOR& vAxVal) const ;
@@ -124,9 +144,15 @@ class Operation : public IUserObj
std::string ExtractHint( const std::string& sNotes) const ;
bool SetBlockedRotAxis( const std::string& sBlockedAxis) const ;
bool CalculateAxesValues( const std::string& sHint, bool bRotContOnNext = true, bool bSolChExact = false) ;
bool CalculateClPathCenterAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W,
bool bMaxDeltaR2OnFirst, bool bRotContOnNext, double dAngDeltaMinForHome,
const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec) ;
bool CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W,
bool bMaxDeltaR2OnFirst, bool bRotContOnNext, double dAngDeltaMinForHome,
const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec, int& nOutStrC) ;
bool CalculateClPathRobotAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W,
bool bMaxDeltaR2OnFirst, bool bRotContOnNext, double dAngDeltaMinForHome,
const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec) ;
bool AdjustStartEndMovements( bool bVerifyPreviousLink = true) ;
bool AdjustOneStartMovement( int nClPathId, int nPrevClPathId, Operation* pPrevOp, const DBLVECTOR& vAxPrev, bool bMaxZ) ;
bool ToolChangeNeeded( const Operation& Op1, const Operation& Op2) const ;
@@ -135,6 +161,10 @@ class Operation : public IUserObj
bool AddSpecialRise( const DBLVECTOR& vAxVal, bool bOk = true, int nClPathId = GDB_ID_NULL, int nFlag = 0) ;
bool RemoveRise( int nClPathId = GDB_ID_NULL) ;
bool AddHome( void) ;
bool RemoveClimbRiseHome( void) ;
bool AddRobotClimb( int nEntId, double dDeltaZ) ;
bool CalcRobotAxesAbovePos( const Point3d& ptP, const Vector3d& vtT, const Vector3d& vtA, double dDeltaZ,
DBLVECTOR& vAx, double* pdNewDeltaZ = nullptr) const ;
bool CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, double& dDeltaZ) const ;
bool GetExtraZ( const DBLVECTOR& vAx1, const Vector3d& vtTool1,
const DBLVECTOR& vAx2, const Vector3d& vtTool2,
@@ -143,14 +173,16 @@ class Operation : public IUserObj
const DBLVECTOR& vAx2, const Vector3d& vtTool2,
double& dMaxZ) const ;
bool GetRotationAtZmax( void) const ;
bool ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const ;
bool ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, const BBox3d& b3Raws) const ;
int GetUserNotesZmax( void) const ;
bool GetZHomeDown( void) const ;
bool TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const ;
bool SpecialMoveZup( DBLVECTOR& vAx, Vector3d& vtTool, int& nFlag, int& nFlag2, bool& bModif) ;
int SpecialTestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const ;
bool SpecialMoveZup( DBLVECTOR& vAx, Vector3d& vtTool, int& nFlag, int& nFlag2, bool& bModif) ;
bool SpecialMoveRapid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, DBLVECTOR& vAxNew, bool& bModif) ;
bool GetAggrBottomData( const std::string& sHead, AggrBottom& agbData) const ;
bool IsAggrBottom( const std::string& sHead) const ;
protected :
int m_nOwnerId ; // identificativo dell'oggetto geometrico possessore
@@ -166,6 +198,7 @@ class Operation : public IUserObj
bool SetCorrAuxDir( const Vector3d& vtDir) ;
bool SetFeed( double dFeed) ;
bool SetFlag( int nFlag) ;
bool SetFlagOnLastMove( int nFlag) ;
bool SetFlag2( int nFlag2) ;
bool SetIndex( int nIndex) ;
bool GetCurrPos( Point3d& ptCurr) const
@@ -180,12 +213,26 @@ class Operation : public IUserObj
int AddRapidStart( const Point3d& ptP, const std::string& sName) ;
int AddRapidMove( const Point3d& ptP) ;
int AddRapidMove( const Point3d& ptP, const std::string& sName) ;
int AddRapidMove( const Point3d& ptP, bool bSplit) ;
int AddRapidMove( const Point3d& ptP, bool bSplit, const std::string& sName) ;
int AddRapidStartOrMove( const Point3d& ptP, bool bFirst)
{ return ( bFirst ? AddRapidStart( ptP) : AddRapidMove( ptP)) ; }
int AddRapidStartOrMove( const Point3d& ptP, bool bFirst, const std::string& sName)
{ return ( bFirst ? AddRapidStart( ptP, sName) : AddRapidMove( ptP, sName)) ; }
int AddRapidStartOrMove( const Point3d& ptP, bool bFirst, bool bSplit)
{ return ( bFirst ? AddRapidStart( ptP) : AddRapidMove( ptP, bSplit)) ; }
int AddRapidStartOrMove( const Point3d& ptP, bool bFirst, bool bSplit, const std::string& sName)
{ return ( bFirst ? AddRapidStart( ptP, sName) : AddRapidMove( ptP, bSplit, sName)) ; }
int AddLinearMove( const Point3d& ptP) ;
int AddLinearMove( const Point3d& ptP, const std::string& sName) ;
int AddLinearMove( const Point3d& ptP, bool bSplit) ;
int AddLinearMove( const Point3d& ptP, bool bSplit, const std::string& sName) ;
int AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN) ;
int AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN, const std::string& sName) ;
int AddCurveMove( const ICurve* pCrv, bool bOnlySimple = false) ;
int AddCurveMove( const ICurve* pCrv, const std::string& sName, bool bOnlySimple = false) ;
int AddCurveMove( const ICurve* pCrv) ;
int AddCurveMove( const ICurve* pCrv, const std::string& sName) ;
int AddCurveMove( const ICurve* pCrv, bool bSplit) ;
int AddCurveMove( const ICurve* pCrv, bool bSplit, const std::string& sName) ;
bool ResetMoveData( void) ;
protected :
@@ -212,3 +259,5 @@ inline Operation* GetOperation( IUserObj* pUserObj)
enum { TOOL_PARAL = 1, TOOL_ORTHO = 2, TOOL_ORTUP = 3, TOOL_PAR_SLANT= 4} ;
// tipo di utilizzo contorno faccia
enum { FACE_DOWN = 1, FACE_TOP = 2, FACE_FRONT = 3, FACE_BACK = 4, FACE_LEFT = 5, FACE_RIGHT = 6, FACE_CONT = 7} ;
// risultato di SpecialTestCollisionAvoid
enum { SCAV_ERROR = -1, SCAV_COLLIDE = 0, SCAV_AVOID = 1, SCAV_TOTEST = 2};
+123 -6
View File
@@ -82,6 +82,18 @@ Operation::SetFlag( int nFlag)
return true ;
}
//----------------------------------------------------------------------------
bool
Operation::SetFlagOnLastMove( int nFlag)
{
int nLastEntId = m_pGeomDB->GetLastInGroup( m_nPathId) ;
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nLastEntId)) ;
if ( pCamData == nullptr)
return false ;
pCamData->SetFlag( nFlag) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Operation::SetFlag2( int nFlag2)
@@ -200,6 +212,46 @@ Operation::AddRapidMove( const Point3d& ptP, const string& sName)
return nId ;
}
//----------------------------------------------------------------------------
int
Operation::AddRapidMove( const Point3d& ptP, bool bSplit)
{
// se non richiesta spezzatura con massima lunghezza, emissione normale
if ( ! NeedSplit( bSplit))
return AddRapidMove( ptP) ;
// altrimenti opportuna spezzatura
Point3d ptS ;
if ( ! GetCurrPos( ptS))
return GDB_ID_NULL ;
double dLen = Dist( ptS, ptP) ;
double dStep = GetMaxSplitLen( true, false) ;
int nStep = int( dLen / dStep + 0.999) ;
int nFirstId = GDB_ID_NULL ;
for ( int i = 1 ; i <= nStep ; ++ i) {
int nId = AddRapidMove( Media( ptS, ptP, i * 1.0 / nStep)) ;
if ( nId == GDB_ID_NULL)
return GDB_ID_NULL ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nId ;
SetFlag( 0) ;
SetFlag2( 0) ;
}
return nFirstId ;
}
//----------------------------------------------------------------------------
int
Operation::AddRapidMove( const Point3d& ptP, bool bSplit, const string& sName)
{
int nFirstId = AddRapidMove( ptP, bSplit) ;
int nId = nFirstId ;
while ( nId != GDB_ID_NULL) {
m_pGeomDB->SetName( nId, sName) ;
nId = m_pGeomDB->GetNext( nId) ;
}
return nFirstId ;
}
//----------------------------------------------------------------------------
int
Operation::AddLinearMove( const Point3d& ptP)
@@ -258,6 +310,44 @@ Operation::AddLinearMove( const Point3d& ptP, const string& sName)
return nId ;
}
//----------------------------------------------------------------------------
int
Operation::AddLinearMove( const Point3d& ptP, bool bSplit)
{
// se non richiesta spezzatura con massima lunghezza, emissione normale
if ( ! NeedSplit( bSplit))
return AddLinearMove( ptP) ;
// altrimenti opportuna spezzatura
Point3d ptS ;
if ( ! GetCurrPos( ptS))
return GDB_ID_NULL ;
double dLen = Dist( ptS, ptP) ;
double dStep = GetMaxSplitLen( true, true) ;
int nStep = int( dLen / dStep + 0.999) ;
int nFirstId = GDB_ID_NULL ;
for ( int i = 1 ; i <= nStep ; ++ i) {
int nId = AddLinearMove( Media( ptS, ptP, i * 1.0 / nStep)) ;
if ( nId == GDB_ID_NULL)
return GDB_ID_NULL ;
if ( nFirstId == GDB_ID_NULL)
nFirstId = nId ;
}
return nFirstId ;
}
//----------------------------------------------------------------------------
int
Operation::AddLinearMove( const Point3d& ptP, bool bSplit, const string& sName)
{
int nFirstId = AddLinearMove( ptP, bSplit) ;
int nId = nFirstId ;
while ( nId != GDB_ID_NULL) {
m_pGeomDB->SetName( nId, sName) ;
nId = m_pGeomDB->GetNext( nId) ;
}
return nFirstId ;
}
//----------------------------------------------------------------------------
int
Operation::AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN)
@@ -334,7 +424,7 @@ Operation::AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen,
//----------------------------------------------------------------------------
int
Operation::AddCurveMove( const ICurve* pCrv, bool bOnlySimple)
Operation::AddCurveMove( const ICurve* pCrv)
{
// verifico che la curva esista
if ( pCrv == nullptr)
@@ -355,8 +445,8 @@ Operation::AddCurveMove( const ICurve* pCrv, bool bOnlySimple)
pArc->GetEndPoint( ptP3) ;
return AddArcMove( ptP3, ptCen, dAngCen, vtN) ;
}
// se ammesse curve composite
else if ( ! bOnlySimple) {
// se arco o curva composita
else if ( pCrv->GetType() == CRV_ARC || pCrv->GetType() == CRV_COMPO) {
// in ogni caso, converto in archi e rette
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
if ( ! pCompo->AddCurve( *pCrv))
@@ -395,16 +485,43 @@ Operation::AddCurveMove( const ICurve* pCrv, bool bOnlySimple)
}
return nFirstId ;
}
// altrimenti
// altre curve non ammesse
else
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
int
Operation::AddCurveMove( const ICurve* pCrv, const string& sName, bool bOnlySimple)
Operation::AddCurveMove( const ICurve* pCrv, const string& sName)
{
int nFirstId = AddCurveMove( pCrv, bOnlySimple) ;
int nFirstId = AddCurveMove( pCrv) ;
int nId = nFirstId ;
while ( nId != GDB_ID_NULL) {
m_pGeomDB->SetName( nId, sName) ;
nId = m_pGeomDB->GetNext( nId) ;
}
return nFirstId ;
}
//----------------------------------------------------------------------------
int
Operation::AddCurveMove( const ICurve* pCrv, bool bSplit)
{
// se non richiesta spezzatura, emissione normale
if ( ! bSplit)
return AddCurveMove( pCrv) ;
// altrimenti opportuna spezzatura
PtrOwner<ICurveComposite> pCompo ;
if ( ! pCompo.Set( ConvertCurveToComposite( pCrv->Clone())) || ! ApproxWithLines( pCompo))
return false ;
return AddCurveMove( pCompo) ;
}
//----------------------------------------------------------------------------
int
Operation::AddCurveMove( const ICurve* pCrv, bool bSplit, const string& sName)
{
int nFirstId = AddCurveMove( pCrv, bSplit) ;
int nId = nFirstId ;
while ( nId != GDB_ID_NULL) {
m_pGeomDB->SetName( nId, sName) ;
+115 -44
View File
@@ -60,6 +60,7 @@ static const std::string GVAR_TOOL = ".TOOL" ; // (string) nome uten
static const std::string GVAR_HEAD = ".HEAD" ; // (string) nome testa
static const std::string GVAR_EXIT = ".EXIT" ; // (int) indice uscita
static const std::string GVAR_TCPOS = ".TCPOS" ; // (string) eventuale posizione utensile nel TC
static const std::string GVAR_TTYPE = ".TTYPE" ; // (int) tipo utensile
static const std::string GVAR_TCOMP = ".TCOMP" ; // (int) numero correttore utensile
static const std::string GVAR_TDIAM = ".TDIAM" ; // (num) diametro utensile
static const std::string GVAR_TTOTDIAM = ".TTOTDIAM" ; // (num) diametro totale utensile
@@ -102,6 +103,9 @@ static const std::string GVAR_R1 = ".R1" ; // (num) valore de
static const std::string GVAR_R2 = ".R2" ; // (num) valore del secondo asse rotante
static const std::string GVAR_R3 = ".R3" ; // (num) valore del terzo asse rotante
static const std::string GVAR_R4 = ".R4" ; // (num) valore del quarto asse rotante
static const std::string GVAR_R5 = ".R5" ; // (num) valore del quinto asse rotante
static const std::string GVAR_R6 = ".R6" ; // (num) valore del sesto asse rotante
static const std::string GVAR_R7 = ".R7" ; // (num) valore del settimo asse rotante
static const std::string GVAR_C1 = ".C1" ; // (num) valore del primo asse lineare per centro arco
static const std::string GVAR_C2 = ".C2" ; // (num) valore del secondo asse lineare per centro arco
static const std::string GVAR_C3 = ".C3" ; // (num) valore del terzo asse lineare per centro arco
@@ -117,6 +121,9 @@ static const std::string GVAR_R1P = ".R1p" ; // (num) valore pr
static const std::string GVAR_R2P = ".R2p" ; // (num) valore precedente del secondo asse rotante
static const std::string GVAR_R3P = ".R3p" ; // (num) valore precedente del terzo asse rotante
static const std::string GVAR_R4P = ".R4p" ; // (num) valore precedente del quarto asse rotante
static const std::string GVAR_R5P = ".R5p" ; // (num) valore precedente del quinto asse rotante
static const std::string GVAR_R6P = ".R6p" ; // (num) valore precedente del sesto asse rotante
static const std::string GVAR_R7P = ".R7p" ; // (num) valore precedente del settimo asse rotante
static const std::string GVAR_L1T = ".L1t" ; // (string) token del primo asse lineare
static const std::string GVAR_L2T = ".L2t" ; // (string) token del secondo asse lineare
static const std::string GVAR_L3T = ".L3t" ; // (string) token del terzo asse lineare
@@ -124,6 +131,9 @@ static const std::string GVAR_R1T = ".R1t" ; // (string) token del
static const std::string GVAR_R2T = ".R2t" ; // (string) token del secondo asse rotante
static const std::string GVAR_R3T = ".R3t" ; // (string) token del terzo asse rotante
static const std::string GVAR_R4T = ".R4t" ; // (string) token del quarto asse rotante
static const std::string GVAR_R5T = ".R5t" ; // (string) token del quinto asse rotante
static const std::string GVAR_R6T = ".R6t" ; // (string) token del sesto asse rotante
static const std::string GVAR_R7T = ".R7t" ; // (string) token del settimo asse rotante
static const std::string GVAR_C1T = ".C1t" ; // (string) token del primo asse lineare per centro arco
static const std::string GVAR_C2T = ".C2t" ; // (string) token del secondo asse lineare per centro arco
static const std::string GVAR_C3T = ".C3t" ; // (string) token del terzo asse lineare per centro arco
@@ -138,6 +148,9 @@ static const std::string GVAR_R1N = ".R1n" ; // (string) nome del
static const std::string GVAR_R2N = ".R2n" ; // (string) nome del secondo asse rotante
static const std::string GVAR_R3N = ".R3n" ; // (string) nome del terzo asse rotante
static const std::string GVAR_R4N = ".R4n" ; // (string) nome del quarto asse rotante
static const std::string GVAR_R5N = ".R5n" ; // (string) nome del quinto asse rotante
static const std::string GVAR_R6N = ".R6n" ; // (string) nome del sesto asse rotante
static const std::string GVAR_R7N = ".R7n" ; // (string) nome del settimo asse rotante
static const std::string GVAR_MASK = ".MASK" ; // (int) mask associato ai movimenti in rapido
static const std::string GVAR_FLAG = ".FLAG" ; // (int) flag associato ad ogni movimento
static const std::string GVAR_FLAG2 = ".FLAG2" ; // (int) secondo flag associato ad ogni movimento
@@ -205,6 +218,8 @@ static const std::string ON_ESTIM_RAPID = "OnEstimRapid" ;
static const std::string ON_ESTIM_LINEAR = "OnEstimLinear" ;
static const std::string ON_ESTIM_ARC = "OnEstimArc" ;
// Funzioni simulazione
static const std::string ON_SIMUL_INIT = "OnSimulInit" ;
static const std::string ON_SIMUL_EXIT = "OnSimulExit" ;
static const std::string ON_SIMUL_START = "OnSimulStart" ;
static const std::string ON_SIMUL_END = "OnSimulEnd" ;
static const std::string ON_SIMUL_DISPOSITION_STARTING = "OnSimulDispositionStarting" ;
@@ -226,64 +241,120 @@ static const std::string ON_RESET_MACHINE = "OnResetMachine" ;
//----------------------------------------------------------------------------
inline std::string
GetGlobVarAxisValue( int nAx, const std::string& sVar = GLOB_VAR)
GetGlobVarAxisValue( int nAx, const std::string& sVar = GLOB_VAR, bool bIsRobot = false)
{
switch ( nAx) {
case 1 : return ( sVar + GVAR_L1) ;
case 2 : return ( sVar + GVAR_L2) ;
case 3 : return ( sVar + GVAR_L3) ;
case 4 : return ( sVar + GVAR_R1) ;
case 5 : return ( sVar + GVAR_R2) ;
case 6 : return ( sVar + GVAR_R3) ;
case 7 : return ( sVar + GVAR_R4) ;
default : return "" ;
}
if ( ! bIsRobot) {
switch ( nAx) {
case 1 : return ( sVar + GVAR_L1) ;
case 2 : return ( sVar + GVAR_L2) ;
case 3 : return ( sVar + GVAR_L3) ;
case 4 : return ( sVar + GVAR_R1) ;
case 5 : return ( sVar + GVAR_R2) ;
case 6 : return ( sVar + GVAR_R3) ;
case 7 : return ( sVar + GVAR_R4) ;
default : return "" ;
}
}
else {
switch ( nAx) {
case 1 : return ( sVar + GVAR_R1) ;
case 2 : return ( sVar + GVAR_R2) ;
case 3 : return ( sVar + GVAR_R3) ;
case 4 : return ( sVar + GVAR_R4) ;
case 5 : return ( sVar + GVAR_R5) ;
case 6 : return ( sVar + GVAR_R6) ;
case 7 : return ( sVar + GVAR_R7) ;
default : return "" ;
}
}
}
//----------------------------------------------------------------------------
inline std::string
GetGlobVarAxisPrev( int nAx, const std::string& sVar = GLOB_VAR)
GetGlobVarAxisPrev( int nAx, const std::string& sVar = GLOB_VAR, bool bIsRobot = false)
{
switch ( nAx) {
case 1 : return ( sVar + GVAR_L1P) ;
case 2 : return ( sVar + GVAR_L2P) ;
case 3 : return ( sVar + GVAR_L3P) ;
case 4 : return ( sVar + GVAR_R1P) ;
case 5 : return ( sVar + GVAR_R2P) ;
case 6 : return ( sVar + GVAR_R3P) ;
case 7 : return ( sVar + GVAR_R4P) ;
default : return "" ;
}
if ( ! bIsRobot) {
switch ( nAx) {
case 1 : return ( sVar + GVAR_L1P) ;
case 2 : return ( sVar + GVAR_L2P) ;
case 3 : return ( sVar + GVAR_L3P) ;
case 4 : return ( sVar + GVAR_R1P) ;
case 5 : return ( sVar + GVAR_R2P) ;
case 6 : return ( sVar + GVAR_R3P) ;
case 7 : return ( sVar + GVAR_R4P) ;
default : return "" ;
}
}
else {
switch ( nAx) {
case 1 : return ( sVar + GVAR_R1P) ;
case 2 : return ( sVar + GVAR_R2P) ;
case 3 : return ( sVar + GVAR_R3P) ;
case 4 : return ( sVar + GVAR_R4P) ;
case 5 : return ( sVar + GVAR_R5P) ;
case 6 : return ( sVar + GVAR_R6P) ;
case 7 : return ( sVar + GVAR_R7P) ;
default : return "" ;
}
}
}
//----------------------------------------------------------------------------
inline std::string
GetGlobVarAxisToken( int nAx)
GetGlobVarAxisToken( int nAx, bool bIsRobot = false)
{
switch ( nAx) {
case 1 : return ( GLOB_VAR + GVAR_L1T) ;
case 2 : return ( GLOB_VAR + GVAR_L2T) ;
case 3 : return ( GLOB_VAR + GVAR_L3T) ;
case 4 : return ( GLOB_VAR + GVAR_R1T) ;
case 5 : return ( GLOB_VAR + GVAR_R2T) ;
case 6 : return ( GLOB_VAR + GVAR_R3T) ;
case 7 : return ( GLOB_VAR + GVAR_R4T) ;
default : return "" ;
}
if ( ! bIsRobot) {
switch ( nAx) {
case 1 : return ( GLOB_VAR + GVAR_L1T) ;
case 2 : return ( GLOB_VAR + GVAR_L2T) ;
case 3 : return ( GLOB_VAR + GVAR_L3T) ;
case 4 : return ( GLOB_VAR + GVAR_R1T) ;
case 5 : return ( GLOB_VAR + GVAR_R2T) ;
case 6 : return ( GLOB_VAR + GVAR_R3T) ;
case 7 : return ( GLOB_VAR + GVAR_R4T) ;
default : return "" ;
}
}
else {
switch ( nAx) {
case 1 : return ( GLOB_VAR + GVAR_R1T) ;
case 2 : return ( GLOB_VAR + GVAR_R2T) ;
case 3 : return ( GLOB_VAR + GVAR_R3T) ;
case 4 : return ( GLOB_VAR + GVAR_R4T) ;
case 5 : return ( GLOB_VAR + GVAR_R5T) ;
case 6 : return ( GLOB_VAR + GVAR_R6T) ;
case 7 : return ( GLOB_VAR + GVAR_R7T) ;
default : return "" ;
}
}
}
//----------------------------------------------------------------------------
inline std::string
GetGlobVarAxisName( int nAx)
GetGlobVarAxisName( int nAx, bool bIsRobot = false)
{
switch ( nAx) {
case 1 : return ( GLOB_VAR + GVAR_L1N) ;
case 2 : return ( GLOB_VAR + GVAR_L2N) ;
case 3 : return ( GLOB_VAR + GVAR_L3N) ;
case 4 : return ( GLOB_VAR + GVAR_R1N) ;
case 5 : return ( GLOB_VAR + GVAR_R2N) ;
case 6 : return ( GLOB_VAR + GVAR_R3N) ;
case 7 : return ( GLOB_VAR + GVAR_R4N) ;
default : return "" ;
}
if ( ! bIsRobot) {
switch ( nAx) {
case 1 : return ( GLOB_VAR + GVAR_L1N) ;
case 2 : return ( GLOB_VAR + GVAR_L2N) ;
case 3 : return ( GLOB_VAR + GVAR_L3N) ;
case 4 : return ( GLOB_VAR + GVAR_R1N) ;
case 5 : return ( GLOB_VAR + GVAR_R2N) ;
case 6 : return ( GLOB_VAR + GVAR_R3N) ;
case 7 : return ( GLOB_VAR + GVAR_R4N) ;
default : return "" ;
}
}
else {
switch ( nAx) {
case 1 : return ( GLOB_VAR + GVAR_R1N) ;
case 2 : return ( GLOB_VAR + GVAR_R2N) ;
case 3 : return ( GLOB_VAR + GVAR_R3N) ;
case 4 : return ( GLOB_VAR + GVAR_R4N) ;
case 5 : return ( GLOB_VAR + GVAR_R5N) ;
case 6 : return ( GLOB_VAR + GVAR_R6N) ;
case 7 : return ( GLOB_VAR + GVAR_R7N) ;
default : return "" ;
}
}
}
+317 -285
View File
File diff suppressed because it is too large Load Diff
+13 -12
View File
@@ -68,26 +68,26 @@ class Pocketing : public Machining
private :
bool VerifyGeometry( SelData Id, int& nSubs, int& nType) ;
bool GetCurves( SelData Id, ICURVEPLIST& lstPC) ;
bool SetCurveAllTempProp( int nCrvId, ICurve* pCurve) ;
bool SetCurveAllTempProp( int nCrvId, bool bForcedClose, ICurve* pCurve, bool* pbSomeOpen = nullptr) ;
bool ResetCurveAllTempProp( ICurve* pCurve) ;
bool Chain( int nGrpDestId) ;
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
bool CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ;
bool CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double dLen, double& dElev) const ;
bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ;
bool GeneratePocketingPv( int nPathId, const ICurveComposite* pCompo) ;
bool AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
double dDepth, double dElev, double dOkStep, bool bSplitArcs, int nPathId) ;
bool CalcZigZag( const ICurveComposite* pOffs, ICRVCOMPOPOVECTOR& vpCrvs) ;
bool OptimizedZigZag( int nPathId, const Vector3d& vtTool, double dDepth, double dSafeZ,
Frame3d& frPocket, bool& bOptimizedZigZag, ICRVCOMPOPOVECTOR& vpCrvs) ;
bool ZigZagOptimizedNoClosedEdges( ICurveComposite* pCrvPocket, bool& bOptimizedZigZag, Vector3d& vtDir) ;
bool ZigZagOptimizedOneClosedEdge( ICurveComposite* pCrvPocket, int nClosedId, bool& bOptimizedZigZag, Vector3d& vtDir) ;
Frame3d& frPocket, bool& bOptimizedZigZag, ICRVCOMPOPOVECTOR& vpCrvs, double& dOffs) ;
bool ZigZagOptimizedNoClosedEdges( ICurveComposite* pCrvPocket, bool& bOptimizedZigZag, Vector3d& vtDir, double& dOffs) ;
bool ZigZagOptimizedOneClosedEdge( ICurveComposite* pCrvPocket, int nClosedId, bool& bOptimizedZigZag, Vector3d& vtDir, double& dOffs) ;
bool ZigZagOptimizedTwoClosedEdges( ICurveComposite* pCrvPocket, const INTVECTOR& vnClosedIds, bool& bOptimizedZigZag,
bool& bOpposite, Vector3d& vtDir) ;
bool& bOpposite, Vector3d& vtDir, double& dOffs) ;
bool ZigZagOptimizedThreeClosedEdges( ICurveComposite* pCrvPocket, const INTVECTOR& vnClosedIds, bool& bOptimizedZigZag,
bool& bOpposite, Vector3d& vtDir) ;
bool& bOpposite, Vector3d& vtDir, double& dOffs) ;
bool ZigZagOptimizedComputeOffset( ICurveComposite* pCrvPocket, const Vector3d& vtMainDir, int nOffsettedEdgesOnY,
const INTVECTOR& vnClosedIds) ;
const INTVECTOR& vnClosedIds, double& dOffs) ;
bool CutCurveWithLine( ICurveComposite* pCrvA, const ICurveLine* pCrvB) ;
bool AddOneWay( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
@@ -116,13 +116,13 @@ class Pocketing : public Machining
bool ComputePolishingPath( ICurveComposite* pMCrv, ICurveComposite* pRCrv, bool bSplitArcs) ;
bool AddEpicycles( ICurveComposite * pCompo, ICurveComposite * pCrv, ICurveComposite * pCrvBound = nullptr) ;
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr, bool bOutStart) ;
double dElev, double dAppr, bool bSplitArcs, bool bOutStart) ;
bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr, bool bOutStart = false) ;
double dElev, double dAppr, bool bSplitArcs, bool bOutStart = false) ;
bool AddLinkRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr) ;
double dElev, double dAppr, bool bSplitArcs) ;
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr) ;
double dElev, double dAppr, bool bSplitArcs) ;
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
const ICurveComposite* pRCrv, Point3d& ptP1) const ;
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
@@ -135,6 +135,7 @@ class Pocketing : public Machining
const ICurveComposite* pRCrv, bool bSplitArcs, bool bNoneForced,
Point3d& ptP1, double& dElev, bool& bOppositeHome) ;
double GetRadiusForStartEndElevation( void) const ;
bool GetForcedClosed( void) ;
bool GetMidOfLongestOpenSide( const ICurveComposite* pCompo, Point3d& ptMid, Vector3d& vtMidOut) ;
bool AdjustContourWithOpenEdges( ICurveComposite* pCompo) ;
bool AdjustContourStart( ICurveComposite* pCompo) ;
+6 -2
View File
@@ -83,6 +83,10 @@ struct PocketingData : public MachiningData
//----------------------------------------------------------------------------
inline const PocketingData* GetPocketingData( const MachiningData* pMdata)
{ return (dynamic_cast<const PocketingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_POCKETING)
return nullptr ;
return ( static_cast<const PocketingData*>( pMdata)) ; }
inline PocketingData* GetPocketingData( MachiningData* pMdata)
{ return (dynamic_cast<PocketingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_POCKETING)
return nullptr ;
return ( static_cast<PocketingData*>( pMdata)) ; }
+29 -14
View File
@@ -84,6 +84,9 @@ Processor::Run( const string& sOutFile, const string& sInfo)
if ( ! VerifySetup())
return false ;
// imposto la fase iniziale come corrente
m_pMchMgr->SetCurrPhase( 1) ;
// evento inizio esecuzione
bool bOk = true ;
if ( ! OnStart()) {
@@ -145,6 +148,9 @@ Processor::Run( const string& sOutFile, const string& sInfo)
LOG_ERROR( GetEMkLogger(), "OnEnd error") ;
}
// imposto la fase iniziale come corrente
m_pMchMgr->SetCurrPhase( 1) ;
return bOk ;
}
@@ -515,8 +521,8 @@ bool
Processor::UpdateAxes( void)
{
// Carico i nomi degli assi macchina attivi
return m_pMachine->GetAllCurrAxesName( m_AxesName) &&
m_pMachine->GetAllCurrAxesToken( m_AxesToken) ;
return m_pMachine->GetAllCurrAxesNames( m_AxesName) &&
m_pMachine->GetAllCurrAxesTokens( m_AxesToken) ;
}
//----------------------------------------------------------------------------
@@ -603,6 +609,7 @@ Processor::ProcessToolData( void)
string sHead ;
int nExit ;
string sTcPos ;
int nType ;
int nComp ;
double dDiam ;
double dTDiam ;
@@ -611,7 +618,7 @@ Processor::ProcessToolData( void)
double dDist ;
double dMaxSpeed ;
MyToolData( void)
: sName(), sHead(), nExit( 0), sTcPos(), nComp(0), dDiam( 0), dLen( 0), dDist( 0), dMaxSpeed( 0) {}
: sName(), sHead(), nExit( 0), sTcPos(), nType(0), nComp(0), dDiam( 0), dLen( 0), dDist( 0), dMaxSpeed( 0) {}
} ;
typedef vector<MyToolData> TDATAVECTOR ;
TDATAVECTOR vTdata ;
@@ -636,6 +643,7 @@ Processor::ProcessToolData( void)
m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, Tdata.sHead) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, Tdata.nExit) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_TCPOS, Tdata.sTcPos) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_TYPE, Tdata.nType) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_CORR, Tdata.nComp) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, Tdata.dDiam) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_TOTDIAM, Tdata.dTDiam) ;
@@ -674,7 +682,8 @@ Processor::ProcessToolData( void)
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos) ;
if ( m_pMchMgr->TdbSetCurrTool( sTool)) {
int nComp ; double dDiam ; double dTDiam ; double dLen ; double dTLen ; double dDist ; double dMaxSpeed ;
int nType ; int nComp ; double dDiam ; double dTDiam ; double dLen ; double dTLen ; double dDist ; double dMaxSpeed ;
m_pMchMgr->TdbGetCurrToolParam( TPA_TYPE, nType) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_CORR, nComp) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, dDiam) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_TOTDIAM, dTDiam) ;
@@ -682,6 +691,7 @@ Processor::ProcessToolData( void)
m_pMchMgr->TdbGetCurrToolParam( TPA_TOTLEN, dTLen) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_DIST, dDist) ;
m_pMchMgr->TdbGetCurrToolParam( TPA_MAXSPEED, dMaxSpeed) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TTYPE, nType) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCOMP, nComp) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIAM, dDiam) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TTOTDIAM, dTDiam) ;
@@ -721,6 +731,7 @@ Processor::ProcessToolData( void)
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, vTdata[i].sHead) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, vTdata[i].nExit) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, vTdata[i].sTcPos) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TTYPE, vTdata[i].nType) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCOMP, vTdata[i].nComp) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIAM, vTdata[i].dDiam) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TTOTDIAM, vTdata[i].dTDiam) ;
@@ -832,15 +843,16 @@ Processor::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos) ;
// assegno il token e il nome degli assi
bool bIsRobot = m_pMchMgr->GetCurrIsRobot() ;
int nNumAxes = int( m_AxesName.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes) {
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisToken(i), m_AxesToken[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisName(i), m_AxesName[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisToken( i, bIsRobot), m_AxesToken[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisName( i, bIsRobot), m_AxesName[i-1]) ;
}
else {
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisToken(i)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisName(i)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisToken( i, bIsRobot)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisName( i, bIsRobot)) ;
}
}
// chiamo la funzione di selezione utensile
@@ -972,12 +984,13 @@ Processor::OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd
// assegno il tipo di movimento
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ;
// assegno il valore degli assi
bool bIsRobot = m_pMchMgr->GetCurrIsRobot() ;
int nNumAxes = int( AxesEnd.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes)
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisValue(i), AxesEnd[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisValue( i, GLOB_VAR, bIsRobot), AxesEnd[i-1]) ;
else
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue(i)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue( i, GLOB_VAR, bIsRobot)) ;
}
// assegno la mascheratura degli assi
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MASK, nAxesMask) ;
@@ -1012,12 +1025,13 @@ Processor::OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEn
// assegno il tipo di movimento
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ;
// assegno il valore degli assi
bool bIsRobot = m_pMchMgr->GetCurrIsRobot() ;
int nNumAxes = int( AxesEnd.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes)
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisValue(i), AxesEnd[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisValue( i, GLOB_VAR, bIsRobot), AxesEnd[i-1]) ;
else
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue(i)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue( i, GLOB_VAR, bIsRobot)) ;
}
// assegno il valore del versore utensile
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIR, vtTool) ;
@@ -1051,12 +1065,13 @@ Processor::OnArc( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd,
// assegno il tipo di movimento
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ;
// assegno il valore degli assi
bool bIsRobot = m_pMchMgr->GetCurrIsRobot() ;
int nNumAxes = int( AxesEnd.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes)
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisValue(i), AxesEnd[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisValue( i, GLOB_VAR, bIsRobot), AxesEnd[i-1]) ;
else
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue(i)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue( i, GLOB_VAR, bIsRobot)) ;
}
// assegno le coordinate del centro
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_C1, ptCen.x) ;
+9 -6
View File
@@ -607,6 +607,9 @@ SawFinishing::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
SetBlockedRotAxis( m_Params.m_sBlockedAxis) ;
@@ -979,8 +982,8 @@ SawFinishing::AdjustGeometry( int nAuxId)
if ( ! pGuide->IsFlat( plPlane, false, 10 * EPS_SMALL) || ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), Z_AX))
return false ;
// verifiche sulla curva (che trasformo in composita)
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pGuide)))
PtrOwner<ICurveComposite> pCompo ;
if ( ! pCompo.Set( ConvertCurveToComposite( Release( pGuide))))
return false ;
// converto in archi e rette
pCompo->ArcsBezierCurvesToArcsPerpExtr( LIN_TOL_MID, ANG_TOL_STD_DEG) ;
@@ -2400,8 +2403,8 @@ SawFinishing::CalcCurvedAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax,
Vector3d vtMove = ( dY - m_TParams.m_dThick / 2) * Z_AX ;
OffsetCurve OffsCrv ;
OffsCrv.Make( pGuide, dOffs, ICurve::OFF_FILLET) ;
PtrOwner<ICurveComposite> pCut( CreateCurveComposite()) ;
if ( IsNull( pCut) || ! pCut->AddCurve( OffsCrv.GetLongerCurve()))
PtrOwner<ICurveComposite> pCut ;
if ( ! pCut.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve())))
return false ;
VerifyArcs( pCut) ;
pCut->SimpleOffset( SAWRF_OFFS, ICurve::OFF_FORCE_OPEN) ;
@@ -2475,8 +2478,8 @@ SawFinishing::CalcCurvedAlongStdCuts( ICurve* pSect, double dUmin, double dUmax,
Vector3d vtMove = ( ptP.y - m_TParams.m_dThick / 2) * Z_AX ;
OffsetCurve OffsCrv ;
OffsCrv.Make( pGuide, dOffs, ICurve::OFF_FILLET) ;
PtrOwner<ICurveComposite> pCut( CreateCurveComposite()) ;
if ( IsNull( pCut) || ! pCut->AddCurve( OffsCrv.GetLongerCurve()))
PtrOwner<ICurveComposite> pCut ;
if ( ! pCut.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve())))
return false ;
VerifyArcs( pCut) ;
pCut->SimpleOffset( SAWRF_OFFS, ICurve::OFF_FORCE_OPEN) ;
+6 -2
View File
@@ -81,6 +81,10 @@ struct SawFinishingData : public MachiningData
//----------------------------------------------------------------------------
inline const SawFinishingData* GetSawFinishingData( const MachiningData* pMdata)
{ return (dynamic_cast<const SawFinishingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_SAWFINISHING)
return nullptr ;
return ( static_cast<const SawFinishingData*>( pMdata)) ; }
inline SawFinishingData* GetSawFinishingData( MachiningData* pMdata)
{ return (dynamic_cast<SawFinishingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_SAWFINISHING)
return nullptr ;
return ( static_cast<SawFinishingData*>( pMdata)) ; }
+7 -4
View File
@@ -571,6 +571,9 @@ SawRoughing::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
SetBlockedRotAxis( m_Params.m_sBlockedAxis) ;
@@ -937,8 +940,8 @@ SawRoughing::AdjustGeometry( int nAuxId)
if ( ! pGuide->IsFlat( plPlane, false, 10 * EPS_SMALL) || ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), Z_AX))
return false ;
// verifiche sulla curva (che trasformo in composita)
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pGuide)))
PtrOwner<ICurveComposite> pCompo ;
if ( ! pCompo.Set( ConvertCurveToComposite( Release( pGuide))))
return false ;
// converto in archi e rette
pCompo->ArcsBezierCurvesToArcsPerpExtr( LIN_TOL_MID, ANG_TOL_STD_DEG) ;
@@ -1327,8 +1330,8 @@ SawRoughing::CalculateCurvedToolPath( int nAuxId, int nClId)
// creo la curva di taglio
OffsetCurve OffsCrv ;
OffsCrv.Make( pGuide, dX, ICurve::OFF_FILLET) ;
PtrOwner<ICurveComposite> pCut( CreateCurveComposite()) ;
if ( IsNull( pCut) || ! pCut->AddCurve( OffsCrv.GetLongerCurve()))
PtrOwner<ICurveComposite> pCut ;
if ( ! pCut.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve())))
return false ;
VerifyArcs( pCut) ;
Vector3d vtMove = ( dY - m_TParams.m_dThick / 2) * Z_AX ;
+6 -2
View File
@@ -78,6 +78,10 @@ struct SawRoughingData : public MachiningData
//----------------------------------------------------------------------------
inline const SawRoughingData* GetSawRoughingData( const MachiningData* pMdata)
{ return (dynamic_cast<const SawRoughingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_SAWROUGHING)
return nullptr ;
return ( static_cast<const SawRoughingData*>( pMdata)) ; }
inline SawRoughingData* GetSawRoughingData( MachiningData* pMdata)
{ return (dynamic_cast<SawRoughingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_SAWROUGHING)
return nullptr ;
return ( static_cast<SawRoughingData*>( pMdata)) ; }
+90 -48
View File
@@ -4,7 +4,7 @@
// File : Sawing.cpp Data : 24.10.15 Versione : 1.6j3
// Contenuto : Implementazione gestione tagli con lama.
//
// Note : Questa lavorazione è sempre espressa nel riferimento globale.
// Note : Questa lavorazione è sempre espressa nel riferimento globale.
//
// Modifiche : 07.06.15 DS Creazione modulo.
//
@@ -532,15 +532,15 @@ Sawing::SetParam( int nType, const string& sVal)
bool
Sawing::SetGeometry( const SELVECTOR& vIds)
{
// verifico validità gestore DB geometrico
// verifico validità gestore DB geometrico
if ( m_pGeomDB == nullptr)
return false ;
// reset della geometria corrente
m_vId.clear() ;
// verifico che gli identificativi rappresentino delle entità ammissibili
// verifico che gli identificativi rappresentino delle entità ammissibili
int nType = GEO_NONE ;
for ( const auto& Id : vIds) {
// test sull'entità
// test sull'entità
int nSubs ;
if ( ! VerifyGeometry( Id, nSubs, nType)) {
string sInfo = "Warning in Sawing : Skipped entity " + ToString( Id) ;
@@ -563,14 +563,14 @@ Sawing::Preview( bool bRecalc)
// reset numero tagli nella lavorazione
m_nCuts = 0 ;
// verifico validità gestore DB geometrico e Id del gruppo
// verifico validità gestore DB geometrico e Id del gruppo
if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId))
return false ;
// recupero gruppo per geometria ausiliaria
int nAuxId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_AUX) ;
bool bChain = false ;
// se non c'è, lo aggiungo
// se non c'è, lo aggiungo
if ( nAuxId == GDB_ID_NULL) {
nAuxId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
if ( nAuxId == GDB_ID_NULL)
@@ -603,7 +603,7 @@ Sawing::Preview( bool bRecalc)
// recupero gruppo per anteprima di lavorazione (PreView)
int nPvId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_PV) ;
// se non c'è, lo aggiungo
// se non c'è, lo aggiungo
if ( nPvId == GDB_ID_NULL) {
nPvId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
if ( nPvId == GDB_ID_NULL)
@@ -633,7 +633,7 @@ Sawing::Apply( bool bRecalc, bool bPostApply)
int nCurrCuts = m_nCuts ;
m_nCuts = 0 ;
// verifico validità gestore DB geometrico e Id del gruppo
// verifico validità gestore DB geometrico e Id del gruppo
if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId))
return false ;
@@ -662,7 +662,7 @@ Sawing::Apply( bool bRecalc, bool bPostApply)
// recupero gruppo per geometria ausiliaria
int nAuxId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_AUX) ;
bool bChain = false ;
// se non c'è, lo aggiungo
// se non c'è, lo aggiungo
if ( nAuxId == GDB_ID_NULL) {
nAuxId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
if ( nAuxId == GDB_ID_NULL)
@@ -689,7 +689,7 @@ Sawing::Apply( bool bRecalc, bool bPostApply)
// recupero gruppo per geometria di lavorazione (Cutter Location)
int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
// se non c'è, lo aggiungo
// se non c'è, lo aggiungo
if ( nClId == GDB_ID_NULL) {
nClId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
if ( nClId == GDB_ID_NULL)
@@ -732,7 +732,7 @@ Sawing::Apply( bool bRecalc, bool bPostApply)
bool
Sawing::Update( bool bPostApply)
{
// verifico validità gestore DB geometrico e Id del gruppo
// verifico validità gestore DB geometrico e Id del gruppo
if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId))
return false ;
@@ -742,6 +742,9 @@ Sawing::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
SetBlockedRotAxis( m_Params.m_sBlockedAxis) ;
@@ -791,7 +794,7 @@ Sawing::Update( bool bPostApply)
bool
Sawing::AdjustFeeds( void)
{
// controlli su GeomDB e simili non ripetuti perchè già fatti
// controlli su GeomDB e simili non ripetuti perchè già fatti
// recupero gruppo della geometria di lavorazione (Cutter Location)
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
@@ -801,11 +804,11 @@ Sawing::AdjustFeeds( void)
// ciclo sui gruppi CL
int nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
while ( nClPathId != GDB_ID_NULL) {
// ciclo su tutte le entità del percorso CL
// ciclo su tutte le entità del percorso CL
for ( int nEntId = m_pGeomDB->GetFirstInGroup( nClPathId) ;
nEntId != GDB_ID_NULL ;
nEntId = m_pGeomDB->GetNext( nEntId)) {
// recupero i dati Cam dell'entità
// recupero i dati Cam dell'entità
CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ;
if ( pCamData == nullptr)
continue ;
@@ -1072,7 +1075,7 @@ Sawing::UpdateToolData( bool* pbChanged)
bool
Sawing::GetGeometry( SELVECTOR& vIds) const
{
// restituisco l'elenco delle entità
// restituisco l'elenco delle entità
vIds = m_vId ;
return true ;
}
@@ -1095,7 +1098,7 @@ Sawing::VerifyGeometry( SelData Id, int& nSubs, int& nType)
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
if ( pGObj == nullptr)
return false ;
// se ammesse curve ed è tale
// se ammesse curve ed è tale
if ( ( nType == GEO_NONE || nType == GEO_CURVE) && ( pGObj->GetType() & GEO_CURVE) != 0) {
nType = GEO_CURVE ;
const ICurve* pCurve = nullptr ;
@@ -1119,7 +1122,7 @@ Sawing::VerifyGeometry( SelData Id, int& nSubs, int& nType)
}
return ( pCurve != nullptr) ;
}
// se altrimenti ammesse superfici trimesh ed è tale
// se altrimenti ammesse superfici trimesh ed è tale
else if ( ( nType == GEO_NONE || nType == GEO_SURF) && pGObj->GetType() == SRF_TRIMESH) {
nType = GEO_SURF ;
const ISurfTriMesh* pSurf = ::GetSurfTriMesh( pGObj) ;
@@ -1139,7 +1142,7 @@ Sawing::VerifyGeometry( SelData Id, int& nSubs, int& nType)
}
return true ;
}
// se altrimenti ammesse regioni ed è tale
// se altrimenti ammesse regioni ed è tale
else if ( ( nType == GEO_NONE || nType == GEO_SURF) && pGObj->GetType() == SRF_FLATRGN) {
nType = GEO_SURF ;
const ISurfFlatRegion* pReg = ::GetSurfFlatRegion( pGObj) ;
@@ -1276,8 +1279,8 @@ Sawing::GetCurve( SelData Id)
// recupero l'indice del chunk
int nChunk = ( ( Id.nSub == SEL_SUB_ALL) ? 0 : Id.nSub) ;
// recupero il contorno esterno del chunk
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo) || ! pCrvCompo->AddCurve( pReg->GetLoop( nChunk, 0)))
PtrOwner<ICurveComposite> pCrvCompo ;
if ( ! pCrvCompo.Set( ConvertCurveToComposite( pReg->GetLoop( nChunk, 0))))
return nullptr ;
// recupero la normale della regione
Vector3d vtN = pReg->GetNormVersor() ;
@@ -1332,7 +1335,7 @@ Sawing::Chain( int nGrpDestId)
for ( const auto& Id : m_vId) {
// prendo curva
vpCrvs.emplace_back( GetCurve( Id)) ;
// ne verifico la validità
// ne verifico la validità
if ( IsNull( vpCrvs.back())) {
string sInfo = "Warning in Sawing : Skipped entity " + ToString( Id) ;
m_pMchMgr->SetWarning( 2251, sInfo) ;
@@ -1474,7 +1477,7 @@ Sawing::ProcessPath( int nPathId, int nPvId, int nClId)
// recupero gruppo per geometria temporanea
const string GRP_TEMP = "Temp" ;
int nTempId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, GRP_TEMP) ;
// se non c'è, lo aggiungo
// se non c'è, lo aggiungo
if ( nTempId == GDB_ID_NULL) {
nTempId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
if ( nTempId == GDB_ID_NULL)
@@ -1539,7 +1542,7 @@ Sawing::ProcessPath( int nPathId, int nPvId, int nClId)
// elaboro la curva composita e la esplodo nelle curve componenti
if ( m_Params.m_nCurveUse == SAW_CRV_APPROX ||
m_Params.m_nCurveUse == SAW_CRV_CONVEX) {
// calcolo l'approssimazione lineare con eventuale convessità
// calcolo l'approssimazione lineare con eventuale convessità
PolyLine PL ;
int nType = ICurve::APL_STD ;
if ( m_Params.m_nWorkSide == SAW_WS_LEFT)
@@ -1628,7 +1631,7 @@ Sawing::ProcessPath( int nPathId, int nPvId, int nClId)
// flag di curva chiusa
bool bClosed = pCompo->IsClosed() ;
// calcolo gli eventuali punti di perdita di tangenza e di cambio di concavità
// calcolo gli eventuali punti di perdita di tangenza e di cambio di concavità
DBLVECTOR vU ;
const double ANG_PERD_TG = 1.0 ;
const ICurveArc* pArc = ( bClosed ? GetCurveArc( pCompo->GetLastCurve()) : nullptr) ;
@@ -1644,7 +1647,7 @@ Sawing::ProcessPath( int nPathId, int nPvId, int nClId)
nCurrConv = 0 ;
continue ;
}
// verifico cambio di concavità e/o lavorazione interna
// verifico cambio di concavità e/o lavorazione interna
const ICurve* pCrv = pCompo->GetCurve( i) ;
if ( pCrv->GetType() == CRV_ARC) {
if ( GetCurveArc( pCrv)->GetAngCenter() > 0) {
@@ -1726,7 +1729,7 @@ Sawing::ProcessEntity( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* p
// altrimenti
else {
if ( m_Params.m_nCurveUse == SAW_CRV_KEEP) {
// determino la convessità
// determino la convessità
int nConv = 0 ;
for ( int i = 0 ; i < pCompo->GetCurveCount() ; ++ i) {
const ICurveArc* pArc = GetCurveArc( pCompo->GetCurve( i)) ;
@@ -1827,7 +1830,7 @@ Sawing::ProcessLine( const ICurve* pCrvP, const ICurveLine* pLineC, const ICurve
( m_Params.m_nWorkSide == SAW_WS_RIGHT && dAngCN < - EPS_ANG_SMALL))
bExtAngCN = false ;
}
// verifico eventuale attacco speciale a step (se parametri validi e su entità linea singola)
// verifico eventuale attacco speciale a step (se parametri validi e su entità linea singola)
double dLiStep = 0 ;
double dLiElev = 0 ;
if ( m_Params.m_dLiTang > 10 * EPS_SMALL && m_Params.m_dLiElev > 10 * EPS_SMALL &&
@@ -1848,7 +1851,7 @@ Sawing::ProcessLine( const ICurve* pCrvP, const ICurveLine* pLineC, const ICurve
return true ;
}
// Eventuale variazioni di velocità all'inizio e alla fine del percorso
// Eventuale variazioni di velocità all'inizio e alla fine del percorso
FseVar FvVar ;
if ( pCrvP == nullptr) {
string sFsta = ExtractInfo( m_Params.m_sUserNotes, "Fsta=") ;
@@ -1996,7 +1999,7 @@ Sawing::GenerateLinePv( const ICurveLine* pLine, const Vector3d& vtTool, const V
ptREnd + vtDir * ( dDtEnd + dExtraL) , RTY_LOC) ;
m_pGeomDB->SetName( nReId, MCH_PV_RLOCUT) ;
m_pGeomDB->SetMaterial( nReId, INVISIBLE) ;
// eventuali ripetizioni in basso per tagli inclinati
if ( abs( m_Params.m_dSideAngle) > EPS_ANG_SMALL) {
// lunghezza movimento
@@ -2054,6 +2057,23 @@ Sawing::GenerateLinePv( const ICurveLine* pLine, const Vector3d& vtTool, const V
}
}
// creo regioni di lavorazione che interessano le superfici superiore e inferiore del grezzo considerando anche gli
// allungamenti dei baffi
int nSurfUpId = ExeCreateSurfFrRectangle3P( nPxId, ptIni - vtDir * ( dStartWhiskExt + 5 * EPS_SMALL),
ptCross + vtDir * ( dEndWhiskExt + 5 * EPS_SMALL),
ptEnd + vtDir * ( dEndWhiskExt + 5 * EPS_SMALL), RTY_LOC) ;
m_pGeomDB->SetName( nSurfUpId, MCH_PV_UP_RAWCUT) ;
m_pGeomDB->SetMaterial( nSurfUpId, INVISIBLE) ;
// solo se la lavorazione interessa il fondo del grezzo creo la superficie down
if ( dRbHeight < EPS_SMALL) {
int nSurfDownId = m_pGeomDB->CopyGlob( nSurfUpId, GDB_ID_NULL, nPxId) ;
double dMove = dElev + dRbHeight / cos( m_Params.m_dSideAngle * DEGTORAD) ;
Vector3d vtMove = - dMove * vtCorr ; vtMove.z = 0 ;
ExeMove( {nSurfDownId}, vtMove, RTY_LOC) ;
m_pGeomDB->SetName( nSurfDownId, MCH_PV_DOWN_RAWCUT) ;
m_pGeomDB->SetMaterial( nSurfDownId, INVISIBLE) ;
}
// salvo in info gruppo : larghezza XY del taglio, distanza XY tra centro e bordo taglio, extra taglio e quota minima della lama
m_pGeomDB->SetInfo( nPxId, MCH_PV_KEY_WT, vtToolH.LenXY()) ;
if ( dLiElev > EPS_SMALL)
@@ -2276,7 +2296,7 @@ Sawing::GenerateLineCl( const ICurveLine* pLine, const Vector3d& vtTool, const V
Point3d ptP3 = pLine->GetEnd() + vtCorr * dDelta ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
// se non è ultimo passo
// se non è ultimo passo
if ( i != 0) {
// movimento di risalita sopra il punto finale
SetFeed( GetEndFeed()) ;
@@ -2472,7 +2492,7 @@ Sawing::GenerateExtCurvePv( const ICurveComposite* pCrv, double dOffs,
if ( abs( m_Params.m_dSideAngle) > EPS_ANG_SMALL)
colCut = FUCHSIA ;
// dimensione da aggiungere alle regioni nelle parti in cui la lama è inclinata
// dimensione da aggiungere alle regioni nelle parti in cui la lama è inclinata
double dExtraL = m_pMchMgr->GetCurrMachiningsMgr()->GetExtraLOnCutRegion() ;
// lunghezza taglio parziale
@@ -2620,6 +2640,17 @@ Sawing::GenerateExtCurvePv( const ICurveComposite* pCrv, double dOffs,
return false ;
if ( ! ExeSurfFrAdd( nRId, nRsId) || ! ExeSurfFrAdd( nRId, nReId))
return false ;
// creo regioni di lavorazione che interessano le superfici superiore e inferiore del grezzo
int nSurfUpId = m_pGeomDB->CopyGlob( nRrId, GDB_ID_NULL, nPxId) ;
m_pGeomDB->SetName( nSurfUpId, MCH_PV_UP_RAWCUT) ;
m_pGeomDB->SetMaterial( nSurfUpId, INVISIBLE) ;
// solo se lavorazione interessa il fondo del grezzo creo la superficie down
if ( dRbHeight < EPS_SMALL) {
int nSurfDownId = m_pGeomDB->CopyGlob( nSurfUpId, GDB_ID_NULL, nPxId) ;
m_pGeomDB->SetName( nSurfDownId, MCH_PV_DOWN_RAWCUT) ;
m_pGeomDB->SetMaterial( nSurfDownId, INVISIBLE) ;
}
}
// altrimenti errore
@@ -2865,7 +2896,7 @@ Sawing::GenerateExtCurveCl( const ICurveComposite* pCrv,
CalculateToolAndCorrVersors( vtCurrDir, m_Params.m_nHeadSide, m_Params.m_nWorkSide, m_Params.m_dSideAngle, vtCurrTool, vtCurrCorr) ;
SetToolDir( vtCurrTool) ;
SetCorrAuxDir( vtCurrCorr) ;
if ( AddCurveMove( pSmpCrv, true) == GDB_ID_NULL)
if ( AddCurveMove( pSmpCrv) == GDB_ID_NULL)
return false ;
}
// 4 -> retrazione
@@ -2943,7 +2974,7 @@ Sawing::GenerateExtCurveCl( const ICurveComposite* pCrv,
pCopy->SimpleOffset( dOffs) ;
}
// emissione
if ( AddCurveMove( pCopy, true) == GDB_ID_NULL)
if ( AddCurveMove( pCopy) == GDB_ID_NULL)
return false ;
}
}
@@ -2976,7 +3007,7 @@ Sawing::GenerateExtCurveCl( const ICurveComposite* pCrv,
// inversione
pCopy->Invert() ;
// emissione
if ( AddCurveMove( pCopy, true) == GDB_ID_NULL)
if ( AddCurveMove( pCopy) == GDB_ID_NULL)
return false ;
}
}
@@ -3043,10 +3074,10 @@ Sawing::GenerateExtCurveCl( const ICurveComposite* pCrv,
pCopy->SimpleOffset( dOffs) ;
}
// emissione
if ( AddCurveMove( pCopy, true) == GDB_ID_NULL)
if ( AddCurveMove( pCopy) == GDB_ID_NULL)
return false ;
}
// se non è ultimo passo
// se non è ultimo passo
if ( i != 0) {
// ricavo punto di risalita e punto iniziale
Point3d ptP4 ;
@@ -3190,7 +3221,7 @@ Sawing::ProcessIntArc( const ICurve* pCrvP, const ICurveArc* pArcC, const ICurve
m_pMchMgr->SetWarning( 2257, "Warning in Sawing : skipped Entity too small") ;
return true ;
}
// ricalcolo i versori fresa alle estremità (potrebbero essere cambiate)
// ricalcolo i versori fresa alle estremità (potrebbero essere cambiate)
pArc->GetStartDir( vtStaDirC) ;
pArc->GetMidDir( vtMidDirC) ;
pArc->GetEndDir( vtEndDirC) ;
@@ -3282,7 +3313,7 @@ Sawing::GenerateIntArcPv( const ICurveArc* pArc,
m_pGeomDB->SetName( nId3, MCH_PV_POST_CUT) ;
m_pGeomDB->SetMaterial( nId3, BLUE) ;
// dimensione da aggiungere alle regioni nelle parti in cui la lama è inclinata
// dimensione da aggiungere alle regioni nelle parti in cui la lama è inclinata
double dExtraL = m_pMchMgr->GetCurrMachiningsMgr()->GetExtraLOnCutRegion() ;
// regione ridotta di taglio per nesting (escluse parti iniziali e finali)
@@ -3336,6 +3367,17 @@ Sawing::GenerateIntArcPv( const ICurveArc* pArc,
if ( ! ExeSurfFrAdd( nRId, nRsId) || ! ExeSurfFrAdd( nRId, nReId))
return false ;
// creo regioni di lavorazione che interessano le superfici superiore e inferiore del grezzo
int nSurfUpId = m_pGeomDB->CopyGlob( nRrId, GDB_ID_NULL, nPxId) ;
m_pGeomDB->SetName( nSurfUpId, MCH_PV_UP_RAWCUT) ;
m_pGeomDB->SetMaterial( nSurfUpId, INVISIBLE) ;
// solo se lavorazione interessa il fondo del grezzo creo la superficie down
if ( dRbHeight < EPS_SMALL) {
int nSurfDownId = m_pGeomDB->CopyGlob( nSurfUpId, GDB_ID_NULL, nPxId) ;
m_pGeomDB->SetName( nSurfDownId, MCH_PV_DOWN_RAWCUT) ;
m_pGeomDB->SetMaterial( nSurfDownId, INVISIBLE) ;
}
// salvo in info gruppo : larghezza XY del taglio, distanza XY tra centro e bordo taglio, extra taglio e quota minima della lama
m_pGeomDB->SetInfo( nPxId, MCH_PV_KEY_WT, dDeltaInt + dDeltaExt) ;
m_pGeomDB->SetInfo( nPxId, MCH_PV_KEY_DT, dDeltaT * dLenCoeff) ;
@@ -3568,12 +3610,12 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
else {
Point3d ptMid ;
pArc->GetMidPoint( ptMid) ;
// prima metà arco
// prima metà arco
SetToolDir( vtMidTool) ;
SetCorrAuxDir( vtMidCorr) ;
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
return false ;
// seconda metà arco
// seconda metà arco
SetToolDir( vtEndTool) ;
SetCorrAuxDir( vtEndCorr) ;
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
@@ -3654,12 +3696,12 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
pArc->GetMidPoint( ptMid) ;
ptMid += Z_AX * dDelta ;
double dCurrAngCen = dAngCen / 2 * ((( i % 2) == 0) ? -1 : 1) ;
// prima metà arco
// prima metà arco
SetToolDir( vtMidTool) ;
SetCorrAuxDir( vtMidCorr) ;
if ( AddArcMove( ptMid, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
return false ;
// seconda metà arco
// seconda metà arco
SetToolDir( ( ( i % 2) == 0) ? vtStaTool : vtEndTool) ;
SetCorrAuxDir( ( ( i % 2) == 0) ? vtStaCorr : vtEndCorr) ;
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
@@ -3743,18 +3785,18 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
Point3d ptMid ;
pArc->GetMidPoint( ptMid) ;
ptMid += Z_AX * dDelta ;
// prima metà arco
// prima metà arco
SetToolDir( vtMidTool) ;
SetCorrAuxDir( vtMidCorr) ;
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
return false ;
// seconda metà arco
// seconda metà arco
SetToolDir( vtEndTool) ;
SetCorrAuxDir( vtEndCorr) ;
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
return false ;
}
// se non è ultimo passo
// se non è ultimo passo
if ( i != 0) {
// movimento di risalita sopra il punto finale
SetFeed( GetEndFeed()) ;
@@ -3876,7 +3918,7 @@ Sawing::CalculateToolAndCorrVersors( const Vector3d& vtTang, int nHeadSide, int
bool
Sawing::AdjustForSide( ICurve* pCurve)
{
// se lato lavoro e lato mandrino coincidono, non devo fare alcunché
// se lato lavoro e lato mandrino coincidono, non devo fare alcunché
if ( ( m_Params.m_nWorkSide == SAW_WS_LEFT && m_Params.m_nHeadSide == SAW_HS_LEFT) ||
( m_Params.m_nWorkSide == SAW_WS_RIGHT && m_Params.m_nHeadSide == SAW_HS_RIGHT))
return true ;
@@ -4045,7 +4087,7 @@ Sawing::AdjustLineForEdges( ICurveLine* pLine, double dElev, const Vector3d& vtC
dDeltaLoExt = dDeltaF ;
}
}
// controllo se lunghezza entità accettabile
// controllo se lunghezza entità accettabile
const double MIN_LEN = 1 ;
double dLenXY = DistXY( pLine->GetStart(), pLine->GetEnd()) ;
if ( dDeltaI + dLenXY + dDeltaF < MIN_LEN) {
@@ -4116,7 +4158,7 @@ Sawing::AdjustCurveForEdges( ICurve* pCrv, double dElev, double dLenCoeff,
dDeltaF = dDeltaT ;
}
dDeltaF *= dLenCoeff ;
// controllo se lunghezza entità accettabile
// controllo se lunghezza entità accettabile
const double MIN_LEN = 1 ;
double dLenXY ;
pCrv->GetLength( dLenXY) ;
+6 -2
View File
@@ -99,6 +99,10 @@ struct SawingData : public MachiningData
//----------------------------------------------------------------------------
inline const SawingData* GetSawingData( const MachiningData* pMdata)
{ return (dynamic_cast<const SawingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_SAWING)
return nullptr ;
return ( static_cast<const SawingData*>( pMdata)) ; }
inline SawingData* GetSawingData( MachiningData* pMdata)
{ return (dynamic_cast<SawingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_SAWING)
return nullptr ;
return ( static_cast<SawingData*>( pMdata)) ; }
+21 -11
View File
@@ -181,16 +181,12 @@ SetupMgr::Import( const string& sFileName)
m_pMchMgr->GetCurrMachGroup() == GDB_ID_NULL)
return false ;
// recupero il gruppo di setup
int nSetupId = m_pMchMgr->GetCurrSetupGroupId() ;
// inizializzo lo scanner
Scanner TheScanner ;
if ( ! TheScanner.Init( sFileName, ";"))
return false ;
// eseguo la lettura dei campi di attrezzaggio
int nPos = 1 ;
string sLine ;
while ( TheScanner.GetLine( sLine)) {
// salto dichiarazione sezione
@@ -228,8 +224,6 @@ SetupMgr::Import( const string& sFileName)
stuData.m_nExit = 0 ;
m_vStuData.emplace_back( stuData) ;
}
// passo alla successiva posizione
++ nPos ;
}
return true ;
@@ -277,14 +271,20 @@ SetupMgr::GetPosData( int nPos, string& sTcPos, string& sHead, int& nExit, strin
bool
SetupMgr::GetToolData( const string& sName, string& sTcPos, string& sHead, int& nExit, int* pnPos) const
{
// reset valori di ritorno
sTcPos.clear() ;
sHead.clear() ;
nExit = 0 ;
if ( pnPos != nullptr)
*pnPos = 0 ;
// verifico validità utensile
if ( IsEmptyOrSpaces( sName))
return false ;
// cerco l'utensile
int nI = - 1 ;
for ( size_t i = 0 ; i < m_vStuData.size() ; ++ i) {
for ( int i = 0 ; i < int( m_vStuData.size()) ; ++ i) {
if ( m_vStuData[i].m_nExit > 0 && EqualNoCase( sName, m_vStuData[i].m_sName)) {
nI = int( i) ;
nI = i ;
break ;
}
}
@@ -318,11 +318,21 @@ SetupMgr::GetToolName( const string& sHead, int nExit, string& sName) const
bool
SetupMgr::GetToolsInSetupPos( const string& sTcPos, STRVECTOR& vsTools) const
{
// default vettore vuoto
vsTools.clear() ;
// eseguo ricerca
// verifico macchina
if ( m_pMachine == nullptr)
return false ;
// eseguo ricerca (con inserimento nel vettore secondo indice dell'uscita)
for ( int i = 0 ; i < int( m_vStuData.size()) ; ++ i) {
if ( EqualNoCase( sTcPos, m_vStuData[i].m_sTcPos)) {
vsTools.emplace_back( m_vStuData[i].m_sName) ;
if ( ! IsEmptyOrSpaces( m_vStuData[i].m_sHead) && EqualNoCase( sTcPos, m_vStuData[i].m_sTcPos)) {
if ( vsTools.empty()) {
int nExitCnt = m_pMachine->GetHeadExitCount( m_vStuData[i].m_sHead) ;
vsTools.resize( nExitCnt) ;
}
int nExit = m_vStuData[i].m_nExit ;
if ( nExit > 0 && nExit <= int( vsTools.size()))
vsTools[nExit - 1] = m_vStuData[i].m_sName ;
}
}
return true ;
+197 -77
View File
@@ -25,9 +25,11 @@
#include "/EgtDev/Include/EGkCDeCylClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeSpheClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeConeFrustumClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h"
#include "/EgtDev/Include/EGkVolZmap.h"
#include "/EgtDev/Include/EGkGeoVector3d.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkSurfLocal.h"
#include "/EgtDev/Include/EXeCmdLogOff.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EMkToolConst.h"
@@ -45,10 +47,12 @@ static const double MIN_STEP = 1.0 ;
static const double MAX_STEP = 100.0 ;
static const double MID_STEP = 50.0 ;
static const double COLL_STEP = 10. ;
static const double SQ_COEFF_ROT_MOVE = 100. ;
static const double COEFF_LIM = 0.999 ;
static const double SAFEDIST_STD = 5.0 ;
static const int ERR_OUTSTROKE = 1 ;
static const int ERR_COLLISION = 11 ;
static const int ERR_TOOL_SEL = 21 ;
//----------------------------------------------------------------------------
Simulator::Simulator( void)
@@ -57,6 +61,7 @@ Simulator::Simulator( void)
m_pGeomDB = nullptr ;
m_pMachine = nullptr ;
m_pPerfCnt = nullptr ;
m_nStatus = SIS_CREATED ;
m_dStep = MID_STEP ;
m_nUiStatus = MCH_UISIM_NULL ;
m_nOpId = GDB_ID_NULL ;
@@ -88,6 +93,8 @@ Simulator::~Simulator( void)
{
// porto la macchina in posizione home
GoHome() ;
// gestione evento uscita dal simulatore
OnExit() ;
// rimuovo tavola variabili globali
m_pMachine->LuaResetGlobVar( GLOB_VAR) ;
// rimuovo performance counter
@@ -109,6 +116,7 @@ Simulator::Init( MachMgr* pMchMgr)
m_pGeomDB = m_pMchMgr->GetGeomDB() ;
m_pMachine = m_pMchMgr->GetCurrMachine() ;
m_pPerfCnt = new PerformanceCounter ;
m_nStatus = SIS_INITIALIZED ;
return true ;
}
@@ -123,12 +131,17 @@ Simulator::Start( bool bFirst)
m_pMchMgr->ResetLastError() ;
m_pMchMgr->ResetWarnings() ;
// Forzo aggiornamento attrezzaggio della macchinata
bool bOk = m_pMchMgr->UpdateCurrSetup() ;
bool bOk = true ;
// Se avvio vero, verifico attrezzaggio
if ( bFirst && ! VerifySetup())
bOk = false ;
// Se appena entrati in simulazione
if ( m_nStatus == SIS_INITIALIZED) {
// Forzo aggiornamento attrezzaggio della macchinata
if ( ! m_pMchMgr->UpdateCurrSetup())
bOk = false ;
// Verifico attrezzaggio
if ( ! VerifySetup())
bOk = false ;
}
// Reset utensile, interpolazione e assi correnti
m_sTool.clear() ;
@@ -139,6 +152,7 @@ Simulator::Start( bool bFirst)
ResetInterpolation() ;
ResetAxes() ;
ResetAuxAxes() ;
// porto la macchina in home
if ( ! GoHome())
bOk = false ;
@@ -157,19 +171,42 @@ Simulator::Start( bool bFirst)
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_VER, GetEMkVer()) ;
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MACHNAME, m_pMachine->GetMachineName()) ;
// Richiamo funzione su avvio simulazione
if ( ! OnStart( bFirst))
// Se appena entrati in simulazione
if ( m_nStatus == SIS_INITIALIZED) {
if ( ! OnInit())
bOk = false ;
m_nStatus = SIS_READYTOSTART ;
}
// Richiamo funzione per evento avvio simulazione
if ( ! OnProgramStart( bFirst))
bOk = false ;
// Arrivo alla preparazione per la prima lavorazione
int nStatus ;
if ( ! FindAndManageOperationStart( true, bFirst, nStatus) && nStatus != MCH_SIM_STOP)
bOk = false ;
// se sono ancora su disposizione
if ( m_pMchMgr->GetOperationType( m_nOpId) == OPER_DISP) {
// ricerca e gestione inizio percorso di lavoro
if ( ! FindAndManagePathStart( nStatus))
return false ;
// eventuali comandi ausiliari di inizio percorso
while ( m_nAuxSInd < m_nAuxSTot) {
if ( ! ManagePathStartAux( nStatus))
return false ;
}
// aggiornamento assi per eventuali teste caricate
UpdateAxes() ;
}
// Reset timer
if ( m_pPerfCnt != nullptr)
m_pPerfCnt->Start() ;
// Imposto lo stato interno
m_nStatus = ( bOk ? SIS_READYTORUN : SIS_READYTOSTART) ;
return bOk ;
}
@@ -225,7 +262,7 @@ bool
Simulator::Move( int& nStatus)
{
// Verifiche
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr || m_pMachine == nullptr) {
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr || m_pMachine == nullptr || m_nStatus != SIS_READYTORUN) {
nStatus = MCH_SIM_ERR ;
return false ;
}
@@ -245,15 +282,15 @@ Simulator::Move( int& nStatus)
m_dCoeff = 0 ;
}
// Se appena arrivato alla fine di un percorso di lavoro
if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd == 0 && m_nCLPathInd > 0) {
// Se appena arrivato alla fine di un percorso di lavoro (verifico anche completamento dei comandi aux di start per path vuote)
if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd == 0 && m_nCLPathInd > 0 && m_nAuxSInd >= m_nAuxSTot) {
// gestione fine percorso di lavoro
if ( ! ManagePathEnd( nStatus))
return false ;
}
// Se alla fine del percorso dopo esecuzione azioni ausiliarie
if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd >= m_nAuxETot) {
// Se alla fine del percorso dopo esecuzione azioni ausiliarie (verifico anche completamento dei comandi aux di start per path vuote)
if ( m_nEntId == GDB_ID_NULL && m_nAuxEInd >= m_nAuxETot && m_nAuxSInd >= m_nAuxSTot) {
// ricerca e gestione inizio percorso di lavoro
if ( ! FindAndManagePathStart( nStatus))
return false ;
@@ -269,7 +306,7 @@ Simulator::Move( int& nStatus)
return false ;
// se non ce ne sono altre, sono alla fine
if ( m_nOpId == GDB_ID_NULL) {
OnEnd() ;
OnProgramEnd() ;
nStatus = MCH_SIM_END ;
return false ;
}
@@ -542,10 +579,10 @@ Simulator::UpdateAxes( void)
if ( pMachine == nullptr)
return false ;
// Carico i nomi e i token degli assi macchina attivi
if ( ! pMachine->GetAllCurrAxesName( m_AxesName) ||
! pMachine->GetAllCurrAxesToken( m_AxesToken))
if ( ! pMachine->GetAllCurrAxesNames( m_AxesName) ||
! pMachine->GetAllCurrAxesTokens( m_AxesToken))
return false ;
// Aggiorno flag invertito, il tipo e la posizione corrente degli assi macchina attivi
// Aggiorno flag di invertito, offset, tipo e posizione corrente degli assi macchina attivi
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
bool bInvert ;
m_pMachine->GetAxisInvert( m_AxesName[i], bInvert) ;
@@ -823,8 +860,9 @@ Simulator::FindAndManagePathStart( int& nStatus)
}
// se altrimenti trovato nuovo CL path vuoto
else if ( m_nCLPathId != GDB_ID_NULL) {
// non ci possono essere eventi ausiliari di inizio
m_nAuxSTot = 0 ;
// recupero il numero di eventi ausiliari di inizio
if ( ! m_pGeomDB->GetInfo( m_nCLPathId, KEY_AS_TOT, m_nAuxSTot))
m_nAuxSTot = 0 ;
m_nAuxSInd = 0 ;
// recupero il numero di eventi ausiliari di fine
if ( ! m_pGeomDB->GetInfo( m_nCLPathId, KEY_AE_TOT, m_nAuxETot))
@@ -988,12 +1026,22 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
// Calcolo distanza di movimento
double dSqDist = 0 ;
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
// coefficiente moltiplicativo per differenziare assi lineari (primi 3) e rotanti (altri)
double dSqCoeff = (( i < 3) ? 1 : 100) ;
// coefficiente moltiplicativo per differenziare assi lineari e rotanti
double dSqCoeff = ( m_AxesLinear[i] ? 1 : SQ_COEFF_ROT_MOVE) ;
dSqDist += dSqCoeff * ( AxesEnd[i] - m_AxesVal[i]) * ( AxesEnd[i] - m_AxesVal[i]) ;
}
// Calcolo distanza di movimento eventuali assi ausiliari
double dSqDistAux = 0 ;
for ( int i = 0 ; i < int( m_AuxAxesName.size()) ; ++ i) {
if ( m_AuxAxesLink[i] != 0)
continue ;
// coefficiente moltiplicativo per differenziare assi lineari e rotanti
double dSqCoeff = ( m_AuxAxesLinear[i] ? 1 : SQ_COEFF_ROT_MOVE) ;
dSqDistAux += dSqCoeff * ( m_AuxAxesEnd[i] - m_AuxAxesVal[i]) * ( m_AuxAxesEnd[i] - m_AuxAxesVal[i]) ;
}
// Considero il massimo delle due distanze
double dPrevCoeff = m_dCoeff ;
double dDist = sqrt( dSqDist) ;
double dDist = sqrt( max( dSqDist, dSqDistAux)) ;
if ( dDist > EPS_SMALL) {
double dStep = min( ( nMoveType == 0 ? 2 : 1) * m_dStep, MAX_STEP) ;
int nStep = max( int( dDist / dStep), 1) ;
@@ -1016,6 +1064,12 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
for ( int i = 0 ; i < int( m_VmId.size()) ; ++ i)
bOkI = m_pGeomDB->GetGlobFrame( m_VmId[i], vFrVzmI[i]) && bOkI ;
// Log per debug
if ( ExeGetDebugLevel() >= 10) {
string sOut = "MoveType=" + ToString( nMoveType) + " Coeff=" + ToString( m_dCoeff) ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str())
}
// Eseguo movimento rapido o lineare
if ( nMoveType != 2 && nMoveType != 3) {
// se attivo CollisionCheck approssimo movimento con più step
@@ -1164,7 +1218,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
double dSqDist = 0 ;
for ( int i = 0 ; i < int( m_AuxAxesName.size()) ; ++ i) {
// coefficiente moltiplicativo per differenziare assi lineari e rotanti
double dSqCoeff = ( m_AuxAxesLinear[i] ? 1 : 100) ;
double dSqCoeff = ( m_AuxAxesLinear[i] ? 1 : SQ_COEFF_ROT_MOVE) ;
dSqDist += dSqCoeff * ( m_AuxAxesEnd[i] - m_AuxAxesVal[i]) * ( m_AuxAxesEnd[i] - m_AuxAxesVal[i]) ;
}
double dPrevCoeff = m_dCoeff ;
@@ -1282,8 +1336,11 @@ Simulator::ExecLineVmill( int nVmId, int nCurrTool, double dVmTdOffs, double dVm
{
// Recupero Zmap
IVolZmap* pVZM = GetVolZmap( m_pGeomDB->GetGeoObj( nVmId)) ;
if ( pVZM == nullptr)
if ( pVZM == nullptr) {
string sOut = " --> GetVolZmap (" + ToString( nVmId) +") Error <--" ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str())
return false ;
}
// Porto gli estremi nel riferimento opportuno dello Zmap
Point3d ptHiL = ptHi ; ptHiL.ToLoc( frVzmI) ;
Vector3d vtHiL = vtHi ; vtHiL.ToLoc( frVzmI) ;
@@ -1296,8 +1353,8 @@ Simulator::ExecLineVmill( int nVmId, int nCurrTool, double dVmTdOffs, double dVm
ptHfL += dVmTdOffs * vtHfL + dVmAdOffs * vtAfL ;
// Log per debug
if ( ExeGetDebugLevel() >= 10) {
string sOut = "Zmap=" + ToString( nVmId) + " CurrTool=" + ToString( nCurrTool) +
"Pi=(" + ToString( ptHiL) + ") Vi=(" + ToString( vtHiL) + ") Ai=(" + ToString( vtAiL) +
string sOut = "Zmap=" + ToString( nVmId) + " Tool=" + ToString( nCurrTool) +
" Pi=(" + ToString( ptHiL) + ") Vi=(" + ToString( vtHiL) + ") Ai=(" + ToString( vtAiL) +
") Pf=(" + ToString( ptHfL) + ") Vf=(" + ToString( vtHfL) + ") Af=(" + ToString( vtAfL) + ")" ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str())
}
@@ -1314,7 +1371,17 @@ Simulator::ExecLineVmill( int nVmId, int nCurrTool, double dVmTdOffs, double dVm
}
}
// Eseguo
return pVZM->MillingStep( nCurrTool, ptHiL, vtHiL, vtAiL, ptHfL, vtHfL, vtAfL) ;
bool bOk = pVZM->MillingStep( nCurrTool, ptHiL, vtHiL, vtAiL, ptHfL, vtHfL, vtAfL) ;
if ( ! bOk) {
if ( ExeGetDebugLevel() < 10) {
string sOut = "Zmap=" + ToString( nVmId) + " Tool=" + ToString( nCurrTool) +
" Pi=(" + ToString( ptHiL) + ") Vi=(" + ToString( vtHiL) + ") Ai=(" + ToString( vtAiL) +
") Pf=(" + ToString( ptHfL) + ") Vf=(" + ToString( vtHfL) + ") Af=(" + ToString( vtAfL) + ")" ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str())
}
LOG_DBG_INFO( GetEMkLogger(), " --> MillingStep Error <--")
}
return bOk ;
}
//----------------------------------------------------------------------------
@@ -1353,44 +1420,62 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType)
// se utensile attivo su grezzo in lavoro e non è rapido, salto
if ( bIsTool && bIsRaw && nMoveType != 0)
continue ;
// se riferimento non trovato, si salta
const IGeoFrame3d* pGeoFrame = GetGeoFrame3d( m_pGeomDB->GetGeoObj( m_CollObj[j].nFrameId)) ;
if ( pGeoFrame == nullptr)
continue ;
// esecuzione controlli di collisione
bool bOk = true ;
Frame3d frObj = pGeoFrame->GetFrame() ;
if ( ! m_CollObj[j].vtMove.IsSmall())
frObj.Translate( m_CollObj[j].vtMove.x * frObj.VersX() +
m_CollObj[j].vtMove.y * frObj.VersY() +
m_CollObj[j].vtMove.z * frObj.VersZ()) ;
Frame3d frParent ; m_pGeomDB->GetGlobFrame( m_CollObj[j].nFrameId, frParent) ;
frObj.LocToLoc( frParent, frCd) ;
if ( m_CollObj[j].nType == MCH_SIM_COB_BOX) {
Vector3d vtDiag( m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3) ;
if ( pVZM != nullptr)
bOk = pVZM->AvoidBox( frObj, vtDiag, m_dSafeDist) ;
else
bOk = ! CDeBoxClosedSurfTm( frObj, vtDiag, m_dSafeDist, *pSTM) ;
// oggetti che richiedono frame associato (Box, Cylinder, Sphere, Cone)
if ( m_CollObj[j].nType != MCH_SIM_COB_POLY) {
// se riferimento non trovato, si salta
const IGeoFrame3d* pGeoFrame = GetGeoFrame3d( m_pGeomDB->GetGeoObj( m_CollObj[j].nFrameId)) ;
if ( pGeoFrame == nullptr)
continue ;
Frame3d frObj = pGeoFrame->GetFrame() ;
if ( ! m_CollObj[j].vtMove.IsSmall())
frObj.Translate( m_CollObj[j].vtMove.x * frObj.VersX() +
m_CollObj[j].vtMove.y * frObj.VersY() +
m_CollObj[j].vtMove.z * frObj.VersZ()) ;
Frame3d frParent ; m_pGeomDB->GetGlobFrame( m_CollObj[j].nFrameId, frParent) ;
frObj.LocToLoc( frParent, frCd) ;
// controlli di collisione
if ( m_CollObj[j].nType == MCH_SIM_COB_BOX) {
Vector3d vtDiag( m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3) ;
if ( pVZM != nullptr)
bOk = ! pVZM->CDeBox( frObj, vtDiag, m_dSafeDist) ;
else
bOk = ! CDeBoxClosedSurfTm( frObj, vtDiag, *pSTM, m_dSafeDist) ;
}
else if ( m_CollObj[j].nType == MCH_SIM_COB_CYL) {
if ( pVZM != nullptr)
bOk = ! pVZM->CDeCylinder( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_dSafeDist) ;
else
bOk = ! CDeCylClosedSurfTm( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, *pSTM, m_dSafeDist) ;
}
else if ( m_CollObj[j].nType == MCH_SIM_COB_SPHE) {
if ( pVZM != nullptr)
bOk = ! pVZM->CDeSphere( frObj.Orig(), m_CollObj[j].dPar1, m_dSafeDist) ;
else
bOk = ! CDeSpheClosedSurfTm( frObj.Orig(), m_CollObj[j].dPar1, *pSTM, m_dSafeDist) ;
}
else if ( m_CollObj[j].nType == MCH_SIM_COB_CONE) {
if ( pVZM != nullptr)
bOk = ! pVZM->CDeConeFrustum( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3, m_dSafeDist) ;
else
bOk = ! CDeConeFrustumClosedSurfTm( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3, *pSTM, m_dSafeDist) ;
}
}
else if ( m_CollObj[j].nType == MCH_SIM_COB_CYL) {
if ( pVZM != nullptr)
bOk = pVZM->AvoidCylinder( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_dSafeDist) ;
// altrimenti poliedro
else {
SurfLocal SurfLoc( m_pGeomDB, m_CollObj[j].nFrameId, frCd) ;
const ISurfTriMesh* pStmLoc = GetSurfTriMesh( SurfLoc) ;
if ( pStmLoc != nullptr) {
if ( pVZM != nullptr)
bOk = ! pVZM->CDeSurfTm( *pStmLoc, m_dSafeDist) ;
else
bOk = ! CDeClosedSurfTmClosedSurfTm( *pStmLoc, *pSTM, m_dSafeDist) ;
}
else
bOk = ! CDeCylClosedSurfTm( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_dSafeDist, *pSTM) ;
}
else if ( m_CollObj[j].nType == MCH_SIM_COB_SPHE) {
if ( pVZM != nullptr)
bOk = pVZM->AvoidSphere( frObj.Orig(), m_CollObj[j].dPar1, m_dSafeDist) ;
else
bOk = ! CDeSpheClosedSurfTm( frObj.Orig(), m_CollObj[j].dPar1, m_dSafeDist, *pSTM) ;
}
else if ( m_CollObj[j].nType == MCH_SIM_COB_CONE) {
if ( pVZM != nullptr)
bOk = pVZM->AvoidConeFrustum( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3, m_dSafeDist) ;
else
bOk = ! CDeConeFrustumClosedSurfTm( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3, m_dSafeDist, *pSTM) ;
bOk = false ;
}
// se trovata collisione
if ( ! bOk) {
nCdInd = i ;
nObjInd = j ;
@@ -1403,7 +1488,29 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType)
//----------------------------------------------------------------------------
bool
Simulator::OnStart( bool bFirst)
Simulator::OnInit( void)
{
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_INIT))
return true ;
// chiamo la funzione di ingresso nella simulazione
return m_pMachine->LuaCallFunction( ON_SIMUL_INIT) ;
}
//----------------------------------------------------------------------------
bool
Simulator::OnExit( void)
{
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_EXIT))
return true ;
// chiamo la funzione di uscita dalla simulazione
return m_pMachine->LuaCallFunction( ON_SIMUL_EXIT) ;
}
//----------------------------------------------------------------------------
bool
Simulator::OnProgramStart( bool bFirst)
{
// assegno flag inizio simulazione
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIM1ST, bFirst) ;
@@ -1417,7 +1524,7 @@ Simulator::OnStart( bool bFirst)
//----------------------------------------------------------------------------
bool
Simulator::OnEnd( void)
Simulator::OnProgramEnd( void)
{
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_END))
@@ -1515,16 +1622,17 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos))
return false ;
// assegno il token e il nome degli assi
bool bIsRobot = m_pMchMgr->GetCurrIsRobot() ;
int nNumAxes = int( m_AxesName.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes) {
if ( ! m_pMachine->LuaSetGlobVar( GetGlobVarAxisToken(i), m_AxesToken[i-1]) ||
! m_pMachine->LuaSetGlobVar( GetGlobVarAxisName(i), m_AxesName[i-1]))
if ( ! m_pMachine->LuaSetGlobVar( GetGlobVarAxisToken( i, bIsRobot), m_AxesToken[i-1]) ||
! m_pMachine->LuaSetGlobVar( GetGlobVarAxisName( i, bIsRobot), m_AxesName[i-1]))
return false ;
}
else {
if ( ! m_pMachine->LuaResetGlobVar( GetGlobVarAxisToken(i)) ||
! m_pMachine->LuaResetGlobVar( GetGlobVarAxisName(i)))
if ( ! m_pMachine->LuaResetGlobVar( GetGlobVarAxisToken( i, bIsRobot)) ||
! m_pMachine->LuaResetGlobVar( GetGlobVarAxisName( i, bIsRobot)))
return false ;
}
}
@@ -1579,8 +1687,10 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
m_AuxAxesLink.emplace_back( 0) ;
}
}
else
else {
bOk = false ;
nErr = ERR_TOOL_SEL ;
}
}
return ( bOk && nErr == 0) ;
@@ -1765,16 +1875,17 @@ Simulator::OnMoveStart( const CamData* pCamData, int& nErr)
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INDEX, pCamData->GetIndex()) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
// valore degli assi all'inizio e alla fine del movimento
bool bIsRobot = m_pMchMgr->GetCurrIsRobot() ;
int nNumAxes = int( m_AxesName.size()) ;
const DBLVECTOR& AxesEnd = pCamData->GetAxesVal() ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes) {
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisPrev( i), m_AxesVal[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisValue( i), AxesEnd[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisPrev( i, GLOB_VAR, bIsRobot), m_AxesVal[i-1]) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisValue( i, GLOB_VAR, bIsRobot), AxesEnd[i-1]) ;
}
else {
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisPrev( i)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue( i)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisPrev( i, GLOB_VAR, bIsRobot)) ;
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue( i, GLOB_VAR, bIsRobot)) ;
}
}
// versori utensile, correzione e ausiliario alla fine del movimento
@@ -1973,6 +2084,10 @@ Simulator::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, con
if ( ( dPar1 < EPS_SMALL && dPar2 < EPS_SMALL) || dPar3 < EPS_SMALL)
return false ;
break ;
case MCH_SIM_COB_POLY :
if ( ! ExeSurfIsClosed( nFrameId))
return false ;
break ;
default :
return false ;
}
@@ -2024,11 +2139,10 @@ Simulator::SetToolForVmill( const string& sTool, const string& sHead, int nExit,
ExeVolZmapSetSawTool( vVmill, sTool, dLen, dDiam, dThick, 0, dCornR, nFlag, bFirst) ;
else if ( nType == TT_WATERJET)
ExeVolZmapSetStdTool( vVmill, sTool, dLen + 50, dDiam, dCornR, dMaxMat, nFlag, bFirst) ;
else if ( nType == TT_ADDITIVE)
ExeVolZmapSetAdditiveTool( vVmill, sTool, dLen, dDiam, dCornR, nFlag, bFirst) ;
else if ( abs( dSideAng) < EPS_ANG_SMALL || abs( dThick) < EPS_SMALL) {
if ( dDiam <= dMaxStemDiam)
ExeVolZmapSetStdTool( vVmill, sTool, dLen, dDiam, dCornR, dMaxMat, nFlag, bFirst) ;
else
ExeVolZmapSetSawTool( vVmill, sTool, dLen, dDiam, dMaxMat, 0, dCornR, nFlag, bFirst) ;
ExeVolZmapSetStdTool( vVmill, sTool, dLen, dDiam, dCornR, dMaxMat, nFlag, bFirst) ;
}
else {
bool bExtra = ( dThick > 0) ;
@@ -2111,6 +2225,7 @@ Simulator::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
static const int STEP_RAPID = -2 ;
static const int STEP_RAPROT = -3 ;
static const int STEP_COLLROT = -4 ;
bool bViewAllFrames = true ;
int nStep = 1 ;
for ( int i = 0 ; i < nAxCount ; ++ i) {
double dMove = abs( vAxNaEpSt[i].dEndPos - vPrev[i]) ;
@@ -2120,10 +2235,14 @@ Simulator::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
dStep = m_dStep ;
else if ( abs( dStep - STEP_RAPID) < EPS_SMALL)
dStep = 4 * m_dStep ;
else if ( abs( dStep - STEP_RAPROT) < EPS_SMALL)
else if ( abs( dStep - STEP_RAPROT) < EPS_SMALL) {
dStep = 0.4 * m_dStep ;
else // STEP_COLLROT
bViewAllFrames = false ;
}
else { // STEP_COLLROT
dStep = min( 0.4 * m_dStep, 10.) ;
bViewAllFrames = false ;
}
}
dStep = max( dStep, 1.) ;
int nAxStep = int( dMove / dStep) + 1 ;
@@ -2158,7 +2277,8 @@ Simulator::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
}
}
// Aggiorno visualizzazione
ExeDraw() ;
if ( bViewAllFrames || ( i % 4) == 0 || i == nStep)
ExeDraw() ;
// Verifico collisioni
int nCdInd, nObjInd ;
bool bCollCheck = ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
+9 -2
View File
@@ -86,8 +86,10 @@ class Simulator
{ return ( ! m_CollObj.empty() && ! m_CdId.empty()) ; }
bool Stopped( void)
{ return ( m_nUiStatus == MCH_UISIM_STOP) ; }
bool OnStart( bool bFirst) ;
bool OnEnd( void) ;
bool OnInit( void) ;
bool OnExit( void) ;
bool OnProgramStart( bool bFirst) ;
bool OnProgramEnd( void) ;
bool OnDispositionStarting( int nOpId, int nOpInd, int nPhase,
const std::string& sTable, const Point3d& ptOri1, bool bEmpty, bool bSomeByHand) ;
bool OnDispositionStart( int nOpId, int nOpInd, int nPhase,
@@ -135,12 +137,17 @@ class Simulator
: sName( sN), sHead( sH), nExit( nE), dTdOffs( dT), dAdOffs( dA) {}
} ;
typedef std::vector<VmTool> VMTVECTOR ;
enum { SIS_CREATED = 0,
SIS_INITIALIZED = 1,
SIS_READYTOSTART = 2,
SIS_READYTORUN = 3} ;
private :
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
Machine* m_pMachine ; // puntatore alla macchina
PerformanceCounter* m_pPerfCnt ; // timer per calcolo FPS
int m_nStatus ; // stato interno del simulatore (creato, inizializzato, pronto al movimento)
double m_dStep ; // lunghezza di riferimento per la velocità di simulazione
int m_nUiStatus ; // stato simulazione a livello utente
int m_nOpId ; // identificativo della operazione (lavoraz.) corrente
+12 -2
View File
@@ -606,6 +606,9 @@ SurfFinishing::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
SetBlockedRotAxis( m_Params.m_sBlockedAxis) ;
@@ -1328,8 +1331,8 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
bool bStart = true ;
while ( OffsCrv.GetCurveCount() > 0) {
// recupero la prima curva di offset
PtrOwner<ICurveComposite> pOffs( CreateCurveComposite()) ;
if ( IsNull( pOffs) || ! pOffs->AddCurve( OffsCrv.GetLongerCurve())) {
PtrOwner<ICurveComposite> pOffs ;
if ( ! pOffs.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve()))) {
m_pMchMgr->SetLastError( 3110, "Error in SurfFinishing : Toolpath not computable") ;
return false ;
}
@@ -1669,6 +1672,13 @@ SurfFinishing::CalcZigZag( const ICurveComposite* pOffs,
nJ = -1 ;
}
}
// se richiesta percorrenza invertita
if ( m_Params.m_bInvert) {
for ( auto& pCompo : vpCrvs)
pCompo->Invert() ;
}
return true ;
}
+6 -2
View File
@@ -83,6 +83,10 @@ struct SurfFinishingData : public MachiningData
//----------------------------------------------------------------------------
inline const SurfFinishingData* GetSurfFinishingData( const MachiningData* pMdata)
{ return (dynamic_cast<const SurfFinishingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_SURFFINISHING)
return nullptr ;
return ( static_cast<const SurfFinishingData*>( pMdata)) ; }
inline SurfFinishingData* GetSurfFinishingData( MachiningData* pMdata)
{ return (dynamic_cast<SurfFinishingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_SURFFINISHING)
return nullptr ;
return ( static_cast<SurfFinishingData*>( pMdata)) ; }
+9 -4
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2024
//----------------------------------------------------------------------------
// File : Table.cpp Data : 25.05.15 Versione : 1.6e7
// File : Table.cpp Data : 19.03.24 Versione : 2.6c2
// Contenuto : Oggetto tavola per gruppo tavola di macchina.
//
//
@@ -45,6 +45,7 @@ Table::Clone( void) const
pTab->m_sName = m_sName ;
pTab->m_nType = m_nType ;
pTab->m_ptRef1 = m_ptRef1 ;
pTab->m_vsColl = m_vsColl ;
}
catch( ...) {
delete pTab ;
@@ -63,7 +64,10 @@ Table::Dump( string& sOut, bool bMM, const char* szNewLine) const
sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ;
sOut += "Name=" + m_sName + szNewLine ;
sOut += "Type=" + ToString( m_nType) + szNewLine ;
sOut += "Ref1=(" + ToString( GetInUiUnits(m_ptRef1, bMM), 4) + ")" + szNewLine ;
sOut += "Ref1=(" + ToString( GetInUiUnits( m_ptRef1, bMM), 4) + ")" + szNewLine ;
sOut += "Area1=(" + ToString( GetInUiUnits( m_b3Area1.GetMin(), bMM), 4) + ";" +
ToString( GetInUiUnits( m_b3Area1.GetMax(), bMM), 4) + szNewLine ;
sOut += "Coll=" + ToString( m_vsColl) + szNewLine ;
return true ;
}
@@ -99,11 +103,12 @@ Table::Table( void)
//----------------------------------------------------------------------------
bool
Table::Set( const string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1)
Table::Set( const string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1, const STRVECTOR& vsColl)
{
m_sName = sName ;
m_nType = nType ;
m_ptRef1 = ptRef1 ;
m_b3Area1 = b3Area1 ;
m_vsColl = vsColl ;
return true ;
}
+4 -1
View File
@@ -30,7 +30,7 @@ class Table : public IUserObj
public :
Table( void) ;
bool Set( const std::string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1) ;
bool Set( const std::string& sName, int nType, const Point3d& ptRef1, const BBox3d& b3Area1, const STRVECTOR& vsColl) ;
const std::string& GetName( void)
{ return m_sName ; }
int GetType( void)
@@ -39,6 +39,8 @@ class Table : public IUserObj
{ return m_ptRef1 ; }
const BBox3d& GetArea1( void)
{ return m_b3Area1 ; }
const STRVECTOR& GetCollGroups( void) const
{ return m_vsColl ; }
private :
int m_nOwnerId ;
@@ -47,4 +49,5 @@ class Table : public IUserObj
int m_nType ;
Point3d m_ptRef1 ;
BBox3d m_b3Area1 ;
STRVECTOR m_vsColl ;
} ;
+8 -8
View File
@@ -738,10 +738,11 @@ ToolsMgr::GetCurrToolThDiam( double& dThDiam) const
if ( ! m_bCurrTool)
return false ;
// se punta a forare, lama, fresa o scalpello
// se punta a forare, lama, fresa, mortasatrice/sega a catena o scalpello
if ( ( m_tdCurrTool.m_nType & TF_DRILLBIT) != 0 ||
( m_tdCurrTool.m_nType & TF_SAWBLADE) != 0 ||
( m_tdCurrTool.m_nType & TF_MILL) != 0 ||
( m_tdCurrTool.m_nType & TF_MORTISE) != 0 ||
( m_tdCurrTool.m_nType & TF_CHISEL) != 0) {
// recupero le dimensioni del porta utensili
double dTHoldBase = 0 ;
@@ -761,9 +762,8 @@ ToolsMgr::GetCurrToolThDiam( double& dThDiam) const
dThDiam = dTHoldDiam ;
return true ;
}
// se mortasatrice/sega a catena o waterjet
else if ( ( m_tdCurrTool.m_nType & TF_MORTISE) != 0 ||
( m_tdCurrTool.m_nType & TF_WATERJET) != 0) {
// se waterjet
else if ( ( m_tdCurrTool.m_nType & TF_WATERJET) != 0) {
dThDiam = 0 ;
return true ;
}
@@ -779,10 +779,11 @@ ToolsMgr::GetCurrToolThLength( double& dThLen) const
if ( ! m_bCurrTool)
return false ;
// se punta a forare, lama, fresa o scalpello
// se punta a forare, lama, fresa, mortasatrice/sega a catena o scalpello
if ( ( m_tdCurrTool.m_nType & TF_DRILLBIT) != 0 ||
( m_tdCurrTool.m_nType & TF_SAWBLADE) != 0 ||
( m_tdCurrTool.m_nType & TF_MILL) != 0 ||
( m_tdCurrTool.m_nType & TF_MORTISE) != 0 ||
( m_tdCurrTool.m_nType & TF_CHISEL) != 0) {
// recupero le dimensioni del porta utensili
double dTHoldBase = 0 ;
@@ -802,9 +803,8 @@ ToolsMgr::GetCurrToolThLength( double& dThLen) const
dThLen = dTHoldLen ;
return true ;
}
// se mortasatrice/sega a catena o waterjet
else if ( ( m_tdCurrTool.m_nType & TF_MORTISE) != 0 ||
( m_tdCurrTool.m_nType & TF_WATERJET) != 0) {
// se waterjet
else if ( ( m_tdCurrTool.m_nType & TF_WATERJET) != 0) {
dThLen = 0 ;
return true ;
}
+169 -152
View File
@@ -740,6 +740,9 @@ WaterJetting::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
SetBlockedRotAxis( m_Params.m_sBlockedAxis) ;
@@ -1673,18 +1676,12 @@ WaterJetting::ProcessPath( int nPathId, int nPvId, int nClId)
m_pGeomDB->GetName( nPathId, sPathName) ;
// eventuale approssimazione con segmenti di retta
int nSplitArcs = m_pMchMgr->GetCurrMachiningsMgr()->GetSplitArcs() ;
bool bSplitArcs = ( nSplitArcs == SPLAR_ALWAYS ||
( nSplitArcs == SPLAR_NO_XY_PLANE && ! vtTool.IsZplus()) ||
( nSplitArcs == SPLAR_GEN_PLANE && vtTool.IsGeneric())) ;
if ( bSplitArcs && ! ApproxWithLines( pCompo)) {
m_pMchMgr->SetLastError( 3211, "Error in WaterJetting : Linear Approx not computable") ;
return false ;
bool bSplitArcs = GetSplitArcs( vtTool) ;
if ( ! bSplitArcs) {
// verifiche sull'ampiezza dell'angolo al centro degli eventuali archi
VerifyArcs( pCompo) ;
}
// verifiche sull'ampiezza dell'angolo al centro degli eventuali archi
VerifyArcs( pCompo) ;
// se abilitato probing, verifico lunghezza entità ed eventualmente le divido
if ( m_Params.m_bProbing)
VerifyMaxLenCurves( pCompo, m_Params.m_dProbingMaxDist) ;
@@ -1777,8 +1774,8 @@ WaterJetting::GeneratePreView( int nPathId, const ICurveComposite* pCompo, doubl
// calcolo la regione
PtrOwner<ISurfFlatRegion> pSfr ;
double dSideCoeff = ( abs( m_Params.m_dSideAngle) > EPS_ANG_SMALL ? 1. / cos( m_Params.m_dSideAngle * DEGTORAD) : 1) ;
double Rad = 0.5 * m_TParams.m_dDiam * dSideCoeff ;
pSfr.Set( GetSurfFlatRegionFromFatCurve( Release( pCrv), Rad, false, false)) ;
double dRad = 0.5 * m_TParams.m_dDiam * dSideCoeff ;
pSfr.Set( GetSurfFlatRegionFromFatCurve( Release( pCrv), dRad, false, false)) ;
if ( IsNull( pSfr))
return false ;
// aggiungo eventuale attacco
@@ -1790,32 +1787,18 @@ WaterJetting::GeneratePreView( int nPathId, const ICurveComposite* pCompo, doubl
// aggiungo eventuali anelli su angoli esterni
if ( ! AddLoopsPreview( pCompo, pSfr))
return false ;
// ne recupero il contorno
PtrOwner< ICurve> pCrv2 ;
pCrv2.Set( pSfr->GetLoop( 0, 0)) ;
if ( IsNull( pCrv2))
return false ;
// inserisco la curva nel DB
int nC2Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pCrv2)) ;
if ( nC2Id == GDB_ID_NULL)
return false ;
// assegno nome e colore
m_pGeomDB->SetName( nC2Id, MCH_PV_CUT) ;
m_pGeomDB->SetMaterial( nC2Id, colCut) ;
// eventuali altri contorni ( interni di contornatura chiusa)
const int MAX_INT_LOOP = 1000 ;
for ( int i = 1 ; i <= MAX_INT_LOOP ; ++i) {
PtrOwner< ICurve> pCrv3 ;
pCrv3.Set( pSfr->GetLoop( 0, i)) ;
if ( IsNull( pCrv3))
break ;
// ne recupero i contorni
for ( int i = 0 ; i < pSfr->GetLoopCount( 0) ; ++i) {
PtrOwner<ICurve> pCrv2( pSfr->GetLoop( 0, i)) ;
if ( IsNull( pCrv2))
return false ;
// inserisco la curva nel DB
int nC3Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pCrv3)) ;
if ( nC3Id == GDB_ID_NULL)
int nC2Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pCrv2)) ;
if ( nC2Id == GDB_ID_NULL)
return false ;
// assegno nome e colore
m_pGeomDB->SetName( nC3Id, MCH_PV_CUT) ;
m_pGeomDB->SetMaterial( nC3Id, colCut) ;
m_pGeomDB->SetName( nC2Id, MCH_PV_CUT) ;
m_pGeomDB->SetMaterial( nC2Id, colCut) ;
}
// inserisco la regione nel DB
int nRId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pSfr)) ;
@@ -1829,10 +1812,11 @@ WaterJetting::GeneratePreView( int nPathId, const ICurveComposite* pCompo, doubl
return false ;
m_pGeomDB->SetName( nRrId, MCH_PV_RRCUT) ;
m_pGeomDB->SetMaterial( nRrId, INVISIBLE) ;
// eventuali ripetizioni in basso per tagli inclinati
if ( abs( m_Params.m_dSideAngle) > EPS_ANG_SMALL) {
// creo copia della curva composita
PtrOwner< ICurve> pCrv( pCompo->Clone()) ;
PtrOwner<ICurveComposite> pCrv( pCompo->Clone()) ;
if ( IsNull( pCrv))
return false ;
// rimuovo eventuale overlap
@@ -1841,98 +1825,114 @@ WaterJetting::GeneratePreView( int nPathId, const ICurveComposite* pCompo, doubl
pCrv->TrimStartAtLen( dAddedOverlap) ;
pCrv->Invert() ;
}
ICURVEPOVECTOR vpCrvs ;
if ( m_Params.m_dSideAngle < 0) {
// se inclinazione negativa devo considerare separatamente ogni sottocurva della composita
vpCrvs.reserve( pCrv->GetCurveCount()) ;
for ( int i = 0 ; i < pCrv->GetCurveCount() ; i++)
vpCrvs.emplace_back( pCrv->GetCurve( i)->Clone()) ;
}
else {
// se inclinazione positiva posso considerare la curva completa
vpCrvs.emplace_back( pCrv->Clone()) ;
}
// offset per raggio utensile
double dRad = 0.5 * m_TParams.m_dDiam / cos( m_Params.m_dSideAngle * DEGTORAD) ;
double dSignOffs1 = dRad ;
double dSignOffs1 = dRad ;
if ( ( m_Params.m_nWorkSide == WJET_WS_RIGHT && m_Params.m_dSideAngle > 0) ||
( m_Params.m_nWorkSide == WJET_WS_LEFT && m_Params.m_dSideAngle < 0))
dSignOffs1 = - dSignOffs1 ;
OffsetCurve OffsCrv1 ;
OffsCrv1.Make( pCrv, dSignOffs1, ICurve::OFF_FILLET) ;
PtrOwner< ICurve> pOffs1( OffsCrv1.GetLongerCurve()) ;
if ( IsNull( pOffs1))
return false ;
// offset per inclinazione
double dSignOffs2 = dRad + m_dElev * abs( sin( m_Params.m_dSideAngle * DEGTORAD)) ;
if ( ( m_Params.m_nWorkSide == WJET_WS_RIGHT && m_Params.m_dSideAngle < 0) ||
( m_Params.m_nWorkSide == WJET_WS_LEFT && m_Params.m_dSideAngle > 0))
dSignOffs2 = - dSignOffs2 ;
OffsetCurve OffsCrv2 ;
OffsCrv2.Make( pCrv, dSignOffs2, ICurve::OFF_EXTEND) ;
PtrOwner< ICurve> pOffs2( OffsCrv2.GetLongerCurve()) ;
if ( IsNull( pOffs2))
return false ;
// calcolo la regione
PtrOwner<ISurfFlatRegion> pSfr ;
// se i due offset sono aperti
if ( ! pOffs1->IsClosed() && ! pOffs2->IsClosed()) {
// li unisco
PtrOwner<ICurveComposite> pBound( CreateCurveComposite()) ;
if ( IsNull( pBound))
return false ;
pBound->AddCurve( Release( pOffs1)) ;
pOffs2->Invert() ;
Point3d ptStart ; pOffs2->GetStartPoint( ptStart) ;
pBound->AddLine( ptStart) ;
pBound->AddCurve( Release( pOffs2)) ;
pBound->Close() ;
// creo la regione
SurfFlatRegionByContours SfrCntr( false, false) ;
SfrCntr.AddCurve( Release( pBound)) ;
pSfr.Set( SfrCntr.GetSurf()) ;
}
// altrimenti sono chiusi
else {
// creo la regione
SurfFlatRegionByContours SfrCntr( false, false) ;
SfrCntr.AddCurve( Release( pOffs1)) ;
SfrCntr.AddCurve( Release( pOffs2)) ;
pSfr.Set( SfrCntr.GetSurf()) ;
}
PtrOwner<ISurfFlatRegion> pSfr( CreateSurfFlatRegion()) ;
if ( IsNull( pSfr))
return false ;
for ( int i = 0 ; i < int( vpCrvs.size()) ; i++) {
OffsetCurve OffsCrv1 ;
OffsCrv1.Make( vpCrvs[i], dSignOffs1, ICurve::OFF_FILLET) ;
PtrOwner< ICurve> pOffs1( OffsCrv1.GetLongerCurve()) ;
if ( IsNull( pOffs1))
return false ;
OffsetCurve OffsCrv2 ;
OffsCrv2.Make( vpCrvs[i], dSignOffs2, ICurve::OFF_EXTEND) ;
PtrOwner< ICurve> pOffs2( OffsCrv2.GetLongerCurve()) ;
if ( IsNull( pOffs2))
return false ;
// calcolo la regione corrente
PtrOwner<ISurfFlatRegion> pSfrCurr ;
// se i due offset sono aperti
if ( ! pOffs1->IsClosed() && ! pOffs2->IsClosed()) {
// li unisco
PtrOwner<ICurveComposite> pBound( CreateCurveComposite()) ;
if ( IsNull( pBound))
return false ;
pBound->AddCurve( Release( pOffs1)) ;
pOffs2->Invert() ;
Point3d ptStart ; pOffs2->GetStartPoint( ptStart) ;
pBound->AddLine( ptStart) ;
pBound->AddCurve( Release( pOffs2)) ;
pBound->Close() ;
// creo la regione
SurfFlatRegionByContours SfrCntr( false, false) ;
SfrCntr.AddCurve( Release( pBound)) ;
pSfrCurr.Set( SfrCntr.GetSurf()) ;
}
// altrimenti sono chiusi
else {
// creo la regione
SurfFlatRegionByContours SfrCntr( false, false) ;
SfrCntr.AddCurve( Release( pOffs1)) ;
SfrCntr.AddCurve( Release( pOffs2)) ;
pSfrCurr.Set( SfrCntr.GetSurf()) ;
}
if ( IsNull( pSfrCurr))
return false ;
// aggiungo alla superficie complessiva
if ( pSfr->IsValid())
pSfr->Add( *pSfrCurr) ;
else
pSfr.Set( Release( pSfrCurr)) ;
}
// la regione deve essere rivolta verso Z+
if ( pSfr->GetNormVersor().z < 0)
pSfr->Invert() ;
// ne recupero il contorno
PtrOwner< ICurve> pCrv2 ;
pCrv2.Set( pSfr->GetLoop( 0, 0)) ;
if ( IsNull( pCrv2))
return false ;
// inserisco la curva nel DB
int nC2Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pCrv2)) ;
if ( nC2Id == GDB_ID_NULL)
return false ;
// assegno nome e colore
m_pGeomDB->SetName( nC2Id, MCH_PV_DOWN_CUT) ;
m_pGeomDB->SetMaterial( nC2Id, colCut) ;
// eventuali altri contorni ( interni di contornatura chiusa)
const int MAX_INT_LOOP = 1000 ;
for ( int i = 1 ; i <= MAX_INT_LOOP ; ++i) {
PtrOwner< ICurve> pCrv3 ;
pCrv3.Set( pSfr->GetLoop( 0, i)) ;
if ( IsNull( pCrv3))
break ;
// inserisco la curva nel DB
int nC3Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pCrv3)) ;
if ( nC3Id == GDB_ID_NULL)
// aggiungo eventuali loops
AddLoopsPreview( pCrv, pSfr) ;
// ne recupero i contorni
for ( int i = 0 ; i < pSfr->GetLoopCount( 0) ; ++i) {
PtrOwner<ICurve> pCrv2( pSfr->GetLoop( 0, i)) ;
if ( IsNull( pCrv2))
return false ;
// assegno nome e colore
m_pGeomDB->SetName( nC3Id, MCH_PV_DOWN_CUT) ;
m_pGeomDB->SetMaterial( nC3Id, colCut) ;
// inserisco la curva nel DB
int nC2Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pCrv2)) ;
if ( nC2Id == GDB_ID_NULL)
return false ;
// assegno nome e colore
m_pGeomDB->SetName( nC2Id, MCH_PV_DOWN_CUT) ;
m_pGeomDB->SetMaterial( nC2Id, colCut) ;
}
// inserisco la regione nel DB
// inserisco la regione nel DB
int nRId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pSfr)) ;
if ( nRId == GDB_ID_NULL)
return false ;
m_pGeomDB->SetName( nRId, MCH_PV_DOWN_RCUT) ;
m_pGeomDB->SetMaterial( nRId, INVISIBLE) ;
// la copio anche come regione ridotta
// la copio anche come regione ridotta
int nRrId = m_pGeomDB->Copy( nRId, GDB_ID_NULL, nPathId) ;
if ( nRrId == GDB_ID_NULL)
return false ;
m_pGeomDB->SetName( nRrId, MCH_PV_DOWN_RRCUT) ;
m_pGeomDB->SetMaterial( nRrId, INVISIBLE) ;
m_pGeomDB->SetMaterial( nRrId, INVISIBLE) ;
}
return true ;
}
@@ -2080,6 +2080,11 @@ WaterJetting::AddLoopsPreview( const ICurveComposite* pCompo, ISurfFlatRegion* p
return false ;
// lunghezza tratti lineari e loro punti estremi
double dTgLen = 0.5 * m_TParams.m_dDiam * tan( 0.5 * dAng * DEGTORAD) ;
if ( m_Params.m_dSideAngle > EPS_ANG_SMALL) {
double dW = m_dElev * sin( m_Params.m_dSideAngle * DEGTORAD) ;
double dExtraLen = dW / tan( ( 180 - abs( dAng)) / 2 * DEGTORAD) ;
dTgLen += dExtraLen ;
}
Point3d ptP ; pCrvC->GetStartPoint( ptP) ;
Point3d ptPe = ptP + vtEnd * dTgLen ;
Point3d ptPs = ptP - vtStart * dTgLen ;
@@ -2112,7 +2117,6 @@ WaterJetting::AddLoopsPreview( const ICurveComposite* pCompo, ISurfFlatRegion* p
if ( IsNull( pSfr) || ! pSPV->Add( *pSfr))
return false ;
}
}
return true ;
}
@@ -2244,7 +2248,7 @@ WaterJetting::AddStandardWj( const ICurveComposite* pCompo, const Vector3d& vtTo
// imposto versore correzione e ausiliario sul punto di partenza
CalcAndSetToolCorrAuxDir( pCompo, i) ;
// aggiungo approccio al punto iniziale
if ( ! AddApproach( ptP1, vtTool, dSafeZ)) {
if ( ! AddApproach( ptP1, vtTool, dSafeZ, bSplitArcs)) {
m_pMchMgr->SetLastError( 3207, "Error in WaterJetting : Approach not computable") ;
return false ;
}
@@ -2270,27 +2274,57 @@ WaterJetting::AddStandardWj( const ICurveComposite* pCompo, const Vector3d& vtTo
vtEnd.GetAngleXY( vtStart, dAng) ;
// Se angolo esterno e richiesto anello esterno
if ( IsExternalAngle( dAng) && m_Params.m_nExtCornerType == WJET_EC_LOOP) {
// lunghezza tratti lineari e loro punti estremi
// lunghezza tratti lineari
double dTgLen = 0.5 * m_TParams.m_dDiam * tan( 0.5 * dAng * DEGTORAD) ;
if ( m_Params.m_dSideAngle > EPS_ANG_SMALL) {
// se inclinazione positiva calcolo di quanto deve uscire per non rovinare lo spigolo
double dW = m_dElev * sin( m_Params.m_dSideAngle * DEGTORAD) ;
double dExtraLen = dW / tan( ( 180 - abs( dAng)) / 2 * DEGTORAD) ;
dTgLen += dExtraLen ;
}
// calcolo punti estremi
Point3d ptP ; pCrvC->GetStartPoint( ptP) ;
Point3d ptPe = ptP + vtEnd * dTgLen ;
Point3d ptPs = ptP - vtStart * dTgLen ;
// tratto prima dell'anello
SetFeed( GetActualFeed()) ;
if ( AddLinearMove( ptPe) == GDB_ID_NULL)
if ( AddLinearMove( ptPe, bSplitArcs) == GDB_ID_NULL)
return false ;
// anello
PtrOwner<ICurve> pCrvA( GetArc2PVN( ptPe, ptPs, vtEnd, vtN)) ;
if ( ! IsNull( pCrvA) && pCrvA->GetType() == CRV_ARC) {
if ( AddCurveMove( pCrvA) == GDB_ID_NULL)
// suddivido l'anello in due parti per forzare il passaggio dalla posizione vtTool = Z_AX
PtrOwner<ICurveComposite> pCompoArc( ConvertCurveToComposite( Release( ( pCrvA)))) ;
if ( IsNull( pCompoArc))
return false ;
if ( pCompoArc->AddJoint( 0.5)) {
// aggiungo il primo tratto
Vector3d vtCorr = CalcCorrDir( pCompoArc, 1) ;
SetToolCorrAuxDir( Z_AX, vtCorr) ;
if ( AddCurveMove( pCompoArc->GetCurve(0), bSplitArcs) == GDB_ID_NULL)
return false ;
// aggiungo secondo tratto
CalcAndSetToolCorrAuxDir( pCompo, i + 0.5) ;
if ( AddCurveMove( pCompoArc->GetCurve(1), bSplitArcs) == GDB_ID_NULL)
return false ;
}
else {
// se non è possibile suddividere anello
CalcAndSetToolCorrAuxDir( pCompo, i + 0.5) ;
if ( AddCurveMove( pCompoArc, bSplitArcs) == GDB_ID_NULL)
return false ;
}
}
else {
if ( AddLinearMove( ptPs) == GDB_ID_NULL)
CalcAndSetToolCorrAuxDir( pCompo, i + 0.5) ;
if ( AddLinearMove( ptPs, bSplitArcs) == GDB_ID_NULL)
return false ;
}
// tratto dopo l'anello
if ( AddLinearMove( ptP) == GDB_ID_NULL)
if ( AddLinearMove( ptP, bSplitArcs) == GDB_ID_NULL)
return false ;
}
// se angolo esterno e richiesto rallentamento esterno, eseguo accelerazione
@@ -2310,7 +2344,7 @@ WaterJetting::AddStandardWj( const ICurveComposite* pCompo, const Vector3d& vtTo
return false ;
CalcAndSetToolCorrAuxDir( pCompo, i + dU) ;
SetFeed( ( 1 - dCoeff) * dMinFeed + dCoeff * GetActualFeed()) ;
if ( AddCurveMove( pCrvT) == GDB_ID_NULL)
if ( AddCurveMove( pCrvT, bSplitArcs) == GDB_ID_NULL)
return false ;
dUprev = dU ;
}
@@ -2352,7 +2386,7 @@ WaterJetting::AddStandardWj( const ICurveComposite* pCompo, const Vector3d& vtTo
Vector3d vtCorr = CalcCorrDir( pCompo, i + dU) ;
SetToolCorrAuxDir( vtTool, vtCorr) ;
SetFeed( ( 1 - dCoeff) * dMinFeed + dCoeff * GetActualFeed()) ;
if ( AddCurveMove( pCrvT) == GDB_ID_NULL)
if ( AddCurveMove( pCrvT, bSplitArcs) == GDB_ID_NULL)
return false ;
dUprev = dU ;
}
@@ -2389,7 +2423,7 @@ WaterJetting::AddStandardWj( const ICurveComposite* pCompo, const Vector3d& vtTo
return false ;
CalcAndSetToolCorrAuxDir( pCompo, i + dU) ;
SetFeed( ( 1 - dCoeff) * GetActualFeed() + dCoeff * dMinFeed) ;
if ( AddCurveMove( pCrvT) == GDB_ID_NULL)
if ( AddCurveMove( pCrvT, bSplitArcs) == GDB_ID_NULL)
return false ;
dUprev = dU ;
}
@@ -2432,15 +2466,22 @@ WaterJetting::AddStandardWj( const ICurveComposite* pCompo, const Vector3d& vtTo
Vector3d vtCorr = CalcCorrDir( pCompo, i + dU) ;
SetToolCorrAuxDir( vtTool, vtCorr) ;
SetFeed( ( 1 - dCoeff) * GetActualFeed() + dCoeff * dMinFeed) ;
if ( AddCurveMove( pCrvT) == GDB_ID_NULL)
if ( AddCurveMove( pCrvT, bSplitArcs) == GDB_ID_NULL)
return false ;
dUprev = dU ;
}
dNextFeed = dMinFeed ;
}
// se successivo non è angolo esterno ad anello imposto versore correzione e ausiliario del punto di arrivo
if ( ! IsExternalAngle( dAng) || m_Params.m_nExtCornerType != WJET_EC_LOOP)
CalcAndSetToolCorrAuxDir( pCompo, i + 1) ;
}
// imposto versore correzione e ausiliario del punto di arrivo
CalcAndSetToolCorrAuxDir( pCompo, i + 1) ;
else {
// se ultima entità imposto versore correzione e ausiliario del punto finale
CalcAndSetToolCorrAuxDir( pCompo, i + 1) ;
}
// elaborazioni sulla curva corrente
if ( pCurve->GetType() == CRV_LINE) {
ICurveLine* pLine = GetCurveLine( pCurve) ;
@@ -2453,25 +2494,20 @@ WaterJetting::AddStandardWj( const ICurveComposite* pCompo, const Vector3d& vtTo
}
else
++ nIdxSkip ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
if ( AddLinearMove( ptP3, bSplitArcs) == GDB_ID_NULL)
return false ;
}
else if ( pCurve->GetType() == CRV_ARC) {
ICurveArc* pArc = GetCurveArc( pCurve) ;
Point3d ptCen = pArc->GetCenter() ;
double dAngCen = pArc->GetAngCenter() ;
Point3d ptP3 ; pArc->GetEndPoint( ptP3) ;
Point3d ptCurr ; GetCurrPos( ptCurr) ;
double dDeltaAng ; pArc->CalcPointAngle( ptCurr, dDeltaAng) ;
SetFeed( dNextFeed) ;
// controlli per indice del punto di arrivo
Point3d ptP3 ; pCurve->GetEndPoint( ptP3) ;
if ( SqDistXY( ptP3, m_ptLastProbe) >= m_Params.m_dProbingMinDist * m_Params.m_dProbingMinDist) {
SetIndex( i + 1 - nIdxSkip) ;
m_ptLastProbe = ptP3 ;
}
else
++ nIdxSkip ;
if ( AddArcMove( ptP3, ptCen, dAngCen - dDeltaAng, vtN) == GDB_ID_NULL)
if ( AddCurveMove( pCurve, bSplitArcs) == GDB_ID_NULL)
return false ;
}
// se ultima entità, uscita e retrazione
@@ -2488,7 +2524,7 @@ WaterJetting::AddStandardWj( const ICurveComposite* pCompo, const Vector3d& vtTo
}
// aggiungo retrazione
SetFlag( 203) ;
if ( ! AddRetract( ptP1, vtTool, dSafeZ)) {
if ( ! AddRetract( ptP1, vtTool, dSafeZ, bSplitArcs)) {
m_pMchMgr->SetLastError( 3210, "Error in WaterJetting : Retract not computable") ;
return false ;
}
@@ -2522,7 +2558,7 @@ class LeadIOStatus
//----------------------------------------------------------------------------
bool
WaterJetting::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ)
WaterJetting::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, bool bSplit)
{
SetFlag( 1) ;
// 1 -> punto sopra inizio
@@ -2531,18 +2567,18 @@ WaterJetting::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dS
return false ;
// affondo al punto iniziale
SetFlag( ( m_Params.m_bLiHole ? 201 : 202)) ;
if ( AddRapidMove( ptP) == GDB_ID_NULL)
if ( AddRapidMove( ptP, bSplit) == GDB_ID_NULL)
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
WaterJetting::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ)
WaterJetting::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, bool bSplit)
{
// Risalgo in rapido alla quota di sicurezza
Point3d ptP4 = ptP + vtTool * dSafeZ ;
if ( AddRapidMove( ptP4) == GDB_ID_NULL)
if ( AddRapidMove( ptP4, bSplit) == GDB_ID_NULL)
return false ;
return true ;
}
@@ -2592,29 +2628,19 @@ WaterJetting::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vect
{
// Assegno il tipo
int nType = GetLeadInType() ;
double dTang = m_Params.m_dLiTang ;
// Eseguo a seconda del tipo
switch ( nType) {
case WJET_LI_NONE :
return true ;
case WJET_LI_LINEAR :
return ( AddLinearMove( ptStart, MCH_CL_LEADIN) != GDB_ID_NULL) ;
return ( AddLinearMove( ptStart, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
case WJET_LI_TANGENT :
{
PtrOwner<ICurve> pCrv( GetArc2PVN( ptStart, ptP1, - vtStart, vtN)) ;
if ( IsNull( pCrv))
return false ;
pCrv->Invert() ;
// eventuale spezzatura
if ( bSplitArcs) {
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pCrv)) || ! ApproxWithLines( pCompo))
return false ;
return ( AddCurveMove( pCompo, MCH_CL_LEADIN) != GDB_ID_NULL) ;
}
else {
return ( AddCurveMove( pCrv, MCH_CL_LEADIN) != GDB_ID_NULL) ;
}
return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ;
}
default :
return false ;
@@ -2664,7 +2690,7 @@ WaterJetting::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vec
Vector3d vtPerp = vtEnd ;
vtPerp.Rotate( vtN, 0, ( bCcwRot ? 1 : - 1)) ;
ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ;
return ( AddLinearMove( ptP1, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
return ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
}
case WJET_LO_TANGENT :
{
@@ -2676,16 +2702,7 @@ WaterJetting::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vec
PtrOwner<ICurve> pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtN)) ;
if ( IsNull( pCrv))
return false ;
// eventuale spezzatura
if ( bSplitArcs) {
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pCrv)) || ! ApproxWithLines( pCompo))
return false ;
return ( AddCurveMove( pCompo, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
}
else {
return ( AddCurveMove( pCrv, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
}
return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
}
default :
return false ;
@@ -2949,7 +2966,7 @@ WaterJetting::CalcOffset( ICurveComposite* pCompo, double dSignOffs)
//----------------------------------------------------------------------------
// Valore limite angolo per corner
const double ANG_CORNER = 10 ;
const double ANG_CORNER = 10 ;
//----------------------------------------------------------------------------
bool
+2 -2
View File
@@ -81,8 +81,8 @@ class WaterJetting : public Machining
bool AddLeadOutPreview( const ICurveComposite* pCompo, ISurfFlatRegion* pSPV) ;
bool AddLoopsPreview( const ICurveComposite* pCompo, ISurfFlatRegion* pSPV) ;
bool AddStandardWj( const ICurveComposite* pCompo, const Vector3d& vtTool, bool bSplitArcs) ;
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ) ;
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ) ;
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, bool bSplit) ;
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, bool bSplit) ;
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
const ICurveComposite* pCompo, Point3d& ptP1) const ;
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart,
+6 -2
View File
@@ -102,6 +102,10 @@ struct WaterJettingData : public MachiningData
//----------------------------------------------------------------------------
inline const WaterJettingData* GetWaterJettingData( const MachiningData* pMdata)
{ return (dynamic_cast<const WaterJettingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_WATERJETTING)
return nullptr ;
return ( static_cast<const WaterJettingData*>( pMdata)) ; }
inline WaterJettingData* GetWaterJettingData( MachiningData* pMdata)
{ return (dynamic_cast<WaterJettingData*>( pMdata)) ; }
{ if ( pMdata == nullptr || pMdata->GetType() != MT_WATERJETTING)
return nullptr ;
return ( static_cast<WaterJettingData*>( pMdata)) ; }