61 Commits

Author SHA1 Message Date
Riccardo Elitropi 30785bb31f EgtExchange :
- Aggiunta file ExportThreejs.cpp al progetto
- Modifica pagina web e aggiunta di controlli.
2022-10-05 12:26:03 +02:00
Riccardo Elitropi 6a72e287cc Merge commit '07cff78ff630e87f9c33705665a398cb04af6d2d' into ThreeJS 2022-10-05 12:18:02 +02:00
DarioS 07cff78ff6 EgtExchange :
- escluso dal progetto il modulo di esportazione ExportThreeJS.cpp.
2022-10-03 08:21:33 +02:00
riccardo.elitropi 72f17b2605 Merge commit 'd96d99c5ae0a73d7b8a7b13a16f996848aaa355e' into ThreeJS 2022-09-20 17:20:45 +02:00
riccardo.elitropi 3881a4bb21 EgtExchange:
- modifica terzo parametro LUA (gruppi) e misure.
2022-09-20 17:19:21 +02:00
riccardo.elitropi d96d99c5ae Merge commit '6bec469a58c2a43896ca9ae7d12e7ac61c9a2137' 2022-09-20 17:07:23 +02:00
riccardo.elitropi 6bec469a58 EgtExchange:
- Modifica codice, implementazione delle misure da mobile e da desktop
- cambio dei parametri e controllo filtro su gruppi.
2022-09-20 17:06:11 +02:00
DarioS 11d89dfd14 EgtExchange :
- ancora piccola miglioria a import BTL.
2022-09-09 08:45:26 +02:00
DarioS 49d0b6e9a9 EgtExchange 2.4i1 :
- in import BTL aggiunta gestione feature 3/4-090-X (ora sono importate tutte).
2022-09-08 09:29:09 +02:00
riccardo.elitropi dc66bdc04e EgtExchange :
- Aggiornamento codice ExportThreeJs.
2022-09-01 11:10:57 +02:00
riccardo.elitropi aa0290e365 Merge commit 'e639b310dc32be5972a47ecac90010223a15899b' into ThreeJS 2022-09-01 11:09:33 +02:00
DarioS e639b310dc EgtExchange 2.4h2 :
- in import BTL migliorata gestione MortiseFront vuota
- in import BTL corretta creazione Outline e Aperture.
2022-08-25 21:01:49 +02:00
riccardo.elitropi 0b7c6e1d29 Merge commit 'e09ee5537f244d8b8f6ac7b89880517e435db457' into ThreeJS 2022-08-25 09:27:24 +02:00
riccardo.elitropi b2e6005700 EgtExchange :
- esportazione con menu e file geometrie separati
2022-08-25 09:26:24 +02:00
DarioS e09ee5537f EgtExchange 2.4h1 :
- in import BTL corretta gestione FreeContour di tipo Pen (P13=10).
2022-08-23 11:22:30 +02:00
riccardo.elitropi 1c8da69f63 EgtExchange :
- aggiunta export threejs (primi test in locale sulla mia macchina).
2022-08-22 17:36:47 +02:00
DarioS 62858b6972 EgtExchange 2.4g8 :
- in import BTL estensione gestione House (ora anche gruppo 1 e 2).
2022-08-09 07:07:37 +02:00
DarioS 609d911cf9 EgtExchange 2.4g7 :
- in import BTL aggiunta gestione feature Text senza testo come feature vuota.
2022-08-04 19:56:38 +02:00
DarioS 264b3318fe EgtExchange 2.4g6 :
- in import BTL aggiunta gestione FreeContour di tipo Nail con solo Start.
2022-08-03 10:27:53 +02:00
DarioS 289744ca70 EgtExchange 2.4g5 :
- in import BTL corretta gestione per trim di seconda superficie di FrontSlot.
2022-08-01 12:29:16 +02:00
DarioS b4ea91e637 EgtExchange 2.4g4 :
- in import BTL correzione per FreeContour aperti con angoli di fianco non nulli.
2022-07-14 06:31:56 +02:00
DarioS 70354dd798 EgtExchange 2.4g3 :
- in import CNC migliorato controllo centro degli archi.
2022-07-08 20:14:33 +02:00
DarioS c59b85ba42 EgtExchange 2.4g2 :
- a BeamMgr aggiunta funzione GetSideData.
2022-07-06 17:44:23 +02:00
DarioS 41b595d798 EgtExchange 2.4g1 :
- in import BTL modifiche a gestione FrontSlot per cercare di evitare piccole facce o setti molto sottili legati a poca precisione del BTL.
2022-07-05 08:53:29 +02:00
DarioS 6a48bd6571 EgtExchange 2.4f5 :
- in import BTL corretta gestione RidgeValleyCut con una delle due facce larga meno di 2 mm.
2022-06-29 16:06:13 +02:00
DarioS 10e2c47a74 EgtExchange 2.4f4 :
- in import BTL feature disabilitate ora sono trasparenti
- in import CNC aggiunta gestione Fagor 8estensione PIM e centro archi).
2022-06-27 08:39:44 +02:00
DarioS 861837f0a6 EgtExchange 2.4f3 :
- in import CNC per Siemens si saltano CYCLE800 e CYCLE832.
2022-06-13 16:30:43 +02:00
DarioS 531d8d8d86 EgtExchange 2.4f2 :
- in import BTL corretto riconoscimento tipo inizio/fine di fori quando sono a cavallo dell'inizio o fine del pezzo.
2022-06-08 11:38:30 +02:00
DarioS ef13501017 EgtExchange 2.4f1 :
- in import BTL migliorata gestione testi vuoti o con soli spazi in Marcature.
2022-06-06 07:04:13 +02:00
DarioS bd3ebca16b EgtExchange 2.4e5 :
- in import BTL corretta gestione feature 3/4-016-X.
2022-05-27 17:07:44 +02:00
DarioS a75278074d EgtExchange 2.4e4 :
- modifiche per prima gestione chiave di rete.
2022-05-17 08:21:26 +02:00
DarioS acab9e3d3a EgtExchange 2.4e3 :
- ricompilazione con cambio versione.
2022-05-14 11:44:25 +02:00
DarioS ae463b4a12 EgtExchange :
- in import BTL facce di LapJoint se vicine ai vertici box (10*EPS_SMALL) ora passano esattamente per i vertici
- in import BTL corretta funzione AdjustPointForPlaneNearBoxVertex.
2022-05-04 23:59:34 +02:00
DarioS 700881d203 EgtExchange 2.4e2 :
- in import BTL aumentata a 10 EPS_SMALL la tolleranza di tutte le DoCompacting (per garantire facce attaccate).
2022-05-04 08:06:57 +02:00
SaraP 8adc82126a EgtExchange :
- in import 3MF correzione per gestire vertici coincidenti.
2022-05-03 10:15:59 +02:00
DarioS 799e2713f4 EgtExchange 2.4e1 :
- in import BTL migliorata gestione FreeContour e OutLine per angoli di fianco
- in import BTL migliorata gestione cancellazione pezzo con assemblato.
2022-05-01 17:56:17 +02:00
DarioS bc2f55efab EgtExchange 2.4d5 :
- corretta gestione FreeContour di gruppo 0 con flag pocket.
2022-04-30 11:07:45 +02:00
DarioS d3fd4bb971 EgtExchange2.4d4 :
- ricompilate versioni a 32bit con v141_xp (VisualStudio 2017 C++ per XP).
2022-04-24 17:08:58 +02:00
DarioS 7cd69e8e12 EgtExchange 2.4d3 :
- in import BTL corretta gestione FrontDtMortise di lunghezza risultante negativa.
2022-04-07 11:07:14 +02:00
DarioS bf05485e33 EgtExchange 2.4d2 :
- modifiche a ImportBtl e BeamMgr per gestione feature trimmate da Outline (flag 128).
2022-04-04 17:26:50 +02:00
DarioS 1b30112f73 EgtExchange 2.4d1 :
- in import BTL si aggiunge faccia di supporto a FrontSlot solo se necessaria
- in BeamMgr corretto calcolo solido con feature formata da più superfici che vanno unite.
2022-04-03 12:03:29 +02:00
DarioS f75335f199 EgtExchange 2.4c2 :
- in import BTL correzione Blockhaus Half Lap (4-037-X) senza primo scasso.
2022-03-24 08:53:57 +01:00
DarioS 367a4d2b47 EgtExchange 2.4c1 :
- in gestione Beam tolto frazionamento facce parallelepipedo per grezzo iniziale.
2022-03-14 09:00:43 +01:00
DarioS 3f99541786 EgtExchange 2.4b3 :
- in import BTL aggiunta gestione RawParts (grezzi per nesting) e Composites (per pareti a layer).
2022-02-27 16:23:30 +01:00
SaraP f41ddb84f0 EgtExchange 2.4b2 :
- migliorie in ImportBTLx.
2022-02-21 16:29:40 +01:00
SaraP 421206b316 EgtExchange :
- correzione errori in ImportBTLx.
2022-02-21 09:52:17 +01:00
DarioS 50fb53d335 EgtExchange 2.4b1 :
- in ImportBTL aggiunta gestione riferimenti su DovetailMortise.
2022-02-08 16:42:54 +01:00
DarioS f12f86ce64 EgtExchange :
- in import BTL differenziato errore nella sezione General da errore per mancanza di pezzi.
2022-01-26 12:52:49 +01:00
DarioS 630f81a755 EgtExchange 2.4a4 :
- in import BTL aggiunto controllo lunghezza massima tenoni standard e DT.
2022-01-25 10:40:14 +01:00
DarioS 9a9993bd5e EgtExchange 2.4a3 :
- in ImportBtl aggiunta gestione flag EIBFLAG_OUTL_FLAT_POS = 64 per pezzi orientati ocn outline in XY oppure piatti.
2022-01-18 11:35:54 +01:00
DarioS 3ea4693cbb EgtExchange :
- inserita opzione in compilazioni 64bit per evitare Warning su verifica riferimenti mnon nulli.
2022-01-09 15:48:54 +01:00
DarioS e71850dacc EgtExchange 2.4a2 :
- ricompilazione per cambio versione.
2022-01-07 09:52:52 +01:00
DarioS c44e28fafb EgtExchange 2.4a1 :
- ricompilazione per cambio versione.
2022-01-04 08:04:37 +01:00
DarioS cbd8863fc8 EgtExchange 2.3l2 :
- nell'import 3MF si utilizza direttamente l'indicizzazione dei vertici sui triangoli.
2021-12-23 20:06:56 +01:00
DarioS f2b922088a EgtExchange 2.3l1 :
- anche a ModifyProcess di BeamMgr aggiunti parametri nCrvId e nCrv2Id per FreeCont, Outline e Aperture
- correzioni varie.
2021-12-02 11:17:41 +01:00
DarioS e67025ded7 EgtExchange 2.3k7 :
- nuove funzioni per aggiunta FreeContour, Outline e Aperture da BeamMgr.
2021-12-01 10:10:54 +01:00
DarioS e4871ab7e8 EgtExchange 2.3k6 :
- in import BTL aggiunta gestione riferimento su fori e gestione foro nullo causa profondità.
2021-11-26 09:18:11 +01:00
DarioS 2f2203466d EgtExchange 2.3k5 :
- in import BTL migliorato controllo raggio fillet delle feature DoveTail (tenon, mortise e front mortise).
2021-11-22 23:21:40 +01:00
DarioS 63421ef658 EgtExchange 2.3k4 :
- in import BTL modificata gestione pocket di mortase DT (il contorno può uscire 30mm).
2021-11-10 07:01:22 +01:00
DarioS 48fe4050f7 EgtExchange 2.3k3 :
- in import BTL se si superano le 200 feature si rinuncia ad aggiornare l'outline con i fori.
2021-11-08 05:21:06 +01:00
DarioS d9973d09fe EgtExchange 2.3k2 :
- in import BTL lo stato di esecuzione (DO=0/1) ora viene propagato dalla feature alle sue geometrie aggiuntive.
2021-11-04 06:59:33 +01:00
32 changed files with 5116 additions and 662 deletions
+114 -20
View File
@@ -45,21 +45,31 @@ BeamMgr::BeamMgr( void)
bool
BeamMgr::Init( IGeomDB* pGDB, int nFlag)
{
// assegno il gestore di DB geometrico
if ( pGDB == nullptr)
return false ;
m_pGDB = pGDB ;
return SetFlag( nFlag) ;
}
//----------------------------------------------------------------------------
bool
BeamMgr::SetFlag( int nFlag)
{
// verifico il gestore di DB geometrico
if ( m_pGDB == nullptr)
return false ;
// inizializzo il gestore geometria pezzi Btl
int nFlatVertPos = 0 ;
if (( nFlag & EIBFLAG_TS3_POS) != 0)
if (( nFlag & EIBFLAG_OUTL_FLAT_POS) != 0)
nFlatVertPos = 4 ;
else if (( nFlag & EIBFLAG_TS3_POS) != 0)
nFlatVertPos = 3 ;
else if (( nFlag & EIBFLAG_FLAT_POS) != 0)
nFlatVertPos = 1 ;
else if (( nFlag & EIBFLAG_VERT_POS) != 0)
nFlatVertPos = 2 ;
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, bUseUAttr)) {
if ( ! m_BtlGeom.Init( m_pGDB, nFlatVertPos, bSpecialTrim, bTrimWithOutline, bUseUAttr)) {
LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init")
return false ;
}
@@ -164,10 +174,36 @@ BeamMgr::SetPartBox( double dLength, double dHeight, double dWidth, bool bUpdate
return true ;
}
//----------------------------------------------------------------------------
bool
BeamMgr::GetSideData( int nSide, Frame3d& frRef, double& dLength, double& dWidth, double& dHeight)
{
// Verifico validità GDB
if ( m_pGDB == nullptr)
return false ;
// Verifico validità identificativo di faccia
if ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_RIGHT)
return false ;
// Recupero riferimento del pezzo corrente
int nPartId = m_BtlGeom.GetCurrPartId() ;
Frame3d frPart ;
if ( ! m_pGDB->GetGroupGlobFrame( nPartId, frPart))
return false ;
// Recupero i dati
frRef = m_BtlGeom.GetSideFrame( nSide) ;
frRef.ToGlob( frPart) ;
dLength = m_BtlGeom.GetSideLength( nSide) ;
dWidth = m_BtlGeom.GetSideWidth( nSide) ;
dHeight = m_BtlGeom.GetSideHeight( nSide) ;
return true ;
}
//----------------------------------------------------------------------------
int
BeamMgr::AddProcess( int nGroup, int nProc, int nSide, const string& sDes, int nProcId,
const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt, bool bUpdate)
const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt,
int nCrvId, int nCrv2Id, bool bUpdate)
{
// Verifico validità GDB
if ( m_pGDB == nullptr)
@@ -186,9 +222,26 @@ BeamMgr::AddProcess( int nGroup, int nProc, int nSide, const string& sDes, int n
vdBtlPar[i] = vdPar[j-1] ;
}
sBtlPar = sPar ;
// Aggiungo la feature
if ( ! m_BtlGeom.AddProcess( nGroup, nProc, nSide, sDes, nProcId,frRef, vnDPar, nSPar, vdBtlPar, sBtlPar, vsUAtt, 0))
return GDB_ID_NULL ;
// Gestione speciale per FreeContour
if ( nProc == 250) {
if ( ! m_BtlGeom.AddOneFreeContour( nGroup, nProc, nSide, sDes, nProcId, frRef, vnDPar, vdBtlPar, vsUAtt, nCrvId, nCrv2Id))
return GDB_ID_NULL ;
}
// gestione speciale per Outline
else if ( nProc == 251) {
if ( ! m_BtlGeom.AddPartOutline( nSide, nCrvId, vdBtlPar, vsUAtt))
return GDB_ID_NULL ;
}
// gestione speciale per Aperture
else if ( nProc == 252) {
if ( ! m_BtlGeom.AddPartAperture( nSide, nCrvId, vdBtlPar, vsUAtt))
return GDB_ID_NULL ;
}
// altrimenti Add standard
else {
if ( ! m_BtlGeom.AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vnDPar, nSPar, vdBtlPar, sBtlPar, vsUAtt, 0))
return GDB_ID_NULL ;
}
// Se richiesto, aggiorno Outline e cancello Solido
if ( bUpdate) {
m_BtlGeom.UpdateOutLine() ;
@@ -201,7 +254,8 @@ BeamMgr::AddProcess( int nGroup, int nProc, int nSide, const string& sDes, int n
//----------------------------------------------------------------------------
int
BeamMgr::ModifyProcess( int nGeomId, int nGroup, int nProc, int nSide, const string& sDes, int nProcId,
const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt, bool bUpdate)
const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt,
int nCrvId, int nCrv2Id, bool bUpdate)
{
// Verifico validità GDB
if ( m_pGDB == nullptr)
@@ -209,10 +263,11 @@ BeamMgr::ModifyProcess( int nGeomId, int nGroup, int nProc, int nSide, const str
// Recupero il pezzo di appartenenza
int nLayId = m_pGDB->GetParentId( nGeomId) ;
int nPartId = m_pGDB->GetParentId( nLayId) ;
if ( ! m_BtlGeom.SetPart( nPartId) || m_BtlGeom.GetCurrProcsLayId() != nLayId)
// accetto feature normali e Outline/Aperture
if ( ! m_BtlGeom.SetPart( nPartId) || ( m_BtlGeom.GetCurrProcsLayId() != nLayId && m_BtlGeom.GetCurrOutsLayId() != nLayId))
return GDB_ID_NULL ;
// Aggiungo il nuovo processo modificato
int nNewId = AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vdPar, sPar, vsUAtt, false) ;
int nNewId = AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vdPar, sPar, vsUAtt, nCrvId, nCrv2Id, false) ;
if ( nNewId == GDB_ID_NULL)
return GDB_ID_NULL ;
// Sposto le geometrie inserite appena sopra le vecchie (mantenendo l'ordine relativo nel gruppo)
@@ -257,7 +312,8 @@ BeamMgr::EraseProcess( int nGeomId, bool bUpdate)
// Recupero il pezzo di appartenenza
int nLayId = m_pGDB->GetParentId( nGeomId) ;
int nPartId = m_pGDB->GetParentId( nLayId) ;
if ( ! m_BtlGeom.SetPart( nPartId) || m_BtlGeom.GetCurrProcsLayId() != nLayId)
// accetto feature normali e Outline/Aperture
if ( ! m_BtlGeom.SetPart( nPartId) || ( m_BtlGeom.GetCurrProcsLayId() != nLayId && m_BtlGeom.GetCurrOutsLayId() != nLayId))
return false ;
// Cancello eventuali geometrie aggiuntive
INTVECTOR vAdj ;
@@ -271,6 +327,18 @@ BeamMgr::EraseProcess( int nGeomId, bool bUpdate)
for ( auto nAux : vAux)
m_pGDB->Erase( nGeomId + nAux) ;
}
// Cancello eventuali geometrie originali
INTVECTOR vOrig ;
if ( m_pGDB->GetInfo( nGeomId, IKEY_ORIGID, vOrig) && ! vOrig.empty()) {
for ( auto nOrig : vOrig) {
INTVECTOR vAux ;
if ( m_pGDB->GetInfo( nOrig, IKEY_AUXID, vAux) && ! vAux.empty()) {
for ( auto nAux : vAux)
m_pGDB->Erase( nOrig + nAux) ;
}
m_pGDB->Erase( nGeomId + nOrig) ;
}
}
m_pGDB->Erase( nGeomId) ;
// Se richiesto, aggiorno Outline e cancello Solido
if ( bUpdate) {
@@ -319,6 +387,13 @@ BeamMgr::EnableProcess( int nGeomId, bool bEnable, bool bUpdate)
for ( auto nAdj : vAdj)
MyEnableProcess( m_pGDB, m_BtlGeom, nGeomId + nAdj, bEnable) ;
}
// Aggiorno eventuali geometrie originali
INTVECTOR vOrig ;
if ( m_pGDB->GetInfo( nGeomId, IKEY_ORIGID, vOrig) && ! vOrig.empty()) {
for ( auto nOrig : vOrig) {
MyEnableProcess( m_pGDB, m_BtlGeom, nGeomId + nOrig, bEnable) ;
}
}
// Se richiesto, aggiorno Outline e cancello Solido
if ( bUpdate) {
m_BtlGeom.UpdateOutLine() ;
@@ -425,7 +500,7 @@ BeamMgr::CalcSolid( int nPartId, bool bRecalc)
Point3d ptMin ; double dDimX, dDimY, dDimz ;
if ( ! b3Box.GetMinDim( ptMin, dDimX, dDimY, dDimz))
return false ;
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshBox( dDimX, dDimY, dDimz, true)) ;
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshBox( dDimX, dDimY, dDimz, false)) ;
if ( IsNull( pSTM))
return false ;
pSTM->Translate( ptMin - ORIG) ;
@@ -478,12 +553,31 @@ 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) {
const ISurfTriMesh* pStmProc = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcId)) ;
PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pStmProc, dStep)) ;
if ( ! IsNull( pStmTmp))
pStmProc = Get( pStmTmp) ;
if ( pStmProc == nullptr || ! pStm->Intersect( *pStmProc))
return false ;
if ( nTrim == 2) {
int nAux ;
if ( m_pGDB->GetInfo( nProcId, IKEY_AUXID, nAux)) {
const ISurfTriMesh* pStmProc = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcId)) ;
const ISurfTriMesh* pAux = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcId + 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 ;
}
}
}
else {
const ISurfTriMesh* pStmProc = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcId)) ;
PtrOwner<ISurfTriMesh> pStmTmp( RegularizeTriMesh( pStmProc, dStep)) ;
if ( ! IsNull( pStmTmp))
pStmProc = Get( pStmTmp) ;
if ( pStmProc == nullptr || ! pStm->Intersect( *pStmProc))
return false ;
}
}
nProcId = m_pGDB->GetNext( nProcId) ;
}
+6 -2
View File
@@ -21,6 +21,7 @@ class BeamMgr : public IBeamMgr
{
public :
bool Init( IGeomDB* pGDB, int nFlag = 0) override ;
bool SetFlag( int nFlag) override ;
int CreatePart( void) override ;
bool SetPart( int nPartId) override ;
bool ErasePart( void) override ;
@@ -29,10 +30,13 @@ class BeamMgr : public IBeamMgr
bool SetPartName( const std::string& sName) override ;
bool SetPartCount( int nCount) override ;
bool SetPartBox( double dLength, double dHeight, double dWidth, bool bUpdate = true) override ;
bool GetSideData( int nSide, Frame3d& frRef, double& dLength, double& dWidth, double& dHeight) override ;
int AddProcess( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const Frame3d& frRef, const DBLVECTOR& vdPar, const std::string& sPar, const STRVECTOR& vsUAtt, bool bUpdate = true) override ;
const Frame3d& frRef, const DBLVECTOR& vdPar, const std::string& sPar, const STRVECTOR& vsUAtt,
int nCrvId, int nCrv2Id, bool bUpdate = true) override ;
int ModifyProcess( int nGeomId, int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const Frame3d& frRef, const DBLVECTOR& vdPar, const std::string& sPar, const STRVECTOR& vsUAtt, bool bUpdate = true) override ;
const Frame3d& frRef, const DBLVECTOR& vdPar, const std::string& sPar, const STRVECTOR& vsUAtt,
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 CalcSolid( int nPartId, bool bRecalc = false) override ;
+3
View File
@@ -146,6 +146,7 @@ enum nPartKey {
KEY_PART_STOREYTYPE,
KEY_PART_TIMBERGRADE,
KEY_PART_TRANSFORMATION,
KEY_PART_TYPE,
KEY_PART_UID,
KEY_PART_USERATTRIBUTE,
KEY_PART_WIDTH,
@@ -186,6 +187,7 @@ static const std::array<std::string,KEY_PART_ZZZ> sPartKey = {
"STOREYTYPE",
"TIMBERGRADE",
"TRANSFORMATION",
"TYPE",
"UID",
"USERATTRIBUTE",
"WIDTH"
@@ -253,3 +255,4 @@ static const std::string PAR_YZ = "YZ" ;
static const std::string PAR_PROCESS = "PROCESS" ;
static const std::string PAR_SIDE = "SIDE" ;
static const std::string PAR_P = "P" ;
static const std::string PAR_UID = "UID" ;
+254 -12
View File
@@ -24,6 +24,7 @@
#include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <unordered_map>
using namespace std ;
@@ -34,17 +35,20 @@ string BtlGeom::m_sBtlAuxDir ;
BtlGeom::BtlGeom( void)
{
m_pGDB = nullptr ;
m_nFlatVertPos = false ;
m_nFlatVertPos = 0 ;
m_bSpecialTrim = false ;
m_bTrimWithOutline = false ;
m_bUseUAttr = false ;
m_BoxCol = Color( 255, 128, 0, 15) ;
m_OutsCol = Color( 224, 128, 0, 50) ;
m_ProcsCol = Color( 80, 160, 160, 100) ;
m_ProcsOffCol = Color( 160, 160, 160, 100) ;
m_ProcsOffCol = Color( 160, 160, 160, 15) ;
m_MarkCol = Color( 96, 192, 192, 100) ;
m_SolidCol = Color(255, 160, 32, 100) ;
m_nInfoId = GDB_ID_NULL ;
m_nAsseId = GDB_ID_NULL ;
m_nRawPartsId = GDB_ID_NULL ;
m_nCompositesId = GDB_ID_NULL ;
m_ptOrig = ORIG ;
m_nPartId = GDB_ID_NULL ;
m_nAuxId = GDB_ID_NULL ;
@@ -58,7 +62,7 @@ BtlGeom::BtlGeom( void)
//----------------------------------------------------------------------------
bool
BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bUseUAttr)
BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bTrimWithOutline, bool bUseUAttr)
{
// salvo puntatore a DB geometrico
m_pGDB = pGDB ;
@@ -67,6 +71,7 @@ BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bUseUAtt
// salvo i flag
m_nFlatVertPos = nFlatVertPos ;
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) ;
@@ -76,6 +81,9 @@ BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bUseUAtt
m_nAsseId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ;
if ( m_nAsseId == GDB_ID_NULL && ! 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) ;
return true ;
}
@@ -239,6 +247,17 @@ BtlGeom::ErasePart( void)
// se non c'è il DB geometrico o il pezzo corrente, errore
if ( m_pGDB == nullptr || m_nPartId == GDB_ID_NULL)
return false ;
// rimuovo eventuali riferimenti e copie nell'assemblato
int nAsseBaseRefId = GDB_ID_NULL ;
if ( m_pGDB->GetInfo( m_nPartId, GDB_SI_LIST, nAsseBaseRefId)) {
m_pGDB->Erase( nAsseBaseRefId) ;
int nInd = 1 ;
int nSouPartId = GDB_ID_NULL ;
while ( m_pGDB->GetInfo( nAsseBaseRefId + nInd, GDB_SI_SOURCE, nSouPartId) && nSouPartId == m_nPartId) {
m_pGDB->Erase( nAsseBaseRefId + nInd) ;
++ nInd ;
}
}
// cancello il pezzo
m_pGDB->Erase( m_nPartId) ;
// annullo tutti gli identificativi del pezzo
@@ -357,6 +376,7 @@ BtlGeom::AddPartBox( double dLength, double dHeight, double dWidth)
m_ptOrig.y += dHeight + PART_OFFSET ;
break ;
case 1 :
case 4 :
m_ptOrig.y += max( dHeight, dWidth) + PART_OFFSET ;
break ;
case 2 :
@@ -382,7 +402,7 @@ BtlGeom::AddPartBox( double dLength, double dHeight, double dWidth)
if ( IsNull( pText))
return false ;
int nSide = BTL_SIDE_TOP ;
if ( m_nFlatVertPos == 1 && m_vtDim.z > m_vtDim.y + EPS_SMALL)
if (( m_nFlatVertPos == 1 || m_nFlatVertPos == 4) && m_vtDim.z > m_vtDim.y + EPS_SMALL)
nSide = BTL_SIDE_FRONT ;
else if ( m_nFlatVertPos == 2 && m_vtDim.y < m_vtDim.z + EPS_SMALL)
nSide = BTL_SIDE_FRONT ;
@@ -442,7 +462,7 @@ BtlGeom::AdjustPartFlatOrVertPos( void)
// dimensioni pezzo
Vector3d vtDim = b3Part.GetMax() - b3Part.GetMin() ;
// se richiesto piatto ed è in verticale, ruoto
if ( m_nFlatVertPos == 1 && vtDim.z > vtDim.y + EPS_SMALL) {
if (( m_nFlatVertPos == 1 || m_nFlatVertPos == 4) && vtDim.z > vtDim.y + EPS_SMALL) {
Point3d ptAx = b3Part.GetMin() + 0.5 * Vector3d( 0, vtDim.y, vtDim.y) ;
m_pGDB->RotateGlob( m_nPartId, ptAx, X_AX, 0, -1) ;
}
@@ -515,7 +535,24 @@ BtlGeom::AddPartTransformation( const string& sUID, const Frame3d& frRef)
// assegno Nome con UID
m_pGDB->SetName( nId, "UID-" + sUID) ;
// assegno Id pezzo istanziato
m_pGDB->SetInfo( nId, "!SOU", m_nPartId) ;
m_pGDB->SetInfo( nId, GDB_SI_SOURCE, m_nPartId) ;
// nascondo e blocco
m_pGDB->SetStatus( nId, GDB_ST_OFF) ;
m_pGDB->SetMode( nId, GDB_MD_LOCKED) ;
return true ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::AddObjectRef( const string& sUID, const Frame3d& frRef)
{
// creo un nuovo gruppo nel pezzo
int nId = m_pGDB->AddGroup( GDB_ID_NULL, m_nPartId, frRef) ;
if ( nId == GDB_ID_NULL)
return false ;
// assegno Nome con UID
m_pGDB->SetName( nId, "UID-" + sUID) ;
// non posso ancora assegnare Id pezzo istanziato
// nascondo e blocco
m_pGDB->SetStatus( nId, GDB_ST_OFF) ;
m_pGDB->SetMode( nId, GDB_MD_LOCKED) ;
@@ -752,22 +789,30 @@ BtlGeom::SetAlpha( int nId, int nAlpha)
Color cCol ;
if ( ! m_pGDB->GetCalcMaterial( nId, cCol))
return false ;
if ( nAlpha < ALPHA_LIM)
m_pGDB->SetInfo( nId, IKEY_COL_A, nAlpha) ;
else
m_pGDB->RemoveInfo( nId, IKEY_COL_A) ;
cCol.SetAlpha( nAlpha) ;
return m_pGDB->SetMaterial( nId, cCol) ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::SortParts( void)
BtlGeom::SortObjects( int nGroupId, Point3d& ptIns)
{
// verifico gruppo
if ( nGroupId == GDB_ID_NULL || ! m_pGDB->ExistsObj( nGroupId))
return true ;
// tabella Id-SN dei pezzi
INTINTVECTOR vIdSN ;
// recupero il numero di serie di ogni singolo pezzo
int nPartId = m_pGDB->GetFirstGroupInGroup( GDB_ID_ROOT) ;
int nPartId = m_pGDB->GetFirstGroupInGroup( nGroupId) ;
while ( nPartId != GDB_ID_NULL) {
int nLev ;
if ( m_pGDB->GetCalcLevel( nPartId, nLev) && nLev == GDB_LV_USER) {
if ( m_pGDB->GetCalcLevel( nPartId, nLev) && ( nLev == GDB_LV_USER || nGroupId != GDB_ID_ROOT)) {
int nSN = 0 ;
m_pGDB->GetInfo( nPartId, IKEY_PROD_NBR, nSN) ;
vIdSN.emplace_back( nPartId, nSN) ;
@@ -780,14 +825,13 @@ BtlGeom::SortParts( void)
{ return a.second < b.second ; }) ;
// cambio posizione dei pezzi nel DB come da ordine in tabella
Point3d ptIns ;
for ( int i = 0 ; i < int( vIdSN.size()) ; ++ i) {
m_pGDB->Relocate( vIdSN[i].first, GDB_ID_ROOT, GDB_LAST_SON) ;
m_pGDB->Relocate( vIdSN[i].first, nGroupId, GDB_LAST_SON) ;
BBox3d b3Part ;
int nBoxId = m_pGDB->GetFirstNameInGroup( vIdSN[i].first, BOX_LAYER_NAME) ;
m_pGDB->GetGlobalBBox( nBoxId, b3Part) ;
m_pGDB->Translate( vIdSN[i].first, ptIns - b3Part.GetMin()) ;
ptIns += Vector3d( 0, b3Part.GetMax().y - b3Part.GetMin().y + 300, 0) ;
ptIns += Vector3d( 0, b3Part.GetMax().y - b3Part.GetMin().y + PART_OFFSET, 0) ;
}
return true ;
@@ -830,3 +874,201 @@ BtlGeom::UpdateNextOrigin( void)
return true ;
}
//----------------------------------------------------------------------------
int
BtlGeom::GetRawPartsGroup( bool bCreate)
{
// se non necessaria creazione ritorno quello che trovo
if ( ! bCreate || m_nRawPartsId != GDB_ID_NULL)
return m_nRawPartsId ;
// creo il gruppo
CreateRawPartsGroup() ;
return m_nRawPartsId ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::CreateRawPartsGroup( void)
{
// se già definito, non faccio alcunchè
m_nRawPartsId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, RAWPARTS_GROUP_NAME) ;
if ( m_nRawPartsId != GDB_ID_NULL)
return true ;
// creo il gruppo sotto la radice
m_nRawPartsId = m_pGDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
if ( m_nRawPartsId == GDB_ID_NULL)
return false ;
// assegno livello di sistema
m_pGDB->SetLevel( m_nRawPartsId, GDB_LV_SYSTEM) ;
// assegno nome
m_pGDB->SetName( m_nRawPartsId, RAWPARTS_GROUP_NAME) ;
return true ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::AdjustRawPart( int nRawPartId)
{
// verifico validità pezzo
if ( nRawPartId == GDB_ID_NULL || ! m_pGDB->ExistsObj( nRawPartId))
return false ;
// cerco il gruppo dei grezzi in cui spostarlo
int nRpsGroupId = GetRawPartsGroup( true) ;
if ( nRpsGroupId == GDB_ID_NULL)
return false ;
// lo sposto e lo nascondo
return m_pGDB->Relocate( nRawPartId, nRpsGroupId) && m_pGDB->SetStatus( nRawPartId, GDB_ST_OFF) ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::AdjustRefForRawParts( void)
{
// verifico esistenza gruppo dei grezzi
int nRpsGroupId = GetRawPartsGroup() ;
if ( nRpsGroupId == GDB_ID_NULL)
return true ;
// tabella Id-UID dei pezzi
std::unordered_map< int, int> umUIDId ;
int nPartId = m_pGDB->GetFirstGroupInGroup( GDB_ID_ROOT) ;
while ( nPartId != GDB_ID_NULL) {
int nLev ;
if ( m_pGDB->GetCalcLevel( nPartId, nLev) && nLev == GDB_LV_USER) {
for ( int i = 1 ; ; ++ i) {
int nUID ;
string sUIDKey = "UID" + ToString( i) ;
if ( ! m_pGDB->GetInfo( nPartId, sUIDKey, nUID))
break ;
umUIDId.emplace( nUID, nPartId) ;
}
}
nPartId = m_pGDB->GetNextGroup( nPartId) ;
}
// assegno riferimenti nei grezzi
int nRawPartId = m_pGDB->GetFirstGroupInGroup( nRpsGroupId) ;
while ( nRawPartId != GDB_ID_NULL) {
int nRefId = m_pGDB->GetFirstNameInGroup( nRawPartId, "UID-*") ;
while ( nRefId != GDB_ID_NULL) {
string sName ; m_pGDB->GetName( nRefId, sName) ;
int nUID ;
if ( FromString( sName.substr( 4), nUID)) {
auto Iter = umUIDId.find( nUID) ;
if ( Iter != umUIDId.end())
m_pGDB->SetInfo( nRefId, GDB_SI_SOURCE, Iter->second) ;
}
nRefId = m_pGDB->GetNextName( nRefId, "UID-*") ;
}
nRawPartId = m_pGDB->GetNextGroup( nRawPartId) ;
}
return true ;
}
//----------------------------------------------------------------------------
int
BtlGeom::GetCompositesGroup( bool bCreate)
{
// se non necessaria creazione ritorno quello che trovo
if ( ! bCreate || m_nCompositesId != GDB_ID_NULL)
return m_nCompositesId ;
// creo il gruppo
CreateCompositesGroup() ;
return m_nCompositesId ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::CreateCompositesGroup( void)
{
// se già definito, non faccio alcunchè
m_nCompositesId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, COMPOSITES_GROUP_NAME) ;
if ( m_nCompositesId != GDB_ID_NULL)
return true ;
// creo il gruppo sotto la radice
m_nCompositesId = m_pGDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
if ( m_nCompositesId == GDB_ID_NULL)
return false ;
// assegno livello di sistema
m_pGDB->SetLevel( m_nCompositesId, GDB_LV_SYSTEM) ;
// assegno nome
m_pGDB->SetName( m_nCompositesId, COMPOSITES_GROUP_NAME) ;
return true ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::AdjustComposite( int nCompositeId)
{
// verifico validità pezzo
if ( nCompositeId == GDB_ID_NULL || ! m_pGDB->ExistsObj( nCompositeId))
return false ;
// cerco il gruppo dei compositi in cui spostarlo
int nCmpGroupId = GetCompositesGroup( true) ;
if ( nCmpGroupId == GDB_ID_NULL)
return false ;
// lo sposto e lo nascondo
return m_pGDB->Relocate( nCompositeId, nCmpGroupId) && m_pGDB->SetStatus( nCompositeId, GDB_ST_OFF) ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::AdjustRefForComposites( void)
{
// verifico esistenza gruppo dei compositi
int nCmpsGroupId = GetCompositesGroup() ;
if ( nCmpsGroupId == GDB_ID_NULL)
return true ;
// tabella Id-UID dei pezzi e dei compositi
std::unordered_map< int, int> umUIDId ;
int nPartId = m_pGDB->GetFirstGroupInGroup( GDB_ID_ROOT) ;
while ( nPartId != GDB_ID_NULL) {
int nLev ;
if ( m_pGDB->GetCalcLevel( nPartId, nLev) && nLev == GDB_LV_USER) {
for ( int i = 1 ; ; ++ i) {
int nUID ;
string sUIDKey = "UID" + ToString( i) ;
if ( ! m_pGDB->GetInfo( nPartId, sUIDKey, nUID))
break ;
umUIDId.emplace( nUID, nPartId) ;
}
}
nPartId = m_pGDB->GetNextGroup( nPartId) ;
}
int nCompoId = m_pGDB->GetFirstGroupInGroup( nCmpsGroupId) ;
while ( nCompoId != GDB_ID_NULL) {
int nLev ;
if ( m_pGDB->GetCalcLevel( nCompoId, nLev) && nLev != GDB_LV_USER) {
for ( int i = 1 ; ; ++ i) {
int nUID ;
string sUIDKey = "UID" + ToString( i) ;
if ( ! m_pGDB->GetInfo( nCompoId, sUIDKey, nUID))
break ;
umUIDId.emplace( nUID, nCompoId) ;
}
}
nCompoId = m_pGDB->GetNextGroup( nCompoId) ;
}
// assegno riferimenti nei compositi
int nCompositeId = m_pGDB->GetFirstGroupInGroup( nCmpsGroupId) ;
while ( nCompositeId != GDB_ID_NULL) {
int nRefId = m_pGDB->GetFirstNameInGroup( nCompositeId, "UID-*") ;
while ( nRefId != GDB_ID_NULL) {
string sName ; m_pGDB->GetName( nRefId, sName) ;
int nUID ;
if ( FromString( sName.substr( 4), nUID)) {
auto Iter = umUIDId.find( nUID) ;
if ( Iter != umUIDId.end())
m_pGDB->SetInfo( nRefId, GDB_SI_SOURCE, Iter->second) ;
}
nRefId = m_pGDB->GetNextName( nRefId, "UID-*") ;
}
nCompositeId = m_pGDB->GetNextGroup( nCompositeId) ;
}
return true ;
}
+42 -20
View File
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2022
//----------------------------------------------------------------------------
// File : BtlGeom.h Data : 26.08.15 Versione : 1.6h5
// File : BtlGeom.h Data : 04.04.22 Versione : 2.4d25
// Contenuto : Dichiarazione della classe BtlGeom.
//
//
//
// Modifiche : 26.08.15 DS Creazione modulo.
//
// 04.04.22 DS Aggiunta gestione trim feature con outline.
//
//----------------------------------------------------------------------------
@@ -26,7 +26,7 @@ class BtlGeom
BtlGeom( void) ;
public :
bool Init( IGeomDB* pGDB, int nFlatPos, bool bSpecialTrim, bool bUseUAttr) ;
bool Init( IGeomDB* pGDB, int nFlatPos, bool bSpecialTrim, bool bTrimWithOutline, bool bUseUAttr) ;
bool CreatePart( void) ;
bool SetPart( int nPartId) ;
bool ErasePart( void) ;
@@ -47,48 +47,53 @@ class BtlGeom
double GetCurrPartWidth( void)
{ return ( m_nPartId != GDB_ID_NULL ? m_vtDim.y : 0) ;}
bool AddPartTransformation( const std::string& sUID, const Frame3d& frRef) ;
bool AddObjectRef( const std::string& sUID, const Frame3d& frRef) ;
bool AdjustPartFlatOrVertPos( void) ;
bool ResetPartSolid( void) ;
std::string GetPartName( void) ;
bool SetUserAttribute( int nUAttrDest, const std::string& sString) ;
bool SetUserAttribute( int nUAttrDest, const std::string& sKey, const std::string& sVal) ;
bool SortParts( void) ;
bool SortObjects( int nGroupId, Point3d& ptIns) ;
bool UpdateNextOrigin( void) ;
int GetRawPartsGroup( bool bCreate = false) ;
bool AdjustRawPart( int nRawPartId) ;
bool AdjustRefForRawParts( void) ;
int GetCompositesGroup( bool bCreate = false) ;
bool AdjustComposite( int nCompositeId) ;
bool AdjustRefForComposites( void) ;
public : // Outline
bool AddPartOutline( int nSide, const FCEDEQUE& dqFce, int nContType, int nContData, double dContPar, const STRVECTOR& vsUAtt) ;
bool AddPartOutline( int nSide, int nCrvId, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddPartAperture( int nSide, const FCEDEQUE& dqFce, int nContType, int nContData, double dContPar, const STRVECTOR& vsUAtt) ;
bool AddPartAperture( int nSide, int nCrvId, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool UpdateOutLine( void) ;
bool AddPartStdOutline( void) ;
bool AddPartCustomOutline( void) ;
bool TrimOutlineWithApertures( void) ;
bool TrimOutlineWithProcesses( void) ;
bool TrimProcessWithOutline( int nProcId) ;
public : // Proc
bool GetProcessParamInfos( int nGroup, int nProc, int nSide,
INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar) const ;
bool AddProcess( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, const Frame3d& frRef,
const INTVECTOR& vnDPar, int nSPar, const DBLVECTOR& vdPar, const std::string& sPar, const STRVECTOR& vsUAtt, int nLine) ;
bool AddOneFreeContour( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, const Frame3d& frRef,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt, int nCrvId, int nCrv2Id) ;
int GetLastProcessId( void) { return m_nProcId ; }
bool CreateFreeContours( void) ;
bool SetProcessColor( int nId, bool bEnable) ;
public : // Proc BTLx
bool AddTenonBTLX( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
const INTVECTOR& vnDPar, DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddDovetailTenonBTLX( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddShapeBTLX( std::vector<INTVECTOR> vFacesVertices, std::vector<Point3d> vPoints) ;
const INTVECTOR& vnDPar, DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints) ;
private :
bool CreateInfoGroup( void) ;
bool CreateAssemblyGroup( void) ;
bool ReadUserAttribute( const std::string& sString, std::string& sKey, std::string& sVal) ;
public : // Data
bool IsTrueSide( int nSide) const ; // esclude gli estremi (RIGHT e LEFT)
std::string GetOutlineOutName( int nSide) const ;
std::string GetOutlineApertureName( int nSide) const ;
std::string GetOutlineTopName( int nSide) const ;
std::string GetOutlineBottomName( int nSide) const ;
double GetSideLength( int nSide) const ;
double GetSideWidth( int nSide) const ;
double GetSideHeight( int nSide) const ;
@@ -96,6 +101,17 @@ class BtlGeom
Plane3d GetSidePlane( int nSide) const ;
Vector3d GetSideVersN( int nSide) const ;
int GetOppositeSide( int nSide) const ;
private :
bool CreateInfoGroup( void) ;
bool CreateAssemblyGroup( void) ;
bool CreateRawPartsGroup( void) ;
bool CreateCompositesGroup( void) ;
bool ReadUserAttribute( const std::string& sString, std::string& sKey, std::string& sVal) ;
std::string GetOutlineOutName( int nSide) const ;
std::string GetOutlineApertureName( int nSide) const ;
std::string GetOutlineTopName( int nSide) const ;
std::string GetOutlineBottomName( int nSide) const ;
bool SetAlpha( int nId, int nAlpha) ;
private : // Outline
@@ -153,7 +169,7 @@ class BtlGeom
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddPocket( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, const Frame3d& frRef,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddDrill( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
bool AddDrill( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, const Frame3d& frRef,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddTenon( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
@@ -163,7 +179,7 @@ class BtlGeom
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddDovetailTenon( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddDovetailMortise( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
bool AddDovetailMortise( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, const Frame3d& frRef,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddDtMortiseFront( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
@@ -179,6 +195,8 @@ class BtlGeom
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddStepJointNotch( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddPlaning( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddProfileFront( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddProfileHeadCoCo( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
@@ -199,10 +217,11 @@ 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) ;
ICurveComposite* GetFreeContourCurve( int nProcId, const Frame3d& frRef) ;
ICurveComposite* GetFreeContourCurve( int nProcId, const Frame3d& frRef, bool bOnlyStartOk = false) ;
ISurfTriMesh* CreateOneCurveFreeContour( const ICurveComposite* pCrvCompo) ;
bool AdjustFreeContourCurve( ICurve* pCrv, int nSide, bool& bClosed, bool& bEndsOnCont) ;
bool VerifyFreeContourCurveSideAng( const ICurveComposite* pCrvCompo) ;
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) ;
@@ -240,8 +259,9 @@ class BtlGeom
private :
IGeomDB* m_pGDB ;
int m_nFlatVertPos ; // flag per posizionamento pezzi (0=come sono, 1=di piatto, 2=in verticale)
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
Color m_BoxCol ; // colore per box pezzi
Color m_OutsCol ; // colore per outline pezzi
@@ -251,6 +271,8 @@ class BtlGeom
Color m_SolidCol ; // colore per il solido
int m_nInfoId ; // identificativo gruppo per informazioni varie
int m_nAsseId ; // identificativo gruppo per trasformazioni di assemblaggio
int m_nRawPartsId ; // identificativo gruppo dei grezzi
int m_nCompositesId ; // identificativo gruppo dei compositi
Point3d m_ptOrig ; // origine di inserimento del prossimo pezzo
int m_nPartId ; // identificativo del pezzo corrente
int m_nAuxId ; // identificativo del layer aux del pezzo corrente
+16 -2
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2022
//----------------------------------------------------------------------------
// File : BtlGeomCoStru.h Data : 25.08.15 Versione : 1.6h5
// File : BtlGeomCoStru.h Data : 27.02.22 Versione : 2.4b3
// Contenuto : Costanti e strutture per la classe BtlGeom.
//
//
@@ -22,6 +22,10 @@
static const std::string INFO_GROUP_NAME = "BtlInfo" ;
// nome gruppo di sistema per riferimenti di definizione assemblaggio
static const std::string ASSEMBLY_GROUP_NAME = "AsseBase" ;
// nome gruppo di sistema per grezzi
static const std::string RAWPARTS_GROUP_NAME = "RawParts" ;
// nome gruppo di sistema per compositi
static const std::string COMPOSITES_GROUP_NAME = "Composites" ;
// nomi layer standard dei pezzi
static const std::string AUX_LAYER_NAME = "Part" ;
static const std::string BOX_LAYER_NAME = "Box" ;
@@ -60,8 +64,11 @@ static const std::string IKEY_FRAME = "FRAME" ;
static const std::string IKEY_MAINID = "MAINID" ;
static const std::string IKEY_ADJID = "ADJID" ;
static const std::string IKEY_AUXID = "AUXID" ;
static const std::string IKEY_ORIGID = "ORIGID" ;
static const std::string IKEY_START_FACE = "FCS" ;
static const std::string IKEY_END_FACE = "FCE" ;
static const std::string IKEY_SIDEANGS = "SideAngs" ;
static const std::string IKEY_DEPTH = "DEPTH" ;
static const std::string IKEY_POCKET = "PCKT" ;
static const std::string IKEY_RULED = "RULED" ;
static const std::string IKEY_CNT_TYPE = "CNT_TYPE" ;
@@ -70,6 +77,7 @@ static const std::string IKEY_CNT_PAR = "CNT_PAR" ;
static const std::string IKEY_TASKID = "TASKID" ;
static const std::string IKEY_DO = "DO" ;
static const std::string IKEY_TRIM = "TRIM" ;
static const std::string IKEY_COL_A = "COL_A" ;
// chiavi di informazioni associate al solido
static const std::string IKEY_VALID = "VALID" ;
// distanza tra pezzi nella disposizione standard lungo Y
@@ -100,12 +108,18 @@ const double DTMORT_EXTRA_LEN = 10.0 ;
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 ;
// angolo di fianco per contorno libero default e non definito
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 ;
//----------------------------------------------------------------------------
// Numero processo speciale Riferimento ad altro oggetto
const int BTL_OBJECT_REF = 300 ;
//----------------------------------------------------------------------------
// Base del nome file geometria varianti
static const std::string VARIANT_BASENAME = "Variant_" ;
+435 -28
View File
@@ -77,8 +77,164 @@ BtlGeom::AddPartOutline( int nSide, const FCEDEQUE& dqFce, int nContType, int nC
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ;
if ( nId == GDB_ID_NULL)
return false ;
// recupero eventuali angoli di fianco
DBLVECTOR vSideAng ;
if ( VerifyFreeContourCurveSideAng( pCrvCompo))
GetFreeContourCurveSideAngles( pCrvCompo, vSideAng) ;
// inserisco la curva nel DB geometrico
int nTId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pCrvCompo)) ;
if ( nTId != GDB_ID_NULL && vSideAng.size() > 0)
m_pGDB->SetInfo( nTId, IKEY_SIDEANGS, vSideAng) ;
// colore
Color cCol = m_ProcsCol ;
m_pGDB->SetMaterial( nId, cCol) ;
m_pGDB->SetMaterial( nTId, cCol) ;
// nome
m_pGDB->SetName( nId, GetOutlineOutName( nSide)) ;
// info con tipo
m_pGDB->SetInfo( nId, IKEY_GROUP, 4) ;
m_pGDB->SetInfo( nId, IKEY_PROC, 251) ;
m_pGDB->SetInfo( nId, IKEY_SIDE, nSide) ;
// eventuali parametri del contorno
if ( nContType > 0 || ( nContType >= 0 && nContData != 0))
m_pGDB->SetInfo( nId, IKEY_CNT_TYPE, nContType) ;
if ( nContData != 0)
m_pGDB->SetInfo( nId, IKEY_CNT_DATA, nContData) ;
if ( abs( dContPar) > EPS_SMALL)
m_pGDB->SetInfo( nId, IKEY_CNT_PAR, dContPar) ;
// eventuali attributi utente
if ( ! SetUserAttributes( nId, vsUAtt))
return false ;
// identificativi di geometrie ausiliarie
SetAuxId( nId, {nTId}) ;
// se richiesto Outline nel piano XY verifico ed eventualmente ruoto il pezzo
if ( m_nFlatVertPos == 4) {
Frame3d frOutline ;
if ( m_pGDB->GetGroupGlobFrame( m_nOutsId, frOutline)) {
Vector3d vtNorm = GetSideVersN( nSide) ;
vtNorm.ToGlob( frOutline) ;
if ( ! AreSameOrOppositeVectorApprox( vtNorm, Z_AX)) {
BBox3d b3Part ;
if ( m_pGDB->GetGlobalBBox( m_nBoxId, b3Part)) {
Vector3d vtDim = b3Part.GetMax() - b3Part.GetMin() ;
Point3d ptAx = b3Part.GetMin() + 0.5 * Vector3d( 0, vtDim.y, vtDim.y) ;
m_pGDB->RotateGlob( m_nPartId, ptAx, X_AX, 0, 1) ;
}
}
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::AddPartOutline( int nSide, int nCrvId, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt)
{
// reset dell'identificativo della geometria principale della feature
m_nProcId = GDB_ID_NULL ;
// verifico esistenza pezzo
if ( m_nBoxId == GDB_ID_NULL)
return false ;
// verifico validità faccia
if ( ! IsTrueSide( nSide))
return false ;
// verifica dei parametri
if ( vdPar.size() < 14)
return false ;
// sistemo i dati
int nContType = lround( vdPar[11]) ; // P13
int nContData = lround( vdPar[12]) ; // P14
double dContPar = vdPar[13] ; // P15
// verifico esista il percorso di contorno
if ( nCrvId == GDB_ID_NULL) {
// inserisco superficie vuota come marcatore
PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ;
if ( IsNull( pStm) || ! pStm->AdjustTopology())
return false ;
// la inserisco nel DB geometrico
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ;
if ( nId == GDB_ID_NULL)
return false ;
// nome
m_pGDB->SetName( nId, GetOutlineOutName( nSide)) ;
// info con tipo
m_pGDB->SetInfo( nId, IKEY_GROUP, 4) ;
m_pGDB->SetInfo( nId, IKEY_PROC, 251) ;
m_pGDB->SetInfo( nId, IKEY_SIDE, nSide) ;
// eventuali parametri del contorno
if ( nContType > 0 || ( nContType >= 0 && nContData != 0))
m_pGDB->SetInfo( nId, IKEY_CNT_TYPE, nContType) ;
if ( nContData != 0)
m_pGDB->SetInfo( nId, IKEY_CNT_DATA, nContData) ;
if ( abs( dContPar) > EPS_SMALL)
m_pGDB->SetInfo( nId, IKEY_CNT_PAR, dContPar) ;
// eventuali attributi utente
if ( ! SetUserAttributes( nId, vsUAtt))
return false ;
m_nProcId = nId ;
// messaggio di warning in log
string sOut = " Warning : Empty Outline (" + ToString( nSide) +
") on line " + ToString( m_nBtlLine) ;
LOG_WARN( GetEExLogger(), sOut.c_str())
return true ;
}
// copio il percorso di contorno
PtrOwner<ICurveComposite> pCrvCompo ;
if ( m_pGDB->GetGeoType( nCrvId) & GEO_CURVE) {
pCrvCompo.Set( CreateCurveComposite()) ;
if ( ! pCrvCompo->CopyFrom( m_pGDB->GetGeoObj( nCrvId)))
pCrvCompo.Reset() ;
}
if ( IsNull( pCrvCompo))
return false ;
// verifico che sia chiuso
if ( ! pCrvCompo->IsClosed())
return false ;
// assegno eventuali angoli di fianco
{ DBLVECTOR vSideAng ;
if ( m_pGDB->GetInfo( nCrvId, IKEY_SIDEANGS, vSideAng)) {
for ( int i = 0 ; i < int( vSideAng.size()) ; ++ i)
pCrvCompo->SetCurveTempProp( i, int( vSideAng[i] * 1000)) ;
}
}
// Lo porto nel riferimento del lato e ve lo appiattisco
Frame3d frRef = GetSideFrame( nSide) ;
pCrvCompo->ToLoc( frRef) ;
pCrvCompo->Scale( Frame3d(), 1, 1, 0) ;
// aggiusto orientamento affinché sia antiorario (devo inoltre invertire il segno dell'angolo di fianco)
double dArea ;
pCrvCompo->GetAreaXY( dArea) ;
if ( dArea < 0) {
pCrvCompo->Invert() ;
for ( int i = 0 ; i < pCrvCompo->GetCurveCount() ; ++ i) {
int nAng ;
if ( pCrvCompo->GetCurveTempProp( i, nAng) && abs( nAng) > 10)
pCrvCompo->SetCurveTempProp( i, -nAng) ;
}
}
// Porto il percorso sul piano corretto
pCrvCompo->ToGlob( frRef) ;
// Sistemazioni della curva
pCrvCompo->SetExtrusion( frRef.VersZ()) ;
pCrvCompo->SetThickness( -GetSideHeight( nSide)) ;
// Creo la superficie
PtrOwner<ISurfTriMesh> pStm ;
pStm.Set( CreateOneCurveFreeContour( pCrvCompo)) ;
if ( IsNull( pStm))
return false ;
// Inserisco la superficie nel layer Outline
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ;
if ( nId == GDB_ID_NULL)
return false ;
// recupero eventuali angoli di fianco
DBLVECTOR vSideAng ;
if ( VerifyFreeContourCurveSideAng( pCrvCompo))
GetFreeContourCurveSideAngles( pCrvCompo, vSideAng) ;
// inserisco la curva nel DB geometrico
int nTId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pCrvCompo)) ;
if ( nTId != GDB_ID_NULL && vSideAng.size() > 0)
m_pGDB->SetInfo( nTId, IKEY_SIDEANGS, vSideAng) ;
// colore
Color cCol = m_ProcsCol ;
m_pGDB->SetMaterial( nId, cCol) ;
@@ -102,6 +258,7 @@ BtlGeom::AddPartOutline( int nSide, const FCEDEQUE& dqFce, int nContType, int nC
// identificativi di geometrie ausiliarie
SetAuxId( nId, {nTId}) ;
m_nProcId = nId ;
return true ;
}
@@ -148,8 +305,14 @@ BtlGeom::AddPartAperture( int nSide, const FCEDEQUE& dqFce, int nContType, int n
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ;
if ( nId == GDB_ID_NULL)
return false ;
// recupero eventuali angoli di fianco
DBLVECTOR vSideAng ;
if ( VerifyFreeContourCurveSideAng( pCrvCompo))
GetFreeContourCurveSideAngles( pCrvCompo, vSideAng) ;
// inserisco la curva nel DB geometrico
int nTId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pCrvCompo)) ;
if ( nTId != GDB_ID_NULL && vSideAng.size() > 0)
m_pGDB->SetInfo( nTId, IKEY_SIDEANGS, vSideAng) ;
// colore
Color cCol = m_ProcsCol ;
m_pGDB->SetMaterial( nId, cCol) ;
@@ -176,6 +339,135 @@ BtlGeom::AddPartAperture( int nSide, const FCEDEQUE& dqFce, int nContType, int n
return true ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::AddPartAperture( int nSide, int nCrvId, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt)
{
// reset dell'identificativo della geometria principale della feature
m_nProcId = GDB_ID_NULL ;
// verifico esistenza pezzo
if ( m_nBoxId == GDB_ID_NULL)
return false ;
// verifico validità faccia
if ( ! IsTrueSide( nSide))
return false ;
// verifica dei parametri
if ( vdPar.size() < 14)
return false ;
// sistemo i dati
int nContType = lround( vdPar[11]) ; // P13
int nContData = lround( vdPar[12]) ; // P14
double dContPar = vdPar[13] ; // P15
// verifico esista il percorso di contorno
if ( nCrvId == GDB_ID_NULL) {
// inserisco superficie vuota come marcatore
PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ;
if ( IsNull( pStm) || ! pStm->AdjustTopology())
return false ;
// la inserisco nel DB geometrico
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ;
if ( nId == GDB_ID_NULL)
return false ;
// nome
m_pGDB->SetName( nId, GetOutlineApertureName( nSide)) ;
// info con tipo
m_pGDB->SetInfo( nId, IKEY_GROUP, 4) ;
m_pGDB->SetInfo( nId, IKEY_PROC, 252) ;
m_pGDB->SetInfo( nId, IKEY_SIDE, nSide) ;
// eventuali parametri del contorno
if ( nContType > 0 || ( nContType >= 0 && nContData != 0))
m_pGDB->SetInfo( nId, IKEY_CNT_TYPE, nContType) ;
if ( nContData != 0)
m_pGDB->SetInfo( nId, IKEY_CNT_DATA, nContData) ;
if ( abs( dContPar) > EPS_SMALL)
m_pGDB->SetInfo( nId, IKEY_CNT_PAR, dContPar) ;
// eventuali attributi utente
if ( ! SetUserAttributes( nId, vsUAtt))
return false ;
m_nProcId = nId ;
// messaggio di warning in log
string sOut = " Warning : Empty Aperture (" + ToString( nSide) +
") on line " + ToString( m_nBtlLine) ;
LOG_WARN( GetEExLogger(), sOut.c_str())
return true ;
}
// copio il percorso di contorno
PtrOwner<ICurveComposite> pCrvCompo ;
if ( m_pGDB->GetGeoType( nCrvId) & GEO_CURVE) {
pCrvCompo.Set( CreateCurveComposite()) ;
if ( ! pCrvCompo->CopyFrom( m_pGDB->GetGeoObj( nCrvId)))
pCrvCompo.Reset() ;
}
if ( IsNull( pCrvCompo))
return false ;
// verifico che sia chiuso
if ( ! pCrvCompo->IsClosed())
return false ;
// assegno eventuali angoli di fianco
{ DBLVECTOR vSideAng ;
if ( m_pGDB->GetInfo( nCrvId, IKEY_SIDEANGS, vSideAng)) {
for ( int i = 0 ; i < int( vSideAng.size()) ; ++ i)
pCrvCompo->SetCurveTempProp( i, int( vSideAng[i] * 1000)) ;
}
}
// Lo porto nel riferimento del lato e ve lo appiattisco
Frame3d frRef = GetSideFrame( nSide) ;
pCrvCompo->ToLoc( frRef) ;
pCrvCompo->Scale( Frame3d(), 1, 1, 0) ;
// aggiusto orientamento affinché sia orario
double dArea ;
pCrvCompo->GetAreaXY( dArea) ;
if ( dArea > 0)
pCrvCompo->Invert() ;
// Porto il percorso sul piano corretto e ve lo appiattisco
pCrvCompo->ToGlob( frRef) ;
// Sistemazioni della curva
pCrvCompo->SetExtrusion( frRef.VersZ()) ;
pCrvCompo->SetThickness( -GetSideHeight( nSide)) ;
// Creo la superficie
PtrOwner<ISurfTriMesh> pStm ;
pStm.Set( CreateOneCurveFreeContour( pCrvCompo)) ;
if ( IsNull( pStm))
return false ;
// Inserisco la superficie nel layer Outline
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ;
if ( nId == GDB_ID_NULL)
return false ;
// recupero eventuali angoli di fianco
DBLVECTOR vSideAng ;
if ( VerifyFreeContourCurveSideAng( pCrvCompo))
GetFreeContourCurveSideAngles( pCrvCompo, vSideAng) ;
// inserisco la curva nel DB geometrico
int nTId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pCrvCompo)) ;
if ( nTId != GDB_ID_NULL && vSideAng.size() > 0)
m_pGDB->SetInfo( nTId, IKEY_SIDEANGS, vSideAng) ;
// colore
Color cCol = m_ProcsCol ;
m_pGDB->SetMaterial( nId, cCol) ;
m_pGDB->SetMaterial( nTId, cCol) ;
// nome
m_pGDB->SetName( nId, GetOutlineApertureName( nSide)) ;
// info con tipo
m_pGDB->SetInfo( nId, IKEY_GROUP, 4) ;
m_pGDB->SetInfo( nId, IKEY_PROC, 252) ;
m_pGDB->SetInfo( nId, IKEY_SIDE, nSide) ;
// eventuali parametri del contorno
if ( nContType > 0 || ( nContType >= 0 && nContData != 0))
m_pGDB->SetInfo( nId, IKEY_CNT_TYPE, nContType) ;
if ( nContData != 0)
m_pGDB->SetInfo( nId, IKEY_CNT_DATA, nContData) ;
if ( abs( dContPar) > EPS_SMALL)
m_pGDB->SetInfo( nId, IKEY_CNT_PAR, dContPar) ;
// eventuali attributi utente
if ( ! SetUserAttributes( nId, vsUAtt))
return false ;
// identificativi di geometrie ausiliarie
SetAuxId( nId, {nTId}) ;
m_nProcId = nId ;
return true ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::UpdateOutLine( void)
@@ -380,18 +672,55 @@ BtlGeom::TrimOutlineWithApertures( void)
bool
BtlGeom::TrimOutlineWithProcesses( void)
{
int nProcId = m_pGDB->GetFirstInGroup( m_nProcsId) ;
while ( nProcId != GDB_ID_NULL) {
// calcolo il numero dei processi di trimming presenti
int nProcCount = 0 ;
for ( int nProcId = m_pGDB->GetFirstInGroup( m_nProcsId) ;
nProcId != GDB_ID_NULL ;
nProcId = m_pGDB->GetNext( nProcId)) {
// deve essere una superficie
if ( m_pGDB->GetGeoType( nProcId) != SRF_TRIMESH)
continue ;
// deve essere attiva
int nDO = 1 ;
int nTrim = 1 ;
m_pGDB->GetInfo( nProcId, IKEY_DO, nDO) ;
if ( nDO == 0)
continue ;
// deve essere abilitata al trimming
int nTrim = 1 ;
m_pGDB->GetInfo( nProcId, IKEY_TRIM, nTrim) ;
// se necessario, aggiusto l'outline
if ( nDO != 0 && nTrim != 0 &&
m_pGDB->GetGeoType( nProcId) == SRF_TRIMESH &&
UseProcessToTrimOutline( nProcId))
TrimOutline( nProcId) ;
nProcId = m_pGDB->GetNext( nProcId) ;
if ( nTrim == 0 || ! UseProcessToTrimOutline( nProcId))
continue ;
// incremento il conteggio
++ nProcCount ;
}
// se troppi, salto i fori
bool bSkipDrills = ( nProcCount > 200) ;
// eseguo il trim
for ( int nProcId = m_pGDB->GetFirstInGroup( m_nProcsId) ;
nProcId != GDB_ID_NULL ;
nProcId = m_pGDB->GetNext( nProcId)) {
// deve essere una superficie
if ( m_pGDB->GetGeoType( nProcId) != SRF_TRIMESH)
continue ;
// deve essere attiva
int nDO = 1 ;
m_pGDB->GetInfo( nProcId, IKEY_DO, nDO) ;
if ( nDO == 0)
continue ;
// deve essere abilitata al trimming
int nTrim = 1 ;
m_pGDB->GetInfo( nProcId, IKEY_TRIM, nTrim) ;
if ( nTrim == 0 || ! UseProcessToTrimOutline( nProcId))
continue ;
// se fori da saltare, non deve essere un foro
if ( bSkipDrills) {
int nProc = 0 ;
m_pGDB->GetInfo( nProcId, IKEY_PROC, nProc) ;
if ( nProc == 40)
continue ;
}
// eseguo il trim
TrimOutline( nProcId) ;
}
return true ;
@@ -423,8 +752,12 @@ BtlGeom::TrimOutline( int nProcSurfId)
// Se processo con più superfici da usare insieme per trim, devo unirle
int nTrim ;
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_TRIM, nTrim) && nTrim == 2) {
// Recupero le due superfici del processo di lavorazione (eventualmente le originali)
int nOrigId = 0 ;
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_ORIGID, nOrigId))
nProcSurfId += nOrigId ;
int nAux ;
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_AUXID, nAux)) {
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_AUXID, nAux) && nAux != 0) {
const ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId)) ;
const ISurfTriMesh* pAux = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId + nAux)) ;
if ( pStm != nullptr && pAux != nullptr) {
@@ -434,8 +767,12 @@ BtlGeom::TrimOutline( int nProcSurfId)
return TrimOutline( pTrim) ;
}
}
return false ;
}
// Recupero la superficie del processo di lavorazione
// Recupero la superficie del processo di lavorazione (eventualmente l'originale)
int nOrigId = 0 ;
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_ORIGID, nOrigId))
nProcSurfId += nOrigId ;
const ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId)) ;
if ( pStm == nullptr)
return false ;
@@ -875,7 +1212,7 @@ BtlGeom::IsPointNearFaceContour( const Point3d& ptP, int nSide)
// Il punto è nel riferimento faccia
// Verifico se sta vicino al contorno o fuori
const double EPS_IN_NEAR = 0.2 ;
const double EPS_OUT_NEAR = 1.0 ;
const double EPS_OUT_NEAR = 5.0 ;
double dL = GetSideLength( nSide) ;
double dW = GetSideWidth( nSide) ;
return ( ( ptP.x > - EPS_OUT_NEAR && ptP.x < EPS_IN_NEAR) ||
@@ -941,33 +1278,103 @@ BtlGeom::TrimRayWithFaceContour( const Point3d& ptP, const Vector3d& vtDir, int
return IntersCurveCurve( *pRay, *pCont).GetIntersPointNearTo( 0, ptP, ptInt) ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::TrimProcessWithOutline( int nProcId)
{
// se non richiesto, esco subito
if ( ! m_bTrimWithOutline)
return true ;
// verifico esistenza superficie della feature da trimmare
ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcId)) ;
if ( pStm == nullptr)
return false ;
// se prevista anche una seconda superficie da trimmare
ISurfTriMesh* pStm2 = nullptr ;
int nTrim = 0 ;
if ( m_pGDB->GetInfo( nProcId, IKEY_TRIM, nTrim) && nTrim == 2) {
int nAux ;
if ( m_pGDB->GetInfo( nProcId, IKEY_AUXID, nAux) && nAux != 0)
pStm2 = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcId + nAux)) ;
if ( pStm2 == nullptr)
return false ;
}
// verifico esistenza superficie di outline
int nOutId = GDB_ID_NULL ;
int nEntId = m_pGDB->GetFirstInGroup( m_nOutsId) ;
while ( nEntId != GDB_ID_NULL) {
int nDO = 1 ;
m_pGDB->GetInfo( nEntId, IKEY_DO, nDO) ;
int nProc = 0 ;
m_pGDB->GetInfo( nEntId, IKEY_PROC, nProc) ;
int nSide = 0 ;
m_pGDB->GetInfo( nEntId, IKEY_SIDE, nSide) ;
if ( nDO != 0 && nProc == 251 && nSide != 0) {
nOutId = nEntId ;
break ;
}
nEntId = m_pGDB->GetNext( nEntId) ;
}
if ( nOutId == GDB_ID_NULL)
return true ;
// recupero la curva associata alla superficie di trim
int nAuxId = 0 ;
m_pGDB->GetInfo( nOutId, IKEY_AUXID, nAuxId) ;
if ( nAuxId == 0)
return true ;
int nCrv = nOutId + nAuxId ;
const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nCrv)) ;
if ( pCrv == nullptr)
return true ;
// creo una copia della superficie come originale
int nCopyId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nProcsId, pStm->Clone()) ;
if ( nCopyId == GDB_ID_NULL)
return false ;
string sOrigId = ( nCopyId - nProcId > 0 ? "+" : "") + ToString( nCopyId - nProcId) ;
m_pGDB->SetInfo( nProcId, IKEY_ORIGID, sOrigId) ;
string sMainId = ( nProcId - nCopyId > 0 ? "+" : "") + ToString( nProcId - nCopyId) ;
m_pGDB->SetInfo( nCopyId, IKEY_MAINID, sMainId) ;
m_pGDB->SetMode( nCopyId, GDB_MD_HIDDEN) ;
// se esiste anche seconda superficie, copio anche questa
if ( pStm2 != nullptr) {
int nCopy2Id = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nProcsId, pStm2->Clone()) ;
if ( nCopy2Id == GDB_ID_NULL)
return false ;
string sAuxId = ( nCopy2Id - nCopyId > 0 ? "+" : "") + ToString( nCopy2Id - nCopyId) ;
m_pGDB->SetInfo( nCopyId, IKEY_AUXID, sAuxId) ;
m_pGDB->SetMode( nCopy2Id, GDB_MD_HIDDEN) ;
}
// eseguo il trim
return ( pStm->GeneralizedCut( *pCrv, false) &&
( pStm2 == nullptr || pStm2->GeneralizedCut( *pCrv, false))) ;
}
//----------------------------------------------------------------------------
bool
BtlGeom::AddShapeBTLX( vector<INTVECTOR> vFacesVertices, vector<Point3d> vPoints)
BtlGeom::AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints)
{
ISurfTriMesh * Shape = CreateSurfTriMesh() ;
PtrOwner<ISurfTriMesh> pShape( CreateSurfTriMesh()) ;
for ( auto it = vFacesVertices.begin() ; it != vFacesVertices.end() ; it++ ){
for ( auto it = vFacesVertices.begin() ; it != vFacesVertices.end() ; it++) {
INTVECTOR vVertices = *it ;
if ( vVertices.size() < 3){
if ( vVertices.size() < 3) {
LOG_ERROR( GetEExLogger(), " Error reading Part Shape: Face not valid")
return false ;
}
// Creo il contorno della faccia
ICurveComposite* CurveCompo = CreateCurveComposite() ;
CurveCompo->AddPoint( vPoints[vVertices[0]]) ;
// creo il contorno della faccia
PtrOwner<ICurveComposite> pCurveCompo( CreateCurveComposite()) ;
pCurveCompo->AddPoint( vPoints[vVertices[0]]) ;
for ( size_t i = 1 ; i != vVertices.size() ; i++)
CurveCompo->AddLine( vPoints[vVertices[i]]) ;
CurveCompo->AddLine( vPoints[vVertices[0]]) ;
pCurveCompo->AddLine( vPoints[vVertices[i]]) ;
pCurveCompo->AddLine( vPoints[vVertices[0]]) ;
if ( it == vFacesVertices.begin() || Shape == nullptr)
Shape = GetSurfTriMeshByFlatContour( CurveCompo) ;
if ( it == vFacesVertices.begin() || ! pShape->IsValid())
pShape.Set( GetSurfTriMeshByFlatContour( pCurveCompo)) ;
else {
ISurfTriMesh * surf = GetSurfTriMeshByFlatContour( CurveCompo) ;
// controllo che CurveCompo racchiuda veramente una superficie
if ( surf != nullptr) {
if ( ! Shape->DoSewing( * surf)){
PtrOwner<ISurfTriMesh> pSurf( GetSurfTriMeshByFlatContour( pCurveCompo)) ;
// controllo che pCurveCompo racchiuda veramente una superficie
if ( ! IsNull( pSurf)) {
if ( ! pShape->DoSewing( * pSurf)) {
LOG_ERROR( GetEExLogger(), " Error reading Part Shape: stm.DoSewing error")
return false ;
}
@@ -975,7 +1382,7 @@ BtlGeom::AddShapeBTLX( vector<INTVECTOR> vFacesVertices, vector<Point3d> vPoints
}
}
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nPartId + 3, Shape) ; // salvo in outline
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nPartId + 3, Release( pShape)) ; // salvo in outline
if ( nId == GDB_ID_NULL)
return false ;
m_pGDB->SetName( nId, "Shape") ;
+784 -124
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -19,3 +19,4 @@
//-----------------------------------------------------------------------------
ILogger* GetEExLogger( void) ;
const std::string& GetEExKey( void) ;
bool GetEExNetHwKey( void) ;
+15
View File
@@ -89,6 +89,7 @@ GetEExLogger( void)
//-----------------------------------------------------------------------------
static std::string s_sKey ;
static bool s_bNetHwKey = false ;
//-----------------------------------------------------------------------------
void
@@ -97,9 +98,23 @@ SetEExKey( const std::string& sKey)
s_sKey = sKey ;
}
//-----------------------------------------------------------------------------
void
SetEExNetHwKey( bool bNetHwKey)
{
s_bNetHwKey = bNetHwKey ;
}
//-----------------------------------------------------------------------------
const std::string&
GetEExKey( void)
{
return s_sKey ;
}
//-----------------------------------------------------------------------------
bool
GetEExNetHwKey( void)
{
return s_bNetHwKey ;
}
BIN
View File
Binary file not shown.
+6 -2
View File
@@ -29,7 +29,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v141_xp</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>v120_xp</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -130,6 +130,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -198,6 +199,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -239,6 +241,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="ExportDxf.h" />
<ClInclude Include="ExportStl.h" />
<ClInclude Include="ExportSvg.h" />
<ClInclude Include="ExportThreeJS.h" />
<ClInclude Include="Import3MF.h" />
<ClInclude Include="ImportBtl.h" />
<ClInclude Include="BtlGeomCoStru.h" />
@@ -275,6 +278,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="ExportDxf.cpp" />
<ClCompile Include="ExportStl.cpp" />
<ClCompile Include="ExportSvg.cpp" />
<ClCompile Include="ExportThreeJS.cpp" />
<ClCompile Include="Import3MF.cpp" />
<ClCompile Include="ImportBtl.cpp" />
<ClCompile Include="BtlGeom.cpp" />
+6
View File
@@ -126,6 +126,9 @@
<ClInclude Include="Export3MF.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="ExportThreeJS.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@@ -203,6 +206,9 @@
<ClCompile Include="Export3MF.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="ExportThreeJS.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtExchange.rc">
+67 -179
View File
@@ -26,8 +26,6 @@
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGnFileUtils.h"
using namespace std ;
using namespace Lib3MF ;
@@ -37,7 +35,7 @@ IExport3MF*
CreateExport3MF( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IExport3MF*> ( new(nothrow) Export3MF) ;
@@ -54,13 +52,12 @@ Export3MF::SetOptions( int nFilter)
//----------------------------------------------------------------------------
bool
Export3MF::Export( IGeomDB* pGDB, int nId, const string& sFile)
{
{
// verifico il DB geometrico
if ( pGDB == nullptr) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on GeomDB")
return false ;
}
m_pGDB = pGDB ;
// verifico l'Id dell'oggetto da esportare
if ( ! pGDB->ExistsObj( nId)) {
@@ -68,54 +65,44 @@ Export3MF::Export( IGeomDB* pGDB, int nId, const string& sFile)
return false ;
}
try {
if ( ! DoExport( nId, sFile))
return false ;
}
catch ( ELib3MFException &exception) {
LOG_ERROR( GetEExLogger(), exception.what()) ;
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Export3MF::DoExport( const int& nId, const string& sFile)
{
// libreria 3MF
m_wrapper = CWrapper::loadLibrary() ;
if ( ! m_wrapper) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Wrapper")
return false ;
return false ;
}
// creo model per 3MF
m_model = m_wrapper->CreateModel() ;
if ( ! m_model) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Model")
return false ;
}
return false ;
}
if ( ! m_model->AddColorGroup()) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Color Group")
return false ;
return false ;
}
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( pGDB)) ;
if ( IsNull( pIter))
return false ;
pIter->GoTo( nId) ;
// esporto l'oggetto e i suoi eventuali figli
if ( ! ExportObject( *pIter))
return false ;
// scrivo il file
PWriter writer = m_model->QueryWriter( "3mf") ;
writer->WriteToFile( sFile) ;
// scrivo il file
try {
PWriter writer = m_model->QueryWriter( "3mf") ;
writer->WriteToFile( sFile) ;
}
catch ( ELib3MFException &e) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on writing")
string s = e.what() ;
LOG_ERROR( GetEExLogger(), ( " " + s).c_str()) ;
return false ;
}
return true ;
}
@@ -131,8 +118,12 @@ Export3MF::ExportObject( const IGdbIterator& iIter)
if ( pGeoObj == nullptr)
return true ;
// se non è una superficie esco
if ( pGeoObj->GetType() != SRF_TRIMESH && pGeoObj->GetType() != SRF_FLATRGN)
return true ;
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) ;
@@ -143,15 +134,22 @@ Export3MF::ExportObject( const IGdbIterator& iIter)
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat)) {
if ( TestFilter( nLev, nMode, nStat)) {
// recupero eventuale nome
string sName ;
if ( ! iIter.GetName( sName))
sName = ToString( iIter.GetId()) ;
// recupero il colore
Color cCol ;
bool bCol = GetColor( cCol, iIter.GetGDB(), iIter.GetId()) ;
// emetto l'oggetto
switch ( pGeoObj->GetType()) {
case SRF_TRIMESH :
if ( ! ExportSTM( iIter.GetId(), GetSurfTriMesh( pGeoObj)))
if ( ! ExportSTM( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr))
return false ;
break ;
case SRF_FLATRGN :
if ( ! ExportSFR( iIter.GetId(), GetSurfFlatRegion( pGeoObj)))
if ( ! ExportSFR( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr))
return false ;
break ;
default :
@@ -190,43 +188,35 @@ Export3MF::TestFilter( int nLev, int nMode, int nStat)
//----------------------------------------------------------------------------
bool
Export3MF::ExportSFR( const int& nId, const ISurfFlatRegion* pSFR)
Export3MF::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol)
{
// verifico oggetto
if ( pSFR == nullptr || nId == GDB_ID_NULL)
const ISurfFlatRegion* pSFR = GetSurfFlatRegion( pGeoObj) ;
if ( pSFR == nullptr)
return false ;
// ricavo la trimesh equivalente
const ISurfTriMesh* pStm = pSFR->GetAuxSurf() ;
return ExportSTM( nId, pStm) ;
return ExportSTM( sName, pStm, frFrame, pCol) ;
}
//----------------------------------------------------------------------------
bool
Export3MF::ExportSTM( const int& nId, const ISurfTriMesh* pSTM)
Export3MF::ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol)
{
// verifico oggetto
if ( pSTM == nullptr || nId == GDB_ID_NULL)
return false ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! m_pGDB->GetGlobFrame( nId, frFrame))
return false ;
// recupero eventuale nome
string sName ;
if ( ! m_pGDB->GetName( nId, sName))
sName = ToString( nId) ;
const ISurfTriMesh* pSTM = GetSurfTriMesh( pGeoObj) ;
if ( pSTM == nullptr)
return false ;
// ciclo sui vertici della trimesh
vector<sLib3MFPosition> vVertices( pSTM->GetVertexSize()) ;
vector<sLib3MFPosition> vVertices( pSTM->GetVertexSize()) ;
for ( int i = 0 ; i < pSTM->GetVertexSize() ; i++) {
Point3d pt ;
pSTM->GetVertex( i, pt) ;
pt.ToGlob( frFrame) ;
vVertices[i].m_Coordinates[0] = Lib3MF_single( pt.x) ;
vVertices[i].m_Coordinates[1] = Lib3MF_single( pt.y) ;
vVertices[i].m_Coordinates[2] = Lib3MF_single( pt.z) ;
vVertices[i].m_Coordinates[2] = Lib3MF_single( pt.z) ;
}
// ciclo sui triangoli della trimesh
@@ -234,44 +224,40 @@ Export3MF::ExportSTM( const int& nId, const ISurfTriMesh* pSTM)
int k = 0 ;
for ( int i = 0 ; i < pSTM->GetTriangleSize() ; i++) {
int nIdVert[3] ;
if ( ! pSTM->GetTriangle( i, nIdVert))
continue ; // 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
vTriangles[k].m_Indices[0] = nIdVert[0] ;
vTriangles[k].m_Indices[1] = nIdVert[1] ;
vTriangles[k].m_Indices[2] = nIdVert[2] ;
k ++ ;
k ++ ;
}
if ( vVertices.size() == 0 || vTriangles.size() == 0) {
LOG_ERROR( GetEExLogger(), ("Export3MF : surface \"" + sName + "\" is empty. Ignored.").c_str()) ;
return true ;
if ( vVertices.size() == 0 || vTriangles.size() == 0) {
LOG_ERROR( GetEExLogger(), ( "Export3MF : surface \"" + sName + "\" is empty. Ignored.").c_str()) ;
return true ;
}
// creo mesh 3MF
PMeshObject meshObject = m_model->AddMeshObject() ;
if ( ! meshObject) {
LOG_ERROR( GetEExLogger(), "Export3MF : Error on lib3mf Mesh Object")
return false ;
}
return false ;
}
meshObject->SetName( sName) ;
meshObject->SetGeometry( vVertices, vTriangles) ;
// texture
if ( ! ExportTexture( nId, pSTM, meshObject))
return false ;
// assegno il colore
Color cCol ;
if ( GetColor( nId, cCol)) {
Lib3MF_uint32 nColId = ColorHandler3MF( cCol) ;
// assegno il colore
if ( pCol != nullptr) {
Lib3MF_uint32 nColId = ColorHandler3MF( pCol) ;
meshObject->SetObjectLevelProperty( 1, nColId) ;
}
m_model->AddBuildItem( meshObject.get(), m_wrapper->GetIdentityTransform()) ;
m_model->AddBuildItem( meshObject.get(), m_wrapper->GetIdentityTransform()) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Export3MF::ScanGroup( const IGdbIterator& iIter)
@@ -294,26 +280,26 @@ Export3MF::ScanGroup( const IGdbIterator& iIter)
//----------------------------------------------------------------------------
bool
Export3MF::GetColor( const int& nId, Color& cCol)
Export3MF::GetColor( Color& pCol, const IGeomDB * pGDB, const int& nId)
{
if ( nId == GDB_ID_NULL)
return false ;
if ( ! m_pGDB->GetMaterial( nId, cCol))
if ( ! pGDB->GetMaterial( nId, pCol))
// se fallisce cerco il colore del parent
return GetColor( m_pGDB->GetParentId( nId), cCol) ;
return GetColor( pCol, pGDB, pGDB->GetParentId( nId)) ;
return true ;
}
//----------------------------------------------------------------------------
Lib3MF_uint32
Export3MF::ColorHandler3MF( const Color& cCol)
Export3MF::ColorHandler3MF( const Color* pCol)
{
PColorGroup pColorGrp = m_model->GetColorGroupByID( 1) ;
// converto il colore nel formato usato da 3MF
Lib3MF_uint8 nAlpha = ( int)( cCol.GetIntAlpha() * 2.55 + 0.5) ;
sColor cCol3mf = m_wrapper->RGBAToColor( cCol.GetIntRed(), cCol.GetIntGreen(), cCol.GetIntBlue(), nAlpha) ;
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
UINTVECTOR vColorIdx ;
pColorGrp->GetAllPropertyIDs( vColorIdx) ;
@@ -321,106 +307,8 @@ Export3MF::ColorHandler3MF( const Color& cCol)
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)
return i ;
return i ;
}
// se non fosse presente, lo aggiungo
return pColorGrp->AddColor( cCol3mf) ;
}
//----------------------------------------------------------------------------
bool
Export3MF::ExportTexture( const int& nObjId, const ISurfTriMesh* pSTM, PMeshObject& meshObject)
{
// verifico esistenza texture
string sTxrName ;
if ( ! m_pGDB->GetTextureName( nObjId, sTxrName))
return true ;
// cerco id della texture nel GeomDB
int nGrpId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, "Photos") ;
if ( nGrpId == GDB_ID_NULL)
return false ;
int nTxrId = m_pGDB->GetFirstNameInGroup( nGrpId, sTxrName) ;
if ( nTxrId == GDB_ID_NULL)
return false ;
double dDimX, dDimY ;
if ( ! ExeGetPhotoDimensions( nTxrId, dDimX, dDimY))
return false ;
// frame per gestire la texture
Frame3d frSrf ;
if ( ! m_pGDB->GetTextureFrame( nObjId, frSrf))
return false ;
Lib3MF_uint32 nTxrGrpId = TextureGroupHandler( nTxrId) ;
PTexture2DGroup textureGroup = m_model->GetTexture2DGroupByID( nTxrGrpId) ;
// creo coordinate ( u, v) della texture per ogni vertice di pSTM
for ( int i = 0 ; i < pSTM->GetVertexSize() ; i ++) {
Point3d pt( 0, 0, 0) ;
pSTM->GetVertex( i, pt) ;
pt.ToLoc( frSrf) ;
textureGroup->AddTex2Coord( sLib3MFTex2Coord({ pt.x / dDimX, pt.y / dDimY})) ;
}
// indice in textureGroup corrispondente al primo vertice di questa superficie
int nOffs = textureGroup->GetCount() - pSTM->GetVertexSize() + 1 ;
// assegno ai triangoli
int k = 0 ;
for ( int i = 0 ; i < pSTM->GetTriangleSize() ; i++) {
sLib3MFTriangleProperties property ;
property.m_ResourceID = nTxrGrpId ;
int nIdVert[3] ;
if ( ! pSTM->GetTriangle( i, nIdVert))
continue ;
property.m_PropertyIDs[0] = nIdVert[0] + nOffs ;
property.m_PropertyIDs[1] = nIdVert[1] + nOffs ;
property.m_PropertyIDs[2] = nIdVert[2] + nOffs ;
meshObject->SetTriangleProperties( k, property) ;
k ++ ;
}
return true ;
}
//----------------------------------------------------------------------------
Lib3MF_uint32
Export3MF::TextureGroupHandler( const int& nTxrId)
{
auto it = m_TexturesMap.find( nTxrId) ;
// se la texture è già presente nel modello 3MF restituisco il suo id
if ( it != m_TexturesMap.end())
return it->second ;
// se non è presente l'aggiungo
string sTxrPath ;
string sInfo ;
m_pGDB->GetInfo( nTxrId, "Path", sInfo) ;
ExeGetPhotoPath( nTxrId, sTxrPath) ;
string sTxrExtension = GetFileExtension( sTxrPath) ;
string sTxrRelationshipType = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture" ;
string sOPCPath = "/3D/Texture/texture_" + to_string( m_TexturesMap.size()) + "." + sTxrExtension ;
PAttachment attachment = m_model->AddAttachment( sOPCPath, sTxrRelationshipType) ;
attachment->ReadFromFile( sTxrPath) ;
PTexture2D texture2D = m_model->AddTexture2DFromAttachment( attachment.get()) ;
if ( sTxrExtension == "jpg" || sTxrExtension == "jpeg")
texture2D->SetContentType( eTextureType::JPEG) ;
else if ( sTxrExtension == "png")
texture2D->SetContentType( eTextureType::PNG) ;
texture2D->SetTileStyleUV( eTextureTileStyle::NoTileStyle, eTextureTileStyle::NoTileStyle) ;
PTexture2DGroup textureGroup = m_model->AddTexture2DGroup( texture2D.get()) ;
Lib3MF_uint32 nTxrGrpId = textureGroup->GetResourceID() ;
m_TexturesMap.emplace( nTxrId, nTxrGrpId) ;
return nTxrGrpId ;
}
+6 -14
View File
@@ -16,11 +16,8 @@
#define NOMINMAX
#include "/EgtDev/Extern/Lib3MF/Include/lib3mf_implicit.hpp"
#include "/EgtDev/Include/EExExport3MF.h"
#include <map>
class IGdbIterator ;
class ISurfTriMesh ;
class ISurfFlatRegion ;
//----------------------------------------------------------------------------
class Export3MF : public IExport3MF
@@ -33,21 +30,16 @@ class Export3MF : public IExport3MF
Export3MF( void) : m_nFilter( EEXFLT_DEFAULT) {}
private :
bool DoExport( const int& nId, const std::string& sFile) ;
bool ExportObject( const IGdbIterator& iIter) ;
bool ScanGroup( const IGdbIterator& iIter) ;
bool TestFilter( int nLev, int nMode, int nStat) ;
bool ExportSFR( const int& nId, const ISurfFlatRegion* pSFR) ;
bool ExportSTM( const int& nId, const ISurfTriMesh* pSTM) ;
Lib3MF_uint32 ColorHandler3MF( const Color& cCol) ;
bool GetColor( const int& nId, Color& cCol) ;
bool ExportTexture( const int& nObjId, const ISurfTriMesh* pSTM, Lib3MF::PMeshObject& meshObject) ;
Lib3MF_uint32 TextureGroupHandler( const int& nTxrId) ;
bool TestFilter( int nLev, int nMode, int nStat) ;
bool ExportSFR( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol) ;
bool ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol) ;
Lib3MF_uint32 ColorHandler3MF( const Color* pCol) ;
bool GetColor( Color& pCol, const IGeomDB * pGBD, const int& nId) ;
private :
IGeomDB* m_pGDB ;
private :
int m_nFilter ; // filtro su livello, modo e stato
Lib3MF::PWrapper m_wrapper ; // lib3mf wrapper
Lib3MF::PModel m_model ; // lib3mf model
std::map< int, Lib3MF_uint32> m_TexturesMap ;
} ;
+1 -1
View File
@@ -46,7 +46,7 @@ IExportDxf*
CreateExportDxf( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IExportDxf*> ( new(nothrow) ExportDxf) ;
+1 -1
View File
@@ -34,7 +34,7 @@ IExportStl*
CreateExportStl( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IExportStl*> ( new(nothrow) ExportStl) ;
+1 -1
View File
@@ -41,7 +41,7 @@ IExportSvg*
CreateExportSvg( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IExportSvg*> ( new(nothrow) ExportSvg) ;
+2896
View File
File diff suppressed because it is too large Load Diff
+83
View File
@@ -0,0 +1,83 @@
//----------------------------------------------------------------------------
// EgalWare 2022-2022
//----------------------------------------------------------------------------
// File : ExportThreeJS.h Data : 05.07.22 Versione : 1.5h2
// Contenuto : Dichiarazione della classe ExportThreeJS.
//
//
//
// Modifiche : 08.07.22
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EExExportThreeJS.h"
#include "/EgtDev/Include/EGnWriter.h"
#include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EGkIntersSurfTmSurfTm.h"
class IGdbIterator;
class IGeoObj;
class Frame3d;
struct sSurfDist {
const ISurfTriMesh* SurvAlpha;
double dDistance = 0;
std::string sName;
};
//----------------------------------------------------------------------------
class ExportThreeJS : public IExportThreeJS
{
public:
virtual bool SetOptions(int nFilter);
virtual bool Export(IGeomDB* pGDB, int nId, const std::string& sFile, IEGrScene* pScene, bool bUdm);
public:
ExportThreeJS(void) : m_nFilter(EEXFLT_DEFAULT) {}
private:
bool HeadAmbient( IEGrScene* pScene, IGeomDB* pGDB, int nId) ;
bool FinishAmbient() ;
bool ExportVector3D( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ;
bool ExportPoint3D( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ;
bool ExportFrame3D( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ;
bool ExportLine3D( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ;
bool ExportCurveComp3D( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ; //archi e curve composite
bool ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ;
bool ExportSFR( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ;
bool ExportSBezier(const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ;
bool ExportText( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color& cCol, const int nIdGroup) ;
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) ;
private:
int m_nFilter; // filtro su livello, modo e stato
Writer m_Writer; // scrittore di file di testo oggetto
Point3d m_ptMin; // punto minimo del box3d
bool m_bUdm_mm; // se l'unità di misura è in mm
double m_dimX; // dimX Box3d Global
double m_dimY; // dimY Box3d Global
double m_dimZ; // dimZ Box3d Global
double m_dDistance; // scala per pan e zoom
int m_nCont = 0; // contatore per linee interne ai testi
Point3d m_ptCamera; // Camera look at
Point3d m_ptCenter; // Camera center
double m_dHalfWidth; // Lunghezza/2 piano di proiezione (culling)
double m_dHalfHeight; // Altezza/2 piano di proiezione (culling)
double m_ZNear; // Distanza (lungo Z) piano di proiezione da origine (culling)
double m_ZFar; // Distanza (lungo Z) piano di culling da origine (culling)
int m_ANG_TOL_STD_DEG = 15; // Interpolazione testo
Frame3d m_frTHREEJSFrame; // frame di ThreeJS
std::list< sSurfDist> m_lTranspSurf; // Lista di superfici trasparenti
int m_nGroupCount = -1; // Contatore del gruppo
std::string m_sCodMenu; // Stringa per la creazione del menu laterale della scena
std::string m_spath; // Path dove salvare il file
std::string m_sUdm; // udm della scena
};
+82 -1
View File
@@ -30,7 +30,7 @@ IImport3MF*
CreateImport3MF( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImport3MF*> ( new( nothrow) Import3MF) ;
@@ -222,6 +222,86 @@ Import3MF::ReadObject( const PObject pObj, ATTRVECTOR& vAttr, sTransform& sTrans
bool
Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sTransf)
{
// Recupero puntatore alla mesh 3MF
PMeshObject pMesh = m_model->GetMeshObjectByID( nId) ;
if ( pMesh.get() == nullptr)
return false ;
// Creo e inizializzo trimesh
PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ;
if ( IsNull( pStm) || ! pStm->Init( 3, 1)) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : ISurfTriMesh Create error") ;
return false ;
}
pStm->SetLinearTolerance( 10 * EPS_SMALL) ;
// Ciclo sui vertici della mesh 3MF
for ( Lib3MF_uint32 i = 0 ; i < pMesh->GetVertexCount() ; i ++) {
// recupero le coordinate del vertice
sPosition pVertex = pMesh->GetVertex( i) ;
// 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 += sTransf.m_Fields[3][0] ;
y += sTransf.m_Fields[3][1] ;
z += sTransf.m_Fields[3][2] ;
// inserisco il vertice nella trimesh
if ( pStm->AddVertex( Point3d( x, y, z)) == SVT_NULL) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : ISurfTriMesh AddVertex error") ;
return false ;
}
}
// Ciclo sui triangoli della mesh 3MF
for ( Lib3MF_uint32 i = 0 ; i < pMesh->GetTriangleCount() ; i ++) {
// recupero gli indici dei vertici del triangolo
sTriangle tTrg = pMesh->GetTriangle( i) ;
int nIdV[3] = { int( tTrg.m_Indices[0]), int( tTrg.m_Indices[1]), int( tTrg.m_Indices[2])} ;
// se i vertici sono tutti diversi tra loro, inserisco il triangolo
if ( nIdV[0] != nIdV[1] && nIdV[0] != nIdV[2] && nIdV[1] != nIdV[2]) {
if ( pStm->AddTriangle( nIdV) == SVT_NULL) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : ISurfTriMesh AddTriangle error") ;
return false ;
}
}
}
// Aggiustamenti finali
if ( ! pStm->DoCompacting()) {
LOG_ERROR( GetEExLogger(), " Error reading 3MF mesh : ISurfTriMesh DoCompacting error") ;
return false ;
}
// Inserimento nel DB geometrico
int nGeoId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, Release( pStm)) ;
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 ;
#if 0
PMeshObject pMesh = m_model->GetMeshObjectByID( nId) ;
StmFromTriangleSoup Stm ;
@@ -292,6 +372,7 @@ Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sT
}
return true ;
#endif
}
//-----------------------------------------------------------------------------------
+108 -95
View File
@@ -39,7 +39,7 @@ IImportBtl*
CreateImportBtl( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPADV, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPADV, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportBtl*> ( new(nothrow) ImportBtl) ;
@@ -67,15 +67,18 @@ ImportBtl::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
// inizializzo il gestore geometria pezzi Btl
int nFlatVertPos = 0 ;
if (( nFlag & EIBFLAG_TS3_POS) != 0)
if (( nFlag & EIBFLAG_OUTL_FLAT_POS) != 0)
nFlatVertPos = 4 ;
else if (( nFlag & EIBFLAG_TS3_POS) != 0)
nFlatVertPos = 3 ;
else if (( nFlag & EIBFLAG_FLAT_POS) != 0)
nFlatVertPos = 1 ;
else if (( nFlag & EIBFLAG_VERT_POS) != 0)
nFlatVertPos = 2 ;
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, bUseUAttr)) {
if ( ! m_BtlGeom.Init( pGDB, nFlatVertPos, bSpecialTrim, bTrimWithOutline, bUseUAttr)) {
LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init")
return false ;
}
@@ -91,25 +94,41 @@ ImportBtl::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
}
// lettura generalità
if ( ! ReadGeneral()) {
bool bEnd ;
if ( ! ReadGeneral( bEnd)) {
string sOut = " Error (ReadGeneral) on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
return false ;
}
else if ( bEnd) {
string sOut = " Error No Parts in Btl file" ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
return false ;
}
// ciclo sui grezzi
bool bOk = true ;
for ( bool bEnd = false ; ! bEnd ;) {
if ( ! ReadRawPart( bEnd)) {
string sOut = " Error (ReadRawPart) on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
// leggo un grezzo
if ( ! ReadObject( RAWPART, bEnd)) {
// i log di errore sono già gestiti nella funzione chiamata
bOk = false ;
}
// se aggiunto un grezzo, lo sistemo
if ( ! bEnd) {
int nNewPart = m_BtlGeom.GetCurrPartId() ;
if ( ! m_BtlGeom.AdjustRawPart( nNewPart)) {
string sOut = " Error Adjusting RawPart on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
return false ;
}
}
}
// ciclo sui pezzi
for ( bool bEnd = false ; ! bEnd ;) {
if ( ! ReadPart( bEnd)) {
// leggo un pezzo
if ( ! ReadObject( PART, bEnd)) {
// i log di errore sono già gestiti nella funzione chiamata
bOk = false ;
}
@@ -117,17 +136,34 @@ ImportBtl::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
// ciclo sui compositi
for ( bool bEnd = false ; ! bEnd ;) {
if ( ! ReadComposite( bEnd)) {
string sOut = " Error on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
// leggo un composito
if ( ! ReadObject( COMPOSITE, bEnd)) {
// i log di errore sono già gestiti nella funzione chiamata
bOk = false ;
}
// se aggiunto un composito, lo sistemo
if ( ! bEnd) {
int nNewPart = m_BtlGeom.GetCurrPartId() ;
if ( ! m_BtlGeom.AdjustComposite( nNewPart)) {
string sOut = " Error Adjusting Composite on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
return false ;
}
}
}
// eventuale ordinamento dei pezzi secondo SN
// aggiusto riferimenti per grezzi e per compositi
m_BtlGeom.AdjustRefForRawParts() ;
m_BtlGeom.AdjustRefForComposites() ;
// eventuale ordinamento degli oggetti secondo SN
bool bSort = (( nFlag & EIBFLAG_SORT) != 0) ;
if ( bSort)
m_BtlGeom.SortParts() ;
if ( bSort) {
Point3d ptIns ;
m_BtlGeom.SortObjects( GDB_ID_ROOT, ptIns) ;
m_BtlGeom.SortObjects( m_BtlGeom.GetRawPartsGroup(), ptIns) ;
m_BtlGeom.SortObjects( m_BtlGeom.GetCompositesGroup(), ptIns) ;
}
return bOk ;
}
@@ -178,8 +214,10 @@ ImportBtl::ReadHeader( void)
//----------------------------------------------------------------------------
bool
ImportBtl::ReadGeneral( void)
ImportBtl::ReadGeneral( bool& bEnd)
{
// default file non finito
bEnd = false ;
// conteggio campi utili letti
int nRead = 0 ;
// leggo la prossima linea e verifico sia la sezione GENERAL
@@ -293,44 +331,14 @@ ImportBtl::ReadGeneral( void)
break ;
}
}
return false ;
}
//----------------------------------------------------------------------------
bool
ImportBtl::ReadRawPart( bool& bEnd)
{
string sLine ;
// leggo la prossima linea e verifico sia la sezione RAWPART
if ( ! m_theScanner.GetLine( sLine)) {
bEnd = true ;
return true ;
}
// verifico sia la sezione RAWPART
if ( sLine != SEC_RAWPART) {
m_theScanner.UngetLine( sLine) ;
bEnd = true ;
return true ;
}
// ciclo sulle linee
while ( m_theScanner.GetLine( sLine)) {
// se cambio sezione
if ( sLine[0] == '[') {
m_theScanner.UngetLine( sLine) ;
bEnd = false ;
return true ;
}
// ignoro tutto
}
// fine del file
bEnd = true ;
return true ;
return ( nRead > 0) ;
}
//----------------------------------------------------------------------------
bool
ImportBtl::ReadPart( bool& bEnd)
ImportBtl::ReadObject( ObjType nType, bool& bEnd)
{
string sLine ;
// leggo la prossima linea
@@ -338,8 +346,10 @@ ImportBtl::ReadPart( bool& bEnd)
bEnd = true ;
return true ;
}
// verifico sia la sezione PART
if ( sLine != SEC_PART) {
// verifico sia la sezione opportuna (PART, RAWPART o COMPOSITE)
if (( nType == PART && sLine != SEC_PART) ||
( nType == RAWPART && sLine != SEC_RAWPART) ||
( nType == COMPOSITE && sLine != SEC_COMPOSITE)) {
m_theScanner.UngetLine( sLine) ;
bEnd = true ;
return true ;
@@ -355,7 +365,8 @@ ImportBtl::ReadPart( bool& bEnd)
// ciclo sulle linee con i dati generali del pezzo
double dLength = 0, dHeight = 0, dWidth = 0 ;
bool bLength = false, bHeight = false, bWidth = false, bBox = false ;
int nTrasfCount = 0, nUID = 0 ;
int nTrasfCount = 0 ;
string sUID = "0" ;
while ( m_theScanner.GetLine( sLine)) {
// se cambio sezione
if ( sLine[0] == '[') {
@@ -368,6 +379,10 @@ ImportBtl::ReadPart( bool& bEnd)
string sKey, sVal ;
SplitFirst( sLine, ":", sKey, sVal) ;
switch ( FindPartKey( sKey)) {
case KEY_PART_TYPE : // tipo (solo per Compositi)
Trim( sVal, " \t\r\n\"") ;
m_BtlGeom.SetUserAttribute( UATD_PART, sKey, sVal) ;
break ;
case KEY_PART_SINGLEMEMBERNUMBER : // identificativo di produzione
{
int nProdNbr = 0 ;
@@ -487,16 +502,18 @@ ImportBtl::ReadPart( bool& bEnd)
}
break ;
case KEY_PART_UID : // UID istanza pezzo nella struttura
FromString( sVal, nUID) ;
Trim( sVal, " \t\r\n\"") ;
sUID = sVal ;
break ;
case KEY_PART_TRANSFORMATION : // matrice di trasformazione istanza pezzo nella struttura
{
Frame3d frRef ;
if ( ReadTransformation( sVal, frRef)) {
++ nTrasfCount ;
m_BtlGeom.AddPartTransformation( ToString( nUID), frRef) ;
if ( nType == PART)
m_BtlGeom.AddPartTransformation( sUID, frRef) ;
string sUIDKey = sPartKey[KEY_PART_UID] + ToString( nTrasfCount) ;
m_BtlGeom.SetUserAttribute( UATD_PART, sUIDKey, ToString( nUID)) ;
m_BtlGeom.SetUserAttribute( UATD_PART, sUIDKey, sUID) ;
string sTRFKey = sPartKey[KEY_PART_TRANSFORMATION] + ToString( nTrasfCount) ;
m_BtlGeom.SetUserAttribute( UATD_PART, sTRFKey, ToString( frRef)) ;
}
@@ -610,7 +627,7 @@ ImportBtl::ReadPart( bool& bEnd)
// interpreto le lavorazioni (processing)
bool bOk = true ;
for ( bool bProcEnd = false ; ! bProcEnd ;) {
if ( ! ReadProcess( bProcEnd)) {
if ( ! ReadProcess( nType != PART, bProcEnd)) {
// i log di errore sono già gestiti nella funzione chiamata
bOk = false ;
}
@@ -631,36 +648,6 @@ ImportBtl::ReadPart( bool& bEnd)
return bOk ;
}
//----------------------------------------------------------------------------
bool
ImportBtl::ReadComposite( bool& bEnd)
{
string sLine ;
// leggo la prossima linea
if ( ! m_theScanner.GetLine( sLine)) {
bEnd = true ;
return true ;
}
// verifico sia la sezione COMPOSITE
if ( sLine != SEC_COMPOSITE) {
bEnd = true ;
return true ;
}
// ciclo sulle linee
while ( m_theScanner.GetLine( sLine)) {
// se cambio sezione
if ( sLine[0] == '[') {
m_theScanner.UngetLine( sLine) ;
bEnd = false ;
return true ;
}
// ignoro tutto
}
bEnd = true ;
return true ;
}
//----------------------------------------------------------------------------
bool
ImportBtl::ReadTransformation( const string& sVal, Frame3d& frRef)
@@ -915,7 +902,7 @@ ImportBtl::ReadReferenceSide( const string& sVal, int& nSide, bool& bAlign)
//----------------------------------------------------------------------------
bool
ImportBtl::ReadProcess( bool& bProcEnd)
ImportBtl::ReadProcess( bool bObjRef, bool& bProcEnd)
{
bProcEnd = false ;
string sLine ;
@@ -952,16 +939,17 @@ ImportBtl::ReadProcess( bool& bProcEnd)
FromString( vsItem[1], nProc) ;
int nSide = 0 ;
FromString( vsItem[2], nSide) ;
if ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_TOP)
if ( nGroup != BTL_OBJECT_REF && ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_TOP))
nSide = BTL_SIDE_FRONT ;
bool bParams = false ;
INTVECTOR vnDPar ;
int nSPar ;
int nSPar = 0 ;
DBLVECTOR vdPar ;
string sPar ;
int nProcId = 0 ;
Frame3d frRef ;
STRVECTOR vsUAtt ;
string sUID ;
// ciclo sulle linee
while ( true) {
// se fine file, concludo
@@ -995,6 +983,17 @@ ImportBtl::ReadProcess( bool& bProcEnd)
}
break ;
case KEY_PROC_PROCESSPARAMETERS : // parametri
if ( nProc == BTL_OBJECT_REF) {
if ( ! GetParam( sVal, PAR_UID, sUID)) {
string sOut = " Error in GetProcessParams (" + sType + ") on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
SkipCurrProcess() ;
bProcEnd = false ;
return false ;
}
bParams = true ;
break ;
}
if ( ! m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar)) {
string sOut = " Error : Unknown Process (" + sType + ") on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
@@ -1036,13 +1035,27 @@ ImportBtl::ReadProcess( bool& bProcEnd)
break ;
}
}
// inserimento della lavorazione nel pezzo
if ( ! bParams ||
! m_BtlGeom.AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vnDPar, nSPar, vdPar, sPar, vsUAtt, m_theScanner.GetCurrLineNbr())) {
string sOut = " Error in AddProcess (" + sType + ") to Part " + m_BtlGeom.GetPartName() + " on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
bProcEnd = false ;
return false ;
// se riferimento ad oggetto
if ( nProc == BTL_OBJECT_REF) {
// inserimento del riferimento nel pezzo
if ( ! bParams ||
! m_BtlGeom.AddObjectRef( sUID, frRef)) {
string sOut = " Error in AddObjectRef (" + sType + ") to Part " + m_BtlGeom.GetPartName() + " on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
bProcEnd = false ;
return false ;
}
}
// altrimenti lavorazione
else {
// inserimento della lavorazione nel pezzo
if ( ! bParams ||
! m_BtlGeom.AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vnDPar, nSPar, vdPar, sPar, vsUAtt, m_theScanner.GetCurrLineNbr())) {
string sOut = " Error in AddProcess (" + sType + ") to Part " + m_BtlGeom.GetPartName() + " on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
bProcEnd = false ;
return false ;
}
}
bProcEnd = false ;
+6 -5
View File
@@ -26,19 +26,20 @@ class ImportBtl : public IImportBtl
public :
ImportBtl( void) ;
private :
enum ObjType { PART = 1, RAWPART = 2, COMPOSITE = 3} ;
private :
bool ReadHeader( void) ;
bool ReadGeneral( void) ;
bool ReadRawPart( bool& bEnd) ;
bool ReadPart( bool& bEnd) ;
bool ReadComposite( bool& bEnd) ;
bool ReadGeneral( bool& bEnd) ;
bool ReadObject( ObjType nType, bool& bEnd) ;
bool ReadTransformation( const std::string& sVal, Frame3d& frRef) ;
bool ReadOutline( void) ;
bool ReadAperture( void) ;
bool ReadColor( const std::string& sVal, Color& colRes) ;
bool ReadGrainDirection( const std::string& sVal, Vector3d& vtDir, bool& bAlign) ;
bool ReadReferenceSide( const std::string& sVal, int& nSide, bool& bAlign) ;
bool ReadProcess( bool& bProcEnd) ;
bool ReadProcess( bool bObjRef, bool& bProcEnd) ;
bool SkipCurrSection( void) ;
bool SkipCurrProcess( void) ;
bool GetProcessParams( const std::string& sText, const std::string& sProcType,
+97 -94
View File
@@ -42,7 +42,7 @@ IImportBtlx*
CreateImportBtlx( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPADV, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPADV, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportBtlx*> ( new(nothrow) ImportBtlx) ;
@@ -62,15 +62,18 @@ ImportBtlx::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
// inizializzo il gestore geometria pezzi Btl
int nFlatVertPos = 0 ;
if (( nFlag & EIBFLAG_TS3_POS) != 0)
if (( nFlag & EIBFLAG_OUTL_FLAT_POS) != 0)
nFlatVertPos = 4 ;
else if (( nFlag & EIBFLAG_TS3_POS) != 0)
nFlatVertPos = 3 ;
else if (( nFlag & EIBFLAG_FLAT_POS) != 0)
nFlatVertPos = 1 ;
else if (( nFlag & EIBFLAG_VERT_POS) != 0)
nFlatVertPos = 2 ;
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, bUseUAttr)) {
if ( ! m_BtlGeom.Init( pGDB, nFlatVertPos, bSpecialTrim, bTrimWithOutline, bUseUAttr)) {
LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init") ;
return false ;
}
@@ -348,7 +351,7 @@ ImportBtlx::ReadPart( pugi::xml_node node)
int nBlue = Clamp( it->attribute( "Blue").as_int(), 0, 255) ;
int nAlpha = Clamp( it->attribute( "Transparency").as_int(), 0, 255) ;
nAlpha = nAlpha * 100 / 255 ; // va scalato su 100 non su 255
colRes.Set( nRed, nGreen, nBlue, nAlpha) ;
bool bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, name, ToString( colRes)) ;
if ( ! bAddOk){
@@ -393,7 +396,7 @@ ImportBtlx::ReadPart( pugi::xml_node node)
}
// UserReferencePlane
else if ( name == "UserReferencePlanes") {
for ( pugi::xml_node_iterator itURefPlanes = it->begin() ; itURefPlanes != it->end() ; itURefPlanes ++ ) {
string nameURefPlanes = itURefPlanes->name() ;
if ( nameURefPlanes != "UserReferencePlane") {
@@ -405,55 +408,55 @@ ImportBtlx::ReadPart( pugi::xml_node node)
return false ;
}
}
// GrainDirection
else if ( name == "GrainDirection") {
Vector3d vtDir ;
if ( it->attribute( "X") == nullptr || it->attribute( "Y") == nullptr || it->attribute( "Z") == nullptr
|| it->attribute( "Align") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part : GrainDirection attribute missing") ;
return false ;
}
vtDir.x = it->attribute( "X").as_double() ;
vtDir.y = it->attribute( "Y").as_double() ;
vtDir.z = it->attribute( "Z").as_double() ;
string sAlign = it->attribute( "Align").value() ;
if ( sAlign == "yes")
sAlign = "1" ;
else if ( sAlign == "no")
sAlign = "0" ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : GrainDirection align is unknown") ;
return false ;
}
bool bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, "GRAINDIRECTION", ToString( vtDir) + ";" + sAlign) ;
if ( ! bAddOk){
LOG_ERROR( GetEExLogger(), " Error reading Part GrainDirection : m_BtlGeom.SetUserAttribute error") ;
return false ;
}
}
// MaterialClass
else if ( name == "MaterialClass") {
string sMaterial = it->attribute( "Group").value() ;
string sSpecification = it ->attribute( "Specification").value() ;
if ( find( svMaterials.begin(), svMaterials.end(), sMaterial) == svMaterials.end()) {
LOG_ERROR( GetEExLogger(), " Error reading Part : MaterialClass group is unknown") ;
return false ;
}
bool bAddOk = false ;
if ( sSpecification != "")
bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, "MATERIALTYPE", sMaterial + ": " + sSpecification) ;
else
bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, "MATERIALTYPE", sMaterial) ;
if ( ! bAddOk){
LOG_ERROR( GetEExLogger(), " Error reading Part : m_BtlGeom.SetUserAttribute error") ;
return false ;
}
}
// GrainDirection
else if ( name == "GrainDirection") {
Vector3d vtDir ;
if ( it->attribute( "X") == nullptr || it->attribute( "Y") == nullptr || it->attribute( "Z") == nullptr
|| it->attribute( "Align") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part : GrainDirection attribute missing") ;
return false ;
}
vtDir.x = it->attribute( "X").as_double() ;
vtDir.y = it->attribute( "Y").as_double() ;
vtDir.z = it->attribute( "Z").as_double() ;
string sAlign = it->attribute( "Align").value() ;
if ( sAlign == "yes")
sAlign = "1" ;
else if ( sAlign == "no")
sAlign = "0" ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : GrainDirection align is unknown") ;
return false ;
}
bool bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, "GRAINDIRECTION", ToString( vtDir) + ";" + sAlign) ;
if ( ! bAddOk){
LOG_ERROR( GetEExLogger(), " Error reading Part GrainDirection : m_BtlGeom.SetUserAttribute error") ;
return false ;
}
}
// MaterialClass
else if ( name == "MaterialClass") {
string sMaterial = it->attribute( "Group").value() ;
string sSpecification = it ->attribute( "Specification").value() ;
if ( find( svMaterials.begin(), svMaterials.end(), sMaterial) == svMaterials.end()) {
LOG_ERROR( GetEExLogger(), " Error reading Part : MaterialClass group is unknown") ;
return false ;
}
bool bAddOk = false ;
if ( sSpecification != "")
bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, "MATERIALTYPE", sMaterial + ": " + sSpecification) ;
else
bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, "MATERIALTYPE", sMaterial) ;
if ( ! bAddOk){
LOG_ERROR( GetEExLogger(), " Error reading Part : m_BtlGeom.SetUserAttribute error") ;
return false ;
}
}
// UserAttribute
else if ( name == "UserAttribute") {
if ( it->attribute( "Name") == nullptr || it->attribute( "")== nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part : UserAttribute attribute missing") ;
return false ;
@@ -468,40 +471,40 @@ ImportBtlx::ReadPart( pugi::xml_node node)
return false ;
}
}
// ReferenceSide
else if ( name == "ReferenceSide") {
// Controllo ci siano i required attributes
if ( it->attribute( "Side") == nullptr || it->attribute( "Align") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part : ReferenceSide attribute missing") ;
return false ;
}
// Controllo che i valori siano sensati
int nSide = it->attribute( "Side").as_int() ;
if ( nSide < 1 || nSide > 4){
LOG_ERROR( GetEExLogger(), " Error reading Part : ReferenceSide Side not valid") ;
return false ;
}
string sAlign = it->attribute( "Align").value() ;
if ( sAlign == "yes" )
sAlign = "1" ;
else if ( sAlign == "no")
sAlign = "0" ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : ReferenceSide Align not valid") ;
return false ;
}
bool bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, "REFERENCESIDE", to_string( nSide) + ";" + sAlign) ;
if ( ! bAddOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part : m_BtlGeom.SetUserAttribute error") ;
return false ;
}
}
// Shape
else if ( name == "Shape") {
if ( ! ReadShape( *it))
return false ;
}
// ReferenceSide
else if ( name == "ReferenceSide") {
// Controllo ci siano i required attributes
if ( it->attribute( "Side") == nullptr || it->attribute( "Align") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part : ReferenceSide attribute missing") ;
return false ;
}
// Controllo che i valori siano sensati
int nSide = it->attribute( "Side").as_int() ;
if ( nSide < 1 || nSide > 4){
LOG_ERROR( GetEExLogger(), " Error reading Part : ReferenceSide Side not valid") ;
return false ;
}
string sAlign = it->attribute( "Align").value() ;
if ( sAlign == "yes" )
sAlign = "1" ;
else if ( sAlign == "no")
sAlign = "0" ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : ReferenceSide Align not valid") ;
return false ;
}
bool bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, "REFERENCESIDE", to_string( nSide) + ";" + sAlign) ;
if ( ! bAddOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part : m_BtlGeom.SetUserAttribute error") ;
return false ;
}
}
// Shape
else if ( name == "Shape") {
if ( ! ReadShape( *it))
return false ;
}
}
// inserisco eventuali contorni liberi
@@ -1558,7 +1561,7 @@ bool
ImportBtlx::ReadShape( pugi::xml_node node)
{
pugi::xml_node FaceSet = node.child( "IndexedFaceSet") ;
if ( FaceSet == nullptr){
if ( FaceSet == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Shape: Indexed Face Set missing") ;
return false ;
}
@@ -1578,8 +1581,8 @@ ImportBtlx::ReadShape( pugi::xml_node node)
return false ;
}
vector<INTVECTOR> vFacesVertices ;
vector<Point3d> vPoints ;
INTMATRIX vFacesVertices ;
PNTVECTOR vPoints ;
size_t str_start = 0 ;
size_t str_end ;
@@ -1588,10 +1591,10 @@ ImportBtlx::ReadShape( pugi::xml_node node)
INTVECTOR vAux ; // vettore per salvare i vertici di una faccia
if ( sFacesVertices.back() != ' ')
sFacesVertices += " " ;
while( ( str_end = sFacesVertices.find( " ", str_start)) != string::npos ) {
while ( ( str_end = sFacesVertices.find( " ", str_start)) != string::npos ) {
int val = std::stoi( sFacesVertices.substr( str_start, str_end - str_start)) ;
str_start = str_end + 1 ;
if ( val == -1){ // delimiter -1 indica che una faccia è terminata
if ( val == -1) { // delimiter -1 indica che una faccia è terminata
vFacesVertices.push_back( vAux) ;
vAux.clear() ;
}
@@ -1605,17 +1608,17 @@ ImportBtlx::ReadShape( pugi::xml_node node)
DBLVECTOR vAux2 ; // vettore per salvare le coordinate di un punto
if ( sCoordPoints.back() != ' ')
sCoordPoints += " " ;
while( ( str_end = sCoordPoints.find( " ", str_start)) != string::npos ){
while( ( str_end = sCoordPoints.find( " ", str_start)) != string::npos ) {
double val = std::stod( sCoordPoints.substr( str_start, str_end - str_start)) ;
str_start = str_end + 1 ;
vAux2.push_back( val) ;
if ( vAux2.size() == 3){ // hai letto 3 coordinate quindi hai un punto
if ( vAux2.size() == 3) { // hai letto 3 coordinate quindi hai un punto
vPoints.push_back( Point3d( vAux2[0], vAux2[1], vAux2[2])) ;
vAux2.clear() ;
}
}
// se termino senza aver svuotato vAux2 significa che ho un punto con coordinate incomplete
if ( vAux2.size() != 0){
if ( vAux2.size() != 0) {
LOG_ERROR( GetEExLogger(), " Error reading Part Shape: Coordinates not defining a point") ;
return false ;
}
+19 -15
View File
@@ -818,7 +818,7 @@ ImportBtlx::ReadTenonParams( pugi::xml_node process, int& nGroup, int& nProc, in
{
// Identifico il processo con sigle usate nel btl
nProc = 50 ;
if ( process.attribute( "ReferencePlaneID") == nullptr){
if ( process.attribute( "ReferencePlaneID") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
@@ -831,7 +831,7 @@ ImportBtlx::ReadTenonParams( pugi::xml_node process, int& nGroup, int& nProc, in
// 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 ;
}
@@ -858,13 +858,13 @@ ImportBtlx::ReadTenonParams( pugi::xml_node process, int& nGroup, int& nProc, in
if ( sShape == "automatic" || sShape.empty())
vdPar[2] = 0 ;
else if ( sShape == "square")
vdPar[2] = 1;
vdPar[2] = 1 ;
else if ( sShape == "round")
vdPar[2] = 2;
vdPar[2] = 2 ;
else if ( sShape == "rounded")
vdPar[2] = 3;
vdPar[2] = 3 ;
else if ( sShape == "radius")
vdPar[2] = 4;
vdPar[2] = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon Shape is unknown") ;
return false ;
@@ -924,7 +924,7 @@ ImportBtlx::ReadMortiseParams( pugi::xml_node process, int& nGroup, int& nProc,
else if ( sShape == "radius")
vdPar[3] = 4;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon Shape is unknown") ;
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Moritise Shape is unknown") ;
return false ;
}
@@ -980,12 +980,14 @@ ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& n
// vdPar[] = Clamp( ReadProcessChild( process, "FlankAngle", vdPar[]), 5.0, 35.0) ;
string sShape = process.child( "Shape").text().get() ; // ~P04
if ( sShape == "round") {
if ( sShape == "round") {
vdPar[6] = 0.0 ; // P09
vdPar[9] = dWidth * cos( vdPar[7] * DEGTORAD) / ( 1 - sin( vdPar[7] * DEGTORAD)) ; // P12
}
else if ( sShape == "radius") {
vdPar[9] *= 2 ; // P12
else if ( sShape == "radius" || sShape == "rounded" || sShape == "square" ) {
if ( sShape != "radius") // P12
vdPar[9] = MILL_DEF_RAD ;
vdPar[9] *= 2 ;
vdPar[6] = dWidth - vdPar[9] * ( 1 - sin( vdPar[7] * DEGTORAD)) / cos( vdPar[7] * DEGTORAD) ; // P09
if ( vdPar[6] < 0 ) {
LOG_ERROR( GetEExLogger(), " Error : Dovetail tenon width")
@@ -993,7 +995,7 @@ ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& n
}
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon Shape is unknown") ;
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail Tenon Shape is unknown") ;
return false ;
}
@@ -1052,20 +1054,22 @@ ImportBtlx::ReadDovetailMortiseParams( pugi::xml_node process, int& nGroup, int&
}
string sShape = process.child( "Shape").text().get() ;
if ( sShape == "round") {
if ( sShape == "round") {
vdPar[7] = 0 ; // P09
vdPar[10] = dWidth * cos( vdPar[8] * DEGTORAD) / ( 1 - sin( vdPar[8] * DEGTORAD)) ; // P12
}
else if ( sShape == "radius") {
else if ( sShape == "radius" || sShape == "rounded" || sShape == "square") {
if ( sShape != "radius") // P12
vdPar[10] = MILL_DEF_RAD ;
vdPar[10] *= 2 ; // P12
vdPar[7] = dWidth - vdPar[10] * ( 1 - sin( vdPar[8] * DEGTORAD)) / cos( vdPar[8] * DEGTORAD) ; // P09
if ( vdPar[7] < 0 ) {
LOG_ERROR( GetEExLogger(), " Error : Dovetail mortise width") ;
return false ;
}
}
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Mortise Shape is unknown") ;
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail mortise Shape is unknown") ;
return false ;
}
+62 -40
View File
@@ -52,7 +52,7 @@ IImportCnc*
CreateImportCnc( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportCnc*> ( new(nothrow) ImportCnc) ;
@@ -139,6 +139,8 @@ ImportCnc::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup, int nFlag)
m_nCNC = CNC_OSAI ;
else if ( sFileExt == "EIA")
m_nCNC = CNC_MAZAK ;
else if ( sFileExt == "PIM")
m_nCNC = CNC_FAGOR ;
// ciclo di lettura delle linee
bool bOk = true ;
@@ -190,6 +192,14 @@ ImportCnc::ProcessLine( const string& sLine)
sMyLine.erase( nStart) ;
}
}
// se controllo SIEMENS elimino i cicli 800 e 832
else if ( m_nCNC == CNC_SIEMENS) {
size_t nStart = sMyLine.find( "CYCLE800") ;
if ( nStart == string::npos)
nStart = sMyLine.find( "CYCLE832") ;
if ( nStart != string::npos)
sMyLine.erase( nStart) ;
}
// divido la linea in parti
STRVECTOR vsTokens ;
@@ -310,6 +320,8 @@ ImportCnc::ParseRemark( const string& sLine)
m_nCNC = CNC_TPA ;
else if ( sCNC == "MAZAK")
m_nCNC = CNC_MAZAK ;
else if ( sCNC == "FAGOR")
m_nCNC = CNC_FAGOR ;
}
// cerco indicazione di posizione Home
string::size_type iFrom = sLine.find( "FROM/") ;
@@ -1117,25 +1129,20 @@ ImportCnc::VerifyArcCenter( const Vector3d& vtN)
if ( ! frOcs.Set( ORIG, vtN))
return A_ERROR ;
// porto i punti in questo riferimento
Point3d ptLloc = m_ptLast ;
ptLloc.ToLoc( frOcs) ;
Point3d ptNloc = m_ptNext ;
ptNloc.ToLoc( frOcs) ;
Point3d ptCloc = m_ptCen ;
ptCloc.ToLoc( frOcs) ;
Vector3d vtOloc = m_vtOffs ;
vtOloc.ToLoc( frOcs) ;
Point3d ptLloc = GetToLoc( m_ptLast, frOcs) ;
Point3d ptNloc = GetToLoc( m_ptNext, frOcs) ;
Point3d ptCloc = GetToLoc( m_ptCen, frOcs) ;
Vector3d vtOloc = GetToLoc( m_vtOffs, frOcs) ;
// verifico se circonferenza
int nRet = ( SqDistXY( ptLloc, ptNloc) > EPS_SMALL * EPS_SMALL) ? A_ARC : A_CIRC ;
// se controllo Fanuc, centro è sempre in relativo
if ( m_nCNC == CNC_FANUC) {
// se controllo Fanuc o Fagor, centro è sempre in relativo
if ( m_nCNC == CNC_FANUC || m_nCNC == CNC_FAGOR) {
// centro in relativo
Point3d ptCrl = ptCloc + ptLloc ;
double dRadLast = DistXY( ptLloc, ptCrl) ;
double dRadNext = DistXY( ptNloc, ptCrl) ;
if ( abs( dRadNext - dRadLast) < 10 * EPS_SMALL) {
m_ptCen = ptCrl ;
m_ptCen.ToGlob( frOcs) ;
if ( abs( dRadNext - dRadLast) < 100 * EPS_SMALL) {
m_ptCen = GetToGlob( ptCrl, frOcs) ;
return nRet ;
}
}
@@ -1143,19 +1150,28 @@ ImportCnc::VerifyArcCenter( const Vector3d& vtN)
else if ( m_bAbsCoord) {
// centro in assoluto
Point3d ptCas = ptCloc + vtOloc ;
double dRadLast = DistXY( ptLloc, ptCas) ;
double dRadNext = DistXY( ptNloc, ptCas) ;
if ( abs( dRadNext - dRadLast) < 10 * EPS_SMALL) {
double dRadCasLast = DistXY( ptLloc, ptCas) ;
double dRadCasNext = DistXY( ptNloc, ptCas) ;
// centro in relativo
Point3d ptCrl = ptCloc + ptLloc ;
double dRadCrlLast = DistXY( ptLloc, ptCrl) ;
double dRadCrlNext = DistXY( ptNloc, ptCrl) ;
// controlli con precisione più elevata
if ( abs( dRadCasNext - dRadCasLast) < 10 * EPS_SMALL) {
m_ptCen += m_vtOffs ;
return nRet ;
}
// centro in relativo
Point3d ptCrl = ptCloc + ptLloc ;
dRadLast = DistXY( ptLloc, ptCrl) ;
dRadNext = DistXY( ptNloc, ptCrl) ;
if ( abs( dRadNext - dRadLast) < 10 * EPS_SMALL) {
m_ptCen = ptCrl ;
m_ptCen.ToGlob( frOcs) ;
if ( abs( dRadCrlNext - dRadCrlLast) < 10 * EPS_SMALL) {
m_ptCen = GetToGlob( ptCrl, frOcs) ;
return nRet ;
}
// controlli con precisione più bassa
if ( abs( dRadCasNext - dRadCasLast) < 100 * EPS_SMALL) {
m_ptCen += m_vtOffs ;
return nRet ;
}
if ( abs( dRadCrlNext - dRadCrlLast) < 100 * EPS_SMALL) {
m_ptCen = GetToGlob( ptCrl, frOcs) ;
return nRet ;
}
}
@@ -1163,18 +1179,27 @@ ImportCnc::VerifyArcCenter( const Vector3d& vtN)
else {
// centro in relativo
Point3d ptCrl = ptCloc + ptLloc ;
double dRadLast = DistXY( ptLloc, ptCrl) ;
double dRadNext = DistXY( ptNloc, ptCrl) ;
if ( abs( dRadNext - dRadLast) < 10 * EPS_SMALL) {
m_ptCen = ptCrl ;
m_ptCen.ToGlob( frOcs) ;
return nRet ;
}
double dRadCrlLast = DistXY( ptLloc, ptCrl) ;
double dRadCrlNext = DistXY( ptNloc, ptCrl) ;
// centro in assoluto
Point3d ptCas = ptCloc + vtOloc ;
dRadLast = DistXY( ptLloc, ptCas) ;
dRadNext = DistXY( ptNloc, ptCas) ;
if ( abs( dRadNext - dRadLast) < 10 * EPS_SMALL) {
double dRadCasLast = DistXY( ptLloc, ptCas) ;
double dRadCasNext = DistXY( ptNloc, ptCas) ;
// controlli con precisione più elevata
if ( abs( dRadCrlNext - dRadCrlLast) < 10 * EPS_SMALL) {
m_ptCen = GetToGlob( ptCrl, frOcs) ;
return nRet ;
}
if ( abs( dRadCasNext - dRadCasLast) < 10 * EPS_SMALL) {
m_ptCen += m_vtOffs ;
return nRet ;
}
// controlli con precisione più bassa
if ( abs( dRadCrlNext - dRadCrlLast) < 100 * EPS_SMALL) {
m_ptCen = GetToGlob( ptCrl, frOcs) ;
return nRet ;
}
if ( abs( dRadCasNext - dRadCasLast) < 100 * EPS_SMALL) {
m_ptCen += m_vtOffs ;
return nRet ;
}
@@ -1193,12 +1218,9 @@ ImportCnc::SetCircC2PN( const Point3d& ptCen, const Point3d& ptStart, const Poin
if ( ! frOcs.Set( ORIG, vtN))
return false ;
// porto i punti in questo riferimento
Point3d ptCloc = ptCen ;
ptCloc.ToLoc( frOcs) ;
Point3d ptSloc = ptStart ;
ptSloc.ToLoc( frOcs) ;
Point3d ptNEloc = ptNearEnd ;
ptNEloc.ToLoc( frOcs) ;
Point3d ptCloc = GetToLoc( ptCen, frOcs) ;
Point3d ptSloc = GetToLoc( ptStart, frOcs) ;
Point3d ptNEloc = GetToLoc( ptNearEnd, frOcs) ;
// calcolo il cerchio in questo piano
double dRad = 0.5 * ( DistXY( ptCloc, ptSloc) + DistXY( ptCloc, ptNEloc)) ;
ptCloc.z = ptSloc.z ;
+1 -1
View File
@@ -71,7 +71,7 @@ class ImportCnc : public IImportCnc
return true ; }
private :
enum CncName { CNC_STD = 0, CNC_OSAI = 1, CNC_FANUC = 2, CNC_NUM = 3, CNC_SIEMENS = 4, CNC_TPA = 5, CNC_MAZAK = 6} ;
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 MoveType { RAPID = 0, LINE = 1, ARC_CW = 2, ARC_CCW = 3, ARC_MID_2D = 4, ARC_MID_3D = 5} ;
+1 -1
View File
@@ -62,7 +62,7 @@ IImportCsf*
CreateImportCsf( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportCsf*> ( new(nothrow) ImportCsf) ;
+1 -1
View File
@@ -30,7 +30,7 @@ IImportDxf*
CreateImportDxf( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportDxf*> ( new(nothrow) ImportDxf) ;
+1 -1
View File
@@ -28,7 +28,7 @@ IImportPnt*
CreateImportPnt( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportPnt*> ( new(nothrow) ImportPnt) ;
+1 -1
View File
@@ -34,7 +34,7 @@ IImportStl*
CreateImportStl( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportStl*> ( new(nothrow) ImportStl) ;
-1
View File
@@ -31,7 +31,6 @@
#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")