69 Commits

Author SHA1 Message Date
Dario Sassi 91d1260d8a EgtExchange 3.1e2 :
- in import BTL aggiunta gestione Tenone Coda di Rondine non limitato dal lato dell'arrotondamento (P04=1).
2026-05-13 11:09:23 +02:00
Dario Sassi aead658f5d EgtExchange 3.1d2 :
- in import CNC aggiunta gestione pausa con G04 (si ignora la linea).
2026-04-22 08:23:18 +02:00
Dario Sassi 82a5161b07 EgtExchange 3.1d1 :
- in import BTL gestite come empty le LapJoint (3/4-030-X) completamente fuori dal pezzo.
2026-04-03 16:16:51 +02:00
Dario Sassi f923477b7e EgtExchange 3.1c2 :
- in import BTL corretta AddMortise (3/4-050-X).
2026-03-05 20:18:50 +01:00
Dario Sassi 96a5f77b12 EgtExchange 3.1c1 :
- ricompilazione con cambio versione.
2026-03-05 11:19:03 +01:00
Dario Sassi c47b3ee4d3 EgtExchange 3.1a4 :
- corretta importazione BTL con tenone a coda di rondine più corto dei raccordi in basso.
2026-02-10 11:08:49 +01:00
Dario Sassi c1f32c6c59 EgtExchenge :
- in import CNC aggiunto salvataggio feed corrente in info di entità.
2026-02-03 18:03:30 +01:00
Dario Sassi 30b1085ef5 EgtExchange 3.1a3 :
- miglioria in import Cnc Siemens (si saltano le linee che iniziano con ID o con DYN).
2026-02-02 10:30:12 +01:00
Dario Sassi 9577795c73 EgtExchange 3.1a2 :
- per BTL aggiunta possibilità di gestione geometrica del PARTOFFSET (controllata da flag).
2026-01-23 18:53:20 +01:00
Dario Sassi e7e7cb21bd EgtExchange 3.1a1 :
- ricompilazione con cambio major version.
2026-01-02 18:28:28 +01:00
Dario Sassi 5e74d640aa EgtExchange 2.7l1 :
- ricompilazione con cambio versione.
2025-12-20 17:55:28 +01:00
Dario Sassi 398f7d86a6 EgtExchange 2.7k2 :
- eliminato include inutile.
2025-12-01 09:16:45 +01:00
Dario Sassi 8eaf7c174f EgtExchange :
- modifiche per inizializzazione BeamMgr senza creare gruppi speciali.
2025-11-04 18:48:03 +01:00
SaraP 18c7c4601a EgtExchange :
- aggiornata pugixml a versione 1.15
- correzioni stilistiche in ImportBTLx.
2025-11-03 10:07:00 +01:00
Dario Sassi df864c93a8 EgtExchange 2.7k1 :
- adattamenti e ricompilazione per passaggio a C++ 20
2025-11-01 17:34:12 +01:00
Dario Sassi e16657f560 EgtExchange 2.7j2 :
- in import BTL corretta lunghezza eventuale tasca per mortase a coda di rondine.
2025-10-25 10:30:11 +02:00
Dario Sassi 1f24ff1dfb EgtExchange :
- in BeamMgr aggiunto calcolo di tutti i solidi dei pezzi in multithread.
2025-10-13 08:47:55 +02:00
Dario Sassi 8d70d31eff EgtExchange 2.7j1 :
- in import BTL gestione di più Info e Assembly in uno stesso progetto (derivano da più importazioni successive).
2025-10-11 10:03:00 +02:00
Dario Sassi a874068e7b EgtExchange 2.7i1 :
- ricompilazione con cambio versione.
2025-09-05 08:19:19 +02:00
SaraP 15dfae1789 EgtExchange :
- in Import3MF eliminata dipendenza inutile da libzip.
2025-08-25 11:12:01 +02:00
Dario Sassi 62aecf63eb EgtExchange 2.7h1 :
- ricompilazione con cambio versione.
2025-08-22 11:47:17 +02:00
Dario Sassi 2bb1767c9d EgtExchange 2.7g2 :
- in import BTL aggiunta possibilità di trim con outline per tutte le feature pareti con esclusione di fori, marcature e testi.
2025-07-24 09:02:38 +02:00
Dario Sassi 798c23e42d EgtExchange 2.7g1 :
- ricompilazione con cambio versione.
2025-07-02 19:49:48 +02:00
Dario Sassi 13c2a1d9e5 EgtExchange 2.7f2 :
- ricompilazione con cambio versione.
2025-06-26 09:47:54 +02:00
Dario Sassi 83215059a5 EgtExchange 2.7f1 :
- ricompilazione con cambio versione.
2025-06-06 17:38:24 +02:00
Dario Sassi 120e341fb7 EgtExchange 2.7d2 :
- ricompilazione con cambio versione.
2025-04-21 11:17:54 +02:00
Dario Sassi b7c3dbc576 EgtExchange :
- in import BTL aggiunto trim con Outline (se abilitato) anche per feature Pocket.
2025-03-31 14:47:29 +02:00
Dario Sassi 1e09cdff14 EgtExchange 2.7c3 :
- in import/manage BTL migliorata segnalazione in Log di Klingschrot con parametri non corretti.
2025-03-25 11:02:07 +01:00
Dario Sassi 53962aa5c1 EgtExchange :
- in import/manage BTL aggiunta gestione fino a due Outline per pezzo (in precedenza erroneamente dava errore).
2025-03-08 22:52:48 +01:00
Dario Sassi c16fba2752 EgtExchange 2.7c2 :
- in import/manage BTL corretta feature 3/4-038-X (Block House Front) da segnalazione Essetre #2316.
2025-03-07 15:39:16 +01:00
Dario Sassi 03eb6707ee EgtExchange :
- in import/gestione BTL migliorata qualità geometrica della sfera.
2025-03-07 08:37:30 +01:00
Dario Sassi c8b4cd9bee EgtExchange 2.7c1 :
- ricompilazione con cambio versione.
2025-03-06 20:11:28 +01:00
Dario Sassi 9331803efc EgtExchange 2.7b2 :
- aggiunta importazione formato PLY
- migliorata importazione formato OFF.
2025-03-02 19:42:10 +01:00
Dario Sassi 050d3acd60 EgtExchange 2.7b1 :
- ricompilazione con cambio versione.
2025-02-28 12:09:30 +01:00
Dario Sassi ac55ab01df EgtExchange :
- in import/gestione BTL aumentati a 25 i parametri gestiti per la feature Variant con script lua.
2025-01-27 12:43:02 +01:00
Dario Sassi 4ab0d89e60 EgtExchange 2.7a2 :
- modifiche in import e gestione BTL per feature Variant con lua.
2025-01-23 11:35:56 +01:00
Dario Sassi b6d4d76783 EgtExchange :
- in import BTL il vincolo sulla lunghezza massima del FreeContour è diventato un vincolo sul suo ingombro massimo.
2025-01-21 11:16:19 +01:00
Dario Sassi b366963eee EgtExchange :
- migliorie nell'importazione formato OFF.
2025-01-13 08:33:50 +01:00
Dario Sassi d1a19ed42f EgtExchange 2.7a1 :
- cambio annuale di versione
- compilazione 32bit senza più limiti per Windows XP.
2025-01-09 17:59:43 +01:00
Dario Sassi ae950c0efa EgtExchange :
- aggiustamenti per modifiche a FromString (in caso di errore non inizializza più a 0 il valore di ritorno).
2025-01-06 18:15:49 +01:00
SaraP aa80fb63af EgtExchange 2.6l3 :
- in import ed export 3MF gestione della gerarchia dei gruppi
- migliorie e correzioni varie.
2024-12-16 10:52:28 +01:00
Dario Sassi 7778cf5027 EgtExchange 2.6l2 :
- piccola modifica in import BTL.
2024-12-04 15:05:33 +01:00
Dario Sassi bb75d9c878 EgtExchange :
- aggiustamento.
2024-11-29 18:53:37 +01:00
Dario Sassi f54f1f8969 EgtExchange 2.6l1 :
- aggiunta importazione formato OFF (Object File Format).
2024-11-29 18:18:28 +01:00
Dario Sassi a71e1211d1 EgtExchange 2.6k1 :
- in import CNC con OSAI si saltano le parti che iniziano con @ (variabili).
2024-11-25 20:32:32 +01:00
Dario Sassi 75d5fc367c EgtExchange 2.6j1 :
- in import BTL le feature FreeContour torte ora sono meglio approssimate utilizzando nei calcoli anche le superfici di Bezier.
2024-10-02 17:29:38 +02:00
Dario Sassi 6624da2a03 EgtExchange 2.6i1 :
- ricompilazione con cambio versione.
2024-09-23 13:05:03 +02:00
Dario Sassi 3d8c83f33c EgtExchange 2.6h2 :
- ricompilazione con cambio versione.
2024-08-22 09:10:59 +02:00
Dario Sassi 584cec6f1c EgtExchange 2.6g5 :
- ricompilazione con cambio versione
2024-07-18 20:19:21 +02:00
Dario Sassi 7ed7f56415 EgtExchange :
- in import BTL piccola modifica per migliorare qualità feature Sfera.
2024-07-09 18:51:34 +02:00
Dario Sassi 22d47e551a EgtExchange 2.6g1 :
- ricompilazione con cambio versione.
2024-07-09 11:15:17 +02:00
Dario Sassi 6434dc6c89 EgtExchange :
- in importBTL in feature LapJoint quando divisa in parti disconnesse si cerca di eliminare quelle troppo piccole, se ne rimangono più di una si disabilita la feature.
2024-06-26 17:42:43 +02:00
Dario Sassi ca58abb125 EgtExchange 2.6f4 :
- ricompilazione con cambio versione.
2024-06-26 08:42:28 +02:00
Dario Sassi f7fb6d3435 EgtExchange 2.6f3 :
- ricompilazione con cambio versione.
2024-06-13 07:59:40 +02:00
Dario Sassi ad9acebd04 EgtExchange 2.6f1 :
- in import BTL gestione di FreeContour con lunghezze elevate (oltre 200 m) come errati (si evitano crash o loop molto lunghi e inutili).
2024-06-04 19:09:53 +02:00
Dario Sassi 3543839299 EgtExchange 2.6e2 :
- in import BTL migliorata geometria FreeContour a due percorsi con torsione.
2024-05-13 07:57:51 +02:00
Dario Sassi b5a3fb5543 EgtExchange 2.6e1 :
- ricompilazione per modifiche a gestione chiave di rete.
2024-04-30 16:54:24 +02:00
Dario Sassi 80634b8fcd EgtExchange 2.6d3 :
- ricompilazione con cambio versione.
2024-04-13 17:10:31 +02:00
Dario Sassi 025336f011 EgtExchange 2.6d1 :
- ricompilazione con cambio versione.
2024-04-05 16:52:05 +02:00
Dario Sassi deaab1767f EgtExchange :
- in gestione BTL imposto visualizzazione spigoli vivi su solidi.
2024-03-10 10:23:28 +01:00
Dario Sassi ee8d0c8c21 EgtExchange 2.6b4 :
- in import BTL agg. variante Klingschrot di feature TyroleanDovetail.
2024-02-28 16:59:17 +01:00
Dario Sassi 1a7483b7c4 EgtExchange :
- in import BTL aggiunta gestione feature 3/4-106-X SPHERE.
2024-02-22 11:59:54 +01:00
Dario Sassi 3205e80262 EgtExchange 2.6b3 :
- ricompilazione con cambio versione.
2024-02-16 08:44:47 +01:00
Dario Sassi 567a7ddba6 EgtExchange :
- in import BTL migliorati FreeContour da due percorsi quando sono superfici torte.
2024-02-05 19:55:36 +01:00
Dario Sassi f8dc7803b5 EgtExchange :
- in gestione BTL irrobustito calcolo del solido.
2024-02-05 12:16:41 +01:00
Dario Sassi d4fb909a0f EgtExchange :
- in import BTLX varie migliorie e correzioni.
2024-02-04 23:53:45 +01:00
Dario Sassi cf05547a38 EgtExchange 2.6b1 :
- in import BTLX abilitato e corretto Planing e corrette LogHouseJoint e RoundArch.
2024-02-04 11:40:00 +01:00
Dario Sassi 926074db57 EgtExchange 2.6a2 :
- in import CNC migliorata gestione di alcuni comandi speciali Siemens.
2024-01-31 10:15:12 +01:00
Dario Sassi 254d4792cf EgtExchange 2.6a1 :
- ricompilazione con cambio versione.
2024-01-16 15:13:12 +01:00
40 changed files with 14860 additions and 10604 deletions
+277 -92
View File
@@ -22,6 +22,7 @@
#include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringEncoder.h" #include "/EgtDev/Include/EgtStringEncoder.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <future>
using namespace std ; using namespace std ;
@@ -70,7 +71,8 @@ BeamMgr::SetFlag( int nFlag)
bool bSpecialTrim = (( nFlag & EIBFLAG_SPECIAL_TRIM) != 0) ; bool bSpecialTrim = (( nFlag & EIBFLAG_SPECIAL_TRIM) != 0) ;
bool bTrimWithOutline = (( nFlag & EIBFLAG_TRIM_WITH_OUTLINE) != 0) ; bool bTrimWithOutline = (( nFlag & EIBFLAG_TRIM_WITH_OUTLINE) != 0) ;
bool bUseUAttr = (( nFlag & EIBFLAG_USEUATTR) != 0) ; bool bUseUAttr = (( nFlag & EIBFLAG_USEUATTR) != 0) ;
if ( ! m_BtlGeom.Init( m_pGDB, nFlatVertPos, bSpecialTrim, bTrimWithOutline, bUseUAttr)) { bool bPartOffset = (( nFlag & EIBFLAG_PARTOFFSET) != 0) ;
if ( ! m_BtlGeom.Init( m_pGDB, nFlatVertPos, bSpecialTrim, bTrimWithOutline, bUseUAttr, bPartOffset, false)) {
LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init") LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init")
return false ; return false ;
} }
@@ -82,7 +84,7 @@ BeamMgr::SetFlag( int nFlag)
int int
BeamMgr::CreatePart( void) BeamMgr::CreatePart( void)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// Aggiorno posizione // Aggiorno posizione
@@ -95,7 +97,7 @@ BeamMgr::CreatePart( void)
bool bool
BeamMgr::SetPart( int nPartId) BeamMgr::SetPart( int nPartId)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Imposto il pezzo come corrente // Imposto il pezzo come corrente
@@ -106,7 +108,7 @@ BeamMgr::SetPart( int nPartId)
bool bool
BeamMgr::ErasePart( void) BeamMgr::ErasePart( void)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Cancello il pezzo corrente // Cancello il pezzo corrente
@@ -117,7 +119,7 @@ BeamMgr::ErasePart( void)
bool bool
BeamMgr::UpdatePart( void) BeamMgr::UpdatePart( void)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Forzo aggiornamento del pezzo corrente // Forzo aggiornamento del pezzo corrente
@@ -128,10 +130,10 @@ BeamMgr::UpdatePart( void)
bool bool
BeamMgr::SetPartProdNbr( int nProdNbr) BeamMgr::SetPartProdNbr( int nProdNbr)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Verifico validità nuovo PDN // Verifico validità nuovo PDN
if ( ! m_BtlGeom.VerifyNewPartProdNbr( nProdNbr)) if ( ! m_BtlGeom.VerifyNewPartProdNbr( nProdNbr))
return false ; return false ;
// Imposto il numero di produzione sul pezzo corrente // Imposto il numero di produzione sul pezzo corrente
@@ -142,7 +144,7 @@ BeamMgr::SetPartProdNbr( int nProdNbr)
bool bool
BeamMgr::SetPartName( const string& sName) BeamMgr::SetPartName( const string& sName)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Imposto il nome sul pezzo corrente // Imposto il nome sul pezzo corrente
@@ -153,7 +155,7 @@ BeamMgr::SetPartName( const string& sName)
bool bool
BeamMgr::SetPartCount( int nCount) BeamMgr::SetPartCount( int nCount)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Imposto il numero delle parti da produrre sul pezzo corrente // Imposto il numero delle parti da produrre sul pezzo corrente
@@ -164,7 +166,7 @@ BeamMgr::SetPartCount( int nCount)
bool bool
BeamMgr::SetPartBox( double dLength, double dHeight, double dWidth, bool bUpdate) BeamMgr::SetPartBox( double dLength, double dHeight, double dWidth, bool bUpdate)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Imposto le dimensioni sul pezzo corrente // Imposto le dimensioni sul pezzo corrente
@@ -185,10 +187,10 @@ BeamMgr::SetPartBox( double dLength, double dHeight, double dWidth, bool bUpdate
bool bool
BeamMgr::GetSideData( int nSide, Frame3d& frRef, double& dLength, double& dWidth, double& dHeight) BeamMgr::GetSideData( int nSide, Frame3d& frRef, double& dLength, double& dWidth, double& dHeight)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Verifico validità identificativo di faccia // Verifico validità identificativo di faccia
if ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_RIGHT) if ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_RIGHT)
return false ; return false ;
// Recupero riferimento del pezzo corrente // Recupero riferimento del pezzo corrente
@@ -210,7 +212,7 @@ BeamMgr::GetSideData( int nSide, Frame3d& frRef, double& dLength, double& dWidth
bool bool
BeamMgr::ShowFacesName( bool bShow) BeamMgr::ShowFacesName( bool bShow)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Verifico esistenza del pezzo corrente // Verifico esistenza del pezzo corrente
@@ -253,7 +255,7 @@ BeamMgr::ShowFacesName( bool bShow)
// porto il testo nel piano della faccia // porto il testo nel piano della faccia
Frame3d frRef = m_BtlGeom.GetSideFrame( nS) ; Frame3d frRef = m_BtlGeom.GetSideFrame( nS) ;
pText->ToGlob( frRef) ; pText->ToGlob( frRef) ;
// recupero eventuale nome già presente // recupero eventuale nome già presente
int nOldTextId = m_pGDB->GetFirstNameInGroup( nFcsNameLayId, sFace) ; int nOldTextId = m_pGDB->GetFirstNameInGroup( nFcsNameLayId, sFace) ;
// se gia presente, lo rimpiazzo // se gia presente, lo rimpiazzo
if ( nOldTextId != GDB_ID_NULL) { if ( nOldTextId != GDB_ID_NULL) {
@@ -293,7 +295,7 @@ BeamMgr::UpdateFacesName( void)
bool bool
BeamMgr::ShowLoadingSide( bool bShow, bool bFromLeft) BeamMgr::ShowLoadingSide( bool bShow, bool bFromLeft)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Verifico esistenza del pezzo corrente // Verifico esistenza del pezzo corrente
@@ -363,7 +365,7 @@ BeamMgr::AddProcess( int nGroup, int nProc, int nSide, const string& sDes, int n
const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt, const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt,
int nCrvId, int nCrv2Id, bool bUpdate) int nCrvId, int nCrv2Id, bool bUpdate)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// Recupero i dati di default della feature // Recupero i dati di default della feature
@@ -415,7 +417,7 @@ BeamMgr::ModifyProcess( int nGeomId, int nGroup, int nProc, int nSide, const str
const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt, const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt,
int nCrvId, int nCrv2Id, bool bUpdate) int nCrvId, int nCrv2Id, bool bUpdate)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return GDB_ID_NULL ; return GDB_ID_NULL ;
// Recupero il pezzo di appartenenza // Recupero il pezzo di appartenenza
@@ -464,7 +466,7 @@ BeamMgr::ModifyProcess( int nGeomId, int nGroup, int nProc, int nSide, const str
bool bool
BeamMgr::EraseProcess( int nGeomId, bool bUpdate) BeamMgr::EraseProcess( int nGeomId, bool bUpdate)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Recupero il pezzo di appartenenza // Recupero il pezzo di appartenenza
@@ -528,7 +530,7 @@ MyEnableProcess( IGeomDB* pGDB, BtlGeom& BtlG, int nGeomId, bool bEnable)
bool bool
BeamMgr::EnableProcess( int nGeomId, bool bEnable, bool bUpdate) BeamMgr::EnableProcess( int nGeomId, bool bEnable, bool bUpdate)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Recupero il pezzo di appartenenza // Recupero il pezzo di appartenenza
@@ -560,6 +562,113 @@ BeamMgr::EnableProcess( int nGeomId, bool bEnable, bool bUpdate)
return true ; return true ;
} }
//----------------------------------------------------------------------------
bool
BeamMgr::CalcAllSolids( bool bShow, bool bRecalc, pcfProcEvents pFun)
{
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Recupero tutti i pezzi
INTVECTOR vPartId ;
int nPartId = m_pGDB->GetFirstGroupInGroup( GDB_ID_ROOT) ;
while ( nPartId != GDB_ID_NULL) {
int nLevel ;
if ( m_pGDB->GetLevel( nPartId, nLevel) && nLevel == GDB_LV_USER &&
m_pGDB->GetFirstNameInGroup( nPartId, BOX_LAYER_NAME) != GDB_ID_NULL) {
vPartId.push_back( nPartId) ;
// nascondo il layer del solido per non avere problemi con le visualizzazioni durante i calcoli in multithread
m_pGDB->SetStatus( m_pGDB->GetFirstNameInGroup( nPartId, SOLID_LAYER_NAME), GDB_ST_OFF) ;
}
nPartId = m_pGDB->GetNextGroup( nPartId) ;
}
// Calcolo i solidi
bool bOk = true ;
constexpr bool MULTITHREAD = true ;
if ( MULTITHREAD) {
int nPartCnt = int( vPartId.size()) ;
int nThreadMax = min( max( 1, int( thread::hardware_concurrency()) - 1), nPartCnt) ;
vector< future<bool>> vRes( nPartCnt) ;
INTVECTOR vInd( nThreadMax) ;
// lancio tutto quanto possibile
for ( int i = 0 ; i < nThreadMax ; ++ i) {
vInd[i] = i ;
vRes[vInd[i]] = async( launch::async, &BeamMgr::CalcSolid, this, vPartId[vInd[i]], bRecalc) ;
}
// attesa completamento e rilancio successivi (occupando sempre lo stesso numero di thread)
int nNext = nThreadMax ;
int nTerminated = 0 ;
while ( nTerminated < nPartCnt) {
for ( int i = 0 ; i < nThreadMax ; ++ i) {
if ( vInd[i] >= 0 && vRes[vInd[i]].valid() && vRes[vInd[i]].wait_for( chrono::microseconds{ 1}) == future_status::ready) {
++ nTerminated ;
if ( ! vRes[vInd[i]].get())
bOk = false ;
ShowSolid( vPartId[vInd[i]], bShow) ;
if ( pFun != nullptr)
pFun( ( 100 * nTerminated) / nPartCnt, -1) ;
if ( nNext < nPartCnt) {
vInd[i] = nNext ;
++ nNext ;
vRes[vInd[i]] = async( launch::async, &BeamMgr::CalcSolid, this, vPartId[vInd[i]], bRecalc) ;
}
else
vInd[i] = -1 ;
}
}
}
}
// non multithread solo per DEBUG
else {
int nPartCnt = int( vPartId.size()) ;
for ( int i = 0 ; i < nPartCnt ; ++ i) {
if ( ! CalcSolid( vPartId[i], bRecalc))
bOk = false ;
ShowSolid( vPartId[i], bShow) ;
if ( pFun != nullptr)
pFun( ( 100 * ( i + 1)) / nPartCnt, -1) ;
}
}
return bOk ;
}
//----------------------------------------------------------------------------
bool
BeamMgr::ShowAllSolids( bool bShow, pcfProcEvents pFun)
{
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Recupero tutti i pezzi
INTVECTOR vPartId ;
int nPartId = m_pGDB->GetFirstGroupInGroup( GDB_ID_ROOT) ;
while ( nPartId != GDB_ID_NULL) {
int nLevel ;
if ( m_pGDB->GetLevel( nPartId, nLevel) && nLevel == GDB_LV_USER &&
m_pGDB->GetFirstNameInGroup( nPartId, BOX_LAYER_NAME) != GDB_ID_NULL)
vPartId.push_back( nPartId) ;
nPartId = m_pGDB->GetNextGroup( nPartId) ;
}
// Aggiorno visualizzazione dei solidi
bool bOk = true ;
int nPartCnt = int( vPartId.size()) ;
for ( int i = 0 ; i < nPartCnt ; ++ i) {
if ( ! ShowSolid( vPartId[i], bShow))
bOk = false ;
if ( pFun != nullptr)
pFun( ( 100 * ( i + 1)) / nPartCnt, -1) ;
}
return bOk ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static ISurfTriMesh* static ISurfTriMesh*
RegularizeTriMesh( const ISurfTriMesh* pStm, double dStep) RegularizeTriMesh( const ISurfTriMesh* pStm, double dStep)
@@ -627,11 +736,51 @@ RegularizeTriMesh( const ISurfTriMesh* pStm, double dStep)
return Release( pStmNew) ; return Release( pStmNew) ;
} }
//----------------------------------------------------------------------------
static bool
IntersectOneFeature( int nProcId, int nTrim, double dStep, IGeomDB* pGDB, ISurfTriMesh* pStm)
{
// recupero eventuale superficie originale
int nProcSurfId = nProcId ;
int nOrigId = 0 ;
if ( pGDB->GetInfo( nProcSurfId, IKEY_ORIGID, nOrigId))
nProcSurfId += nOrigId ;
// se da utilizzare anche superfici ausiliarie
if ( nTrim == 2) {
int nAux ;
if ( pGDB->GetInfo( nProcSurfId, IKEY_AUXID, nAux)) {
const ISurfTriMesh* pStmProc = GetSurfTriMesh( pGDB->GetGeoObj( nProcSurfId)) ;
const ISurfTriMesh* pAux = GetSurfTriMesh( pGDB->GetGeoObj( nProcSurfId + nAux)) ;
if ( pStmProc != nullptr && ! pStmProc->IsEmpty() && pAux != nullptr && ! pAux->IsEmpty()) {
PtrOwner<ISurfTriMesh> pTrim( pAux->Clone()) ;
if ( IsNull( pTrim) || ! pTrim->DoSewing( *pStmProc))
return false ;
PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pTrim, dStep)) ;
const ISurfTriMesh* pStmTool = ( ! IsNull( pStmTmp) ? Get( pStmTmp) : Get( pTrim)) ;
if ( pStmTool == nullptr || ! pStm->Intersect( *pStmTool))
return false ;
}
}
}
// caso standard
else {
const ISurfTriMesh* pStmProc = GetSurfTriMesh( pGDB->GetGeoObj( nProcSurfId)) ;
if ( ! pStmProc->IsEmpty()) {
PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pStmProc, dStep)) ;
if ( ! IsNull( pStmTmp))
pStmProc = Get( pStmTmp) ;
if ( pStmProc == nullptr || ! pStm->Intersect( *pStmProc))
return false ;
}
}
return true ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
BeamMgr::CalcSolid( int nPartId, bool bRecalc) BeamMgr::CalcSolid( int nPartId, bool bRecalc)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Verifico esistenza del pezzo // Verifico esistenza del pezzo
@@ -649,32 +798,34 @@ BeamMgr::CalcSolid( int nPartId, bool bRecalc)
m_pGDB->SetMaterial( nSolLayId, Color(255, 160, 32)) ; m_pGDB->SetMaterial( nSolLayId, Color(255, 160, 32)) ;
} }
int nSolidId = m_pGDB->GetFirstNameInGroup( nSolLayId, SOLID_SOLID_NAME) ; int nSolidId = m_pGDB->GetFirstNameInGroup( nSolLayId, SOLID_SOLID_NAME) ;
const ISurfTriMesh* pOldStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nSolidId)) ; if ( ! m_pGDB->ExistsInfo( nSolidId, IKEY_VALID))
if ( pOldStm == nullptr || pOldStm->GetFacetCount() == 0)
bRecalc = true ; bRecalc = true ;
if ( bRecalc) { const ISurfTriMesh* pOldStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nSolidId)) ;
BBox3d b3Box ; if ( pOldStm == nullptr || pOldStm->IsEmpty())
m_pGDB->GetLocalBBox( nBoxId, b3Box, BBF_STANDARD) ; bRecalc = true ;
Point3d ptMin ; double dDimX, dDimY, dDimz ; // Se non necessario ricalcolo, esco con successo
if ( ! b3Box.GetMinDim( ptMin, dDimX, dDimY, dDimz)) if ( ! bRecalc)
return true ;
// Calcolo il solido senza feature
BBox3d b3Box ;
m_pGDB->GetLocalBBox( nBoxId, b3Box, BBF_STANDARD) ;
Point3d ptMin ; double dDimX, dDimY, dDimZ ;
if ( ! b3Box.GetMinDim( ptMin, dDimX, dDimY, dDimZ))
return false ;
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshBox( dDimX, dDimY, dDimZ, false)) ;
if ( IsNull( pSTM))
return false ;
pSTM->Translate( ptMin - ORIG) ;
if ( nSolidId != GDB_ID_NULL) {
if ( ! m_pGDB->ReplaceGeoObj( nSolidId, Release( pSTM)))
return false ; return false ;
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshBox( dDimX, dDimY, dDimz, false)) ;
if ( IsNull( pSTM))
return false ;
pSTM->Translate( ptMin - ORIG) ;
if ( nSolidId != GDB_ID_NULL) {
if ( ! m_pGDB->ReplaceGeoObj( nSolidId, Release( pSTM)))
return false ;
}
else {
nSolidId = m_pGDB->AddGeoObj( GDB_ID_NULL, nSolLayId, Release( pSTM)) ;
if ( nSolidId == GDB_ID_NULL)
return false ;
m_pGDB->SetName( nSolidId, SOLID_SOLID_NAME) ;
}
} }
else { else {
return true ; nSolidId = m_pGDB->AddGeoObj( GDB_ID_NULL, nSolLayId, Release( pSTM)) ;
if ( nSolidId == GDB_ID_NULL)
return false ;
m_pGDB->SetName( nSolidId, SOLID_SOLID_NAME) ;
} }
BBox3d b3Solid ; BBox3d b3Solid ;
m_pGDB->GetLocalBBox( nSolidId, b3Solid, BBF_STANDARD) ; m_pGDB->GetLocalBBox( nSolidId, b3Solid, BBF_STANDARD) ;
@@ -693,17 +844,21 @@ BeamMgr::CalcSolid( int nPartId, bool bRecalc)
int nDO = 1 ; int nDO = 1 ;
m_pGDB->GetInfo( nOutId, IKEY_DO, nDO) ; m_pGDB->GetInfo( nOutId, IKEY_DO, nDO) ;
if ( nDO != 0 && m_pGDB->GetGeoType( nOutId) == SRF_TRIMESH) { if ( nDO != 0 && m_pGDB->GetGeoType( nOutId) == SRF_TRIMESH) {
// sempre standard
const ISurfTriMesh* pStmOut = GetSurfTriMesh( m_pGDB->GetGeoObj( nOutId)) ; const ISurfTriMesh* pStmOut = GetSurfTriMesh( m_pGDB->GetGeoObj( nOutId)) ;
PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pStmOut, dStep)) ; if ( ! pStmOut->IsEmpty()) {
if ( ! IsNull( pStmTmp)) PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pStmOut, dStep)) ;
pStmOut = Get( pStmTmp) ; if ( ! IsNull( pStmTmp))
if ( pStmOut == nullptr || ! pStm->Intersect( *pStmOut)) pStmOut = Get( pStmTmp) ;
return false ; if ( pStmOut == nullptr || ! pStm->Intersect( *pStmOut))
return false ;
}
} }
nOutId = m_pGDB->GetNext( nOutId) ; nOutId = m_pGDB->GetNext( nOutId) ;
} }
// ciclo sulle features // ciclo su feature troncanti (taglio di testa,..)
int nProcLayId = m_pGDB->GetFirstNameInGroup( nPartId, PROCESSINGS_LAYER_NAME) ; int nProcLayId = m_pGDB->GetFirstNameInGroup( nPartId, PROCESSINGS_LAYER_NAME) ;
INTVECTOR vUsedFea ;
int nProcId = m_pGDB->GetFirstInGroup( nProcLayId) ; int nProcId = m_pGDB->GetFirstInGroup( nProcLayId) ;
while ( nProcId != GDB_ID_NULL) { while ( nProcId != GDB_ID_NULL) {
int nDO = 1 ; int nDO = 1 ;
@@ -711,41 +866,36 @@ BeamMgr::CalcSolid( int nPartId, bool bRecalc)
m_pGDB->GetInfo( nProcId, IKEY_DO, nDO) ; m_pGDB->GetInfo( nProcId, IKEY_DO, nDO) ;
m_pGDB->GetInfo( nProcId, IKEY_TRIM, nTrim) ; m_pGDB->GetInfo( nProcId, IKEY_TRIM, nTrim) ;
if ( nDO != 0 && nTrim != 0 && m_pGDB->GetGeoType( nProcId) == SRF_TRIMESH) { if ( nDO != 0 && nTrim != 0 && m_pGDB->GetGeoType( nProcId) == SRF_TRIMESH) {
// recupero eventuale superficie originale int nGroup = 0 ;
int nProcSurfId = nProcId ; int nProc = 0 ;
int nOrigId = 0 ; m_pGDB->GetInfo( nProcId, IKEY_GROUP, nGroup) ;
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_ORIGID, nOrigId)) m_pGDB->GetInfo( nProcId, IKEY_PROC, nProc) ;
nProcSurfId += nOrigId ; if ( IS_CUT( nGroup, nProc) || IS_DOUBLE_CUT( nGroup, nProc) ||
// se da utilizzare anche suerfici ausiliarie IS_TENON( nGroup, nProc) || IS_DOVETAIL_TENON( nGroup, nProc)) {
if ( nTrim == 2) { if ( ! IntersectOneFeature( nProcId, nTrim, dStep, m_pGDB, pStm))
int nAux ;
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_AUXID, nAux)) {
const ISurfTriMesh* pStmProc = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId)) ;
const ISurfTriMesh* pAux = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId + nAux)) ;
if ( pStmProc != nullptr && pAux != nullptr) {
PtrOwner<ISurfTriMesh> pTrim ;
pTrim.Set( pAux->Clone()) ;
if ( IsNull( pTrim) || ! pTrim->DoSewing( *pStmProc))
return false ;
PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pTrim, dStep)) ;
const ISurfTriMesh* pStmTool = ( ! IsNull( pStmTmp) ? Get( pStmTmp) : Get( pTrim)) ;
if ( pStmTool == nullptr || ! pStm->Intersect( *pStmTool))
return false ;
}
}
}
// caso standard
else {
const ISurfTriMesh* pStmProc = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId)) ;
PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pStmProc, dStep)) ;
if ( ! IsNull( pStmTmp))
pStmProc = Get( pStmTmp) ;
if ( pStmProc == nullptr || ! pStm->Intersect( *pStmProc))
return false ; return false ;
vUsedFea.push_back( nProcId) ;
} }
} }
nProcId = m_pGDB->GetNext( nProcId) ; nProcId = m_pGDB->GetNext( nProcId) ;
} }
// ciclo sulle altre features
nProcId = m_pGDB->GetFirstInGroup( nProcLayId) ;
while ( nProcId != GDB_ID_NULL) {
int nDO = 1 ;
int nTrim = 1 ;
m_pGDB->GetInfo( nProcId, IKEY_DO, nDO) ;
m_pGDB->GetInfo( nProcId, IKEY_TRIM, nTrim) ;
if ( find( vUsedFea.begin(), vUsedFea.end(), nProcId) == vUsedFea.end() &&
nDO != 0 && nTrim != 0 && m_pGDB->GetGeoType( nProcId) == SRF_TRIMESH) {
if ( ! IntersectOneFeature( nProcId, nTrim, dStep, m_pGDB, pStm))
return false ;
}
nProcId = m_pGDB->GetNext( nProcId) ;
}
// imposto visualizzazione spigoli
pStm->SetShowEdges( true) ;
// dichiaro calcolato il solido
m_pGDB->SetInfo( nSolidId, IKEY_VALID, 1) ; m_pGDB->SetInfo( nSolidId, IKEY_VALID, 1) ;
return true ; return true ;
@@ -755,7 +905,7 @@ BeamMgr::CalcSolid( int nPartId, bool bRecalc)
int int
BeamMgr::GetSolid( int nPartId) const BeamMgr::GetSolid( int nPartId) const
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Recupero layer del solido e Id del solido // Recupero layer del solido e Id del solido
@@ -768,7 +918,7 @@ BeamMgr::GetSolid( int nPartId) const
bool bool
BeamMgr::ShowSolid( int nPartId, bool bShow) BeamMgr::ShowSolid( int nPartId, bool bShow)
{ {
// Verifico validità GDB // Verifico validità GDB
if ( m_pGDB == nullptr) if ( m_pGDB == nullptr)
return false ; return false ;
// Verifico esistenza del pezzo // Verifico esistenza del pezzo
@@ -790,30 +940,54 @@ BeamMgr::ShowSolid( int nPartId, bool bShow)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
BeamMgr::GetBuildingIsOn( void) const BeamMgr::GetBuildingIsOn( int nAssGrpId) const
{ {
// verifico esistenza gruppo di assemblaggio // Verifico validità GDB
int nAssGrpId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ; if ( m_pGDB == nullptr)
if ( nAssGrpId == GDB_ID_NULL)
return false ; return false ;
// se gruppo di assemblaggio indicato lo verifico
if ( nAssGrpId != GDB_ID_NULL) {
string sAssName ;
if ( ! m_pGDB->GetName( nAssGrpId, sAssName) || sAssName != ASSEMBLY_GROUP_NAME)
return false ;
}
// altrimenti cerco il primo gruppo di assemblaggio
else {
nAssGrpId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ;
if ( nAssGrpId == GDB_ID_NULL)
return false ;
}
// recupero il primo oggetto nel gruppo // recupero il primo oggetto nel gruppo
int nAssId = m_pGDB->GetFirstInGroup( nAssGrpId) ; int nAssId = m_pGDB->GetFirstInGroup( nAssGrpId) ;
if ( nAssId == GDB_ID_NULL) if ( nAssId == GDB_ID_NULL)
return false ; return false ;
// se contiene oggetti, assemblaggio è On // se contiene oggetti, assemblaggio è On
return ( m_pGDB->GetGroupObjs( nAssId) > 0) ; return ( m_pGDB->GetGroupObjs( nAssId) > 0) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
BeamMgr::ShowBuilding( bool bShow) BeamMgr::ShowBuilding( int nAssGrpId, bool bShow)
{ {
// verifico esistenza gruppo di assemblaggio // Verifico validità GDB
int nAssGrpId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ; if ( m_pGDB == nullptr)
if ( nAssGrpId == GDB_ID_NULL)
return false ; return false ;
// se gruppo di assemblaggio indicato lo verifico
if ( nAssGrpId != GDB_ID_NULL) {
string sAssName ;
if ( ! m_pGDB->GetName( nAssGrpId, sAssName) || sAssName != ASSEMBLY_GROUP_NAME)
return false ;
}
// altrimenti cerco il primo gruppo di assemblaggio
else {
nAssGrpId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ;
if ( nAssGrpId == GDB_ID_NULL)
return false ;
}
// ciclo sul gruppo di assemblaggio // ciclo sul gruppo di assemblaggio
int nAssId = m_pGDB->GetFirstInGroup( nAssGrpId) ; int nAssId = m_pGDB->GetFirstInGroup( nAssGrpId) ;
while ( nAssId != GDB_ID_NULL) { while ( nAssId != GDB_ID_NULL) {
@@ -826,7 +1000,7 @@ BeamMgr::ShowBuilding( bool bShow)
if ( m_pGDB->GetInfo( nAssId, GDB_SI_SOURCE, nSouId)) { if ( m_pGDB->GetInfo( nAssId, GDB_SI_SOURCE, nSouId)) {
m_pGDB->SetMode( nSouId, GDB_MD_STD) ; m_pGDB->SetMode( nSouId, GDB_MD_STD) ;
m_pGDB->SetStatus( nSouId, GDB_ST_ON) ; m_pGDB->SetStatus( nSouId, GDB_ST_ON) ;
// se già utilizzato, ne faccio una copia // se già utilizzato, ne faccio una copia
if ( m_pGDB->GetParentId( nSouId) != GDB_ID_ROOT) { if ( m_pGDB->GetParentId( nSouId) != GDB_ID_ROOT) {
int nCopyId = m_pGDB->Copy( nSouId, GDB_ID_NULL, GDB_ID_ROOT) ; int nCopyId = m_pGDB->Copy( nSouId, GDB_ID_NULL, GDB_ID_ROOT) ;
if ( nCopyId != GDB_ID_NULL) { if ( nCopyId != GDB_ID_NULL) {
@@ -837,7 +1011,7 @@ BeamMgr::ShowBuilding( bool bShow)
m_pGDB->SetInfo( nAssId, GDB_SI_SOURCE, nSouId) ; m_pGDB->SetInfo( nAssId, GDB_SI_SOURCE, nSouId) ;
} }
} }
m_pGDB->SetStatus( m_pGDB->GetFirstNameInGroup( nSouId, BOX_LAYER_NAME), GDB_ST_OFF) ; m_pGDB->SetMode( m_pGDB->GetFirstNameInGroup( nSouId, BOX_LAYER_NAME), GDB_MD_HIDDEN) ;
m_pGDB->GroupSwap( nSouId, nAssId, true, true) ; m_pGDB->GroupSwap( nSouId, nAssId, true, true) ;
} }
} }
@@ -852,12 +1026,23 @@ BeamMgr::ShowBuilding( bool bShow)
m_pGDB->SetInfo( nBaseId, GDB_SI_SOURCE, nCopyId) ; m_pGDB->SetInfo( nBaseId, GDB_SI_SOURCE, nCopyId) ;
} }
else { else {
m_pGDB->SetStatus( m_pGDB->GetFirstNameInGroup( nAssId, BOX_LAYER_NAME), GDB_ST_ON) ; m_pGDB->SetMode( m_pGDB->GetFirstNameInGroup( nAssId, BOX_LAYER_NAME), GDB_MD_STD) ;
} }
} }
} }
// passo al successivo // passo al successivo
nAssId = nNextId ; nAssId = nNextId ;
} }
// Nascondo o visualizzo tutti i pezzi sotto la radice
int nPartId = m_pGDB->GetFirstInGroup( GDB_ID_ROOT) ;
while ( nPartId != GDB_ID_NULL) {
int nLevel ;
if ( m_pGDB->GetLevel( nPartId, nLevel) && nLevel == GDB_LV_USER &&
m_pGDB->GetFirstNameInGroup( nPartId, BOX_LAYER_NAME) != GDB_ID_NULL)
m_pGDB->SetStatus( nPartId, ( bShow ? GDB_ST_OFF : GDB_ST_ON)) ;
nPartId = m_pGDB->GetNext( nPartId) ;
}
return true ; return true ;
} }
+4 -2
View File
@@ -41,11 +41,13 @@ class BeamMgr : public IBeamMgr
int nCrvId, int nCrv2Id, bool bUpdate = true) override ; int nCrvId, int nCrv2Id, bool bUpdate = true) override ;
bool EraseProcess( int nGeomId, bool bUpdate = true) override ; bool EraseProcess( int nGeomId, bool bUpdate = true) override ;
bool EnableProcess( int nGeomId, bool bEnable, bool bUpdate = true) override ; bool EnableProcess( int nGeomId, bool bEnable, bool bUpdate = true) override ;
bool CalcAllSolids( bool bShow, bool bRecalc, pcfProcEvents pFun = nullptr) override ;
bool ShowAllSolids( bool bShow, pcfProcEvents pFun = nullptr) override ;
bool CalcSolid( int nPartId, bool bRecalc = false) override ; bool CalcSolid( int nPartId, bool bRecalc = false) override ;
int GetSolid( int nPartId) const override ; int GetSolid( int nPartId) const override ;
bool ShowSolid( int nPartId, bool bShow) override ; bool ShowSolid( int nPartId, bool bShow) override ;
bool GetBuildingIsOn( void) const override ; bool GetBuildingIsOn( int nAssGrpId) const override ;
bool ShowBuilding( bool bShow) override ; bool ShowBuilding( int nAssGrpId, bool bShow) override ;
public : public :
BeamMgr( void) ; BeamMgr( void) ;
+104 -7
View File
@@ -22,6 +22,7 @@
#include "/EgtDev/Include/EGkStmStandard.h" #include "/EgtDev/Include/EGkStmStandard.h"
#include "/EgtDev/Include/EGkStmFromCurves.h" #include "/EgtDev/Include/EGkStmFromCurves.h"
#include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <unordered_map> #include <unordered_map>
@@ -30,6 +31,8 @@ using namespace std ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
string BtlGeom::m_sBtlAuxDir ; string BtlGeom::m_sBtlAuxDir ;
string BtlGeom::m_sBtlLuaLibsDir ;
string BtlGeom::m_sBtlLuaLastRequire ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
BtlGeom::BtlGeom( void) BtlGeom::BtlGeom( void)
@@ -39,7 +42,9 @@ BtlGeom::BtlGeom( void)
m_bSpecialTrim = false ; m_bSpecialTrim = false ;
m_bTrimWithOutline = false ; m_bTrimWithOutline = false ;
m_bUseUAttr = false ; m_bUseUAttr = false ;
m_bPartOffset = false ;
m_BoxCol = Color( 255, 128, 0, 15) ; m_BoxCol = Color( 255, 128, 0, 15) ;
m_OffsCol = Color( 255, 0, 0, 15) ;
m_OutsCol = Color( 224, 128, 0, 50) ; m_OutsCol = Color( 224, 128, 0, 50) ;
m_ProcsCol = Color( 80, 160, 160, 100) ; m_ProcsCol = Color( 80, 160, 160, 100) ;
m_ProcsOffCol = Color( 160, 160, 160, 30) ; m_ProcsOffCol = Color( 160, 160, 160, 30) ;
@@ -58,11 +63,24 @@ BtlGeom::BtlGeom( void)
m_nSolidsId = GDB_ID_NULL ; m_nSolidsId = GDB_ID_NULL ;
m_vtDim = V_NULL ; m_vtDim = V_NULL ;
m_nCount = 0 ; m_nCount = 0 ;
m_nProcId = GDB_ID_NULL ;
m_nBtlLine = 0 ;
}
//----------------------------------------------------------------------------
BtlGeom::~BtlGeom( void)
{
// chiudo lua ( se era aperto)
if ( m_LuaMgr.Exit()) {
string sLua = "Lua BtlGeom interpreter closed" ;
LOG_INFO( GetEExLogger(), sLua.data())
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bTrimWithOutline, bool bUseUAttr) BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim,
bool bTrimWithOutline, bool bUseUAttr, bool bPartOffset, bool bIsAdding)
{ {
// salvo puntatore a DB geometrico // salvo puntatore a DB geometrico
m_pGDB = pGDB ; m_pGDB = pGDB ;
@@ -73,17 +91,35 @@ BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bTrimWit
m_bSpecialTrim = bSpecialTrim ; m_bSpecialTrim = bSpecialTrim ;
m_bTrimWithOutline = bTrimWithOutline ; m_bTrimWithOutline = bTrimWithOutline ;
m_bUseUAttr = bUseUAttr ; m_bUseUAttr = bUseUAttr ;
// se non esiste, creo gruppo per informazioni varie m_bPartOffset = bPartOffset ;
m_nInfoId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, INFO_GROUP_NAME) ; // gruppo per informazioni varie, se in aggiunta lo creo sempre
if ( m_nInfoId == GDB_ID_NULL && ! CreateInfoGroup()) m_nInfoId = ( bIsAdding ? GDB_ID_NULL : m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, INFO_GROUP_NAME)) ;
if ( bIsAdding && ! CreateInfoGroup())
return false ; return false ;
// se non esiste, creo gruppo per assemblaggio // gruppo per assemblaggio, se in aggiunta lo creo sempre
m_nAsseId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ; m_nAsseId = ( bIsAdding ? GDB_ID_NULL : m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME)) ;
if ( m_nAsseId == GDB_ID_NULL && ! CreateAssemblyGroup()) if ( bIsAdding && ! CreateAssemblyGroup())
return false ; return false ;
// recupero eventuali riferimenti a gruppi per grezzi e compositi // recupero eventuali riferimenti a gruppi per grezzi e compositi
m_nRawPartsId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, RAWPARTS_GROUP_NAME) ; m_nRawPartsId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, RAWPARTS_GROUP_NAME) ;
m_nCompositesId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, COMPOSITES_GROUP_NAME) ; m_nCompositesId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, COMPOSITES_GROUP_NAME) ;
// inizializzo interprete lua
if ( ! m_LuaMgr.Init())
return false ;
// carico le funzioni speciali
if ( ! LuaInstallEgtFunctions( m_LuaMgr))
return false ;
// recupero la versione di Lua
string sLua ;
if ( m_LuaMgr.GetVersion( sLua))
sLua += " BtlGeom interpreter started" ;
else
sLua = "Lua *.* BtlGeom interpreter started" ;
LOG_INFO( GetEExLogger(), sLua.data())
// imposto il direttorio delle librerie
m_LuaMgr.SetLuaLibsDir( m_sBtlLuaLibsDir) ;
// carico la libreria standard
m_LuaMgr.Require( m_sBtlLuaLastRequire) ;
return true ; return true ;
} }
@@ -595,6 +631,67 @@ BtlGeom::AddObjectRef( const string& sUID, const Frame3d& frRef)
return true ; return true ;
} }
//----------------------------------------------------------------------------
bool
BtlGeom::AddPartOffset( const DBLVECTOR& vdPar)
{
// se non c'è il DB geometrico o il pezzo corrente, errore
if ( m_pGDB == nullptr || m_nPartId == GDB_ID_NULL)
return false ;
// recupero le dimensioni del pezzo corrente
if ( m_vtDim.IsSmall())
return false ;
// se non abilitato, esco
if ( ! m_bPartOffset)
return true ;
// aggiusto i solidi di rappresentazione dell'offset
for ( int i = 1 ; i <= 4 ; ++ i) {
string sOffsName = BOX_OFFSX_NAME + ToString( i) ;
int nOffsId = m_pGDB->GetFirstNameInGroup( m_nBoxId, sOffsName) ;
// se valore offset significativo, modifico o aggiungo nuovo solido
if ( vdPar[i] > EPS_SMALL) {
double dDimX = m_vtDim.x ;
double dDimY = (( i == 1 || i == 3) ? vdPar[i] : m_vtDim.y) ;
double dDimZ = (( i == 1 || i == 3) ? m_vtDim.z : vdPar[i]) ;
// creo il solido (parallelepipedo)
PtrOwner<ISurfTriMesh> pStm( GetSurfTriMeshBox( dDimX, dDimY, dDimZ)) ;
if ( IsNull( pStm))
return false ;
// lo traslo opportunamente
Vector3d vtMove ;
if ( i == 1)
vtMove = Vector3d( 0, -vdPar[i], 0) ;
else if ( i == 2)
vtMove = Vector3d( 0, 0, -vdPar[i]) ;
else if ( i == 3)
vtMove = Vector3d( 0, m_vtDim.y, 0) ;
else
vtMove = Vector3d( 0, 0, m_vtDim.z) ;
pStm->Translate( vtMove) ;
// se gia presente, lo rimpiazzo
if ( nOffsId != GDB_ID_NULL) {
if ( ! m_pGDB->ReplaceGeoObj( nOffsId, Release( pStm)))
return false ;
}
// altrimenti, lo inserisco nel layer box del pezzo
else {
nOffsId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nBoxId, Release( pStm)) ;
if ( nOffsId == GDB_ID_NULL)
return false ;
// assegno nome
m_pGDB->SetName( nOffsId, sOffsName) ;
}
// assegno il colore
m_pGDB->SetMaterial( nOffsId, m_OffsCol) ;
}
// elimino eventuale vecchio solido
else {
m_pGDB->Erase( nOffsId) ;
}
}
return true ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
BtlGeom::ResetPartSolid( void) BtlGeom::ResetPartSolid( void)
+18 -5
View File
@@ -18,15 +18,16 @@
#include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkPolygon3d.h" #include "/EgtDev/Include/EGkPolygon3d.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGnLuaMgr.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class BtlGeom class BtlGeom
{ {
public : public :
BtlGeom( void) ; BtlGeom( void) ;
~BtlGeom( void) ;
public : bool Init( IGeomDB* pGDB, int nFlatPos, bool bSpecialTrim,
bool Init( IGeomDB* pGDB, int nFlatPos, bool bSpecialTrim, bool bTrimWithOutline, bool bUseUAttr) ; bool bTrimWithOutline, bool bUseUAttr, bool bPartOffset, bool bIsAdding) ;
bool CreatePart( void) ; bool CreatePart( void) ;
bool SetPart( int nPartId) ; bool SetPart( int nPartId) ;
bool ErasePart( void) ; bool ErasePart( void) ;
@@ -49,6 +50,7 @@ class BtlGeom
{ return ( m_nPartId != GDB_ID_NULL ? m_vtDim.z : 0) ;} { return ( m_nPartId != GDB_ID_NULL ? m_vtDim.z : 0) ;}
bool AddPartTransformation( const std::string& sUID, const Frame3d& frRef) ; bool AddPartTransformation( const std::string& sUID, const Frame3d& frRef) ;
bool AddObjectRef( const std::string& sUID, const Frame3d& frRef) ; bool AddObjectRef( const std::string& sUID, const Frame3d& frRef) ;
bool AddPartOffset( const DBLVECTOR& vdPar) ;
bool AdjustPartFlatOrVertPos( void) ; bool AdjustPartFlatOrVertPos( void) ;
bool ResetPartSolid( void) ; bool ResetPartSolid( void) ;
std::string GetPartName( void) ; std::string GetPartName( void) ;
@@ -210,6 +212,8 @@ class BtlGeom
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ; const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddRoundArch( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, bool AddRoundArch( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ; const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddSphere( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddTriangleCut( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, bool AddTriangleCut( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ; const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddTyroleanDovetail( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, bool AddTyroleanDovetail( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
@@ -220,6 +224,10 @@ class BtlGeom
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ; const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddVariant( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, bool AddVariant( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ; const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddVariantLua( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt, const std::string& sLuaPath) ;
bool AddVariantNge( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt, const std::string& sNgePath) ;
ICurveComposite* GetFreeContourCurve( int nProcId, const Frame3d& frRef, bool bOnlyStartOk = false) ; ICurveComposite* GetFreeContourCurve( int nProcId, const Frame3d& frRef, bool bOnlyStartOk = false) ;
ISurfTriMesh* CreateOneCurveFreeContour( const ICurveComposite* pCrvCompo) ; ISurfTriMesh* CreateOneCurveFreeContour( const ICurveComposite* pCrvCompo) ;
bool AdjustFreeContourCurve( ICurve* pCrv, int nSide, bool& bClosed, bool& bEndsOnOrOutCont) ; bool AdjustFreeContourCurve( ICurve* pCrv, int nSide, bool& bClosed, bool& bEndsOnOrOutCont) ;
@@ -227,7 +235,7 @@ class BtlGeom
bool GetFreeContourCurveSideAngles( const ICurveComposite* pCrvCompo, DBLVECTOR& vSideAng) ; bool GetFreeContourCurveSideAngles( const ICurveComposite* pCrvCompo, DBLVECTOR& vSideAng) ;
bool CreatePolygonInBox( const Point3d& ptP, const Vector3d& vtN, int nSide, Polygon3d& Polyg, bool CreatePolygonInBox( const Point3d& ptP, const Vector3d& vtN, int nSide, Polygon3d& Polyg,
double dMatMin = FACE_MIN_BACK_MAT, double dAreaMin = FACE_MIN_BACK_AREA) ; double dMatMin = FACE_MIN_BACK_MAT, double dAreaMin = FACE_MIN_BACK_AREA) ;
double GetPlaneElevation( const Plane3d& plPlane) ; double GetDistanceBeamPlane( const Plane3d& plPlane) ;
bool TrimPolygons( Polygon3d& plyP1, Polygon3d& plyP2, bool bInVsOut, bool bOnEq) ; bool TrimPolygons( Polygon3d& plyP1, Polygon3d& plyP2, bool bInVsOut, bool bOnEq) ;
bool VerifyPolygonSize( Polygon3d& plyP, double dMinDim = FACE_MIN_CROSS_DIM) ; bool VerifyPolygonSize( Polygon3d& plyP, double dMinDim = FACE_MIN_CROSS_DIM) ;
bool VerifyPolygonBackMat( Polygon3d& plyP, double dMatMin = FACE_MIN_BACK_MAT, double dAreaMin = FACE_MIN_BACK_AREA) ; bool VerifyPolygonBackMat( Polygon3d& plyP, double dMatMin = FACE_MIN_BACK_MAT, double dAreaMin = FACE_MIN_BACK_AREA) ;
@@ -262,11 +270,14 @@ class BtlGeom
private : private :
IGeomDB* m_pGDB ; IGeomDB* m_pGDB ;
LuaMgr m_LuaMgr ; // interprete per Variant parametrici
int m_nFlatVertPos ; // flag per posizionamento pezzi (0=come sono, 1=di piatto, 2=in verticale, 3=ruotato 90deg, 4=da outline o piatto) int m_nFlatVertPos ; // flag per posizionamento pezzi (0=come sono, 1=di piatto, 2=in verticale, 3=ruotato 90deg, 4=da outline o piatto)
bool m_bSpecialTrim ; // flag per trim speciale regioni per pareti (solo con feature passanti) bool m_bSpecialTrim ; // flag per trim speciale regioni per pareti (solo con feature passanti)
bool m_bTrimWithOutline ; // flag per trim delle feature con l'outline (se presente) bool m_bTrimWithOutline ; // flag per trim delle feature con l'outline (se presente)
bool m_bUseUAttr ; // flag per utilizzo attributi utente per modificare geometria features bool m_bUseUAttr ; // flag per utilizzo attributi utente per modificare geometria features
bool m_bPartOffset ; // flag per gestione geometrica di PARTOFFSET
Color m_BoxCol ; // colore per box pezzi Color m_BoxCol ; // colore per box pezzi
Color m_OffsCol ; // colore per offset pezzi
Color m_OutsCol ; // colore per outline pezzi Color m_OutsCol ; // colore per outline pezzi
Color m_ProcsCol ; // colore per lavorazioni pezzi Color m_ProcsCol ; // colore per lavorazioni pezzi
Color m_ProcsOffCol ; // colore per lavorazioni pezzi disabilitate Color m_ProcsOffCol ; // colore per lavorazioni pezzi disabilitate
@@ -291,5 +302,7 @@ class BtlGeom
FCEDEQUE m_FcData ; // dati per contorni liberi in definizione FCEDEQUE m_FcData ; // dati per contorni liberi in definizione
public : public :
static std::string m_sBtlAuxDir ; // direttorio in cui cercare i dati per le feature Variant static std::string m_sBtlAuxDir ; // direttorio in cui cercare i dati per le feature Variant
static std::string m_sBtlLuaLibsDir ; // direttorio librerie lua per Variant
static std::string m_sBtlLuaLastRequire ; // ultimo require lua per Variant
} ; } ;
+59 -1
View File
@@ -17,6 +17,56 @@
#include "/EgtDev/Include/EgtStringBase.h" #include "/EgtDev/Include/EgtStringBase.h"
#include <deque> #include <deque>
//----------------------------------------------------------------------------
// Riconoscimento feature
#define IS_CUT( nG, nP) ( ( nG == 1 || nG == 2) && nP == 10)
#define IS_LONGIT_CUT( nG, nP) ( ( nG == 0 || nG == 3 || nG == 4) && nP == 10)
#define IS_DOUBLE_CUT( nG, nP) ( ( nG == 1 || nG == 2) && nP == 11)
#define IS_RIDGEVALLEY_CUT( nG, nP) ( ( nG == 0) && nP == 12)
#define IS_SAW_CUT( nG, nP) ( ( nG == 0 || nG == 3 || nG == 4) && nP == 13)
#define IS_SLOT( nG, nP) ( ( nG == 3 || nG == 4) && nP == 16)
#define IS_FRONT_SLOT( nG, nP) ( ( nG == 3 || nG == 4) && nP == 17)
#define IS_BIRDS_MOUTH( nG, nP) ( ( nG == 3 || nG == 4) && nP == 20)
#define IS_RAFTER_NOTCH( nG, nP) ( ( nG == 3 || nG == 4) && nP == 25)
#define IS_RIDGE_LAP( nG, nP) ( ( nG == 1 || nG == 2) && nP == 30)
#define IS_LAP_JOINT( nG, nP) ( ( nG == 3 || nG == 4) && nP == 30)
#define IS_NOTCH( nG, nP) ( ( nG == 3 || nG == 4) && nP == 32)
#define IS_LOGHOUSE_HL2( nG, nP) ( ( nG == 3 || nG == 4) && nP == 33)
#define IS_SEATHING_CUT( nG, nP) ( ( nG == 3 || nG == 4) && nP == 34)
#define IS_FRENCH_RIDGELAP( nG, nP) ( ( nG == 1 || nG == 2) && nP == 35)
#define IS_CHAMFER( nG, nP) ( ( nG == 3 || nG == 4) && nP == 36)
#define IS_LOGHOUSE_HL4( nG, nP) ( ( nG == 4) && nP == 37)
#define IS_LOGHOUSE_FRONT( nG, nP) ( ( nG == 3 || nG == 4) && nP == 38)
#define IS_POCKET( nG, nP) ( ( nG == 4) && nP == 39)
#define IS_DRILL( nG, nP) ( ( nG == 3 || nG == 4) && nP == 40)
#define IS_TENON( nG, nP) ( ( nG == 1 || nG == 2) && nP == 50)
#define IS_MORTISE( nG, nP) ( ( nG == 3 || nG == 4) && nP == 50)
#define IS_MORTISE_FRONT( nG, nP) ( ( nG == 3 || nG == 4) && nP == 51)
#define IS_HOUSE( nG, nP) ( ( nG == 1 || nG == 2 || nG == 3 || nG == 4) && nP == 52)
#define IS_HOUSE_MORTISE( nG, nP) ( ( nG == 3 || nG == 4) && nP == 53)
#define IS_DOVETAIL_TENON( nG, nP) ( ( nG == 1 || nG == 2) && nP == 55)
#define IS_DOVETAIL_MORTISE( nG, nP) ( ( nG == 3 || nG == 4) && nP == 55)
#define IS_DTMORTISE_FRONT( nG, nP) ( ( nG == 3 || nG == 4) && nP == 56)
#define IS_MARKING( nG, nP) ( ( nG == 3 || nG == 4) && nP == 60)
#define IS_TEXT( nG, nP) ( ( nG == 4) && nP == 61)
#define IS_SIMPLESCARF( nG, nP) ( ( nG == 1 || nG == 2) && nP == 70)
#define IS_SCARFJOINT( nG, nP) ( ( nG == 1 || nG == 2) && nP == 71)
#define IS_STEPJOINT( nG, nP) ( ( nG == 1 || nG == 2) && nP == 80)
#define IS_STEPJOINTNOTCH( nG, nP) ( ( nG == 3 || nG == 4) && nP == 80)
#define IS_PLANING( nG, nP) ( ( nG == 3 || nG == 4) && nP == 90)
#define IS_PROF_FRONT( nG, nP) ( ( nG == 3 || nG == 4) && nP == 100)
#define IS_PROF_HEADCONCAVE( nG, nP) ( ( nG == 3 || nG == 4) && nP == 101)
#define IS_PROF_HEADCONVEX( nG, nP) ( ( nG == 3 || nG == 4) && nP == 102)
#define IS_PROF_HEADCAMBERED( nG, nP) ( ( nG == 3 || nG == 4) && nP == 103)
#define IS_PROF_HEAD( nG, nP) ( ( nG == 3 || nG == 4) && nP == 106)
#define IS_ROUND_ARCH( nG, nP) ( ( nG == 4) && nP == 104)
#define IS_SPHERE( nG, nP) ( ( nG == 3 || nG == 4) && nP == 107)
#define IS_TRIANGLE_CUT( nG, nP) ( ( nG == 4) && nP == 120)
#define IS_TYROLEAN_DOVETAIL( nG, nP) ( ( nG == 1 || nG == 2 || nG == 3 || nG == 4) && nP == 136)
#define IS_DOVETAIL( nG, nP) ( ( nG == 1 || nG == 2 || nG == 3 || nG == 4) && nP == 138)
#define IS_FREE_CONTOUR( nG, nP) ( ( nG == 0 || nG == 3 || nG == 4) && (nP == 250 || nP == 251 || nP == 252))
#define IS_VARIANT( nG, nP) ( ( nG == 0 || nG == 1 || nG == 2 || nG == 3 || nG == 4) && nP == 900)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// nome gruppo di sistema per informazioni varie // nome gruppo di sistema per informazioni varie
static const std::string INFO_GROUP_NAME = "BtlInfo" ; static const std::string INFO_GROUP_NAME = "BtlInfo" ;
@@ -38,6 +88,7 @@ static const std::string FCSNAME_LAYER_NAME = "FcsName" ;
// nomi entità standard dei pezzi // nomi entità standard dei pezzi
static const std::string AUX_PART_NAME = "Name" ; static const std::string AUX_PART_NAME = "Name" ;
static const std::string BOX_BOX_NAME = "Box" ; static const std::string BOX_BOX_NAME = "Box" ;
static const std::string BOX_OFFSX_NAME = "Offs" ;
static const std::string OL_OUTSTM_NAME = "Out" ; static const std::string OL_OUTSTM_NAME = "Out" ;
static const std::string OL_APERTURESTM_NAME = "Ape" ; static const std::string OL_APERTURESTM_NAME = "Ape" ;
static const std::string OL_TOPREGION_NAME = "Top" ; static const std::string OL_TOPREGION_NAME = "Top" ;
@@ -102,6 +153,8 @@ const double FACE_MIN_BACK_MAT = 2.0 ;
const double FACE_MIN_BACK_AREA = 400.0 ; const double FACE_MIN_BACK_AREA = 400.0 ;
// minimo materiale dietro la faccia, limite assoluto // minimo materiale dietro la faccia, limite assoluto
const double FACE_ZERO_BACK_MAT = 0.5 ; const double FACE_ZERO_BACK_MAT = 0.5 ;
// minima area di componente staccata
const double FACE_DETACHED_MIN_AREA = 400.0 ;
// minimo spostamento per vari tipi di Mortise // minimo spostamento per vari tipi di Mortise
const double MORTISE_DISPL_MIN = 0.5 ; const double MORTISE_DISPL_MIN = 0.5 ;
// raggio fresa di default // raggio fresa di default
@@ -110,11 +163,12 @@ const double MILL_DEF_RAD = 12.5 ;
const double DTMILL_DEF_RAD = 30.0 ; const double DTMILL_DEF_RAD = 30.0 ;
// angolo coda di rondine di default // angolo coda di rondine di default
const double DOVETAIL_DEF_ANG = 15.0 ; const double DOVETAIL_DEF_ANG = 15.0 ;
// lunghezza extra per tenoni coda di rondine passanti
const double DTTEN_EXTRA_LEN = 5.0 ;
// lunghezza extra per mortase coda di rondine passanti // lunghezza extra per mortase coda di rondine passanti
const double DTMORT_EXTRA_LEN = 10.0 ; const double DTMORT_EXTRA_LEN = 10.0 ;
// minima e massima dimensione tasca per mortasa a coda di rondine // minima e massima dimensione tasca per mortasa a coda di rondine
const double MIN_DTMORT_POCKET = 70.0 ; const double MIN_DTMORT_POCKET = 70.0 ;
const double MAX_DTMORT_POCKET = 200.0 ;
const double MIN_DTMORT_AREA = 100.0 ; const double MIN_DTMORT_AREA = 100.0 ;
// tolleranza fuoriuscita curve di tasche di code di rondine // tolleranza fuoriuscita curve di tasche di code di rondine
const double DTMORT_OUT_CRV_TOL = 30.0 ; const double DTMORT_OUT_CRV_TOL = 30.0 ;
@@ -123,6 +177,10 @@ const double FC_SIDEANG_DEF = 0.0 ;
const double FC_SIDEANG_NONE = 999.0 ; const double FC_SIDEANG_NONE = 999.0 ;
// tolleranza fuoriuscita curve di contorni liberi // tolleranza fuoriuscita curve di contorni liberi
const double FC_OUT_CRV_TOL = 50.0 ; const double FC_OUT_CRV_TOL = 50.0 ;
// dimensione massima di contorno libero
const double FC_MAX_DIM = 200000.0 ;
// distanza limite tra diagonali per quadrilatero con twist di freecontour
const double FC_TWIST_DIAG_DIST = 2.0 ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Numero processo speciale Riferimento ad altro oggetto // Numero processo speciale Riferimento ad altro oggetto
+14 -23
View File
@@ -496,9 +496,10 @@ BtlGeom::UpdateOutLine( void)
// taglio con tutte le features // taglio con tutte le features
TrimOutlineWithProcesses() ; TrimOutlineWithProcesses() ;
// se presente Shape, nascondo Outline // se presente Shape e abilitato, nascondo Outline
int nDO ;
int nShapeId = m_pGDB->GetFirstNameInGroup( m_nOutsId, OL_SHAPE_NAME) ; int nShapeId = m_pGDB->GetFirstNameInGroup( m_nOutsId, OL_SHAPE_NAME) ;
if ( nShapeId != GDB_ID_NULL) { if ( nShapeId != GDB_ID_NULL && m_pGDB->GetInfo( nShapeId, IKEY_DO, nDO) && nDO != 0) {
int nEntId = m_pGDB->GetFirstInGroup( m_nOutsId) ; int nEntId = m_pGDB->GetFirstInGroup( m_nOutsId) ;
while ( nEntId != GDB_ID_NULL) { while ( nEntId != GDB_ID_NULL) {
if ( nEntId != nShapeId) if ( nEntId != nShapeId)
@@ -1073,8 +1074,8 @@ BtlGeom::AdjustOneOutlineFace( int nSide, ICURVEPOVECTOR& vCrvP)
// concateno le linee senza invertirle // concateno le linee senza invertirle
const double TOLER = 10 * EPS_SMALL ; const double TOLER = 10 * EPS_SMALL ;
ChainCurves chainC ; ChainCurves chainC ;
chainC.Init( false, TOLER, int( vCrvP.size())) ; chainC.Init( false, TOLER, ssize( vCrvP)) ;
for ( size_t i = 0 ; i < vCrvP.size() ; ++ i) { for ( int i = 0 ; i < ssize( vCrvP) ; ++ i) {
Point3d ptStart, ptEnd ; Point3d ptStart, ptEnd ;
Vector3d vtStart, vtEnd ; Vector3d vtStart, vtEnd ;
if ( ! vCrvP[i]->GetStartPoint( ptStart) || ! vCrvP[i]->GetStartDir( vtStart) || if ( ! vCrvP[i]->GetStartPoint( ptStart) || ! vCrvP[i]->GetStartDir( vtStart) ||
@@ -1091,7 +1092,7 @@ BtlGeom::AdjustOneOutlineFace( int nSide, ICURVEPOVECTOR& vCrvP)
if ( IsNull( pCrvCompo)) if ( IsNull( pCrvCompo))
return false ; return false ;
// recupero le curve semplici e le inserisco nella curva composita // recupero le curve semplici e le inserisco nella curva composita
for ( size_t i = 0 ; i < vId2s.size() ; ++ i) { for ( int i = 0 ; i < ssize( vId2s) ; ++ i) {
// indice della curva // indice della curva
int j = vId2s[i] - 1 ; int j = vId2s[i] - 1 ;
// la aggiungo alla curva composta // la aggiungo alla curva composta
@@ -1385,7 +1386,6 @@ BtlGeom::TrimProcessWithOutline( int nProcId)
bool bool
BtlGeom::AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints) BtlGeom::AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints)
{ {
StmFromTriangleSoup StmFts ; StmFromTriangleSoup StmFts ;
if ( ! StmFts.Start()) { if ( ! StmFts.Start()) {
LOG_ERROR( GetEExLogger(), " Error reading Part Shape: StmFts.Start error") LOG_ERROR( GetEExLogger(), " Error reading Part Shape: StmFts.Start error")
@@ -1401,22 +1401,13 @@ BtlGeom::AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints
// creo il contorno della faccia // creo il contorno della faccia
PtrOwner<ICurveComposite> pCurveCompo( CreateCurveComposite()) ; PtrOwner<ICurveComposite> pCurveCompo( CreateCurveComposite()) ;
pCurveCompo->AddPoint( vPoints[vVertices[0]]) ; pCurveCompo->AddPoint( vPoints[vVertices[0]]) ;
for ( size_t i = 1 ; i != vVertices.size() ; i++) for ( int i = 1 ; i < ssize( vVertices) ; i++)
pCurveCompo->AddLine( vPoints[vVertices[i]]) ; pCurveCompo->AddLine( vPoints[vVertices[i]]) ;
pCurveCompo->AddLine( vPoints[vVertices[0]]) ; pCurveCompo->AddLine( vPoints[vVertices[0]]) ;
// creo la faccia e recupero i suoi triangoli
PtrOwner<ISurfTriMesh> pSurf( GetSurfTriMeshByFlatContour( pCurveCompo)) ; PtrOwner<ISurfTriMesh> pSurf( GetSurfTriMeshByFlatContour( pCurveCompo)) ;
if ( ! IsNull( pSurf)) { if ( ! IsNull( pSurf))
// recupero tutti i triangoli StmFts.AddSurfTriMesh( *pSurf) ;
Triangle3d Tria ;
int nT = pSurf->GetFirstTriangle( Tria) ;
while ( nT != SVT_NULL) {
// inserisco il triangolo nella nuova superficie
StmFts.AddTriangle( Tria) ;
// passo al triangolo successivo
nT = pSurf->GetNextTriangle( nT, Tria) ;
}
}
} }
if ( ! StmFts.End()) { if ( ! StmFts.End()) {
@@ -1425,13 +1416,13 @@ BtlGeom::AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints
} }
PtrOwner<ISurfTriMesh> pShape( StmFts.GetSurf()) ; PtrOwner<ISurfTriMesh> pShape( StmFts.GetSurf()) ;
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pShape)) ;
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nPartId + 3, Release( pShape)) ; // salvo in outline
if ( nId == GDB_ID_NULL) if ( nId == GDB_ID_NULL)
return false ; return false ;
m_pGDB->SetName( nId, OL_SHAPE_NAME) ; m_pGDB->SetName( nId, OL_SHAPE_NAME) ;
m_pGDB->SetMaterial( nId, m_OutsCol) ; m_pGDB->SetMaterial( nId, m_OutsCol) ;
m_pGDB->SetStatus( nId, GDB_ST_ON) ; m_pGDB->SetStatus( nId, GDB_ST_OFF) ;
m_pGDB->SetInfo( nId, IKEY_DO, 0) ;
return true ; return true ;
} }
+727 -227
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 17
VisualStudioVersion = 15.0.28307.645 VisualStudioVersion = 17.12.35521.163
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtExchange", "EgtExchange.vcxproj", "{80FCBEA4-1883-4542-939D-8582E66D8D51}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtExchange", "EgtExchange.vcxproj", "{80FCBEA4-1883-4542-939D-8582E66D8D51}"
EndProject EndProject
+14 -7
View File
@@ -22,14 +22,14 @@
<ProjectGuid>{80FCBEA4-1883-4542-939D-8582E66D8D51}</ProjectGuid> <ProjectGuid>{80FCBEA4-1883-4542-939D-8582E66D8D51}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>EgtExchange</RootNamespace> <RootNamespace>EgtExchange</RootNamespace>
<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -42,7 +42,7 @@
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -104,7 +104,7 @@
<OpenMPSupport>false</OpenMPSupport> <OpenMPSupport>false</OpenMPSupport>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -128,7 +128,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
<PreprocessorDefinitions>WIN32;I_AM_EEX;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;I_AM_EEX;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<OpenMPSupport>true</OpenMPSupport> <OpenMPSupport>true</OpenMPSupport>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions> <AdditionalOptions>
</AdditionalOptions> </AdditionalOptions>
</ClCompile> </ClCompile>
@@ -163,7 +163,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration> <EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@@ -197,7 +197,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration> <EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions> <AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile> </ClCompile>
<Link> <Link>
@@ -232,6 +232,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="..\Include\EExImportCnc.h" /> <ClInclude Include="..\Include\EExImportCnc.h" />
<ClInclude Include="..\Include\EExImportCsf.h" /> <ClInclude Include="..\Include\EExImportCsf.h" />
<ClInclude Include="..\Include\EExImportDxf.h" /> <ClInclude Include="..\Include\EExImportDxf.h" />
<ClInclude Include="..\Include\EExImportOff.h" />
<ClInclude Include="..\Include\EExImportPnt.h" /> <ClInclude Include="..\Include\EExImportPnt.h" />
<ClInclude Include="..\Include\EExImportStl.h" /> <ClInclude Include="..\Include\EExImportStl.h" />
<ClInclude Include="..\Include\EGkAngle.h" /> <ClInclude Include="..\Include\EGkAngle.h" />
@@ -330,7 +331,10 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="ImportCnc.h" /> <ClInclude Include="ImportCnc.h" />
<ClInclude Include="ImportCsf.h" /> <ClInclude Include="ImportCsf.h" />
<ClInclude Include="ImportDxf.h" /> <ClInclude Include="ImportDxf.h" />
<ClInclude Include="ImportOff.h" />
<ClInclude Include="ImportPly.h" />
<ClInclude Include="ImportStl.h" /> <ClInclude Include="ImportStl.h" />
<ClInclude Include="miniply.h" />
<ClInclude Include="pugiconfig.hpp" /> <ClInclude Include="pugiconfig.hpp" />
<ClInclude Include="pugixml.hpp" /> <ClInclude Include="pugixml.hpp" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
@@ -372,8 +376,11 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="ImportDxfEnts.cpp" /> <ClCompile Include="ImportDxfEnts.cpp" />
<ClCompile Include="ImportDxfHeader.cpp" /> <ClCompile Include="ImportDxfHeader.cpp" />
<ClCompile Include="ImportDxfTabs.cpp" /> <ClCompile Include="ImportDxfTabs.cpp" />
<ClCompile Include="ImportOff.cpp" />
<ClCompile Include="ImportPly.cpp" />
<ClCompile Include="ImportPnt.cpp" /> <ClCompile Include="ImportPnt.cpp" />
<ClCompile Include="ImportStl.cpp" /> <ClCompile Include="ImportStl.cpp" />
<ClCompile Include="miniply.cpp" />
<ClCompile Include="pugixml.cpp" /> <ClCompile Include="pugixml.cpp" />
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+21
View File
@@ -375,6 +375,18 @@
<ClInclude Include="..\Include\SELkKeyProc.h"> <ClInclude Include="..\Include\SELkKeyProc.h">
<Filter>File di intestazione\Include</Filter> <Filter>File di intestazione\Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="ImportOff.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="..\Include\EExImportOff.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="ImportPly.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="miniply.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
@@ -455,6 +467,15 @@
<ClCompile Include="ExportThreeJS.cpp"> <ClCompile Include="ExportThreeJS.cpp">
<Filter>File di origine</Filter> <Filter>File di origine</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="ImportOff.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="ImportPly.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="miniply.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="EgtExchange.rc"> <ResourceCompile Include="EgtExchange.rc">
+86 -90
View File
@@ -17,15 +17,9 @@
#include "Export3MF.h" #include "Export3MF.h"
#include "DllMain.h" #include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h" #include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ; using namespace std ;
using namespace Lib3MF ; using namespace Lib3MF ;
@@ -71,13 +65,13 @@ Export3MF::Export( IGeomDB* pGDB, int nId, const string& sFile)
// libreria 3MF // libreria 3MF
m_wrapper = CWrapper::loadLibrary() ; m_wrapper = CWrapper::loadLibrary() ;
if ( ! m_wrapper) { if ( m_wrapper == nullptr) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Wrapper") LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Wrapper")
return false ; return false ;
} }
// creo model per 3MF // creo model per 3MF
m_model = m_wrapper->CreateModel() ; m_model = m_wrapper->CreateModel() ;
if ( ! m_model) { if ( m_model == nullptr) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Model") LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Model")
return false ; return false ;
} }
@@ -92,20 +86,10 @@ Export3MF::Export( IGeomDB* pGDB, int nId, const string& sFile)
return false ; return false ;
pIter->GoTo( nId) ; pIter->GoTo( nId) ;
// assegno le info dell'oggetto al modello
PMetaDataGroup metaDataGrp = m_model->GetMetaDataGroup() ;
STRVECTOR vInfo ;
pIter->GetAllInfo( vInfo) ;
for ( const string& sInfo : vInfo) {
string sKey, sVal ;
SplitFirst( sInfo, "=", sKey, sVal) ;
metaDataGrp->AddMetaData( sInfoNamespace, sKey, sVal, "xs:string", 0) ;
}
// esporto l'oggetto e i suoi eventuali figli // esporto l'oggetto e i suoi eventuali figli
if ( ! ExportObject( *pIter)) if ( ! ExportObject( *pIter))
return false ; return false ;
// scrivo il file // scrivo il file
try { try {
PWriter writer = m_model->QueryWriter( "3mf") ; PWriter writer = m_model->QueryWriter( "3mf") ;
@@ -123,7 +107,7 @@ Export3MF::Export( IGeomDB* pGDB, int nId, const string& sFile)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
Export3MF::ExportObject( const IGdbIterator& iIter) Export3MF::ExportObject( const IGdbIterator& iIter, PComponentsObject pParent, bool bSaveGrpAsComponent)
{ {
// recupero il livello dell'oggetto // recupero il livello dell'oggetto
int nLev = GDB_LV_USER ; int nLev = GDB_LV_USER ;
@@ -137,48 +121,43 @@ Export3MF::ExportObject( const IGdbIterator& iIter)
int nType = iIter.GetGdbType() ; int nType = iIter.GetGdbType() ;
// se il filtro lo abilita // se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat, nType == GDB_TY_GROUP)) { if ( TestFilter( nLev, nMode, nStat, nType == GDB_TY_GROUP)) {
switch ( iIter.GetGdbType()) { // se è un oggetto geometrico diverso da una superficie esco
int nGeoType = iIter.GetGeoType() ;
if ( nGeoType != GEO_NONE && nGeoType != SRF_TRIMESH && nGeoType != SRF_FLATRGN)
return true ;
// recupero nome
string sName ;
iIter.GetName( sName) ;
// recupero info
STRVECTOR vsInfo ;
iIter.GetAllInfo( vsInfo) ;
// esporto
switch ( nType) {
case GDB_TY_GEO : case GDB_TY_GEO :
{ {
// recupero l'oggetto geometrico // recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ; const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr) if ( pGeoObj == nullptr)
return true ; return false ;
// se non è una superficie esco
if ( pGeoObj->GetType() != SRF_TRIMESH && pGeoObj->GetType() != SRF_FLATRGN)
return true ;
// recupero il riferimento globale dell'oggetto // recupero il riferimento globale dell'oggetto
Frame3d frFrame ; Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame)) if ( ! iIter.GetGlobFrame( frFrame))
return false ; return false ;
// recupero eventuale nome
string sName ;
if ( ! iIter.GetName( sName))
sName = ToString( iIter.GetId()) ;
// recupero il colore // recupero il colore
Color cCol ; Color cCol ;
bool bCol = GetColor( cCol, iIter.GetGDB(), iIter.GetId()) ; iIter.GetCalcMaterial( cCol) ;
// recupero le proprietà
STRVECTOR vInfo ;
iIter.GetAllInfo( vInfo) ;
// emetto l'oggetto // emetto l'oggetto
switch ( pGeoObj->GetType()) { switch ( nGeoType) {
case SRF_TRIMESH : case SRF_TRIMESH :
if ( ! ExportSTM( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr, vInfo)) return ExportSTM( pGeoObj, frFrame, sName, vsInfo, cCol, pParent) ;
return false ;
break ;
case SRF_FLATRGN : case SRF_FLATRGN :
if ( ! ExportSFR( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr, vInfo)) return ExportSFR( pGeoObj, frFrame, sName, vsInfo, cCol, pParent) ;
return false ;
break ;
default : default :
break ; return false ;
} }
} }
return true ; case GDB_TY_GROUP :
case GDB_TY_GROUP : return ExportGroup( iIter, sName, vsInfo, pParent, bSaveGrpAsComponent) ;
// esploro il gruppo
return ScanGroup( iIter) ;
default : default :
return false ; return false ;
} }
@@ -188,7 +167,7 @@ Export3MF::ExportObject( const IGdbIterator& iIter)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
Export3MF::TestFilter( int nLev, int nMode, int nStat, bool bGroup) Export3MF::TestFilter( int nLev, int nMode, int nStat, bool bGroup) const
{ {
int nFilter = bGroup ? m_nGroupFilter : m_nFilter ; int nFilter = bGroup ? m_nGroupFilter : m_nFilter ;
if ( ( nLev == GDB_LV_USER && ( nFilter & EEXFLT_LEVUSER) == 0) || if ( ( nLev == GDB_LV_USER && ( nFilter & EEXFLT_LEVUSER) == 0) ||
@@ -239,7 +218,8 @@ Export3MF::CalcGroupFilter( void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
Export3MF::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, const STRVECTOR& vInfo) Export3MF::ExportSFR( const IGeoObj* pGeoObj, const Frame3d& frFrame, const string& sName, const STRVECTOR& vInfo,
const Color& cCol, PComponentsObject pParent)
{ {
// verifico oggetto // verifico oggetto
const ISurfFlatRegion* pSFR = GetSurfFlatRegion( pGeoObj) ; const ISurfFlatRegion* pSFR = GetSurfFlatRegion( pGeoObj) ;
@@ -247,12 +227,13 @@ Export3MF::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d
return false ; return false ;
// ricavo la trimesh equivalente // ricavo la trimesh equivalente
const ISurfTriMesh* pStm = pSFR->GetAuxSurf() ; const ISurfTriMesh* pStm = pSFR->GetAuxSurf() ;
return ExportSTM( sName, pStm, frFrame, pCol, vInfo) ; return ExportSTM( pStm, frFrame, sName, vInfo, cCol, pParent) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
Export3MF::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, const STRVECTOR& vInfo) Export3MF::ExportSTM( const IGeoObj* pGeoObj, const Frame3d& frFrame, const string& sName, const STRVECTOR& vInfo,
const Color& cCol, PComponentsObject pParent)
{ {
// verifico oggetto // verifico oggetto
const ISurfTriMesh* pSTM = GetSurfTriMesh( pGeoObj) ; const ISurfTriMesh* pSTM = GetSurfTriMesh( pGeoObj) ;
@@ -286,25 +267,21 @@ Export3MF::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d
} }
if ( vVertices.size() == 0 || vTriangles.size() == 0) { if ( vVertices.size() == 0 || vTriangles.size() == 0) {
LOG_ERROR( GetEExLogger(), ( "Export3MF : surface \"" + sName + "\" is empty. Ignored.").c_str()) ; LOG_ERROR( GetEExLogger(), "Export3MF : empty surface ignored") ;
return true ; return true ;
} }
// creo mesh 3MF // creo mesh 3MF
PMeshObject meshObject = m_model->AddMeshObject() ; PMeshObject meshObject = m_model->AddMeshObject() ;
if ( ! meshObject) { if ( meshObject == nullptr) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Mesh Object") LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Mesh Object")
return false ; return false ;
} }
meshObject->SetName( sName) ;
meshObject->SetGeometry( vVertices, vTriangles) ; meshObject->SetGeometry( vVertices, vTriangles) ;
// assegno il colore
if ( pCol != nullptr) {
Lib3MF_uint32 nColId = ColorHandler3MF( pCol) ;
meshObject->SetObjectLevelProperty( 1, nColId) ;
}
// assegno il nome
if ( ! sName.empty())
meshObject->SetName( sName) ;
// assegno le info // assegno le info
PMetaDataGroup metaDataGrp = meshObject->GetMetaDataGroup() ; PMetaDataGroup metaDataGrp = meshObject->GetMetaDataGroup() ;
for ( const string& sInfo : vInfo) { for ( const string& sInfo : vInfo) {
@@ -312,60 +289,79 @@ Export3MF::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d
SplitFirst( sInfo, "=", sKey, sVal) ; SplitFirst( sInfo, "=", sKey, sVal) ;
metaDataGrp->AddMetaData( sInfoNamespace, sKey, sVal, "xs:string", 0) ; metaDataGrp->AddMetaData( sInfoNamespace, sKey, sVal, "xs:string", 0) ;
} }
// assegno il colore
Lib3MF_uint32 nColId = ColorHandler3MF( cCol) ;
meshObject->SetObjectLevelProperty( 1, nColId) ;
// aggiungo al modello
if ( pParent == nullptr)
m_model->AddBuildItem( meshObject.get(), m_wrapper->GetIdentityTransform()) ;
else
pParent->AddComponent( meshObject.get(), m_wrapper->GetIdentityTransform()) ;
m_model->AddBuildItem( meshObject.get(), m_wrapper->GetIdentityTransform()) ;
return true ; return true ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
Export3MF::ScanGroup( const IGdbIterator& iIter) Export3MF::ExportGroup( const IGdbIterator& iIter, const string& sName, const STRVECTOR& vsInfo, PComponentsObject pParent,
bool bSaveAsComponent)
{ {
// creo un iteratore PComponentsObject pComponent = pParent ;
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( iIter.GetGDB())) ; // se il layer va salvato come componente, la creo
if ( IsNull( pIter)) if ( bSaveAsComponent) {
return false ; pComponent = m_model->AddComponentsObject() ;
// scandisco il gruppo if ( ! sName.empty())
bool bOk = true ; pComponent->SetName( sName) ;
for ( bool bNext = pIter->GoToFirstInGroup( iIter) ; }
bNext ;
bNext = pIter->GoToNext()) { // salvo le info sulla componente ( se il gruppo viene esportato come tale) o sul modello
if ( ! ExportObject( *pIter)) PMetaDataGroup metaDataGrp ;
bOk = false ; if ( bSaveAsComponent)
metaDataGrp = pComponent->GetMetaDataGroup() ;
else
metaDataGrp = m_model->GetMetaDataGroup() ;
for ( const string& sInfo : vsInfo) {
string sKey, sVal ;
SplitFirst( sInfo, "=", sKey, sVal) ;
metaDataGrp->AddMetaData( sInfoNamespace, sKey, sVal, "xs:string", 0) ;
} }
return bOk ; // scandisco il gruppo per inserire i suoi oggetti
} PtrOwner<IGdbIterator> pIter( CreateGdbIterator( iIter.GetGDB())) ;
if ( IsNull( pIter))
return false ;
for ( bool bNext = pIter->GoToFirstInGroup( iIter) ; bNext ; bNext = pIter->GoToNext()) {
if ( ! ExportObject( *pIter, pComponent, true))
return false ;
}
//---------------------------------------------------------------------------- // se il gruppo va salvato come componente, lo aggiungo al modello
bool if ( bSaveAsComponent && pComponent->GetComponentCount() > 0) {
Export3MF::GetColor( Color& pCol, const IGeomDB * pGDB, const int& nId) if ( pParent == nullptr)
{ m_model->AddBuildItem( pComponent.get(), m_wrapper->GetIdentityTransform()) ;
if ( nId == GDB_ID_NULL) else
return false ; pParent->AddComponent( pComponent.get(), m_wrapper->GetIdentityTransform()) ;
}
if ( ! pGDB->GetMaterial( nId, pCol))
// se fallisce cerco il colore del parent
return GetColor( pCol, pGDB, pGDB->GetParentId( nId)) ;
return true ; return true ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
Lib3MF_uint32 Lib3MF_uint32
Export3MF::ColorHandler3MF( const Color* pCol) Export3MF::ColorHandler3MF( const Color& cCol)
{ {
PColorGroup pColorGrp = m_model->GetColorGroupByID( 1) ; PColorGroup pColorGrp = m_model->GetColorGroupByID( 1) ;
// converto il colore nel formato usato da 3MF // converto il colore nel formato usato da 3MF
Lib3MF_uint8 nAlpha = ( int)( pCol->GetIntAlpha() * 2.55 + 0.5) ; Lib3MF_uint8 nAlpha = ( int)( cCol.GetIntAlpha() * 2.55 + 0.5) ;
sColor cCol3mf = m_wrapper->RGBAToColor( pCol->GetIntRed(), pCol->GetIntGreen(), pCol->GetIntBlue(), nAlpha) ; sColor cCol3mf = m_wrapper->RGBAToColor( cCol.GetIntRed(), cCol.GetIntGreen(), cCol.GetIntBlue(), nAlpha) ;
// verifico se il colore gi presente nel colorgroup // verifico se il colore è già presente nel colorgroup
UINTVECTOR vColorIdx ; UINTVECTOR vColorIdx ;
pColorGrp->GetAllPropertyIDs( vColorIdx) ; pColorGrp->GetAllPropertyIDs( vColorIdx) ;
for ( Lib3MF_uint32 i : vColorIdx) { for ( Lib3MF_uint32 i : vColorIdx) {
sColor cColTmp = pColorGrp->GetColor( i) ; sColor cColTmp = pColorGrp->GetColor( i) ;
if ( cColTmp.m_Red == cCol3mf.m_Red && cColTmp.m_Green == cCol3mf.m_Green && cColTmp.m_Blue == cCol3mf.m_Blue if ( cColTmp.m_Red == cCol3mf.m_Red && cColTmp.m_Green == cCol3mf.m_Green && cColTmp.m_Blue == cCol3mf.m_Blue &&
&& cColTmp.m_Alpha == cCol3mf.m_Alpha) cColTmp.m_Alpha == cCol3mf.m_Alpha)
return i ; return i ;
} }
// se non fosse presente, lo aggiungo // se non fosse presente, lo aggiungo
+12 -12
View File
@@ -13,7 +13,7 @@
#pragma once #pragma once
#define NOMINMAX #define NOMINMAX
#include "/EgtDev/Extern/Lib3MF/Include/lib3mf_implicit.hpp" #include "/EgtDev/Extern/Lib3MF/Include/lib3mf_implicit.hpp"
#include "/EgtDev/Include/EExExport3MF.h" #include "/EgtDev/Include/EExExport3MF.h"
@@ -32,20 +32,20 @@ class Export3MF : public IExport3MF
} }
private : private :
bool ExportObject( const IGdbIterator& iIter) ; bool ExportObject( const IGdbIterator& iIter, Lib3MF::PComponentsObject pParent = nullptr, bool bSaveGrpAsComponent = false) ;
bool ScanGroup( const IGdbIterator& iIter) ; bool ExportGroup( const IGdbIterator& iIter, const std::string& sName, const STRVECTOR& vsInfo, Lib3MF::PComponentsObject pParent,
bool TestFilter( int nLev, int nMode, int nStat, bool bGroup) ; bool bSaveAsComponent) ;
bool ExportSFR( const IGeoObj* pGeoObj, const Frame3d& frFrame, const std::string& sName, const STRVECTOR& vInfo,
const Color& cCol, Lib3MF::PComponentsObject pParent) ;
bool ExportSTM( const IGeoObj* pGeoObj, const Frame3d& frFrame, const std::string& sName, const STRVECTOR& vInfo,
const Color& cCol, Lib3MF::PComponentsObject pParent) ;
bool TestFilter( int nLev, int nMode, int nStat, bool bGroup) const ;
bool CalcGroupFilter( void) ; bool CalcGroupFilter( void) ;
bool ExportSFR( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, Lib3MF_uint32 ColorHandler3MF( const Color& cCol) ;
const STRVECTOR& vInfo) ;
bool ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol,
const STRVECTOR& vInfo) ;
Lib3MF_uint32 ColorHandler3MF( const Color* pCol) ;
bool GetColor( Color& pCol, const IGeomDB * pGBD, const int& nId) ;
private : private :
int m_nFilter ; // filtro su livello, modo e stato, se l'oggetto da valutare un oggetto geometrico int m_nFilter ; // filtro su livello, modo e stato, se l'oggetto da valutare è un oggetto geometrico
int m_nGroupFilter ; // filtro su livello, modo e stato, se l'oggetto da valutare un gruppo int m_nGroupFilter ; // filtro su livello, modo e stato, se l'oggetto da valutare è un gruppo
Lib3MF::PWrapper m_wrapper ; // lib3mf wrapper Lib3MF::PWrapper m_wrapper ; // lib3mf wrapper
Lib3MF::PModel m_model ; // lib3mf model Lib3MF::PModel m_model ; // lib3mf model
} ; } ;
-2
View File
@@ -33,8 +33,6 @@
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtStringDecoder.h" #include "/EgtDev/Include/EgtStringDecoder.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
-2
View File
@@ -21,8 +21,6 @@
#include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <fstream> #include <fstream>
-2
View File
@@ -28,8 +28,6 @@
#include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <fstream> #include <fstream>
+104 -212
View File
@@ -18,7 +18,7 @@
#include "Import3MF.h" #include "Import3MF.h"
#include "DllMain.h" #include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h" #include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h" #include "/EgtDev/Include/EGkSurfTriMesh.h"
using namespace std ; using namespace std ;
using namespace Lib3MF ; using namespace Lib3MF ;
@@ -27,16 +27,16 @@ using namespace Lib3MF ;
IImport3MF* IImport3MF*
CreateImport3MF( void) CreateImport3MF( void)
{ {
// verifico la chiave e le opzioni // verifico la chiave e le opzioni
if ( ! VerifyKey( KEYOPT_EEX_INPBASE)) if ( ! VerifyKey( KEYOPT_EEX_INPBASE))
return nullptr ; return nullptr ;
// creo l'oggetto // creo l'oggetto
return static_cast<IImport3MF*> ( new( nothrow) Import3MF) ; return static_cast<IImport3MF*> ( new( nothrow) Import3MF) ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
Import3MF::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup) Import3MF::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup, int nFlag)
{ {
LOG_INFO( GetEExLogger(), ( "Import3MF : " + sFile).c_str()) ; LOG_INFO( GetEExLogger(), ( "Import3MF : " + sFile).c_str()) ;
@@ -53,7 +53,10 @@ Import3MF::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup)
return false ; return false ;
} }
m_nIdGroup = nIdGroup ; m_nIdGroup = nIdGroup ;
// imposto le opzioni di importazione
m_nFlag = nFlag ;
try { try {
if ( ! DoImport( sFile)) if ( ! DoImport( sFile))
return false ; return false ;
@@ -71,15 +74,15 @@ bool
Import3MF::DoImport( const string& sFile) Import3MF::DoImport( const string& sFile)
{ {
// libreria 3MF // libreria 3MF
PWrapper m_wrapper = CWrapper::loadLibrary() ; m_wrapper = CWrapper::loadLibrary() ;
if ( ! m_wrapper) { if ( m_wrapper == nullptr) {
LOG_ERROR( GetEExLogger(), " Import3MF : Error on lib3mf Wrapper") ; LOG_ERROR( GetEExLogger(), " Import3MF : Error on lib3mf Wrapper") ;
return false ; return false ;
} }
// creazione del 3MF model // creazione del 3MF model
m_model = m_wrapper->CreateModel() ; m_model = m_wrapper->CreateModel() ;
if ( ! m_model) { if ( m_model == nullptr) {
LOG_ERROR( GetEExLogger(), " Import3MF : Error on lib3mf Model") ; LOG_ERROR( GetEExLogger(), " Import3MF : Error on lib3mf Model") ;
return false ; return false ;
} }
@@ -87,33 +90,34 @@ Import3MF::DoImport( const string& sFile)
// lettura file // lettura file
PReader reader = m_model->QueryReader( "3mf") ; PReader reader = m_model->QueryReader( "3mf") ;
reader->ReadFromFile( sFile) ; reader->ReadFromFile( sFile) ;
for ( Lib3MF_uint32 iWarning = 0 ; iWarning < reader->GetWarningCount() ; iWarning ++) { for ( Lib3MF_uint32 nWarning = 0 ; nWarning < reader->GetWarningCount() ; nWarning ++) {
Lib3MF_uint32 nErrorCode ; Lib3MF_uint32 nErrorCode ;
string sWarningMsg = reader->GetWarning( iWarning, nErrorCode) ; string sWarningMsg = reader->GetWarning( nWarning, nErrorCode) ;
string sErrorMsg = " Reading 3MF file encountered warning # " + to_string( nErrorCode) + " : " + sWarningMsg ; string sErrorMsg = " Reading 3MF file encountered warning # " + to_string( nErrorCode) + " : " + sWarningMsg ;
LOG_ERROR( GetEExLogger(), sErrorMsg.c_str()) ;
} }
switch ( m_model->GetUnit()) { switch ( m_model->GetUnit()) {
case eModelUnit::MicroMeter : case eModelUnit::MicroMeter :
m_nScaleFactor = 0.001 ; m_dScaleFactor = 0.001 ;
break ; break ;
case eModelUnit::MilliMeter : case eModelUnit::MilliMeter :
m_nScaleFactor = 1.0 ; m_dScaleFactor = 1.0 ;
break ; break ;
case eModelUnit::CentiMeter : case eModelUnit::CentiMeter :
m_nScaleFactor = 10.0 ; m_dScaleFactor = 10.0 ;
break ; break ;
case eModelUnit::Inch : case eModelUnit::Inch :
m_nScaleFactor = 25.4 ; m_dScaleFactor = 25.4 ;
break ; break ;
case eModelUnit::Foot : case eModelUnit::Foot :
m_nScaleFactor = 304.8 ; m_dScaleFactor = 304.8 ;
break ; break ;
case eModelUnit::Meter : case eModelUnit::Meter :
m_nScaleFactor = 1000.0 ; m_dScaleFactor = 1000.0 ;
break ; break ;
default: default:
m_nScaleFactor = 1.0 ; m_dScaleFactor = 1.0 ;
} }
// analisi metadata // analisi metadata
@@ -121,83 +125,54 @@ Import3MF::DoImport( const string& sFile)
Lib3MF_uint32 nMetaDataCount = metaDataGrp->GetMetaDataCount() ; Lib3MF_uint32 nMetaDataCount = metaDataGrp->GetMetaDataCount() ;
for ( Lib3MF_uint32 i = 0 ; i < nMetaDataCount ; i ++) { for ( Lib3MF_uint32 i = 0 ; i < nMetaDataCount ; i ++) {
PMetaData metaData = metaDataGrp->GetMetaData( i) ; PMetaData metaData = metaDataGrp->GetMetaData( i) ;
string sMetaDataValue = metaData->GetValue() ; string sName = metaData->GetName() ;
string sMetaDataName = metaData->GetName() ; string sValue = metaData->GetValue() ;
if ( ! sMetaDataValue.empty() && ! sMetaDataName.empty()) if ( ! sName.empty() && ! sValue.empty())
m_pGDB->SetInfo( m_nIdGroup, sMetaDataName, sMetaDataValue) ; m_pGDB->SetInfo( m_nIdGroup, sName, sValue) ;
} }
// scorro gli items nel build node // scorro gli items nel build node
PBuildItemIterator pBuildItemsIter = m_model->GetBuildItems() ; PBuildItemIterator pBuildItemsIter = m_model->GetBuildItems() ;
while ( pBuildItemsIter->MoveNext()) { while ( pBuildItemsIter->MoveNext()) {
if ( ! ReadItem( pBuildItemsIter->GetCurrent())) PBuildItem pItem = pBuildItemsIter->GetCurrent() ;
return false ; // ignoro i suoi attributes e i suoi metadata
// recupero la sua trasformazione
sTransform sTransf = pItem->GetObjectTransform() ;
// lettura oggetto associato
if ( ! ReadObject( pItem->GetObjectResource(), sTransf, m_nIdGroup))
return false ;
} }
return true ; return true ;
} }
//----------------------------------------------------------------------------------------------------
bool
Import3MF::ReadItem( const PBuildItem pItem)
{
if ( ! pItem)
return false ;
// trasformazione
sTransform sTransf = pItem->GetObjectTransform() ;
// attributes
ATTRVECTOR vAttr ;
string sProp = pItem->GetPartNumber() ;
if ( ! sProp.empty())
vAttr.push_back( make_pair( "Item partnumber", pItem->GetPartNumber())) ;
bool bUUID ;
sProp = pItem->GetUUID( bUUID) ;
if ( bUUID)
vAttr.push_back( make_pair( "Item UUID", sProp)) ;
// metadata
PMetaDataGroup pMetaDataGrp = pItem->GetMetaDataGroup() ;
if ( pMetaDataGrp)
ReadMetaDataGroup( pMetaDataGrp, vAttr, Item) ;
// lettura oggetto associato
return ReadObject( pItem->GetObjectResource(), vAttr, sTransf) ;
}
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
bool bool
Import3MF::ReadObject( const PObject pObj, ATTRVECTOR& vAttr, sTransform& sTransf) Import3MF::ReadObject( const PObject pObj, const sTransform& Transform, int nParentId)
{ {
if ( ! pObj) if ( pObj == nullptr)
return false ; return false ;
bool bMeshObj = pObj->IsMeshObject() ;
// attributes // attributes
string sProp = pObj->GetName() ; INFOVECTOR vInfo ;
string sName = pObj->GetName() ;
string sProp = pObj->GetPartNumber() ;
if ( ! sProp.empty()) if ( ! sProp.empty())
vAttr.push_back( make_pair( "name", sProp)) ; vInfo.emplace_back( "PartNumber", sProp) ;
sProp = pObj->GetPartNumber() ;
if ( ! sProp.empty())
vAttr.push_back( make_pair( "partnumber", sProp)) ;
bool bUUID = false ; bool bUUID = false ;
sProp = pObj->GetUUID( bUUID) ; sProp = pObj->GetUUID( bUUID) ;
if ( bUUID) { if ( bUUID)
string sPropName = bMeshObj ? "UUID" : "object UUID" ; vInfo.emplace_back( "UUID", sProp) ;
vAttr.push_back( make_pair( sPropName, sProp)) ;
}
switch ( pObj->GetType()) { switch ( pObj->GetType()) {
case eObjectType::Model : case eObjectType::Model :
vAttr.push_back( make_pair( "type", "Model")) ; vInfo.emplace_back( "Type", "Model") ;
break ; break ;
case eObjectType::Support : case eObjectType::Support :
vAttr.push_back( make_pair( "type", "Support")) ; vInfo.emplace_back( "Type", "Support") ;
break ; break ;
case eObjectType::SolidSupport : case eObjectType::SolidSupport :
vAttr.push_back( make_pair( "type", "SolidSupport")) ; vInfo.emplace_back( "Type", "SolidSupport") ;
break ; break ;
default : default :
break ; break ;
@@ -205,29 +180,34 @@ Import3MF::ReadObject( const PObject pObj, ATTRVECTOR& vAttr, sTransform& sTrans
// metadata // metadata
PMetaDataGroup pMetaDataGrp = pObj->GetMetaDataGroup() ; PMetaDataGroup pMetaDataGrp = pObj->GetMetaDataGroup() ;
if ( pMetaDataGrp) for ( Lib3MF_uint32 i = 0 ; i < pMetaDataGrp->GetMetaDataCount() ; i ++) {
ReadMetaDataGroup( pMetaDataGrp, vAttr, bMeshObj ? Mesh : Component) ; PMetaData metaData = pMetaDataGrp->GetMetaData( i) ;
string sMetaDataName = metaData->GetName() ;
string sMetaDataValue = metaData->GetValue() ;
if ( ! sMetaDataName.empty() && ! sMetaDataValue.empty())
vInfo.emplace_back( sMetaDataName, sMetaDataValue) ;
}
if ( pObj->IsMeshObject()) if ( pObj->IsMeshObject())
return ReadMesh( pObj->GetResourceID(), vAttr, sTransf) ; return ReadMesh( pObj->GetResourceID(), sName, vInfo, Transform, nParentId) ;
else if ( pObj->IsComponentsObject()) else if ( pObj->IsComponentsObject())
return ReadComponents( pObj->GetResourceID(), vAttr, sTransf) ; return ReadComponent( pObj->GetResourceID(), sName, vInfo, Transform, nParentId) ;
return false ; return false ;
} }
//---------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------
bool bool
Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sTransf) Import3MF::ReadMesh( Lib3MF_uint32 nId, const string& sName, const INFOVECTOR& vInfo, const sTransform& Transform, int nParentId)
{ {
// Recupero puntatore alla mesh 3MF // Recupero puntatore alla mesh 3MF
PMeshObject pMesh = m_model->GetMeshObjectByID( nId) ; PMeshObject pMesh = m_model->GetMeshObjectByID( nId) ;
if ( pMesh.get() == nullptr) if ( pMesh == nullptr)
return false ; return false ;
// Creo e inizializzo trimesh // Creo e inizializzo trimesh
PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ; PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ;
if ( IsNull( pStm) || ! pStm->Init( 3, 1)) { if ( IsNull( pStm) || ! pStm->Init( pMesh->GetVertexCount(), pMesh->GetTriangleCount())) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : ISurfTriMesh Create error") ; LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : ISurfTriMesh Create error") ;
return false ; return false ;
} }
@@ -240,15 +220,15 @@ Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sT
// applico la trasformazione // applico la trasformazione
double x = 0.0, y = 0.0, z = 0.0 ; double x = 0.0, y = 0.0, z = 0.0 ;
for ( int k = 0 ; k < 3 ; k ++) { for ( int k = 0 ; k < 3 ; k ++) {
x += pVertex.m_Coordinates[k] * sTransf.m_Fields[k][0] ; x += pVertex.m_Coordinates[k] * Transform.m_Fields[k][0] ;
y += pVertex.m_Coordinates[k] * sTransf.m_Fields[k][1] ; y += pVertex.m_Coordinates[k] * Transform.m_Fields[k][1] ;
z += pVertex.m_Coordinates[k] * sTransf.m_Fields[k][2] ; z += pVertex.m_Coordinates[k] * Transform.m_Fields[k][2] ;
} }
x += sTransf.m_Fields[3][0] ; x += Transform.m_Fields[3][0] ;
y += sTransf.m_Fields[3][1] ; y += Transform.m_Fields[3][1] ;
z += sTransf.m_Fields[3][2] ; z += Transform.m_Fields[3][2] ;
// inserisco il vertice nella trimesh // inserisco il vertice nella trimesh
if ( pStm->AddVertex( Point3d( x, y, z)) == SVT_NULL) { if ( pStm->AddVertex( Point3d( x, y, z) * m_dScaleFactor) == SVT_NULL) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : ISurfTriMesh AddVertex error") ; LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : ISurfTriMesh AddVertex error") ;
return false ; return false ;
} }
@@ -275,7 +255,7 @@ Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sT
} }
// Inserimento nel DB geometrico // Inserimento nel DB geometrico
int nGeoId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, Release( pStm)) ; int nGeoId = m_pGDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) ;
if ( nGeoId == GDB_ID_NULL) { if ( nGeoId == GDB_ID_NULL) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : error adding GeoObject") ; LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : error adding GeoObject") ;
return false ; return false ;
@@ -290,125 +270,65 @@ Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sT
} }
// attributes // attributes
for ( size_t i = 0 ; i < vAttr.size() ; i++) { if ( ! sName.empty())
if ( vAttr[i].first == "name") m_pGDB->SetName( nGeoId, sName) ;
m_pGDB->SetName( nGeoId, vAttr[i].second) ; for ( int i = 0 ; i < int( vInfo.size()) ; i++)
else m_pGDB->SetInfo( nGeoId, vInfo[i].first, vInfo[i].second) ;
m_pGDB->SetInfo( nGeoId, vAttr[i].first, vAttr[i].second) ;
}
return true ; return true ;
#if 0
PMeshObject pMesh = m_model->GetMeshObjectByID( nId) ;
StmFromTriangleSoup Stm ;
if ( ! Stm.Start()) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : StmFromTriangleSoup error") ;
return false ;
}
// vertici
vector<Point3d> vVertices( pMesh->GetVertexCount()) ;
for ( Lib3MF_uint32 i = 0 ; i < pMesh->GetVertexCount() ; i ++) {
sPosition pVertex = pMesh->GetVertex( i) ;
// applico la trasformazione
double x = 0.0, y = 0.0, z = 0.0 ;
for ( Lib3MF_uint32 k = 0 ; k < 3 ; k ++) {
x += pVertex.m_Coordinates[k] * sTransf.m_Fields[k][0] ;
y += pVertex.m_Coordinates[k] * sTransf.m_Fields[k][1] ;
z += pVertex.m_Coordinates[k] * sTransf.m_Fields[k][2] ;
}
x += sTransf.m_Fields[3][0] ;
y += sTransf.m_Fields[3][1] ;
z += sTransf.m_Fields[3][2] ;
Point3d pt( x, y, z) ;
vVertices[i] = pt * m_nScaleFactor ;
}
// triangoli
for ( Lib3MF_uint32 i = 0 ; i < pMesh->GetTriangleCount() ; i ++) {
sTriangle tTrg = pMesh->GetTriangle( i) ;
if ( ! Stm.AddTriangle( vVertices[tTrg.m_Indices[0]], vVertices[tTrg.m_Indices[1]], vVertices[tTrg.m_Indices[2]])) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : StmFromTriangleSoup AddTriangle error") ;
return false ;
}
}
if ( ! Stm.End()) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : StmFromTriangleSoup error") ;
return false ;
}
ISurfTriMesh* pSurf = Stm.GetSurf() ;
if ( pSurf == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : StmFromTriangleSoup GetSurf error") ;
return false ;
}
int nGeoId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, pSurf) ;
if ( nGeoId == GDB_ID_NULL) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : error adding GeoObject") ;
return false ;
}
// colore
Lib3MF_uint32 pid, pindex ;
if ( pMesh->GetObjectLevelProperty( pid, pindex)) {
Color cCol ;
if ( FindColor( pid, pindex, cCol))
m_pGDB->SetMaterial( nGeoId, cCol) ;
}
// attributes
for ( size_t i = 0 ; i < vAttr.size() ; i++) {
if ( vAttr[i].first == "name")
m_pGDB->SetName( nGeoId, vAttr[i].second) ;
else
m_pGDB->SetInfo( nGeoId, vAttr[i].first, vAttr[i].second) ;
}
return true ;
#endif
} }
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
bool bool
Import3MF::ReadComponents( const Lib3MF_uint32& nId, ATTRVECTOR& attributes, sTransform& sTransfItem) Import3MF::ReadComponent( Lib3MF_uint32 nId, const string& sName, const INFOVECTOR& vInfo, const sTransform& Transform, int nParentId)
{ {
PComponentsObject pComponents = m_model->GetComponentsObjectByID( nId) ; // se va conservata la gerarchia ogni componente corrisponde ad un layer, altrimenti gli elementi della componente vengono
// inseriti direttamente in m_nIdGroup e i suoi attributes vengono ignorati
// Scorro tutte le componenti PComponentsObject pComponents = m_model->GetComponentsObjectByID( nId) ;
for ( Lib3MF_uint32 iC = 0 ; iC < pComponents->GetComponentCount() ; iC ++ ) { if ( pComponents == nullptr)
return false ;
int nLayerId = nParentId ;
// se importo gerarchia creo il layer corrispondente alla componente
if ( ( m_nFlag & EI3FLAG_KEEP_GROUPS) != 0) {
nLayerId = m_pGDB->AddGroup( GDB_ID_NULL, nParentId, GLOB_FRM) ;
// assegno nome e info
if ( ! sName.empty())
m_pGDB->SetName( nLayerId, sName) ;
for ( int i = 0 ; i < int( vInfo.size()) ; i++)
m_pGDB->SetInfo( nLayerId, vInfo[i].first, vInfo[i].second) ;
}
// scorro tutti i suoi oggetti
for ( Lib3MF_uint32 nC = 0 ; nC < pComponents->GetComponentCount() ; nC++) {
PComponent pComponent = pComponents->GetComponent( iC) ; PComponent pComponent = pComponents->GetComponent( nC) ;
sTransform sTransfComp = pComponent->GetTransform() ; // combino le trasformazioni
// combino le trasformazioni sTransform TransfComp = pComponent->GetTransform() ;
sTransform sTransfRes ; sTransform TransfRes ;
// inizializzo sTransfRes a zero // inizializzo TransfRes a zero
for ( Lib3MF_uint32 i = 0 ; i < 4 ; i++) for ( Lib3MF_uint32 i = 0 ; i < 4 ; i++)
fill( sTransfRes.m_Fields[i], sTransfRes.m_Fields[i] + 3, ( Lib3MF_single)0.0) ; fill( TransfRes.m_Fields[i], TransfRes.m_Fields[i] + 3, ( Lib3MF_single) 0.0) ;
for ( Lib3MF_uint32 i = 0 ; i < 4 ; i ++) for ( Lib3MF_uint32 i = 0 ; i < 4 ; i ++)
for ( Lib3MF_uint32 j = 0 ; j < 3 ; j++) for ( Lib3MF_uint32 j = 0 ; j < 3 ; j++)
for ( Lib3MF_uint32 k = 0 ; k < 3 ; k ++) for ( Lib3MF_uint32 k = 0 ; k < 3 ; k ++)
sTransfRes.m_Fields[i][j] += sTransfComp.m_Fields[i][k] * sTransfItem.m_Fields[k][j] ; // prodotto fra matrici TransfRes.m_Fields[i][j] += TransfComp.m_Fields[i][k] * Transform.m_Fields[k][j] ; // prodotto fra matrici
for ( Lib3MF_uint32 j = 0 ; j < 3 ; j ++) for ( Lib3MF_uint32 j = 0 ; j < 3 ; j ++)
sTransfRes.m_Fields[3][j] += sTransfItem.m_Fields[3][j] ; TransfRes.m_Fields[3][j] += Transform.m_Fields[3][j] ;
if ( ! ReadObject( pComponent->GetObjectResource(), attributes, sTransfRes)) if ( ! ReadObject( pComponent->GetObjectResource(), TransfRes, nLayerId))
return false ; return false ;
} }
return true ; return true ;
} }
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
bool bool
Import3MF::FindColor( const Lib3MF_uint32& pid, const Lib3MF_uint32& pindex, Color& cCol) Import3MF::FindColor( Lib3MF_uint32 pid, Lib3MF_uint32 pindex, Color& cCol) const
{ {
sColor sCol ; sColor sCol ;
@@ -431,12 +351,12 @@ Import3MF::FindColor( const Lib3MF_uint32& pid, const Lib3MF_uint32& pindex, Col
// multiproperty corrispondente a pindex // multiproperty corrispondente a pindex
UINTVECTOR pindices ; UINTVECTOR pindices ;
pMultiPropGrp->GetMultiProperty( pindex, pindices) ; pMultiPropGrp->GetMultiProperty( pindex, pindices) ;
// analizzo i layers alla ricerca di una proprietà che definisca un colore // analizzo i layers alla ricerca di una proprietà che definisca un colore
Lib3MF_uint32 nLayers = pMultiPropGrp->GetLayerCount() ; Lib3MF_uint32 nLayers = pMultiPropGrp->GetLayerCount() ;
for ( Lib3MF_uint32 i = 0 ; i < nLayers ; i ++) { for ( Lib3MF_uint32 i = 0 ; i < nLayers ; i ++) {
sMultiPropertyLayer layer = pMultiPropGrp->GetLayer( i) ; sMultiPropertyLayer layer = pMultiPropGrp->GetLayer( i) ;
Lib3MF_uint32 pidLayer = layer.m_ResourceID ; Lib3MF_uint32 pidLayer = layer.m_ResourceID ;
// appena trovo una propietà che definisce un colore mi fermo // appena trovo una propietà che definisce un colore mi fermo
if ( m_model->GetPropertyTypeByID( pidLayer) == ePropertyType::BaseMaterial || if ( m_model->GetPropertyTypeByID( pidLayer) == ePropertyType::BaseMaterial ||
m_model->GetPropertyTypeByID( pidLayer) == ePropertyType::Colors) m_model->GetPropertyTypeByID( pidLayer) == ePropertyType::Colors)
return FindColor( pidLayer, pindices[i], cCol) ; return FindColor( pidLayer, pindices[i], cCol) ;
@@ -453,19 +373,19 @@ Import3MF::FindColor( const Lib3MF_uint32& pid, const Lib3MF_uint32& pindex, Col
// check sui valori in vComposite // check sui valori in vComposite
double dMixSum = 0.0 ; double dMixSum = 0.0 ;
for( size_t i = 0 ; i < vComposite.size(); i ++) for( int i = 0 ; i < int( vComposite.size()) ; i ++)
dMixSum += vComposite[i].m_MixingRatio ; dMixSum += vComposite[i].m_MixingRatio ;
// se fossero tutti zero, considero proporzioni uguali per ogni colore // se fossero tutti zero, considero proporzioni uguali per ogni colore
if ( abs( dMixSum) < EPS_SMALL) { if ( abs( dMixSum) < EPS_SMALL) {
dMixSum = vComposite.size() ; dMixSum = vComposite.size() ;
for ( size_t i = 0 ; i < vComposite.size() ; i++) for ( int i = 0 ; i < int( vComposite.size()) ; i++)
vComposite[i].m_MixingRatio = 1 ; vComposite[i].m_MixingRatio = 1 ;
} }
double dRed = 0.0, dGreen = 0.0, dBlue = 0.0, dAlpha = 0.0 ; // colore finale double dRed = 0.0, dGreen = 0.0, dBlue = 0.0, dAlpha = 0.0 ; // colore finale
Lib3MF_uint8 nRedTmp, nGreenTmp, nBlueTmp, nAlphaTmp ; // colore del BaseMaterial Lib3MF_uint8 nRedTmp, nGreenTmp, nBlueTmp, nAlphaTmp ; // colore del BaseMaterial
// per ogni elemento di composite aggiungo il suo colore con l'opportuno coefficiente // per ogni elemento di composite aggiungo il suo colore con l'opportuno coefficiente
for ( size_t i = 0 ; i < vComposite.size() ; i++) { for ( int i = 0 ; i < int( vComposite.size()) ; i++) {
sCol = pBaseMatGrp->GetDisplayColor( vComposite[i].m_PropertyID) ; sCol = pBaseMatGrp->GetDisplayColor( vComposite[i].m_PropertyID) ;
m_wrapper->ColorToRGBA( sCol, nRedTmp, nGreenTmp, nBlueTmp, nAlphaTmp) ; m_wrapper->ColorToRGBA( sCol, nRedTmp, nGreenTmp, nBlueTmp, nAlphaTmp) ;
double dMixingRatio = vComposite[i].m_MixingRatio / dMixSum ; double dMixingRatio = vComposite[i].m_MixingRatio / dMixSum ;
@@ -490,31 +410,3 @@ Import3MF::FindColor( const Lib3MF_uint32& pid, const Lib3MF_uint32& pindex, Col
return true ; return true ;
} }
//----------------------------------------------------------------------------------------------------
bool
Import3MF::ReadMetaDataGroup( const PMetaDataGroup pMetaDataGrp, ATTRVECTOR& vAttr, const MDGCaller& caller)
{
for ( Lib3MF_uint32 i = 0 ; i < pMetaDataGrp->GetMetaDataCount() ; i ++) {
PMetaData metaData = pMetaDataGrp->GetMetaData( i) ;
string sMetaDataValue = metaData->GetValue() ;
if ( sMetaDataValue.empty())
continue ;
string sMetaDataName ;
switch ( caller) {
case Item :
sMetaDataName = "Item " ;
break ;
case Component :
sMetaDataName = "Object " ;
break ;
case Mesh :
sMetaDataName = "" ;
}
sMetaDataName += metaData->GetName() ;
vAttr.push_back( make_pair( sMetaDataName, sMetaDataValue)) ;
}
return true ;
}
+16 -19
View File
@@ -13,39 +13,36 @@
#pragma once #pragma once
#include <unordered_map>
#include "/EgtDev/Include/EExImport3MF.h"
#include "pugixml.hpp"
#include "/EgtDev/Extern/libzip/Include/zip.h"
#define NOMINMAX #define NOMINMAX
#include "/EgtDev/Extern/Lib3MF/Include/lib3mf_implicit.hpp"
#include "/EgtDev/Include/EExImport3MF.h"
#include "/EgtDev/Extern/lib3MF/Include/lib3mf_implicit.hpp"
#include <unordered_map>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class Import3MF : public IImport3MF class Import3MF : public IImport3MF
{ {
private : private :
typedef std::vector<std::pair<std::string, std::string>> ATTRVECTOR ; typedef std::vector<std::pair<std::string, std::string>> INFOVECTOR ;
enum MDGCaller { Item = 0, Component = 1, Mesh = 2 } ;
public : public :
virtual bool Import( const std::string& sFile, IGeomDB* pGDB, int nIdGroup) ; virtual bool Import( const std::string& sFile, IGeomDB* pGDB, int nIdGroup, int nFlag = 0) ;
private : private :
bool DoImport( const std::string& sFile) ; bool DoImport( const std::string& sFile) ;
bool ReadItem( const Lib3MF::PBuildItem item) ; bool ReadObject( const Lib3MF::PObject pObj, const Lib3MF::sTransform& Transform, int nParentId) ;
bool ReadObject( const Lib3MF::PObject pObj, ATTRVECTOR& vAttr, Lib3MF::sTransform& sTransf) ; bool ReadComponent( Lib3MF_uint32 nId, const std::string& sName, const INFOVECTOR& vInfo, const Lib3MF::sTransform& Transform,
bool ReadComponents( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, Lib3MF::sTransform& sTransfItem) ; int nParentId) ;
bool ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, Lib3MF::sTransform& sTransfr) ; bool ReadMesh( Lib3MF_uint32 nId, const std::string& sName, const INFOVECTOR& vInfo, const Lib3MF::sTransform& Transfrorm,
bool ReadMetaDataGroup( const Lib3MF::PMetaDataGroup pMetaDataGrp, ATTRVECTOR& vAttr, const MDGCaller& caller) ; int nParentId) ;
bool FindColor( const Lib3MF_uint32& pid, const Lib3MF_uint32& pindex, Color& cCol) ; bool FindColor( Lib3MF_uint32 pid, Lib3MF_uint32 pindex, Color& cCol) const ;
private : private :
double m_nScaleFactor ; double m_dScaleFactor ;
IGeomDB* m_pGDB ; IGeomDB* m_pGDB ;
int m_nIdGroup ; int m_nIdGroup ;
int m_nFlag ;
Lib3MF::PWrapper m_wrapper ; Lib3MF::PWrapper m_wrapper ;
Lib3MF::PModel m_model ; Lib3MF::PModel m_model ;
} ; } ;
+53 -13
View File
@@ -20,9 +20,8 @@
#include "/EgtDev/Include/EGkStmStandard.h" #include "/EgtDev/Include/EGkStmStandard.h"
#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringEncoder.h"
#include "/EgtDev/Include/EgtStringEncoder.h" #include "/EgtDev/Include/EgtStringEncoder.h"
#include "/EgtDev/Include/EgtNumUtils.h"
using namespace std ; using namespace std ;
@@ -34,6 +33,15 @@ SetBtlAuxDir( const string& sBtlAuxDir)
return ExistsDirectory( sBtlAuxDir) ; return ExistsDirectory( sBtlAuxDir) ;
} }
//----------------------------------------------------------------------------
bool
SetBtlLuaData( const string& sLuaLibsDir, const string& sLuaLastRequire)
{
BtlGeom::m_sBtlLuaLibsDir = sLuaLibsDir ;
BtlGeom::m_sBtlLuaLastRequire = sLuaLastRequire ;
return ExistsDirectory( sLuaLibsDir) ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
IImportBtl* IImportBtl*
CreateImportBtl( void) CreateImportBtl( void)
@@ -49,6 +57,7 @@ CreateImportBtl( void)
ImportBtl::ImportBtl( void) ImportBtl::ImportBtl( void)
{ {
m_nBuild = 10000 ; m_nBuild = 10000 ;
m_nEdition = 0 ;
m_dScale = 1 ; m_dScale = 1 ;
} }
@@ -78,7 +87,8 @@ ImportBtl::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
bool bSpecialTrim = (( nFlag & EIBFLAG_SPECIAL_TRIM) != 0) ; bool bSpecialTrim = (( nFlag & EIBFLAG_SPECIAL_TRIM) != 0) ;
bool bTrimWithOutline = (( nFlag & EIBFLAG_TRIM_WITH_OUTLINE) != 0) ; bool bTrimWithOutline = (( nFlag & EIBFLAG_TRIM_WITH_OUTLINE) != 0) ;
bool bUseUAttr = (( nFlag & EIBFLAG_USEUATTR) != 0) ; bool bUseUAttr = (( nFlag & EIBFLAG_USEUATTR) != 0) ;
if ( ! m_BtlGeom.Init( pGDB, nFlatVertPos, bSpecialTrim, bTrimWithOutline, bUseUAttr)) { bool bPartOffset = (( nFlag & EIBFLAG_PARTOFFSET) != 0) ;
if ( ! m_BtlGeom.Init( pGDB, nFlatVertPos, bSpecialTrim, bTrimWithOutline, bUseUAttr, bPartOffset, true)) {
LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init") LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init")
return false ; return false ;
} }
@@ -299,7 +309,7 @@ ImportBtl::ReadGeneral( bool& bEnd)
Trim( sVal, " \t\r\n\"") ; Trim( sVal, " \t\r\n\"") ;
int nUnit ; int nUnit ;
if ( FromString( sVal, nUnit)) { if ( FromString( sVal, nUnit)) {
m_dScale = pow( 10, - nUnit) ; m_dScale = Pow( 10, -nUnit) ;
++ nRead ; ++ nRead ;
} }
m_BtlGeom.SetUserAttribute( UATD_INFO, sKey, sVal) ; m_BtlGeom.SetUserAttribute( UATD_INFO, sKey, sVal) ;
@@ -527,8 +537,14 @@ ImportBtl::ReadObject( ObjType nType, bool& bEnd)
m_BtlGeom.SetUserAttribute( UATD_PART, sKey, sVal) ; m_BtlGeom.SetUserAttribute( UATD_PART, sKey, sVal) ;
break ; break ;
case KEY_PART_PARTOFFSET : // offset pezzo case KEY_PART_PARTOFFSET : // offset pezzo
Trim( sVal, " \t\r\n\"") ; {
m_BtlGeom.SetUserAttribute( UATD_PART, sKey, sVal) ; DBLVECTOR vdPar ;
if ( ReadPartOffset( sVal, vdPar)) {
m_BtlGeom.AddPartOffset( vdPar) ;
string sVal = ToString( vdPar) ;
m_BtlGeom.SetUserAttribute( UATD_PART, sPartKey[KEY_PART_PARTOFFSET], sVal) ;
}
}
break ; break ;
case KEY_PART_PROCESSINGQUALITY : // qualità di lavorazione case KEY_PART_PROCESSINGQUALITY : // qualità di lavorazione
Trim( sVal, " \t\r\n\"") ; Trim( sVal, " \t\r\n\"") ;
@@ -676,6 +692,21 @@ ImportBtl::ReadTransformation( const string& sVal, Frame3d& frRef)
return frRef.Set( ptO, ptO + vtX, ptO + vtY) ; return frRef.Set( ptO, ptO + vtX, ptO + vtY) ;
} }
//----------------------------------------------------------------------------
bool
ImportBtl::ReadPartOffset( const string& sVal, DBLVECTOR& vdPar)
{
// assegno i valori di default
vdPar = { 0, 0, 0, 0, 0} ;
// leggo i valori
GetParamP( sVal, 4, vdPar[0]) ;
GetParamP( sVal, 11, vdPar[1]) ;
GetParamP( sVal, 12, vdPar[2]) ;
GetParamP( sVal, 13, vdPar[3]) ;
GetParamP( sVal, 14, vdPar[4]) ;
return true ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
ImportBtl::ReadOutline( void) ImportBtl::ReadOutline( void)
@@ -704,6 +735,18 @@ ImportBtl::ReadOutline( void)
break ; break ;
} }
// leggo i dati // leggo i dati
// leggo faccia di riferimento
int nCurrSide ;
if ( GetInfo( sVal, PAR_SIDE, nCurrSide)) {
// se non ancora assegnata
if ( nSide == BTL_SIDE_NONE)
nSide = nCurrSide ;
// altrimenti è un nuovo outline, si assegna questo e si esce
else if ( nSide != nCurrSide) {
m_theScanner.UngetLine( sLine) ;
return m_BtlGeom.AddPartOutline( nSide, dqFce, nContType, nContData, dContPar, vsUAtt) ;
}
}
// tipo // tipo
int nFlag ; int nFlag ;
GetParamP( sVal, 8, nFlag) ; GetParamP( sVal, 8, nFlag) ;
@@ -716,9 +759,6 @@ ImportBtl::ReadOutline( void)
bProcFound = true ; bProcFound = true ;
} }
} }
// se non ancora assegnata, leggo faccia di riferimento
if ( nSide == BTL_SIDE_NONE)
GetInfo( sVal, PAR_SIDE, nSide) ;
// punto principale // punto principale
Point3d ptP ; Point3d ptP ;
GetParamP( sVal, 1, ptP.x) ; GetParamP( sVal, 1, ptP.x) ;
@@ -837,13 +877,13 @@ ImportBtl::ReadColor( const string& sVal, Color& colRes)
// leggo i valori // leggo i valori
string sRes ; string sRes ;
GetParam( sVal, PAR_R, sRes) ; GetParam( sVal, PAR_R, sRes) ;
int nRed ; FromString( sRes, nRed) ; int nRed = 0 ; FromString( sRes, nRed) ;
GetParam( sVal, PAR_G, sRes) ; GetParam( sVal, PAR_G, sRes) ;
int nGreen ; FromString( sRes, nGreen) ; int nGreen = 0 ; FromString( sRes, nGreen) ;
GetParam( sVal, PAR_B, sRes) ; GetParam( sVal, PAR_B, sRes) ;
int nBlue ; FromString( sRes, nBlue) ; int nBlue = 0 ; FromString( sRes, nBlue) ;
GetParam( sVal, PAR_A, sRes) ; GetParam( sVal, PAR_A, sRes) ;
int nAlpha ; FromString( sRes, nAlpha) ; nAlpha = nAlpha * 100 / 255 ; int nAlpha = 0 ; FromString( sRes, nAlpha) ; nAlpha = nAlpha * 100 / 255 ;
colRes.Set( nRed, nGreen, nBlue, nAlpha) ; colRes.Set( nRed, nGreen, nBlue, nAlpha) ;
return true ; return true ;
} }
+1
View File
@@ -34,6 +34,7 @@ class ImportBtl : public IImportBtl
bool ReadGeneral( bool& bEnd) ; bool ReadGeneral( bool& bEnd) ;
bool ReadObject( ObjType nType, bool& bEnd) ; bool ReadObject( ObjType nType, bool& bEnd) ;
bool ReadTransformation( const std::string& sVal, Frame3d& frRef) ; bool ReadTransformation( const std::string& sVal, Frame3d& frRef) ;
bool ReadPartOffset( const std::string& sVal, DBLVECTOR& vdPar) ;
bool ReadOutline( void) ; bool ReadOutline( void) ;
bool ReadAperture( void) ; bool ReadAperture( void) ;
bool ReadColor( const std::string& sVal, Color& colRes) ; bool ReadColor( const std::string& sVal, Color& colRes) ;
+232 -266
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -28,7 +28,7 @@ public :
bool ReadFileHistory( pugi::xml_node node) ; bool ReadFileHistory( pugi::xml_node node) ;
bool ReadProjectAttributes( pugi::xml_attribute attr) ; bool ReadProjectAttributes( pugi::xml_attribute attr) ;
bool ReadUserAttributes( pugi::xml_node node, int caller, std::vector<std::string> * pvsAttr = nullptr) ; bool ReadUserAttributes( pugi::xml_node node, int caller, STRVECTOR* pvsAttr = nullptr) ;
bool ReadPart( pugi::xml_node node) ; bool ReadPart( pugi::xml_node node) ;
bool ReadPartAttributes( pugi::xml_attribute attr) ; bool ReadPartAttributes( pugi::xml_attribute attr) ;
bool ReadCamber( pugi::xml_node node) ; bool ReadCamber( pugi::xml_node node) ;
@@ -42,7 +42,7 @@ public :
bool ReadAperture( pugi::xml_node node, int nSide) ; bool ReadAperture( pugi::xml_node node, int nSide) ;
bool ReadUserReferencePlane( pugi::xml_node node) ; bool ReadUserReferencePlane( pugi::xml_node node) ;
bool ReadShape( pugi::xml_node node) ; bool ReadShape( pugi::xml_node node) ;
bool CheckGuid ( std::string s) ; bool CheckGuid( const std::string& s) ;
// processing // processing
bool ReadJackRafterCutParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, bool ReadJackRafterCutParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar,
+132 -123
View File
@@ -30,12 +30,12 @@ using namespace std ;
// ------------------------- Prototipi locali funzioni ausiliarie --------------------------------- // ------------------------- Prototipi locali funzioni ausiliarie ---------------------------------
static int GetGroup12( const pugi::xml_node& process) ; static int GetGroup12( const pugi::xml_node& process) ;
static int GetGroup34( const pugi::xml_node& process) ; static int GetGroup34( const pugi::xml_node& process) ;
static double ReadProcessChild( const pugi::xml_node& process, const string& sChild, const double& dVal) ; static double ReadProcessChild( const pugi::xml_node& process, const string& sChild, double dVal) ;
static double ReadProcessChildAttribute( const pugi::xml_node& process, const string& sChild, const string& sAttribute, const double& dVal) ; static double ReadProcessChildAttribute( const pugi::xml_node& process, const string& sChild, const string& sAttribute, double dVal) ;
static int ReadProcessChildBool( const pugi::xml_node& process, const string& sChild, const int& nDefaultVal, bool bInverted = false) ; static int ReadProcessChildBool( const pugi::xml_node& process, const string& sChild, const int& nDefaultVal, bool bInverted = false) ;
static string ReadProcessChildYesNo( const pugi::xml_node& process, const string& sChild, const string& sVal) ; static string ReadProcessChildYesNo( const pugi::xml_node& process, const string& sChild, const string& sVal) ;
static double ReadProcessChildYesNoToDouble( const pugi::xml_node& process, const string& sChild1, const string& sDefaultOpt, const string& sChild2, static double ReadProcessChildYesNoToDouble( const pugi::xml_node& process, const string& sChild1, const string& sDefaultOpt, const string& sChild2,
const double& nDefaultVal) ; double nDefaultVal) ;
static int ComputeP04( const STRVECTOR& values) ; static int ComputeP04( const STRVECTOR& values) ;
static int ComputeP04( const pugi::xml_node& MachiningLimits) ; static int ComputeP04( const pugi::xml_node& MachiningLimits) ;
@@ -52,7 +52,7 @@ ImportBtlx::ReadJackRafterCutParams( pugi::xml_node process, int& nGroup, int& n
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup12( process) ; nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: JackRafterCut Orientation is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: JackRafterCut Orientation is not valid") ;
return false ; return false ;
} }
@@ -98,9 +98,9 @@ ImportBtlx::ReadLongitudinalCutParams( pugi::xml_node process, int& nGroup, int&
if ( sToolPosition == "center") if ( sToolPosition == "center")
nGroup = 0 ; nGroup = 0 ;
else if ( sToolPosition == "right") else if ( sToolPosition == "right")
nGroup = 3 ;
else if ( sToolPosition == "left")
nGroup = 4 ; nGroup = 4 ;
else if ( sToolPosition == "left")
nGroup = 3 ;
else { else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LongitudinalCut Tool position not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LongitudinalCut Tool position not valid") ;
return false ; return false ;
@@ -126,6 +126,13 @@ ImportBtlx::ReadLongitudinalCutParams( pugi::xml_node process, int& nGroup, int&
vdPar[6] = Clamp( ReadProcessChild( process, "AngleStart", vdPar[6]), 0.1, 179.9) ; // P13 vdPar[6] = Clamp( ReadProcessChild( process, "AngleStart", vdPar[6]), 0.1, 179.9) ; // P13
vdPar[7] = Clamp( ReadProcessChild( process, "AngleEnd", vdPar[7]), 0.1, 179.9) ; // P14 vdPar[7] = Clamp( ReadProcessChild( process, "AngleEnd", vdPar[7]), 0.1, 179.9) ; // P14
if ( vdPar[3] < 0) {
if ( nGroup == 3)
nGroup = 4 ;
else if ( nGroup == 4)
nGroup = 3 ;
}
string sStartLimited = ReadProcessChildYesNo( process, "StartLimited", "no") ; // P04 string sStartLimited = ReadProcessChildYesNo( process, "StartLimited", "no") ; // P04
string sEndLimited = ReadProcessChildYesNo( process, "EndLimited", "no") ; string sEndLimited = ReadProcessChildYesNo( process, "EndLimited", "no") ;
vdPar[2] = ComputeP04( { "no", sStartLimited, sEndLimited}) ; vdPar[2] = ComputeP04( { "no", sStartLimited, sEndLimited}) ;
@@ -148,14 +155,14 @@ ImportBtlx::ReadDoubleCutParams( pugi::xml_node process, int& nGroup, int& nProc
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup12( process) ; nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: DoubleCut orientation unknown") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: DoubleCut orientation unknown") ;
return false ; return false ;
} }
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -191,7 +198,7 @@ ImportBtlx::ReadRidgeValleyCutParams( pugi::xml_node process, int& nGroup, int&
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -288,7 +295,7 @@ ImportBtlx::ReadSlotParams( pugi::xml_node process, int& nGroup, int& nProc, int
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Slot orientation unknown") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Slot orientation unknown") ;
return false ; return false ;
} }
@@ -317,7 +324,7 @@ ImportBtlx::ReadSlotParams( pugi::xml_node process, int& nGroup, int& nProc, int
vdPar[10] = ReadProcessChild( process, "Length", vdPar[10]) ; // P12 vdPar[10] = ReadProcessChild( process, "Length", vdPar[10]) ; // P12
vdPar[11] = ReadProcessChild( process, "Thickness", vdPar[11]) ; // P13 vdPar[11] = ReadProcessChild( process, "Thickness", vdPar[11]) ; // P13
if ( process.child( "MachiningLimits") != nullptr ) { // P04 if ( process.child( "MachiningLimits") != nullptr) { // P04
vdPar[3] = ComputeP04( process.child( "MachiningLimits")) ; vdPar[3] = ComputeP04( process.child( "MachiningLimits")) ;
if ( vdPar[3] == -2) if ( vdPar[3] == -2)
return false ; return false ;
@@ -341,7 +348,7 @@ ImportBtlx::ReadBirdsMouthParams( pugi::xml_node process, int& nGroup, int& nPro
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BirdsMouth orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BirdsMouth orientation unknwon") ;
return false ; return false ;
} }
@@ -388,7 +395,7 @@ ImportBtlx::ReadHipValleyRafterNotchParams( pugi::xml_node process, int& nGroup,
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation unknwon") ;
return false ; return false ;
} }
@@ -437,7 +444,7 @@ ImportBtlx::ReadLapParams( pugi::xml_node process, int& nGroup, int& nProc, int&
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation unknwon") ;
return false ; return false ;
} }
@@ -456,7 +463,7 @@ ImportBtlx::ReadLapParams( pugi::xml_node process, int& nGroup, int& nProc, int&
// Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default // Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
vdPar[0] = Clamp( ReadProcessChild( process, "StartX", vdPar[0]), -100000.0, 100000.0) ; // P01 vdPar[0] = Clamp( ReadProcessChild( process, "StartX", vdPar[0]), -100000.0, 100000.0) ; // P01
vdPar[1] = Clamp( ReadProcessChild( process, "StartY", vdPar[1]), -50000.0, 50000.0) ; // P02 vdPar[1] = Clamp( ReadProcessChild( process, "StartY", vdPar[1]), -50000.0, 50000.0) ; // P02
// vdPar[2] = ? Non c'è StartDepth // vdPar[2] = ? Non c'è StartDepth
vdPar[4] = ReadProcessChild( process, "Angle", vdPar[4]) ; // P04 vdPar[4] = ReadProcessChild( process, "Angle", vdPar[4]) ; // P04
vdPar[5] = ReadProcessChild( process, "Inclination", vdPar[5]) ; // P07 vdPar[5] = ReadProcessChild( process, "Inclination", vdPar[5]) ; // P07
vdPar[6] = ReadProcessChild( process, "Slope", vdPar[6]) ; // P08 vdPar[6] = ReadProcessChild( process, "Slope", vdPar[6]) ; // P08
@@ -467,7 +474,7 @@ ImportBtlx::ReadLapParams( pugi::xml_node process, int& nGroup, int& nProc, int&
// vdPar[11] = ? // vdPar[11] = ?
vdPar[12] = Clamp( ReadProcessChild( process, "Width", vdPar[12]), 0.0, 50000.0) ; // P14 vdPar[12] = Clamp( ReadProcessChild( process, "Width", vdPar[12]), 0.0, 50000.0) ; // P14
if ( process.child( "MachiningLimits") != nullptr ) { if ( process.child( "MachiningLimits") != nullptr) {
vdPar[3] = ComputeP04( process.child( "MachiningLimits")) ; vdPar[3] = ComputeP04( process.child( "MachiningLimits")) ;
if ( vdPar[3] == -2) if ( vdPar[3] == -2)
return false ; return false ;
@@ -489,14 +496,14 @@ ImportBtlx::ReadLogHouseHalfLapParams( pugi::xml_node process, int& nGroup, int&
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseHalfLap orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseHalfLap orientation unknwon") ;
return false ; return false ;
} }
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -529,7 +536,7 @@ ImportBtlx::ReadFrenchRidgeLapParams( pugi::xml_node process, int& nGroup, int&
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup12( process) ; nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FrenchRidgeLap orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FrenchRidgeLap orientation unknwon") ;
return false ; return false ;
} }
@@ -537,7 +544,7 @@ ImportBtlx::ReadFrenchRidgeLapParams( pugi::xml_node process, int& nGroup, int&
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -549,8 +556,7 @@ ImportBtlx::ReadFrenchRidgeLapParams( pugi::xml_node process, int& nGroup, int&
// Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default // Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
vdPar[0] = Clamp( ReadProcessChild( process, "StartX", vdPar[0]), -100000.0, 100000.0) ; // P01 vdPar[0] = Clamp( ReadProcessChild( process, "StartX", vdPar[0]), -100000.0, 100000.0) ; // P01
vdPar[2] = ReadProcessChild( process, "Angle", vdPar[2]) ; // P06 vdPar[2] = ReadProcessChild( process, "Angle", vdPar[2]) ; // P06
vdPar[3] = ReadProcessChild( process, "DrillholeDiam", vdPar[3]) ; // P13 vdPar[3] = ReadProcessChild( process, "DrillholeDiam", vdPar[3]) ; // P13
string sRefPosition = process.child( "RefPosition").text().get() ; // P02 string sRefPosition = process.child( "RefPosition").text().get() ; // P02
if ( sRefPosition == "refedge" || sRefPosition.empty()) if ( sRefPosition == "refedge" || sRefPosition.empty())
@@ -575,10 +581,9 @@ ImportBtlx::ReadChamferParams( pugi::xml_node process, int& nGroup, int& nProc,
nSide = 3 ; // Chamfer non ha un reference plane nSide = 3 ; // Chamfer non ha un reference plane
nGroup = 4 ; // Chamfer non ha orientation ( prendo start) nGroup = 4 ; // Chamfer non ha orientation ( prendo start)
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -596,12 +601,12 @@ ImportBtlx::ReadChamferParams( pugi::xml_node process, int& nGroup, int& nProc,
string sCamferEdge23 = ReadProcessChildYesNo( process, "ChamferEdge23", "yes") ; string sCamferEdge23 = ReadProcessChildYesNo( process, "ChamferEdge23", "yes") ;
string sCamferEdge34 = ReadProcessChildYesNo( process, "ChamferEdge34", "yes") ; string sCamferEdge34 = ReadProcessChildYesNo( process, "ChamferEdge34", "yes") ;
string sCamferEdge41 = ReadProcessChildYesNo( process, "ChamferEdge41", "yes") ; string sCamferEdge41 = ReadProcessChildYesNo( process, "ChamferEdge41", "yes") ;
STRVECTOR values = { sCamferEdge12, sCamferEdge23, sCamferEdge34, sCamferEdge41} ; STRVECTOR vsValues = { sCamferEdge12, sCamferEdge23, sCamferEdge34, sCamferEdge41} ;
vdPar[1] = 0.0 ; vdPar[1] = 0.0 ;
for ( size_t i = 0 ; i < values.size() ; i++) { for ( int i = 0 ; i < ssize( vsValues) ; i++) {
if ( values[i] == "yes") if ( vsValues[i] == "yes")
vdPar[1] += pow( 2, i) ; vdPar[1] += Pow( 2, i) ;
else if ( values[i] != "no") { else if ( vsValues[i] != "no") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ChamferEdge value is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ChamferEdge value is not valid") ;
return false ; return false ;
} }
@@ -638,11 +643,11 @@ ImportBtlx::ReadLogHouseJointParams( pugi::xml_node process, int& nGroup, int& n
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
if ( vdPar.size() != 15) { if ( vdPar.size() != 16) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseJoint number of parameters is wrong") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseJoint number of parameters is wrong") ;
return false ; return false ;
} }
@@ -700,14 +705,14 @@ ImportBtlx::ReadLogHouseFrontParams( pugi::xml_node process, int& nGroup, int& n
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseFront orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseFront orientation unknwon") ;
return false ; return false ;
} }
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -744,7 +749,7 @@ ImportBtlx::ReadPocketParams( pugi::xml_node process, int& nGroup, int& nProc, i
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -768,8 +773,7 @@ ImportBtlx::ReadPocketParams( pugi::xml_node process, int& nGroup, int& nProc, i
vdPar[2] = ComputeP04( process.child( "MachiningLimits")) ; vdPar[2] = ComputeP04( process.child( "MachiningLimits")) ;
if ( vdPar[2] == -2) if ( vdPar[2] == -2)
return false ; return false ;
} }
return true ; return true ;
} }
@@ -790,7 +794,7 @@ ImportBtlx::ReadDrillingParams( pugi::xml_node process, int& nGroup, int& nProc,
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -885,12 +889,11 @@ ImportBtlx::ReadMortiseParams( pugi::xml_node process, int& nGroup, int& nProc,
return false ; return false ;
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = 4 ; nGroup = 4 ;
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -911,7 +914,6 @@ ImportBtlx::ReadMortiseParams( pugi::xml_node process, int& nGroup, int& nProc,
vdPar[10] = Clamp( ReadProcessChild( process, "Length", vdPar[10]), 0.0, 50000.0) ; // P13 vdPar[10] = Clamp( ReadProcessChild( process, "Length", vdPar[10]), 0.0, 50000.0) ; // P13
vdPar[13] = Clamp( ReadProcessChild( process, "Slope", vdPar[13]), 0.1, 179.9) ; // P16 vdPar[13] = Clamp( ReadProcessChild( process, "Slope", vdPar[13]), 0.1, 179.9) ; // P16
string sShape = process.child( "Shape").text().get() ; // P04 string sShape = process.child( "Shape").text().get() ; // P04
if ( sShape == "automatic" || sShape.empty()) if ( sShape == "automatic" || sShape.empty())
vdPar[3] = 0 ; vdPar[3] = 0 ;
@@ -940,7 +942,7 @@ bool
ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide,
INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar) INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{ {
// Identifico il processo con sigle usate nel btl // Identifico il processo con codici usate nel btl
nProc = 55 ; nProc = 55 ;
if ( process.attribute( "ReferencePlaneID") == nullptr) { if ( process.attribute( "ReferencePlaneID") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
@@ -948,7 +950,7 @@ ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& n
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup12( process) ; nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Orientation unknown") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Orientation unknown") ;
return false ; return false ;
} }
@@ -986,13 +988,14 @@ ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& n
} }
else if ( sShape == "radius" || sShape == "rounded" || sShape == "square" ) { else if ( sShape == "radius" || sShape == "rounded" || sShape == "square" ) {
if ( sShape != "radius") // P12 if ( sShape != "radius") // P12
vdPar[9] = MILL_DEF_RAD ; vdPar[9] = DTMILL_DEF_RAD ;
vdPar[9] *= 2 ; vdPar[9] *= 2 ;
vdPar[6] = dWidth - vdPar[9] * ( 1 - sin( vdPar[7] * DEGTORAD)) / cos( vdPar[7] * DEGTORAD) ; // P09 vdPar[6] = dWidth - vdPar[9] * ( 1 - sin( vdPar[7] * DEGTORAD)) / cos( vdPar[7] * DEGTORAD) ; // P09
if ( vdPar[6] < 0 ) { if ( vdPar[6] < -10 * EPS_SMALL) {
LOG_ERROR( GetEExLogger(), " Error : Dovetail tenon width") ; LOG_ERROR( GetEExLogger(), " Error : Dovetail tenon width") ;
return false ; return false ;
} }
vdPar[6] = max( vdPar[6], 0.) ;
} }
else { else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail Tenon Shape is unknown") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail Tenon Shape is unknown") ;
@@ -1058,13 +1061,14 @@ ImportBtlx::ReadDovetailMortiseParams( pugi::xml_node process, int& nGroup, int&
} }
else if ( sShape == "radius" || sShape == "rounded" || sShape == "square") { else if ( sShape == "radius" || sShape == "rounded" || sShape == "square") {
if ( sShape != "radius") // P12 if ( sShape != "radius") // P12
vdPar[10] = MILL_DEF_RAD ; vdPar[10] = DTMILL_DEF_RAD ;
vdPar[10] *= 2 ; // P12 vdPar[10] *= 2 ; // P12
vdPar[7] = dWidth - vdPar[10] * ( 1 - sin( vdPar[8] * DEGTORAD)) / cos( vdPar[8] * DEGTORAD) ; // P09 vdPar[7] = dWidth - vdPar[10] * ( 1 - sin( vdPar[8] * DEGTORAD)) / cos( vdPar[8] * DEGTORAD) ; // P09
if ( vdPar[7] < - EPS_SMALL) { if ( vdPar[7] < - 10 * EPS_SMALL) {
LOG_ERROR( GetEExLogger(), " Error : Dovetail mortise width") ; LOG_ERROR( GetEExLogger(), " Error : Dovetail mortise width") ;
return false ; return false ;
} }
vdPar[7] = max( vdPar[7], 0.) ;
} }
else { else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail mortise Shape is unknown") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail mortise Shape is unknown") ;
@@ -1085,7 +1089,7 @@ ImportBtlx::ReadMarkingParams( pugi::xml_node process, int& nGroup, int& nProc,
{ {
// Identifico il processo con sigle usate nel btl // Identifico il processo con sigle usate nel btl
nProc = 60 ; nProc = 60 ;
if ( process.attribute( "ReferencePlaneID") == nullptr){ if ( process.attribute( "ReferencePlaneID") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ; return false ;
} }
@@ -1123,7 +1127,7 @@ ImportBtlx::ReadMarkingParams( pugi::xml_node process, int& nGroup, int& nProc,
if ( nGroup == 4) if ( nGroup == 4)
vtD.Mirror( X_AX) ; vtD.Mirror( X_AX) ;
if ( sLimited == "no" || sLimited.empty()) if ( sLimited == "no" || sLimited.empty())
vdPar[6] = 0.0 ; // la funzione AddMarking sistemerà il valore in base alla lunghezza del lato vdPar[6] = 0.0 ; // la funzione AddMarking sistemerà il valore in base alla lunghezza del lato
else if ( sLimited == "yes") else if ( sLimited == "yes")
if ( abs( vdPar[3]) < EPS_SMALL) if ( abs( vdPar[3]) < EPS_SMALL)
vdPar[6] = dLength ; vdPar[6] = dLength ;
@@ -1177,7 +1181,7 @@ ImportBtlx::ReadTextParams( pugi::xml_node process, int& nGroup, int& nProc, int
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -1255,7 +1259,7 @@ ImportBtlx::ReadSimpleScarfParams( pugi::xml_node process, int& nGroup, int& nPr
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -1288,7 +1292,7 @@ ImportBtlx::ReadScarfJointParams( pugi::xml_node process, int& nGroup, int& nPro
} }
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup12( process) ; nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon orientation unknwon") ;
return false ; return false ;
} }
@@ -1312,8 +1316,7 @@ ImportBtlx::ReadScarfJointParams( pugi::xml_node process, int& nGroup, int& nPro
vdPar[5] = ReadProcessChild( process, "DepthOppSide", vdPar[5]) ; // P12 vdPar[5] = ReadProcessChild( process, "DepthOppSide", vdPar[5]) ; // P12
vdPar[6] = ReadProcessChild( process, "Length", vdPar[6]) ; // P13 vdPar[6] = ReadProcessChild( process, "Length", vdPar[6]) ; // P13
vdPar[7] = ReadProcessChild( process, "DrillHoleDiam1", vdPar[7]) ; // P14 vdPar[7] = ReadProcessChild( process, "DrillHoleDiam1", vdPar[7]) ; // P14
vdPar[8] = ReadProcessChild( process, "DrillHoleDiam2", vdPar[8]) ; // P15 vdPar[8] = ReadProcessChild( process, "DrillHoleDiam2", vdPar[8]) ; // P15
string sScarfShape = process.child( "ScarfShape").text().get() ; // P09 string sScarfShape = process.child( "ScarfShape").text().get() ; // P09
if ( sScarfShape == "classic") if ( sScarfShape == "classic")
@@ -1337,7 +1340,7 @@ ImportBtlx::ReadStepJointParams( pugi::xml_node process, int& nGroup, int& nProc
{ {
// Identifico il processo con sigle usate nel btl // Identifico il processo con sigle usate nel btl
nProc = 80 ; nProc = 80 ;
if ( process.attribute( "ReferencePlaneID") == nullptr){ if ( process.attribute( "ReferencePlaneID") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ; return false ;
} }
@@ -1350,7 +1353,7 @@ ImportBtlx::ReadStepJointParams( pugi::xml_node process, int& nGroup, int& nProc
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -1389,7 +1392,7 @@ ImportBtlx::ReadStepJointNotchParams( pugi::xml_node process, int& nGroup, int&
{ {
// Identifico il processo con sigle usate nel btl // Identifico il processo con sigle usate nel btl
nProc = 80 ; nProc = 80 ;
if ( process.attribute( "ReferencePlaneID") == nullptr){ if ( process.attribute( "ReferencePlaneID") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ; return false ;
} }
@@ -1402,7 +1405,7 @@ ImportBtlx::ReadStepJointNotchParams( pugi::xml_node process, int& nGroup, int&
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -1447,7 +1450,7 @@ ImportBtlx::ReadPlaningParams( pugi::xml_node process, int& nGroup, int& nProc,
{ {
// Identifico il processo con sigle usate nel btl // Identifico il processo con sigle usate nel btl
nProc = 90 ; nProc = 90 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = BTL_SIDE_FRONT ;
nGroup = 4 ; nGroup = 4 ;
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
@@ -1486,7 +1489,7 @@ ImportBtlx::ReadProfileFrontParams( pugi::xml_node process, int& nGroup, int& nP
nProc = 100 ; nProc = 100 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileFront orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileFront orientation unknwon") ;
return false ; return false ;
} }
@@ -1523,14 +1526,14 @@ ImportBtlx::ReadProfileCamberedParams( pugi::xml_node process, int& nGroup, int&
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileCambered orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileCambered orientation unknwon") ;
return false ; return false ;
} }
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -1547,7 +1550,6 @@ ImportBtlx::ReadProfileCamberedParams( pugi::xml_node process, int& nGroup, int&
vdPar[4] = Clamp( ReadProcessChild( process, "MinDepth", vdPar[4]), 0.0, 1000.0) ; // P13 vdPar[4] = Clamp( ReadProcessChild( process, "MinDepth", vdPar[4]), 0.0, 1000.0) ; // P13
vdPar[5] = Clamp( ReadProcessChild( process, "EndDepth", vdPar[5]), 0.0, 1000.0) ; // P14 vdPar[5] = Clamp( ReadProcessChild( process, "EndDepth", vdPar[5]), 0.0, 1000.0) ; // P14
string sPremill = process.child( "Premill").text().get() ; // P15 string sPremill = process.child( "Premill").text().get() ; // P15
if ( sPremill == "round") if ( sPremill == "round")
vdPar[6] = 0 ; vdPar[6] = 0 ;
@@ -1587,6 +1589,10 @@ ImportBtlx::ReadRoundArchParams( pugi::xml_node process, int& nGroup, int& nProc
vdPar[1] = Clamp( ReadProcessChild( process, "Camber", vdPar[1]), 0.0, 1000.0) ; // P11 vdPar[1] = Clamp( ReadProcessChild( process, "Camber", vdPar[1]), 0.0, 1000.0) ; // P11
vdPar[2] = ReadProcessChild( process, "Length", vdPar[2]) ; // P12 vdPar[2] = ReadProcessChild( process, "Length", vdPar[2]) ; // P12
string sArcShape = process.child( "ArcShape").text().get() ;
if ( sArcShape == "convex")
vdPar[1] = -vdPar[1] ;
return true ; return true ;
} }
@@ -1599,7 +1605,7 @@ ImportBtlx::ReadProfileHeadParams( pugi::xml_node process, int& nGroup, int& nPr
nProc = 106 ; nProc = 106 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileHead orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileHead orientation unknwon") ;
return false ; return false ;
} }
@@ -1687,14 +1693,14 @@ ImportBtlx::ReadSphereParams( pugi::xml_node process, int& nGroup, int& nProc, i
nProc = 107 ; nProc = 107 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ; nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ; nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) { if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Sphere orientation unknwon") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Sphere orientation unknwon") ;
return false ; return false ;
} }
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -1726,7 +1732,7 @@ ImportBtlx::ReadTriangleCutParams( pugi::xml_node process, int& nGroup, int& nPr
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -1817,7 +1823,7 @@ ImportBtlx::ReadTyroleanDovetailParams( pugi::xml_node process, int& nGroup, int
vdPar[4] = -1 ; vdPar[4] = -1 ;
else if ( sLapExit == "rebate") { else if ( sLapExit == "rebate") {
if ( process.child( "RebateLength") != nullptr) if ( process.child( "RebateLength") != nullptr)
vdPar[4] = std::stod( process.child( "RebateLength").text().get()) ; FromString( process.child( "RebateLength").text().get(), vdPar[4]) ;
else else
vdPar[4] = 10.0 ; // valore di default vdPar[4] = 10.0 ; // valore di default
} }
@@ -1864,13 +1870,13 @@ ImportBtlx::ReadDovetailParams( pugi::xml_node process, int& nGroup, int& nProc,
if ( sCutOff.empty()) if ( sCutOff.empty())
sCutOff = "no" ; // se non ci fosse, valore di default sCutOff = "no" ; // se non ci fosse, valore di default
if( sOrientation == "end" && sCutOff == "yes") if( sOrientation == "end" && sCutOff == "yes")
nGroup = 1 ; nGroup = 1 ;
else if (sOrientation == "start" && sCutOff == "yes") else if ( sOrientation == "start" && sCutOff == "yes")
nGroup = 2 ; nGroup = 2 ;
else if (sOrientation == "end" && sCutOff == "no") else if ( sOrientation == "end" && sCutOff == "no")
nGroup = 3 ; nGroup = 3 ;
else if (sOrientation == "start" && sCutOff == "yes") else if ( sOrientation == "start" && sCutOff == "yes")
nGroup = 4 ; nGroup = 4 ;
else { else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail group not defined") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail group not defined") ;
@@ -1879,7 +1885,7 @@ ImportBtlx::ReadDovetailParams( pugi::xml_node process, int& nGroup, int& nProc,
// Inizializzo i vettori dei parametri // Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ; bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){ if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ; return false ;
} }
@@ -1924,7 +1930,7 @@ ImportBtlx::ReadDovetailParams( pugi::xml_node process, int& nGroup, int& nProc,
vdPar[4] = -1 ; vdPar[4] = -1 ;
else if ( sLapExit == "rebate") { else if ( sLapExit == "rebate") {
if ( process.child( "RebateLength") != nullptr) if ( process.child( "RebateLength") != nullptr)
vdPar[4] = std::stod( process.child( "RebateLength").text().get()) ; FromString( process.child( "RebateLength").text().get(), vdPar[4]) ;
else else
vdPar[4] = 10.0 ; // valore di default vdPar[4] = 10.0 ; // valore di default
} }
@@ -1982,14 +1988,14 @@ ImportBtlx::ReadFreeContourParams( pugi::xml_node process, const STRVECTOR& vsUA
// scrorro i contours // scrorro i contours
for ( pugi::xml_node_iterator it = process.begin() ; it != process.end() ; it ++) { for ( pugi::xml_node_iterator it = process.begin() ; it != process.end() ; it ++) {
string itName = it->name() ; string sName = it->name() ;
bool bContOk = true ; bool bContOk = true ;
if ( itName == "Contour") { if ( sName == "Contour") {
bContOk = ReadSContourParams( *it, 0, 0, nGroup, nProc, nSide, bCounterSink, nCrvCnt, vsUAtt) ; bContOk = ReadSContourParams( *it, 0, 0, nGroup, nProc, nSide, bCounterSink, nCrvCnt, vsUAtt) ;
if ( ! bContOk) if ( ! bContOk)
return false ; return false ;
} }
else if ( itName == "DualContour") { else if ( sName == "DualContour") {
bContOk = ReadDContourParams( *it, nGroup, nProc, nSide, bCounterSink, nCrvCnt, vsUAtt) ; bContOk = ReadDContourParams( *it, nGroup, nProc, nSide, bCounterSink, nCrvCnt, vsUAtt) ;
if ( ! bContOk) if ( ! bContOk)
return false ; return false ;
@@ -2018,7 +2024,7 @@ ImportBtlx::ReadSContourParams( pugi::xml_node process, int nType, int nOtherId,
} }
frRef = m_mapRefPlanes[nSide] ; frRef = m_mapRefPlanes[nSide] ;
if ( ! frRef.IsValid()) { if ( ! frRef.IsValid()) {
LOG_ERROR( GetEExLogger(), (" Error reading Part Process: FreeContour User Reference Plane " + to_string( nSide) + " is not valid").c_str()) ; LOG_ERROR( GetEExLogger(), ( " Error reading Part Process: FreeContour User Reference Plane " + to_string( nSide) + " is not valid").c_str()) ;
return false ; return false ;
} }
} }
@@ -2206,17 +2212,20 @@ GetGroup34( const pugi::xml_node& process)
//--------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------
double double
ReadProcessChild( const pugi::xml_node& process, const string& sChild, const double& dVal) ReadProcessChild( const pugi::xml_node& process, const string& sChild, double dVal)
{ {
if ( process.child( sChild.c_str()) != nullptr && process.child( sChild.c_str()).text().get() != '\0') if ( process.child( sChild.c_str()) != nullptr && process.child( sChild.c_str()).text().get() != nullptr) {
return std::stod( process.child( sChild.c_str()).text().get()) ; double dRes = dVal ;
FromString( process.child( sChild.c_str()).text().get(), dRes) ;
return dRes ;
}
else else
return dVal ; return dVal ;
} }
//--------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------
double double
ReadProcessChildAttribute( const pugi::xml_node& process, const string& sChild, const string& sAttribute, const double& dVal) ReadProcessChildAttribute( const pugi::xml_node& process, const string& sChild, const string& sAttribute, double dVal)
{ {
if ( process.child( sChild.c_str()) != nullptr && process.child( sChild.c_str()).attribute( sAttribute.c_str()) != nullptr) if ( process.child( sChild.c_str()) != nullptr && process.child( sChild.c_str()).attribute( sAttribute.c_str()) != nullptr)
return process.child( sChild.c_str()).attribute( sAttribute.c_str()).as_double() ; return process.child( sChild.c_str()).attribute( sAttribute.c_str()).as_double() ;
@@ -2259,7 +2268,7 @@ ReadProcessChildYesNo( const pugi::xml_node& process, const string& sChild, cons
//--------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------
double double
ReadProcessChildYesNoToDouble( const pugi::xml_node& process, const string& sChild1, const string& sDefaultOpt, const string& sChild2, ReadProcessChildYesNoToDouble( const pugi::xml_node& process, const string& sChild1, const string& sDefaultOpt, const string& sChild2,
const double& nDefaultVal) double nDefaultVal)
{ {
string sValue = process.child( sChild1.c_str()).text().get() ; string sValue = process.child( sChild1.c_str()).text().get() ;
if ( sValue == sDefaultOpt || sValue.empty() || ( sValue != "no" && sValue != "yes")) if ( sValue == sDefaultOpt || sValue.empty() || ( sValue != "no" && sValue != "yes"))
@@ -2270,96 +2279,96 @@ ReadProcessChildYesNoToDouble( const pugi::xml_node& process, const string& sChi
//----------------------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------------------
int int
ComputeP04( const STRVECTOR& values) ComputeP04( const STRVECTOR& vsValues)
{ {
if ( values.size() > 6 || values.empty()) { if ( vsValues.size() > 6 || vsValues.empty()) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: P04 is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: P04 is not valid") ;
return -2 ; return -2 ;
} }
int result = 0 ; int nResult = 0 ;
for ( size_t i = 0 ; i < values.size() ; i ++) { for ( int i = 0 ; i < ssize( vsValues) ; i ++) {
if ( values[i] == "no") if ( vsValues[i] == "no")
result += static_cast<int>( pow( 2, i)) ; nResult += int( Pow( 2, i)) ;
else if ( values[i] != "yes") { else if ( vsValues[i] != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit value is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit value is not valid") ;
return -2 ; return -2 ;
} }
} }
return result ; return nResult ;
} }
//----------------------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------------------
int int
ComputeP04( const pugi::xml_node& MachiningLimits) ComputeP04( const pugi::xml_node& MachiningLimits)
{ {
string FaceLimitedStart = "yes" ; string sFaceLimitedStart = "yes" ;
if ( MachiningLimits.attribute( "FaceLimitedStart") != nullptr) if ( MachiningLimits.attribute( "FaceLimitedStart") != nullptr)
FaceLimitedStart = MachiningLimits.attribute( "FaceLimitedStart").value() ; sFaceLimitedStart = MachiningLimits.attribute( "FaceLimitedStart").value() ;
string FaceLimitedEnd = "yes" ; string sFaceLimitedEnd = "yes" ;
if ( MachiningLimits.attribute( "FaceLimitedEnd") != nullptr) if ( MachiningLimits.attribute( "FaceLimitedEnd") != nullptr)
FaceLimitedEnd = MachiningLimits.attribute( "FaceLimitedEnd").value() ; sFaceLimitedEnd = MachiningLimits.attribute( "FaceLimitedEnd").value() ;
string FaceLimitedFront = "yes" ; string sFaceLimitedFront = "yes" ;
if ( MachiningLimits.attribute( "FaceLimitedFront") != nullptr) if ( MachiningLimits.attribute( "FaceLimitedFront") != nullptr)
FaceLimitedFront = MachiningLimits.attribute( "FaceLimitedFront").value() ; sFaceLimitedFront = MachiningLimits.attribute( "FaceLimitedFront").value() ;
string FaceLimitedBack = "yes" ; string sFaceLimitedBack = "yes" ;
if ( MachiningLimits.attribute( "FaceLimitedBack") != nullptr) if ( MachiningLimits.attribute( "FaceLimitedBack") != nullptr)
FaceLimitedBack = MachiningLimits.attribute( "FaceLimitedBack").value() ; sFaceLimitedBack = MachiningLimits.attribute( "FaceLimitedBack").value() ;
string FaceLimitedBottom = "yes" ; string sFaceLimitedBottom = "yes" ;
if ( MachiningLimits.attribute( "FaceLimitedBottom") != nullptr) if ( MachiningLimits.attribute( "FaceLimitedBottom") != nullptr)
FaceLimitedBottom = MachiningLimits.attribute( "FaceLimitedBottom").value() ; sFaceLimitedBottom = MachiningLimits.attribute( "FaceLimitedBottom").value() ;
string FaceLimitedTop = "no" ; string sFaceLimitedTop = "no" ;
if ( MachiningLimits.attribute( "FaceLimitedTop") != nullptr) if ( MachiningLimits.attribute( "FaceLimitedTop") != nullptr)
FaceLimitedTop = MachiningLimits.attribute( "FaceLimitedTop").value() ; sFaceLimitedTop = MachiningLimits.attribute( "FaceLimitedTop").value() ;
int result = 0 ; int nResult = 0 ;
if ( FaceLimitedStart == "no") if ( sFaceLimitedStart == "no")
result += 1 ; nResult += 1 ;
else if ( FaceLimitedStart != "yes") { else if ( sFaceLimitedStart != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ; return -2 ;
} }
if ( FaceLimitedEnd == "no") if ( sFaceLimitedEnd == "no")
result += 2 ; nResult += 2 ;
else if ( FaceLimitedEnd != "yes") { else if ( sFaceLimitedEnd != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ; return -2 ;
} }
if ( FaceLimitedFront == "no") if ( sFaceLimitedFront == "no")
result += 4 ; nResult += 4 ;
else if ( FaceLimitedFront != "yes") { else if ( sFaceLimitedFront != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ; return -2 ;
} }
if ( FaceLimitedBack == "no") if ( sFaceLimitedBack == "no")
result += 8 ; nResult += 8 ;
else if ( FaceLimitedBack != "yes") { else if ( sFaceLimitedBack != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ; return -2 ;
} }
if ( FaceLimitedBottom == "no") if ( sFaceLimitedBottom == "no")
result += 16 ; nResult += 16 ;
else if ( FaceLimitedBottom != "yes") { else if ( sFaceLimitedBottom != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ; return -2 ;
} }
if ( FaceLimitedTop == "no") if ( sFaceLimitedTop == "no")
result += 32 ; nResult += 32 ;
else if ( FaceLimitedTop != "yes") { else if ( sFaceLimitedTop != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ; LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ; return -2 ;
} }
return result ; return nResult ;
} }
+56 -8
View File
@@ -25,8 +25,6 @@
#include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkArcSpecial.h" #include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDEv/Include/EGnScanner.h" #include "/EgtDEv/Include/EGnScanner.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
@@ -43,6 +41,7 @@ static const string KEY_EXIT = "EXIT" ;
static const string KEY_TPOS = "TPOS" ; static const string KEY_TPOS = "TPOS" ;
static const string KEY_TPOS2 = "TPOS2" ; static const string KEY_TPOS2 = "TPOS2" ;
static const string KEY_SPEED = "SPEED" ; static const string KEY_SPEED = "SPEED" ;
static const string KEY_FEED = "FEED" ;
static const string KEY_ROTAX_A = "A" ; static const string KEY_ROTAX_A = "A" ;
static const string KEY_ROTAX_B = "B" ; static const string KEY_ROTAX_B = "B" ;
static const string KEY_ROTAX_C = "C" ; static const string KEY_ROTAX_C = "C" ;
@@ -125,6 +124,7 @@ ImportCnc::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup, int nFlag)
m_colCurr = BLACK ; m_colCurr = BLACK ;
m_sToolName.clear() ; m_sToolName.clear() ;
m_nExit = 1 ; m_nExit = 1 ;
m_dFeed = 0 ;
// se estensione xpi è NUM // se estensione xpi è NUM
string sFileTitle, sFileExt ; string sFileTitle, sFileExt ;
@@ -171,7 +171,7 @@ ImportCnc::ProcessLine( const string& sLine)
return ParseRemark( sLine) ; return ParseRemark( sLine) ;
// altre linee da saltare // altre linee da saltare
if ( sLine[0] == '$' || sLine[0] == '!' || ( sLine[0] == 'M' && sLine[1] == 'S' && sLine[2] == 'G')) if ( sLine[0] == '$' || sLine[0] == '!' || sLine.starts_with( "MSG"))
return true ; return true ;
// eliminazione di commenti intermedi o finali // eliminazione di commenti intermedi o finali
@@ -179,6 +179,8 @@ ImportCnc::ProcessLine( const string& sLine)
// se controllo OSAI elimino le parti dopo ; // se controllo OSAI elimino le parti dopo ;
if ( m_nCNC == CNC_OSAI) { if ( m_nCNC == CNC_OSAI) {
size_t nStart = sMyLine.find( ';') ; size_t nStart = sMyLine.find( ';') ;
if ( nStart == string::npos)
nStart = sMyLine.find( "@") ;
if ( nStart != string::npos) if ( nStart != string::npos)
sMyLine.erase( nStart) ; sMyLine.erase( nStart) ;
} }
@@ -193,13 +195,21 @@ ImportCnc::ProcessLine( const string& sLine)
sMyLine.erase( nStart) ; sMyLine.erase( nStart) ;
} }
} }
// se controllo SIEMENS elimino i cicli 800 e 832 // se controllo SIEMENS elimino alcuni comandi speciali ed effettuo conversioni o salti
else if ( m_nCNC == CNC_SIEMENS) { else if ( m_nCNC == CNC_SIEMENS) {
if ( sMyLine.starts_with( "ID"))
return true ;
if ( sMyLine.starts_with( "DYN"))
return true ;
size_t nStart = sMyLine.find( "CYCLE800") ; size_t nStart = sMyLine.find( "CYCLE800") ;
if ( nStart == string::npos) if ( nStart == string::npos)
nStart = sMyLine.find( "CYCLE832") ; nStart = sMyLine.find( "CYCLE832") ;
if ( nStart == string::npos)
nStart = sMyLine.find( "/WHEN") ;
if ( nStart != string::npos) if ( nStart != string::npos)
sMyLine.erase( nStart) ; sMyLine.erase( nStart) ;
ReplaceString( sMyLine, "SUPA", "G79") ;
ReplaceString( sMyLine, "AC(", "") ;
} }
// divido la linea in parti // divido la linea in parti
@@ -207,7 +217,7 @@ ImportCnc::ProcessLine( const string& sLine)
TokenizePlus( sMyLine, "NGXYZIJKPQRUVWABCFTMHhDEL", vsTokens) ; TokenizePlus( sMyLine, "NGXYZIJKPQRUVWABCFTMHhDEL", vsTokens) ;
// analizzo ogni singola parte // analizzo ogni singola parte
for ( size_t i = 0 ; i < vsTokens.size() ; ++ i) { for ( int i = 0 ; i < ssize( vsTokens) ; ++ i) {
// analizzo per categorie determinate dal primo carattere del token // analizzo per categorie determinate dal primo carattere del token
switch ( vsTokens[i][0]) { switch ( vsTokens[i][0]) {
case 'G' : case 'G' :
@@ -252,6 +262,9 @@ ImportCnc::ProcessLine( const string& sLine)
case 'T' : case 'T' :
ParseT( vsTokens[i]) ; ParseT( vsTokens[i]) ;
break ; break ;
case 'F' :
ParseF( vsTokens[i]) ;
break ;
case 'M' : case 'M' :
ParseM( vsTokens[i]) ; ParseM( vsTokens[i]) ;
break ; break ;
@@ -274,8 +287,11 @@ ImportCnc::ProcessLine( const string& sLine)
// se utensile da caricare // se utensile da caricare
if ( m_bLoadTool) if ( m_bLoadTool)
m_nTool = m_nNextTool ; m_nTool = m_nNextTool ;
// se comando da ignorare
if ( m_nCommand == SKIP)
;
// se comando di movimento o riconosciuto movimento, lo eseguo // se comando di movimento o riconosciuto movimento, lo eseguo
if ( m_nCommand == MOVE || m_bToMove) else if ( m_nCommand == MOVE || m_bToMove)
bOk = ExecMovement() ; bOk = ExecMovement() ;
// se comando di impostazione piano di interpolazione // se comando di impostazione piano di interpolazione
else if ( m_nCommand == IPL) else if ( m_nCommand == IPL)
@@ -363,7 +379,8 @@ ImportCnc::ParseRemark( const string& sLine)
if ( iExit == string::npos) if ( iExit == string::npos)
iExit = sLine.find( "EXIT=") ; iExit = sLine.find( "EXIT=") ;
if ( iExit != string::npos) { if ( iExit != string::npos) {
FromString( sLine.substr( iExit + 5), m_nExit) ; if ( ! FromString( sLine.substr( iExit + 5), m_nExit))
m_nExit = 0 ;
return true ; return true ;
} }
// cerco indicazione posizione nel TC // cerco indicazione posizione nel TC
@@ -435,6 +452,9 @@ ImportCnc::ParseG( const string& sToken)
m_nCommand = MOVE ; m_nCommand = MOVE ;
m_nMoveType = ARC_CCW ; m_nMoveType = ARC_CCW ;
break ; break ;
case 4 :
m_nCommand = SKIP ;
break ;
case 14 : case 14 :
m_nCommand = MOVE ; m_nCommand = MOVE ;
m_nMoveType = ARC_MID_3D ; m_nMoveType = ARC_MID_3D ;
@@ -523,6 +543,8 @@ ImportCnc::ParseX( const string& sToken)
case OFFS : case OFFS :
m_vtOffs.x = dVal ; m_vtOffs.x = dVal ;
break ; break ;
case SKIP :
break ;
default : default :
if ( m_bZeroMach) if ( m_bZeroMach)
m_ptNext.x = m_ptHome.x + dVal ; m_ptNext.x = m_ptHome.x + dVal ;
@@ -550,6 +572,8 @@ ImportCnc::ParseY( const string& sToken)
case OFFS : case OFFS :
m_vtOffs.y = dVal ; m_vtOffs.y = dVal ;
break ; break ;
case SKIP :
break ;
default : default :
if ( m_bZeroMach) if ( m_bZeroMach)
m_ptNext.y = m_ptHome.y + dVal ; m_ptNext.y = m_ptHome.y + dVal ;
@@ -577,6 +601,8 @@ ImportCnc::ParseZ( const string& sToken)
case OFFS : case OFFS :
m_vtOffs.z = dVal ; m_vtOffs.z = dVal ;
break ; break ;
case SKIP :
break ;
default : default :
if ( m_bZeroMach) if ( m_bZeroMach)
m_ptNext.z = m_ptHome.z + dVal ; m_ptNext.z = m_ptHome.z + dVal ;
@@ -630,7 +656,6 @@ ImportCnc::ParseJ( const string& sToken)
case ZX : m_ptCen.x = dVal ; break ; case ZX : m_ptCen.x = dVal ; break ;
} }
} }
m_nArcType = CENTER ; m_nArcType = CENTER ;
m_bToMove = true ; m_bToMove = true ;
return true ; return true ;
@@ -771,6 +796,17 @@ ImportCnc::ParseT( const string& sToken)
return true ; return true ;
} }
//----------------------------------------------------------------------------
bool
ImportCnc::ParseF( const string& sToken)
{
double dVal ;
int nStart = ( sToken[1] == '=' ? 2 : 1) ;
if ( FromString( sToken.substr( nStart), dVal))
m_dFeed = dVal ;
return true ;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
ImportCnc::ParseM( const string& sToken) ImportCnc::ParseM( const string& sToken)
@@ -903,6 +939,9 @@ ImportCnc::AddPoint( int nPntType)
m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ; m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ;
if ( ! isnan( m_dRotAxC)) if ( ! isnan( m_dRotAxC))
m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ; m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ;
// assegnazione eventuale Feed
if ( nPntType == P_PNT && abs( m_dFeed) > 0.1)
m_pGDB->SetInfo( nId, KEY_FEED, m_dFeed) ;
// assegnazione eventuali info // assegnazione eventuali info
SetInfos( nId) ; SetInfos( nId) ;
m_vInfos.clear() ; m_vInfos.clear() ;
@@ -962,6 +1001,9 @@ ImportCnc::AddLine( int nLineType)
m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ; m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ;
if ( ! isnan( m_dRotAxC)) if ( ! isnan( m_dRotAxC))
m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ; m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ;
// assegnazione eventuale Feed
if ( nLineType == L_LINE && abs( m_dFeed) > 0.1)
m_pGDB->SetInfo( nId, KEY_FEED, m_dFeed) ;
// assegnazione eventuali info // assegnazione eventuali info
SetInfos( nId) ; SetInfos( nId) ;
m_vInfos.clear() ; m_vInfos.clear() ;
@@ -1053,6 +1095,9 @@ ImportCnc::AddArc( bool bCCW)
m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ; m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ;
if ( ! isnan( m_dRotAxC)) if ( ! isnan( m_dRotAxC))
m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ; m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ;
// assegnazione eventuale Feed
if ( abs( m_dFeed) > 0.1)
m_pGDB->SetInfo( nId, KEY_FEED, m_dFeed) ;
// assegnazione eventuali info // assegnazione eventuali info
SetInfos( nId) ; SetInfos( nId) ;
m_vInfos.clear() ; m_vInfos.clear() ;
@@ -1119,6 +1164,9 @@ ImportCnc::AddArc3P( bool bIs2D)
m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ; m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ;
if ( ! isnan( m_dRotAxC)) if ( ! isnan( m_dRotAxC))
m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ; m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ;
// assegnazione eventuale Feed
if ( abs( m_dFeed) > 0.1)
m_pGDB->SetInfo( nId, KEY_FEED, m_dFeed) ;
// assegnazione eventuali info // assegnazione eventuali info
SetInfos( nId) ; SetInfos( nId) ;
m_vInfos.clear() ; m_vInfos.clear() ;
+3 -1
View File
@@ -42,6 +42,7 @@ class ImportCnc : public IImportCnc
bool ParseB( const std::string& sToken) ; bool ParseB( const std::string& sToken) ;
bool ParseC( const std::string& sToken) ; bool ParseC( const std::string& sToken) ;
bool ParseT( const std::string& sToken) ; bool ParseT( const std::string& sToken) ;
bool ParseF( const std::string& sToken) ;
bool ParseM( const std::string& sToken) ; bool ParseM( const std::string& sToken) ;
bool ParseH( const std::string& sToken) ; bool ParseH( const std::string& sToken) ;
bool ExecSetIPL( void) ; bool ExecSetIPL( void) ;
@@ -73,7 +74,7 @@ class ImportCnc : public IImportCnc
private : private :
enum CncName { CNC_STD = 0, CNC_OSAI = 1, CNC_FANUC = 2, CNC_NUM = 3, CNC_SIEMENS = 4, CNC_TPA = 5, CNC_MAZAK = 6, CNC_FAGOR} ; enum CncName { CNC_STD = 0, CNC_OSAI = 1, CNC_FANUC = 2, CNC_NUM = 3, CNC_SIEMENS = 4, CNC_TPA = 5, CNC_MAZAK = 6, CNC_FAGOR} ;
enum InterpPl { XY = 1, YZ = 2, ZX = 3} ; enum InterpPl { XY = 1, YZ = 2, ZX = 3} ;
enum Command { NO_CMD = 0, MOVE = 1, IPL = 2, OFFS = 3} ; enum Command { NO_CMD = 0, MOVE = 1, IPL = 2, OFFS = 3, SKIP = 4} ;
enum MoveType { RAPID = 0, LINE = 1, ARC_CW = 2, ARC_CCW = 3, ARC_MID_2D = 4, ARC_MID_3D = 5} ; enum MoveType { RAPID = 0, LINE = 1, ARC_CW = 2, ARC_CCW = 3, ARC_MID_2D = 4, ARC_MID_3D = 5} ;
enum PntType { P_RAPID = 0, P_PNT = 1, P_ERROR = 2} ; enum PntType { P_RAPID = 0, P_PNT = 1, P_ERROR = 2} ;
enum LineType { L_RAPID = 0, L_LINE = 1, L_ERROR = 2} ; enum LineType { L_RAPID = 0, L_LINE = 1, L_ERROR = 2} ;
@@ -125,5 +126,6 @@ class ImportCnc : public IImportCnc
std::string m_sToolPos ; std::string m_sToolPos ;
std::string m_sToolPos2 ; std::string m_sToolPos2 ;
std::string m_sSpeed ; std::string m_sSpeed ;
double m_dFeed ;
STRVECTOR m_vInfos ; STRVECTOR m_vInfos ;
} ; } ;
+1 -3
View File
@@ -25,8 +25,6 @@
#include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <fstream> #include <fstream>
@@ -599,7 +597,7 @@ ImportCsf::ProcessExtendedText( const CsfEnt& csfEnt)
} }
// salvataggio testo con un punto di inserimento per ogni carattere // salvataggio testo con un punto di inserimento per ogni carattere
else if ( etData.sText.size() == etData.vPnt.size()) { else if ( etData.sText.size() == etData.vPnt.size()) {
for ( size_t i = 0 ; i < etData.sText.size() ; ++ i) { for ( int i = 0 ; i < ssize( etData.sText) ; ++ i) {
// creo il testo // creo il testo
PtrOwner<IExtText> pTxt( CreateExtText()) ; PtrOwner<IExtText> pTxt( CreateExtText()) ;
if ( IsNull( pTxt)) if ( IsNull( pTxt))
-3
View File
@@ -19,12 +19,9 @@
#include "/EgtDev/Include/EExDllMain.h" #include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
using namespace std ; using namespace std ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
IImportDxf* IImportDxf*
CreateImportDxf( void) CreateImportDxf( void)
+25 -17
View File
@@ -398,9 +398,9 @@ bool
ImportDxf::ReadArc( bool& bFileEnd) ImportDxf::ReadArc( bool& bFileEnd)
{ {
Point3d ptCen ; Point3d ptCen ;
double dRadius ; double dRadius = 0 ;
double dStartAng ; double dStartAng = 0 ;
double dEndAng ; double dEndAng = 0 ;
Vector3d vtExtr = Z_AX ; Vector3d vtExtr = Z_AX ;
double dThick = 0 ; double dThick = 0 ;
string sLayer ; string sLayer ;
@@ -529,7 +529,7 @@ bool
ImportDxf::ReadCircle( bool& bFileEnd) ImportDxf::ReadCircle( bool& bFileEnd)
{ {
Point3d ptCen ; Point3d ptCen ;
double dRadius ; double dRadius = 0 ;
Vector3d vtExtr = Z_AX ; Vector3d vtExtr = Z_AX ;
double dThick = 0 ; double dThick = 0 ;
string sLayer ; string sLayer ;
@@ -2146,47 +2146,55 @@ ImportDxf::ReadSpline( bool& bFileEnd)
sLayer = m_sCurrItem ; sLayer = m_sCurrItem ;
break ; break ;
case 10 : case 10 :
FromString( m_sCurrItem, ptP.x) ; if ( ! FromString( m_sCurrItem, ptP.x))
ptP.x = 0 ;
++ nContX ; ++ nContX ;
if ( nContX == nContY && nContY == nContZ) if ( nContX == nContY && nContY == nContZ)
cnData.vCP.push_back( ptP) ; cnData.vCP.push_back( ptP) ;
break ; break ;
case 20 : case 20 :
FromString( m_sCurrItem, ptP.y) ; if ( ! FromString( m_sCurrItem, ptP.y))
ptP.y = 0 ;
++ nContY ; ++ nContY ;
if ( nContX == nContY && nContY == nContZ) if ( nContX == nContY && nContY == nContZ)
cnData.vCP.push_back( ptP) ; cnData.vCP.push_back( ptP) ;
break ; break ;
case 30 : case 30 :
FromString( m_sCurrItem, ptP.z) ; if ( ! FromString( m_sCurrItem, ptP.z))
ptP.z = 0 ;
++ nContZ ; ++ nContZ ;
if ( nContX == nContY && nContY == nContZ) if ( nContX == nContY && nContY == nContZ)
cnData.vCP.push_back( ptP) ; cnData.vCP.push_back( ptP) ;
break ; break ;
case 11 : case 11 :
FromString( m_sCurrItem, ptInt.x) ; if ( ! FromString( m_sCurrItem, ptInt.x))
ptInt.x = 0 ;
++ nIntX ; ++ nIntX ;
if ( nIntX == nIntY && nIntY == nIntZ) if ( nIntX == nIntY && nIntY == nIntZ)
vIntPnt.push_back( ptInt) ; vIntPnt.push_back( ptInt) ;
break ; break ;
case 21 : case 21 :
FromString( m_sCurrItem, ptInt.y) ; if ( ! FromString( m_sCurrItem, ptInt.y))
ptInt.y = 0 ;
++ nIntY ; ++ nIntY ;
if ( nIntX == nIntY && nIntY == nIntZ) if ( nIntX == nIntY && nIntY == nIntZ)
vIntPnt.push_back( ptInt) ; vIntPnt.push_back( ptInt) ;
break ; break ;
case 31 : case 31 :
FromString( m_sCurrItem, ptInt.z) ; if ( ! FromString( m_sCurrItem, ptInt.z))
ptInt.z = 0 ;
++ nIntZ ; ++ nIntZ ;
if ( nIntX == nIntY && nIntY == nIntZ) if ( nIntX == nIntY && nIntY == nIntZ)
vIntPnt.push_back( ptInt) ; vIntPnt.push_back( ptInt) ;
break ; break ;
case 40 : case 40 :
FromString( m_sCurrItem, dTemp) ; if ( ! FromString( m_sCurrItem, dTemp))
dTemp = 0 ;
cnData.vU.push_back( dTemp) ; cnData.vU.push_back( dTemp) ;
break; break;
case 41 : case 41 :
FromString( m_sCurrItem, dTemp) ; if ( ! FromString( m_sCurrItem, dTemp))
dTemp = 0 ;
cnData.vW.push_back( dTemp) ; cnData.vW.push_back( dTemp) ;
break; break;
case 60 : case 60 :
@@ -2302,7 +2310,7 @@ ImportDxf::ReadText( int nGroupId, bool& bFileEnd)
string sText ; string sText ;
string sLayer ; string sLayer ;
string sStyle = "STANDARD" ; string sStyle = "STANDARD" ;
double dH ; double dH = 0 ;
double dAngDeg = 0 ; double dAngDeg = 0 ;
double dRat = 1 ; double dRat = 1 ;
int nSpace = ENT_MODELSPACE ; int nSpace = ENT_MODELSPACE ;
@@ -2500,7 +2508,7 @@ ImportDxf::ReadMText( bool& bFileEnd)
string sText ; string sText ;
string sLayer ; string sLayer ;
string sStyle = "STANDARD" ; string sStyle = "STANDARD" ;
double dH ; double dH = 0 ;
double dTextMaxWidth = 0 ; double dTextMaxWidth = 0 ;
double dAngRad = 0 ; double dAngRad = 0 ;
int nInsPos = ETXT_IPBL ; int nInsPos = ETXT_IPBL ;
@@ -2687,16 +2695,16 @@ ImportDxf::AdjustMText( string& sText, double dTextMaxWidth, double dW)
// coefficiente empirico che in generale migliora l'adattamento // coefficiente empirico che in generale migliora l'adattamento
const double COEFF_LARGH = 1.2 ; const double COEFF_LARGH = 1.2 ;
// gestione max lunghezza riga di testo // gestione max lunghezza riga di testo
size_t nLastSp = - 1 ; int nLastSp = -1 ;
double dCurrWidth = 0 ; double dCurrWidth = 0 ;
for ( size_t i = 0 ; i < sText.size() ; ++ i) { for ( int i = 0 ; i < ssize( sText) ; ++ i) {
// posso dividere solo sugli spazi // posso dividere solo sugli spazi
if ( sText[i] == ' ') if ( sText[i] == ' ')
nLastSp = i ; nLastSp = i ;
// se c'è già un a capo // se c'è già un a capo
if ( sText[i] == '\n') { if ( sText[i] == '\n') {
dCurrWidth = 0 ; dCurrWidth = 0 ;
nLastSp = - 1 ; nLastSp = -1 ;
} }
// se supera il limite // se supera il limite
else if ( dCurrWidth > COEFF_LARGH * dTextMaxWidth) { else if ( dCurrWidth > COEFF_LARGH * dTextMaxWidth) {
+206
View File
@@ -0,0 +1,206 @@
//----------------------------------------------------------------------------
// EgalTech 2024-2024
//----------------------------------------------------------------------------
// File : ImportOff.cpp Data : 28.11.24 Versione : 2.6k2
// Contenuto : Implementazione della classe per l'importazione di OFF.
//
//
//
// Modifiche : 28.11.24 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "ImportOff.h"
#include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
//----------------------------------------------------------------------------
IImportOff*
CreateImportOff( void)
{
// verifico la chiave e le opzioni
if ( ! VerifyKey( KEYOPT_EEX_INPBASE))
return nullptr ;
// creo l'oggetto
return static_cast<IImportOff*> ( new( nothrow) ImportOff) ;
}
//----------------------------------------------------------------------------
bool
ImportOff::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup, double dScaleFactor)
{
// verifico il DB geometrico
if ( pGDB == nullptr) {
LOG_ERROR( GetEExLogger(), "ImportOff : Error on GeomDB")
return false ;
}
m_pGDB = pGDB ;
// verifico l'Id di gruppo
if ( ! m_pGDB->ExistsObj( nIdGroup)) {
LOG_ERROR( GetEExLogger(), "ImportOff : Error on IdGroup")
return false ;
}
m_nIdGroup = nIdGroup ;
// verifico il fattore di scala
if ( dScaleFactor < EPS_SMALL) {
LOG_ERROR( GetEExLogger(), "ImportOff : Error on ScaleFactor too small (minimum 0.001).")
return false ;
}
m_dScaleFactor = dScaleFactor ;
// inizializzo lo scanner
if ( ! m_theScanner.Init( sFile, "#")) {
LOG_ERROR( GetEExLogger(), "ImportOff : Error on Init")
return false ;
}
// lettura intestazione
if ( ! ReadData()) {
string sOut = " ImportOff : Error in ReadData on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
ImportOff::ReadData( void)
{
string sLine ;
// Intestazione opzionale OFF
if ( ! m_theScanner.GetLine( sLine))
return false ;
bool bOFF = ( sLine.find( "OFF") != string::npos) ;
// Numero di vertici, di facce e di spigoli (ignorato)
if ( bOFF && ! m_theScanner.GetLine( sLine))
return false ;
STRVECTOR vsTok ;
Tokenize( sLine, " ", vsTok) ;
if ( vsTok.size() < 3)
return false ;
int nVerts = 0, nFaces = 0 ;
if ( ! FromString( vsTok[0], nVerts) || nVerts <= 0 ||
! FromString( vsTok[1], nFaces) || nFaces <= 0)
return false ;
// Vettore dei vertici
PNTVECTOR vVert( nVerts) ;
// lettura dei vertici
for ( int i = 0 ; i < nVerts ; ++ i) {
if ( ! m_theScanner.GetLine( sLine))
return false ;
STRVECTOR vsTok ;
Tokenize( sLine, " ", vsTok) ;
if ( vsTok.size() < 3)
return false ;
if ( ! FromString( vsTok[0], vVert[i].x) || ! FromString( vsTok[1],vVert[i].y) || ! FromString( vsTok[2], vVert[i].z))
return false ;
vVert[i] *= m_dScaleFactor ;
}
// Costruttore di trimesh da insieme disordinato di triangoli
StmFromTriangleSoup StmFts ;
if ( ! StmFts.Start())
return false ;
// lettura delle facce
int nBadFaces = 0 ;
for ( int i = 0 ; i < nFaces ; ++ i) {
if ( ! m_theScanner.GetLine( sLine))
return false ;
STRVECTOR vsTok ;
Tokenize( sLine, " ", vsTok) ;
if ( vsTok.empty())
return false ;
int nFVs = 0 ;
if ( ! FromString( vsTok[0], nFVs) || int( vsTok.size()) < nFVs + 1)
return false ;
// se triangolo
if ( nFVs == 3) {
Triangle3d Tria ;
for ( int j = 0 ; j < 3 ; ++ j) {
int nV = -1 ;
if ( ! FromString( vsTok[j+1], nV) || nV < 0 || nV >= nVerts)
return false ;
Tria.SetP( j, vVert[nV]) ;
}
if ( Tria.Validate( true)) {
if ( ! StmFts.AddTriangle( Tria))
return false ;
}
else
++ nBadFaces ;
}
// se quadrilatero
else if ( nFVs == 4) {
Triangle3d TriaA, TriaB ;
for ( int j = 0 ; j < 4 ; ++ j) {
int nV = -1 ;
if ( ! FromString( vsTok[j+1], nV) || nV < 0 || nV >= nVerts)
return false ;
if ( j != 3)
TriaA.SetP( j, vVert[nV]) ;
if ( j != 1)
TriaB.SetP( ( j == 0 ? j : j - 1), vVert[nV]) ;
}
if ( TriaA.Validate( true)) {
if ( ! StmFts.AddTriangle( TriaA))
return false ;
}
else
++ nBadFaces ;
if ( TriaB.Validate( true)) {
if ( ! StmFts.AddTriangle( TriaB))
return false ;
}
else
++ nBadFaces ;
}
// altrimenti poligono generico
else {
PolyLine PL ;
for ( int j = 0 ; j < nFVs ; ++ j) {
int nV = -1 ;
if ( ! FromString( vsTok[j+1], nV) || nV < 0 || nV >= nVerts)
return false ;
PL.AddUPoint( j, vVert[nV]) ;
}
PL.Close() ;
PL.FlattenInAutoPlane( 1.) ;
PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ;
if ( ! IsNull( pStm) && pStm->CreateByFlatContour( PL)) {
if ( ! StmFts.AddSurfTriMesh( *pStm))
return false ;
}
else
++ nBadFaces ;
}
}
if ( nBadFaces > 0) {
string sOut = " ImportOff : found " + ToString( nBadFaces) + " bad faces" ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
}
// Valido la superficie e calcolo le adiacenze
if ( ! StmFts.End())
return false ;
// inserisco l'oggetto nel DB geometrico
PtrOwner<ISurfTriMesh> pSTM( StmFts.GetSurf()) ;
int nIdNew = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, Release( pSTM)) ;
if ( nIdNew == GDB_ID_NULL)
return false ;
return true ;
}
+33
View File
@@ -0,0 +1,33 @@
//----------------------------------------------------------------------------
// EgalTech 2024-2024
//----------------------------------------------------------------------------
// File : ImportOff.h Data : 28.11.24 Versione : 2.6k2
// Contenuto : Dichiarazione della classe ImportOff.
//
//
//
// Modifiche : 28.11.24 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EExImportOff.h"
#include "/EgtDEv/Include/EGnScanner.h"
//----------------------------------------------------------------------------
class ImportOff : public IImportOff
{
public :
virtual bool Import( const std::string& sFile, IGeomDB* pGDB, int nIdGroup, double dScaleFactor = 1) ;
private :
bool ReadData( void) ;
private :
Scanner m_theScanner ;
IGeomDB* m_pGDB ;
int m_nIdGroup ;
double m_dScaleFactor ;
} ;
+169
View File
@@ -0,0 +1,169 @@
//----------------------------------------------------------------------------
// EgalTech 2025-2025
//----------------------------------------------------------------------------
// File : ImportPLY.cpp Data : 28.02.25 Versione : 2.7b2
// Contenuto : Implementazione della classe per l'importazione di PLY.
//
//
//
// Modifiche : 28.02.25 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "ImportPly.h"
#include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
//----------------------------------------------------------------------------
IImportPly*
CreateImportPly( void)
{
// verifico la chiave e le opzioni
if ( ! VerifyKey( KEYOPT_EEX_INPBASE))
return nullptr ;
// creo l'oggetto
return static_cast<IImportPly*> ( new( nothrow) ImportPly) ;
}
//----------------------------------------------------------------------------
bool
ImportPly::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup, double dScaleFactor)
{
// verifico il DB geometrico
if ( pGDB == nullptr) {
LOG_ERROR( GetEExLogger(), "ImportPly : Error on GeomDB")
return false ;
}
m_pGDB = pGDB ;
// verifico l'Id di gruppo
if ( ! m_pGDB->ExistsObj( nIdGroup)) {
LOG_ERROR( GetEExLogger(), "ImportPly : Error on IdGroup")
return false ;
}
m_nIdGroup = nIdGroup ;
// verifico il fattore di scala
if ( dScaleFactor < EPS_SMALL) {
LOG_ERROR( GetEExLogger(), "ImportPly : Error on ScaleFactor too small (minimum 0.001).")
return false ;
}
m_dScaleFactor = dScaleFactor ;
// inizializzo il lettore
miniply::PLYReader TheReader( sFile.data()) ;
if ( ! TheReader.valid()) {
LOG_ERROR( GetEExLogger(), "ImportPly : Error on Init")
return false ;
}
// lettura dati
return ReadData( TheReader) ;
}
//----------------------------------------------------------------------------
bool
ImportPly::ReadData( miniply::PLYReader& TheReader)
{
typedef std::vector<float> FLTVECTOR ; // vettore di float
uint32_t propIdxs[3] ;
bool bGotVerts = false, bGotFaces = false ;
int nVerts = 0 ;
FLTVECTOR vVert ;
int nTrias = 0 ;
INTVECTOR vTria ;
while ( TheReader.has_element() && ( ! bGotVerts || ! bGotFaces)) {
// Recupero i vertici
if ( TheReader.element_is( miniply::kPLYVertexElement) && TheReader.load_element() && TheReader.find_pos( propIdxs)) {
nVerts = TheReader.num_rows() ;
vVert.resize( 3 * nVerts) ;
TheReader.extract_properties( propIdxs, 3, miniply::PLYPropertyType::Float, vVert.data()) ;
bGotVerts = true ;
}
// Recupero gli indici dei vertici dei triangoli delle facce
else if ( TheReader.element_is( miniply::kPLYFaceElement) && TheReader.load_element() && TheReader.find_indices( propIdxs)) {
bool bPolys = TheReader.requires_triangulation( propIdxs[0]) ;
if ( bPolys && ! bGotVerts) {
string sOut = " ImportPly : need vertex positions to triangulate faces" ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
return false ;
}
if ( bPolys) {
nTrias = TheReader.num_triangles( propIdxs[0]) ;
vTria.resize( 3 * nTrias) ;
TheReader.extract_triangles( propIdxs[0], vVert.data(), nVerts, miniply::PLYPropertyType::Int, vTria.data()) ;
}
else {
nTrias = TheReader.num_rows() ;
vTria.resize( 3 * nTrias) ;
TheReader.extract_list_property( propIdxs[0], miniply::PLYPropertyType::Int, vTria.data()) ;
}
bGotFaces = true ;
}
if ( bGotVerts && bGotFaces)
break ;
TheReader.next_element() ;
}
// Controllo lettura effettiuata di vertici e facce
if ( ! bGotVerts) {
string sOut = " ImportPly : vertex positions not found" ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
return false ;
}
if ( ! bGotFaces) {
string sOut = " ImportPly : face indices not found" ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
return false ;
}
// Costruttore di trimesh da insieme disordinato di triangoli
StmFromTriangleSoup StmFts ;
if ( ! StmFts.Start())
return false ;
// ciclo sui triangoli
int nBadTrias = 0 ;
for ( int i = 0 ; i < nTrias ; ++ i) {
int nT = 3 * i ;
Triangle3d Tria ;
for ( int j = 0 ; j < 3 ; ++ j) {
int nV = 3 * vTria[nT+j] ;
Point3d ptP( vVert[nV], vVert[nV+1], vVert[nV+2]) ;
ptP *= m_dScaleFactor ;
Tria.SetP( j, ptP) ;
}
if ( Tria.Validate( true)) {
if ( ! StmFts.AddTriangle( Tria)) {
string sOut = " ImportPly : error adding triangle" ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
return false ;
}
}
else
++ nBadTrias ;
}
if ( nBadTrias > 0) {
string sOut = " ImportPly : found " + ToString( nBadTrias) + " bad triangles" ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
}
// Valido la superficie e calcolo le adiacenze
if ( ! StmFts.End())
return false ;
// inserisco l'oggetto nel DB geometrico
PtrOwner<ISurfTriMesh> pSTM( StmFts.GetSurf()) ;
int nIdNew = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, Release( pSTM)) ;
if ( nIdNew == GDB_ID_NULL)
return false ;
return true ;
}
+32
View File
@@ -0,0 +1,32 @@
//----------------------------------------------------------------------------
// EgalTech 2025-2025
//----------------------------------------------------------------------------
// File : ImportPly.h Data : 28.02.25 Versione : 2.7b2
// Contenuto : Dichiarazione della classe ImportPly.
//
//
//
// Modifiche : 28.02.25 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "miniply.h"
#include "/EgtDev/Include/EExImportPly.h"
//----------------------------------------------------------------------------
class ImportPly : public IImportPly
{
public :
virtual bool Import( const std::string& sFile, IGeomDB* pGDB, int nIdGroup, double dScaleFactor = 1) ;
private :
bool ReadData( miniply::PLYReader& TheReader) ;
private :
IGeomDB* m_pGDB ;
int m_nIdGroup ;
double m_dScaleFactor ;
} ;
-1
View File
@@ -18,7 +18,6 @@
#include "/EgtDev/Include/EExDllMain.h" #include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDEv/Include/EGnScanner.h" #include "/EgtDEv/Include/EGnScanner.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ; using namespace std ;
+7 -8
View File
@@ -16,13 +16,10 @@
#include "ImportStl.h" #include "ImportStl.h"
#include "DllMain.h" #include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h" #include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDEv/Include/EGnScanner.h" #include "/EgtDEv/Include/EGnScanner.h"
#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtPointerOwner.h"
#include <fstream> #include <fstream>
@@ -199,14 +196,16 @@ ImportStl::LoadSolid( Scanner& TheScanner, bool& bEnd)
return false ; return false ;
} }
// inserisco l'oggetto nel DB geometrico // inserisco l'oggetto nel DB geometrico
ISurfTriMesh* pSTM = StmFts.GetSurf() ; PtrOwner<ISurfTriMesh> pSTM( StmFts.GetSurf()) ;
int nIdNew = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, pSTM) ; int nIdNew = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, Release( pSTM)) ;
if ( nIdNew == GDB_ID_NULL)
return false ;
// se previsto il nome, lo assegno // se previsto il nome, lo assegno
if ( ! sName.empty()) if ( ! sName.empty())
m_pGDB->SetName( nIdNew, sName) ; m_pGDB->SetName( nIdNew, sName) ;
bEnd = false ; bEnd = false ;
return ( nIdNew != GDB_ID_NULL) ; return true ;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
+2058
View File
File diff suppressed because it is too large Load Diff
+317
View File
@@ -0,0 +1,317 @@
/*
MIT License
Copyright (c) 2019 Vilya Harvey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef MINIPLY_H
#define MINIPLY_H
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#include <string>
#include <vector>
/// miniply - A simple and fast parser for PLY files
/// ================================================
///
/// For details about the PLY format see:
/// * http://paulbourke.net/dataformats/ply/
/// * https://en.wikipedia.org/wiki/PLY_(file_format)
namespace miniply {
//
// Constants
//
static constexpr uint32_t kInvalidIndex = 0xFFFFFFFFu;
// Standard PLY element names
extern const char* kPLYVertexElement; // "vertex"
extern const char* kPLYFaceElement; // "face"
//
// PLY Parsing types
//
enum class PLYFileType {
ASCII,
Binary,
BinaryBigEndian,
};
enum class PLYPropertyType {
Char,
UChar,
Short,
UShort,
Int,
UInt,
Float,
Double,
None, //!< Special value used in Element::listCountType to indicate a non-list property.
};
struct PLYProperty {
std::string name;
PLYPropertyType type = PLYPropertyType::None; //!< Type of the data. Must be set to a value other than None.
PLYPropertyType countType = PLYPropertyType::None; //!< None indicates this is not a list type, otherwise it's the type for the list count.
uint32_t offset = 0; //!< Byte offset from the start of the row.
uint32_t stride = 0;
std::vector<uint8_t> listData;
std::vector<uint32_t> rowCount; // Entry `i` is the number of items (*not* the number of bytes) in row `i`.
};
struct PLYElement {
std::string name; //!< Name of this element.
std::vector<PLYProperty> properties;
uint32_t count = 0; //!< The number of items in this element (e.g. the number of vertices if this is the vertex element).
bool fixedSize = true; //!< `true` if there are only fixed-size properties in this element, i.e. no list properties.
uint32_t rowStride = 0; //!< The number of bytes from the start of one row to the start of the next, for this element.
void calculate_offsets();
/// Returns the index for the named property in this element, or `kInvalidIndex`
/// if it can't be found.
uint32_t find_property(const char* propName) const;
/// Return the indices for several properties in one go. Use it like this:
/// ```
/// uint32_t indexes[3];
/// if (elem.find_properties(indexes, 3, "foo", "bar", "baz")) { ... }
/// ```
/// `propIdxs` is where the property indexes will be stored. `numIdxs` is
/// the number of properties we will look up. There must be exactly
/// `numIdxs` parameters after `numIdxs`; each of the is a c-style string
/// giving the name of a property.
///
/// The return value will be true if all properties were found. If it was
/// not true, you should not use any values from propIdxs.
bool find_properties(uint32_t propIdxs[], uint32_t numIdxs, ...) const;
/// Same as `find_properties`, for when you already have a `va_list`. This
/// is called internally by both `PLYElement::find_properties` and
/// `PLYReader::find_properties`.
bool find_properties_va(uint32_t propIdxs[], uint32_t numIdxs, va_list names) const;
/// Call this on the element at some point before you load its data, when
/// you know that every row's list will have the same length. It will
/// replace the single variable-size property with a set of new fixed-size
/// properties: one for the list count, followed by one for each of the
/// list values. This will allow miniply to load and extract the property
/// data a lot more efficiently, giving a big performance increase.
///
/// After you've called this, you must use PLYReader's `extract_columns`
/// method to get the data, rather than `extract_list_column`.
///
/// The `newPropIdxs` parameter must be an array with at least `listSize`
/// entries. If the function returns true, this will have been populated
/// with the indices of the new properties that represent the list values
/// (i.e. not including the list count property, which will have the same
/// index as the old list property).
///
/// The function returns false if the property index is invalid, or the
/// property it refers to is not a list property. In these cases it will
/// not modify anything. Otherwise it will return true.
bool convert_list_to_fixed_size(uint32_t listPropIdx, uint32_t listSize, uint32_t newPropIdxs[]);
};
class PLYReader {
public:
PLYReader(const char* filename);
~PLYReader();
bool valid() const;
bool has_element() const;
const PLYElement* element() const;
bool load_element();
void next_element();
PLYFileType file_type() const;
int version_major() const;
int version_minor() const;
uint32_t num_elements() const;
uint32_t find_element(const char* name) const;
PLYElement* get_element(uint32_t idx);
/// Check whether the current element has the given name.
bool element_is(const char* name) const;
/// Number of rows in the current element.
uint32_t num_rows() const;
/// Returns the index for the named property in the current element, or
/// `kInvalidIndex` if it can't be found.
uint32_t find_property(const char* name) const;
/// Equivalent to calling `find_properties` on the current element.
bool find_properties(uint32_t propIdxs[], uint32_t numIdxs, ...) const;
/// Copy the data for the specified properties into `dest`, which must be
/// an array with at least enough space to hold all of the extracted column
/// data. `propIdxs` is an array containing the indexes of the properties
/// to copy; it has `numProps` elements.
///
/// `destType` specifies the data type for values stored in `dest`. All
/// property values will be converted to this type if necessary.
///
/// This function does some checks up front to pick the most efficient code
/// path for extracting the data. It considers:
/// (a) whether any data conversion is required.
/// (b) whether all property values to be extracted are in contiguous
/// memory locations for any given item.
/// (c) whether the data for all rows is contiguous in memory.
/// In the best case it reduces to a single memcpy call. In the worst case
/// we must iterate over all values to be copied, applying type conversions
/// as we go.
///
/// Note that this function does not handle list-valued properties. Use
/// `extract_list_column()` for those instead.
bool extract_properties(const uint32_t propIdxs[], uint32_t numProps, PLYPropertyType destType, void* dest) const;
/// The same as `extract_properties`, but does not require rows in the
/// destination to be contiguous: `destStride` is the number of bytes
/// between the start of one row and the start of the next row in the
/// destination memory.
///
/// This is useful for when your destination is an array of structs where
/// you cannot extract all of the properties with a single
/// `extract_properties` call, e.g. when not all of the struct members
/// have the same type, or when the data you're extracting is only a
/// subset of the columns in each destination row.
///
/// This is a tiny bit slower than `extract_properties`. Wherever possible
/// you should use `extract_properties` in preference to this method.
bool extract_properties_with_stride(const uint32_t propIdxs[], uint32_t numProps, PLYPropertyType destType, void* dest, uint32_t destStride) const;
/// Get the array of item counts for a list property. Entry `i` in this
/// array is the number of items in the `i`th list.
const uint32_t* get_list_counts(uint32_t propIdx) const;
/// Get the sum of all item counts for a list property. This can be useful
/// to determine how big a destination array you'll need for a call to
/// `extract_list_property`. It's equivalent to summing up all the values
/// in the array returned by `get_list_counts`, but faster.
uint32_t sum_of_list_counts(uint32_t propIdx) const;
const uint8_t* get_list_data(uint32_t propIdx) const;
bool extract_list_property(uint32_t propIdx, PLYPropertyType destType, void* dest) const;
uint32_t num_triangles(uint32_t propIdx) const;
bool requires_triangulation(uint32_t propIdx) const;
bool extract_triangles(uint32_t propIdx, const float pos[], uint32_t numVerts, PLYPropertyType destType, void* dest) const;
bool find_pos(uint32_t propIdxs[3]) const;
bool find_normal(uint32_t propIdxs[3]) const;
bool find_texcoord(uint32_t propIdxs[2]) const;
bool find_color(uint32_t propIdxs[3]) const;
bool find_indices(uint32_t propIdxs[1]) const;
private:
bool refill_buffer();
bool rewind_to_safe_char();
bool accept();
bool advance();
bool next_line();
bool match(const char* str);
bool which(const char* values[], uint32_t* index);
bool which_property_type(PLYPropertyType* type);
bool keyword(const char* kw);
bool identifier(char* dest, size_t destLen);
template <class T> // T must be a type compatible with uint32_t.
bool typed_which(const char* values[], T* index) {
return which(values, reinterpret_cast<uint32_t*>(index));
}
bool int_literal(int* value);
bool float_literal(float* value);
bool double_literal(double* value);
bool parse_elements();
bool parse_element();
bool parse_property(std::vector<PLYProperty>& properties);
bool load_fixed_size_element(PLYElement& elem);
bool load_variable_size_element(PLYElement& elem);
bool load_ascii_scalar_property(PLYProperty& prop, size_t& destIndex);
bool load_ascii_list_property(PLYProperty& prop);
bool load_binary_scalar_property(PLYProperty& prop, size_t& destIndex);
bool load_binary_list_property(PLYProperty& prop);
bool load_binary_scalar_property_big_endian(PLYProperty& prop, size_t& destIndex);
bool load_binary_list_property_big_endian(PLYProperty& prop);
bool ascii_value(PLYPropertyType propType, uint8_t value[8]);
private:
FILE* m_f = nullptr;
char* m_buf = nullptr;
const char* m_bufEnd = nullptr;
const char* m_pos = nullptr;
const char* m_end = nullptr;
bool m_inDataSection = false;
bool m_atEOF = false;
int64_t m_bufOffset = 0;
bool m_valid = false;
PLYFileType m_fileType = PLYFileType::ASCII; //!< Whether the file was ascii, binary little-endian, or binary big-endian.
int m_majorVersion = 0;
int m_minorVersion = 0;
std::vector<PLYElement> m_elements; //!< Element descriptors for this file.
size_t m_currentElement = 0;
bool m_elementLoaded = false;
std::vector<uint8_t> m_elementData;
char* m_tmpBuf = nullptr;
};
/// Given a polygon with `n` vertices, where `n` > 3, triangulate it and
/// store the indices for the resulting triangles in `dst`. The `pos`
/// parameter is the array of all vertex positions for the mesh; `indices` is
/// the list of `n` indices for the polygon we're triangulating; and `dst` is
/// where we write the new indices to.
///
/// The triangulation will always produce `n - 2` triangles, so `dst` must
/// have enough space for `3 * (n - 2)` indices.
///
/// If `n == 3`, we simply copy the input indices to `dst`. If `n < 3`,
/// nothing gets written to dst.
///
/// The return value is the number of triangles.
uint32_t triangulate_polygon(uint32_t n, const float pos[], uint32_t numVerts, const int indices[], int dst[]);
} // namespace miniply
#endif // MINIPLY_H
+38 -38
View File
@@ -1,15 +1,15 @@
/** /**
* pugixml parser - version 1.11 * pugixml parser - version 1.15
* -------------------------------------------------------- * --------------------------------------------------------
* Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) * Copyright (C) 2006-2025, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/ * Report bugs and download new versions at https://pugixml.org/
* *
* This library is distributed under the MIT License. See notice at the end * This library is distributed under the MIT License. See notice at the end
* of this file. * of this file.
* *
* This work is based on the pugxml parser, which is: * This work is based on the pugxml parser, which is:
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/ */
#ifndef HEADER_PUGICONFIG_HPP #ifndef HEADER_PUGICONFIG_HPP
#define HEADER_PUGICONFIG_HPP #define HEADER_PUGICONFIG_HPP
@@ -46,35 +46,35 @@
// Uncomment this to switch to header-only version // Uncomment this to switch to header-only version
// #define PUGIXML_HEADER_ONLY // #define PUGIXML_HEADER_ONLY
// Uncomment this to enable long long support // Uncomment this to enable long long support (usually enabled automatically)
// #define PUGIXML_HAS_LONG_LONG // #define PUGIXML_HAS_LONG_LONG
// Uncomment this to enable support for std::string_view (usually enabled automatically)
// #define PUGIXML_HAS_STRING_VIEW
#endif #endif
/** /**
* Copyright (c) 2006-2020 Arseny Kapoulkine * Copyright (c) 2006-2025 Arseny Kapoulkine
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without * files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, * restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell * copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the * copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following * Software is furnished to do so, subject to the following
* conditions: * conditions:
* *
* The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
+9831 -9297
View File
File diff suppressed because it is too large Load Diff
+204 -119
View File
@@ -1,20 +1,20 @@
/** /**
* pugixml parser - version 1.11 * pugixml parser - version 1.15
* -------------------------------------------------------- * --------------------------------------------------------
* Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) * Copyright (C) 2006-2025, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/ * Report bugs and download new versions at https://pugixml.org/
* *
* This library is distributed under the MIT License. See notice at the end * This library is distributed under the MIT License. See notice at the end
* of this file. * of this file.
* *
* This work is based on the pugxml parser, which is: * This work is based on the pugxml parser, which is:
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/ */
#ifndef PUGIXML_VERSION
// Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons // Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons
// Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits // Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits
# define PUGIXML_VERSION 1110 #ifndef PUGIXML_VERSION
# define PUGIXML_VERSION 1150 // 1.15
#endif #endif
// Include user configuration file (this can define various configuration macros) // Include user configuration file (this can define various configuration macros)
@@ -38,6 +38,20 @@
# include <string> # include <string>
#endif #endif
// Check if std::string_view is available
#if !defined(PUGIXML_HAS_STRING_VIEW) && !defined(PUGIXML_NO_STL)
# if __cplusplus >= 201703L
# define PUGIXML_HAS_STRING_VIEW
# elif defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
# define PUGIXML_HAS_STRING_VIEW
# endif
#endif
// Include string_view if appropriate
#ifdef PUGIXML_HAS_STRING_VIEW
# include <string_view>
#endif
// Macro for deprecated features // Macro for deprecated features
#ifndef PUGIXML_DEPRECATED #ifndef PUGIXML_DEPRECATED
# if defined(__GNUC__) # if defined(__GNUC__)
@@ -82,14 +96,14 @@
# endif # endif
#endif #endif
// If C++ is 2011 or higher, add 'noexcept' specifiers // If C++ is 2011 or higher, use 'noexcept' specifiers
#ifndef PUGIXML_NOEXCEPT #ifndef PUGIXML_NOEXCEPT
# if __cplusplus >= 201103 # if __cplusplus >= 201103
# define PUGIXML_NOEXCEPT noexcept # define PUGIXML_NOEXCEPT noexcept
# elif defined(_MSC_VER) && _MSC_VER >= 1900 # elif defined(_MSC_VER) && _MSC_VER >= 1900
# define PUGIXML_NOEXCEPT noexcept # define PUGIXML_NOEXCEPT noexcept
# else # else
# define PUGIXML_NOEXCEPT # define PUGIXML_NOEXCEPT throw()
# endif # endif
#endif #endif
@@ -115,6 +129,8 @@
#ifndef PUGIXML_NULL #ifndef PUGIXML_NULL
# if __cplusplus >= 201103 # if __cplusplus >= 201103
# define PUGIXML_NULL nullptr # define PUGIXML_NULL nullptr
# elif defined(_MSC_VER) && _MSC_VER >= 1600
# define PUGIXML_NULL nullptr
# else # else
# define PUGIXML_NULL 0 # define PUGIXML_NULL 0
# endif # endif
@@ -136,7 +152,12 @@ namespace pugi
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE // String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
typedef std::basic_string<PUGIXML_CHAR, std::char_traits<PUGIXML_CHAR>, std::allocator<PUGIXML_CHAR> > string_t; typedef std::basic_string<PUGIXML_CHAR> string_t;
#endif
#ifdef PUGIXML_HAS_STRING_VIEW
// String view type used for operations that can work with a length delimited string; depends on PUGIXML_WCHAR_MODE
typedef std::basic_string_view<PUGIXML_CHAR> string_view_t;
#endif #endif
} }
@@ -211,6 +232,10 @@ namespace pugi
// This flag is off by default. // This flag is off by default.
const unsigned int parse_embed_pcdata = 0x2000; const unsigned int parse_embed_pcdata = 0x2000;
// This flag determines whether determines whether the the two pcdata should be merged or not, if no intermediatory data are parsed in the document.
// This flag is off by default.
const unsigned int parse_merge_pcdata = 0x4000;
// The default parsing mode. // The default parsing mode.
// Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded, // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded,
// End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
@@ -291,12 +316,12 @@ namespace pugi
class xml_text; class xml_text;
#ifndef PUGIXML_NO_XPATH #ifndef PUGIXML_NO_XPATH
class xpath_node; class xpath_node;
class xpath_node_set; class xpath_node_set;
class xpath_query; class xpath_query;
class xpath_variable_set; class xpath_variable_set;
#endif #endif
// Range-based for loop support // Range-based for loop support
template <typename It> class xml_object_range template <typename It> class xml_object_range
@@ -312,6 +337,8 @@ namespace pugi
It begin() const { return _begin; } It begin() const { return _begin; }
It end() const { return _end; } It end() const { return _end; }
bool empty() const { return _begin == _end; }
private: private:
It _begin, _end; It _begin, _end;
}; };
@@ -320,7 +347,7 @@ namespace pugi
class PUGIXML_CLASS xml_writer class PUGIXML_CLASS xml_writer
{ {
public: public:
virtual ~xml_writer() {} virtual ~xml_writer();
// Write memory chunk into stream/file/whatever // Write memory chunk into stream/file/whatever
virtual void write(const void* data, size_t size) = 0; virtual void write(const void* data, size_t size) = 0;
@@ -339,22 +366,22 @@ namespace pugi
void* file; void* file;
}; };
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// xml_writer implementation for streams // xml_writer implementation for streams
class PUGIXML_CLASS xml_writer_stream: public xml_writer class PUGIXML_CLASS xml_writer_stream: public xml_writer
{ {
public: public:
// Construct writer from an output stream object // Construct writer from an output stream object
xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream); xml_writer_stream(std::basic_ostream<char>& stream);
xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream); xml_writer_stream(std::basic_ostream<wchar_t>& stream);
virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE; virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
private: private:
std::basic_ostream<char, std::char_traits<char> >* narrow_stream; std::basic_ostream<char>* narrow_stream;
std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream; std::basic_ostream<wchar_t>* wide_stream;
}; };
#endif #endif
// A light-weight handle for manipulating attributes in DOM tree // A light-weight handle for manipulating attributes in DOM tree
class PUGIXML_CLASS xml_attribute class PUGIXML_CLASS xml_attribute
@@ -388,7 +415,7 @@ namespace pugi
bool operator<=(const xml_attribute& r) const; bool operator<=(const xml_attribute& r) const;
bool operator>=(const xml_attribute& r) const; bool operator>=(const xml_attribute& r) const;
// Check if attribute is empty // Check if attribute is empty (null)
bool empty() const; bool empty() const;
// Get attribute name/value, or "" if attribute is empty // Get attribute name/value, or "" if attribute is empty
@@ -404,17 +431,25 @@ namespace pugi
double as_double(double def = 0) const; double as_double(double def = 0) const;
float as_float(float def = 0) const; float as_float(float def = 0) const;
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_LONG_LONG
long long as_llong(long long def = 0) const; long long as_llong(long long def = 0) const;
unsigned long long as_ullong(unsigned long long def = 0) const; unsigned long long as_ullong(unsigned long long def = 0) const;
#endif #endif
// Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty
bool as_bool(bool def = false) const; bool as_bool(bool def = false) const;
// Set attribute name/value (returns false if attribute is empty or there is not enough memory) // Set attribute name/value (returns false if attribute is empty or there is not enough memory)
bool set_name(const char_t* rhs); bool set_name(const char_t* rhs);
bool set_name(const char_t* rhs, size_t size);
#ifdef PUGIXML_HAS_STRING_VIEW
bool set_name(string_view_t rhs);
#endif
bool set_value(const char_t* rhs); bool set_value(const char_t* rhs);
bool set_value(const char_t* rhs, size_t size);
#ifdef PUGIXML_HAS_STRING_VIEW
bool set_value(string_view_t rhs);
#endif
// Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
bool set_value(int rhs); bool set_value(int rhs);
@@ -427,10 +462,10 @@ namespace pugi
bool set_value(float rhs, int precision); bool set_value(float rhs, int precision);
bool set_value(bool rhs); bool set_value(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_LONG_LONG
bool set_value(long long rhs); bool set_value(long long rhs);
bool set_value(unsigned long long rhs); bool set_value(unsigned long long rhs);
#endif #endif
// Set attribute value (equivalent to set_value without error checking) // Set attribute value (equivalent to set_value without error checking)
xml_attribute& operator=(const char_t* rhs); xml_attribute& operator=(const char_t* rhs);
@@ -442,10 +477,14 @@ namespace pugi
xml_attribute& operator=(float rhs); xml_attribute& operator=(float rhs);
xml_attribute& operator=(bool rhs); xml_attribute& operator=(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_STRING_VIEW
xml_attribute& operator=(string_view_t rhs);
#endif
#ifdef PUGIXML_HAS_LONG_LONG
xml_attribute& operator=(long long rhs); xml_attribute& operator=(long long rhs);
xml_attribute& operator=(unsigned long long rhs); xml_attribute& operator=(unsigned long long rhs);
#endif #endif
// Get next/previous attribute in the attribute list of the parent node // Get next/previous attribute in the attribute list of the parent node
xml_attribute next_attribute() const; xml_attribute next_attribute() const;
@@ -497,7 +536,7 @@ namespace pugi
bool operator<=(const xml_node& r) const; bool operator<=(const xml_node& r) const;
bool operator>=(const xml_node& r) const; bool operator>=(const xml_node& r) const;
// Check if node is empty. // Check if node is empty (null)
bool empty() const; bool empty() const;
// Get node type // Get node type
@@ -536,9 +575,18 @@ namespace pugi
xml_attribute attribute(const char_t* name) const; xml_attribute attribute(const char_t* name) const;
xml_node next_sibling(const char_t* name) const; xml_node next_sibling(const char_t* name) const;
xml_node previous_sibling(const char_t* name) const; xml_node previous_sibling(const char_t* name) const;
#ifdef PUGIXML_HAS_STRING_VIEW
xml_node child(string_view_t name) const;
xml_attribute attribute(string_view_t name) const;
xml_node next_sibling(string_view_t name) const;
xml_node previous_sibling(string_view_t name) const;
#endif
// Get attribute, starting the search from a hint (and updating hint so that searching for a sequence of attributes is fast) // Get attribute, starting the search from a hint (and updating hint so that searching for a sequence of attributes is fast)
xml_attribute attribute(const char_t* name, xml_attribute& hint) const; xml_attribute attribute(const char_t* name, xml_attribute& hint) const;
#ifdef PUGIXML_HAS_STRING_VIEW
xml_attribute attribute(string_view_t name, xml_attribute& hint) const;
#endif
// Get child value of current node; that is, value of the first child node of type PCDATA/CDATA // Get child value of current node; that is, value of the first child node of type PCDATA/CDATA
const char_t* child_value() const; const char_t* child_value() const;
@@ -548,13 +596,27 @@ namespace pugi
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value) // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
bool set_name(const char_t* rhs); bool set_name(const char_t* rhs);
bool set_name(const char_t* rhs, size_t size);
#ifdef PUGIXML_HAS_STRING_VIEW
bool set_name(string_view_t rhs);
#endif
bool set_value(const char_t* rhs); bool set_value(const char_t* rhs);
bool set_value(const char_t* rhs, size_t size);
#ifdef PUGIXML_HAS_STRING_VIEW
bool set_value(string_view_t rhs);
#endif
// Add attribute with specified name. Returns added attribute, or empty attribute on errors. // Add attribute with specified name. Returns added attribute, or empty attribute on errors.
xml_attribute append_attribute(const char_t* name); xml_attribute append_attribute(const char_t* name);
xml_attribute prepend_attribute(const char_t* name); xml_attribute prepend_attribute(const char_t* name);
xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr); xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr);
xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr); xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr);
#ifdef PUGIXML_HAS_STRING_VIEW
xml_attribute append_attribute(string_view_t name);
xml_attribute prepend_attribute(string_view_t name);
xml_attribute insert_attribute_after(string_view_t name, const xml_attribute& attr);
xml_attribute insert_attribute_before(string_view_t name, const xml_attribute& attr);
#endif
// Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors. // Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors.
xml_attribute append_copy(const xml_attribute& proto); xml_attribute append_copy(const xml_attribute& proto);
@@ -573,6 +635,12 @@ namespace pugi
xml_node prepend_child(const char_t* name); xml_node prepend_child(const char_t* name);
xml_node insert_child_after(const char_t* name, const xml_node& node); xml_node insert_child_after(const char_t* name, const xml_node& node);
xml_node insert_child_before(const char_t* name, const xml_node& node); xml_node insert_child_before(const char_t* name, const xml_node& node);
#ifdef PUGIXML_HAS_STRING_VIEW
xml_node append_child(string_view_t name);
xml_node prepend_child(string_view_t name);
xml_node insert_child_after(string_view_t, const xml_node& node);
xml_node insert_child_before(string_view_t name, const xml_node& node);
#endif
// Add a copy of the specified node as a child. Returns added node, or empty node on errors. // Add a copy of the specified node as a child. Returns added node, or empty node on errors.
xml_node append_copy(const xml_node& proto); xml_node append_copy(const xml_node& proto);
@@ -589,6 +657,9 @@ namespace pugi
// Remove specified attribute // Remove specified attribute
bool remove_attribute(const xml_attribute& a); bool remove_attribute(const xml_attribute& a);
bool remove_attribute(const char_t* name); bool remove_attribute(const char_t* name);
#ifdef PUGIXML_HAS_STRING_VIEW
bool remove_attribute(string_view_t name);
#endif
// Remove all attributes // Remove all attributes
bool remove_attributes(); bool remove_attributes();
@@ -596,6 +667,9 @@ namespace pugi
// Remove specified child // Remove specified child
bool remove_child(const xml_node& n); bool remove_child(const xml_node& n);
bool remove_child(const char_t* name); bool remove_child(const char_t* name);
#ifdef PUGIXML_HAS_STRING_VIEW
bool remove_child(string_view_t name);
#endif
// Remove all children // Remove all children
bool remove_children(); bool remove_children();
@@ -657,10 +731,10 @@ namespace pugi
xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const; xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Get the absolute node path from root as a text string. // Get the absolute node path from root as a text string.
string_t path(char_t delimiter = '/') const; string_t path(char_t delimiter = '/') const;
#endif #endif
// Search for a node by path consisting of node names and . or .. elements. // Search for a node by path consisting of node names and . or .. elements.
xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const; xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const;
@@ -668,7 +742,7 @@ namespace pugi
// Recursively traverse subtree with xml_tree_walker // Recursively traverse subtree with xml_tree_walker
bool traverse(xml_tree_walker& walker); bool traverse(xml_tree_walker& walker);
#ifndef PUGIXML_NO_XPATH #ifndef PUGIXML_NO_XPATH
// Select single node by evaluating XPath query. Returns first node from the resulting node set. // Select single node by evaluating XPath query. Returns first node from the resulting node set.
xpath_node select_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; xpath_node select_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const;
xpath_node select_node(const xpath_query& query) const; xpath_node select_node(const xpath_query& query) const;
@@ -681,16 +755,16 @@ namespace pugi
PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const;
PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const; PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const;
#endif #endif
// Print subtree using a writer object // Print subtree using a writer object
void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Print subtree to stream // Print subtree to stream
void print(std::basic_ostream<char, std::char_traits<char> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; void print(std::basic_ostream<char>& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
void print(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const; void print(std::basic_ostream<wchar_t>& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const;
#endif #endif
// Child nodes iterators // Child nodes iterators
typedef xml_node_iterator iterator; typedef xml_node_iterator iterator;
@@ -706,9 +780,12 @@ namespace pugi
// Range-based for support // Range-based for support
xml_object_range<xml_node_iterator> children() const; xml_object_range<xml_node_iterator> children() const;
xml_object_range<xml_named_node_iterator> children(const char_t* name) const;
xml_object_range<xml_attribute_iterator> attributes() const; xml_object_range<xml_attribute_iterator> attributes() const;
// Range-based for support for all children with the specified name
// Note: name pointer must have a longer lifetime than the returned object; be careful with passing temporaries!
xml_object_range<xml_named_node_iterator> children(const char_t* name) const;
// Get node offset in parsed file/string (in char_t units) for debugging purposes // Get node offset in parsed file/string (in char_t units) for debugging purposes
ptrdiff_t offset_debug() const; ptrdiff_t offset_debug() const;
@@ -749,7 +826,7 @@ namespace pugi
// Borland C++ workaround // Borland C++ workaround
bool operator!() const; bool operator!() const;
// Check if text object is empty // Check if text object is empty (null)
bool empty() const; bool empty() const;
// Get text, or "" if object is empty // Get text, or "" if object is empty
@@ -764,16 +841,20 @@ namespace pugi
double as_double(double def = 0) const; double as_double(double def = 0) const;
float as_float(float def = 0) const; float as_float(float def = 0) const;
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_LONG_LONG
long long as_llong(long long def = 0) const; long long as_llong(long long def = 0) const;
unsigned long long as_ullong(unsigned long long def = 0) const; unsigned long long as_ullong(unsigned long long def = 0) const;
#endif #endif
// Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty
bool as_bool(bool def = false) const; bool as_bool(bool def = false) const;
// Set text (returns false if object is empty or there is not enough memory) // Set text (returns false if object is empty or there is not enough memory)
bool set(const char_t* rhs); bool set(const char_t* rhs);
bool set(const char_t* rhs, size_t size);
#ifdef PUGIXML_HAS_STRING_VIEW
bool set(string_view_t rhs);
#endif
// Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
bool set(int rhs); bool set(int rhs);
@@ -786,10 +867,10 @@ namespace pugi
bool set(float rhs, int precision); bool set(float rhs, int precision);
bool set(bool rhs); bool set(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_LONG_LONG
bool set(long long rhs); bool set(long long rhs);
bool set(unsigned long long rhs); bool set(unsigned long long rhs);
#endif #endif
// Set text (equivalent to set without error checking) // Set text (equivalent to set without error checking)
xml_text& operator=(const char_t* rhs); xml_text& operator=(const char_t* rhs);
@@ -801,10 +882,14 @@ namespace pugi
xml_text& operator=(float rhs); xml_text& operator=(float rhs);
xml_text& operator=(bool rhs); xml_text& operator=(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_STRING_VIEW
xml_text& operator=(string_view_t rhs);
#endif
#ifdef PUGIXML_HAS_LONG_LONG
xml_text& operator=(long long rhs); xml_text& operator=(long long rhs);
xml_text& operator=(unsigned long long rhs); xml_text& operator=(unsigned long long rhs);
#endif #endif
// Get the data node (node_pcdata or node_cdata) for this object // Get the data node (node_pcdata or node_cdata) for this object
xml_node data() const; xml_node data() const;
@@ -834,9 +919,9 @@ namespace pugi
typedef xml_node* pointer; typedef xml_node* pointer;
typedef xml_node& reference; typedef xml_node& reference;
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
typedef std::bidirectional_iterator_tag iterator_category; typedef std::bidirectional_iterator_tag iterator_category;
#endif #endif
// Default constructor // Default constructor
xml_node_iterator(); xml_node_iterator();
@@ -851,10 +936,10 @@ namespace pugi
xml_node& operator*() const; xml_node& operator*() const;
xml_node* operator->() const; xml_node* operator->() const;
const xml_node_iterator& operator++(); xml_node_iterator& operator++();
xml_node_iterator operator++(int); xml_node_iterator operator++(int);
const xml_node_iterator& operator--(); xml_node_iterator& operator--();
xml_node_iterator operator--(int); xml_node_iterator operator--(int);
}; };
@@ -876,9 +961,9 @@ namespace pugi
typedef xml_attribute* pointer; typedef xml_attribute* pointer;
typedef xml_attribute& reference; typedef xml_attribute& reference;
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
typedef std::bidirectional_iterator_tag iterator_category; typedef std::bidirectional_iterator_tag iterator_category;
#endif #endif
// Default constructor // Default constructor
xml_attribute_iterator(); xml_attribute_iterator();
@@ -893,10 +978,10 @@ namespace pugi
xml_attribute& operator*() const; xml_attribute& operator*() const;
xml_attribute* operator->() const; xml_attribute* operator->() const;
const xml_attribute_iterator& operator++(); xml_attribute_iterator& operator++();
xml_attribute_iterator operator++(int); xml_attribute_iterator operator++(int);
const xml_attribute_iterator& operator--(); xml_attribute_iterator& operator--();
xml_attribute_iterator operator--(int); xml_attribute_iterator operator--(int);
}; };
@@ -912,14 +997,15 @@ namespace pugi
typedef xml_node* pointer; typedef xml_node* pointer;
typedef xml_node& reference; typedef xml_node& reference;
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
typedef std::bidirectional_iterator_tag iterator_category; typedef std::bidirectional_iterator_tag iterator_category;
#endif #endif
// Default constructor // Default constructor
xml_named_node_iterator(); xml_named_node_iterator();
// Construct an iterator which points to the specified node // Construct an iterator which points to the specified node
// Note: name pointer is stored in the iterator and must have a longer lifetime than iterator itself
xml_named_node_iterator(const xml_node& node, const char_t* name); xml_named_node_iterator(const xml_node& node, const char_t* name);
// Iterator operators // Iterator operators
@@ -929,10 +1015,10 @@ namespace pugi
xml_node& operator*() const; xml_node& operator*() const;
xml_node* operator->() const; xml_node* operator->() const;
const xml_named_node_iterator& operator++(); xml_named_node_iterator& operator++();
xml_named_node_iterator operator++(int); xml_named_node_iterator operator++(int);
const xml_named_node_iterator& operator--(); xml_named_node_iterator& operator--();
xml_named_node_iterator operator--(int); xml_named_node_iterator operator--(int);
private: private:
@@ -1041,11 +1127,11 @@ namespace pugi
// Destructor, invalidates all node/attribute handles to this document // Destructor, invalidates all node/attribute handles to this document
~xml_document(); ~xml_document();
#ifdef PUGIXML_HAS_MOVE #ifdef PUGIXML_HAS_MOVE
// Move semantics support // Move semantics support
xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
xml_document& operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; xml_document& operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
#endif #endif
// Removes all nodes, leaving the empty document // Removes all nodes, leaving the empty document
void reset(); void reset();
@@ -1053,11 +1139,11 @@ namespace pugi
// Removes all nodes, then copies the entire contents of the specified document // Removes all nodes, then copies the entire contents of the specified document
void reset(const xml_document& proto); void reset(const xml_document& proto);
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Load document from stream. // Load document from stream.
xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); xml_parse_result load(std::basic_istream<char>& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
xml_parse_result load(std::basic_istream<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default); xml_parse_result load(std::basic_istream<wchar_t>& stream, unsigned int options = parse_default);
#endif #endif
// (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied. // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied.
PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default); PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
@@ -1083,11 +1169,11 @@ namespace pugi
// Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details). // Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details).
void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details). // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details).
void save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; void save(std::basic_ostream<char>& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
void save(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const; void save(std::basic_ostream<wchar_t>& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const;
#endif #endif
// Save XML to file // Save XML to file
bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
@@ -1185,11 +1271,11 @@ namespace pugi
xpath_variable_set(const xpath_variable_set& rhs); xpath_variable_set(const xpath_variable_set& rhs);
xpath_variable_set& operator=(const xpath_variable_set& rhs); xpath_variable_set& operator=(const xpath_variable_set& rhs);
#ifdef PUGIXML_HAS_MOVE #ifdef PUGIXML_HAS_MOVE
// Move semantics support // Move semantics support
xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT; xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT; xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
#endif #endif
// Add a new variable or get the existing one, if the types match // Add a new variable or get the existing one, if the types match
xpath_variable* add(const char_t* name, xpath_value_type type); xpath_variable* add(const char_t* name, xpath_value_type type);
@@ -1229,11 +1315,11 @@ namespace pugi
// Destructor // Destructor
~xpath_query(); ~xpath_query();
#ifdef PUGIXML_HAS_MOVE #ifdef PUGIXML_HAS_MOVE
// Move semantics support // Move semantics support
xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT; xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT;
xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT; xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT;
#endif #endif
// Get query expression return type // Get query expression return type
xpath_value_type return_type() const; xpath_value_type return_type() const;
@@ -1246,11 +1332,11 @@ namespace pugi
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
double evaluate_number(const xpath_node& n) const; double evaluate_number(const xpath_node& n) const;
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Evaluate expression as string value in the specified context; performs type conversion if necessary. // Evaluate expression as string value in the specified context; performs type conversion if necessary.
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
string_t evaluate_string(const xpath_node& n) const; string_t evaluate_string(const xpath_node& n) const;
#endif #endif
// Evaluate expression as string value in the specified context; performs type conversion if necessary. // Evaluate expression as string value in the specified context; performs type conversion if necessary.
// At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero). // At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero).
@@ -1279,13 +1365,13 @@ namespace pugi
bool operator!() const; bool operator!() const;
}; };
#ifndef PUGIXML_NO_EXCEPTIONS #ifndef PUGIXML_NO_EXCEPTIONS
#if defined(_MSC_VER) #if defined(_MSC_VER)
// C4275 can be ignored in Visual C++ if you are deriving // C4275 can be ignored in Visual C++ if you are deriving
// from a type in the Standard C++ Library // from a type in the Standard C++ Library
#pragma warning(push) #pragma warning(push)
#pragma warning(disable: 4275) #pragma warning(disable: 4275)
#endif #endif
// XPath exception class // XPath exception class
class PUGIXML_CLASS xpath_exception: public std::exception class PUGIXML_CLASS xpath_exception: public std::exception
{ {
@@ -1297,15 +1383,15 @@ namespace pugi
explicit xpath_exception(const xpath_parse_result& result); explicit xpath_exception(const xpath_parse_result& result);
// Get error message // Get error message
virtual const char* what() const throw() PUGIXML_OVERRIDE; virtual const char* what() const PUGIXML_NOEXCEPT PUGIXML_OVERRIDE;
// Get parse result // Get parse result
const xpath_parse_result& result() const; const xpath_parse_result& result() const;
}; };
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif #endif
// XPath node class (either xml_node or xml_attribute) // XPath node class (either xml_node or xml_attribute)
class PUGIXML_CLASS xpath_node class PUGIXML_CLASS xpath_node
@@ -1379,11 +1465,11 @@ namespace pugi
xpath_node_set(const xpath_node_set& ns); xpath_node_set(const xpath_node_set& ns);
xpath_node_set& operator=(const xpath_node_set& ns); xpath_node_set& operator=(const xpath_node_set& ns);
#ifdef PUGIXML_HAS_MOVE #ifdef PUGIXML_HAS_MOVE
// Move semantics support // Move semantics support
xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT; xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT; xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
#endif #endif
// Get collection type // Get collection type
type_t type() const; type_t type() const;
@@ -1422,12 +1508,12 @@ namespace pugi
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Convert wide string to UTF8 // Convert wide string to UTF8
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str); std::basic_string<char> PUGIXML_FUNCTION as_utf8(const wchar_t* str);
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >& str); std::basic_string<char> PUGIXML_FUNCTION as_utf8(const std::basic_string<wchar_t>& str);
// Convert UTF8 to wide string // Convert UTF8 to wide string
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str); std::basic_string<wchar_t> PUGIXML_FUNCTION as_wide(const char* str);
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >& str); std::basic_string<wchar_t> PUGIXML_FUNCTION as_wide(const std::basic_string<char>& str);
#endif #endif
// Memory allocation function interface; returns pointer to allocated memory or NULL on failure // Memory allocation function interface; returns pointer to allocated memory or NULL on failure
@@ -1474,27 +1560,26 @@ namespace std
#endif #endif
/** /**
* Copyright (c) 2006-2020 Arseny Kapoulkine * Copyright (c) 2006-2025 Arseny Kapoulkine
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without * files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, * restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell * copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the * copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following * Software is furnished to do so, subject to the following
* conditions: * conditions:
* *
* The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
+2
View File
@@ -31,8 +31,10 @@
#pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "EgtNumKernel" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "EgtNumKernel" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "EgtExecutor" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "SEgtLock" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "SEgtLock" EGTLIBVER ".lib")
#pragma comment(lib, EGTEXTDIR "/libzip/Lib/zip" EGTLIBVER ".lib") #pragma comment(lib, EGTEXTDIR "/libzip/Lib/zip" EGTLIBVER ".lib")
#pragma comment(lib, EGTEXTDIR "/lib3mf/Lib/lib3mf" EGTLIBVER ".lib") #pragma comment(lib, EGTEXTDIR "/lib3mf/Lib/lib3mf" EGTLIBVER ".lib")
#pragma comment(lib, EGTEXTDIR "Lua/Lib/Lua54" EGTLIBVER ".lib")