89 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
Dario Sassi 0dd44e569a EgtExchange 2.5l3 :
- in import DXF sistemata gestione SPLINE per modifiche a EgtGeomKernel.
2023-12-18 19:57:02 +01:00
Dario Sassi ba8a4c8914 EgtExchange 2.5l1 :
- ricompilazione con cambio versione.
2023-12-01 16:45:09 +01:00
Dario Sassi 55fb88d85b Merge commit 'f25473dfd205909deb17cb433a8658d11991fc52' 2023-11-28 09:37:45 +01:00
Dario Sassi b8fb6d9a07 EgtExchange :
- in import BTL aggiunta correzione P04=63, valore errato messo a 0.
2023-11-28 09:25:00 +01:00
SaraP f25473dfd2 EgtExchange :
- piccola correzione export stl.
2023-11-27 14:48:28 +01:00
Dario Sassi 977fe9f016 EgtExchange :
- in import BTL resa migliore l'approssimazione di FreeContour generati da due percorsi.
2023-11-22 20:23:51 +01:00
Dario Sassi d38beed861 EgtExchange :
- import/export 3dm spostati nella libreria EgtExch3dm.
2023-11-14 18:56:47 +01:00
Daniele Bariletti 55a02dc387 EgtExchange :
- formattazione dell'import dei layer nell'Import3dm.
2023-11-14 15:14:34 +01:00
Daniele Bariletti e18833d837 Merge branch 'master' of https://gitlab.steamware.net/egaltech/EgtExchange 2023-11-13 17:10:31 +01:00
Daniele Bariletti 7d25e262c2 EgtExchange :
- correzione nella gestione dei layer nell'Import3dm.
2023-11-13 17:10:02 +01:00
Dario Sassi e32c603647 EgtExchange :
- riportate modifiche a import BTL per process Variant
- in export 3MF modifiche di indentazione.
2023-11-12 19:29:22 +01:00
Daniele Bariletti b6847a3da7 EgtExchage :
- miglioria al filtro degli oggetti/gruppi negli Export 3MF, Stl,
ThreeJS e Dxf
- modifiche di stile minori a Export3dm.
2023-11-09 15:47:06 +01:00
Daniele Bariletti 0316c32afb EgtExchange :
- piccole modifiche.
2023-11-09 12:53:12 +01:00
Dario Sassi 0db5c4aa91 EgtExchange 2.5k2 :
- in import BTL estesa gestione processo Variant (0/1/2/3/4-900-x).
2023-11-08 17:58:29 +01:00
SaraP 4399074418 EgtExchange :
- piccole modifiche Import3dm.
2023-11-08 17:03:48 +01:00
Daniele Bariletti e0dcd3f3ac EgtExchange 2.5k2 :
- rimosso l'argomento dScaleFactor da Import3dm.
2023-11-08 10:47:38 +01:00
Daniele Bariletti 7a78c4e832 EgtExchange :
- cambio versione.
2023-11-08 08:45:37 +01:00
Daniele Bariletti 77447763b3 Merge branch '3dm_import' 2023-11-07 17:52:47 +01:00
Dario Sassi 1636f8c0b4 EgtExchange :
- in import BTL modifiche a FrontSlot per eliminare facce con dietro materiale trascurabile.
2023-11-06 19:52:13 +01:00
Dario Sassi 281e7183bd EgtExchange 2.5k1 :
- ricompilazione con cambio versione.
2023-11-03 17:23:48 +01:00
50 changed files with 15294 additions and 13184 deletions
+277 -92
View File
@@ -22,6 +22,7 @@
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringEncoder.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <future>
using namespace std ;
@@ -70,7 +71,8 @@ BeamMgr::SetFlag( int nFlag)
bool bSpecialTrim = (( nFlag & EIBFLAG_SPECIAL_TRIM) != 0) ;
bool bTrimWithOutline = (( nFlag & EIBFLAG_TRIM_WITH_OUTLINE) != 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")
return false ;
}
@@ -82,7 +84,7 @@ BeamMgr::SetFlag( int nFlag)
int
BeamMgr::CreatePart( void)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return GDB_ID_NULL ;
// Aggiorno posizione
@@ -95,7 +97,7 @@ BeamMgr::CreatePart( void)
bool
BeamMgr::SetPart( int nPartId)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Imposto il pezzo come corrente
@@ -106,7 +108,7 @@ BeamMgr::SetPart( int nPartId)
bool
BeamMgr::ErasePart( void)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Cancello il pezzo corrente
@@ -117,7 +119,7 @@ BeamMgr::ErasePart( void)
bool
BeamMgr::UpdatePart( void)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Forzo aggiornamento del pezzo corrente
@@ -128,10 +130,10 @@ BeamMgr::UpdatePart( void)
bool
BeamMgr::SetPartProdNbr( int nProdNbr)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Verifico validità nuovo PDN
// Verifico validità nuovo PDN
if ( ! m_BtlGeom.VerifyNewPartProdNbr( nProdNbr))
return false ;
// Imposto il numero di produzione sul pezzo corrente
@@ -142,7 +144,7 @@ BeamMgr::SetPartProdNbr( int nProdNbr)
bool
BeamMgr::SetPartName( const string& sName)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Imposto il nome sul pezzo corrente
@@ -153,7 +155,7 @@ BeamMgr::SetPartName( const string& sName)
bool
BeamMgr::SetPartCount( int nCount)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Imposto il numero delle parti da produrre sul pezzo corrente
@@ -164,7 +166,7 @@ BeamMgr::SetPartCount( int nCount)
bool
BeamMgr::SetPartBox( double dLength, double dHeight, double dWidth, bool bUpdate)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Imposto le dimensioni sul pezzo corrente
@@ -185,10 +187,10 @@ BeamMgr::SetPartBox( double dLength, double dHeight, double dWidth, bool bUpdate
bool
BeamMgr::GetSideData( int nSide, Frame3d& frRef, double& dLength, double& dWidth, double& dHeight)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Verifico validità identificativo di faccia
// Verifico validità identificativo di faccia
if ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_RIGHT)
return false ;
// Recupero riferimento del pezzo corrente
@@ -210,7 +212,7 @@ BeamMgr::GetSideData( int nSide, Frame3d& frRef, double& dLength, double& dWidth
bool
BeamMgr::ShowFacesName( bool bShow)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Verifico esistenza del pezzo corrente
@@ -253,7 +255,7 @@ BeamMgr::ShowFacesName( bool bShow)
// porto il testo nel piano della faccia
Frame3d frRef = m_BtlGeom.GetSideFrame( nS) ;
pText->ToGlob( frRef) ;
// recupero eventuale nome già presente
// recupero eventuale nome già presente
int nOldTextId = m_pGDB->GetFirstNameInGroup( nFcsNameLayId, sFace) ;
// se gia presente, lo rimpiazzo
if ( nOldTextId != GDB_ID_NULL) {
@@ -293,7 +295,7 @@ BeamMgr::UpdateFacesName( void)
bool
BeamMgr::ShowLoadingSide( bool bShow, bool bFromLeft)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// 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,
int nCrvId, int nCrv2Id, bool bUpdate)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return GDB_ID_NULL ;
// 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,
int nCrvId, int nCrv2Id, bool bUpdate)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return GDB_ID_NULL ;
// Recupero il pezzo di appartenenza
@@ -464,7 +466,7 @@ BeamMgr::ModifyProcess( int nGeomId, int nGroup, int nProc, int nSide, const str
bool
BeamMgr::EraseProcess( int nGeomId, bool bUpdate)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Recupero il pezzo di appartenenza
@@ -528,7 +530,7 @@ MyEnableProcess( IGeomDB* pGDB, BtlGeom& BtlG, int nGeomId, bool bEnable)
bool
BeamMgr::EnableProcess( int nGeomId, bool bEnable, bool bUpdate)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Recupero il pezzo di appartenenza
@@ -560,6 +562,113 @@ BeamMgr::EnableProcess( int nGeomId, bool bEnable, bool bUpdate)
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*
RegularizeTriMesh( const ISurfTriMesh* pStm, double dStep)
@@ -627,11 +736,51 @@ RegularizeTriMesh( const ISurfTriMesh* pStm, double dStep)
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
BeamMgr::CalcSolid( int nPartId, bool bRecalc)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Verifico esistenza del pezzo
@@ -649,32 +798,34 @@ BeamMgr::CalcSolid( int nPartId, bool bRecalc)
m_pGDB->SetMaterial( nSolLayId, Color(255, 160, 32)) ;
}
int nSolidId = m_pGDB->GetFirstNameInGroup( nSolLayId, SOLID_SOLID_NAME) ;
const ISurfTriMesh* pOldStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nSolidId)) ;
if ( pOldStm == nullptr || pOldStm->GetFacetCount() == 0)
if ( ! m_pGDB->ExistsInfo( nSolidId, IKEY_VALID))
bRecalc = true ;
if ( bRecalc) {
BBox3d b3Box ;
m_pGDB->GetLocalBBox( nBoxId, b3Box, BBF_STANDARD) ;
Point3d ptMin ; double dDimX, dDimY, dDimz ;
if ( ! b3Box.GetMinDim( ptMin, dDimX, dDimY, dDimz))
const ISurfTriMesh* pOldStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nSolidId)) ;
if ( pOldStm == nullptr || pOldStm->IsEmpty())
bRecalc = true ;
// Se non necessario ricalcolo, esco con successo
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 ;
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 {
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 ;
m_pGDB->GetLocalBBox( nSolidId, b3Solid, BBF_STANDARD) ;
@@ -693,17 +844,21 @@ BeamMgr::CalcSolid( int nPartId, bool bRecalc)
int nDO = 1 ;
m_pGDB->GetInfo( nOutId, IKEY_DO, nDO) ;
if ( nDO != 0 && m_pGDB->GetGeoType( nOutId) == SRF_TRIMESH) {
// sempre standard
const ISurfTriMesh* pStmOut = GetSurfTriMesh( m_pGDB->GetGeoObj( nOutId)) ;
PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pStmOut, dStep)) ;
if ( ! IsNull( pStmTmp))
pStmOut = Get( pStmTmp) ;
if ( pStmOut == nullptr || ! pStm->Intersect( *pStmOut))
return false ;
if ( ! pStmOut->IsEmpty()) {
PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pStmOut, dStep)) ;
if ( ! IsNull( pStmTmp))
pStmOut = Get( pStmTmp) ;
if ( pStmOut == nullptr || ! pStm->Intersect( *pStmOut))
return false ;
}
}
nOutId = m_pGDB->GetNext( nOutId) ;
}
// ciclo sulle features
// ciclo su feature troncanti (taglio di testa,..)
int nProcLayId = m_pGDB->GetFirstNameInGroup( nPartId, PROCESSINGS_LAYER_NAME) ;
INTVECTOR vUsedFea ;
int nProcId = m_pGDB->GetFirstInGroup( nProcLayId) ;
while ( nProcId != GDB_ID_NULL) {
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_TRIM, nTrim) ;
if ( nDO != 0 && nTrim != 0 && m_pGDB->GetGeoType( nProcId) == SRF_TRIMESH) {
// recupero eventuale superficie originale
int nProcSurfId = nProcId ;
int nOrigId = 0 ;
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_ORIGID, nOrigId))
nProcSurfId += nOrigId ;
// se da utilizzare anche suerfici ausiliarie
if ( nTrim == 2) {
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))
int nGroup = 0 ;
int nProc = 0 ;
m_pGDB->GetInfo( nProcId, IKEY_GROUP, nGroup) ;
m_pGDB->GetInfo( nProcId, IKEY_PROC, nProc) ;
if ( IS_CUT( nGroup, nProc) || IS_DOUBLE_CUT( nGroup, nProc) ||
IS_TENON( nGroup, nProc) || IS_DOVETAIL_TENON( nGroup, nProc)) {
if ( ! IntersectOneFeature( nProcId, nTrim, dStep, m_pGDB, pStm))
return false ;
vUsedFea.push_back( 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) ;
return true ;
@@ -755,7 +905,7 @@ BeamMgr::CalcSolid( int nPartId, bool bRecalc)
int
BeamMgr::GetSolid( int nPartId) const
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Recupero layer del solido e Id del solido
@@ -768,7 +918,7 @@ BeamMgr::GetSolid( int nPartId) const
bool
BeamMgr::ShowSolid( int nPartId, bool bShow)
{
// Verifico validità GDB
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Verifico esistenza del pezzo
@@ -790,30 +940,54 @@ BeamMgr::ShowSolid( int nPartId, bool bShow)
//----------------------------------------------------------------------------
bool
BeamMgr::GetBuildingIsOn( void) const
BeamMgr::GetBuildingIsOn( int nAssGrpId) const
{
// verifico esistenza gruppo di assemblaggio
int nAssGrpId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ;
if ( nAssGrpId == GDB_ID_NULL)
// Verifico validità GDB
if ( m_pGDB == nullptr)
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
int nAssId = m_pGDB->GetFirstInGroup( nAssGrpId) ;
if ( nAssId == GDB_ID_NULL)
return false ;
// se contiene oggetti, assemblaggio è On
// se contiene oggetti, assemblaggio è On
return ( m_pGDB->GetGroupObjs( nAssId) > 0) ;
}
//----------------------------------------------------------------------------
bool
BeamMgr::ShowBuilding( bool bShow)
BeamMgr::ShowBuilding( int nAssGrpId, bool bShow)
{
// verifico esistenza gruppo di assemblaggio
int nAssGrpId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ;
if ( nAssGrpId == GDB_ID_NULL)
// Verifico validità GDB
if ( m_pGDB == nullptr)
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
int nAssId = m_pGDB->GetFirstInGroup( nAssGrpId) ;
while ( nAssId != GDB_ID_NULL) {
@@ -826,7 +1000,7 @@ BeamMgr::ShowBuilding( bool bShow)
if ( m_pGDB->GetInfo( nAssId, GDB_SI_SOURCE, nSouId)) {
m_pGDB->SetMode( nSouId, GDB_MD_STD) ;
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) {
int nCopyId = m_pGDB->Copy( nSouId, GDB_ID_NULL, GDB_ID_ROOT) ;
if ( nCopyId != GDB_ID_NULL) {
@@ -837,7 +1011,7 @@ BeamMgr::ShowBuilding( bool bShow)
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) ;
}
}
@@ -852,12 +1026,23 @@ BeamMgr::ShowBuilding( bool bShow)
m_pGDB->SetInfo( nBaseId, GDB_SI_SOURCE, nCopyId) ;
}
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
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 ;
}
+4 -2
View File
@@ -41,11 +41,13 @@ class BeamMgr : public IBeamMgr
int nCrvId, int nCrv2Id, bool bUpdate = true) override ;
bool EraseProcess( int nGeomId, 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 ;
int GetSolid( int nPartId) const override ;
bool ShowSolid( int nPartId, bool bShow) override ;
bool GetBuildingIsOn( void) const override ;
bool ShowBuilding( bool bShow) override ;
bool GetBuildingIsOn( int nAssGrpId) const override ;
bool ShowBuilding( int nAssGrpId, bool bShow) override ;
public :
BeamMgr( void) ;
+104 -7
View File
@@ -22,6 +22,7 @@
#include "/EgtDev/Include/EGkStmStandard.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
#include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <unordered_map>
@@ -30,6 +31,8 @@ using namespace std ;
//----------------------------------------------------------------------------
string BtlGeom::m_sBtlAuxDir ;
string BtlGeom::m_sBtlLuaLibsDir ;
string BtlGeom::m_sBtlLuaLastRequire ;
//----------------------------------------------------------------------------
BtlGeom::BtlGeom( void)
@@ -39,7 +42,9 @@ BtlGeom::BtlGeom( void)
m_bSpecialTrim = false ;
m_bTrimWithOutline = false ;
m_bUseUAttr = false ;
m_bPartOffset = false ;
m_BoxCol = Color( 255, 128, 0, 15) ;
m_OffsCol = Color( 255, 0, 0, 15) ;
m_OutsCol = Color( 224, 128, 0, 50) ;
m_ProcsCol = Color( 80, 160, 160, 100) ;
m_ProcsOffCol = Color( 160, 160, 160, 30) ;
@@ -58,11 +63,24 @@ BtlGeom::BtlGeom( void)
m_nSolidsId = GDB_ID_NULL ;
m_vtDim = V_NULL ;
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
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
m_pGDB = pGDB ;
@@ -73,17 +91,35 @@ BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bTrimWit
m_bSpecialTrim = bSpecialTrim ;
m_bTrimWithOutline = bTrimWithOutline ;
m_bUseUAttr = bUseUAttr ;
// se non esiste, creo gruppo per informazioni varie
m_nInfoId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, INFO_GROUP_NAME) ;
if ( m_nInfoId == GDB_ID_NULL && ! CreateInfoGroup())
m_bPartOffset = bPartOffset ;
// gruppo per informazioni varie, se in aggiunta lo creo sempre
m_nInfoId = ( bIsAdding ? GDB_ID_NULL : m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, INFO_GROUP_NAME)) ;
if ( bIsAdding && ! CreateInfoGroup())
return false ;
// se non esiste, creo gruppo per assemblaggio
m_nAsseId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ;
if ( m_nAsseId == GDB_ID_NULL && ! CreateAssemblyGroup())
// gruppo per assemblaggio, se in aggiunta lo creo sempre
m_nAsseId = ( bIsAdding ? GDB_ID_NULL : m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME)) ;
if ( bIsAdding && ! CreateAssemblyGroup())
return false ;
// recupero eventuali riferimenti a gruppi per grezzi e compositi
m_nRawPartsId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, RAWPARTS_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 ;
}
@@ -595,6 +631,67 @@ BtlGeom::AddObjectRef( const string& sUID, const Frame3d& frRef)
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
BtlGeom::ResetPartSolid( void)
+18 -5
View File
@@ -18,15 +18,16 @@
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkPolygon3d.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGnLuaMgr.h"
//----------------------------------------------------------------------------
class BtlGeom
{
public :
BtlGeom( void) ;
public :
bool Init( IGeomDB* pGDB, int nFlatPos, bool bSpecialTrim, bool bTrimWithOutline, bool bUseUAttr) ;
~BtlGeom( void) ;
bool Init( IGeomDB* pGDB, int nFlatPos, bool bSpecialTrim,
bool bTrimWithOutline, bool bUseUAttr, bool bPartOffset, bool bIsAdding) ;
bool CreatePart( void) ;
bool SetPart( int nPartId) ;
bool ErasePart( void) ;
@@ -49,6 +50,7 @@ class BtlGeom
{ return ( m_nPartId != GDB_ID_NULL ? m_vtDim.z : 0) ;}
bool AddPartTransformation( 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 ResetPartSolid( void) ;
std::string GetPartName( void) ;
@@ -210,6 +212,8 @@ class BtlGeom
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddRoundArch( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
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,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
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) ;
bool AddVariant( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
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) ;
ISurfTriMesh* CreateOneCurveFreeContour( const ICurveComposite* pCrvCompo) ;
bool AdjustFreeContourCurve( ICurve* pCrv, int nSide, bool& bClosed, bool& bEndsOnOrOutCont) ;
@@ -227,7 +235,7 @@ class BtlGeom
bool GetFreeContourCurveSideAngles( const ICurveComposite* pCrvCompo, DBLVECTOR& vSideAng) ;
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 GetPlaneElevation( const Plane3d& plPlane) ;
double GetDistanceBeamPlane( const Plane3d& plPlane) ;
bool TrimPolygons( Polygon3d& plyP1, Polygon3d& plyP2, bool bInVsOut, bool bOnEq) ;
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) ;
@@ -262,11 +270,14 @@ class BtlGeom
private :
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)
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_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_OffsCol ; // colore per offset pezzi
Color m_OutsCol ; // colore per outline pezzi
Color m_ProcsCol ; // colore per lavorazioni pezzi
Color m_ProcsOffCol ; // colore per lavorazioni pezzi disabilitate
@@ -291,5 +302,7 @@ class BtlGeom
FCEDEQUE m_FcData ; // dati per contorni liberi in definizione
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
} ;
+60 -1
View File
@@ -17,6 +17,56 @@
#include "/EgtDev/Include/EgtStringBase.h"
#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
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
static const std::string AUX_PART_NAME = "Name" ;
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_APERTURESTM_NAME = "Ape" ;
static const std::string OL_TOPREGION_NAME = "Top" ;
@@ -91,6 +142,7 @@ static const std::string IKEY_LSIDE = "LSIDE" ;
const double PART_OFFSET = 300 ;
// costanti di approssimazione per curve
const double CRV_LIN_APPROX = 0.05 ;
const double CRV_LIN_FINE_APPROX = 0.01 ;
const double CRV_ANG_APPROX_DEG = 22.5 ;
// costante di compattazione di superfici
const double STM_COMPACT_APPROX = 0.01 ;
@@ -101,6 +153,8 @@ const double FACE_MIN_BACK_MAT = 2.0 ;
const double FACE_MIN_BACK_AREA = 400.0 ;
// minimo materiale dietro la faccia, limite assoluto
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
const double MORTISE_DISPL_MIN = 0.5 ;
// raggio fresa di default
@@ -109,11 +163,12 @@ const double MILL_DEF_RAD = 12.5 ;
const double DTMILL_DEF_RAD = 30.0 ;
// angolo coda di rondine di default
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
const double DTMORT_EXTRA_LEN = 10.0 ;
// minima e massima dimensione tasca per mortasa a coda di rondine
const double MIN_DTMORT_POCKET = 70.0 ;
const double MAX_DTMORT_POCKET = 200.0 ;
const double MIN_DTMORT_AREA = 100.0 ;
// tolleranza fuoriuscita curve di tasche di code di rondine
const double DTMORT_OUT_CRV_TOL = 30.0 ;
@@ -122,6 +177,10 @@ const double FC_SIDEANG_DEF = 0.0 ;
const double FC_SIDEANG_NONE = 999.0 ;
// tolleranza fuoriuscita curve di contorni liberi
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
+14 -23
View File
@@ -496,9 +496,10 @@ BtlGeom::UpdateOutLine( void)
// taglio con tutte le features
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) ;
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) ;
while ( nEntId != GDB_ID_NULL) {
if ( nEntId != nShapeId)
@@ -1073,8 +1074,8 @@ BtlGeom::AdjustOneOutlineFace( int nSide, ICURVEPOVECTOR& vCrvP)
// concateno le linee senza invertirle
const double TOLER = 10 * EPS_SMALL ;
ChainCurves chainC ;
chainC.Init( false, TOLER, int( vCrvP.size())) ;
for ( size_t i = 0 ; i < vCrvP.size() ; ++ i) {
chainC.Init( false, TOLER, ssize( vCrvP)) ;
for ( int i = 0 ; i < ssize( vCrvP) ; ++ i) {
Point3d ptStart, ptEnd ;
Vector3d vtStart, vtEnd ;
if ( ! vCrvP[i]->GetStartPoint( ptStart) || ! vCrvP[i]->GetStartDir( vtStart) ||
@@ -1091,7 +1092,7 @@ BtlGeom::AdjustOneOutlineFace( int nSide, ICURVEPOVECTOR& vCrvP)
if ( IsNull( pCrvCompo))
return false ;
// 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
int j = vId2s[i] - 1 ;
// la aggiungo alla curva composta
@@ -1385,7 +1386,6 @@ BtlGeom::TrimProcessWithOutline( int nProcId)
bool
BtlGeom::AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints)
{
StmFromTriangleSoup StmFts ;
if ( ! StmFts.Start()) {
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
PtrOwner<ICurveComposite> pCurveCompo( CreateCurveComposite()) ;
pCurveCompo->AddPoint( vPoints[vVertices[0]]) ;
for ( size_t i = 1 ; i != vVertices.size() ; i++)
pCurveCompo->AddLine( vPoints[vVertices[i]]) ;
for ( int i = 1 ; i < ssize( vVertices) ; i++)
pCurveCompo->AddLine( vPoints[vVertices[i]]) ;
pCurveCompo->AddLine( vPoints[vVertices[0]]) ;
// creo la faccia e recupero i suoi triangoli
PtrOwner<ISurfTriMesh> pSurf( GetSurfTriMeshByFlatContour( pCurveCompo)) ;
if ( ! IsNull( pSurf)) {
// recupero tutti i triangoli
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 ( ! IsNull( pSurf))
StmFts.AddSurfTriMesh( *pSurf) ;
}
if ( ! StmFts.End()) {
@@ -1425,13 +1416,13 @@ BtlGeom::AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints
}
PtrOwner<ISurfTriMesh> pShape( StmFts.GetSurf()) ;
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nPartId + 3, Release( pShape)) ; // salvo in outline
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pShape)) ;
if ( nId == GDB_ID_NULL)
return false ;
m_pGDB->SetName( nId, OL_SHAPE_NAME) ;
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 ;
}
+781 -235
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
# Visual Studio 15
VisualStudioVersion = 15.0.28307.645
# Visual Studio Version 17
VisualStudioVersion = 17.12.35521.163
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtExchange", "EgtExchange.vcxproj", "{80FCBEA4-1883-4542-939D-8582E66D8D51}"
EndProject
+15 -12
View File
@@ -22,14 +22,14 @@
<ProjectGuid>{80FCBEA4-1883-4542-939D-8582E66D8D51}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>EgtExchange</RootNamespace>
<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -42,7 +42,7 @@
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -101,10 +101,10 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;I_AM_EEX;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<OpenMPSupport>true</OpenMPSupport>
<OpenMPSupport>false</OpenMPSupport>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -128,7 +128,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
<PreprocessorDefinitions>WIN32;I_AM_EEX;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<OpenMPSupport>true</OpenMPSupport>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>
</AdditionalOptions>
</ClCompile>
@@ -163,7 +163,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -197,7 +197,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile>
<Link>
@@ -232,6 +232,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="..\Include\EExImportCnc.h" />
<ClInclude Include="..\Include\EExImportCsf.h" />
<ClInclude Include="..\Include\EExImportDxf.h" />
<ClInclude Include="..\Include\EExImportOff.h" />
<ClInclude Include="..\Include\EExImportPnt.h" />
<ClInclude Include="..\Include\EExImportStl.h" />
<ClInclude Include="..\Include\EGkAngle.h" />
@@ -318,13 +319,11 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="DxfColors.h" />
<ClInclude Include="DxfConst.h" />
<ClInclude Include="ExcExecutor.h" />
<ClInclude Include="Export3dm.h" />
<ClInclude Include="Export3MF.h" />
<ClInclude Include="ExportDxf.h" />
<ClInclude Include="ExportStl.h" />
<ClInclude Include="ExportSvg.h" />
<ClInclude Include="ExportThreeJS.h" />
<ClInclude Include="Import3dm.h" />
<ClInclude Include="Import3MF.h" />
<ClInclude Include="ImportBtl.h" />
<ClInclude Include="BtlGeomCoStru.h" />
@@ -332,7 +331,10 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="ImportCnc.h" />
<ClInclude Include="ImportCsf.h" />
<ClInclude Include="ImportDxf.h" />
<ClInclude Include="ImportOff.h" />
<ClInclude Include="ImportPly.h" />
<ClInclude Include="ImportStl.h" />
<ClInclude Include="miniply.h" />
<ClInclude Include="pugiconfig.hpp" />
<ClInclude Include="pugixml.hpp" />
<ClInclude Include="resource.h" />
@@ -357,13 +359,11 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="ExcExecutor.cpp" />
<ClCompile Include="Export3dm.cpp" />
<ClCompile Include="Export3MF.cpp" />
<ClCompile Include="ExportDxf.cpp" />
<ClCompile Include="ExportStl.cpp" />
<ClCompile Include="ExportSvg.cpp" />
<ClCompile Include="ExportThreeJS.cpp" />
<ClCompile Include="Import3dm.cpp" />
<ClCompile Include="Import3MF.cpp" />
<ClCompile Include="ImportBtl.cpp" />
<ClCompile Include="BtlGeom.cpp" />
@@ -376,8 +376,11 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="ImportDxfEnts.cpp" />
<ClCompile Include="ImportDxfHeader.cpp" />
<ClCompile Include="ImportDxfTabs.cpp" />
<ClCompile Include="ImportOff.cpp" />
<ClCompile Include="ImportPly.cpp" />
<ClCompile Include="ImportPnt.cpp" />
<ClCompile Include="ImportStl.cpp" />
<ClCompile Include="miniply.cpp" />
<ClCompile Include="pugixml.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+13 -4
View File
@@ -375,10 +375,16 @@
<ClInclude Include="..\Include\SELkKeyProc.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="Import3dm.h">
<ClInclude Include="ImportOff.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Export3dm.h">
<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>
@@ -461,10 +467,13 @@
<ClCompile Include="ExportThreeJS.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Import3dm.cpp">
<ClCompile Include="ImportOff.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Export3dm.cpp">
<ClCompile Include="ImportPly.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="miniply.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
-1
View File
@@ -22,7 +22,6 @@
#include "/EgtDev/Include/EExImportCnc.h"
#include "/EgtDev/Include/EExImportDxf.h"
#include "/EgtDev/Include/EExImportStl.h"
#include "/EgtDev/Include/EExImport3dm.h"
using namespace std ;
+153 -123
View File
@@ -17,15 +17,9 @@
#include "Export3MF.h"
#include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
#include "/EgtDev/Include/EGkSurfTriMesh.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 Lib3MF ;
@@ -49,6 +43,7 @@ bool
Export3MF::SetOptions( int nFilter)
{
m_nFilter = nFilter ;
CalcGroupFilter() ;
return true ;
}
@@ -70,13 +65,13 @@ Export3MF::Export( IGeomDB* pGDB, int nId, const string& sFile)
// libreria 3MF
m_wrapper = CWrapper::loadLibrary() ;
if ( ! m_wrapper) {
if ( m_wrapper == nullptr) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Wrapper")
return false ;
}
// creo model per 3MF
m_model = m_wrapper->CreateModel() ;
if ( ! m_model) {
if ( m_model == nullptr) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Model")
return false ;
}
@@ -91,20 +86,10 @@ Export3MF::Export( IGeomDB* pGDB, int nId, const string& sFile)
return false ;
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
if ( ! ExportObject( *pIter))
return false ;
// scrivo il file
try {
PWriter writer = m_model->QueryWriter( "3mf") ;
@@ -122,82 +107,80 @@ Export3MF::Export( IGeomDB* pGDB, int nId, const string& sFile)
//----------------------------------------------------------------------------
bool
Export3MF::ExportObject( const IGdbIterator& iIter)
Export3MF::ExportObject( const IGdbIterator& iIter, PComponentsObject pParent, bool bSaveGrpAsComponent)
{
switch ( iIter.GetGdbType()) {
case GDB_TY_GEO :
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return true ;
// se non è una superficie esco
if ( pGeoObj->GetType() != SRF_TRIMESH && pGeoObj->GetType() != SRF_FLATRGN)
return true ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
// recupero il livello dell'oggetto
int nLev = GDB_LV_USER ;
iIter.GetCalcLevel( nLev) ;
// recupero il modo dell'oggetto
int nMode = GDB_MD_STD ;
iIter.GetCalcMode( nMode) ;
// recupero lo stato dell'oggetto
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat)) {
// recupero eventuale nome
string sName ;
if ( ! iIter.GetName( sName))
sName = ToString( iIter.GetId()) ;
// recupero il livello dell'oggetto
int nLev = GDB_LV_USER ;
iIter.GetCalcLevel( nLev) ;
// recupero il modo dell'oggetto
int nMode = GDB_MD_STD ;
iIter.GetCalcMode( nMode) ;
// recupero lo stato dell'oggetto
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
int nType = iIter.GetGdbType() ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat, nType == GDB_TY_GROUP)) {
// 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 :
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return false ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
// recupero il colore
Color cCol ;
bool bCol = GetColor( cCol, iIter.GetGDB(), iIter.GetId()) ;
// recupero le proprietà
STRVECTOR vInfo ;
iIter.GetAllInfo( vInfo) ;
iIter.GetCalcMaterial( cCol) ;
// emetto l'oggetto
switch ( pGeoObj->GetType()) {
switch ( nGeoType) {
case SRF_TRIMESH :
if ( ! ExportSTM( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr, vInfo))
return false ;
break ;
return ExportSTM( pGeoObj, frFrame, sName, vsInfo, cCol, pParent) ;
case SRF_FLATRGN :
if ( ! ExportSFR( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr, vInfo))
return false ;
break ;
return ExportSFR( pGeoObj, frFrame, sName, vsInfo, cCol, pParent) ;
default :
break ;
return false ;
}
}
}
return true ;
case GDB_TY_GROUP :
// esploro il gruppo
return ScanGroup( iIter) ;
default :
return false ;
}
case GDB_TY_GROUP :
return ExportGroup( iIter, sName, vsInfo, pParent, bSaveGrpAsComponent) ;
default :
return false ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
Export3MF::TestFilter( int nLev, int nMode, int nStat)
Export3MF::TestFilter( int nLev, int nMode, int nStat, bool bGroup) const
{
if ( ( nLev == GDB_LV_USER && ( m_nFilter & EEXFLT_LEVUSER) == 0) ||
( nLev == GDB_LV_SYSTEM && ( m_nFilter & EEXFLT_LEVSYSTEM) == 0) ||
( nLev == GDB_LV_TEMP && ( m_nFilter & EEXFLT_LEVTEMP) == 0))
int nFilter = bGroup ? m_nGroupFilter : m_nFilter ;
if ( ( nLev == GDB_LV_USER && ( nFilter & EEXFLT_LEVUSER) == 0) ||
( nLev == GDB_LV_SYSTEM && ( nFilter & EEXFLT_LEVSYSTEM) == 0) ||
( nLev == GDB_LV_TEMP && ( nFilter & EEXFLT_LEVTEMP) == 0))
return false ;
if ( ( nMode == GDB_MD_STD && ( m_nFilter & EEXFLT_MODESTD) == 0) ||
( nMode == GDB_MD_LOCKED && ( m_nFilter & EEXFLT_MODELOCKED) == 0) ||
( nMode == GDB_MD_HIDDEN && ( m_nFilter & EEXFLT_MODEHIDDEN) == 0))
if ( ( nMode == GDB_MD_STD && ( nFilter & EEXFLT_MODESTD) == 0) ||
( nMode == GDB_MD_LOCKED && ( nFilter & EEXFLT_MODELOCKED) == 0) ||
( nMode == GDB_MD_HIDDEN && ( nFilter & EEXFLT_MODEHIDDEN) == 0))
return false ;
if ( ( nStat == GDB_ST_OFF && ( m_nFilter & EEXFLT_STAOFF) == 0) ||
( nStat == GDB_ST_ON && ( m_nFilter & EEXFLT_STAON) == 0) ||
( nStat == GDB_ST_SEL && ( m_nFilter & EEXFLT_STASEL) == 0))
if ( ( nStat == GDB_ST_OFF && ( nFilter & EEXFLT_STAOFF) == 0) ||
( nStat == GDB_ST_ON && ( nFilter & EEXFLT_STAON) == 0) ||
( nStat == GDB_ST_SEL && ( nFilter & EEXFLT_STASEL) == 0))
return false ;
return true ;
@@ -205,7 +188,38 @@ Export3MF::TestFilter( int nLev, int nMode, int nStat)
//----------------------------------------------------------------------------
bool
Export3MF::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, const STRVECTOR& vInfo)
Export3MF::CalcGroupFilter( void)
{
m_nGroupFilter = 0 ;
// Status
if ( ( m_nFilter & EEXFLT_STASEL) != 0)
m_nGroupFilter += EEXFLT_STASEL + EEXFLT_STAOFF + EEXFLT_STAON ;
else if ( ( m_nFilter & EEXFLT_STAOFF) != 0)
m_nGroupFilter += EEXFLT_STAOFF + EEXFLT_STAON ;
else
m_nGroupFilter += EEXFLT_STAON ;
// Mode
if ( ( m_nFilter & EEXFLT_MODELOCKED) != 0)
m_nGroupFilter += EEXFLT_MODELOCKED + EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else if ( ( m_nFilter & EEXFLT_MODEHIDDEN) != 0)
m_nGroupFilter += EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else
m_nGroupFilter += EEXFLT_MODESTD ;
// Level
if ( ( m_nFilter & EEXFLT_LEVSYSTEM) != 0)
m_nGroupFilter += EEXFLT_LEVSYSTEM + EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else if ( ( m_nFilter & EEXFLT_LEVTEMP) != 0)
m_nGroupFilter += EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else
m_nGroupFilter += EEXFLT_LEVUSER ;
return true ;
}
//----------------------------------------------------------------------------
bool
Export3MF::ExportSFR( const IGeoObj* pGeoObj, const Frame3d& frFrame, const string& sName, const STRVECTOR& vInfo,
const Color& cCol, PComponentsObject pParent)
{
// verifico oggetto
const ISurfFlatRegion* pSFR = GetSurfFlatRegion( pGeoObj) ;
@@ -213,12 +227,13 @@ Export3MF::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d
return false ;
// ricavo la trimesh equivalente
const ISurfTriMesh* pStm = pSFR->GetAuxSurf() ;
return ExportSTM( sName, pStm, frFrame, pCol, vInfo) ;
return ExportSTM( pStm, frFrame, sName, vInfo, cCol, pParent) ;
}
//----------------------------------------------------------------------------
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
const ISurfTriMesh* pSTM = GetSurfTriMesh( pGeoObj) ;
@@ -241,7 +256,7 @@ Export3MF::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d
int k = 0 ;
for ( int i = 0 ; i < pSTM->GetTriangleSize() ; i++) {
int nIdVert[3] ;
// se il triangolo non è valido passo al successivo
// se il triangolo non è valido passo al successivo
if ( ! pSTM->GetTriangle( i, nIdVert))
continue ;
// assegno gli indici dei vertici
@@ -252,25 +267,21 @@ Export3MF::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d
}
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 ;
}
// creo mesh 3MF
PMeshObject meshObject = m_model->AddMeshObject() ;
if ( ! meshObject) {
if ( meshObject == nullptr) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Mesh Object")
return false ;
}
meshObject->SetName( sName) ;
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
PMetaDataGroup metaDataGrp = meshObject->GetMetaDataGroup() ;
for ( const string& sInfo : vInfo) {
@@ -278,60 +289,79 @@ Export3MF::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d
SplitFirst( sInfo, "=", sKey, sVal) ;
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 ;
}
//----------------------------------------------------------------------------
bool
Export3MF::ScanGroup( const IGdbIterator& iIter)
Export3MF::ExportGroup( const IGdbIterator& iIter, const string& sName, const STRVECTOR& vsInfo, PComponentsObject pParent,
bool bSaveAsComponent)
{
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( iIter.GetGDB())) ;
if ( IsNull( pIter))
return false ;
// scandisco il gruppo
bool bOk = true ;
for ( bool bNext = pIter->GoToFirstInGroup( iIter) ;
bNext ;
bNext = pIter->GoToNext()) {
if ( ! ExportObject( *pIter))
bOk = false ;
PComponentsObject pComponent = pParent ;
// se il layer va salvato come componente, la creo
if ( bSaveAsComponent) {
pComponent = m_model->AddComponentsObject() ;
if ( ! sName.empty())
pComponent->SetName( sName) ;
}
// salvo le info sulla componente ( se il gruppo viene esportato come tale) o sul modello
PMetaDataGroup metaDataGrp ;
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 ;
}
//----------------------------------------------------------------------------
bool
Export3MF::GetColor( Color& pCol, const IGeomDB * pGDB, const int& nId)
{
if ( nId == GDB_ID_NULL)
return false ;
if ( ! pGDB->GetMaterial( nId, pCol))
// se fallisce cerco il colore del parent
return GetColor( pCol, pGDB, pGDB->GetParentId( nId)) ;
// se il gruppo va salvato come componente, lo aggiungo al modello
if ( bSaveAsComponent && pComponent->GetComponentCount() > 0) {
if ( pParent == nullptr)
m_model->AddBuildItem( pComponent.get(), m_wrapper->GetIdentityTransform()) ;
else
pParent->AddComponent( pComponent.get(), m_wrapper->GetIdentityTransform()) ;
}
return true ;
}
//----------------------------------------------------------------------------
Lib3MF_uint32
Export3MF::ColorHandler3MF( const Color* pCol)
Export3MF::ColorHandler3MF( const Color& cCol)
{
PColorGroup pColorGrp = m_model->GetColorGroupByID( 1) ;
// converto il colore nel formato usato da 3MF
Lib3MF_uint8 nAlpha = ( int)( pCol->GetIntAlpha() * 2.55 + 0.5) ;
sColor cCol3mf = m_wrapper->RGBAToColor( pCol->GetIntRed(), pCol->GetIntGreen(), pCol->GetIntBlue(), nAlpha) ;
// verifico se il colore è già presente nel colorgroup
Lib3MF_uint8 nAlpha = ( int)( cCol.GetIntAlpha() * 2.55 + 0.5) ;
sColor cCol3mf = m_wrapper->RGBAToColor( cCol.GetIntRed(), cCol.GetIntGreen(), cCol.GetIntBlue(), nAlpha) ;
// verifico se il colore è già presente nel colorgroup
UINTVECTOR vColorIdx ;
pColorGrp->GetAllPropertyIDs( vColorIdx) ;
for ( Lib3MF_uint32 i : vColorIdx) {
sColor cColTmp = pColorGrp->GetColor( i) ;
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)
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)
return i ;
}
// se non fosse presente, lo aggiungo
+16 -12
View File
@@ -13,7 +13,7 @@
#pragma once
#define NOMINMAX
#define NOMINMAX
#include "/EgtDev/Extern/Lib3MF/Include/lib3mf_implicit.hpp"
#include "/EgtDev/Include/EExExport3MF.h"
@@ -27,21 +27,25 @@ class Export3MF : public IExport3MF
virtual bool Export( IGeomDB* pGDB, int nId, const std::string& sFile) ;
public :
Export3MF( void) : m_nFilter( EEXFLT_DEFAULT) {}
Export3MF( void) : m_nFilter( EEXFLT_DEFAULT) {
CalcGroupFilter() ;
}
private :
bool ExportObject( const IGdbIterator& iIter) ;
bool ScanGroup( const IGdbIterator& iIter) ;
bool TestFilter( int nLev, int nMode, int nStat) ;
bool ExportSFR( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol,
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) ;
bool ExportObject( const IGdbIterator& iIter, Lib3MF::PComponentsObject pParent = nullptr, bool bSaveGrpAsComponent = false) ;
bool ExportGroup( const IGdbIterator& iIter, const std::string& sName, const STRVECTOR& vsInfo, Lib3MF::PComponentsObject pParent,
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) ;
Lib3MF_uint32 ColorHandler3MF( const Color& cCol) ;
private :
int m_nFilter ; // filtro su livello, modo e stato
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
Lib3MF::PWrapper m_wrapper ; // lib3mf wrapper
Lib3MF::PModel m_model ; // lib3mf model
} ;
-732
View File
@@ -1,732 +0,0 @@
//----------------------------------------------------------------------------
// EgalTech 2023
//----------------------------------------------------------------------------
// File : Export3dm.cpp Data : 21.09.23 Versione :
// Contenuto : Implementazione della classe per l'esportazione in formato 3dm.
//
//
//
// Modifiche : 21.09.23 DB Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "Export3dm.h"
#include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGkSurfBezier.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkCurveBezier.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkGeoObjType.h"
#include "/EgtDev/Include/EGkGeoPoint3d.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"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Extern/opennurbs/Include/opennurbs.h"
#include <fstream>
#include <map>
using namespace std ;
//N.B.:
// se si vuole richiamare qualche variabile di default definita in una classe come statica e a cui viene assegnato un valore
// nel file opennurbs_statics.cpp bisogna richiamarla in questo elenco per evitare problemi di compilazione ( errore di LINK)
//----------------------------------------------------------------------------
IExport3dm*
CreateExport3dm( void)
{
// verifico la chiave e le opzioni
if ( ! VerifyKey( KEYOPT_EEX_EXPBASE))
return nullptr ;
// creo l'oggetto
return static_cast<IExport3dm*> ( new( nothrow) Export3dm) ;
}
//----------------------------------------------------------------------------
bool
Export3dm::SetOptions( int nFilter)
{
m_nFilter = nFilter ;
CalcGroupFilter() ;
return true ;
}
//----------------------------------------------------------------------------
static void
Internal_SetExampleModelProperties( ONX_Model& model, const char* source_file_name)
{
const bool bHaveFileName = ( nullptr != source_file_name && 0 != source_file_name[0]) ;
if ( ! bHaveFileName)
source_file_name = "" ;
model.m_sStartSectionComments = "This file was created using openNURBS to convert an .nge into .3dm" ;
// set application information
const ON_wString wide_source_file_name( source_file_name) ;
model.m_properties.m_Application.m_application_URL = L"http://www.opennurbs.org" ;
// set revision history information
model.m_properties.m_RevisionHistory.NewRevision() ;
}
//----------------------------------------------------------------------------
bool
Export3dm::Export( IGeomDB* pGDB, int nId, const string& sFile)
{
Internal_SetExampleModelProperties( m_model, sFile.c_str()) ;
ON::Begin() ;
// verifico il DB geometrico
if ( pGDB == nullptr) {
LOG_ERROR( GetEExLogger(), "Export3dm : Error on GeomDB")
return false ;
}
// verifico l'Id dell'oggetto da esportare
if ( ! pGDB->ExistsObj( nId)) {
LOG_ERROR( GetEExLogger(), "Export3dm : Error on Id")
return false ;
}
//// file settings ( units, tolerances, views, ...)
//// OPTIONAL - change values from defaults
m_model.m_settings.m_ModelUnitsAndTolerances.m_unit_system = ON::LengthUnitSystem::Millimeters ;
m_model.m_settings.m_ModelUnitsAndTolerances.m_absolute_tolerance = 0.01 ;
m_model.m_settings.m_ModelUnitsAndTolerances.m_angle_tolerance = ON_PI/180.0 ;// radians
m_model.m_settings.m_ModelUnitsAndTolerances.m_relative_tolerance = 0.01 ;// 1%
m_model.m_settings.m_current_material_source = ON::object_material_source::material_from_object ;
m_model.m_settings.m_RenderSettings.m_bFlatShade = true ;
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( pGDB)) ;
if ( IsNull( pIter))
return false ;
pIter->GoTo( nId) ;
// esporto l'oggetto e i suoi eventuali figli
bool bOk = ExportObject( *pIter, 0) ;
// stampo il file
int version = 7 ;
// errors printed to stdout
ON_TextLog error_log ;
// writes model to archive
bOk = bOk && m_model.Write( ConvertString( sFile).c_str(), version, &error_log) ;
ON::End() ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
Export3dm::ExportObject( const IGdbIterator& iIter, const int& nLayer)
{
// recupero il livello dell'oggetto
int nLev = GDB_LV_USER ;
iIter.GetCalcLevel( nLev) ;
// recupero il modo dell'oggetto
int nMode = GDB_MD_STD ;
iIter.GetCalcMode( nMode) ;
// recupero lo stato dell'oggetto
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
int nType = iIter.GetGdbType() ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat, nType == GDB_TY_GROUP)) {
switch ( nType) {
case GDB_TY_GEO :
{
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
//recupero il colore dell'oggetto
Color cCol ;
iIter.GetCalcMaterial( cCol) ;
// recupero eventuale nome
string sName ;
if ( ! iIter.GetName( sName))
sName = ToString( iIter.GetId()) ;
// emetto l'oggetto
switch ( iIter.GetGeoType()) {
case GEO_PNT3D: {
if ( ! ExportPnt( sName, iIter, frFrame, cCol, nLayer))
return false ;
break ;
}
case SRF_BEZIER: {
if ( ! ExportSrfBz( sName, iIter, frFrame, cCol, nLayer))
return false ;
break ;
}
case SRF_FLATRGN :
case SRF_TRIMESH :
if ( ! ExportSTM( sName, iIter, frFrame, cCol, nLayer))
return false ;
break ;
case CRV_ARC : {
if ( ! ExportCrvArc( sName, iIter, frFrame, cCol, nLayer))
return false ;
break ;
}
case CRV_BEZIER : {
if ( ! ExportCrvBezier( sName, iIter, frFrame, cCol, nLayer))
return false ;
break ;
}
case CRV_COMPO : {
if ( ! ExportCrvCompo( sName, iIter, frFrame, cCol, nLayer))
return false ;
break ;
}
case CRV_LINE : {
if ( ! ExportCrvLine( sName, iIter, frFrame, cCol, nLayer))
return false ;
break ;
}
default :
break ;
}
}
return true ;
case GDB_TY_GROUP: {
int nLayer = iIter.GetId() ;
if ( nLayer == 0) {
m_model.RemoveModelComponent( ON_ModelComponent::Type::Layer, m_model.LayerFromIndex( 0).ModelComponentId()) ;
return ScanGroup( iIter, nLayer) ;
}
// creo il layer e setto le proprietà
ON_Layer* layer = new ON_Layer() ;
std::string sLayName ;
iIter.GetName( sLayName) ;
if ( sLayName == "" ) {
sLayName = "Layer " + ToString( nLayer) ;
}
layer->SetName( ConvertString( sLayName).c_str()) ;
layer->SetIndex( nLayer) ;
ON_Color onCol( 0, 0, 0) ; // black
layer->SetColor( onCol) ;
layer->SetVisible( true) ;
layer->SetLocked( false) ;
int nParent = iIter.GetParentId() ;
if ( nParent != 0) {
// setto il parent
const ON_Layer* onParLay = ON_Layer::Cast( m_model.LayerFromIndex( m_mLayer[nParent]).ModelComponent()) ;
layer->SetParentLayerId( onParLay->Id()) ;
}
// copio le info
STRVECTOR vStrInfo, vStrInfo_split ;
iIter.GetAllInfo( vStrInfo) ;
for ( string sInfo : vStrInfo) {
Tokenize( sInfo, "=", vStrInfo_split) ;
layer->SetUserString( ConvertString( vStrInfo_split[0]).c_str(), ConvertString( vStrInfo_split[1]).c_str()) ;
}
// aggiungo il layer
ON_ModelComponentReference mcr = m_model.AddManagedModelComponent( layer) ;
int nIndex = mcr.ModelComponentIndex() ;
m_mLayer.insert( pair< int, int>( nLayer, nIndex)) ;
// esploro il gruppo
return ScanGroup( iIter, nIndex) ;
}
default :
return false ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
Export3dm::AddObjectToModel( const IGdbIterator& iIter, ON_Object* onObject, const int& nLayer, const std::string& sName, const Color& cCol,
ON_3dmObjectAttributes* pOnAttr)
{
if ( pOnAttr == nullptr)
pOnAttr = new ON_3dmObjectAttributes() ;
pOnAttr->m_layer_index = nLayer ;
pOnAttr->m_name = ConvertString( sName).c_str() ;
pOnAttr->SetColorSource( ON::color_from_object) ;
//N.B. RHINO ha i valori di Alpha invertiti rispetto ai nostri, oltre che su una scala diversa! per loro 0 = opaco e 255 = trasparente
// per noi invece 0 = trasparente, 100 = opaco
ON_Color onCol( cCol.GetIntRed(), cCol.GetIntGreen(), cCol.GetIntBlue(), abs( int( cCol.GetIntAlpha() * 2.55) - 255)) ;
pOnAttr->m_color = onCol ;
// se è una mesh aggiungo il materiale
if ( const ON_Mesh* onMesh = ON_Mesh::Cast( onObject)) {
// aggiungo il materiale al modello se necessario
std::string sCol = ToString(cCol.GetIntRed()) + "," + ToString( cCol.GetIntGreen()) + "," + ToString( cCol.GetIntBlue()) ;
if ( m_mMaterial.find( sCol) == m_mMaterial.end()) {
ON_Material* onMat = new ON_Material ;
ON_Color onCAmb( 126, 126, 126) ; // gray126
onMat->m_reflection_glossiness = 0.0 ;
onMat->SetEmission( onCol) ;
onMat->SetDiffuse( onCol) ;
onMat->SetAmbient( onCAmb) ;
onMat->SetReflectivity( 0) ;
ON_ModelComponentReference mcr = m_model.AddManagedModelComponent( onMat) ;
int nIndex = mcr.ModelComponentIndex() ;
m_mMaterial.insert( pair< std::string, int>( sCol, nIndex)) ;
pOnAttr->SetMaterialSource( ON::object_material_source::material_from_object) ;
pOnAttr->m_material_index = nIndex ;
}
// sennò richiamo un materiale già definito
else {
pOnAttr->SetMaterialSource( ON::object_material_source::material_from_object) ;
pOnAttr->m_material_index = m_mMaterial[sCol] ;
}
}
// copio le info
STRVECTOR vStrInfo, vStrInfo_split ;
iIter.GetAllInfo(vStrInfo) ;
for ( string sInfo : vStrInfo) {
Tokenize( sInfo, "=", vStrInfo_split) ;
pOnAttr->SetUserString( ConvertString( vStrInfo_split[0]).c_str(), ConvertString( vStrInfo_split[1]).c_str()) ;
}
// aggiungo al modello
ON_ModelComponentReference mcr = m_model.AddManagedModelGeometryComponent( onObject, pOnAttr) ;
return ! mcr.IsEmpty() ;
}
//----------------------------------------------------------------------------
bool
Export3dm::AddInfoToObject( const IGdbIterator& iIter, ON_Object* onObject)
{
// copio le info
STRVECTOR vStrInfo, vStrInfo_split ;
iIter.GetAllInfo( vStrInfo) ;
for ( string sInfo : vStrInfo) {
Tokenize( sInfo, "=", vStrInfo_split) ;
onObject->SetUserString( ConvertString( vStrInfo_split[0]).c_str(), ConvertString( vStrInfo_split[1]).c_str()) ;
}
return true ;
}
//----------------------------------------------------------------------------
wstring
Export3dm::ConvertString( const std::string& sName)
{
wstring ws = wstring( sName.begin(), sName.end()) ;
return ws ;
}
//----------------------------------------------------------------------------
ON_3dPoint
Export3dm::ConvertPoint( const Point3d& pt)
{
ON_3dPoint onPt( pt.x, pt.y, pt.z) ;
return onPt ;
}
//----------------------------------------------------------------------------
ON_3dVector
Export3dm::ConvertVector( const Vector3d& vt)
{
ON_3dVector onVt( vt.x, vt.y, vt.z) ;
return onVt ;
}
//----------------------------------------------------------------------------
bool
Export3dm::TestFilter( int nLev, int nMode, int nStat, bool bGroup)
{
int nFilter = bGroup ? m_nGroupFilter : m_nFilter ;
if ( ( nLev == GDB_LV_USER && ( nFilter & EEXFLT_LEVUSER) == 0) ||
( nLev == GDB_LV_SYSTEM && ( nFilter & EEXFLT_LEVSYSTEM) == 0) ||
( nLev == GDB_LV_TEMP && ( nFilter & EEXFLT_LEVTEMP) == 0))
return false ;
if ( ( nMode == GDB_MD_STD && ( nFilter & EEXFLT_MODESTD) == 0) ||
( nMode == GDB_MD_LOCKED && ( nFilter & EEXFLT_MODELOCKED) == 0) ||
( nMode == GDB_MD_HIDDEN && ( nFilter & EEXFLT_MODEHIDDEN) == 0))
return false ;
if ( ( nStat == GDB_ST_OFF && ( nFilter & EEXFLT_STAOFF) == 0) ||
( nStat == GDB_ST_ON && ( nFilter & EEXFLT_STAON) == 0) ||
( nStat == GDB_ST_SEL && ( nFilter & EEXFLT_STASEL) == 0))
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
Export3dm::CalcGroupFilter( void)
{
m_nGroupFilter = 0 ;
// Status
if ( ( m_nFilter & EEXFLT_STASEL) != 0)
m_nGroupFilter += EEXFLT_STASEL + EEXFLT_STAOFF + EEXFLT_STAON ;
else if ( ( m_nFilter & EEXFLT_STAOFF) != 0)
m_nGroupFilter += EEXFLT_STAOFF + EEXFLT_STAON ;
else
m_nGroupFilter += EEXFLT_STAON ;
// Mode
if ( ( m_nFilter & EEXFLT_MODELOCKED) != 0)
m_nGroupFilter += EEXFLT_MODELOCKED + EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else if ( ( m_nFilter & EEXFLT_MODEHIDDEN) != 0)
m_nGroupFilter += EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else
m_nGroupFilter += EEXFLT_MODESTD ;
// Level
if ( ( m_nFilter & EEXFLT_LEVSYSTEM) != 0)
m_nGroupFilter += EEXFLT_LEVSYSTEM + EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else if ( ( m_nFilter & EEXFLT_LEVTEMP) != 0)
m_nGroupFilter += EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else
m_nGroupFilter += EEXFLT_LEVUSER ;
return true ;
}
//----------------------------------------------------------------------------
bool
Export3dm::ExportPnt(const string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer)
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return false ;
// verifico oggetto
PtrOwner<IGeoPoint3d> pGeoPnt( GetGeoPoint3d( pGeoObj->Clone())) ;
if ( IsNull( pGeoPnt))
return false ;
// lo porto nel riferimento globale
pGeoPnt->ToGlob( frFrame) ;
Point3d pt = pGeoPnt->GetPoint() ;
ON_Point* onPt = new ON_Point( ConvertPoint( pt)) ;
// aggiungo l'oggetto al modello
return AddObjectToModel( iIter, onPt, nLayer, sName, cCol) ; ;
}
//----------------------------------------------------------------------------
bool
Export3dm::ExportSrfBz( const string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer)
{
//MANCA DA IMPLEMENTARE IL TRIM DELLE SUPERFICI!!/////////////////////////////////////////////////////////////////////////////////////////////////////
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return false ;
// verifico oggetto
PtrOwner<ISurfBezier> pSrfBz( GetSurfBezier( pGeoObj->Clone())) ;
if ( IsNull( pSrfBz))
return false ;
// lo porto nel riferimento globale
pSrfBz->ToGlob( frFrame) ;
bool bOk = true ;
int nDegU, nDegV, nSpanU, nSpanV ;
bool bRat = false ;
bool bTrimmed = false ;
pSrfBz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bRat, bTrimmed) ;
int nCPU = nDegU * nSpanU + 1 ;
int nCPV = nDegV * nSpanV + 1 ;
ON_NurbsSurface* onNurbsSurf = new ON_NurbsSurface( 3, bRat, nDegU + 1, nDegV + 1, nCPU, nCPV) ;
for ( int u = 0 ; u < nCPU ; ++u) {
for ( int v = 0 ; v < nCPV ; ++v) {
Point3d ptCV = pSrfBz->GetControlPoint( u, v, &bOk) ;
if ( ! bRat) {
onNurbsSurf->SetCV( u, v, ConvertPoint( ptCV)) ;
}
else {
double dW = pSrfBz->GetControlWeight( u, v, &bOk) ;
onNurbsSurf->SetCV( u, v, ConvertPoint( ptCV * dW)) ;
onNurbsSurf->SetWeight( u, v, dW) ;
}
}
}
// imposto il vettore dei nodi in U
int nKnotCountU = nDegU + nCPU - 1 ;
double dKnot = 0 ;
// per costruzione nKnotCount é un multiplo di nDegU
for ( int u = 0 ; u < int ( nKnotCountU / nDegU) ; ++u) {
for ( int p = 0 ; p < nDegU ; ++p)
onNurbsSurf->SetKnot( 0, u * nDegU + p, dKnot) ;
++dKnot ;
}
// imposto il vettore dei nodi in V
int nKnotCountV = nDegV + nCPV - 1 ;
dKnot = 0 ;
// per costruzione nKnotCount é un multiplo di nDegU
for ( int v = 0 ; v < int ( nKnotCountV / nDegV) ; ++v) {
for ( int p = 0 ; p < nDegV ; ++p)
onNurbsSurf->SetKnot( 0, v * nDegV + p, dKnot) ;
++dKnot ;
}
// aggiungo l'oggetto al modello
return AddObjectToModel( iIter, onNurbsSurf, nLayer, sName, cCol) ;
}
//----------------------------------------------------------------------------
bool
Export3dm::ExportSTM( const string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer)
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return false ;
// verifico oggetto
PtrOwner<ISurfTriMesh> pSrfTm ;
if ( pGeoObj->GetType() == SRF_TRIMESH)
pSrfTm.Set( GetSurfTriMesh( pGeoObj->Clone())) ;
else {
const ISurfFlatRegion* pSrfFr = GetSurfFlatRegion( pGeoObj) ;
const ISurfTriMesh* pSrfTm_ = pSrfFr->GetAuxSurf() ;
if ( pSrfTm_ == nullptr){
return false ;
}
pSrfTm.Set( pSrfTm_->Clone()) ;
}
if ( IsNull( pSrfTm))
return false ;
// lo porto nel frame globale
pSrfTm->ToGlob( frFrame) ;
int nVertices = pSrfTm->GetVertexCount() ;
int nTriangles = pSrfTm->GetTriangleCount() ;
ON_Mesh* onMesh = new ON_Mesh ;
for ( int v = 0 ; v < nVertices ; ++v) {
Point3d pt ; pSrfTm->GetVertex( v, pt) ;
onMesh->SetVertex( v, ConvertPoint( pt)) ;
}
for ( int t = 0 ; t < nTriangles ; ++t) {
int nIdVert[3] ; pSrfTm->GetTriangle( t, nIdVert) ;
onMesh->SetTriangle( t, nIdVert[0], nIdVert[1], nIdVert[2]) ;
}
// aggiungo l'oggetto al modello
return AddObjectToModel( iIter, onMesh, nLayer, sName, cCol) ;
}
//----------------------------------------------------------------------------
ON_ArcCurve*
Export3dm::ConvertCrvArc( const ICurveArc* pCrvArc)
{
double dRad = pCrvArc->GetRadius() ;
Point3d ptCen ;
pCrvArc->GetCenterPoint( ptCen) ;
PtrOwner<ON_ArcCurve> onArcCrv( new ON_ArcCurve()) ;
if ( ! pCrvArc->IsACircle()) {
Vector3d vtZ = pCrvArc->GetNormVersor() ;
Vector3d vtX, vtY ;
vtX = pCrvArc->GetStartVersor() ;
vtY = vtZ ^ vtX ;
double dAngDeg = pCrvArc->GetAngCenter() ;
ON_Plane onPlane( ConvertPoint( ptCen), ConvertVector( vtX), ConvertVector( vtY)) ;
onArcCrv.Set( new ON_ArcCurve( ON_Arc( onPlane, dRad, dAngDeg * DEGTORAD))) ;
}
else
onArcCrv.Set( new ON_ArcCurve ( ON_Circle( ConvertPoint( ptCen), dRad))) ;
return Release( onArcCrv) ;
}
//----------------------------------------------------------------------------
bool
Export3dm::ExportCrvArc( const string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer)
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return false ;
// verifico oggetto
PtrOwner<ICurveArc> pCrvArc( GetCurveArc( pGeoObj->Clone())) ;
if ( IsNull( pCrvArc))
return false ;
// lo porto nel fram globale
pCrvArc->ToGlob( frFrame) ;
ON_ArcCurve* onArcCrv = ConvertCrvArc( pCrvArc) ;
if ( onArcCrv == nullptr)
return false ;
// aggiungo l'oggetto al modello
return AddObjectToModel( iIter, onArcCrv, nLayer, sName, cCol) ;
}
//----------------------------------------------------------------------------
ON_NurbsCurve*
Export3dm::ConvertCrvBezier( const ICurveBezier* pCrvBz)
{
// creo l'oggetto da esportare
int nDeg = pCrvBz->GetDegree() ;
int nCV = nDeg + 1 ;
PtrOwner<ON_NurbsCurve> onNurbsCrv( new ON_NurbsCurve( 3, // dim
pCrvBz->IsRational(), // bRat
nDeg + 1, // order = deg + 1
nCV)) ; // numero di CP
// imposto i punti di controllo con gli eventuali pesi
if ( ! pCrvBz->IsRational()) {
bool bOk = true ;
for ( int i = 0 ; i < nCV ; ++i) {
ON_3dPoint onPt = ConvertPoint( pCrvBz->GetControlPoint( i, &bOk)) ;
onNurbsCrv->SetCV( i, onPt) ;
}
}
else {
bool bOk = true ;
for ( int i = 0 ; i < nCV ; ++i) {
ON_3dPoint onPt = ConvertPoint( pCrvBz->GetControlPoint( i, &bOk)) ;
double dWeight = pCrvBz->GetControlWeight( i, &bOk) ;
onNurbsCrv->SetCV( i, onPt * dWeight) ;
onNurbsCrv->SetWeight( i, dWeight) ;
}
}
// imposto il vettore dei nodi
int nKnotCount = nDeg + nCV - 1 ;
double dKnot = 0 ;
for ( int u = 0 ; u < int ( nKnotCount / nDeg) ; ++u) {
for ( int p = 0 ; p < nDeg ; ++p)
onNurbsCrv->SetKnot( u * nDeg + p, dKnot) ;
++dKnot ;
}
return Release( onNurbsCrv) ;
}
//----------------------------------------------------------------------------
bool
Export3dm::ExportCrvBezier( const string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer)
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return false ;
// verifico oggetto
PtrOwner<ICurveBezier> pCrvBz( GetCurveBezier( pGeoObj->Clone())) ;
if ( IsNull( pCrvBz))
return false ;
// lo porto nel riferimento globale
pCrvBz->ToGlob( frFrame) ;
ON_NurbsCurve* onNurbsCrv = ConvertCrvBezier( pCrvBz) ;
if ( onNurbsCrv == nullptr)
return false ;
// aggiungo l'oggetto al modello
return AddObjectToModel( iIter, onNurbsCrv, nLayer, sName, cCol) ;
}
//----------------------------------------------------------------------------
bool
Export3dm::ExportCrvCompo( const string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer)
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return false ;
// verifico oggetto
PtrOwner<ICurveComposite> pCrvCompo( GetCurveComposite( pGeoObj->Clone())) ;
if ( IsNull( pCrvCompo))
return false ;
// lo porto nel riferimento globale
pCrvCompo->ToGlob( frFrame) ;
ON_PolyCurve* onPolyCrv = new ON_PolyCurve ;
for ( const ICurve* pCrv = pCrvCompo->GetFirstCurve() ; pCrv != nullptr ; pCrv = pCrvCompo->GetNextCurve()) {
GeoObjType type = pCrv->GetType() ;
switch ( type) {
case CRV_LINE : {
PtrOwner<ICurveLine> pCrvL( GetCurveLine( pCrv->Clone())) ;
if ( IsNull( pCrvL)) {
delete onPolyCrv ;
return false ;
}
ON_LineCurve* onLine = ConvertCrvLine( pCrvL) ;
if ( onLine == nullptr) {
delete onPolyCrv ;
return false ;
}
onPolyCrv->Append( onLine) ;
break ;
}
case CRV_ARC : {
PtrOwner<ICurveArc> pCrvArc( GetCurveArc( pCrv->Clone())) ;
if ( IsNull( pCrvArc)) {
delete onPolyCrv ;
return false ;
}
ON_ArcCurve* onArcCrv = ConvertCrvArc( pCrvArc) ;
if ( onArcCrv == nullptr) {
delete onPolyCrv ;
return false ;
}
onPolyCrv->Append( onArcCrv) ;
break ;
}
case CRV_BEZIER : {
PtrOwner<ICurveBezier> pCrvBz( GetCurveBezier( pCrv->Clone())) ;
if ( IsNull( pCrvBz)) {
delete onPolyCrv ;
return false ;
}
ON_NurbsCurve* onNurbsCrv = ConvertCrvBezier( pCrvBz) ;
if ( onNurbsCrv == nullptr) {
delete onPolyCrv ;
return false ;
}
onPolyCrv->Append( onNurbsCrv) ;
break ;
}
default : break ;
}
}
// aggiungo l'oggetto al modello
return AddObjectToModel( iIter, onPolyCrv, nLayer, sName, cCol) ;
}
//----------------------------------------------------------------------------
ON_LineCurve*
Export3dm::ConvertCrvLine( const ICurveLine* pCrvL)
{
Point3d ptStart, ptEnd ;
pCrvL->GetStartPoint( ptStart) ;
pCrvL->GetEndPoint( ptEnd) ;
PtrOwner<ON_LineCurve> onCrvLine( new ON_LineCurve( ON_Line( ConvertPoint( ptStart), ConvertPoint( ptEnd)))) ;
return Release( onCrvLine) ;
}
//----------------------------------------------------------------------------
bool
Export3dm::ExportCrvLine( const string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer)
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return false ;
// verifico oggetto
PtrOwner<ICurveLine> pCrvL( GetCurveLine( pGeoObj->Clone())) ;
if ( IsNull( pCrvL))
return false ;
// lo porto nel frame globale
pCrvL->ToGlob( frFrame) ;
ON_LineCurve* onCrvLine = ConvertCrvLine( pCrvL) ;
// aggiungo l'oggetto al modello
return AddObjectToModel( iIter, onCrvLine, nLayer, sName, cCol) ;
}
//----------------------------------------------------------------------------
bool
Export3dm::ScanGroup( const IGdbIterator& iIter, const int& nLayer)
{
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( iIter.GetGDB())) ;
if ( IsNull( pIter))
return false ;
// scandisco il gruppo
bool bOk = true ;
for ( bool bNext = pIter->GoToFirstInGroup( iIter) ;
bNext ;
bNext = pIter->GoToNext()) {
if ( ! ExportObject( *pIter, nLayer))
bOk = false ;
}
return bOk ;
}
-79
View File
@@ -1,79 +0,0 @@
//----------------------------------------------------------------------------
// EgalTech 2023
//----------------------------------------------------------------------------
// File : Export3dm.cpp Data : 21.09.23 Versione :
// Contenuto : Dichiarazione della classe ExportStl.
//
//
//
// Modifiche : 21.09.23 DB Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#define NOMINMAX
#include "/EgtDev/Include/EExExport3dm.h"
#include "/EgtDev/Include/EGnWriter.h"
#include "/EgtDev/Extern/opennurbs/Include/opennurbs.h"
#include <map>
class IGdbIterator ;
class IGeoObj ;
class Frame3d ;
class Point3d ;
class ICurveBezier ;
class ICurveArc ;
class ICurveLine ;
class ISurfFlatRegion ;
class ON_3dPoint ;
class ON_3dVector ;
class ON_Object ;
class ON_NurbsCurve ;
class ON_ArcCurve ;
class ON_LineCurve ;
//----------------------------------------------------------------------------
class Export3dm : public IExport3dm
{
public :
virtual bool SetOptions( int nFilter) ;
virtual bool Export( IGeomDB* pGDB, int nId, const std::string& sFile) ;
public :
Export3dm(void) : m_nFilter(EEXFLT_DEFAULT) {
CalcGroupFilter() ;
}
private :
bool ExportObject( const IGdbIterator& iIter, const int& nLayer) ;
bool AddObjectToModel( const IGdbIterator& iIter, ON_Object* onObject, const int& nLayer, const std::string& sName, const Color& cCol,
ON_3dmObjectAttributes* pOnAttr = nullptr) ;
bool AddInfoToObject( const IGdbIterator& iIter, ON_Object* onObject) ;
bool ScanGroup( const IGdbIterator& iIter, const int& nLayer) ;
bool TestFilter( int nLev, int nMode, int nStat, bool bGroup = false) ;
std::wstring ConvertString( const std::string& sName) ;
ON_3dPoint ConvertPoint( const Point3d& pt) ;
ON_3dVector ConvertVector( const Vector3d& vt) ;
ON_NurbsCurve* ConvertCrvBezier( const ICurveBezier* pCrvBz) ;
ON_ArcCurve* ConvertCrvArc( const ICurveArc* pCrvArc) ;
ON_LineCurve* ConvertCrvLine( const ICurveLine* pCrvL) ;
bool ExportPnt( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
bool ExportSrfBz( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
bool ExportSTM( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
bool ExportCrvArc( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
bool ExportCrvBezier( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
bool ExportCrvCompo( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
bool ExportCrvLine( const std::string& sName, const IGdbIterator& iIter, const Frame3d& frFrame, const Color& cCol, const int& nLayer) ;
bool CalcGroupFilter( void) ;
private :
int m_nFilter ; // filtro su livello, modo e stato, se l'oggeto da valutare è un oggetto geometrico
int m_nGroupFilter ; // filtro su livello, modo e stato, se l'oggetto da valutare è un gruppo
Writer m_Writer ; // scrittore di file di testo
ONX_Model m_model ; // modello opennurbs
std::map<int,int> m_mLayer ; // mappa dei layer <indice layer nge, indice del componente layer nel modello 3dm>
std::map<std::string,int> m_mMaterial ; // mappa dei materiali <stringa del colore ( R,G,B), indice del componente material nel modello 3dm>
} ;
+111 -79
View File
@@ -33,8 +33,6 @@
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtStringDecoder.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -57,6 +55,7 @@ bool
ExportDxf::SetOptions( int nFilter, int nFlag)
{
m_nFilter = nFilter ;
CalcGroupFilter() ;
m_bCompoundLayer = (( nFlag & EEXFLAG_COMP_LAYER) != 0) ;
m_bColorByLayer = (( nFlag & EEXFLAG_COL_BY_LAYER) != 0) ;
m_bAdvancedNames = (( nFlag & EEXFLAG_ADV_NAMES) != 0) ;
@@ -100,7 +99,7 @@ ExportDxf::Export( IGeomDB* pGDB, int nId, const string& sFile)
if ( ! ExportBlocks( pGDB, nId))
bOk = false ;
// scrivo la sezione entità
// scrivo la sezione entit
if ( ! ExportEntities( pGDB, nId))
bOk = false ;
@@ -602,7 +601,7 @@ ExportDxf::WriteLayersTable( IGeomDB* pGDB, int nId)
bool
ExportDxf::FindLayers( const IGdbIterator& iIter, const string& sLay, LAYDATVECTOR& vLayDat)
{
// se non è un gruppo, esco subito
// se non un gruppo, esco subito
if ( iIter.GetGdbType() != GDB_TY_GROUP)
return true ;
@@ -616,7 +615,7 @@ ExportDxf::FindLayers( const IGdbIterator& iIter, const string& sLay, LAYDATVECT
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
// se il filtro non lo abilita, esco subito
if ( ! TestFilter( nLev, nMode, nStat))
if ( ! TestFilter( nLev, nMode, nStat, true))
return true ;
// aggiorno nome layer
@@ -634,7 +633,7 @@ ExportDxf::FindLayers( const IGdbIterator& iIter, const string& sLay, LAYDATVECT
string s2 = sNewLay ;
if ( ToUpper( s1) == ToUpper( s2)) {
bFound = true ;
// se è il nome esatto, aggiorno il colore
// se il nome esatto, aggiorno il colore
if ( bExactLay)
vLayDat[i].second = nCol ;
}
@@ -720,9 +719,9 @@ ExportDxf::WriteStylesTable( IGeomDB* pGDB, int nId)
bool
ExportDxf::FindTextStyles( const IGdbIterator& iIter, STRVECTOR& vFontName)
{
// se è una entità geometrica
// se una entit geometrica
if ( iIter.GetGdbType() == GDB_TY_GEO) {
// se è un testo
// se un testo
if ( const IExtText* pTXT = GetExtText( iIter.GetGeoObj())) {
// se font non presente, lo aggiungo al vettore dei font
bool bFound = false ;
@@ -918,7 +917,7 @@ ExportDxf::ExportBlocks( IGeomDB* pGDB, int nId)
bool
ExportDxf::ExportEntities( IGeomDB* pGDB, int nId)
{
// intestazione sezione entità
// intestazione sezione entit
if ( ! WriteItem( 0, "SECTION") ||
! WriteItem( 2, "ENTITIES"))
return false ;
@@ -932,7 +931,7 @@ ExportDxf::ExportEntities( IGeomDB* pGDB, int nId)
if ( ! ExportGdbObject( *pIter, LAY_DEFAULT))
return false ;
// terminazione sezione entità
// terminazione sezione entit
if ( ! WriteItem( 0, "ENDSEC"))
return false ;
@@ -943,35 +942,36 @@ ExportDxf::ExportEntities( IGeomDB* pGDB, int nId)
bool
ExportDxf::ExportGdbObject( const IGdbIterator& iIter, const string& sLay)
{
// recupero il livello dell'oggetto
int nLev = GDB_LV_USER ;
iIter.GetCalcLevel( nLev) ;
// recupero il modo dell'oggetto
int nMode = GDB_MD_STD ;
iIter.GetCalcMode( nMode) ;
// recupero lo stato dell'oggetto
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
// recupero il tipo dell'oggetto
int nGdbType = iIter.GetGdbType() ;
// se gruppo di oggetti
if ( nGdbType == GDB_TY_GROUP) {
// esporto il gruppo
return ExportGdbGroup( iIter, sLay) ;
}
// se oggetto geometrico
else if ( nGdbType == GDB_TY_GEO) {
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return true ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
// recupero il livello dell'oggetto
int nLev = GDB_LV_USER ;
iIter.GetCalcLevel( nLev) ;
// recupero il modo dell'oggetto
int nMode = GDB_MD_STD ;
iIter.GetCalcMode( nMode) ;
// recupero lo stato dell'oggetto
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat)) {
// recupero colore (trasformato in formato ACI)
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat, nGdbType == GDB_TY_GROUP)) {
// se gruppo di oggetti
if ( nGdbType == GDB_TY_GROUP) {
// esporto il gruppo
return ExportGdbGroup( iIter, sLay) ;
}
// se oggetto geometrico
else if ( nGdbType == GDB_TY_GEO) {
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return true ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
// recupero colore (trasformato in formato ACI)
int nCol = COL_DEFAULT ;
Color cCol ;
if ( ( m_bColorByLayer && iIter.GetMaterial( cCol)) ||
@@ -1016,11 +1016,12 @@ ExportDxf::ExportGdbObject( const IGdbIterator& iIter, const string& sLay)
return false ;
break ;
}
}
return true ;
}
else
return false ;
return true ;
}
else
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
@@ -1077,7 +1078,7 @@ ExportDxf::ExportLine( const string& sLay, int nCol, const IGeoObj* pGeoObj, con
const ICurveLine* pLine = GetCurveLine( pGeoObj) ;
if ( pLine == nullptr)
return false ;
// scrivo l'entità
// scrivo l'entit
return WriteLine( sLay, nCol, pLine, frFrame) ;
}
@@ -1089,7 +1090,7 @@ ExportDxf::ExportArc( const string& sLay, int nCol, const IGeoObj* pGeoObj, cons
const ICurveArc* pArc = GetCurveArc( pGeoObj) ;
if ( pArc == nullptr)
return false ;
// se è un'elica o con estrusione non parallela a N
// se un'elica o con estrusione non parallela a N
if ( ! pArc->IsPlane()) {
// esporto come polilinea 3d
return WriteCurve3d( sLay, nCol, pArc, frFrame) ;
@@ -1162,9 +1163,9 @@ ExportDxf::ExportSTM( const string& sLay, int nCol, const IGeoObj* pGeoObj, cons
const ISurfTriMesh* pSTM = GetSurfTriMesh( pGeoObj) ;
if ( pSTM == nullptr)
return false ;
// posso esportare come unica polymesh solo se il numero dei vertici e dei triangoli è inferiore a 32767
// posso esportare come unica polymesh solo se il numero dei vertici e dei triangoli inferiore a 32767
if ( pSTM->GetVertexCount() < SHRT_MAX && pSTM->GetTriangleCount() < SHRT_MAX) {
// identificativo entità
// identificativo entit
if ( ! WriteItem( 0, "POLYLINE"))
return false ;
// layer
@@ -1173,7 +1174,7 @@ ExportDxf::ExportSTM( const string& sLay, int nCol, const IGeoObj* pGeoObj, cons
// colore
if ( ! WriteItem( 62, nCol))
return false ;
// flag segnalazione entità successive dipendenti (vertex)
// flag segnalazione entit successive dipendenti (vertex)
if ( ! WriteItem( 66, 1))
return false ;
// punto inutile ma obbligatorio
@@ -1196,7 +1197,7 @@ ExportDxf::ExportSTM( const string& sLay, int nCol, const IGeoObj* pGeoObj, cons
nId != SVT_NULL ;
nId = pSTM->GetNextVertex( nId, ptP)) {
ptP.ToGlob( frFrame) ;
// entità vertice
// entit vertice
if ( ! WriteItem( 0, "VERTEX"))
return false ;
// layer
@@ -1216,7 +1217,7 @@ ExportDxf::ExportSTM( const string& sLay, int nCol, const IGeoObj* pGeoObj, cons
for ( int nId = pSTM->GetFirstTriangle( nIdVert) ;
nId != SVT_NULL ;
nId = pSTM->GetNextTriangle( nId, nIdVert)) {
// entità vertice
// entit vertice
if ( ! WriteItem( 0, "VERTEX"))
return false ;
// layer
@@ -1239,7 +1240,7 @@ ExportDxf::ExportSTM( const string& sLay, int nCol, const IGeoObj* pGeoObj, cons
! WriteItem( 73, nIdVert[2] + 1))
return false ;
}
// entità termine dei vertici
// entit termine dei vertici
if ( ! WriteItem( 0, "SEQEND"))
return false ;
// layer
@@ -1255,7 +1256,7 @@ ExportDxf::ExportSTM( const string& sLay, int nCol, const IGeoObj* pGeoObj, cons
nId != SVT_NULL ;
nId = pSTM->GetNextTriangle( nId, Tria)) {
Tria.ToGlob( frFrame) ;
// entità 3dface
// entit 3dface
if ( ! WriteItem( 0, "3DFACE"))
return false ;
// layer
@@ -1311,7 +1312,7 @@ ExportDxf::ExportText( const string& sLay, int nCol, const IGeoObj* pGeoObj, con
// ciclo sui diversi testi semplici
bool bOk = true ;
for ( int i = 0 ; i < int( vTxt.size()) ; ++ i) {
// identificativo entità
// identificativo entit
if ( ! WriteItem( 0, "TEXT"))
return false ;
// layer
@@ -1354,7 +1355,7 @@ ExportDxf::ExportText( const string& sLay, int nCol, const IGeoObj* pGeoObj, con
! WriteItem( 220, vtN.y) ||
! WriteItem( 230, vtN.z))
return false ;
// libero l'entità
// libero l'entit
delete vTxt[i] ;
}
return bOk ;
@@ -1396,7 +1397,7 @@ ExportDxf::AdjustText( string& sText)
bool
ExportDxf::WritePoint( const string& sLay, int nCol, const Point3d& ptP, const Vector3d& vtV, const Frame3d& frFrame)
{
// identificativo entità
// identificativo entit
if ( ! WriteItem( 0, "POINT"))
return false ;
// layer
@@ -1430,10 +1431,10 @@ ExportDxf::WritePoint( const string& sLay, int nCol, const Point3d& ptP, const V
bool
ExportDxf::WriteLine( const string& sLay, int nCol, const ICurveLine* pLine, const Frame3d& frFrame)
{
// verifico validità linea
// verifico validit linea
if ( pLine == nullptr)
return false ;
// identificativo entità
// identificativo entit
if ( ! WriteItem( 0, "LINE"))
return false ;
// layer
@@ -1481,7 +1482,7 @@ ExportDxf::WriteLine( const string& sLay, int nCol, const ICurveLine* pLine, con
bool
ExportDxf::WriteCircle( const string& sLay, int nCol, const ICurveArc* pArc, const Frame3d& frFrame)
{
// verifico validità arco
// verifico validit arco
if ( pArc == nullptr)
return false ;
// verifico verso eventuale estrusione
@@ -1493,7 +1494,7 @@ ExportDxf::WriteCircle( const string& sLay, int nCol, const ICurveArc* pArc, con
vtN.ToGlob( frFrame) ;
Frame3d frOCS ;
frOCS.Set( ORIG, vtN) ;
// identificativo entità
// identificativo entit
if ( ! WriteItem( 0, "CIRCLE"))
return false ;
// layer
@@ -1532,7 +1533,7 @@ ExportDxf::WriteCircle( const string& sLay, int nCol, const ICurveArc* pArc, con
bool
ExportDxf::WriteArc( const string& sLay, int nCol, const ICurveArc* pArc, const Frame3d& frFrame)
{
// verifico validità arco
// verifico validit arco
if ( pArc == nullptr)
return false ;
// verifico verso eventuale estrusione
@@ -1544,7 +1545,7 @@ ExportDxf::WriteArc( const string& sLay, int nCol, const ICurveArc* pArc, const
vtN.ToGlob( frFrame) ;
Frame3d frOCS ;
frOCS.Set( ORIG, vtN) ;
// identificativo entità
// identificativo entit
if ( ! WriteItem( 0, "ARC"))
return false ;
// layer
@@ -1596,7 +1597,7 @@ bool
ExportDxf::WriteCurve2d( const string& sLay, int nCol, const ICurve* pCrv,
const Frame3d& frPlane, const Frame3d& frFrame)
{
// verifico validità curva
// verifico validit curva
if ( pCrv == nullptr)
return false ;
// trasformo in poliarco
@@ -1637,7 +1638,7 @@ ExportDxf::WriteCurve2d( const string& sLay, int nCol, const ICurve* pCrv,
// colore
if ( ! WriteItem( 62, nCol))
return false ;
// flag segnalazione entità successive dipendenti (vertex)
// flag segnalazione entit successive dipendenti (vertex)
if ( ! WriteItem( 66, 1))
return false ;
// punto per sola elevazione : X,Y inutili Z elevazione
@@ -1669,7 +1670,7 @@ ExportDxf::WriteCurve2d( const string& sLay, int nCol, const ICurve* pCrv,
for ( bool bPnt = PA.GetFirstPoint( ptP, dBulge) ;
bPnt ;
bPnt = PA.GetNextPoint( ptP, dBulge, bClosed)) {
// entità vertice
// entit vertice
if ( ! WriteItem( 0, "VERTEX"))
return false ;
// layer
@@ -1688,7 +1689,7 @@ ExportDxf::WriteCurve2d( const string& sLay, int nCol, const ICurve* pCrv,
if ( ! WriteItem( 70, 0))
return false ;
}
// entità termine dei vertici
// entit termine dei vertici
if ( ! WriteItem( 0, "SEQEND"))
return false ;
// layer
@@ -1701,7 +1702,7 @@ ExportDxf::WriteCurve2d( const string& sLay, int nCol, const ICurve* pCrv,
bool
ExportDxf::WriteCurve3d( const string& sLay, int nCol, const ICurve* pCrv, const Frame3d& frFrame)
{
// verifico validità curva
// verifico validit curva
if ( pCrv == nullptr)
return false ;
// trasformo in polilinea
@@ -1726,7 +1727,7 @@ ExportDxf::WriteCurve3d( const string& sLay, int nCol, const ICurve* pCrv, const
// colore
if ( ! WriteItem( 62, nCol))
return false ;
// flag segnalazione entità successive dipendenti (vertex)
// flag segnalazione entit successive dipendenti (vertex)
if ( ! WriteItem( 66, 1))
return false ;
// punto inutile ma obbligatorio
@@ -1742,7 +1743,7 @@ ExportDxf::WriteCurve3d( const string& sLay, int nCol, const ICurve* pCrv, const
for ( bool bPnt = PL.GetFirstPoint( ptP) ;
bPnt ;
bPnt = PL.GetNextPoint( ptP)) {
// entità vertice
// entit vertice
if ( ! WriteItem( 0, "VERTEX"))
return false ;
// layer
@@ -1758,7 +1759,7 @@ ExportDxf::WriteCurve3d( const string& sLay, int nCol, const ICurve* pCrv, const
if ( ! WriteItem( 70, 32))
return false ;
}
// entità termine dei vertici
// entit termine dei vertici
if ( ! WriteItem( 0, "SEQEND"))
return false ;
// layer
@@ -1771,7 +1772,7 @@ ExportDxf::WriteCurve3d( const string& sLay, int nCol, const ICurve* pCrv, const
for ( bool bPnt = PL.GetFirstLine( ptStart, ptEnd) ;
bPnt ;
bPnt = PL.GetNextLine( ptStart, ptEnd)) {
// identificativo entità
// identificativo entit
if ( ! WriteItem( 0, "LINE"))
return false ;
// layer
@@ -1811,24 +1812,55 @@ ExportDxf::WriteCurve3d( const string& sLay, int nCol, const ICurve* pCrv, const
//----------------------------------------------------------------------------
bool
ExportDxf::TestFilter( int nLev, int nMode, int nStat)
ExportDxf::TestFilter( int nLev, int nMode, int nStat, bool bGroup)
{
if ( ( nLev == GDB_LV_USER && ( m_nFilter & EEXFLT_LEVUSER) == 0) ||
( nLev == GDB_LV_SYSTEM && ( m_nFilter & EEXFLT_LEVSYSTEM) == 0) ||
( nLev == GDB_LV_TEMP && ( m_nFilter & EEXFLT_LEVTEMP) == 0))
int nFilter = bGroup ? m_nGroupFilter : m_nFilter ;
if ( ( nLev == GDB_LV_USER && ( nFilter & EEXFLT_LEVUSER) == 0) ||
( nLev == GDB_LV_SYSTEM && ( nFilter & EEXFLT_LEVSYSTEM) == 0) ||
( nLev == GDB_LV_TEMP && ( nFilter & EEXFLT_LEVTEMP) == 0))
return false ;
if ( ( nMode == GDB_MD_STD && ( m_nFilter & EEXFLT_MODESTD) == 0) ||
( nMode == GDB_MD_LOCKED && ( m_nFilter & EEXFLT_MODELOCKED) == 0) ||
( nMode == GDB_MD_HIDDEN && ( m_nFilter & EEXFLT_MODEHIDDEN) == 0))
if ( ( nMode == GDB_MD_STD && ( nFilter & EEXFLT_MODESTD) == 0) ||
( nMode == GDB_MD_LOCKED && ( nFilter & EEXFLT_MODELOCKED) == 0) ||
( nMode == GDB_MD_HIDDEN && ( nFilter & EEXFLT_MODEHIDDEN) == 0))
return false ;
if ( ( nStat == GDB_ST_OFF && ( m_nFilter & EEXFLT_STAOFF) == 0) ||
( nStat == GDB_ST_ON && ( m_nFilter & EEXFLT_STAON) == 0) ||
( nStat == GDB_ST_SEL && ( m_nFilter & EEXFLT_STASEL) == 0))
if ( ( nStat == GDB_ST_OFF && ( nFilter & EEXFLT_STAOFF) == 0) ||
( nStat == GDB_ST_ON && ( nFilter & EEXFLT_STAON) == 0) ||
( nStat == GDB_ST_SEL && ( nFilter & EEXFLT_STASEL) == 0))
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
ExportDxf::CalcGroupFilter( void)
{
m_nGroupFilter = 0 ;
// Status
if ( ( m_nFilter & EEXFLT_STASEL) != 0)
m_nGroupFilter += EEXFLT_STASEL + EEXFLT_STAOFF + EEXFLT_STAON ;
else if ( ( m_nFilter & EEXFLT_STAOFF) != 0)
m_nGroupFilter += EEXFLT_STAOFF + EEXFLT_STAON ;
else
m_nGroupFilter += EEXFLT_STAON ;
// Mode
if ( ( m_nFilter & EEXFLT_MODELOCKED) != 0)
m_nGroupFilter += EEXFLT_MODELOCKED + EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else if ( ( m_nFilter & EEXFLT_MODEHIDDEN) != 0)
m_nGroupFilter += EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else
m_nGroupFilter += EEXFLT_MODESTD ;
// Level
if ( ( m_nFilter & EEXFLT_LEVSYSTEM) != 0)
m_nGroupFilter += EEXFLT_LEVSYSTEM + EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else if ( ( m_nFilter & EEXFLT_LEVTEMP) != 0)
m_nGroupFilter += EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else
m_nGroupFilter += EEXFLT_LEVUSER ;
return true ;
}
//----------------------------------------------------------------------------
bool
ExportDxf::WriteItem( int nCode, int nVal)
+4 -2
View File
@@ -71,7 +71,8 @@ class ExportDxf : public IExportDxf
bool WriteCurve2d( const std::string& sLay, int nCol, const ICurve* pCrv,
const Frame3d& frPlane, const Frame3d& frFrame) ;
bool WriteCurve3d( const std::string& sLay, int nCol, const ICurve* pCrv, const Frame3d& frFrame) ;
bool TestFilter( int nLev, int nMode, int nStat) ;
bool TestFilter( int nLev, int nMode, int nStat, bool bGroup) ;
bool CalcGroupFilter( void) ;
bool WriteItem( int nCode, int nVal) ;
bool WriteItem( int nCode, double dVal, int nPrec = 6) ;
bool WriteItem( int nCode, const std::string& sVal) ;
@@ -81,7 +82,8 @@ class ExportDxf : public IExportDxf
std::string AdjustFontName( const std::string& sFontName) ;
private :
int m_nFilter ; // filtro su livello, modo e stato
int m_nFilter ; // filtro su livello, modo e stato, se l'oggeto da valutare è un oggetto geometrico
int m_nGroupFilter ; // filtro su livello, modo e stato, se l'oggetto da valutare è un gruppo
bool m_bCompoundLayer ;
bool m_bColorByLayer ;
bool m_bAdvancedNames ;
+76 -44
View File
@@ -21,8 +21,6 @@
#include "/EgtDev/Include/EGkSurfTriMesh.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"
#include <fstream>
@@ -45,6 +43,7 @@ bool
ExportStl::SetOptions( int nFilter)
{
m_nFilter = nFilter ;
CalcGroupFilter() ;
return true ;
}
@@ -89,34 +88,35 @@ ExportStl::Export( IGeomDB* pGDB, int nId, const string& sFile)
bool
ExportStl::ExportObject( const IGdbIterator& iIter)
{
switch ( iIter.GetGdbType()) {
case GDB_TY_GEO :
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return true ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
// recupero il livello dell'oggetto
int nLev = GDB_LV_USER ;
iIter.GetCalcLevel( nLev) ;
// recupero il modo dell'oggetto
int nMode = GDB_MD_STD ;
iIter.GetCalcMode( nMode) ;
// recupero lo stato dell'oggetto
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat)) {
// recupero eventuale nome
// recupero il livello dell'oggetto
int nLev = GDB_LV_USER ;
iIter.GetCalcLevel( nLev) ;
// recupero il modo dell'oggetto
int nMode = GDB_MD_STD ;
iIter.GetCalcMode( nMode) ;
// recupero lo stato dell'oggetto
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
int nType = iIter.GetGdbType() ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat, nType == GDB_TY_GROUP)) {
switch ( nType) {
case GDB_TY_GEO :
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return true ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
// recupero eventuale nome
string sName ;
if ( ! iIter.GetName( sName))
sName = ToString( iIter.GetId()) ;
// emetto l'oggetto
switch ( pGeoObj->GetType()) {
switch ( pGeoObj->GetType()) {
case SRF_TRIMESH :
if ( ! ExportSTM( sName, pGeoObj, frFrame))
return false ;
@@ -128,37 +128,69 @@ ExportStl::ExportObject( const IGdbIterator& iIter)
default :
break ;
}
}
}
return true ;
case GDB_TY_GROUP :
// esploro il gruppo
return ScanGroup( iIter) ;
default :
return false ;
}
return true ;
case GDB_TY_GROUP :
// esploro il gruppo
return ScanGroup( iIter) ;
default :
return false ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
ExportStl::TestFilter( int nLev, int nMode, int nStat)
ExportStl::TestFilter( int nLev, int nMode, int nStat, bool bGroup)
{
if ( ( nLev == GDB_LV_USER && ( m_nFilter & EEXFLT_LEVUSER) == 0) ||
( nLev == GDB_LV_SYSTEM && ( m_nFilter & EEXFLT_LEVSYSTEM) == 0) ||
( nLev == GDB_LV_TEMP && ( m_nFilter & EEXFLT_LEVTEMP) == 0))
int nFilter = bGroup ? m_nGroupFilter : m_nFilter ;
if ( ( nLev == GDB_LV_USER && ( nFilter & EEXFLT_LEVUSER) == 0) ||
( nLev == GDB_LV_SYSTEM && ( nFilter & EEXFLT_LEVSYSTEM) == 0) ||
( nLev == GDB_LV_TEMP && ( nFilter & EEXFLT_LEVTEMP) == 0))
return false ;
if ( ( nMode == GDB_MD_STD && ( m_nFilter & EEXFLT_MODESTD) == 0) ||
( nMode == GDB_MD_LOCKED && ( m_nFilter & EEXFLT_MODELOCKED) == 0) ||
( nMode == GDB_MD_HIDDEN && ( m_nFilter & EEXFLT_MODEHIDDEN) == 0))
if ( ( nMode == GDB_MD_STD && ( nFilter & EEXFLT_MODESTD) == 0) ||
( nMode == GDB_MD_LOCKED && ( nFilter & EEXFLT_MODELOCKED) == 0) ||
( nMode == GDB_MD_HIDDEN && ( nFilter & EEXFLT_MODEHIDDEN) == 0))
return false ;
if ( ( nStat == GDB_ST_OFF && ( m_nFilter & EEXFLT_STAOFF) == 0) ||
( nStat == GDB_ST_ON && ( m_nFilter & EEXFLT_STAON) == 0) ||
( nStat == GDB_ST_SEL && ( m_nFilter & EEXFLT_STASEL) == 0))
if ( ( nStat == GDB_ST_OFF && ( nFilter & EEXFLT_STAOFF) == 0) ||
( nStat == GDB_ST_ON && ( nFilter & EEXFLT_STAON) == 0) ||
( nStat == GDB_ST_SEL && ( nFilter & EEXFLT_STASEL) == 0))
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
ExportStl::CalcGroupFilter( void)
{
m_nGroupFilter = 0 ;
// Status
if ( ( m_nFilter & EEXFLT_STASEL) != 0)
m_nGroupFilter += EEXFLT_STASEL + EEXFLT_STAOFF + EEXFLT_STAON ;
else if ( ( m_nFilter & EEXFLT_STAOFF) != 0)
m_nGroupFilter += EEXFLT_STAOFF + EEXFLT_STAON ;
else
m_nGroupFilter += EEXFLT_STAON ;
// Mode
if ( ( m_nFilter & EEXFLT_MODELOCKED) != 0)
m_nGroupFilter += EEXFLT_MODELOCKED + EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else if ( ( m_nFilter & EEXFLT_MODEHIDDEN) != 0)
m_nGroupFilter += EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else
m_nGroupFilter += EEXFLT_MODESTD ;
// Level
if ( ( m_nFilter & EEXFLT_LEVSYSTEM) != 0)
m_nGroupFilter += EEXFLT_LEVSYSTEM + EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else if ( ( m_nFilter & EEXFLT_LEVTEMP) != 0)
m_nGroupFilter += EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else
m_nGroupFilter += EEXFLT_LEVUSER ;
return true ;
}
//----------------------------------------------------------------------------
bool
ExportStl::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame)
+7 -3
View File
@@ -28,16 +28,20 @@ class ExportStl : public IExportStl
virtual bool Export( IGeomDB* pGDB, int nId, const std::string& sFile) ;
public :
ExportStl( void) : m_nFilter( EEXFLT_DEFAULT) {}
ExportStl( void) : m_nFilter( EEXFLT_DEFAULT) {
CalcGroupFilter() ;
}
private :
bool ExportObject( const IGdbIterator& iIter) ;
bool ScanGroup( const IGdbIterator& iIter) ;
bool TestFilter( int nLev, int nMode, int nStat) ;
bool TestFilter( int nLev, int nMode, int nStat, bool bGroup) ;
bool CalcGroupFilter( void) ;
bool ExportSFR( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame) ;
bool ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame) ;
private :
int m_nFilter ; // filtro su livello, modo e stato
int m_nFilter ; // filtro su livello, modo e stato, se l'oggeto da valutare è un oggetto geometrico
int m_nGroupFilter ; // filtro su livello, modo e stato, se l'oggetto da valutare è un gruppo
Writer m_Writer ; // scrittore di file di testo
} ;
-2
View File
@@ -28,8 +28,6 @@
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkStringUtils3d.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"
#include <fstream>
+108 -90
View File
@@ -71,6 +71,7 @@ bool
ExportThreeJS::SetOptions( int nFilter)
{
m_nFilter = nFilter ;
CalcGroupFilter() ;
return true ;
}
@@ -2571,22 +2572,22 @@ ExportThreeJS::ExportObject( const IGdbIterator& iIter, IGeomDB* pGDB, const int
// recupero lo stato dell'oggetto
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
int nType = iIter.GetGdbType() ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat, nType == GDB_TY_GROUP)) {
switch ( nType) {
case GDB_TY_GEO :
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return true ;
switch ( iIter.GetGdbType()) {
case GDB_TY_GEO :
{
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = iIter.GetGeoObj() ;
if ( pGeoObj == nullptr)
return true ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat)) {
// recupero eventuale nome
string sName ;
if ( ! iIter.GetName( sName))
@@ -2666,14 +2667,14 @@ ExportThreeJS::ExportObject( const IGdbIterator& iIter, IGeomDB* pGDB, const int
default :
break ;
}
return true ;
}
return true ;
case GDB_TY_GROUP :
// esploro il gruppo
return ScanGroup( iIter, pGDB, nGroupCount) ;
default :
return false ;
}
case GDB_TY_GROUP :
// esploro il gruppo
return ScanGroup( iIter, pGDB, nGroupCount) ;
default :
return false ;
}
return true ;
@@ -3180,91 +3181,108 @@ ExportThreeJS::ScanGroup( const IGdbIterator& iIter, IGeomDB* pGDB, const int nG
pIter->GoTo( iIter.GetId()) ;
// recupero il livello dell'oggetto
int nLev = GDB_LV_USER ;
iIter.GetCalcLevel( nLev) ;
// recupero il modo dell'oggetto
int nMode = GDB_MD_STD;
iIter.GetCalcMode( nMode) ;
// recupero lo stato dell'oggetto
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
m_nGroupCount ++ ;
m_Writer.OutText( " const group" + ToString( m_nGroupCount) + " = new THREE.Group();") ;
if ( TestFilter( nLev, nMode, nStat)) {
m_nGroupCount ++ ;
m_Writer.OutText( " const group" + ToString( m_nGroupCount) + " = new THREE.Group();") ;
if ( nGroupCount != -1)
m_sCodMenu += "<ol class = 'list-group-item border-0 my-0 py-0 pe-0'>" ;
if ( nGroupCount != -1)
m_sCodMenu += "<ol class = 'list-group-item border-0 my-0 py-0 pe-0'>" ;
string sName ;
pIter->GetName( sName) ;
string sId = ToString( pIter->GetId()) ;
string sName ;
pIter->GetName( sName) ;
string sId = ToString( pIter->GetId()) ;
m_Writer.OutText( " group" + ToString( m_nGroupCount) + ".name = '" + sId + "'") ;
// aggiungo l'EventListner per il menu laterale sinistro
//m_Writer.OutText( " document.getElementById('p_id_" + sId + "').addEventListener('click', function(){ if(!booked) { findGroupByNameAndId(groupRoot, " + sId + ", 1); }});") ;
//m_Writer.OutText( " document.getElementById('lb_" + sId + "').addEventListener('click', function(){ lightbulb('lb_" + sId + "', 0)});") ;
m_Writer.OutText( " group" + ToString( m_nGroupCount) + ".name = '" + sId + "'") ;
// aggiungo l'EventListner per il menu laterale sinistro
//m_Writer.OutText( " document.getElementById('p_id_" + sId + "').addEventListener('click', function(){ if(!booked) { findGroupByNameAndId(groupRoot, " + sId + ", 1); }});") ;
//m_Writer.OutText( " document.getElementById('lb_" + sId + "').addEventListener('click', function(){ lightbulb('lb_" + sId + "', 0)});") ;
if ( ! sId.compare( "0")) {
if ( ! sId.compare( "0")) {
//m_sCodMenu += "<div class = 'd-flex flex-row bd-highlight'>" ;
//m_sCodMenu += "<i id = 'lb_0' name = 'lb_on' class = 'fa-solid fa-lightbulb m-0 py-1 visible' style = 'cursor: pointer; color: #f0ad4e'></i>" ;
//m_sCodMenu += "<button class = 'list-group-item list-group-item-action list-group-flush list-group-item-dark mb-0 border-0 ml-1 py-0 mx-1' name='btMenu' id = 'p_id_0'>" ;
//m_sCodMenu += "<span class = 'badge bg-dark float-end my-0' id = 's_id_0' name ='badgeMenu'></span>" ;
//m_sCodMenu += "<span class = 'border-0' name = 's_col_ora' id = 's_col_0'> <i>(0)</i></span>" ;
//m_sCodMenu += "<span id = 'ss_id_0' name = 's_nb'> BASIC MODEL</span>" ;
//m_sCodMenu += "</button>" ;
//m_sCodMenu += "</div>" ;
}
else {
m_Writer.OutText(" document.getElementById('p_id_" + sId + "').addEventListener('click', function(){ if(!booked) { findGroupByNameAndId(groupRoot, " + sId + ", 1); }});") ;
m_Writer.OutText(" document.getElementById('lb_" + sId + "').addEventListener('click', function(){ lightbulb('lb_" + sId + "', 0)});") ;
m_sCodMenu += "<div class = 'd-flex flex-row bd-highlight'>" ;
m_sCodMenu += "<i id = 'lb_" + sId + "' name = 'lb_on' class = 'fa-solid fa-lightbulb m-0 py-1 visible' style = 'cursor: pointer; color: #f0ad4e'></i>" ;
m_sCodMenu += "<button class = 'list-group-item list-group-item-action list-group-flush list-group-item-dark mb-0 border-0 ml-1 py-0 mx-1' name='btMenu' id = 'p_id_" + sId + "'>" ;
m_sCodMenu += "<span class='badge bg-dark float-end my-0' name ='badgeMenu' id = 's_id_" + sId + "'></span>" ;
m_sCodMenu += "<span name = 's_col_ora' id = 's_col_" + sId + "'><i>(" + sId + ")</i></span>" ;
m_sCodMenu += "<span id = 'ss_id_" + sId + "' name = 's_nb'> " + sName + "</span>" ; //Inserisco uno spazio !
m_sCodMenu += "</button>" ;
m_sCodMenu += "</div>" ;
}
int nCurrentGroup = m_nGroupCount ;
for ( bool bNext = pIter->GoToFirstInGroup(iIter) ; bNext ; bNext = pIter->GoToNext()) {
if ( ! ExportObject( *pIter, pGDB, nCurrentGroup))
bOk = false ;
}
if ( nGroupCount != -1) {
m_Writer.OutText(" group" + ToString( nGroupCount) + ".add(group" + ToString( nCurrentGroup) + ")") ;
}
m_sCodMenu += " </ol>" ;
//m_sCodMenu += "<div class = 'd-flex flex-row bd-highlight'>" ;
//m_sCodMenu += "<i id = 'lb_0' name = 'lb_on' class = 'fa-solid fa-lightbulb m-0 py-1 visible' style = 'cursor: pointer; color: #f0ad4e'></i>" ;
//m_sCodMenu += "<button class = 'list-group-item list-group-item-action list-group-flush list-group-item-dark mb-0 border-0 ml-1 py-0 mx-1' name='btMenu' id = 'p_id_0'>" ;
//m_sCodMenu += "<span class = 'badge bg-dark float-end my-0' id = 's_id_0' name ='badgeMenu'></span>" ;
//m_sCodMenu += "<span class = 'border-0' name = 's_col_ora' id = 's_col_0'> <i>(0)</i></span>" ;
//m_sCodMenu += "<span id = 'ss_id_0' name = 's_nb'> BASIC MODEL</span>" ;
//m_sCodMenu += "</button>" ;
//m_sCodMenu += "</div>" ;
}
else {
m_Writer.OutText(" document.getElementById('p_id_" + sId + "').addEventListener('click', function(){ if(!booked) { findGroupByNameAndId(groupRoot, " + sId + ", 1); }});") ;
m_Writer.OutText(" document.getElementById('lb_" + sId + "').addEventListener('click', function(){ lightbulb('lb_" + sId + "', 0)});") ;
m_sCodMenu += "<div class = 'd-flex flex-row bd-highlight'>" ;
m_sCodMenu += "<i id = 'lb_" + sId + "' name = 'lb_on' class = 'fa-solid fa-lightbulb m-0 py-1 visible' style = 'cursor: pointer; color: #f0ad4e'></i>" ;
m_sCodMenu += "<button class = 'list-group-item list-group-item-action list-group-flush list-group-item-dark mb-0 border-0 ml-1 py-0 mx-1' name='btMenu' id = 'p_id_" + sId + "'>" ;
m_sCodMenu += "<span class='badge bg-dark float-end my-0' name ='badgeMenu' id = 's_id_" + sId + "'></span>" ;
m_sCodMenu += "<span name = 's_col_ora' id = 's_col_" + sId + "'><i>(" + sId + ")</i></span>" ;
m_sCodMenu += "<span id = 'ss_id_" + sId + "' name = 's_nb'> " + sName + "</span>" ; //Inserisco uno spazio !
m_sCodMenu += "</button>" ;
m_sCodMenu += "</div>" ;
}
int nCurrentGroup = m_nGroupCount ;
for ( bool bNext = pIter->GoToFirstInGroup(iIter) ; bNext ; bNext = pIter->GoToNext()) {
if ( ! ExportObject( *pIter, pGDB, nCurrentGroup))
bOk = false ;
}
if ( nGroupCount != -1) {
m_Writer.OutText(" group" + ToString( nGroupCount) + ".add(group" + ToString( nCurrentGroup) + ")") ;
}
m_sCodMenu += " </ol>" ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
ExportThreeJS::TestFilter( int nLev, int nMode, int nStat)
ExportThreeJS::TestFilter( int nLev, int nMode, int nStat, bool bGroup)
{
// COMMENTO TEMPORANEO !
/*
if (( nLev == GDB_LV_USER && ( m_nFilter & EEXFLT_LEVUSER) == 0) ||
( nLev == GDB_LV_SYSTEM && ( m_nFilter & EEXFLT_LEVSYSTEM) == 0) ||
( nLev == GDB_LV_TEMP && ( m_nFilter & EEXFLT_LEVTEMP) == 0))
int nFilter = bGroup ? m_nGroupFilter : m_nFilter ;
if ( ( nLev == GDB_LV_USER && ( nFilter & EEXFLT_LEVUSER) == 0) ||
( nLev == GDB_LV_SYSTEM && ( nFilter & EEXFLT_LEVSYSTEM) == 0) ||
( nLev == GDB_LV_TEMP && ( nFilter & EEXFLT_LEVTEMP) == 0))
return false ;
*/
if (( nMode == GDB_MD_STD && ( m_nFilter & EEXFLT_MODESTD) == 0) ||
( nMode == GDB_MD_LOCKED && ( m_nFilter & EEXFLT_MODELOCKED) == 0) ||
( nMode == GDB_MD_HIDDEN && ( m_nFilter & EEXFLT_MODEHIDDEN) == 0))
if ( ( nMode == GDB_MD_STD && ( nFilter & EEXFLT_MODESTD) == 0) ||
( nMode == GDB_MD_LOCKED && ( nFilter & EEXFLT_MODELOCKED) == 0) ||
( nMode == GDB_MD_HIDDEN && ( nFilter & EEXFLT_MODEHIDDEN) == 0))
return false ;
if (( nStat == GDB_ST_OFF && ( m_nFilter & EEXFLT_STAOFF) == 0) ||
( nStat == GDB_ST_ON && ( m_nFilter & EEXFLT_STAON) == 0) ||
( nStat == GDB_ST_SEL && ( m_nFilter & EEXFLT_STASEL) == 0))
if ( ( nStat == GDB_ST_OFF && ( nFilter & EEXFLT_STAOFF) == 0) ||
( nStat == GDB_ST_ON && ( nFilter & EEXFLT_STAON) == 0) ||
( nStat == GDB_ST_SEL && ( nFilter & EEXFLT_STASEL) == 0))
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
ExportThreeJS::CalcGroupFilter( void)
{
m_nGroupFilter = 0 ;
// Status
if ( ( m_nFilter & EEXFLT_STASEL) != 0)
m_nGroupFilter += EEXFLT_STASEL + EEXFLT_STAOFF + EEXFLT_STAON ;
else if ( ( m_nFilter & EEXFLT_STAOFF) != 0)
m_nGroupFilter += EEXFLT_STAOFF + EEXFLT_STAON ;
else
m_nGroupFilter += EEXFLT_STAON ;
// Mode
if ( ( m_nFilter & EEXFLT_MODELOCKED) != 0)
m_nGroupFilter += EEXFLT_MODELOCKED + EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else if ( ( m_nFilter & EEXFLT_MODEHIDDEN) != 0)
m_nGroupFilter += EEXFLT_MODEHIDDEN + EEXFLT_MODESTD ;
else
m_nGroupFilter += EEXFLT_MODESTD ;
// Level
if ( ( m_nFilter & EEXFLT_LEVSYSTEM) != 0)
m_nGroupFilter += EEXFLT_LEVSYSTEM + EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else if ( ( m_nFilter & EEXFLT_LEVTEMP) != 0)
m_nGroupFilter += EEXFLT_LEVTEMP + EEXFLT_LEVUSER ;
else
m_nGroupFilter += EEXFLT_LEVUSER ;
return true ;
}
+7 -3
View File
@@ -38,7 +38,9 @@ class ExportThreeJS : public IExportThreeJS
virtual bool Export( IGeomDB* pGDB, int nId, IEGrScene* pScene, bool bUdm, const std::string& sFile) ;
public:
ExportThreeJS( void) : m_nFilter( EEXFLT_DEFAULT), m_bShowGrid( true), m_nGroupCount( -1), m_nCont( 0) {}
ExportThreeJS( void) : m_nFilter( EEXFLT_DEFAULT), m_bShowGrid( true), m_nGroupCount( -1), m_nCont( 0) {
CalcGroupFilter() ;
}
private:
bool HeadAmbient( IEGrScene* pScene, IGeomDB* pGDB, int nId) ;
@@ -56,10 +58,12 @@ class ExportThreeJS : public IExportThreeJS
bool ExportDimension( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ;
bool ScanGroup( const IGdbIterator& iIter, IGeomDB* pGDB, const int nIdGroup) ;
bool ExportObject( const IGdbIterator& iIter, IGeomDB* pGDB, const int nIdGroup) ;
bool TestFilter( int nLev, int nMode, int nStat) ;
bool TestFilter( int nLev, int nMode, int nStat, bool bGroup) ;
bool CalcGroupFilter( void) ;
private:
int m_nFilter ; // Filtro su livello, modo e stato
int m_nFilter ; // filtro su livello, modo e stato, se l'oggeto da valutare è un oggetto geometrico
int m_nGroupFilter ; // filtro su livello, modo e stato, se l'oggetto da valutare è un gruppo
Point3d m_ptMin ; // Punto minimo del box3d
double m_dimX ; // DimX Box3d Global
double m_dimY ; // DimY Box3d Global
+104 -212
View File
@@ -18,7 +18,7 @@
#include "Import3MF.h"
#include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h"
using namespace std ;
using namespace Lib3MF ;
@@ -27,16 +27,16 @@ using namespace Lib3MF ;
IImport3MF*
CreateImport3MF( void)
{
// verifico la chiave e le opzioni
// verifico la chiave e le opzioni
if ( ! VerifyKey( KEYOPT_EEX_INPBASE))
return nullptr ;
// creo l'oggetto
// creo l'oggetto
return static_cast<IImport3MF*> ( new( nothrow) Import3MF) ;
}
//----------------------------------------------------------------------------
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()) ;
@@ -53,7 +53,10 @@ Import3MF::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup)
return false ;
}
m_nIdGroup = nIdGroup ;
// imposto le opzioni di importazione
m_nFlag = nFlag ;
try {
if ( ! DoImport( sFile))
return false ;
@@ -71,15 +74,15 @@ bool
Import3MF::DoImport( const string& sFile)
{
// libreria 3MF
PWrapper m_wrapper = CWrapper::loadLibrary() ;
if ( ! m_wrapper) {
m_wrapper = CWrapper::loadLibrary() ;
if ( m_wrapper == nullptr) {
LOG_ERROR( GetEExLogger(), " Import3MF : Error on lib3mf Wrapper") ;
return false ;
}
// creazione del 3MF model
m_model = m_wrapper->CreateModel() ;
if ( ! m_model) {
if ( m_model == nullptr) {
LOG_ERROR( GetEExLogger(), " Import3MF : Error on lib3mf Model") ;
return false ;
}
@@ -87,33 +90,34 @@ Import3MF::DoImport( const string& sFile)
// lettura file
PReader reader = m_model->QueryReader( "3mf") ;
reader->ReadFromFile( sFile) ;
for ( Lib3MF_uint32 iWarning = 0 ; iWarning < reader->GetWarningCount() ; iWarning ++) {
for ( Lib3MF_uint32 nWarning = 0 ; nWarning < reader->GetWarningCount() ; nWarning ++) {
Lib3MF_uint32 nErrorCode ;
string sWarningMsg = reader->GetWarning( iWarning, nErrorCode) ;
string sErrorMsg = " Reading 3MF file encountered warning # " + to_string( nErrorCode) + " : " + sWarningMsg ;
string sWarningMsg = reader->GetWarning( nWarning, nErrorCode) ;
string sErrorMsg = " Reading 3MF file encountered warning # " + to_string( nErrorCode) + " : " + sWarningMsg ;
LOG_ERROR( GetEExLogger(), sErrorMsg.c_str()) ;
}
switch ( m_model->GetUnit()) {
case eModelUnit::MicroMeter :
m_nScaleFactor = 0.001 ;
m_dScaleFactor = 0.001 ;
break ;
case eModelUnit::MilliMeter :
m_nScaleFactor = 1.0 ;
m_dScaleFactor = 1.0 ;
break ;
case eModelUnit::CentiMeter :
m_nScaleFactor = 10.0 ;
m_dScaleFactor = 10.0 ;
break ;
case eModelUnit::Inch :
m_nScaleFactor = 25.4 ;
m_dScaleFactor = 25.4 ;
break ;
case eModelUnit::Foot :
m_nScaleFactor = 304.8 ;
m_dScaleFactor = 304.8 ;
break ;
case eModelUnit::Meter :
m_nScaleFactor = 1000.0 ;
m_dScaleFactor = 1000.0 ;
break ;
default:
m_nScaleFactor = 1.0 ;
m_dScaleFactor = 1.0 ;
}
// analisi metadata
@@ -121,83 +125,54 @@ Import3MF::DoImport( const string& sFile)
Lib3MF_uint32 nMetaDataCount = metaDataGrp->GetMetaDataCount() ;
for ( Lib3MF_uint32 i = 0 ; i < nMetaDataCount ; i ++) {
PMetaData metaData = metaDataGrp->GetMetaData( i) ;
string sMetaDataValue = metaData->GetValue() ;
string sMetaDataName = metaData->GetName() ;
if ( ! sMetaDataValue.empty() && ! sMetaDataName.empty())
m_pGDB->SetInfo( m_nIdGroup, sMetaDataName, sMetaDataValue) ;
string sName = metaData->GetName() ;
string sValue = metaData->GetValue() ;
if ( ! sName.empty() && ! sValue.empty())
m_pGDB->SetInfo( m_nIdGroup, sName, sValue) ;
}
// scorro gli items nel build node
PBuildItemIterator pBuildItemsIter = m_model->GetBuildItems() ;
while ( pBuildItemsIter->MoveNext()) {
if ( ! ReadItem( pBuildItemsIter->GetCurrent()))
return false ;
PBuildItem pItem = pBuildItemsIter->GetCurrent() ;
// 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 ;
}
//----------------------------------------------------------------------------------------------------
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
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 ;
bool bMeshObj = pObj->IsMeshObject() ;
// attributes
string sProp = pObj->GetName() ;
INFOVECTOR vInfo ;
string sName = pObj->GetName() ;
string sProp = pObj->GetPartNumber() ;
if ( ! sProp.empty())
vAttr.push_back( make_pair( "name", sProp)) ;
sProp = pObj->GetPartNumber() ;
if ( ! sProp.empty())
vAttr.push_back( make_pair( "partnumber", sProp)) ;
vInfo.emplace_back( "PartNumber", sProp) ;
bool bUUID = false ;
sProp = pObj->GetUUID( bUUID) ;
if ( bUUID) {
string sPropName = bMeshObj ? "UUID" : "object UUID" ;
vAttr.push_back( make_pair( sPropName, sProp)) ;
}
if ( bUUID)
vInfo.emplace_back( "UUID", sProp) ;
switch ( pObj->GetType()) {
case eObjectType::Model :
vAttr.push_back( make_pair( "type", "Model")) ;
vInfo.emplace_back( "Type", "Model") ;
break ;
case eObjectType::Support :
vAttr.push_back( make_pair( "type", "Support")) ;
vInfo.emplace_back( "Type", "Support") ;
break ;
case eObjectType::SolidSupport :
vAttr.push_back( make_pair( "type", "SolidSupport")) ;
vInfo.emplace_back( "Type", "SolidSupport") ;
break ;
default :
break ;
@@ -205,29 +180,34 @@ Import3MF::ReadObject( const PObject pObj, ATTRVECTOR& vAttr, sTransform& sTrans
// metadata
PMetaDataGroup pMetaDataGrp = pObj->GetMetaDataGroup() ;
if ( pMetaDataGrp)
ReadMetaDataGroup( pMetaDataGrp, vAttr, bMeshObj ? Mesh : Component) ;
for ( Lib3MF_uint32 i = 0 ; i < pMetaDataGrp->GetMetaDataCount() ; i ++) {
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())
return ReadMesh( pObj->GetResourceID(), vAttr, sTransf) ;
return ReadMesh( pObj->GetResourceID(), sName, vInfo, Transform, nParentId) ;
else if ( pObj->IsComponentsObject())
return ReadComponents( pObj->GetResourceID(), vAttr, sTransf) ;
return ReadComponent( pObj->GetResourceID(), sName, vInfo, Transform, nParentId) ;
return false ;
}
//----------------------------------------------------------------------------------------------------------------
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
PMeshObject pMesh = m_model->GetMeshObjectByID( nId) ;
if ( pMesh.get() == nullptr)
if ( pMesh == nullptr)
return false ;
// Creo e inizializzo trimesh
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") ;
return false ;
}
@@ -240,15 +220,15 @@ Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sT
// applico la trasformazione
double x = 0.0, y = 0.0, z = 0.0 ;
for ( int 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 += pVertex.m_Coordinates[k] * Transform.m_Fields[k][0] ;
y += pVertex.m_Coordinates[k] * Transform.m_Fields[k][1] ;
z += pVertex.m_Coordinates[k] * Transform.m_Fields[k][2] ;
}
x += sTransf.m_Fields[3][0] ;
y += sTransf.m_Fields[3][1] ;
z += sTransf.m_Fields[3][2] ;
x += Transform.m_Fields[3][0] ;
y += Transform.m_Fields[3][1] ;
z += Transform.m_Fields[3][2] ;
// 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") ;
return false ;
}
@@ -275,7 +255,7 @@ Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sT
}
// 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) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : error adding GeoObject") ;
return false ;
@@ -290,125 +270,65 @@ Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sT
}
// 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) ;
}
if ( ! sName.empty())
m_pGDB->SetName( nGeoId, sName) ;
for ( int i = 0 ; i < int( vInfo.size()) ; i++)
m_pGDB->SetInfo( nGeoId, vInfo[i].first, vInfo[i].second) ;
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
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
for ( Lib3MF_uint32 iC = 0 ; iC < pComponents->GetComponentCount() ; iC ++ ) {
PComponentsObject pComponents = m_model->GetComponentsObjectByID( nId) ;
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) ;
sTransform sTransfComp = pComponent->GetTransform() ;
// combino le trasformazioni
sTransform sTransfRes ;
// inizializzo sTransfRes a zero
PComponent pComponent = pComponents->GetComponent( nC) ;
// combino le trasformazioni
sTransform TransfComp = pComponent->GetTransform() ;
sTransform TransfRes ;
// inizializzo TransfRes a zero
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 j = 0 ; j < 3 ; j++)
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 ++)
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 true ;
}
//------------------------------------------------------------------------------------
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 ;
@@ -431,12 +351,12 @@ Import3MF::FindColor( const Lib3MF_uint32& pid, const Lib3MF_uint32& pindex, Col
// multiproperty corrispondente a pindex
UINTVECTOR 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() ;
for ( Lib3MF_uint32 i = 0 ; i < nLayers ; i ++) {
sMultiPropertyLayer layer = pMultiPropGrp->GetLayer( i) ;
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 ||
m_model->GetPropertyTypeByID( pidLayer) == ePropertyType::Colors)
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
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 ;
// se fossero tutti zero, considero proporzioni uguali per ogni colore
if ( abs( dMixSum) < EPS_SMALL) {
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 ;
}
double dRed = 0.0, dGreen = 0.0, dBlue = 0.0, dAlpha = 0.0 ; // colore finale
Lib3MF_uint8 nRedTmp, nGreenTmp, nBlueTmp, nAlphaTmp ; // colore del BaseMaterial
// 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) ;
m_wrapper->ColorToRGBA( sCol, nRedTmp, nGreenTmp, nBlueTmp, nAlphaTmp) ;
double dMixingRatio = vComposite[i].m_MixingRatio / dMixSum ;
@@ -490,31 +410,3 @@ Import3MF::FindColor( const Lib3MF_uint32& pid, const Lib3MF_uint32& pindex, Col
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
#include <unordered_map>
#include "/EgtDev/Include/EExImport3MF.h"
#include "pugixml.hpp"
#include "/EgtDev/Extern/libzip/Include/zip.h"
#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
{
private :
typedef std::vector<std::pair<std::string, std::string>> ATTRVECTOR ;
enum MDGCaller { Item = 0, Component = 1, Mesh = 2 } ;
typedef std::vector<std::pair<std::string, std::string>> INFOVECTOR ;
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 :
bool DoImport( const std::string& sFile) ;
bool ReadItem( const Lib3MF::PBuildItem item) ;
bool ReadObject( const Lib3MF::PObject pObj, ATTRVECTOR& vAttr, Lib3MF::sTransform& sTransf) ;
bool ReadComponents( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, Lib3MF::sTransform& sTransfItem) ;
bool ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, Lib3MF::sTransform& sTransfr) ;
bool ReadMetaDataGroup( const Lib3MF::PMetaDataGroup pMetaDataGrp, ATTRVECTOR& vAttr, const MDGCaller& caller) ;
bool FindColor( const Lib3MF_uint32& pid, const Lib3MF_uint32& pindex, Color& cCol) ;
bool ReadObject( const Lib3MF::PObject pObj, const Lib3MF::sTransform& Transform, int nParentId) ;
bool ReadComponent( Lib3MF_uint32 nId, const std::string& sName, const INFOVECTOR& vInfo, const Lib3MF::sTransform& Transform,
int nParentId) ;
bool ReadMesh( Lib3MF_uint32 nId, const std::string& sName, const INFOVECTOR& vInfo, const Lib3MF::sTransform& Transfrorm,
int nParentId) ;
bool FindColor( Lib3MF_uint32 pid, Lib3MF_uint32 pindex, Color& cCol) const ;
private :
double m_nScaleFactor ;
private :
double m_dScaleFactor ;
IGeomDB* m_pGDB ;
int m_nIdGroup ;
int m_nFlag ;
Lib3MF::PWrapper m_wrapper ;
Lib3MF::PModel m_model ;
} ;
-1401
View File
File diff suppressed because it is too large Load Diff
-64
View File
@@ -1,64 +0,0 @@
//----------------------------------------------------------------------------
// EgalTech 2023
//----------------------------------------------------------------------------
// File : Import3dm.h Data : 23.06.23 Versione : 2.5f1
// Contenuto : Dichiarazione della classe Import3dm.
//
//
//
// Modifiche : 23.06.23 DB Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EExImport3dm.h"
#include "/EgtDev/Include/EGkSurf.h"
//#include "/EgtDev/opennurbs/opennurbs.h"
class ON_Point ;
class ON_4dPoint ;
class ON_3fPoint ;
class ON_Object ;
class ON_3dPoint ;
class ON_Curve ;
class ON_Surface ;
class ON_Brep ;
class ON_BrepLoop ;
class ON_3dVector ;
class ON_2dVector ;
class ON_NurbsSurface ;
class ICurve ;
class ICurveArc ;
class ICurveLine ;
class ISurf ;
class ISurfTriMesh ;
class ISurfFlatRegion ;
//----------------------------------------------------------------------------
class Import3dm : public IImport3dm
{
public :
bool Import( const std::string& sFile, IGeomDB* pGDB, int nIdGroup, double dScaleFactor = 1,
double dTextHeight = 2.0, double dExtLine = 5.0, double dArrLen = 5.0, double dTextDist = 2.0,
bool bLenIsMM = true, int nDecDig = -2, std::string sFont = "ModernPropS.Nfe") override ;
private :
Point3d ConvertPoint( const ON_Point& onPoint) ;
Point3d ConvertPoint( const ON_3dPoint& on3dPoint) ;
Point3d ConvertPoint( const ON_4dPoint& on4dPoint) ;
Point3d ConvertPoint( const ON_3fPoint& on3fPoint) ;
Vector3d ConvertVector( const ON_3dVector& onVector) ;
Vector3d ConvertVector( const ON_2dVector& onVector) ;
ICurve* ConvertCurve( const ON_Curve* onCurve) ;
ISurf* ConvertSurface( const ON_Surface* onSurf) ;
ISURFPVECTOR ConvertBrep( const ON_Brep* onBrep, const bool bForceTriMesh) ;
ICurve* ConvertBrepLoop( const ON_BrepLoop* onBrepLoop) ;
bool MakeUniform( ISurfFlatRegion** sfr, ON_NurbsSurface onNurbsSurface, double& dScaleU, double& dScaleV) ;
private :
IGeomDB* m_pGDB ;
int m_nIdGroup ;
double m_dScaleFactor ;
} ;
-34
View File
@@ -1,34 +0,0 @@
//----------------------------------------------------------------------------
// EgalTech 2023
//----------------------------------------------------------------------------
// File : Import3dmEnts.cpp Data : 27.06.23 Versione : 2.5f1
// Contenuto : Implementazione di Import3dm : gestione delle entità.
//
//
//
// Modifiche : 27.06.23 DB Creazione modulo.
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "Import3dm.h"
#include "DllMain.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EGkGeoVector3d.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveArc.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkCurveByInterp.h"
#include "/EgtDev/Include/EGkSurfTriMesh.h"
#include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGnStringKeyVal.h"
#include "/EgtDev/Include/EgtStringEncoder.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
+53 -13
View File
@@ -20,9 +20,8 @@
#include "/EgtDev/Include/EGkStmStandard.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringEncoder.h"
#include "/EgtDev/Include/EgtStringEncoder.h"
#include "/EgtDev/Include/EgtNumUtils.h"
using namespace std ;
@@ -34,6 +33,15 @@ SetBtlAuxDir( const string& sBtlAuxDir)
return ExistsDirectory( sBtlAuxDir) ;
}
//----------------------------------------------------------------------------
bool
SetBtlLuaData( const string& sLuaLibsDir, const string& sLuaLastRequire)
{
BtlGeom::m_sBtlLuaLibsDir = sLuaLibsDir ;
BtlGeom::m_sBtlLuaLastRequire = sLuaLastRequire ;
return ExistsDirectory( sLuaLibsDir) ;
}
//----------------------------------------------------------------------------
IImportBtl*
CreateImportBtl( void)
@@ -49,6 +57,7 @@ CreateImportBtl( void)
ImportBtl::ImportBtl( void)
{
m_nBuild = 10000 ;
m_nEdition = 0 ;
m_dScale = 1 ;
}
@@ -78,7 +87,8 @@ ImportBtl::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
bool bSpecialTrim = (( nFlag & EIBFLAG_SPECIAL_TRIM) != 0) ;
bool bTrimWithOutline = (( nFlag & EIBFLAG_TRIM_WITH_OUTLINE) != 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")
return false ;
}
@@ -299,7 +309,7 @@ ImportBtl::ReadGeneral( bool& bEnd)
Trim( sVal, " \t\r\n\"") ;
int nUnit ;
if ( FromString( sVal, nUnit)) {
m_dScale = pow( 10, - nUnit) ;
m_dScale = Pow( 10, -nUnit) ;
++ nRead ;
}
m_BtlGeom.SetUserAttribute( UATD_INFO, sKey, sVal) ;
@@ -527,8 +537,14 @@ ImportBtl::ReadObject( ObjType nType, bool& bEnd)
m_BtlGeom.SetUserAttribute( UATD_PART, sKey, sVal) ;
break ;
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 ;
case KEY_PART_PROCESSINGQUALITY : // qualità di lavorazione
Trim( sVal, " \t\r\n\"") ;
@@ -676,6 +692,21 @@ ImportBtl::ReadTransformation( const string& sVal, Frame3d& frRef)
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
ImportBtl::ReadOutline( void)
@@ -704,6 +735,18 @@ ImportBtl::ReadOutline( void)
break ;
}
// 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
int nFlag ;
GetParamP( sVal, 8, nFlag) ;
@@ -716,9 +759,6 @@ ImportBtl::ReadOutline( void)
bProcFound = true ;
}
}
// se non ancora assegnata, leggo faccia di riferimento
if ( nSide == BTL_SIDE_NONE)
GetInfo( sVal, PAR_SIDE, nSide) ;
// punto principale
Point3d ptP ;
GetParamP( sVal, 1, ptP.x) ;
@@ -837,13 +877,13 @@ ImportBtl::ReadColor( const string& sVal, Color& colRes)
// leggo i valori
string sRes ;
GetParam( sVal, PAR_R, sRes) ;
int nRed ; FromString( sRes, nRed) ;
int nRed = 0 ; FromString( sRes, nRed) ;
GetParam( sVal, PAR_G, sRes) ;
int nGreen ; FromString( sRes, nGreen) ;
int nGreen = 0 ; FromString( sRes, nGreen) ;
GetParam( sVal, PAR_B, sRes) ;
int nBlue ; FromString( sRes, nBlue) ;
int nBlue = 0 ; FromString( sRes, nBlue) ;
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) ;
return true ;
}
+1
View File
@@ -34,6 +34,7 @@ class ImportBtl : public IImportBtl
bool ReadGeneral( bool& bEnd) ;
bool ReadObject( ObjType nType, bool& bEnd) ;
bool ReadTransformation( const std::string& sVal, Frame3d& frRef) ;
bool ReadPartOffset( const std::string& sVal, DBLVECTOR& vdPar) ;
bool ReadOutline( void) ;
bool ReadAperture( void) ;
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 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 ReadPartAttributes( pugi::xml_attribute attr) ;
bool ReadCamber( pugi::xml_node node) ;
@@ -42,7 +42,7 @@ public :
bool ReadAperture( pugi::xml_node node, int nSide) ;
bool ReadUserReferencePlane( pugi::xml_node node) ;
bool ReadShape( pugi::xml_node node) ;
bool CheckGuid ( std::string s) ;
bool CheckGuid( const std::string& s) ;
// processing
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 ---------------------------------
static int GetGroup12( 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 ReadProcessChildAttribute( const pugi::xml_node& process, const string& sChild, const string& sAttribute, 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, double dVal) ;
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 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 pugi::xml_node& MachiningLimits) ;
@@ -52,7 +52,7 @@ ImportBtlx::ReadJackRafterCutParams( pugi::xml_node process, int& nGroup, int& n
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: JackRafterCut Orientation is not valid") ;
return false ;
}
@@ -98,9 +98,9 @@ ImportBtlx::ReadLongitudinalCutParams( pugi::xml_node process, int& nGroup, int&
if ( sToolPosition == "center")
nGroup = 0 ;
else if ( sToolPosition == "right")
nGroup = 3 ;
else if ( sToolPosition == "left")
nGroup = 4 ;
else if ( sToolPosition == "left")
nGroup = 3 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LongitudinalCut Tool position not valid") ;
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[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 sEndLimited = ReadProcessChildYesNo( process, "EndLimited", "no") ;
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() ;
nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: DoubleCut orientation unknown") ;
return false ;
}
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -191,7 +198,7 @@ ImportBtlx::ReadRidgeValleyCutParams( pugi::xml_node process, int& nGroup, int&
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -288,7 +295,7 @@ ImportBtlx::ReadSlotParams( pugi::xml_node process, int& nGroup, int& nProc, int
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Slot orientation unknown") ;
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[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")) ;
if ( vdPar[3] == -2)
return false ;
@@ -341,7 +348,7 @@ ImportBtlx::ReadBirdsMouthParams( pugi::xml_node process, int& nGroup, int& nPro
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BirdsMouth orientation unknwon") ;
return false ;
}
@@ -388,7 +395,7 @@ ImportBtlx::ReadHipValleyRafterNotchParams( pugi::xml_node process, int& nGroup,
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation unknwon") ;
return false ;
}
@@ -437,7 +444,7 @@ ImportBtlx::ReadLapParams( pugi::xml_node process, int& nGroup, int& nProc, int&
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation unknwon") ;
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
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[2] = ? Non c'è StartDepth
// vdPar[2] = ? Non c'è StartDepth
vdPar[4] = ReadProcessChild( process, "Angle", vdPar[4]) ; // P04
vdPar[5] = ReadProcessChild( process, "Inclination", vdPar[5]) ; // P07
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[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")) ;
if ( vdPar[3] == -2)
return false ;
@@ -489,14 +496,14 @@ ImportBtlx::ReadLogHouseHalfLapParams( pugi::xml_node process, int& nGroup, int&
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseHalfLap orientation unknwon") ;
return false ;
}
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -529,7 +536,7 @@ ImportBtlx::ReadFrenchRidgeLapParams( pugi::xml_node process, int& nGroup, int&
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FrenchRidgeLap orientation unknwon") ;
return false ;
}
@@ -537,7 +544,7 @@ ImportBtlx::ReadFrenchRidgeLapParams( pugi::xml_node process, int& nGroup, int&
// Inizializzo i vettori dei parametri
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") ;
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
vdPar[0] = Clamp( ReadProcessChild( process, "StartX", vdPar[0]), -100000.0, 100000.0) ; // P01
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
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
nGroup = 4 ; // Chamfer non ha orientation ( prendo start)
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -596,12 +601,12 @@ ImportBtlx::ReadChamferParams( pugi::xml_node process, int& nGroup, int& nProc,
string sCamferEdge23 = ReadProcessChildYesNo( process, "ChamferEdge23", "yes") ;
string sCamferEdge34 = ReadProcessChildYesNo( process, "ChamferEdge34", "yes") ;
string sCamferEdge41 = ReadProcessChildYesNo( process, "ChamferEdge41", "yes") ;
STRVECTOR values = { sCamferEdge12, sCamferEdge23, sCamferEdge34, sCamferEdge41} ;
STRVECTOR vsValues = { sCamferEdge12, sCamferEdge23, sCamferEdge34, sCamferEdge41} ;
vdPar[1] = 0.0 ;
for ( size_t i = 0 ; i < values.size() ; i++) {
if ( values[i] == "yes")
vdPar[1] += pow( 2, i) ;
else if ( values[i] != "no") {
for ( int i = 0 ; i < ssize( vsValues) ; i++) {
if ( vsValues[i] == "yes")
vdPar[1] += Pow( 2, i) ;
else if ( vsValues[i] != "no") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ChamferEdge value is not valid") ;
return false ;
}
@@ -638,11 +643,11 @@ ImportBtlx::ReadLogHouseJointParams( pugi::xml_node process, int& nGroup, int& n
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
if ( vdPar.size() != 15) {
if ( vdPar.size() != 16) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseJoint number of parameters is wrong") ;
return false ;
}
@@ -700,14 +705,14 @@ ImportBtlx::ReadLogHouseFrontParams( pugi::xml_node process, int& nGroup, int& n
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseFront orientation unknwon") ;
return false ;
}
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -744,7 +749,7 @@ ImportBtlx::ReadPocketParams( pugi::xml_node process, int& nGroup, int& nProc, i
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -768,8 +773,7 @@ ImportBtlx::ReadPocketParams( pugi::xml_node process, int& nGroup, int& nProc, i
vdPar[2] = ComputeP04( process.child( "MachiningLimits")) ;
if ( vdPar[2] == -2)
return false ;
}
}
return true ;
}
@@ -790,7 +794,7 @@ ImportBtlx::ReadDrillingParams( pugi::xml_node process, int& nGroup, int& nProc,
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -885,12 +889,11 @@ ImportBtlx::ReadMortiseParams( pugi::xml_node process, int& nGroup, int& nProc,
return false ;
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = 4 ;
nGroup = 4 ;
// Inizializzo i vettori dei parametri
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") ;
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[13] = Clamp( ReadProcessChild( process, "Slope", vdPar[13]), 0.1, 179.9) ; // P16
string sShape = process.child( "Shape").text().get() ; // P04
if ( sShape == "automatic" || sShape.empty())
vdPar[3] = 0 ;
@@ -940,7 +942,7 @@ bool
ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide,
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 ;
if ( process.attribute( "ReferencePlaneID") == nullptr) {
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() ;
nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Orientation unknown") ;
return false ;
}
@@ -986,13 +988,14 @@ ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& n
}
else if ( sShape == "radius" || sShape == "rounded" || sShape == "square" ) {
if ( sShape != "radius") // P12
vdPar[9] = MILL_DEF_RAD ;
vdPar[9] = DTMILL_DEF_RAD ;
vdPar[9] *= 2 ;
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") ;
return false ;
}
vdPar[6] = max( vdPar[6], 0.) ;
}
else {
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") {
if ( sShape != "radius") // P12
vdPar[10] = MILL_DEF_RAD ;
vdPar[10] = DTMILL_DEF_RAD ;
vdPar[10] *= 2 ; // P12
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") ;
return false ;
}
vdPar[7] = max( vdPar[7], 0.) ;
}
else {
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
nProc = 60 ;
if ( process.attribute( "ReferencePlaneID") == nullptr){
if ( process.attribute( "ReferencePlaneID") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
@@ -1123,7 +1127,7 @@ ImportBtlx::ReadMarkingParams( pugi::xml_node process, int& nGroup, int& nProc,
if ( nGroup == 4)
vtD.Mirror( X_AX) ;
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")
if ( abs( vdPar[3]) < EPS_SMALL)
vdPar[6] = dLength ;
@@ -1177,7 +1181,7 @@ ImportBtlx::ReadTextParams( pugi::xml_node process, int& nGroup, int& nProc, int
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -1255,7 +1259,7 @@ ImportBtlx::ReadSimpleScarfParams( pugi::xml_node process, int& nGroup, int& nPr
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -1288,7 +1292,7 @@ ImportBtlx::ReadScarfJointParams( pugi::xml_node process, int& nGroup, int& nPro
}
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup12( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon orientation unknwon") ;
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[6] = ReadProcessChild( process, "Length", vdPar[6]) ; // P13
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
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
nProc = 80 ;
if ( process.attribute( "ReferencePlaneID") == nullptr){
if ( process.attribute( "ReferencePlaneID") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
@@ -1350,7 +1353,7 @@ ImportBtlx::ReadStepJointParams( pugi::xml_node process, int& nGroup, int& nProc
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -1389,7 +1392,7 @@ ImportBtlx::ReadStepJointNotchParams( pugi::xml_node process, int& nGroup, int&
{
// Identifico il processo con sigle usate nel btl
nProc = 80 ;
if ( process.attribute( "ReferencePlaneID") == nullptr){
if ( process.attribute( "ReferencePlaneID") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
@@ -1402,7 +1405,7 @@ ImportBtlx::ReadStepJointNotchParams( pugi::xml_node process, int& nGroup, int&
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -1447,7 +1450,7 @@ ImportBtlx::ReadPlaningParams( pugi::xml_node process, int& nGroup, int& nProc,
{
// Identifico il processo con sigle usate nel btl
nProc = 90 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nSide = BTL_SIDE_FRONT ;
nGroup = 4 ;
// Inizializzo i vettori dei parametri
@@ -1486,7 +1489,7 @@ ImportBtlx::ReadProfileFrontParams( pugi::xml_node process, int& nGroup, int& nP
nProc = 100 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileFront orientation unknwon") ;
return false ;
}
@@ -1523,14 +1526,14 @@ ImportBtlx::ReadProfileCamberedParams( pugi::xml_node process, int& nGroup, int&
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileCambered orientation unknwon") ;
return false ;
}
// Inizializzo i vettori dei parametri
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") ;
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[5] = Clamp( ReadProcessChild( process, "EndDepth", vdPar[5]), 0.0, 1000.0) ; // P14
string sPremill = process.child( "Premill").text().get() ; // P15
if ( sPremill == "round")
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[2] = ReadProcessChild( process, "Length", vdPar[2]) ; // P12
string sArcShape = process.child( "ArcShape").text().get() ;
if ( sArcShape == "convex")
vdPar[1] = -vdPar[1] ;
return true ;
}
@@ -1599,7 +1605,7 @@ ImportBtlx::ReadProfileHeadParams( pugi::xml_node process, int& nGroup, int& nPr
nProc = 106 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileHead orientation unknwon") ;
return false ;
}
@@ -1687,14 +1693,14 @@ ImportBtlx::ReadSphereParams( pugi::xml_node process, int& nGroup, int& nProc, i
nProc = 107 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ;
nGroup = GetGroup34( process) ;
if ( nGroup == -1 ) {
if ( nGroup == -1) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Sphere orientation unknwon") ;
return false ;
}
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -1726,7 +1732,7 @@ ImportBtlx::ReadTriangleCutParams( pugi::xml_node process, int& nGroup, int& nPr
// Inizializzo i vettori dei parametri
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") ;
return false ;
}
@@ -1817,7 +1823,7 @@ ImportBtlx::ReadTyroleanDovetailParams( pugi::xml_node process, int& nGroup, int
vdPar[4] = -1 ;
else if ( sLapExit == "rebate") {
if ( process.child( "RebateLength") != nullptr)
vdPar[4] = std::stod( process.child( "RebateLength").text().get()) ;
FromString( process.child( "RebateLength").text().get(), vdPar[4]) ;
else
vdPar[4] = 10.0 ; // valore di default
}
@@ -1864,13 +1870,13 @@ ImportBtlx::ReadDovetailParams( pugi::xml_node process, int& nGroup, int& nProc,
if ( sCutOff.empty())
sCutOff = "no" ; // se non ci fosse, valore di default
if( sOrientation == "end" && sCutOff == "yes")
if( sOrientation == "end" && sCutOff == "yes")
nGroup = 1 ;
else if (sOrientation == "start" && sCutOff == "yes")
else if ( sOrientation == "start" && sCutOff == "yes")
nGroup = 2 ;
else if (sOrientation == "end" && sCutOff == "no")
else if ( sOrientation == "end" && sCutOff == "no")
nGroup = 3 ;
else if (sOrientation == "start" && sCutOff == "yes")
else if ( sOrientation == "start" && sCutOff == "yes")
nGroup = 4 ;
else {
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
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") ;
return false ;
}
@@ -1924,7 +1930,7 @@ ImportBtlx::ReadDovetailParams( pugi::xml_node process, int& nGroup, int& nProc,
vdPar[4] = -1 ;
else if ( sLapExit == "rebate") {
if ( process.child( "RebateLength") != nullptr)
vdPar[4] = std::stod( process.child( "RebateLength").text().get()) ;
FromString( process.child( "RebateLength").text().get(), vdPar[4]) ;
else
vdPar[4] = 10.0 ; // valore di default
}
@@ -1982,14 +1988,14 @@ ImportBtlx::ReadFreeContourParams( pugi::xml_node process, const STRVECTOR& vsUA
// scrorro i contours
for ( pugi::xml_node_iterator it = process.begin() ; it != process.end() ; it ++) {
string itName = it->name() ;
string sName = it->name() ;
bool bContOk = true ;
if ( itName == "Contour") {
if ( sName == "Contour") {
bContOk = ReadSContourParams( *it, 0, 0, nGroup, nProc, nSide, bCounterSink, nCrvCnt, vsUAtt) ;
if ( ! bContOk)
return false ;
}
else if ( itName == "DualContour") {
else if ( sName == "DualContour") {
bContOk = ReadDContourParams( *it, nGroup, nProc, nSide, bCounterSink, nCrvCnt, vsUAtt) ;
if ( ! bContOk)
return false ;
@@ -2018,7 +2024,7 @@ ImportBtlx::ReadSContourParams( pugi::xml_node process, int nType, int nOtherId,
}
frRef = m_mapRefPlanes[nSide] ;
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 ;
}
}
@@ -2206,17 +2212,20 @@ GetGroup34( const pugi::xml_node& process)
//---------------------------------------------------------------------------------------------------------------------------
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')
return std::stod( process.child( sChild.c_str()).text().get()) ;
if ( process.child( sChild.c_str()) != nullptr && process.child( sChild.c_str()).text().get() != nullptr) {
double dRes = dVal ;
FromString( process.child( sChild.c_str()).text().get(), dRes) ;
return dRes ;
}
else
return dVal ;
}
//---------------------------------------------------------------------------------------------------------------------------
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)
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
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() ;
if ( sValue == sDefaultOpt || sValue.empty() || ( sValue != "no" && sValue != "yes"))
@@ -2270,96 +2279,96 @@ ReadProcessChildYesNoToDouble( const pugi::xml_node& process, const string& sChi
//-----------------------------------------------------------------------------------------------------------------------------
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") ;
return -2 ;
}
int result = 0 ;
for ( size_t i = 0 ; i < values.size() ; i ++) {
if ( values[i] == "no")
result += static_cast<int>( pow( 2, i)) ;
else if ( values[i] != "yes") {
int nResult = 0 ;
for ( int i = 0 ; i < ssize( vsValues) ; i ++) {
if ( vsValues[i] == "no")
nResult += int( Pow( 2, i)) ;
else if ( vsValues[i] != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit value is not valid") ;
return -2 ;
}
}
return result ;
return nResult ;
}
//-----------------------------------------------------------------------------------------------------------------------------
int
ComputeP04( const pugi::xml_node& MachiningLimits)
{
string FaceLimitedStart = "yes" ;
string sFaceLimitedStart = "yes" ;
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)
FaceLimitedEnd = MachiningLimits.attribute( "FaceLimitedEnd").value() ;
sFaceLimitedEnd = MachiningLimits.attribute( "FaceLimitedEnd").value() ;
string FaceLimitedFront = "yes" ;
string sFaceLimitedFront = "yes" ;
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)
FaceLimitedBack = MachiningLimits.attribute( "FaceLimitedBack").value() ;
sFaceLimitedBack = MachiningLimits.attribute( "FaceLimitedBack").value() ;
string FaceLimitedBottom = "yes" ;
string sFaceLimitedBottom = "yes" ;
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)
FaceLimitedTop = MachiningLimits.attribute( "FaceLimitedTop").value() ;
sFaceLimitedTop = MachiningLimits.attribute( "FaceLimitedTop").value() ;
int result = 0 ;
if ( FaceLimitedStart == "no")
result += 1 ;
else if ( FaceLimitedStart != "yes") {
int nResult = 0 ;
if ( sFaceLimitedStart == "no")
nResult += 1 ;
else if ( sFaceLimitedStart != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ;
}
if ( FaceLimitedEnd == "no")
result += 2 ;
else if ( FaceLimitedEnd != "yes") {
if ( sFaceLimitedEnd == "no")
nResult += 2 ;
else if ( sFaceLimitedEnd != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ;
}
if ( FaceLimitedFront == "no")
result += 4 ;
else if ( FaceLimitedFront != "yes") {
if ( sFaceLimitedFront == "no")
nResult += 4 ;
else if ( sFaceLimitedFront != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ;
}
if ( FaceLimitedBack == "no")
result += 8 ;
else if ( FaceLimitedBack != "yes") {
if ( sFaceLimitedBack == "no")
nResult += 8 ;
else if ( sFaceLimitedBack != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ;
}
if ( FaceLimitedBottom == "no")
result += 16 ;
else if ( FaceLimitedBottom != "yes") {
if ( sFaceLimitedBottom == "no")
nResult += 16 ;
else if ( sFaceLimitedBottom != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ;
}
if ( FaceLimitedTop == "no")
result += 32 ;
else if ( FaceLimitedTop != "yes") {
if ( sFaceLimitedTop == "no")
nResult += 32 ;
else if ( sFaceLimitedTop != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid") ;
return -2 ;
}
return result ;
return nResult ;
}
+56 -8
View File
@@ -25,8 +25,6 @@
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDEv/Include/EGnScanner.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.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_TPOS2 = "TPOS2" ;
static const string KEY_SPEED = "SPEED" ;
static const string KEY_FEED = "FEED" ;
static const string KEY_ROTAX_A = "A" ;
static const string KEY_ROTAX_B = "B" ;
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_sToolName.clear() ;
m_nExit = 1 ;
m_dFeed = 0 ;
// se estensione xpi è NUM
string sFileTitle, sFileExt ;
@@ -171,7 +171,7 @@ ImportCnc::ProcessLine( const string& sLine)
return ParseRemark( sLine) ;
// 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 ;
// eliminazione di commenti intermedi o finali
@@ -179,6 +179,8 @@ ImportCnc::ProcessLine( const string& sLine)
// se controllo OSAI elimino le parti dopo ;
if ( m_nCNC == CNC_OSAI) {
size_t nStart = sMyLine.find( ';') ;
if ( nStart == string::npos)
nStart = sMyLine.find( "@") ;
if ( nStart != string::npos)
sMyLine.erase( nStart) ;
}
@@ -193,13 +195,21 @@ ImportCnc::ProcessLine( const string& sLine)
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) {
if ( sMyLine.starts_with( "ID"))
return true ;
if ( sMyLine.starts_with( "DYN"))
return true ;
size_t nStart = sMyLine.find( "CYCLE800") ;
if ( nStart == string::npos)
nStart = sMyLine.find( "CYCLE832") ;
if ( nStart == string::npos)
nStart = sMyLine.find( "/WHEN") ;
if ( nStart != string::npos)
sMyLine.erase( nStart) ;
ReplaceString( sMyLine, "SUPA", "G79") ;
ReplaceString( sMyLine, "AC(", "") ;
}
// divido la linea in parti
@@ -207,7 +217,7 @@ ImportCnc::ProcessLine( const string& sLine)
TokenizePlus( sMyLine, "NGXYZIJKPQRUVWABCFTMHhDEL", vsTokens) ;
// 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
switch ( vsTokens[i][0]) {
case 'G' :
@@ -252,6 +262,9 @@ ImportCnc::ProcessLine( const string& sLine)
case 'T' :
ParseT( vsTokens[i]) ;
break ;
case 'F' :
ParseF( vsTokens[i]) ;
break ;
case 'M' :
ParseM( vsTokens[i]) ;
break ;
@@ -274,8 +287,11 @@ ImportCnc::ProcessLine( const string& sLine)
// se utensile da caricare
if ( m_bLoadTool)
m_nTool = m_nNextTool ;
// se comando da ignorare
if ( m_nCommand == SKIP)
;
// se comando di movimento o riconosciuto movimento, lo eseguo
if ( m_nCommand == MOVE || m_bToMove)
else if ( m_nCommand == MOVE || m_bToMove)
bOk = ExecMovement() ;
// se comando di impostazione piano di interpolazione
else if ( m_nCommand == IPL)
@@ -363,7 +379,8 @@ ImportCnc::ParseRemark( const string& sLine)
if ( iExit == string::npos)
iExit = sLine.find( "EXIT=") ;
if ( iExit != string::npos) {
FromString( sLine.substr( iExit + 5), m_nExit) ;
if ( ! FromString( sLine.substr( iExit + 5), m_nExit))
m_nExit = 0 ;
return true ;
}
// cerco indicazione posizione nel TC
@@ -435,6 +452,9 @@ ImportCnc::ParseG( const string& sToken)
m_nCommand = MOVE ;
m_nMoveType = ARC_CCW ;
break ;
case 4 :
m_nCommand = SKIP ;
break ;
case 14 :
m_nCommand = MOVE ;
m_nMoveType = ARC_MID_3D ;
@@ -523,6 +543,8 @@ ImportCnc::ParseX( const string& sToken)
case OFFS :
m_vtOffs.x = dVal ;
break ;
case SKIP :
break ;
default :
if ( m_bZeroMach)
m_ptNext.x = m_ptHome.x + dVal ;
@@ -550,6 +572,8 @@ ImportCnc::ParseY( const string& sToken)
case OFFS :
m_vtOffs.y = dVal ;
break ;
case SKIP :
break ;
default :
if ( m_bZeroMach)
m_ptNext.y = m_ptHome.y + dVal ;
@@ -577,6 +601,8 @@ ImportCnc::ParseZ( const string& sToken)
case OFFS :
m_vtOffs.z = dVal ;
break ;
case SKIP :
break ;
default :
if ( m_bZeroMach)
m_ptNext.z = m_ptHome.z + dVal ;
@@ -630,7 +656,6 @@ ImportCnc::ParseJ( const string& sToken)
case ZX : m_ptCen.x = dVal ; break ;
}
}
m_nArcType = CENTER ;
m_bToMove = true ;
return true ;
@@ -771,6 +796,17 @@ ImportCnc::ParseT( const string& sToken)
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
ImportCnc::ParseM( const string& sToken)
@@ -903,6 +939,9 @@ ImportCnc::AddPoint( int nPntType)
m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ;
if ( ! isnan( 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
SetInfos( nId) ;
m_vInfos.clear() ;
@@ -962,6 +1001,9 @@ ImportCnc::AddLine( int nLineType)
m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ;
if ( ! isnan( 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
SetInfos( nId) ;
m_vInfos.clear() ;
@@ -1053,6 +1095,9 @@ ImportCnc::AddArc( bool bCCW)
m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ;
if ( ! isnan( 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
SetInfos( nId) ;
m_vInfos.clear() ;
@@ -1119,6 +1164,9 @@ ImportCnc::AddArc3P( bool bIs2D)
m_pGDB->SetInfo( nId, KEY_ROTAX_B, m_dRotAxB) ;
if ( ! isnan( 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
SetInfos( nId) ;
m_vInfos.clear() ;
+3 -1
View File
@@ -42,6 +42,7 @@ class ImportCnc : public IImportCnc
bool ParseB( const std::string& sToken) ;
bool ParseC( const std::string& sToken) ;
bool ParseT( const std::string& sToken) ;
bool ParseF( const std::string& sToken) ;
bool ParseM( const std::string& sToken) ;
bool ParseH( const std::string& sToken) ;
bool ExecSetIPL( void) ;
@@ -73,7 +74,7 @@ class ImportCnc : public IImportCnc
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 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 PntType { P_RAPID = 0, P_PNT = 1, P_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_sToolPos2 ;
std::string m_sSpeed ;
double m_dFeed ;
STRVECTOR m_vInfos ;
} ;
+1 -3
View File
@@ -25,8 +25,6 @@
#include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <fstream>
@@ -599,7 +597,7 @@ ImportCsf::ProcessExtendedText( const CsfEnt& csfEnt)
}
// salvataggio testo con un punto di inserimento per ogni carattere
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
PtrOwner<IExtText> pTxt( CreateExtText()) ;
if ( IsNull( pTxt))
-3
View File
@@ -19,12 +19,9 @@
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
using namespace std ;
//----------------------------------------------------------------------------
IImportDxf*
CreateImportDxf( void)
+27 -18
View File
@@ -398,9 +398,9 @@ bool
ImportDxf::ReadArc( bool& bFileEnd)
{
Point3d ptCen ;
double dRadius ;
double dStartAng ;
double dEndAng ;
double dRadius = 0 ;
double dStartAng = 0 ;
double dEndAng = 0 ;
Vector3d vtExtr = Z_AX ;
double dThick = 0 ;
string sLayer ;
@@ -529,7 +529,7 @@ bool
ImportDxf::ReadCircle( bool& bFileEnd)
{
Point3d ptCen ;
double dRadius ;
double dRadius = 0 ;
Vector3d vtExtr = Z_AX ;
double dThick = 0 ;
string sLayer ;
@@ -2146,47 +2146,55 @@ ImportDxf::ReadSpline( bool& bFileEnd)
sLayer = m_sCurrItem ;
break ;
case 10 :
FromString( m_sCurrItem, ptP.x) ;
if ( ! FromString( m_sCurrItem, ptP.x))
ptP.x = 0 ;
++ nContX ;
if ( nContX == nContY && nContY == nContZ)
cnData.vCP.push_back( ptP) ;
break ;
case 20 :
FromString( m_sCurrItem, ptP.y) ;
if ( ! FromString( m_sCurrItem, ptP.y))
ptP.y = 0 ;
++ nContY ;
if ( nContX == nContY && nContY == nContZ)
cnData.vCP.push_back( ptP) ;
break ;
case 30 :
FromString( m_sCurrItem, ptP.z) ;
if ( ! FromString( m_sCurrItem, ptP.z))
ptP.z = 0 ;
++ nContZ ;
if ( nContX == nContY && nContY == nContZ)
cnData.vCP.push_back( ptP) ;
break ;
case 11 :
FromString( m_sCurrItem, ptInt.x) ;
if ( ! FromString( m_sCurrItem, ptInt.x))
ptInt.x = 0 ;
++ nIntX ;
if ( nIntX == nIntY && nIntY == nIntZ)
vIntPnt.push_back( ptInt) ;
break ;
case 21 :
FromString( m_sCurrItem, ptInt.y) ;
if ( ! FromString( m_sCurrItem, ptInt.y))
ptInt.y = 0 ;
++ nIntY ;
if ( nIntX == nIntY && nIntY == nIntZ)
vIntPnt.push_back( ptInt) ;
break ;
case 31 :
FromString( m_sCurrItem, ptInt.z) ;
if ( ! FromString( m_sCurrItem, ptInt.z))
ptInt.z = 0 ;
++ nIntZ ;
if ( nIntX == nIntY && nIntY == nIntZ)
vIntPnt.push_back( ptInt) ;
break ;
case 40 :
FromString( m_sCurrItem, dTemp) ;
if ( ! FromString( m_sCurrItem, dTemp))
dTemp = 0 ;
cnData.vU.push_back( dTemp) ;
break;
case 41 :
FromString( m_sCurrItem, dTemp) ;
if ( ! FromString( m_sCurrItem, dTemp))
dTemp = 0 ;
cnData.vW.push_back( dTemp) ;
break;
case 60 :
@@ -2253,8 +2261,9 @@ ImportDxf::ReadSpline( bool& bFileEnd)
}
// assegnazione flag
cnData.bRat = (( nFlag & SPL_RATIONAL) != 0) ;
cnData.bPeriodic = (( nFlag & SPL_PERIODIC) != 0 && ( nKnotNbr != nCPntNbr + cnData.nDeg +1)) ;
cnData.bPeriodic = (( nFlag & SPL_PERIODIC) != 0 && ( nKnotNbr != nCPntNbr + cnData.nDeg + 1)) ;
cnData.bClosed = (( nFlag & SPL_CLOSED) != 0) ;
cnData.bClamped = true ;
cnData.bExtraKnotes = true ;
// Verifico il numero di nodi
if ( cnData.vU.size() != nKnotNbr || nKnotNbr < 4)
@@ -2301,7 +2310,7 @@ ImportDxf::ReadText( int nGroupId, bool& bFileEnd)
string sText ;
string sLayer ;
string sStyle = "STANDARD" ;
double dH ;
double dH = 0 ;
double dAngDeg = 0 ;
double dRat = 1 ;
int nSpace = ENT_MODELSPACE ;
@@ -2499,7 +2508,7 @@ ImportDxf::ReadMText( bool& bFileEnd)
string sText ;
string sLayer ;
string sStyle = "STANDARD" ;
double dH ;
double dH = 0 ;
double dTextMaxWidth = 0 ;
double dAngRad = 0 ;
int nInsPos = ETXT_IPBL ;
@@ -2686,16 +2695,16 @@ ImportDxf::AdjustMText( string& sText, double dTextMaxWidth, double dW)
// coefficiente empirico che in generale migliora l'adattamento
const double COEFF_LARGH = 1.2 ;
// gestione max lunghezza riga di testo
size_t nLastSp = - 1 ;
int nLastSp = -1 ;
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
if ( sText[i] == ' ')
nLastSp = i ;
// se c'è già un a capo
if ( sText[i] == '\n') {
dCurrWidth = 0 ;
nLastSp = - 1 ;
nLastSp = -1 ;
}
// se supera il limite
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/EGkGeoPoint3d.h"
#include "/EgtDEv/Include/EGnScanner.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
+7 -8
View File
@@ -16,13 +16,10 @@
#include "ImportStl.h"
#include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
#include "/EgtDEv/Include/EGnScanner.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/EgtPointerOwner.h"
#include <fstream>
@@ -199,14 +196,16 @@ ImportStl::LoadSolid( Scanner& TheScanner, bool& bEnd)
return false ;
}
// inserisco l'oggetto nel DB geometrico
ISurfTriMesh* pSTM = StmFts.GetSurf() ;
int nIdNew = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, pSTM) ;
PtrOwner<ISurfTriMesh> pSTM( StmFts.GetSurf()) ;
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
if ( ! sName.empty())
m_pGDB->SetName( nIdNew, sName) ;
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
* --------------------------------------------------------
* Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
* of this file.
*
* This work is based on the pugxml parser, which is:
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/
* pugixml parser - version 1.15
* --------------------------------------------------------
* Copyright (C) 2006-2025, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
* of this file.
*
* This work is based on the pugxml parser, which is:
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/
#ifndef HEADER_PUGICONFIG_HPP
#define HEADER_PUGICONFIG_HPP
@@ -46,35 +46,35 @@
// Uncomment this to switch to header-only version
// #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
// Uncomment this to enable support for std::string_view (usually enabled automatically)
// #define PUGIXML_HAS_STRING_VIEW
#endif
/**
* Copyright (c) 2006-2020 Arseny Kapoulkine
*
* 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.
*/
* Copyright (c) 2006-2025 Arseny Kapoulkine
*
* 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.
*/
+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
* --------------------------------------------------------
* Copyright (C) 2006-2020, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
* of this file.
*
* This work is based on the pugxml parser, which is:
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/
* pugixml parser - version 1.15
* --------------------------------------------------------
* Copyright (C) 2006-2025, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
* of this file.
*
* This work is based on the pugxml parser, which is:
* 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
// 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
// Include user configuration file (this can define various configuration macros)
@@ -38,6 +38,20 @@
# include <string>
#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
#ifndef PUGIXML_DEPRECATED
# if defined(__GNUC__)
@@ -82,14 +96,14 @@
# endif
#endif
// If C++ is 2011 or higher, add 'noexcept' specifiers
// If C++ is 2011 or higher, use 'noexcept' specifiers
#ifndef PUGIXML_NOEXCEPT
# if __cplusplus >= 201103
# define PUGIXML_NOEXCEPT noexcept
# elif defined(_MSC_VER) && _MSC_VER >= 1900
# define PUGIXML_NOEXCEPT noexcept
# else
# define PUGIXML_NOEXCEPT
# define PUGIXML_NOEXCEPT throw()
# endif
#endif
@@ -115,6 +129,8 @@
#ifndef PUGIXML_NULL
# if __cplusplus >= 201103
# define PUGIXML_NULL nullptr
# elif defined(_MSC_VER) && _MSC_VER >= 1600
# define PUGIXML_NULL nullptr
# else
# define PUGIXML_NULL 0
# endif
@@ -136,7 +152,12 @@ namespace pugi
#ifndef PUGIXML_NO_STL
// 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
}
@@ -211,6 +232,10 @@ namespace pugi
// This flag is off by default.
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.
// 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.
@@ -291,12 +316,12 @@ namespace pugi
class xml_text;
#ifndef PUGIXML_NO_XPATH
#ifndef PUGIXML_NO_XPATH
class xpath_node;
class xpath_node_set;
class xpath_query;
class xpath_variable_set;
#endif
#endif
// Range-based for loop support
template <typename It> class xml_object_range
@@ -312,6 +337,8 @@ namespace pugi
It begin() const { return _begin; }
It end() const { return _end; }
bool empty() const { return _begin == _end; }
private:
It _begin, _end;
};
@@ -320,7 +347,7 @@ namespace pugi
class PUGIXML_CLASS xml_writer
{
public:
virtual ~xml_writer() {}
virtual ~xml_writer();
// Write memory chunk into stream/file/whatever
virtual void write(const void* data, size_t size) = 0;
@@ -339,22 +366,22 @@ namespace pugi
void* file;
};
#ifndef PUGIXML_NO_STL
#ifndef PUGIXML_NO_STL
// xml_writer implementation for streams
class PUGIXML_CLASS xml_writer_stream: public xml_writer
{
public:
// 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<wchar_t, std::char_traits<wchar_t> >& stream);
xml_writer_stream(std::basic_ostream<char>& stream);
xml_writer_stream(std::basic_ostream<wchar_t>& stream);
virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
private:
std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream;
std::basic_ostream<char>* narrow_stream;
std::basic_ostream<wchar_t>* wide_stream;
};
#endif
#endif
// A light-weight handle for manipulating attributes in DOM tree
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;
// Check if attribute is empty
// Check if attribute is empty (null)
bool empty() const;
// Get attribute name/value, or "" if attribute is empty
@@ -404,17 +431,25 @@ namespace pugi
double as_double(double 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;
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
bool as_bool(bool def = false) const;
// 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, 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, 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")
bool set_value(int rhs);
@@ -427,10 +462,10 @@ namespace pugi
bool set_value(float rhs, int precision);
bool set_value(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG
#ifdef PUGIXML_HAS_LONG_LONG
bool set_value(long long rhs);
bool set_value(unsigned long long rhs);
#endif
#endif
// Set attribute value (equivalent to set_value without error checking)
xml_attribute& operator=(const char_t* rhs);
@@ -442,10 +477,14 @@ namespace pugi
xml_attribute& operator=(float 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=(unsigned long long rhs);
#endif
#endif
// Get next/previous attribute in the attribute list of the parent node
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;
// Check if node is empty.
// Check if node is empty (null)
bool empty() const;
// Get node type
@@ -536,9 +575,18 @@ namespace pugi
xml_attribute attribute(const char_t* name) const;
xml_node next_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)
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
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)
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, 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.
xml_attribute append_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_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.
xml_attribute append_copy(const xml_attribute& proto);
@@ -573,6 +635,12 @@ namespace pugi
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_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.
xml_node append_copy(const xml_node& proto);
@@ -589,6 +657,9 @@ namespace pugi
// Remove specified attribute
bool remove_attribute(const xml_attribute& a);
bool remove_attribute(const char_t* name);
#ifdef PUGIXML_HAS_STRING_VIEW
bool remove_attribute(string_view_t name);
#endif
// Remove all attributes
bool remove_attributes();
@@ -596,6 +667,9 @@ namespace pugi
// Remove specified child
bool remove_child(const xml_node& n);
bool remove_child(const char_t* name);
#ifdef PUGIXML_HAS_STRING_VIEW
bool remove_child(string_view_t name);
#endif
// Remove all 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* 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.
string_t path(char_t delimiter = '/') const;
#endif
#endif
// 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;
@@ -668,7 +742,7 @@ namespace pugi
// Recursively traverse subtree with xml_tree_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.
xpath_node select_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) 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 xpath_query& query) const;
#endif
#endif
// 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;
#ifndef PUGIXML_NO_STL
#ifndef PUGIXML_NO_STL
// 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<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;
#endif
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>& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const;
#endif
// Child nodes iterators
typedef xml_node_iterator iterator;
@@ -706,9 +780,12 @@ namespace pugi
// Range-based for support
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;
// 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
ptrdiff_t offset_debug() const;
@@ -749,7 +826,7 @@ namespace pugi
// Borland C++ workaround
bool operator!() const;
// Check if text object is empty
// Check if text object is empty (null)
bool empty() const;
// Get text, or "" if object is empty
@@ -764,16 +841,20 @@ namespace pugi
double as_double(double 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;
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
bool as_bool(bool def = false) const;
// 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, 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")
bool set(int rhs);
@@ -786,10 +867,10 @@ namespace pugi
bool set(float rhs, int precision);
bool set(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG
#ifdef PUGIXML_HAS_LONG_LONG
bool set(long long rhs);
bool set(unsigned long long rhs);
#endif
#endif
// Set text (equivalent to set without error checking)
xml_text& operator=(const char_t* rhs);
@@ -801,10 +882,14 @@ namespace pugi
xml_text& operator=(float 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=(unsigned long long rhs);
#endif
#endif
// Get the data node (node_pcdata or node_cdata) for this object
xml_node data() const;
@@ -834,9 +919,9 @@ namespace pugi
typedef xml_node* pointer;
typedef xml_node& reference;
#ifndef PUGIXML_NO_STL
#ifndef PUGIXML_NO_STL
typedef std::bidirectional_iterator_tag iterator_category;
#endif
#endif
// Default constructor
xml_node_iterator();
@@ -851,10 +936,10 @@ namespace pugi
xml_node& operator*() const;
xml_node* operator->() const;
const xml_node_iterator& operator++();
xml_node_iterator& operator++();
xml_node_iterator operator++(int);
const xml_node_iterator& operator--();
xml_node_iterator& operator--();
xml_node_iterator operator--(int);
};
@@ -876,9 +961,9 @@ namespace pugi
typedef xml_attribute* pointer;
typedef xml_attribute& reference;
#ifndef PUGIXML_NO_STL
#ifndef PUGIXML_NO_STL
typedef std::bidirectional_iterator_tag iterator_category;
#endif
#endif
// Default constructor
xml_attribute_iterator();
@@ -893,10 +978,10 @@ namespace pugi
xml_attribute& operator*() const;
xml_attribute* operator->() const;
const xml_attribute_iterator& operator++();
xml_attribute_iterator& operator++();
xml_attribute_iterator operator++(int);
const xml_attribute_iterator& operator--();
xml_attribute_iterator& operator--();
xml_attribute_iterator operator--(int);
};
@@ -912,14 +997,15 @@ namespace pugi
typedef xml_node* pointer;
typedef xml_node& reference;
#ifndef PUGIXML_NO_STL
#ifndef PUGIXML_NO_STL
typedef std::bidirectional_iterator_tag iterator_category;
#endif
#endif
// Default constructor
xml_named_node_iterator();
// 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);
// Iterator operators
@@ -929,10 +1015,10 @@ namespace pugi
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);
const xml_named_node_iterator& operator--();
xml_named_node_iterator& operator--();
xml_named_node_iterator operator--(int);
private:
@@ -1041,11 +1127,11 @@ namespace pugi
// Destructor, invalidates all node/attribute handles to this document
~xml_document();
#ifdef PUGIXML_HAS_MOVE
#ifdef PUGIXML_HAS_MOVE
// Move semantics support
xml_document(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
void reset();
@@ -1053,11 +1139,11 @@ namespace pugi
// Removes all nodes, then copies the entire contents of the specified document
void reset(const xml_document& proto);
#ifndef PUGIXML_NO_STL
#ifndef PUGIXML_NO_STL
// 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<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default);
#endif
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>& stream, unsigned int options = parse_default);
#endif
// (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);
@@ -1083,11 +1169,11 @@ namespace pugi
// 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;
#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).
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<wchar_t, std::char_traits<wchar_t> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const;
#endif
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>& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const;
#endif
// 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;
@@ -1185,11 +1271,11 @@ namespace pugi
xpath_variable_set(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
xpath_variable_set(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
xpath_variable* add(const char_t* name, xpath_value_type type);
@@ -1229,11 +1315,11 @@ namespace pugi
// Destructor
~xpath_query();
#ifdef PUGIXML_HAS_MOVE
#ifdef PUGIXML_HAS_MOVE
// Move semantics support
xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT;
xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT;
#endif
#endif
// Get query expression return type
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.
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.
// 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;
#endif
#endif
// 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).
@@ -1279,13 +1365,13 @@ namespace pugi
bool operator!() const;
};
#ifndef PUGIXML_NO_EXCEPTIONS
#if defined(_MSC_VER)
// C4275 can be ignored in Visual C++ if you are deriving
// from a type in the Standard C++ Library
#pragma warning(push)
#pragma warning(disable: 4275)
#endif
#ifndef PUGIXML_NO_EXCEPTIONS
#if defined(_MSC_VER)
// C4275 can be ignored in Visual C++ if you are deriving
// from a type in the Standard C++ Library
#pragma warning(push)
#pragma warning(disable: 4275)
#endif
// XPath exception class
class PUGIXML_CLASS xpath_exception: public std::exception
{
@@ -1297,15 +1383,15 @@ namespace pugi
explicit xpath_exception(const xpath_parse_result& result);
// Get error message
virtual const char* what() const throw() PUGIXML_OVERRIDE;
virtual const char* what() const PUGIXML_NOEXCEPT PUGIXML_OVERRIDE;
// Get parse result
const xpath_parse_result& result() const;
};
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif
// XPath node class (either xml_node or xml_attribute)
class PUGIXML_CLASS xpath_node
@@ -1379,11 +1465,11 @@ namespace pugi
xpath_node_set(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
xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
#endif
#endif
// Get collection type
type_t type() const;
@@ -1422,12 +1508,12 @@ namespace pugi
#ifndef PUGIXML_NO_STL
// 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, 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 wchar_t* str);
std::basic_string<char> PUGIXML_FUNCTION as_utf8(const std::basic_string<wchar_t>& str);
// 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, 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 char* str);
std::basic_string<wchar_t> PUGIXML_FUNCTION as_wide(const std::basic_string<char>& str);
#endif
// Memory allocation function interface; returns pointer to allocated memory or NULL on failure
@@ -1474,27 +1560,26 @@ namespace std
#endif
/**
* Copyright (c) 2006-2020 Arseny Kapoulkine
*
* 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.
*/
* Copyright (c) 2006-2025 Arseny Kapoulkine
*
* 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.
*/
+2 -1
View File
@@ -31,9 +31,10 @@
#pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "EgtNumKernel" 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, EGTEXTDIR "/libzip/Lib/zip" EGTLIBVER ".lib")
#pragma comment(lib, EGTEXTDIR "/lib3mf/Lib/lib3mf" EGTLIBVER ".lib")
#pragma comment(lib, EGTEXTDIR "/opennurbs/Lib/opennurbs_public" EGTLIBVER ".lib")
#pragma comment(lib, EGTEXTDIR "Lua/Lib/Lua54" EGTLIBVER ".lib")