diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc
index 0a6da7e..ae6fb4a 100644
Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ
diff --git a/EgtMachKernel.vcxproj b/EgtMachKernel.vcxproj
index 0dc0ba1..e2cd8da 100644
--- a/EgtMachKernel.vcxproj
+++ b/EgtMachKernel.vcxproj
@@ -221,6 +221,8 @@ copy $(TargetPath) \EgtProg\Dll64
+
+
@@ -280,6 +282,8 @@ copy $(TargetPath) \EgtProg\Dll64
+
+
diff --git a/EgtMachKernel.vcxproj.filters b/EgtMachKernel.vcxproj.filters
index 6cd1a30..e5e6ac2 100644
--- a/EgtMachKernel.vcxproj.filters
+++ b/EgtMachKernel.vcxproj.filters
@@ -180,6 +180,12 @@
Source Files\MachMgr
+
+ Source Files\Machinings
+
+
+ Source Files\Operations
+
@@ -308,6 +314,12 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
diff --git a/GenMachining.cpp b/GenMachining.cpp
new file mode 100644
index 0000000..f1b587a
--- /dev/null
+++ b/GenMachining.cpp
@@ -0,0 +1,1416 @@
+//----------------------------------------------------------------------------
+// EgalTech 2017-2017
+//----------------------------------------------------------------------------
+// File : GenMachining.cpp Data : 15.01.17 Versione : 1.6x7
+// Contenuto : Implementazione gestione lavorazione generica.
+//
+//
+//
+// Modifiche : 15.01.17 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "MachMgr.h"
+#include "DllMain.h"
+#include "GenMachining.h"
+#include "MachiningConst.h"
+#include "/EgtDev/Include/EGkCurveLine.h"
+#include "/EgtDev/Include/EGkCurveArc.h"
+#include "/EgtDev/Include/EGkCurveComposite.h"
+#include "/EgtDev/Include/EgkArcSpecial.h"
+#include "/EgtDev/Include/EgkChainCurves.h"
+#include "/EgtDev/Include/EGkSfrCreate.h"
+#include "/EgtDev/Include/EGkSurfTriMesh.h"
+#include "/EgtDev/Include/EGkUserObjFactory.h"
+#include "/EgtDev/Include/EGnStringKeyVal.h"
+#include "/EgtDev/Include/EgtPointerOwner.h"
+
+using namespace std ;
+
+//----------------------------------------------------------------------------
+USEROBJ_REGISTER( "EMkGenMachining", GenMachining) ;
+
+//----------------------------------------------------------------------------
+const string&
+GenMachining::GetClassName( void) const
+{
+ return USEROBJ_GETNAME( GenMachining) ;
+}
+
+//----------------------------------------------------------------------------
+GenMachining*
+GenMachining::Clone( void) const
+{
+ // alloco oggetto
+ GenMachining* pGenM = new(nothrow) GenMachining ;
+ // eseguo copia dei dati
+ if ( pGenM != nullptr) {
+ try {
+ pGenM->m_Params = m_Params ;
+ pGenM->m_TParams = m_TParams ;
+ }
+ catch( ...) {
+ delete pGenM ;
+ return nullptr ;
+ }
+ }
+ // ritorno l'oggetto
+ return pGenM ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::Dump( string& sOut, bool bMM, const char* szNewLine) const
+{
+ sOut += GetClassName() + "[mm]" + szNewLine ;
+ sOut += KEY_PHASE + EQUAL + ToString( m_nPhase) + szNewLine ;
+ sOut += KEY_IDS + EQUAL + ToString( m_vId) + szNewLine ;
+ for ( int i = 0 ; i < m_Params.GetSize() ; ++ i)
+ sOut += m_Params.ToString( i) + szNewLine ;
+ for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i)
+ sOut += m_TParams.ToString( i) + szNewLine ;
+ sOut += KEY_NUM + EQUAL + ToString( m_nMills) + szNewLine ;
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::Save( STRVECTOR& vString) const
+{
+ try {
+ int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() + 2 ;
+ vString.insert( vString.begin(), nSize, "") ;
+ int k = - 1 ;
+ if ( ! SetVal( KEY_IDS, m_vId, vString[++k]))
+ return false ;
+ for ( int i = 0 ; i < m_Params.GetSize() ; ++ i)
+ vString[++k] = m_Params.ToString( i) ;
+ for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i)
+ vString[++k] = m_TParams.ToString( i) ;
+ if ( ! SetVal( KEY_PHASE, m_nPhase, vString[++k]))
+ return false ;
+ if ( ! SetVal( KEY_NUM, m_nMills, vString[++k]))
+ return false ;
+ }
+ catch( ...) {
+ return false ;
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::Load( const STRVECTOR& vString, int nBaseGdbId)
+{
+ int nSize = int( vString.size()) ;
+ // lista identificativi geometrie da lavorare
+ int k = - 1 ;
+ if ( k >= nSize - 1 || ! GetVal( vString[++k], KEY_IDS, m_vId))
+ return false ;
+ for ( auto& Sel : m_vId)
+ Sel.nId += nBaseGdbId ;
+ // parametri lavorazione
+ for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) {
+ int nKey ;
+ if ( k >= nSize - 1 || ! m_Params.FromString( vString[++k], nKey) || nKey != i) {
+ if ( m_Params.IsOptional( i))
+ -- k ;
+ else
+ return false ;
+ }
+ }
+ // parametri utensile
+ for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) {
+ int nKey ;
+ if ( k >= nSize - 1 || ! m_TParams.FromString( vString[++k], nKey) || nKey != i)
+ return false ;
+ }
+ // parametri di stato
+ while ( k < nSize - 1) {
+ // separo chiave da valore
+ string sKey, sVal ;
+ SplitFirst( vString[++k], "=", sKey, sVal) ;
+ // leggo
+ if ( sKey == KEY_PHASE){
+ if ( ! FromString( sVal, m_nPhase))
+ return false ;
+ }
+ else if ( sKey == KEY_NUM) {
+ if ( ! FromString( sVal, m_nMills))
+ return false ;
+ }
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+GenMachining::GenMachining( void)
+{
+ m_Params.m_sName = "*" ;
+ m_Params.m_sToolName = "*" ;
+ m_TParams.m_sName = "*" ;
+ m_TParams.m_sHead = "*" ;
+ m_nMills = 0 ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::Prepare( const string& sGenMchName)
+{
+ // verifico il gestore lavorazioni
+ if ( m_pMchMgr == nullptr)
+ return false ;
+ // recupero il gestore DB utensili della macchina corrente
+ ToolsMgr* pTMgr = m_pMchMgr->GetCurrToolsMgr() ;
+ if ( pTMgr == nullptr)
+ return false ;
+ // recupero il gestore DB lavorazioni della macchina corrente
+ MachiningsMgr* pMMgr = m_pMchMgr->GetCurrMachiningsMgr() ;
+ if ( pMMgr == nullptr)
+ return false ;
+ // ricerca della lavorazione di libreria con il nome indicato
+ const GenMachiningData* pDdata = GetGenMachiningData( pMMgr->GetMachining( sGenMchName)) ;
+ if ( pDdata == nullptr)
+ return false ;
+ m_Params = *pDdata ;
+ // ricerca dell'utensile usato dalla lavorazione
+ const ToolData* pTdata = pTMgr->GetTool( m_Params.m_ToolUuid) ;
+ if ( pTdata == nullptr)
+ return false ;
+ m_TParams = *pTdata ;
+ m_Params.m_sToolName = m_TParams.m_sName ;
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::SetParam( int nType, bool bVal)
+{
+ switch ( nType) {
+ case MPA_INVERT :
+ m_Params.m_bInvert = bVal ;
+ return true ;
+ }
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::SetParam( int nType, int nVal)
+{
+ switch ( nType) {
+ case MPA_SCC :
+ if ( ! m_Params.VerifySolCh( nVal))
+ return false ;
+ m_Params.m_nSolCh = nVal ;
+ return true ;
+ }
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::SetParam( int nType, double dVal)
+{
+ switch ( nType) {
+ case MPA_SPEED :
+ if ( ! m_TParams.VerifySpeed( dVal))
+ return false ;
+ if ( abs( m_TParams.m_dSpeed - dVal) < EPS_MACH_ANG_PAR)
+ m_Params.m_dSpeed = 0 ;
+ else
+ m_Params.m_dSpeed = dVal ;
+ return true ;
+ case MPA_FEED :
+ if ( abs( m_TParams.m_dFeed - dVal) < EPS_MACH_LEN_PAR)
+ m_Params.m_dFeed = 0 ;
+ else
+ m_Params.m_dFeed = dVal ;
+ return true ;
+ case MPA_STARTFEED :
+ if ( abs( m_TParams.m_dStartFeed - dVal) < EPS_MACH_LEN_PAR)
+ m_Params.m_dStartFeed = 0 ;
+ else
+ m_Params.m_dStartFeed = dVal ;
+ return true ;
+ case MPA_ENDFEED :
+ if ( abs( m_TParams.m_dEndFeed - dVal) < EPS_MACH_LEN_PAR)
+ m_Params.m_dEndFeed = 0 ;
+ else
+ m_Params.m_dEndFeed = dVal ;
+ return true ;
+ case MPA_TIPFEED :
+ if ( abs( m_TParams.m_dTipFeed - dVal) < EPS_MACH_LEN_PAR)
+ m_Params.m_dTipFeed = 0 ;
+ else
+ m_Params.m_dTipFeed = dVal ;
+ return true ;
+ case MPA_OFFSR :
+ if ( abs( m_TParams.m_dOffsR - dVal) < EPS_MACH_LEN_PAR)
+ m_Params.m_dOffsR = UNKNOWN_PAR ;
+ else
+ m_Params.m_dOffsR = dVal ;
+ return true ;
+ case MPA_OFFSL :
+ if ( abs( m_TParams.m_dOffsL - dVal) < EPS_MACH_LEN_PAR)
+ m_Params.m_dOffsL = UNKNOWN_PAR ;
+ else
+ m_Params.m_dOffsL = dVal ;
+ return true ;
+ case MPA_DEPTH :
+ m_Params.m_sDepth = ToString( dVal) ;
+ return true ;
+ case MPA_STARTPOS :
+ m_Params.m_dStartPos = dVal ;
+ return true ;
+ }
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::SetParam( int nType, const string& sVal)
+{
+ switch ( nType) {
+ case MPA_TOOL : {
+ const ToolData* pTdata ;
+ if ( ! m_Params.VerifyTool( m_pMchMgr->GetCurrToolsMgr(), sVal, pTdata))
+ return false ;
+ m_Params.m_sToolName = sVal ;
+ m_Params.m_ToolUuid = pTdata->m_Uuid ;
+ m_TParams = *pTdata ;
+ } break ;
+ case MPA_DEPTH_STR :
+ m_Params.m_sDepth = sVal ;
+ return true ;
+ case MPA_SYSNOTES :
+ m_Params.m_sSysNotes = sVal ;
+ break ;
+ case MPA_USERNOTES :
+ m_Params.m_sUserNotes = sVal ;
+ break ;
+ default :
+ return false ;
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::SetGeometry( const SELVECTOR& vIds)
+{
+ // 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 (tutte curve o tutte facce)
+ int nType = GEO_NONE ;
+ for ( const auto& Id : vIds) {
+ // test sull'entità
+ int nSubs ;
+ if ( ! VerifyGeometry( Id, nSubs, nType)) {
+ string sOut = "Entity " + ToString( Id) + " skipped by Milling" ;
+ LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
+ continue ;
+ }
+ // posso aggiungere alla lista
+ m_vId.emplace_back( Id) ;
+ }
+ return ( ! m_vId.empty() || vIds.empty()) ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::Preview( bool bRecalc)
+{
+ // reset numero percorsi di lavoro generati
+ m_nMills = 0 ;
+
+ // 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
+ if ( nAuxId == GDB_ID_NULL) {
+ nAuxId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
+ if ( nAuxId == GDB_ID_NULL)
+ return false ;
+ m_pGeomDB->SetName( nAuxId, MCH_AUX) ;
+ m_pGeomDB->SetStatus( nAuxId, GDB_ST_OFF) ;
+ bChain = true ;
+ }
+ // altrimenti, se chiesto ricalcolo, lo svuoto
+ else if ( bRecalc) {
+ m_pGeomDB->EmptyGroup( nAuxId) ;
+ bChain = true ;
+ }
+
+ // aggiorno dati geometrici dell'utensile
+ if ( ! UpdateToolData()) {
+ LOG_INFO( GetEMkLogger(), "Error in Milling : UpdateToolData failed") ;
+ return false ;
+ }
+
+ // se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
+ if ( bChain && ! Chain( nAuxId))
+ return false ;
+
+ // recupero gruppo per geometria di Preview
+ int nPvId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_PV) ;
+ // 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)
+ return false ;
+ m_pGeomDB->SetName( nPvId, MCH_PV) ;
+ }
+ // altrimenti lo svuoto
+ else
+ m_pGeomDB->EmptyGroup( nPvId) ;
+
+ // lavoro ogni singola catena
+ int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ;
+ while ( nPathId != GDB_ID_NULL) {
+ if ( ! ProcessPath( nPathId, nPvId, GDB_ID_NULL))
+ return false ;
+ nPathId = m_pGeomDB->GetNextGroup( nPathId) ;
+ }
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::Apply( bool bRecalc)
+{
+ // reset numero percorsi di lavoro generati
+ m_nMills = 0 ;
+
+ // 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
+ if ( nAuxId == GDB_ID_NULL) {
+ nAuxId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
+ if ( nAuxId == GDB_ID_NULL)
+ return false ;
+ m_pGeomDB->SetName( nAuxId, MCH_AUX) ;
+ m_pGeomDB->SetStatus( nAuxId, GDB_ST_OFF) ;
+ bChain = true ;
+ }
+ // altrimenti, se chiesto ricalcolo, lo svuoto
+ else if ( bRecalc) {
+ m_pGeomDB->EmptyGroup( nAuxId) ;
+ bChain = true ;
+ }
+
+ // aggiorno dati geometrici dell'utensile
+ if ( ! UpdateToolData()) {
+ LOG_INFO( GetEMkLogger(), "Error in Milling : UpdateToolData failed") ;
+ return false ;
+ }
+
+ // se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
+ if ( bChain && ! Chain( nAuxId))
+ return false ;
+
+ // recupero gruppo per geometria di lavorazione (Cutter Location)
+ int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
+ // 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)
+ return false ;
+ m_pGeomDB->SetName( nClId, MCH_CL) ;
+ }
+ // altrimenti lo svuoto
+ else
+ m_pGeomDB->EmptyGroup( nClId) ;
+
+ // lavoro ogni singola catena
+ int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ;
+ while ( nPathId != GDB_ID_NULL) {
+ if ( ! ProcessPath( nPathId, GDB_ID_NULL, nClId))
+ return false ;
+ nPathId = m_pGeomDB->GetNextGroup( nPathId) ;
+ }
+
+ // se lavorazione vuota, esco
+ if ( m_nMills == 0)
+ return true ;
+
+ // calcolo gli assi macchina
+ string sHint = ExtractHint( m_Params.m_sUserNotes) ;
+ if ( ! CalculateAxesValues( sHint))
+ return false ;
+
+ // gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine della lavorazione
+ if ( ! AdjustStartEndMovements())
+ return false ;
+
+ // esecuzione eventuali personalizzazioni
+ if ( ! PostApply())
+ return false ;
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::GetParam( int nType, bool& bVal) const
+{
+ switch ( nType) {
+ case MPA_INVERT :
+ bVal = m_Params.m_bInvert ;
+ return true ;
+ }
+ bVal = false ;
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::GetParam( int nType, int& nVal) const
+{
+ switch ( nType) {
+ case MPA_TYPE :
+ nVal = MT_GENMACHINING ;
+ return true ;
+ case MPA_SCC :
+ nVal = m_Params.m_nSolCh ;
+ return true ;
+ }
+ nVal = 0 ;
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::GetParam( int nType, double& dVal) const
+{
+ switch ( nType) {
+ case MPA_SPEED :
+ dVal = GetSpeed() ;
+ return true ;
+ case MPA_FEED :
+ dVal = GetFeed() ;
+ return true ;
+ case MPA_STARTFEED :
+ dVal = GetStartFeed() ;
+ return true ;
+ case MPA_ENDFEED :
+ dVal = GetEndFeed() ;
+ return true ;
+ case MPA_TIPFEED :
+ dVal = GetTipFeed() ;
+ return true ;
+ case MPA_OFFSR :
+ dVal = GetOffsR() ;
+ return true ;
+ case MPA_OFFSL :
+ dVal = GetOffsL() ;
+ return true ;
+ case MPA_STARTPOS :
+ dVal = m_Params.m_dStartPos ;
+ return true ;
+ }
+ dVal = 0 ;
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::GetParam( int nType, string& sVal) const
+{
+ switch ( nType) {
+ case MPA_NAME :
+ sVal = m_Params.m_sName ;
+ return true ;
+ case MPA_TOOL :
+ sVal = m_Params.m_sToolName ;
+ return true ;
+ case MPA_DEPTH_STR :
+ sVal = m_Params.m_sDepth ;
+ return true ;
+ case MPA_TUUID :
+ sVal = ToString( m_Params.m_ToolUuid) ;
+ return true ;
+ case MPA_UUID :
+ sVal = ToString( m_Params.m_Uuid) ;
+ return true ;
+ case MPA_SYSNOTES :
+ sVal = m_Params.m_sSysNotes ;
+ return true ;
+ case MPA_USERNOTES :
+ sVal = m_Params.m_sUserNotes ;
+ return true ;
+ }
+ sVal = "" ;
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+const ToolData&
+GenMachining::GetToolData( void) const
+{
+ return m_TParams ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::UpdateToolData( void)
+{
+ // recupero il gestore DB utensili della macchina corrente
+ ToolsMgr* pTMgr = m_pMchMgr->GetCurrToolsMgr() ;
+ if ( pTMgr == nullptr)
+ return false ;
+ // recupero l'utensile nel DB utensili
+ const ToolData* pTdata = pTMgr->GetTool( m_Params.m_ToolUuid) ;
+ if ( pTdata == nullptr)
+ return false ;
+ // aggiorno i parametri
+ m_TParams = *pTdata ;
+ if ( ! EqualNoCase( m_Params.m_sToolName, m_TParams.m_sName)) {
+ string sLog = "Warning in GenMachining : tool name changed (" +
+ m_Params.m_sToolName + "->" + m_TParams.m_sName +")" ;
+ LOG_INFO( GetEMkLogger(), sLog.c_str()) ;
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::GetGeometry( SELVECTOR& vIds) const
+{
+ // restituisco l'elenco delle entità
+ vIds = m_vId ;
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::VerifyGeometry( SelData Id, int& nSubs, int& nType)
+{
+ // ammessi : tutte curve o tutte facce di trimesh
+ const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
+ if ( pGObj == nullptr)
+ return false ;
+ // se ammesse curve ed è tale
+ if ( nType != GEO_SURF && ( pGObj->GetType() & GEO_CURVE) != 0) {
+ const ICurve* pCurve = nullptr ;
+ // se direttamente la curva
+ if ( Id.nSub == SEL_SUB_ALL) {
+ pCurve = ::GetCurve( pGObj) ;
+ if ( pCurve != nullptr) {
+ if ( pCurve->GetType() == CRV_COMPO)
+ nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ;
+ else
+ nSubs = 0 ;
+ }
+ }
+ // altrimenti sottocurva di composita
+ else {
+ const ICurveComposite* pCompo = GetCurveComposite( pGObj) ;
+ if ( pCompo != nullptr)
+ pCurve = pCompo->GetCurve( Id.nSub) ;
+ nSubs = 0 ;
+ }
+ return ( pCurve != nullptr) ;
+ }
+ // se altrimenti ammesse superfici trimesh ed è tale
+ else if ( nType != GEO_CURVE && ( pGObj->GetType() & GEO_SURF) != 0) {
+ const ISurfTriMesh* pSurf = ::GetSurfTriMesh( pGObj) ;
+ if ( pSurf == nullptr)
+ return false ;
+ // se direttamente la superficie
+ if ( Id.nSub == SEL_SUB_ALL) {
+ nSubs = pSurf->GetFacetCount() ;
+ return true ;
+ }
+ // altrimenti faccia di superficie trimesh
+ else {
+ // se faccia non esistente
+ if ( Id.nSub > pSurf->GetFacetCount())
+ return false ;
+ // tutto bene
+ nSubs = 0 ;
+ return true ;
+ }
+ }
+ // altrimenti errore
+ else
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+ICurve*
+GenMachining::GetCurve( SelData Id)
+{
+ // ammessi : curve o facce di polymesh
+ const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
+ if ( pGObj == nullptr)
+ return nullptr ;
+ // ne recupero il riferimento globale
+ Frame3d frGlob ;
+ if ( ! m_pGeomDB->GetGlobFrame( Id.nId, frGlob))
+ return nullptr ;
+ // se curva
+ if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
+ PtrOwner pCurve ;
+ // se direttamente curva
+ if ( Id.nSub == SEL_SUB_ALL) {
+ // recupero e duplico la curva
+ const ICurve* pOriCurve = ::GetCurve( pGObj) ;
+ if ( pOriCurve != nullptr)
+ pCurve.Set( pOriCurve->Clone()) ;
+ // se estrusione mancante, imposto default
+ Vector3d vtExtr ;
+ if ( ! pCurve->GetExtrusion( vtExtr) || vtExtr.IsSmall())
+ pCurve->SetExtrusion( Z_AX) ;
+ }
+ // altrimenti sottocurva di composita
+ else {
+ // recupero la composita
+ const ICurveComposite* pCompo = GetCurveComposite( pGObj) ;
+ if ( pCompo != nullptr) {
+ // duplico la curva semplice
+ const ICurve* pOriCurve = ::GetCurve( pCompo->GetCurve( Id.nSub)) ;
+ if ( pOriCurve != nullptr) {
+ pCurve.Set( pOriCurve->Clone()) ;
+ // recupero estrusione e spessore
+ Vector3d vtExtr ;
+ if ( ! pCompo->GetExtrusion( vtExtr) || vtExtr.IsSmall())
+ vtExtr = Z_AX ;
+ pCurve->SetExtrusion( vtExtr) ;
+ double dThick ;
+ if ( pCompo->GetThickness( dThick))
+ pCurve->SetThickness( dThick) ;
+ }
+ }
+ }
+ if ( IsNull( pCurve))
+ return nullptr ;
+ // la porto in globale
+ pCurve->ToGlob( frGlob) ;
+ // la restituisco
+ return Release( pCurve) ;
+ }
+ // se altrimenti superficie
+ else if ( ( pGObj->GetType() & GEO_SURF) != 0) {
+ // recupero la trimesh
+ const ISurfTriMesh* pSurf = ::GetSurfTriMesh( pGObj) ;
+ if ( pSurf == nullptr)
+ return nullptr ;
+ // recupero l'indice della faccia
+ int nFacet = ( ( Id.nSub == SEL_SUB_ALL) ? 0 : Id.nSub) ;
+ // recupero i contorni della faccia
+ POLYLINEVECTOR vPL ;
+ pSurf->GetFacetLoops( nFacet, vPL) ;
+ if ( vPL.empty())
+ return nullptr ;
+ // recupero la normale esterna della faccia
+ Vector3d vtN ;
+ if ( ! pSurf->GetFacetNormal( nFacet, vtN))
+ return nullptr ;
+ // creo la curva a partire da quello esterno
+ PtrOwner pCrvCompo( CreateCurveComposite()) ;
+ pCrvCompo->FromPolyLine( vPL[0]) ;
+ if ( ! pCrvCompo->IsValid())
+ return nullptr ;
+ // assegno l'estrusione dalla normale alla faccia
+ pCrvCompo->SetExtrusion( vtN) ;
+ // la porto in globale
+ pCrvCompo->ToGlob( frGlob) ;
+ // sistemazioni varie
+ AdjustCurveFromSurf( pCrvCompo) ;
+ // la restituisco
+ return Release( pCrvCompo) ;
+ }
+ // altrimenti errore
+ else
+ return nullptr ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::AdjustCurveFromSurf( ICurveComposite* pCrvCompo)
+{
+ // con utensile fresa fa il contorno
+ if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) {
+ // cerco l'estremo più alto e lo imposto come inizio
+ double dU = 0 ;
+ double dUmax = 0 ;
+ double dZmax = - INFINITO ;
+ Point3d ptP ;
+ while ( pCrvCompo->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP)) {
+ if ( ptP.z > dZmax + EPS_SMALL) {
+ dZmax = ptP.z ;
+ dUmax = dU ;
+ }
+ dU += 1 ;
+ }
+ if ( dU != 0)
+ pCrvCompo->ChangeStartPoint( dUmax) ;
+ }
+ // con utensile lama tiene solo la parte sotto
+ else {
+ // ingombro
+ BBox3d b3Box ;
+ pCrvCompo->GetLocalBBox( b3Box) ;
+ double dZmin = b3Box.GetMin().z ;
+ double dZtol = min( ( b3Box.GetMax().z - b3Box.GetMin().z) / 2., 20.) ;
+ // elimino le linee troppo sopra il minimo dall'inizio e poi dalla fine
+ const ICurve* pCrv = pCrvCompo->GetFirstCurve() ;
+ while ( pCrv != nullptr) {
+ Point3d ptMid ; pCrv->GetMidPoint( ptMid) ;
+ Vector3d vtDir ; pCrv->GetMidDir( vtDir) ;
+ if ( ptMid.z > dZmin + dZtol) {
+ ICurve* pErase = pCrvCompo->RemoveFirstOrLastCurve( false) ;
+ delete( pErase) ;
+ pCrv = pCrvCompo->GetFirstCurve() ;
+ }
+ else
+ break ;
+ }
+ pCrv = pCrvCompo->GetLastCurve() ;
+ while ( pCrv != nullptr) {
+ Point3d ptMid ; pCrv->GetMidPoint( ptMid) ;
+ Vector3d vtDir ; pCrv->GetMidDir( vtDir) ;
+ if ( ptMid.z > dZmin + dZtol) {
+ ICurve* pErase = pCrvCompo->RemoveFirstOrLastCurve( true) ;
+ delete( pErase) ;
+ pCrv = pCrvCompo->GetLastCurve() ;
+ }
+ else
+ break ;
+ }
+ // verifico il versore estrusione
+ Vector3d vtN ;
+ pCrvCompo->GetExtrusion( vtN) ;
+ if ( vtN.z < - sin( 2 * DEGTORAD)) {
+ pCrvCompo->Invert() ;
+ pCrvCompo->Translate( vtN * m_TParams.m_dThick) ;
+ pCrvCompo->SetExtrusion( - vtN) ;
+ }
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::Chain( int nGrpDestId)
+{
+ // vettore puntatori alle curve
+ typedef PtrOwner POWNCURVE ;
+ typedef std::vector POCRVVECTOR ;
+ POCRVVECTOR vpCrvs ;
+ vpCrvs.reserve( m_vId.size()) ;
+ // recupero tutte le curve e le porto in globale
+ for ( const auto& Id : m_vId) {
+ // prendo curva
+ vpCrvs.emplace_back( GetCurve( Id)) ;
+ // ne verifico la validità
+ if ( IsNull( vpCrvs.back())) {
+ string sOut = "Entity " + ToString( Id) + " skipped by Milling" ;
+ LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
+ vpCrvs.back().Reset() ;
+ }
+ }
+ // preparo i dati per il concatenamento
+ bool bFirst = true ;
+ Point3d ptNear = ORIG ;
+ double dToler = 10 * EPS_SMALL ;
+ ChainCurves chainC ;
+ chainC.Init( true, dToler, int( vpCrvs.size())) ;
+ for ( size_t i = 0 ; i < vpCrvs.size() ; ++ i) {
+ // recupero la curva e il suo riferimento
+ ICurve* pCrv = vpCrvs[i] ;
+ if ( pCrv == nullptr)
+ continue ;
+ // recupero i dati della curva necessari al concatenamento e li assegno
+ Point3d ptStart, ptEnd ;
+ Vector3d vtStart, vtEnd ;
+ if ( ! pCrv->GetStartPoint( ptStart) || ! pCrv->GetStartDir( vtStart) ||
+ ! pCrv->GetEndPoint( ptEnd) || ! pCrv->GetEndDir( vtEnd))
+ return false ;
+ if ( ! chainC.AddCurve( int( i + 1), ptStart, vtStart, ptEnd, vtEnd))
+ return false ;
+ // se prima curva, assegno inizio della ricerca
+ if ( bFirst) {
+ ptNear = ptStart + 10 * EPS_SMALL * vtStart ;
+ bFirst = false ;
+ }
+ }
+ // recupero i percorsi concatenati
+ int nCount = 0 ;
+ INTVECTOR vnId2 ;
+ while ( chainC.GetChainFromNear( ptNear, false, vnId2)) {
+ // creo una curva composita
+ PtrOwner pCrvCompo( CreateCurveComposite()) ;
+ if ( IsNull( pCrvCompo))
+ return false ;
+ // estrusione e spessore
+ Vector3d vtExtr = Z_AX ;
+ double dThick = 0 ;
+ // vettore Id originali
+ SELVECTOR vId2 ;
+ vId2.reserve( vnId2.size()) ;
+ // recupero le curve semplici e le inserisco nella curva composita
+ for ( size_t i = 0 ; i < vnId2.size() ; ++ i) {
+ int nId = abs( vnId2[i]) - 1 ;
+ bool bInvert = ( vnId2[i] < 0) ;
+ vId2.emplace_back( m_vId[nId]) ;
+ // recupero la curva
+ ICurve* pCrv = vpCrvs[nId] ;
+ // se necessario, la inverto
+ if ( bInvert)
+ pCrv->Invert() ;
+ // recupero eventuali estrusione e spessore
+ Vector3d vtTemp ;
+ if ( pCrv->GetExtrusion( vtTemp)) {
+ vtExtr = vtTemp ;
+ double dTemp ;
+ if ( pCrv->GetThickness( dTemp) && fabs( dTemp) > fabs( dThick))
+ dThick = dTemp ;
+ }
+ // la aggiungo alla curva composta
+ if ( ! pCrvCompo->AddCurve( ::Release( vpCrvs[nId]), true, dToler))
+ return false ;
+ }
+ // se non sono state inserite curve, vado oltre
+ if ( pCrvCompo->GetCurveCount() == 0)
+ continue ;
+ // imposto estrusione e spessore
+ pCrvCompo->SetExtrusion( vtExtr) ;
+ pCrvCompo->SetThickness( dThick) ;
+ // aggiorno il nuovo punto vicino
+ pCrvCompo->GetEndPoint( ptNear) ;
+ // creo nuovo gruppo
+ int nPathId = m_pGeomDB->AddGroup( GDB_ID_NULL, nGrpDestId, Frame3d()) ;
+ if ( nPathId == GDB_ID_NULL)
+ return false ;
+ m_pGeomDB->SetName( nPathId, MCH_PATH + ToString( ++ nCount)) ;
+ m_pGeomDB->SetInfo( nPathId, KEY_IDS, ToString( vId2)) ;
+ // inserisco la curva composita nel gruppo destinazione
+ int nNewId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, ::Release( pCrvCompo)) ;
+ if ( nNewId == GDB_ID_NULL)
+ return false ;
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) const
+{
+ // non devo fare alcunché
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::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
+ if ( nTempId == GDB_ID_NULL) {
+ nTempId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
+ if ( nTempId == GDB_ID_NULL)
+ return false ;
+ m_pGeomDB->SetName( nTempId, GRP_TEMP) ;
+ }
+ // altrimenti lo svuoto
+ else
+ m_pGeomDB->EmptyGroup( nTempId) ;
+ // in ogni caso lo dichiaro temporaneo e non visibile
+ m_pGeomDB->SetLevel( nTempId, GDB_LV_TEMP) ;
+ m_pGeomDB->SetStatus( nTempId, GDB_ST_OFF) ;
+
+ // copio la curva composita da elaborare
+ int nCrvId = m_pGeomDB->GetFirstInGroup( nPathId) ;
+ if ( m_pGeomDB->GetGeoType( nCrvId) != CRV_COMPO)
+ return false ;
+ int nCopyId = m_pGeomDB->CopyGlob( nCrvId, GDB_ID_NULL, nTempId) ;
+ if ( nCopyId == GDB_ID_NULL)
+ return false ;
+ ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( nCopyId)) ;
+
+ // eventuale inversione percorso
+ if ( m_Params.m_bInvert)
+ pCompo->Invert() ;
+
+ // recupero estrusione e spessore
+ Vector3d vtExtr ;
+ pCompo->GetExtrusion( vtExtr) ;
+ double dThick ;
+ pCompo->GetThickness( dThick) ;
+
+ // unisco le parti allineate (tranne inizio-fine se chiusa)
+ if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false))
+ return false ;
+
+ // recupero il punto di inizio (per poi salvarlo nelle info di CL path)
+ Point3d ptStart ;
+ pCompo->GetStartPoint( ptStart) ;
+
+ // recupero il box del grezzo in globale
+ BBox3d b3Raw ;
+ if ( ! GetRawGlobBox( m_nPhase, nPathId, b3Raw) || b3Raw.IsEmpty()) {
+ LOG_INFO( GetEMkLogger(), "Error in GenMachining : Empty RawBox") ;
+ return false ;
+ }
+
+ // recupero distanza da fondo dei grezzi interessati dal percorso
+ double dRbDist = 0 ;
+ if ( AreSameVectorApprox( vtExtr, Z_AX)) {
+ if ( ! GetDistanceFromRawBottom( m_nPhase, nCopyId, m_TParams.m_dDiam, dRbDist))
+ return false ;
+ }
+
+ // valuto l'espressione dell'affondamento
+ ExeLuaSetGlobNumVar( "TH", abs( dThick)) ;
+ ExeLuaSetGlobNumVar( "RB", dRbDist) ;
+ double dDepth ;
+ string sMyDepth = m_Params.m_sDepth ;
+ if ( ! ExeLuaEvalNumExpr( ToUpper( sMyDepth), &dDepth)) {
+ LOG_INFO( GetEMkLogger(), "Error in GenMachining : Depth not computable") ;
+ return false ;
+ }
+ // se spessore positivo, lo sottraggo dal risultato
+ if ( dThick > 0)
+ dDepth -= dThick ;
+ // sottraggo eventuale offset longitudinale
+ dDepth -= GetOffsL() ;
+
+ // recupero nome del path
+ string sPathName ;
+ 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 && ! vtExtr.IsZplus()) ||
+ ( nSplitArcs == SPLAR_GEN_PLANE && vtExtr.IsGeneric())) ;
+ if ( bSplitArcs) {
+ const double ANG_TOL_MAX_DEG = 90 ;
+ PolyLine PL ;
+ if ( pCompo->ApproxWithLines( 50 * EPS_SMALL, ANG_TOL_MAX_DEG, ICurve::APL_SPECIAL, PL)) {
+ // sostituisco le linee alle curve originali
+ pCompo->Clear() ;
+ pCompo->FromPolyLine( PL) ;
+ // riassegno estrusione e spessore
+ pCompo->SetExtrusion( vtExtr) ;
+ pCompo->SetThickness( dThick) ;
+ }
+ }
+
+ // verifiche sull'ampiezza dell'angolo al centro degli eventuali archi
+ const double MAX_ANG_CEN = 150 + EPS_ANG_SMALL ;
+ int nMaxInd = pCompo->GetCurveCount() - 1 ;
+ for ( int i = 0 ; i <= nMaxInd ; ++ i) {
+ // se arco con angolo al centro oltre il limite, lo divido a metà
+ const ICurveArc* pArc = GetCurveArc( pCompo->GetCurve( i)) ;
+ if ( pArc != nullptr && abs( pArc->GetAngCenter()) > MAX_ANG_CEN) {
+ pCompo->AddJoint( i + 0.5) ;
+ ++ i ;
+ ++ nMaxInd ;
+ }
+ }
+
+ // calcolo il versore fresa
+ Vector3d vtTool = Z_AX ;
+ if ( ! vtExtr.IsSmall())
+ vtTool = vtExtr ;
+
+ // calcolo l'elevazione massima
+ double dElev ;
+ if ( CalcPathElevation( pCompo, vtTool, dDepth, 0.5 * m_TParams.m_dDiam, dElev)) {
+ if ( dElev < EPS_SMALL && AreSameVectorApprox( vtExtr, Z_AX)) {
+ BBox3d b3Crv ;
+ pCompo->GetLocalBBox( b3Crv) ;
+ dElev = max( 0., b3Raw.GetMax().z - b3Crv.GetMin().z + dDepth) ;
+ }
+ }
+ else
+ return false ;
+
+ // per frese normali, verifico di non superare il massimo materiale
+ if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) {
+ const double MAXMAT_TOL = EPS_SMALL ;
+ if ( dElev > m_TParams.m_dMaxMat + MAXMAT_TOL) {
+ if ( dDepth + max( dThick, 0.0) > m_TParams.m_dMaxMat) {
+ dDepth = m_TParams.m_dMaxMat - max( dThick, 0.0) ;
+ string sInfo = "Warning in GenMachining : machining depth (" + ToString( dElev, 1) +
+ ") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ;
+ LOG_INFO( GetEMkLogger(), sInfo.c_str()) ;
+ }
+ else {
+ string sInfo = "Error in GenMachining : machining depth (" + ToString( dElev, 1) +
+ ") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ;
+ LOG_INFO( GetEMkLogger(), sInfo.c_str()) ;
+ return false ;
+ }
+ }
+ }
+
+ // se richiesta anteprima
+ if ( nPvId != GDB_ID_NULL) {
+ // creo gruppo per geometria di lavorazione del percorso
+ int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nPvId, Frame3d()) ;
+ if ( nPxId == GDB_ID_NULL)
+ return false ;
+ m_pGeomDB->SetName( nPxId, sPathName) ;
+ m_pGeomDB->SetMaterial( nPxId, GREEN) ;
+ // creo l'anteprima del percorso
+ if ( ! GenerateMillingPv( nPxId, pCompo))
+ return false ;
+ }
+
+ // se richiesta lavorazione
+ if ( nClId != GDB_ID_NULL) {
+ // creo gruppo per geometria di lavorazione del percorso
+ int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nClId, Frame3d()) ;
+ if ( nPxId == GDB_ID_NULL)
+ return false ;
+ m_pGeomDB->SetName( nPxId, sPathName) ;
+ m_pGeomDB->SetMaterial( nPxId, BLUE) ;
+
+ // assegno il vettore estrazione al gruppo del percorso
+ m_pGeomDB->SetInfo( nPxId, KEY_EXTR, vtTool) ;
+ // assegno il punto di inizio al gruppo del percorso
+ m_pGeomDB->SetInfo( nPxId, KEY_START, ptStart) ;
+
+ // Imposto dati comuni
+ SetPathId( nPxId) ;
+ SetToolDir( vtTool) ;
+
+ // Calcolo la lavorazione
+ if ( ! AddStandardMilling( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs))
+ return false ;
+
+ // assegno al gruppo l'ingombro del percorso di lavoro
+ BBox3d b3Grp ;
+ m_pGeomDB->GetGlobalBBox( nPxId, b3Grp) ;
+ m_pGeomDB->SetInfo( nPxId, KEY_PMIN, b3Grp.GetMin()) ;
+ m_pGeomDB->SetInfo( nPxId, KEY_PMAX, b3Grp.GetMax()) ;
+ }
+
+ // incremento numero di fresate
+ ++ m_nMills ;
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad,
+ double& dElev)
+{
+ dElev = 0 ;
+ int nMaxInd = pCompo->GetCurveCount() - 1 ;
+ for ( int i = 0 ; i <= nMaxInd ; ++ i) {
+ // curva corrente
+ const ICurve* pCrvC = pCompo->GetCurve( i) ;
+ // calcolo elevazione
+ double dCurrElev ;
+ Point3d ptStart, ptMid, ptEnd ;
+ pCrvC->GetStartPoint( ptStart) ;
+ pCrvC->GetMidPoint( ptMid) ;
+ pCrvC->GetEndPoint( ptEnd) ;
+ Vector3d vtStartPerp, vtMidPerp, vtEndPerp, vtTg ;
+ pCrvC->GetStartDir( vtTg) ;
+ vtStartPerp = vtTg ^ vtTool ;
+ vtStartPerp.Normalize() ;
+ vtStartPerp *= dRad ;
+ pCrvC->GetMidDir( vtTg) ;
+ vtMidPerp = vtTg ^ vtTool ;
+ vtMidPerp.Normalize() ;
+ vtMidPerp *= dRad ;
+ pCrvC->GetEndDir( vtTg) ;
+ vtEndPerp = vtTg ^ vtTool ;
+ vtEndPerp.Normalize() ;
+ vtEndPerp *= dRad ;
+ Vector3d vtDepth = vtTool * dDepth ;
+ // linea centro utensile
+ if ( GetElevation( m_nPhase, ptStart - vtDepth, ptMid - vtDepth, ptEnd - vtDepth, vtTool, dCurrElev)) {
+ if ( dCurrElev > dElev)
+ dElev = dCurrElev ;
+ }
+ else {
+ LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ;
+ return false ;
+ }
+ // da una parte
+ if ( GetElevation( m_nPhase, ptStart + vtStartPerp - vtDepth, ptMid + vtMidPerp - vtDepth,
+ ptEnd + vtEndPerp - vtDepth, vtTool, dCurrElev)) {
+ if ( dCurrElev > dElev)
+ dElev = dCurrElev ;
+ }
+ else {
+ LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ;
+ return false ;
+ }
+ // dall'altra parte
+ if ( GetElevation( m_nPhase, ptStart - vtStartPerp - vtDepth, ptMid - vtMidPerp - vtDepth,
+ ptEnd - vtEndPerp - vtDepth, vtTool, dCurrElev)) {
+ if ( dCurrElev > dElev)
+ dElev = dCurrElev ;
+ }
+ else {
+ LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ;
+ return false ;
+ }
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::GenerateMillingPv( int nPathId, const ICurveComposite* pCompo)
+{
+ // creo copia della curva composita
+ PtrOwner< ICurve> pCrv( pCompo->Clone()) ;
+ if ( IsNull( pCrv))
+ return false ;
+ // calcolo la regione
+ PtrOwner pSfr ;
+ pSfr.Set( GetSurfFlatRegionFromFatCurve( Release( pCrv), 0.5 * m_TParams.m_dDiam, false, false)) ;
+ if ( IsNull( 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, LIME) ;
+ // 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)
+ return false ;
+ // assegno nome e colore
+ m_pGeomDB->SetName( nC3Id, MCH_PV_CUT) ;
+ m_pGeomDB->SetMaterial( nC3Id, LIME) ;
+ }
+ // 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_RCUT) ;
+ m_pGeomDB->SetMaterial( nRId, INVISIBLE) ;
+ // 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_RRCUT) ;
+ m_pGeomDB->SetMaterial( nRrId, INVISIBLE) ;
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
+ double dDepth, double dElev, bool bSplitArcs)
+{
+ // recupero distanza di sicurezza
+ double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
+ // lunghezza di approccio/retrazione
+ double dAppr = m_Params.m_dStartPos ;
+
+ // ciclo sulle curve elementari
+ bool bClosed = pCompo->IsClosed() ;
+ int nMaxInd = pCompo->GetCurveCount() - 1 ;
+ for ( int i = 0 ; i <= nMaxInd ; ++ i) {
+ // curva corrente
+ const ICurve* pCrvC = pCompo->GetCurve( i) ;
+ // copio la curva
+ PtrOwner pCurve( ::GetCurve( pCrvC->Clone())) ;
+ if ( IsNull( pCurve))
+ return false ;
+ // aggiungo affondamento
+ pCurve->Translate( - vtTool * dDepth) ;
+ // se prima entità, approccio e affondo
+ if ( i == 0) {
+ // dati inizio entità
+ Point3d ptStart ;
+ pCurve->GetStartPoint( ptStart) ;
+ Vector3d vtStart ;
+ pCurve->GetStartDir( vtStart) ;
+ // determino inizio attacco
+ Point3d ptP1 = ptStart ;
+ // aggiungo approccio per frese normali con spazio sopra attacco
+ if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) {
+ // determino elevazione su inizio attacco
+ double dStElev ;
+ if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dStElev))
+ dStElev = dElev ;
+ dStElev -= ( ptP1 - ptStart) * vtExtr ;
+ // approccio al punto iniziale
+ if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr))
+ return false ;
+ }
+ // altrimenti, approccio per lame o diretto
+ else {
+ // affondo al punto iniziale
+ SetFlag( 0) ;
+ if ( AddRapidStart( ptP1) == GDB_ID_NULL)
+ return false ;
+ }
+ // aggiungo attacco
+ SetFeed( GetStartFeed()) ;
+ // ...
+ }
+ // elaborazioni sulla curva corrente
+ if ( pCurve->GetType() == CRV_LINE) {
+ ICurveLine* pLine = GetCurveLine( pCurve) ;
+ Point3d ptP3 = pLine->GetEnd() ;
+ SetFeed( GetFeed()) ;
+ if ( AddLinearMove( ptP3) == GDB_ID_NULL)
+ return false ;
+ }
+ else if ( pCurve->GetType() == CRV_ARC) {
+ ICurveArc* pArc = GetCurveArc( pCurve) ;
+ Point3d ptCen = pArc->GetCenter() ;
+ double dAngCen = pArc->GetAngCenter() ;
+ Vector3d vtN = pArc->GetNormVersor() ;
+ Point3d ptP3 ;
+ pArc->GetEndPoint( ptP3) ;
+ SetFeed( GetFeed()) ;
+ if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
+ return false ;
+ }
+ // se ultima entità, uscita e retrazione
+ if ( i == nMaxInd) {
+ // dati fine entità
+ Point3d ptEnd ;
+ pCurve->GetEndPoint( ptEnd) ;
+ Vector3d vtEnd ;
+ pCurve->GetEndDir( vtEnd) ;
+ // aggiungo uscita
+ Point3d ptP1 ;
+ SetFeed( GetStartFeed()) ;
+ // ...
+ // aggiungo retrazione per frese normali
+ if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) {
+ double dEndElev ;
+ if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dEndElev))
+ dEndElev = dElev ;
+ dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
+ // aggiungo retrazione
+ if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr))
+ return false ;
+ }
+ // per lame non è necessario
+ }
+ }
+ return true ;
+}
+
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr)
+{
+ // se sopra attacco c'è spazio per sicurezza o approccio
+ if ( dElev + max( dSafeZ, dAppr) > 10 * EPS_SMALL) {
+ // se distanza di sicurezza minore di distanza di inizio
+ if ( dSafeZ < dAppr + 10 * EPS_SMALL) {
+ // 1 -> punto sopra inizio
+ SetFlag( 1) ;
+ Point3d ptP1 = ptP + vtTool * ( dElev + dAppr) ;
+ if ( AddRapidStart( ptP1) == GDB_ID_NULL)
+ return false ;
+ }
+ else {
+ // 1a -> punto sopra inizio
+ SetFlag( 1) ;
+ Point3d ptP1b = ptP + vtTool * ( dElev + dAppr) ;
+ Point3d ptP1a = ptP1b + vtTool * ( dSafeZ - dAppr) ;
+ if ( AddRapidStart( ptP1a) == GDB_ID_NULL)
+ return false ;
+ // 1b -> punto appena sopra inizio
+ if ( ( dElev + dAppr) > EPS_SMALL) {
+ SetFlag( 0) ;
+ if ( AddRapidMove( ptP1b) == GDB_ID_NULL)
+ return false ;
+ }
+ }
+ // affondo al punto iniziale
+ SetFlag( 0) ;
+ SetFeed( GetTipFeed()) ;
+ if ( AddLinearMove( ptP) == GDB_ID_NULL)
+ return false ;
+ }
+ else {
+ // affondo diretto al punto iniziale
+ SetFlag( 0) ;
+ if ( AddRapidStart( ptP) == GDB_ID_NULL)
+ return false ;
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachining::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr)
+{
+ // se sopra uscita c'è spazio per sicurezza o approccio
+ if ( dElev + max( dSafeZ, dAppr) > 10 * EPS_SMALL) {
+ if ( dSafeZ < dAppr + 10 * EPS_SMALL) {
+ // 4 -> movimento di risalita sopra il punto finale
+ SetFeed( GetEndFeed()) ;
+ Point3d ptP4 = ptP + vtTool * ( dElev + dAppr) ;
+ if ( AddLinearMove( ptP4) == GDB_ID_NULL)
+ return false ;
+ }
+ else {
+ // 4a -> movimento di risalita appena sopra il punto finale
+ Point3d ptP4a = ptP + vtTool * ( dElev + dAppr) ;
+ if ( dElev + dAppr > EPS_SMALL) {
+ SetFeed( GetEndFeed()) ;
+ if ( AddLinearMove( ptP4a) == GDB_ID_NULL)
+ return false ;
+ }
+ // 4b -> movimento di risalita sopra il punto finale
+ Point3d ptP4b = ptP4a + vtTool * ( dSafeZ - dAppr) ;
+ if ( AddRapidMove( ptP4b) == GDB_ID_NULL)
+ return false ;
+ }
+ }
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+double
+GenMachining::GetRadiusForStartEndElevation( void)
+{
+ const double DELTA_ELEV_RAD = 20.0 ;
+ return ( 0.5 * m_TParams.m_dTDiam + DELTA_ELEV_RAD) ;
+}
diff --git a/GenMachining.h b/GenMachining.h
new file mode 100644
index 0000000..3c5c195
--- /dev/null
+++ b/GenMachining.h
@@ -0,0 +1,99 @@
+//----------------------------------------------------------------------------
+// EgalTech 2017-2017
+//----------------------------------------------------------------------------
+// File :GenMachining.h Data : 15.01.17 Versione : 1.6x7
+// Contenuto : Dichiarazione della classe GenMachining.
+//
+//
+//
+// Modifiche : 15.01.17 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+#include "Machining.h"
+#include "GenMachiningData.h"
+#include "ToolData.h"
+
+class ICurve ;
+class ICurveComposite ;
+
+//----------------------------------------------------------------------------
+class GenMachining : public Machining
+{
+ public : // IUserObj
+ GenMachining* Clone( void) const override ;
+ const std::string& GetClassName( void) const override ;
+ bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ;
+ bool ToSave( void) const override
+ { return true ; }
+ bool Save( STRVECTOR& vString) const override ;
+ bool Load( const STRVECTOR& vString, int nBaseGdbId) override ;
+
+ public : // Operation
+ bool IsEmpty( void) const override
+ { return ( m_nMills == 0) ; }
+
+ protected : // Operation
+ int GetSolCh( void) const override
+ { return m_Params.m_nSolCh ; }
+ bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) const override ;
+
+ public : // Machining
+ bool Prepare( const std::string& sMillName) override ;
+ bool SetParam( int nType, bool bVal) override ;
+ bool SetParam( int nType, int nVal) override ;
+ bool SetParam( int nType, double dVal) override ;
+ bool SetParam( int nType, const std::string& sVal) override ;
+ bool SetGeometry( const SELVECTOR& vIds) override ;
+ bool Preview( bool bRecalc) override ;
+ bool Apply( bool bRecalc) override ;
+ bool GetParam( int nType, bool& bVal) const override ;
+ bool GetParam( int nType, int& nVal) const override ;
+ bool GetParam( int nType, double& dVal) const override ;
+ bool GetParam( int nType, std::string& sVal) const override ;
+ const ToolData& GetToolData( void) const ;
+ bool GetGeometry( SELVECTOR& vIds) const override ;
+
+ public :
+ GenMachining( void) ;
+
+ private :
+ bool UpdateToolData( void) ;
+ bool VerifyGeometry( SelData Id, int& nSubs, int& nType) ;
+ ICurve* GetCurve( SelData Id) ;
+ bool AdjustCurveFromSurf( ICurveComposite* pCrvCompo) ;
+ bool Chain( int nGrpDestId) ;
+ bool ProcessPath( int nPathId, int nPvId, int nClId) ;
+ bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) ;
+ bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) ;
+ bool AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
+ double dDepth, double dElev, bool bSplitArcs) ;
+ bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
+ bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
+ double GetRadiusForStartEndElevation( void) ;
+
+ private :
+ double GetSpeed() const
+ { return ( abs( m_Params.m_dSpeed) < EPS_MACH_ANG_PAR ? m_TParams.m_dSpeed : m_Params.m_dSpeed) ; }
+ double GetFeed() const
+ { return ( abs( m_Params.m_dFeed) < EPS_MACH_LEN_PAR ? m_TParams.m_dFeed : m_Params.m_dFeed) ; }
+ double GetStartFeed() const
+ { return ( abs( m_Params.m_dStartFeed) < EPS_MACH_LEN_PAR ? m_TParams.m_dStartFeed : m_Params.m_dStartFeed) ; }
+ double GetEndFeed() const
+ { return ( abs( m_Params.m_dEndFeed) < EPS_MACH_LEN_PAR ? m_TParams.m_dEndFeed : m_Params.m_dEndFeed) ; }
+ double GetTipFeed() const
+ { return ( abs( m_Params.m_dTipFeed) < EPS_MACH_LEN_PAR ? m_TParams.m_dTipFeed : m_Params.m_dTipFeed) ; }
+ double GetOffsL() const
+ { return ( abs( m_Params.m_dOffsL - UNKNOWN_PAR) < EPS_MACH_LEN_PAR ? m_TParams.m_dOffsL : m_Params.m_dOffsL) ; }
+ double GetOffsR() const
+ { return ( abs( m_Params.m_dOffsR - UNKNOWN_PAR) < EPS_MACH_LEN_PAR ? m_TParams.m_dOffsR : m_Params.m_dOffsR) ; }
+
+ private :
+ SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
+ GenMachiningData m_Params ; // parametri lavorazione
+ ToolData m_TParams ; // parametri utensile
+ int m_nMills ; // numero di percorsi di lavoro generati
+} ;
\ No newline at end of file
diff --git a/GenMachiningData.cpp b/GenMachiningData.cpp
new file mode 100644
index 0000000..8408756
--- /dev/null
+++ b/GenMachiningData.cpp
@@ -0,0 +1,502 @@
+//----------------------------------------------------------------------------
+// EgalTech 2017-2017
+//----------------------------------------------------------------------------
+// File : GenMachiningData.cpp Data : 15.01.17 Versione : 1.6x7
+// Contenuto : Implementazione struttura dati lavorazione generica.
+//
+//
+//
+// Modifiche : 15.01.17 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "GenMachiningData.h"
+#include "MachiningDataFactory.h"
+#include "MachiningConst.h"
+#include "/EgtDev/Include/EmkToolConst.h"
+#include "/EgtDev/Include/EmkSimuGenConst.h"
+#include "/EgtDev/Include/EGnStringUtils.h"
+#include
+#include
+
+using namespace std ;
+
+//----------------------------------------------------------------------------
+enum nGenMachiningKey {
+ KEY_DH = 0,
+ KEY_F,
+ KEY_FE,
+ KEY_FS,
+ KEY_FT,
+ KEY_INV,
+ KEY_NAME,
+ KEY_NNS,
+ KEY_NNU,
+ KEY_OL,
+ KEY_OR,
+ KEY_PS,
+ KEY_S,
+ KEY_SCC,
+ KEY_TNAME,
+ KEY_TUUID,
+ KEY_UUID,
+ KEY_ZZZ} ; // rappresenta il numero di elementi
+
+static const std::array sGenMachiningKey = {
+ "DH",
+ "F",
+ "FE",
+ "FS",
+ "FT",
+ "INV",
+ "NAME",
+ "NNS",
+ "NNU",
+ "OL",
+ "OR",
+ "PS",
+ "S",
+ "SCC",
+ "TN",
+ "TU",
+ "UUID"} ;
+
+//----------------------------------------------------------------------------
+MCHDATA_REGISTER( MT_GENMACHINING, "GENMACHINING", GenMachiningData) ;
+
+//----------------------------------------------------------------------------
+GenMachiningData*
+GenMachiningData::Clone( void) const
+{
+ // alloco oggetto
+ GenMachiningData* pDdata = new(nothrow) GenMachiningData ;
+ // copio i dati
+ if ( pDdata != nullptr) {
+ if ( ! pDdata->CopyFrom( this)) {
+ delete pDdata ;
+ return nullptr ;
+ }
+ }
+ return pDdata ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::CopyFrom( const MachiningData* pMdata)
+{
+ // è inutile copiare se sorgente coincide con destinazione
+ if ( pMdata == this)
+ return true ;
+ // la sorgente deve essere dello stesso tipo
+ const GenMachiningData* pGdata = GetGenMachiningData( pMdata) ;
+ if ( pGdata == nullptr)
+ return false ;
+ // eseguo copia
+ m_Uuid = pGdata->m_Uuid ;
+ m_sName = pGdata->m_sName ;
+ m_nSolCh = pGdata->m_nSolCh ;
+ m_ToolUuid = pGdata->m_ToolUuid ;
+ m_sToolName = pGdata->m_sToolName ;
+ m_dSpeed = pGdata->m_dSpeed ;
+ m_dFeed = pGdata->m_dFeed ;
+ m_dEndFeed = pGdata->m_dEndFeed ;
+ m_dStartFeed = pGdata->m_dStartFeed ;
+ m_dTipFeed = pGdata->m_dTipFeed ;
+ m_dOffsL = pGdata->m_dOffsL ;
+ m_dOffsR = pGdata->m_dOffsR ;
+ m_bInvert = pGdata->m_bInvert ;
+ m_sDepth = pGdata->m_sDepth ;
+ m_dStartPos = pGdata->m_dStartPos ;
+ m_sSysNotes = pGdata->m_sSysNotes ;
+ m_sUserNotes = pGdata->m_sUserNotes ;
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::SameAs(const MachiningData* pMdata) const
+{
+ // se coincide con altro -> uguali
+ if ( pMdata == this)
+ return true ;
+ // se sono di tipo diverso -> diversi
+ const GenMachiningData* pGdata = GetGenMachiningData( pMdata) ;
+ if ( pGdata == nullptr)
+ return false ;
+ // confronto termine a termine
+ return ( m_Uuid == pGdata->m_Uuid &&
+ m_sName == pGdata->m_sName &&
+ m_ToolUuid == pGdata->m_ToolUuid &&
+ m_sToolName == pGdata->m_sToolName &&
+ m_nSolCh == pGdata->m_nSolCh &&
+ abs( m_dSpeed - pGdata->m_dSpeed) < EPS_MACH_ANG_PAR &&
+ abs( m_dFeed - pGdata->m_dFeed) < EPS_MACH_LEN_PAR &&
+ abs( m_dEndFeed - pGdata->m_dEndFeed) < EPS_MACH_LEN_PAR &&
+ abs( m_dStartFeed - pGdata->m_dStartFeed) < EPS_MACH_LEN_PAR &&
+ abs( m_dTipFeed - pGdata->m_dTipFeed) < EPS_MACH_LEN_PAR &&
+ abs( m_dOffsL - pGdata->m_dOffsL) < EPS_MACH_LEN_PAR &&
+ abs( m_dOffsR - pGdata->m_dOffsR) < EPS_MACH_LEN_PAR &&
+ m_bInvert == pGdata->m_bInvert &&
+ m_sDepth == pGdata->m_sDepth &&
+ abs( m_dStartPos - pGdata->m_dStartPos) < EPS_MACH_LEN_PAR &&
+ m_sSysNotes == pGdata->m_sSysNotes &&
+ m_sUserNotes == pGdata->m_sUserNotes) ;
+}
+
+//----------------------------------------------------------------------------
+int
+GenMachiningData::GetSize( void) const
+{
+ // in debug verifico validità ultimo campo
+ assert( sGenMachiningKey[KEY_UUID] == "UUID") ;
+ return KEY_ZZZ ;
+}
+//----------------------------------------------------------------------------
+string
+GenMachiningData::GetTitle( void) const
+{
+ return MCHDATA_GETNAME( GenMachiningData) ;
+}
+
+//----------------------------------------------------------------------------
+int
+FindGenMachiningKey( const string& sKey)
+{
+ auto TheRange = equal_range( sGenMachiningKey.cbegin(), sGenMachiningKey.cend(), sKey) ;
+ if ( TheRange.first == TheRange.second)
+ return - 1 ;
+ return int( TheRange.first - sGenMachiningKey.cbegin()) ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::FromString( const string& sString, int& nKey)
+{
+ // separo chiave da valore
+ string sKey, sVal ;
+ SplitFirst( sString, "=", sKey, sVal) ;
+ // riconosco la chiave
+ nKey = FindGenMachiningKey( ToUpper( sKey)) ;
+ bool bOk = ( nKey >= 0) ;
+ switch ( nKey) {
+ case KEY_DH :
+ m_sDepth = sVal ;
+ if ( m_sDepth.empty())
+ m_sDepth = "0" ;
+ break ;
+ case KEY_F :
+ bOk = ::FromString( sVal, m_dFeed) ;
+ break ;
+ case KEY_FE :
+ bOk = ::FromString( sVal, m_dEndFeed) ;
+ break ;
+ case KEY_FS :
+ bOk = ::FromString( sVal, m_dStartFeed) ;
+ break ;
+ case KEY_FT :
+ bOk = ::FromString( sVal, m_dTipFeed) ;
+ break ;
+ case KEY_INV :
+ bOk = ::FromString( sVal, m_bInvert) ;
+ break ;
+ case KEY_NAME :
+ m_sName = sVal ;
+ bOk = ! m_sName.empty() ;
+ break ;
+ case KEY_NNS :
+ m_sSysNotes = sVal ;
+ break ;
+ case KEY_NNU :
+ m_sUserNotes = sVal ;
+ break ;
+ case KEY_OL :
+ bOk = ::FromString( sVal, m_dOffsL) ;
+ break ;
+ case KEY_OR :
+ bOk = ::FromString( sVal, m_dOffsR) ;
+ break ;
+ case KEY_PS :
+ bOk = ::FromString( sVal, m_dStartPos) ;
+ break ;
+ case KEY_S :
+ bOk = ::FromString( sVal, m_dSpeed) ;
+ break ;
+ case KEY_SCC :
+ bOk = ::FromString( sVal, m_nSolCh) ;
+ break ;
+ case KEY_TNAME :
+ m_sToolName = sVal ;
+ break ;
+ case KEY_TUUID :
+ bOk = ::FromString( sVal, m_ToolUuid) ;
+ break ;
+ case KEY_UUID :
+ bOk = ::FromString( sVal, m_Uuid) ;
+ break ;
+ default :
+ bOk = false ;
+ break ;
+ }
+ return bOk ;
+}
+
+//----------------------------------------------------------------------------
+string
+GenMachiningData::ToString( int nKey) const
+{
+ switch ( nKey) {
+ case KEY_DH : return ( sGenMachiningKey[KEY_DH] + "=" + m_sDepth) ;
+ case KEY_F : return ( sGenMachiningKey[KEY_F] + "=" + ::ToString( m_dFeed)) ;
+ case KEY_FE : return ( sGenMachiningKey[KEY_FE] + "=" + ::ToString( m_dEndFeed)) ;
+ case KEY_FS : return ( sGenMachiningKey[KEY_FS] + "=" + ::ToString( m_dStartFeed)) ;
+ case KEY_FT : return ( sGenMachiningKey[KEY_FT] + "=" + ::ToString( m_dTipFeed)) ;
+ case KEY_INV : return ( sGenMachiningKey[KEY_INV] + "=" + ::ToString( m_bInvert)) ;
+ case KEY_NAME : return ( sGenMachiningKey[KEY_NAME] + "=" + m_sName) ;
+ case KEY_NNS : return ( sGenMachiningKey[KEY_NNS] + "=" + m_sSysNotes) ;
+ case KEY_NNU : return ( sGenMachiningKey[KEY_NNU] + "=" + m_sUserNotes) ;
+ case KEY_OL : return ( sGenMachiningKey[KEY_OL] + "=" + ::ToString( m_dOffsL)) ;
+ case KEY_OR : return ( sGenMachiningKey[KEY_OR] + "=" + ::ToString( m_dOffsR)) ;
+ case KEY_PS : return ( sGenMachiningKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ;
+ case KEY_S : return ( sGenMachiningKey[KEY_S] + "=" + ::ToString( m_dSpeed)) ;
+ case KEY_SCC : return ( sGenMachiningKey[KEY_SCC] + "=" + ::ToString( m_nSolCh)) ;
+ case KEY_TNAME : return ( sGenMachiningKey[KEY_TNAME] + "=" + m_sToolName) ;
+ case KEY_TUUID : return ( sGenMachiningKey[KEY_TUUID] + "=" + ::ToString( m_ToolUuid)) ;
+ case KEY_UUID : return ( sGenMachiningKey[KEY_UUID] + "=" + ::ToString( m_Uuid)) ;
+ default : return "" ;
+ }
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::IsOptional( int nKey) const
+{
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::VerifySolCh( int nVal) const
+{
+ return IsValidOperationScc( nVal) ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const
+{
+ if ( pToolsMgr == nullptr)
+ return false ;
+ pTdata = pToolsMgr->GetTool( sVal) ;
+ if ( pTdata == nullptr)
+ return false ;
+ if ( ( pTdata->m_nType & TF_MILL) == 0 && ( pTdata->m_nType & TF_DRILLBIT) == 0 &&
+ ( pTdata->m_nType & TF_SAWBLADE) == 0)
+ return false ;
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::GetTool( const ToolsMgr* pToolsMgr, const ToolData*& pTdata) const
+{
+ if ( pToolsMgr == nullptr)
+ return false ;
+ pTdata = pToolsMgr->GetTool( m_ToolUuid) ;
+ return ( pTdata != nullptr) ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::SetParam( int nType, bool bVal)
+{
+ switch ( nType) {
+ case MPA_INVERT :
+ m_bInvert = bVal ;
+ return true ;
+ }
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::SetParam( int nType, int nVal)
+{
+ switch ( nType) {
+ case MPA_SCC :
+ if ( ! VerifySolCh( nVal))
+ return false ;
+ m_nSolCh = nVal ;
+ return true ;
+ }
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::SetParam( int nType, double dVal)
+{
+ switch ( nType) {
+ case MPA_SPEED :
+ m_dSpeed = dVal ;
+ return true ;
+ case MPA_FEED :
+ m_dFeed = dVal ;
+ return true ;
+ case MPA_STARTFEED :
+ m_dStartFeed = dVal ;
+ return true ;
+ case MPA_ENDFEED :
+ m_dEndFeed = dVal ;
+ return true ;
+ case MPA_TIPFEED :
+ m_dTipFeed = dVal ;
+ return true ;
+ case MPA_OFFSL :
+ m_dOffsL = dVal ;
+ return true ;
+ case MPA_OFFSR :
+ m_dOffsR = dVal ;
+ return true ;
+ case MPA_DEPTH :
+ m_sDepth = ::ToString( dVal) ;
+ return true ;
+ case MPA_STARTPOS :
+ m_dStartPos = dVal ;
+ return true ;
+ }
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::SetParam( int nType, const string& sVal)
+{
+ switch ( nType) {
+ case MPA_NAME :
+ m_sName = sVal ;
+ return true ;
+ case MPA_TOOL :
+ m_sToolName = sVal ;
+ return true ;
+ case MPA_DEPTH_STR :
+ m_sDepth = sVal ;
+ return true ;
+ case MPA_TUUID :
+ return ::FromString( sVal, m_ToolUuid) ;
+ case MPA_UUID :
+ return ::FromString( sVal, m_Uuid) ;
+ case MPA_SYSNOTES :
+ m_sSysNotes = sVal ;
+ return true ;
+ case MPA_USERNOTES :
+ m_sUserNotes = sVal ;
+ return true ;
+ }
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::ResetTool( void)
+{
+ m_sToolName.clear() ;
+ m_ToolUuid.Clear() ;
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::GetParam( int nType, bool& bVal) const
+{
+ switch ( nType) {
+ case MPA_INVERT :
+ bVal = m_bInvert ;
+ return true ;
+ }
+ bVal = false ;
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::GetParam( int nType, int& nVal) const
+{
+ switch ( nType) {
+ case MPA_TYPE :
+ nVal = MT_GENMACHINING ;
+ return true ;
+ case MPA_SCC :
+ nVal = m_nSolCh ;
+ return true ;
+ }
+ nVal = 0 ;
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::GetParam( int nType, double& dVal) const
+{
+ switch ( nType) {
+ case MPA_SPEED :
+ dVal = m_dSpeed ;
+ return true ;
+ case MPA_FEED :
+ dVal = m_dFeed ;
+ return true ;
+ case MPA_STARTFEED :
+ dVal = m_dStartFeed ;
+ return true ;
+ case MPA_ENDFEED :
+ dVal = m_dEndFeed ;
+ return true ;
+ case MPA_TIPFEED :
+ dVal = m_dTipFeed ;
+ return true ;
+ case MPA_OFFSL :
+ dVal = m_dOffsL ;
+ return true ;
+ case MPA_OFFSR :
+ dVal = m_dOffsR ;
+ return true ;
+ case MPA_STARTPOS :
+ dVal = m_dStartPos ;
+ return true ;
+ }
+ dVal = 0 ;
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GenMachiningData::GetParam( int nType, string& sVal) const
+{
+ switch ( nType) {
+ case MPA_NAME :
+ sVal = m_sName ;
+ return true ;
+ case MPA_TOOL :
+ sVal = m_sToolName ;
+ return true ;
+ case MPA_DEPTH_STR :
+ sVal = m_sDepth ;
+ return true ;
+ case MPA_TUUID :
+ sVal = ::ToString( m_ToolUuid) ;
+ return true ;
+ case MPA_UUID :
+ sVal = ::ToString( m_Uuid) ;
+ return true ;
+ case MPA_SYSNOTES :
+ sVal = m_sSysNotes ;
+ return true ;
+ case MPA_USERNOTES :
+ sVal = m_sUserNotes ;
+ return true ;
+ }
+ sVal = "" ;
+ return false ;
+}
diff --git a/GenMachiningData.h b/GenMachiningData.h
new file mode 100644
index 0000000..8bb54f7
--- /dev/null
+++ b/GenMachiningData.h
@@ -0,0 +1,68 @@
+//----------------------------------------------------------------------------
+// EgalTech 2017-2017
+//----------------------------------------------------------------------------
+// File : GenMachiningData.h Data : 15.01.17 Versione : 1.6x7
+// Contenuto : Dichiarazione della struct GenMachiningData e costanti associate.
+//
+//
+//
+// Modifiche : 15.01.17 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+#include "MachiningData.h"
+
+//----------------------------------------------------------------------------
+struct GenMachiningData : public MachiningData
+{
+ EgtUUID m_ToolUuid ; // identificativo universale dell'utensile
+ std::string m_sToolName ; // nome dell'utensile
+ int m_nSolCh ; // criterio scelta soluzione (quando possibili molteplici)
+ double m_dSpeed ; // velocità di rotazione (+ se CCW, - se CW) ( se 0 da utensile)
+ double m_dFeed ; // velocità di lavorazione normale ( se 0 da utensile)
+ double m_dStartFeed ; // velocità di lavorazione iniziale ( se 0 da utensile)
+ double m_dEndFeed ; // velocità di lavorazione finale ( se 0 da utensile)
+ double m_dTipFeed ; // velocità di lavorazione di sfondamento ( se 0 da utensile)
+ double m_dOffsR ; // offset radiale ( se UNKNOWN_PAR da utensile)
+ double m_dOffsL ; // offset longitudinale ( se UNKNOWN_PAR da utensile)
+ bool m_bInvert ; // flag di inversione direzione lavorazione per fori aperti
+ std::string m_sDepth ; // affondamento (espressione numerica)
+ double m_dStartPos ; // quota di inizio lavorazione (sempre >= 0)
+ std::string m_sSysNotes ; // note interne
+ std::string m_sUserNotes ; // note dell'utente
+
+ GenMachiningData( void)
+ : m_ToolUuid(), m_nSolCh( 0), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0),
+ m_dOffsR( 0), m_dOffsL( 0), m_bInvert( false), m_dStartPos( 0) {}
+ GenMachiningData* Clone( void) const override ;
+ bool CopyFrom( const MachiningData* pMdata) override ;
+ bool SameAs(const MachiningData* pMdata) const override ;
+ int GetType( void) const override
+ { return MT_GENMACHINING ; }
+ int GetSize( void) const override ;
+ std::string GetTitle( void) const override ;
+ bool FromString( const std::string& sString, int& nKey) override ;
+ std::string ToString( int nKey) const override ;
+ bool IsOptional( int nKey) const override ;
+ bool SetParam( int nType, bool bVal) override ;
+ bool SetParam( int nType, int nVal) override ;
+ bool SetParam( int nType, double dVal) override ;
+ bool SetParam( int nType, const std::string& sVal) override ;
+ bool ResetTool( void) override ;
+ bool GetParam( int nType, bool& bVal) const override ;
+ bool GetParam( int nType, int& nVal) const override ;
+ bool GetParam( int nType, double& dVal) const override ;
+ bool GetParam( int nType, std::string& sVal) const override ;
+ bool GetTool( const ToolsMgr* pToolsMgr, const ToolData*& pTdata) const override ;
+ bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const override ;
+ bool VerifySolCh( int nVal) const ;
+} ;
+
+//----------------------------------------------------------------------------
+inline const GenMachiningData* GetGenMachiningData( const MachiningData* pMdata)
+ { return (dynamic_cast( pMdata)) ; }
+inline GenMachiningData* GetGenMachiningData( MachiningData* pMdata)
+ { return (dynamic_cast( pMdata)) ; }
diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp
index afa721f..3d1f745 100644
--- a/MachMgrOperations.cpp
+++ b/MachMgrOperations.cpp
@@ -175,6 +175,8 @@ MachMgr::GetOperationType( int nId) const
return OPER_SAWROUGHING ;
else if ( sUserObj == USEROBJ_GETNAME( SawFinishing))
return OPER_SAWFINISHING ;
+ else if ( sUserObj == USEROBJ_GETNAME( GenMachining))
+ return OPER_GENMACHINING ;
else
return OPER_NULL ;
}
diff --git a/MachiningCreate.h b/MachiningCreate.h
index bd17e06..e096637 100644
--- a/MachiningCreate.h
+++ b/MachiningCreate.h
@@ -18,6 +18,7 @@
#include "Milling.h"
#include "SawRoughing.h"
#include "SawFinishing.h"
+#include "GenMachining.h"
//----------------------------------------------------------------------------
// Dal tipo numerico crea una istanza della classe
@@ -30,6 +31,7 @@ CreateMachining( int nMchType)
case MT_MILLING : return new( std::nothrow) Milling ;
case MT_SAWROUGHING : return new( std::nothrow) SawRoughing ;
case MT_SAWFINISHING : return new( std::nothrow) SawFinishing ;
+ case MT_GENMACHINING : return new( std::nothrow) GenMachining ;
}
return nullptr ;
}
diff --git a/MachiningsMgr.cpp b/MachiningsMgr.cpp
index 471b482..a2f7e5c 100644
--- a/MachiningsMgr.cpp
+++ b/MachiningsMgr.cpp
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------------
-// EgalTech 2015-2016
+// EgalTech 2015-2017
//----------------------------------------------------------------------------
-// File : MachiningsMgr.cpp Data : 13.07.16 Versione : 1.6r8
+// File : MachiningsMgr.cpp Data : 15.01.17 Versione : 1.6x7
// Contenuto : Implementazione gestore database lavorazioni.
//
//
//
// Modifiche : 02.06.15 DS Creazione modulo.
-// 13.07.16 DS Aggiunta gestione SplitArcs (MF_CURR_VER = 1005).
+// 13.07.16 DS Agg. gestione SplitArcs (MF_CURR_VER = 1005).
//
//----------------------------------------------------------------------------
@@ -17,14 +17,14 @@
#include "MachiningDataFactory.h"
#include "MachiningConst.h"
#include "DllMain.h"
-#include "/EgtDEv/Include/EGkGeoConst.h"
-#include "/EgtDEv/Include/EMkMachiningConst.h"
-#include "/EgtDEv/Include/EGnStringKeyVal.h"
-#include "/EgtDEv/Include/EGnStringUtils.h"
-#include "/EgtDEv/Include/EGnFileUtils.h"
-#include "/EgtDEv/Include/EGnScanner.h"
-#include "/EgtDEv/Include/EGnWriter.h"
-#include "/EgtDEv/Include/EgtPointerOwner.h"
+#include "/EgtDev/Include/EGkGeoConst.h"
+#include "/EgtDev/Include/EMkMachiningConst.h"
+#include "/EgtDev/Include/EGnStringKeyVal.h"
+#include "/EgtDev/Include/EGnStringUtils.h"
+#include "/EgtDev/Include/EGnFileUtils.h"
+#include "/EgtDev/Include/EGnScanner.h"
+#include "/EgtDev/Include/EGnWriter.h"
+#include "/EgtDev/Include/EgtPointerOwner.h"
#include
#include
@@ -620,7 +620,7 @@ MachiningsMgr::GetFirstMachining( int nType, string& sName) const
bool
MachiningsMgr::GetNextMachining( int nType, string& sName) const
{
- // mentre esiste utensile
+ // mentre esiste lavorazione
while ( m_suCIter != m_suData.end()) {
// nome successivo
++ m_suCIter ;