diff --git a/Drilling.cpp b/Drilling.cpp
index e855871..9d2205d 100644
--- a/Drilling.cpp
+++ b/Drilling.cpp
@@ -16,7 +16,7 @@
#include "MachMgr.h"
#include "DllMain.h"
#include "Drilling.h"
-#include "CamData.h"
+#include "MachiningConst.h"
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveArc.h"
@@ -26,10 +26,6 @@
using namespace std ;
-//----------------------------------------------------------------------------
-static std::string DRI_IDS = "IDS" ;
-static std::string DRI_T1 = "T1" ;
-
//----------------------------------------------------------------------------
struct Hole
{
@@ -82,7 +78,7 @@ bool
Drilling::Dump( string& sOut, const char* szNewLine) const
{
sOut += GetClassName() + szNewLine ;
- sOut += DRI_IDS + EQUAL + ToString( m_vId) + 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)
@@ -99,7 +95,7 @@ Drilling::Save( STRVECTOR& vString) const
int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ;
vString.insert( vString.begin(), nSize, "") ;
int k = - 1 ;
- if ( ! SetVal( DRI_IDS, m_vId, vString[++k]))
+ 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) ;
@@ -120,7 +116,7 @@ Drilling::Load( const STRVECTOR& vString)
if ( int( vString.size()) < nSize)
return false ;
int k = - 1 ;
- if ( ! GetVal( vString[++k], DRI_IDS, m_vId))
+ if ( ! GetVal( vString[++k], KEY_IDS, m_vId))
return false ;
for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) {
int nKey ;
@@ -207,45 +203,55 @@ Drilling::Apply( void)
// verifico validità gestore DB geometrico e Id del gruppo
if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId))
return false ;
- // recupero gruppo per geometria di lavorazione del primo utensile
- int nT1Id = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, DRI_T1) ;
+ // recupero gruppo per geometria di lavorazione (Cutter Location)
+ int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
// se non c'è, lo aggiungo
- if ( nT1Id == GDB_ID_NULL) {
- nT1Id = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
- if ( nT1Id == GDB_ID_NULL)
+ 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( nT1Id, DRI_T1) ;
- m_pGeomDB->SetMaterial( nT1Id, GREEN) ;
+ m_pGeomDB->SetName( nClId, MCH_CL) ;
}
// altrimenti lo svuoto
else
- m_pGeomDB->EmptyGroup( nT1Id) ;
+ m_pGeomDB->EmptyGroup( nClId) ;
// elaboro i singoli fori
- for ( int i = 0 ; i < int( m_vId.size()) ; ++ i) {
+ int i = 0 ;
+ for ( const auto& vId : m_vId) {
+ // creo gruppo per geometria di lavorazione del foro
+ int nPathId = m_pGeomDB->AddGroup( GDB_ID_NULL, nClId, Frame3d()) ;
+ if ( nPathId == GDB_ID_NULL)
+ return false ;
+ m_pGeomDB->SetName( nPathId, MCH_PATH + ToString( ++i)) ;
+ m_pGeomDB->SetInfo( nPathId, KEY_IDS, ToString( vId)) ;
+ m_pGeomDB->SetMaterial( nPathId, GREEN) ;
// recupero i dati del foro
Hole hole ;
- if ( ! GetHoleData( m_vId[i], hole)) {
- string sOut = "Entity " + ToString( m_vId[i]) + " skipped by Drilling" ;
+ if ( ! GetHoleData( vId, hole) || fabs( hole.dDiam - m_TParams.m_dDiam) > EPS_SMALL) {
+ m_pGeomDB->Erase( nPathId) ;
+ string sOut = "Entity " + ToString( vId) + " skipped by Drilling" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
continue ;
}
// limito lunghezza foro a massima lavorazione della punta
if ( hole.dLen > m_TParams.m_dMaxMat + EPS_SMALL) {
hole.dLen = m_TParams.m_dMaxMat ;
- string sOut = "Drill bit too short for Hole " + ToString( m_vId[i]) ;
+ string sOut = "Drill bit too short for Hole " + ToString( vId) ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
}
// foro normale
if ( m_Params.m_dStep < EPS_SMALL ||
m_Params.m_dStep > hole.dLen - EPS_SMALL) {
- if ( ! DoStandardDrilling( hole, m_vId[i], nT1Id)) {
- string sOut = "Entity " + ToString( m_vId[i]) + " skipped by Standard Drilling" ;
+ if ( ! DoStandardDrilling( hole, vId, nPathId)) {
+ m_pGeomDB->Erase( nPathId) ;
+ string sOut = "Hole " + ToString( vId) + " skipped by Standard Drilling" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
}
}
else {
- if ( ! DoPeckDrilling( hole, m_vId[i], nT1Id)) {
- string sOut = "Entity " + ToString( m_vId[i]) + " skipped by Peck Drilling" ;
+ if ( ! DoPeckDrilling( hole, vId, nPathId)) {
+ m_pGeomDB->Erase( nPathId) ;
+ string sOut = "Hole " + ToString( vId) + " skipped by Peck Drilling" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
}
}
diff --git a/EgtMachKernel.vcxproj b/EgtMachKernel.vcxproj
index f48725f..9d86e84 100644
--- a/EgtMachKernel.vcxproj
+++ b/EgtMachKernel.vcxproj
@@ -262,6 +262,7 @@ copy $(TargetPath) \EgtProg\Dll64
+
diff --git a/EgtMachKernel.vcxproj.filters b/EgtMachKernel.vcxproj.filters
index 236f603..6409d4c 100644
--- a/EgtMachKernel.vcxproj.filters
+++ b/EgtMachKernel.vcxproj.filters
@@ -218,6 +218,9 @@
Header Files
+
+ Header Files
+
diff --git a/MachConst.h b/MachConst.h
index eab580d..acfeb20 100644
--- a/MachConst.h
+++ b/MachConst.h
@@ -58,7 +58,3 @@ const std::string MACHININGS_FILE = "Machinings.data" ;
// Minimo spessore del grezzo
const double RAW_MIN_H = 1 ;
-//----------------------------------------------------------------------------
-// Feed equivalente a massima
-const double MAX_FEED = 100000 ;
-
diff --git a/MachiningConst.h b/MachiningConst.h
new file mode 100644
index 0000000..899f29e
--- /dev/null
+++ b/MachiningConst.h
@@ -0,0 +1,28 @@
+//----------------------------------------------------------------------------
+// EgalTech 2015-2015
+//----------------------------------------------------------------------------
+// File : MachiningConst.h Data : 18.06.15 Versione : 1.6f3
+// Contenuto : Costanti delle lavorazioni.
+//
+//
+//
+// Modifiche : 18.06.15 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+#include
+
+//----------------------------------------------------------------------------
+// Chiave per elenco identificativi di selezione
+static std::string KEY_IDS = "IDS" ;
+// Sottogruppi delle lavorazioni
+static std::string MCH_AUX = "AUX" ;
+static std::string MCH_CL = "CL" ;
+static std::string MCH_PATH = "P" ;
+
+//----------------------------------------------------------------------------
+// Feed equivalente a massima
+const double MAX_FEED = 100000 ;
diff --git a/Milling.cpp b/Milling.cpp
index 000661e..44db9ff 100644
--- a/Milling.cpp
+++ b/Milling.cpp
@@ -16,14 +16,16 @@
#include "MachMgr.h"
#include "DllMain.h"
#include "Milling.h"
+#include "MachiningConst.h"
+#include "/EgtDev/Include/EGkCurveLine.h"
+#include "/EgtDev/Include/EGkCurveComposite.h"
+#include "/EgtDev/Include/EgkChainCurves.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
#include "/EgtDev/Include/EGnStringKeyVal.h"
+#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
-//----------------------------------------------------------------------------
-static std::string KEY_IDS = "IDS" ;
-
//----------------------------------------------------------------------------
USEROBJ_REGISTER( "EMkMilling", Milling) ;
@@ -169,3 +171,172 @@ Milling::Apply( void)
{
return false ;
}
+
+//----------------------------------------------------------------------------
+bool
+Milling::VerifyGeometry( SelData Id, int& nSubs)
+{
+ // ammessi : curve o facce di polymesh
+
+ // per ora accetto solo curve
+ const ICurve* pCurve = nullptr ;
+ const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
+ // se direttamente la curva
+ if ( Id.nSub == SEL_SUB_ALL) {
+ pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ;
+ if ( pCurve != nullptr && pCurve->GetType() == CRV_COMPO)
+ nSubs = ::GetCurveComposite( pCurve)->GetCurveNumber() ;
+ }
+ // altrimenti sottocurva di composita
+ else {
+ const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ;
+ if ( pCompo != nullptr)
+ pCurve = pCompo->GetCurve( Id.nSub) ;
+ nSubs = 0 ;
+ }
+ return ( pCurve != nullptr) ;
+}
+
+//----------------------------------------------------------------------------
+ICurve*
+Milling::GetCurve( SelData Id)
+{
+ // ammessi : curve o facce di polymesh
+ // nel caso di facce si deve recuperare la linea di base
+
+ // per ora accetto solo curve
+ PtrOwner pCurve ;
+ // se direttamente curva
+ if ( Id.nSub == SEL_SUB_ALL) {
+ // recupero e duplico la curva
+ const ICurve* pOriCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ;
+ if ( pOriCurve != nullptr)
+ pCurve.Set( pOriCurve->Clone()) ;
+ }
+ // altrimenti sottocurva di composita
+ else {
+ // recupero la composita
+ const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ;
+ 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))
+ pCurve->SetExtrusion( vtExtr) ;
+ double dThick ;
+ if ( pCompo->GetThickness( dThick))
+ pCurve->SetThickness( dThick) ;
+ }
+ }
+ }
+ if ( IsNull( pCurve))
+ return nullptr ;
+ // ne recupero il riferimento globale
+ Frame3d frGlob ;
+ if ( ! m_pGeomDB->GetGlobFrame( Id.nId, frGlob))
+ return nullptr ;
+ // la porto in globale
+ pCurve->ToGlob( frGlob) ;
+ // la restituisco
+ return Release( pCurve) ;
+}
+
+//----------------------------------------------------------------------------
+bool
+Milling::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
+ 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 = Get( 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 ;
+ }
+ // recupero i percorsi concatenati
+ int nCount = 0 ;
+ Point3d ptNear = ORIG ;
+ 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 = Get( 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->GetCurveNumber() == 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 ;
+}
diff --git a/Milling.h b/Milling.h
index e4ac790..2ef1924 100644
--- a/Milling.h
+++ b/Milling.h
@@ -17,6 +17,8 @@
#include "MillingData.h"
#include "ToolData.h"
+class ICurve ;
+
//----------------------------------------------------------------------------
class Milling : public Machining
{
@@ -36,6 +38,11 @@ class Milling : public Machining
public :
Milling( void) ;
+ private :
+ bool VerifyGeometry( SelData Id, int& nSubs) ;
+ ICurve* GetCurve( SelData Id) ;
+ bool Chain( int nGrpDestId) ;
+
private :
INTVECTOR m_vId ; // identificativi entità geometriche da lavorare
MillingData m_Params ; // parametri lavorazione
diff --git a/Sawing.cpp b/Sawing.cpp
index d5a5b4f..7065db5 100644
--- a/Sawing.cpp
+++ b/Sawing.cpp
@@ -16,18 +16,16 @@
#include "MachMgr.h"
#include "DllMain.h"
#include "Sawing.h"
+#include "MachiningConst.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
+#include "/EgtDev/Include/EgkChainCurves.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
#include "/EgtDev/Include/EGnStringKeyVal.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
-//----------------------------------------------------------------------------
-static std::string SAW_IDS = "IDS" ;
-static std::string SAW_T1 = "T1" ;
-
//----------------------------------------------------------------------------
USEROBJ_REGISTER( "EMkSawing", Sawing) ;
@@ -66,7 +64,7 @@ bool
Sawing::Dump( string& sOut, const char* szNewLine) const
{
sOut += GetClassName() + szNewLine ;
- sOut += SAW_IDS + EQUAL + ToString( m_vId) + 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)
@@ -83,7 +81,7 @@ Sawing::Save( STRVECTOR& vString) const
int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ;
vString.insert( vString.begin(), nSize, "") ;
int k = - 1 ;
- if ( ! SetVal( SAW_IDS, m_vId, vString[++k]))
+ 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) ;
@@ -104,7 +102,7 @@ Sawing::Load( const STRVECTOR& vString)
if ( int( vString.size()) < nSize)
return false ;
int k = - 1 ;
- if ( ! GetVal( vString[++k], SAW_IDS, m_vId))
+ if ( ! GetVal( vString[++k], KEY_IDS, m_vId))
return false ;
for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) {
int nKey ;
@@ -172,13 +170,19 @@ Sawing::SetGeometry( const SELVECTOR& vIds)
// verifico che gli identificativi rappresentino delle entità ammissibili
for ( const auto& Id : vIds) {
// test sull'entità
- if ( ! VerifyGeometry( Id)) {
+ int nSubs ;
+ if ( ! VerifyGeometry( Id, nSubs)) {
string sOut = "Entity " + ToString( Id) + " skipped by Sawing" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
continue ;
}
// posso aggiungere alla lista
- m_vId.push_back( Id) ;
+ if ( nSubs == 0)
+ m_vId.emplace_back( Id) ;
+ else {
+ for ( int i = 0 ; i < nSubs ; ++ i)
+ m_vId.emplace_back( Id.nId, i) ;
+ }
}
return ( ! m_vId.empty()) ;
}
@@ -190,6 +194,47 @@ Sawing::Apply( void)
// 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) ;
+ // 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) ;
+ }
+ // altrimenti lo svuoto
+ else
+ m_pGeomDB->EmptyGroup( nAuxId) ;
+
+ // eseguo concatenamento, inserisco i percorsi sotto la geometria ausiliaria
+ if ( ! 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) {
+ PathApply( nPathId) ;
+ nPathId = m_pGeomDB->GetNextGroup( nPathId) ;
+ }
+
+ return true ;
+
+#if 0
// recupero gruppo per geometria di lavorazione del primo utensile
int nT1Id = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, SAW_T1) ;
// se non c'è, lo aggiungo
@@ -247,27 +292,32 @@ Sawing::Apply( void)
}
return true ;
+#endif
}
//----------------------------------------------------------------------------
bool
-Sawing::VerifyGeometry( SelData Id)
+Sawing::VerifyGeometry( SelData Id, int& nSubs)
{
// ammessi : curve o facce di polymesh
- // !!! per ora accetto solo linee !!!
- const ICurveLine* pLine = nullptr ;
+ // per ora accetto solo curve
+ const ICurve* pCurve = nullptr ;
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
// se direttamente la curva
- if ( Id.nSub == SEL_SUB_ALL)
- pLine = GetCurveLine( m_pGeomDB->GetGeoObj( Id.nId)) ;
+ if ( Id.nSub == SEL_SUB_ALL) {
+ pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ;
+ if ( pCurve != nullptr && pCurve->GetType() == CRV_COMPO)
+ nSubs = ::GetCurveComposite( pCurve)->GetCurveNumber() ;
+ }
// altrimenti sottocurva di composita
else {
const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ;
if ( pCompo != nullptr)
- pLine = GetCurveLine( pCompo->GetCurve( Id.nSub)) ;
+ pCurve = pCompo->GetCurve( Id.nSub) ;
+ nSubs = 0 ;
}
- return ( pLine != nullptr) ;
+ return ( pCurve != nullptr) ;
}
//----------------------------------------------------------------------------
@@ -277,34 +327,151 @@ Sawing::GetCurve( SelData Id)
// ammessi : curve o facce di polymesh
// nel caso di facce si deve recuperare la linea di base
- // !!! per ora accetto solo linee !!!
- const ICurveLine* pLine = nullptr ;
- const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
- // se direttamente la curva
- if ( Id.nSub == SEL_SUB_ALL)
- pLine = GetCurveLine( m_pGeomDB->GetGeoObj( Id.nId)) ;
+ // per ora accetto solo curve
+ PtrOwner pCurve ;
+ // se direttamente curva
+ if ( Id.nSub == SEL_SUB_ALL) {
+ // recupero e duplico la curva
+ const ICurve* pOriCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ;
+ if ( pOriCurve != nullptr)
+ pCurve.Set( pOriCurve->Clone()) ;
+ }
// altrimenti sottocurva di composita
else {
+ // recupero la composita
const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ;
- if ( pCompo != nullptr)
- pLine = GetCurveLine( pCompo->GetCurve( Id.nSub)) ;
+ 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))
+ pCurve->SetExtrusion( vtExtr) ;
+ double dThick ;
+ if ( pCompo->GetThickness( dThick))
+ pCurve->SetThickness( dThick) ;
+ }
+ }
}
- if ( pLine == nullptr)
+ if ( IsNull( pCurve))
return nullptr ;
// ne recupero il riferimento globale
Frame3d frGlob ;
if ( ! m_pGeomDB->GetGlobFrame( Id.nId, frGlob))
return nullptr ;
- // ne faccio una copia e la porto in globale
- PtrOwner pCurve( pLine->Clone()) ;
- if ( IsNull( pCurve))
- return nullptr ;
+ // la porto in globale
pCurve->ToGlob( frGlob) ;
- // imposto estrusione a Zglob+
- pCurve->SetExtrusion( Z_AX) ;
+ // la restituisco
return Release( pCurve) ;
}
+//----------------------------------------------------------------------------
+bool
+Sawing::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 Sawing" ;
+ LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
+ vpCrvs.back().Reset() ;
+ }
+ }
+ // preparo i dati per il concatenamento
+ 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 = Get( 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 ;
+ }
+ // recupero i percorsi concatenati
+ int nCount = 0 ;
+ Point3d ptNear = ORIG ;
+ 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 = Get( 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->GetCurveNumber() == 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
+Sawing::PathApply( int nPathId)
+{
+
+ return true ;
+}
+
//----------------------------------------------------------------------------
bool
Sawing::CalculateToolAndCorrVersors( const ICurve* pCurve, Vector3d& vtTool, Vector3d& vtCorr)
diff --git a/Sawing.h b/Sawing.h
index e8e6341..a94c2d2 100644
--- a/Sawing.h
+++ b/Sawing.h
@@ -34,13 +34,15 @@ class Sawing : public Machining
virtual bool Prepare( const std::string& sSawName) ;
virtual bool SetGeometry( const SELVECTOR& vIds) ;
virtual bool Apply( void) ;
+ virtual bool PathApply( int nPathId) ;
public :
Sawing( void) ;
private :
- bool VerifyGeometry( SelData Id) ;
+ bool VerifyGeometry( SelData Id, int& nSubs) ;
ICurve* GetCurve( SelData Id) ;
+ bool Chain( int nGrpDestId) ;
bool CalculateToolAndCorrVersors( const ICurve* pCurve, Vector3d& vtTool, Vector3d& vtCorr) ;
bool AdjustForSide( ICurve* pCurve) ;
diff --git a/SawingData.cpp b/SawingData.cpp
index d728b69..50ca1c9 100644
--- a/SawingData.cpp
+++ b/SawingData.cpp
@@ -23,29 +23,37 @@ using namespace std ;
//----------------------------------------------------------------------------
enum nSawingKey {
- KEY_DH = 0,
+ KEY_APPR = 0,
+ KEY_CRV,
+ KEY_DH,
KEY_HS,
KEY_INV,
+ KEY_LETY,
+ KEY_LITY,
+ KEY_LOTY,
KEY_NAME,
KEY_SA,
KEY_TAF,
KEY_TNAME,
KEY_TUUID,
- KEY_TY,
KEY_UUID,
KEY_WS,
KEY_ZZZ} ; // rappresenta il numero di elementi
static const std::array sSawingKey = {
+ "APPR",
+ "CRV",
"DH",
"HS",
"INV",
+ "LETY",
+ "LITY",
+ "LOTY",
"NAME",
"SA",
"TAF",
"TN",
"TU",
- "TY",
"UUID",
"WS"} ;
@@ -88,8 +96,15 @@ SawingData::FromString( const string& sString, int& nKey)
nKey = FindSawingKey( ToUpper( sKey)) ;
bool bOk = ( nKey >= 0) ;
switch ( nKey) {
+ case KEY_APPR :
+ bOk = ::FromString( sVal, m_dApprox) ;
+ break ;
+ case KEY_CRV :
+ bOk = ::FromString( sVal, m_nCurveUse) ;
+ break ;
case KEY_DH :
- bOk = ::FromString( sVal, m_dDepth) ;
+ m_sDepth = sVal ;
+ bOk = ! m_sDepth.empty() ;
break ;
case KEY_HS :
bOk = ::FromString( sVal, m_nHeadSide) ;
@@ -97,6 +112,15 @@ SawingData::FromString( const string& sString, int& nKey)
case KEY_INV :
bOk = ::FromString( sVal, m_bInvert) ;
break ;
+ case KEY_LETY :
+ bOk = ::FromString( sVal, m_nExtLinkType) ;
+ break ;
+ case KEY_LITY :
+ bOk = ::FromString( sVal, m_nLeadInType) ;
+ break ;
+ case KEY_LOTY :
+ bOk = ::FromString( sVal, m_nLeadOutType) ;
+ break ;
case KEY_NAME :
m_sName = sVal ;
bOk = ! m_sName.empty() ;
@@ -114,9 +138,6 @@ SawingData::FromString( const string& sString, int& nKey)
case KEY_TUUID :
bOk = ::FromString( sVal, m_ToolUuid) ;
break ;
- case KEY_TY :
- bOk = ::FromString( sVal, m_nType) ;
- break ;
case KEY_UUID :
bOk = ::FromString( sVal, m_Uuid) ;
break ;
@@ -135,15 +156,19 @@ string
SawingData::ToString( int nInd) const
{
switch ( nInd) {
- case KEY_DH : return ( sSawingKey[KEY_DH] + "=" + ::ToString( m_dDepth)) ;
+ case KEY_APPR : return ( sSawingKey[KEY_APPR] + "=" + ::ToString( m_dApprox)) ;
+ case KEY_CRV : return ( sSawingKey[KEY_CRV] + "=" + ::ToString( m_nCurveUse)) ;
+ case KEY_DH : return ( sSawingKey[KEY_DH] + "=" + m_sDepth) ;
case KEY_HS : return ( sSawingKey[KEY_HS] + "=" + ::ToString( m_nHeadSide)) ;
case KEY_INV : return ( sSawingKey[KEY_INV] + "=" + ::ToString( m_bInvert)) ;
+ case KEY_LETY : return ( sSawingKey[KEY_LETY] + "=" + ::ToString( m_nExtLinkType)) ;
+ case KEY_LITY : return ( sSawingKey[KEY_LITY] + "=" + ::ToString( m_nLeadInType)) ;
+ case KEY_LOTY : return ( sSawingKey[KEY_LOTY] + "=" + ::ToString( m_nLeadOutType)) ;
case KEY_NAME : return ( sSawingKey[KEY_NAME] + "=" + m_sName) ;
case KEY_SA : return ( sSawingKey[KEY_SA] + "=" + ::ToString( m_dSideAngle)) ;
case KEY_TAF : return ( sSawingKey[KEY_TAF] + "=" + ::ToString( m_bToAndFro)) ;
case KEY_TNAME : return ( sSawingKey[KEY_TNAME] + "=" + m_sToolName) ;
case KEY_TUUID : return ( sSawingKey[KEY_TUUID] + "=" + ::ToString( m_ToolUuid)) ;
- case KEY_TY : return ( sSawingKey[KEY_TY] + "=" + ::ToString( m_nType)) ;
case KEY_UUID : return ( sSawingKey[KEY_UUID] + "=" + ::ToString( m_Uuid)) ;
case KEY_WS : return ( sSawingKey[KEY_WS] + "=" + ::ToString( m_nWorkSide)) ;
default : return "" ;
diff --git a/SawingData.h b/SawingData.h
index 45c51eb..6cc0f11 100644
--- a/SawingData.h
+++ b/SawingData.h
@@ -23,13 +23,17 @@ struct SawingData : public MachiningData
bool m_bInvert ; // flag di inversione direzione lavorazione
int m_nWorkSide ; // lato di lavoro (destra, sinistra, centro)
int m_nHeadSide ; // lato di posizionamento del mandrino ( destra o sinistra)
- int m_nType ; // preciso, centro lama o allungato fino al bordo del grezzo
bool m_bToAndFro ; // taglio avanti-indietro
- double m_dDepth ; // affondamento
- double m_dSideAngle ; // angolo di sbandamento (0-60deg)
+ std::string m_sDepth ; // affondamento (espressione numerica)
+ double m_dSideAngle ; // angolo di sbandamento (0..+60deg, 99=auto)
+ int m_nLeadInType ; // tipo di attacco (interno, centro, fuori, esteso, esteso fuori)
+ int m_nExtLinkType ; // tipo di collegamento su ang esterno ( centro, esteso prec, esteso succ, esteso minore)
+ int m_nLeadOutType ; // tipo di uscita (interno, centro, esteso)
+ int m_nCurveUse ; // gestione delle curve(salta, approssima, convesso)
+ double m_dApprox ; // valore di approssimazione per curve
SawingData( void)
- : m_bInvert( false), m_nWorkSide( 0), m_nHeadSide(0), m_nType(0), m_bToAndFro( false),
- m_dDepth( 0), m_dSideAngle( 0) {}
+ : m_bInvert( false), m_nWorkSide( 0), m_nHeadSide(0), m_bToAndFro( false), m_dSideAngle( 0),
+ m_nLeadInType( 0), m_nExtLinkType( 0), m_nLeadOutType( 0), m_nCurveUse( 0), m_dApprox( 0) {}
virtual int GetType( void) const { return MT_SAWING ; }
virtual int GetSize( void) const ;
virtual std::string GetTitle( void) const ;
@@ -49,9 +53,22 @@ enum { SAW_WS_CENTER = 0,
// Lato di posizionamento della testa
enum { SAW_HS_LEFT = 1,
SAW_HS_RIGHT = 2 } ;
-// Tipo di lavorazione di lama
-enum { SAW_TY_STRICT = 0,
- SAW_TY_CENT_ON = 1,
- SAW_TY_CENT_OUT = 2,
- SAW_TY_EXT_ON = 3,
- SAW_TY_EXT_OUT = 4} ;
+// Tipo di attacco con lama
+enum { SAW_LI_STRICT = 0,
+ SAW_LI_CENT = 1,
+ SAW_LI_OUT = 2,
+ SAW_LI_EXT_CENT = 3,
+ SAW_LI_EXT_OUT = 4} ;
+// Tipo di uscita con lama
+enum { SAW_LO_STRICT = 0,
+ SAW_LO_CENT = 1,
+ SAW_LO_EXT = 2} ;
+// Tipo di link esterno con lama
+enum { SAW_EL_CENT = 0,
+ SAW_EL_EXT_PREV = 1,
+ SAW_EL_EXT_NEXT = 2,
+ SAW_EL_EXT_SMALLER = 3} ;
+// Gestione curve
+enum { SAW_CRV_SKIP = 0,
+ SAW_CRV_APPROX = 1,
+ SAW_CRV_CONVEX = 2} ;