3 Commits

Author SHA1 Message Date
SaraP 91efbdc5df Merge commit 'afb30be43c1ccd54811fef1999a748c04ff7b251' into SaraP 2021-11-03 15:12:27 +01:00
SaraP 2a4d3b7947 EgtExchange :
- in export 3MF aggiunta esportazione texture
- in export 3MF migliorie varie.
2021-11-03 15:10:49 +01:00
SaraP c1e12ea3df Merge commit '91899b9a91f53812633cf5b13e912e62a8b3afbf' into SaraP 2021-11-03 13:05:04 +01:00
32 changed files with 663 additions and 5528 deletions
+20 -114
View File
@@ -45,31 +45,21 @@ BeamMgr::BeamMgr( void)
bool
BeamMgr::Init( IGeomDB* pGDB, int nFlag)
{
m_pGDB = pGDB ;
return SetFlag( nFlag) ;
}
//----------------------------------------------------------------------------
bool
BeamMgr::SetFlag( int nFlag)
{
// verifico il gestore di DB geometrico
if ( m_pGDB == nullptr)
// assegno il gestore di DB geometrico
if ( pGDB == nullptr)
return false ;
m_pGDB = pGDB ;
// inizializzo il gestore geometria pezzi Btl
int nFlatVertPos = 0 ;
if (( nFlag & EIBFLAG_OUTL_FLAT_POS) != 0)
nFlatVertPos = 4 ;
else if (( nFlag & EIBFLAG_TS3_POS) != 0)
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( m_pGDB, nFlatVertPos, bSpecialTrim, bTrimWithOutline, bUseUAttr)) {
if ( ! m_BtlGeom.Init( pGDB, nFlatVertPos, bSpecialTrim, bUseUAttr)) {
LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init")
return false ;
}
@@ -174,36 +164,10 @@ 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,
int nCrvId, int nCrv2Id, bool bUpdate)
const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt, bool bUpdate)
{
// Verifico validità GDB
if ( m_pGDB == nullptr)
@@ -222,26 +186,9 @@ BeamMgr::AddProcess( int nGroup, int nProc, int nSide, const string& sDes, int n
vdBtlPar[i] = vdPar[j-1] ;
}
sBtlPar = sPar ;
// 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 ;
}
// Aggiungo la feature
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() ;
@@ -254,8 +201,7 @@ 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,
int nCrvId, int nCrv2Id, bool bUpdate)
const Frame3d& frRef, const DBLVECTOR& vdPar, const string& sPar, const STRVECTOR& vsUAtt, bool bUpdate)
{
// Verifico validità GDB
if ( m_pGDB == nullptr)
@@ -263,11 +209,10 @@ 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) ;
// accetto feature normali e Outline/Aperture
if ( ! m_BtlGeom.SetPart( nPartId) || ( m_BtlGeom.GetCurrProcsLayId() != nLayId && m_BtlGeom.GetCurrOutsLayId() != nLayId))
if ( ! m_BtlGeom.SetPart( nPartId) || m_BtlGeom.GetCurrProcsLayId() != nLayId)
return GDB_ID_NULL ;
// Aggiungo il nuovo processo modificato
int nNewId = AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vdPar, sPar, vsUAtt, nCrvId, nCrv2Id, false) ;
int nNewId = AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vdPar, sPar, vsUAtt, false) ;
if ( nNewId == GDB_ID_NULL)
return GDB_ID_NULL ;
// Sposto le geometrie inserite appena sopra le vecchie (mantenendo l'ordine relativo nel gruppo)
@@ -312,8 +257,7 @@ BeamMgr::EraseProcess( int nGeomId, bool bUpdate)
// Recupero il pezzo di appartenenza
int nLayId = m_pGDB->GetParentId( nGeomId) ;
int nPartId = m_pGDB->GetParentId( nLayId) ;
// accetto feature normali e Outline/Aperture
if ( ! m_BtlGeom.SetPart( nPartId) || ( m_BtlGeom.GetCurrProcsLayId() != nLayId && m_BtlGeom.GetCurrOutsLayId() != nLayId))
if ( ! m_BtlGeom.SetPart( nPartId) || m_BtlGeom.GetCurrProcsLayId() != nLayId)
return false ;
// Cancello eventuali geometrie aggiuntive
INTVECTOR vAdj ;
@@ -327,18 +271,6 @@ 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) {
@@ -387,13 +319,6 @@ 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() ;
@@ -500,7 +425,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, false)) ;
PtrOwner<ISurfTriMesh> pSTM( GetSurfTriMeshBox( dDimX, dDimY, dDimz, true)) ;
if ( IsNull( pSTM))
return false ;
pSTM->Translate( ptMin - ORIG) ;
@@ -553,31 +478,12 @@ 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) {
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 ;
}
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) ;
}
+2 -6
View File
@@ -21,7 +21,6 @@ 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 ;
@@ -30,13 +29,10 @@ 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,
int nCrvId, int nCrv2Id, bool bUpdate = true) override ;
const Frame3d& frRef, const DBLVECTOR& vdPar, const std::string& sPar, const STRVECTOR& vsUAtt, 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,
int nCrvId, int nCrv2Id, bool bUpdate = true) override ;
const Frame3d& frRef, const DBLVECTOR& vdPar, const std::string& sPar, const STRVECTOR& vsUAtt, 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,7 +146,6 @@ enum nPartKey {
KEY_PART_STOREYTYPE,
KEY_PART_TIMBERGRADE,
KEY_PART_TRANSFORMATION,
KEY_PART_TYPE,
KEY_PART_UID,
KEY_PART_USERATTRIBUTE,
KEY_PART_WIDTH,
@@ -187,7 +186,6 @@ static const std::array<std::string,KEY_PART_ZZZ> sPartKey = {
"STOREYTYPE",
"TIMBERGRADE",
"TRANSFORMATION",
"TYPE",
"UID",
"USERATTRIBUTE",
"WIDTH"
@@ -255,4 +253,3 @@ 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" ;
+12 -254
View File
@@ -24,7 +24,6 @@
#include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <unordered_map>
using namespace std ;
@@ -35,20 +34,17 @@ string BtlGeom::m_sBtlAuxDir ;
BtlGeom::BtlGeom( void)
{
m_pGDB = nullptr ;
m_nFlatVertPos = 0 ;
m_nFlatVertPos = false ;
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, 15) ;
m_ProcsOffCol = Color( 160, 160, 160, 100) ;
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 ;
@@ -62,7 +58,7 @@ BtlGeom::BtlGeom( void)
//----------------------------------------------------------------------------
bool
BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bTrimWithOutline, bool bUseUAttr)
BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bUseUAttr)
{
// salvo puntatore a DB geometrico
m_pGDB = pGDB ;
@@ -71,7 +67,6 @@ BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bTrimWit
// 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) ;
@@ -81,9 +76,6 @@ BtlGeom::Init( IGeomDB* pGDB, int nFlatVertPos, bool bSpecialTrim, bool bTrimWit
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 ;
}
@@ -247,17 +239,6 @@ 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
@@ -376,7 +357,6 @@ 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 :
@@ -402,7 +382,7 @@ BtlGeom::AddPartBox( double dLength, double dHeight, double dWidth)
if ( IsNull( pText))
return false ;
int nSide = BTL_SIDE_TOP ;
if (( m_nFlatVertPos == 1 || m_nFlatVertPos == 4) && m_vtDim.z > m_vtDim.y + EPS_SMALL)
if ( m_nFlatVertPos == 1 && 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 ;
@@ -462,7 +442,7 @@ BtlGeom::AdjustPartFlatOrVertPos( void)
// dimensioni pezzo
Vector3d vtDim = b3Part.GetMax() - b3Part.GetMin() ;
// se richiesto piatto ed è in verticale, ruoto
if (( m_nFlatVertPos == 1 || m_nFlatVertPos == 4) && vtDim.z > vtDim.y + EPS_SMALL) {
if ( m_nFlatVertPos == 1 && 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) ;
}
@@ -535,24 +515,7 @@ 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, 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
m_pGDB->SetInfo( nId, "!SOU", m_nPartId) ;
// nascondo e blocco
m_pGDB->SetStatus( nId, GDB_ST_OFF) ;
m_pGDB->SetMode( nId, GDB_MD_LOCKED) ;
@@ -789,30 +752,22 @@ 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::SortObjects( int nGroupId, Point3d& ptIns)
BtlGeom::SortParts( void)
{
// 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( nGroupId) ;
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 || nGroupId != GDB_ID_ROOT)) {
if ( m_pGDB->GetCalcLevel( nPartId, nLev) && nLev == GDB_LV_USER) {
int nSN = 0 ;
m_pGDB->GetInfo( nPartId, IKEY_PROD_NBR, nSN) ;
vIdSN.emplace_back( nPartId, nSN) ;
@@ -825,13 +780,14 @@ BtlGeom::SortObjects( int nGroupId, Point3d& ptIns)
{ 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, nGroupId, GDB_LAST_SON) ;
m_pGDB->Relocate( vIdSN[i].first, GDB_ID_ROOT, 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 + PART_OFFSET, 0) ;
ptIns += Vector3d( 0, b3Part.GetMax().y - b3Part.GetMin().y + 300, 0) ;
}
return true ;
@@ -874,201 +830,3 @@ 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 ;
}
+20 -42
View File
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2022
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : BtlGeom.h Data : 04.04.22 Versione : 2.4d25
// File : BtlGeom.h Data : 26.08.15 Versione : 1.6h5
// 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 bTrimWithOutline, bool bUseUAttr) ;
bool Init( IGeomDB* pGDB, int nFlatPos, bool bSpecialTrim, bool bUseUAttr) ;
bool CreatePart( void) ;
bool SetPart( int nPartId) ;
bool ErasePart( void) ;
@@ -47,53 +47,48 @@ 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 SortObjects( int nGroupId, Point3d& ptIns) ;
bool SortParts( void) ;
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( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints) ;
const INTVECTOR& vnDPar, DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddShapeBTLX( std::vector<INTVECTOR> vFacesVertices, std::vector<Point3d> vPoints) ;
public : // Data
private :
bool CreateInfoGroup( void) ;
bool CreateAssemblyGroup( void) ;
bool ReadUserAttribute( const std::string& sString, std::string& sKey, std::string& sVal) ;
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 ;
@@ -101,17 +96,6 @@ 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
@@ -169,7 +153,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, const Frame3d& frRef,
bool AddDrill( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
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) ;
@@ -179,7 +163,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, const Frame3d& frRef,
bool AddDovetailMortise( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
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) ;
@@ -195,8 +179,6 @@ 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,
@@ -217,11 +199,10 @@ class BtlGeom
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
bool AddVariant( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId,
const INTVECTOR& vnDPar, const DBLVECTOR& vdPar, const STRVECTOR& vsUAtt) ;
ICurveComposite* GetFreeContourCurve( int nProcId, const Frame3d& frRef, bool bOnlyStartOk = false) ;
ICurveComposite* GetFreeContourCurve( int nProcId, const Frame3d& frRef) ;
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) ;
@@ -259,9 +240,8 @@ class BtlGeom
private :
IGeomDB* m_pGDB ;
int m_nFlatVertPos ; // flag per posizionamento pezzi (0=come sono, 1=di piatto, 2=in verticale, 3=ruotato 90deg, 4=da outline o piatto)
int m_nFlatVertPos ; // flag per posizionamento pezzi (0=come sono, 1=di piatto, 2=in verticale)
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
@@ -271,8 +251,6 @@ 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
+2 -16
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2022
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : BtlGeomCoStru.h Data : 27.02.22 Versione : 2.4b3
// File : BtlGeomCoStru.h Data : 25.08.15 Versione : 1.6h5
// Contenuto : Costanti e strutture per la classe BtlGeom.
//
//
@@ -22,10 +22,6 @@
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" ;
@@ -64,11 +60,8 @@ 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" ;
@@ -77,7 +70,6 @@ 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
@@ -108,18 +100,12 @@ 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_" ;
+27 -434
View File
@@ -77,164 +77,8 @@ 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) ;
@@ -258,7 +102,6 @@ BtlGeom::AddPartOutline( int nSide, int nCrvId, const DBLVECTOR& vdPar, const ST
// identificativi di geometrie ausiliarie
SetAuxId( nId, {nTId}) ;
m_nProcId = nId ;
return true ;
}
@@ -305,14 +148,8 @@ 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) ;
@@ -339,135 +176,6 @@ 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)
@@ -672,55 +380,18 @@ BtlGeom::TrimOutlineWithApertures( void)
bool
BtlGeom::TrimOutlineWithProcesses( void)
{
// 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 nProcId = m_pGDB->GetFirstInGroup( m_nProcsId) ;
while ( nProcId != GDB_ID_NULL) {
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 ;
// 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) ;
// 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) ;
}
return true ;
@@ -752,12 +423,8 @@ 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) && nAux != 0) {
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_AUXID, nAux)) {
const ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId)) ;
const ISurfTriMesh* pAux = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId + nAux)) ;
if ( pStm != nullptr && pAux != nullptr) {
@@ -767,12 +434,8 @@ BtlGeom::TrimOutline( int nProcSurfId)
return TrimOutline( pTrim) ;
}
}
return false ;
}
// Recupero la superficie del processo di lavorazione (eventualmente l'originale)
int nOrigId = 0 ;
if ( m_pGDB->GetInfo( nProcSurfId, IKEY_ORIGID, nOrigId))
nProcSurfId += nOrigId ;
// Recupero la superficie del processo di lavorazione
const ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId)) ;
if ( pStm == nullptr)
return false ;
@@ -1212,7 +875,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 = 5.0 ;
const double EPS_OUT_NEAR = 1.0 ;
double dL = GetSideLength( nSide) ;
double dW = GetSideWidth( nSide) ;
return ( ( ptP.x > - EPS_OUT_NEAR && ptP.x < EPS_IN_NEAR) ||
@@ -1278,103 +941,33 @@ 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( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints)
BtlGeom::AddShapeBTLX( vector<INTVECTOR> vFacesVertices, vector<Point3d> vPoints)
{
PtrOwner<ISurfTriMesh> pShape( CreateSurfTriMesh()) ;
ISurfTriMesh * Shape = 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
PtrOwner<ICurveComposite> pCurveCompo( CreateCurveComposite()) ;
pCurveCompo->AddPoint( vPoints[vVertices[0]]) ;
// Creo il contorno della faccia
ICurveComposite* CurveCompo = CreateCurveComposite() ;
CurveCompo->AddPoint( vPoints[vVertices[0]]) ;
for ( size_t i = 1 ; i != vVertices.size() ; i++)
pCurveCompo->AddLine( vPoints[vVertices[i]]) ;
pCurveCompo->AddLine( vPoints[vVertices[0]]) ;
CurveCompo->AddLine( vPoints[vVertices[i]]) ;
CurveCompo->AddLine( vPoints[vVertices[0]]) ;
if ( it == vFacesVertices.begin() || ! pShape->IsValid())
pShape.Set( GetSurfTriMeshByFlatContour( pCurveCompo)) ;
if ( it == vFacesVertices.begin() || Shape == nullptr)
Shape = GetSurfTriMeshByFlatContour( CurveCompo) ;
else {
PtrOwner<ISurfTriMesh> pSurf( GetSurfTriMeshByFlatContour( pCurveCompo)) ;
// controllo che pCurveCompo racchiuda veramente una superficie
if ( ! IsNull( pSurf)) {
if ( ! pShape->DoSewing( * pSurf)) {
ISurfTriMesh * surf = GetSurfTriMeshByFlatContour( CurveCompo) ;
// controllo che CurveCompo racchiuda veramente una superficie
if ( surf != nullptr) {
if ( ! Shape->DoSewing( * surf)){
LOG_ERROR( GetEExLogger(), " Error reading Part Shape: stm.DoSewing error")
return false ;
}
@@ -1382,7 +975,7 @@ BtlGeom::AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints
}
}
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nPartId + 3, Release( pShape)) ; // salvo in outline
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nPartId + 3, Shape) ; // salvo in outline
if ( nId == GDB_ID_NULL)
return false ;
m_pGDB->SetName( nId, "Shape") ;
+124 -784
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -19,4 +19,3 @@
//-----------------------------------------------------------------------------
ILogger* GetEExLogger( void) ;
const std::string& GetEExKey( void) ;
bool GetEExNetHwKey( void) ;
-15
View File
@@ -89,7 +89,6 @@ GetEExLogger( void)
//-----------------------------------------------------------------------------
static std::string s_sKey ;
static bool s_bNetHwKey = false ;
//-----------------------------------------------------------------------------
void
@@ -98,23 +97,9 @@ 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.
+2 -6
View File
@@ -29,7 +29,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v120_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>v141_xp</PlatformToolset>
<PlatformToolset>v120_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -130,7 +130,6 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -199,7 +198,6 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -241,7 +239,6 @@ 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" />
@@ -278,7 +275,6 @@ 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,9 +126,6 @@
<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">
@@ -206,9 +203,6 @@
<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">
+179 -67
View File
@@ -26,6 +26,8 @@
#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 ;
@@ -35,7 +37,7 @@ IExport3MF*
CreateExport3MF( void)
{
// verifico la chiave e le opzioni
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IExport3MF*> ( new(nothrow) Export3MF) ;
@@ -52,12 +54,13 @@ 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)) {
@@ -65,44 +68,54 @@ 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( pGDB)) ;
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_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
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 ;
}
// scrivo il file
PWriter writer = m_model->QueryWriter( "3mf") ;
writer->WriteToFile( sFile) ;
return true ;
}
@@ -118,12 +131,8 @@ 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 ;
// recupero il riferimento globale dell'oggetto
Frame3d frFrame ;
if ( ! iIter.GetGlobFrame( frFrame))
return false ;
if ( pGeoObj->GetType() != SRF_TRIMESH && pGeoObj->GetType() != SRF_FLATRGN)
return true ;
// recupero il livello dell'oggetto
int nLev = GDB_LV_USER ;
iIter.GetCalcLevel( nLev) ;
@@ -134,22 +143,15 @@ Export3MF::ExportObject( const IGdbIterator& iIter)
int nStat = GDB_ST_ON ;
iIter.GetCalcStatus( nStat) ;
// se il filtro lo abilita
if ( TestFilter( nLev, nMode, nStat)) {
// recupero eventuale nome
string sName ;
if ( ! iIter.GetName( sName))
sName = ToString( iIter.GetId()) ;
// recupero il colore
Color cCol ;
bool bCol = GetColor( cCol, iIter.GetGDB(), iIter.GetId()) ;
if ( TestFilter( nLev, nMode, nStat)) {
// emetto l'oggetto
switch ( pGeoObj->GetType()) {
case SRF_TRIMESH :
if ( ! ExportSTM( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr))
if ( ! ExportSTM( iIter.GetId(), GetSurfTriMesh( pGeoObj)))
return false ;
break ;
case SRF_FLATRGN :
if ( ! ExportSFR( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr))
if ( ! ExportSFR( iIter.GetId(), GetSurfFlatRegion( pGeoObj)))
return false ;
break ;
default :
@@ -188,35 +190,43 @@ Export3MF::TestFilter( int nLev, int nMode, int nStat)
//----------------------------------------------------------------------------
bool
Export3MF::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol)
Export3MF::ExportSFR( const int& nId, const ISurfFlatRegion* pSFR)
{
// verifico oggetto
const ISurfFlatRegion* pSFR = GetSurfFlatRegion( pGeoObj) ;
if ( pSFR == nullptr)
if ( pSFR == nullptr || nId == GDB_ID_NULL)
return false ;
// ricavo la trimesh equivalente
const ISurfTriMesh* pStm = pSFR->GetAuxSurf() ;
return ExportSTM( sName, pStm, frFrame, pCol) ;
return ExportSTM( nId, pStm) ;
}
//----------------------------------------------------------------------------
bool
Export3MF::ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol)
Export3MF::ExportSTM( const int& nId, const ISurfTriMesh* pSTM)
{
// verifico oggetto
const ISurfTriMesh* pSTM = GetSurfTriMesh( pGeoObj) ;
if ( pSTM == nullptr)
return false ;
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) ;
// 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
@@ -224,40 +234,44 @@ Export3MF::ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Fr
int k = 0 ;
for ( int i = 0 ; i < pSTM->GetTriangleSize() ; i++) {
int nIdVert[3] ;
// se il triangolo non è valido passo al successivo
if ( ! pSTM->GetTriangle( i, nIdVert))
continue ;
// assegno gli indici dei vertici
if ( ! pSTM->GetTriangle( i, nIdVert))
continue ; // se il triangolo non è valido passo al successivo
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) ;
// assegno il colore
if ( pCol != nullptr) {
Lib3MF_uint32 nColId = ColorHandler3MF( pCol) ;
// texture
if ( ! ExportTexture( nId, pSTM, meshObject))
return false ;
// assegno il colore
Color cCol ;
if ( GetColor( nId, cCol)) {
Lib3MF_uint32 nColId = ColorHandler3MF( cCol) ;
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)
@@ -280,26 +294,26 @@ Export3MF::ScanGroup( const IGdbIterator& iIter)
//----------------------------------------------------------------------------
bool
Export3MF::GetColor( Color& pCol, const IGeomDB * pGDB, const int& nId)
Export3MF::GetColor( const int& nId, Color& cCol)
{
if ( nId == GDB_ID_NULL)
return false ;
if ( ! pGDB->GetMaterial( nId, pCol))
if ( ! m_pGDB->GetMaterial( nId, cCol))
// se fallisce cerco il colore del parent
return GetColor( pCol, pGDB, pGDB->GetParentId( nId)) ;
return GetColor( m_pGDB->GetParentId( nId), cCol) ;
return true ;
}
//----------------------------------------------------------------------------
Lib3MF_uint32
Export3MF::ColorHandler3MF( const Color* pCol)
Export3MF::ColorHandler3MF( const Color& cCol)
{
PColorGroup pColorGrp = m_model->GetColorGroupByID( 1) ;
// converto il colore nel formato usato da 3MF
Lib3MF_uint8 nAlpha = ( int)( pCol->GetIntAlpha() * 2.55 + 0.5) ;
sColor cCol3mf = m_wrapper->RGBAToColor( pCol->GetIntRed(), pCol->GetIntGreen(), pCol->GetIntBlue(), nAlpha) ;
Lib3MF_uint8 nAlpha = ( int)( cCol.GetIntAlpha() * 2.55 + 0.5) ;
sColor cCol3mf = m_wrapper->RGBAToColor( cCol.GetIntRed(), cCol.GetIntGreen(), cCol.GetIntBlue(), nAlpha) ;
// verifico se il colore è già presente nel colorgroup
UINTVECTOR vColorIdx ;
pColorGrp->GetAllPropertyIDs( vColorIdx) ;
@@ -307,8 +321,106 @@ Export3MF::ColorHandler3MF( const Color* pCol)
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 ;
}
+14 -6
View File
@@ -16,8 +16,11 @@
#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
@@ -30,16 +33,21 @@ 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 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) ;
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) ;
private :
private :
IGeomDB* m_pGDB ;
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 ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
if ( ! 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 ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
if ( ! 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 ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_EXPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IExportSvg*> ( new(nothrow) ExportSvg) ;
-3296
View File
File diff suppressed because it is too large Load Diff
-94
View File
@@ -1,94 +0,0 @@
//----------------------------------------------------------------------------
// EgalWare 2022-2022
//----------------------------------------------------------------------------
// File : ExportThreeJS.h Data : 05.07.22 Versione : 2.4j1
// Contenuto : Dichiarazione della classe ExportThreeJS.
//
//
//
// Modifiche : 19.10.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 CreateFolderSpace( const std::string& SFileName, const std::string& sUserPath, const std::string& sLibPath) ;
bool HeadAmbient( IEGrScene* pScene, IGeomDB* pGDB, int nId) ;
bool FinishAmbient() ;
bool CompressAll( const std::string& sFile) ;
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) ;
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
std::string m_sUdm ; // udm della scena
Point3d m_ptMin ; // punto minimo del box3d
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)
double m_dCameraPhi ; // [0,180] angolo phi in coordinate polari della telecamera
double m_dCameraTheta ; // [0, 360) angolo Theta in coordinate polari della telecamera
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
// Parametri...
bool m_bShowGrid = true ; // se esportare o meno la griglia dalla scena
bool m_bUdm_mm ; // se l'unità di misura è in mm
std::string m_sPath ; // Path aggiuntivo dove salvare il file (il vero path è nel LUA)
public:
static std::string m_sThreeJSAuxDir ; // direttorio librerie
};
+1 -82
View File
@@ -30,7 +30,7 @@ IImport3MF*
CreateImport3MF( void)
{
// verifico la chiave e le opzioni
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImport3MF*> ( new( nothrow) Import3MF) ;
@@ -222,86 +222,6 @@ 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 ;
@@ -372,7 +292,6 @@ Import3MF::ReadMesh( const Lib3MF_uint32& nId, ATTRVECTOR& vAttr, sTransform& sT
}
return true ;
#endif
}
//-----------------------------------------------------------------------------------
+96 -109
View File
@@ -39,7 +39,7 @@ IImportBtl*
CreateImportBtl( void)
{
// verifico la chiave e le opzioni
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPADV, GetEExLogger()))
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPADV, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportBtl*> ( new(nothrow) ImportBtl) ;
@@ -67,18 +67,15 @@ ImportBtl::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
// inizializzo il gestore geometria pezzi Btl
int nFlatVertPos = 0 ;
if (( nFlag & EIBFLAG_OUTL_FLAT_POS) != 0)
nFlatVertPos = 4 ;
else if (( nFlag & EIBFLAG_TS3_POS) != 0)
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, bTrimWithOutline, bUseUAttr)) {
if ( ! m_BtlGeom.Init( pGDB, nFlatVertPos, bSpecialTrim, bUseUAttr)) {
LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init")
return false ;
}
@@ -94,41 +91,25 @@ ImportBtl::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
}
// lettura generalità
bool bEnd ;
if ( ! ReadGeneral( bEnd)) {
if ( ! ReadGeneral()) {
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 ;) {
// leggo un grezzo
if ( ! ReadObject( RAWPART, bEnd)) {
// i log di errore sono già gestiti nella funzione chiamata
if ( ! ReadRawPart( bEnd)) {
string sOut = " Error (ReadRawPart) on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
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 ;) {
// leggo un pezzo
if ( ! ReadObject( PART, bEnd)) {
if ( ! ReadPart( bEnd)) {
// i log di errore sono già gestiti nella funzione chiamata
bOk = false ;
}
@@ -136,34 +117,17 @@ ImportBtl::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
// ciclo sui compositi
for ( bool bEnd = false ; ! bEnd ;) {
// leggo un composito
if ( ! ReadObject( COMPOSITE, bEnd)) {
// i log di errore sono già gestiti nella funzione chiamata
if ( ! ReadComposite( bEnd)) {
string sOut = " Error on line " + ToString( m_theScanner.GetCurrLineNbr()) ;
LOG_ERROR( GetEExLogger(), sOut.c_str())
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 ;
}
}
}
// aggiusto riferimenti per grezzi e per compositi
m_BtlGeom.AdjustRefForRawParts() ;
m_BtlGeom.AdjustRefForComposites() ;
// eventuale ordinamento degli oggetti secondo SN
// eventuale ordinamento dei pezzi secondo SN
bool bSort = (( nFlag & EIBFLAG_SORT) != 0) ;
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) ;
}
if ( bSort)
m_BtlGeom.SortParts() ;
return bOk ;
}
@@ -214,10 +178,8 @@ ImportBtl::ReadHeader( void)
//----------------------------------------------------------------------------
bool
ImportBtl::ReadGeneral( bool& bEnd)
ImportBtl::ReadGeneral( void)
{
// default file non finito
bEnd = false ;
// conteggio campi utili letti
int nRead = 0 ;
// leggo la prossima linea e verifico sia la sezione GENERAL
@@ -331,14 +293,44 @@ ImportBtl::ReadGeneral( bool& bEnd)
break ;
}
}
// fine del file
bEnd = true ;
return ( nRead > 0) ;
return false ;
}
//----------------------------------------------------------------------------
bool
ImportBtl::ReadObject( ObjType nType, bool& bEnd)
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
}
bEnd = true ;
return true ;
}
//----------------------------------------------------------------------------
bool
ImportBtl::ReadPart( bool& bEnd)
{
string sLine ;
// leggo la prossima linea
@@ -346,10 +338,8 @@ ImportBtl::ReadObject( ObjType nType, bool& bEnd)
bEnd = true ;
return true ;
}
// 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)) {
// verifico sia la sezione PART
if ( sLine != SEC_PART) {
m_theScanner.UngetLine( sLine) ;
bEnd = true ;
return true ;
@@ -365,8 +355,7 @@ ImportBtl::ReadObject( ObjType nType, 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 ;
string sUID = "0" ;
int nTrasfCount = 0, nUID = 0 ;
while ( m_theScanner.GetLine( sLine)) {
// se cambio sezione
if ( sLine[0] == '[') {
@@ -379,10 +368,6 @@ ImportBtl::ReadObject( ObjType nType, 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 ;
@@ -502,18 +487,16 @@ ImportBtl::ReadObject( ObjType nType, bool& bEnd)
}
break ;
case KEY_PART_UID : // UID istanza pezzo nella struttura
Trim( sVal, " \t\r\n\"") ;
sUID = sVal ;
FromString( sVal, nUID) ;
break ;
case KEY_PART_TRANSFORMATION : // matrice di trasformazione istanza pezzo nella struttura
{
Frame3d frRef ;
if ( ReadTransformation( sVal, frRef)) {
++ nTrasfCount ;
if ( nType == PART)
m_BtlGeom.AddPartTransformation( sUID, frRef) ;
m_BtlGeom.AddPartTransformation( ToString( nUID), frRef) ;
string sUIDKey = sPartKey[KEY_PART_UID] + ToString( nTrasfCount) ;
m_BtlGeom.SetUserAttribute( UATD_PART, sUIDKey, sUID) ;
m_BtlGeom.SetUserAttribute( UATD_PART, sUIDKey, ToString( nUID)) ;
string sTRFKey = sPartKey[KEY_PART_TRANSFORMATION] + ToString( nTrasfCount) ;
m_BtlGeom.SetUserAttribute( UATD_PART, sTRFKey, ToString( frRef)) ;
}
@@ -627,7 +610,7 @@ ImportBtl::ReadObject( ObjType nType, bool& bEnd)
// interpreto le lavorazioni (processing)
bool bOk = true ;
for ( bool bProcEnd = false ; ! bProcEnd ;) {
if ( ! ReadProcess( nType != PART, bProcEnd)) {
if ( ! ReadProcess( bProcEnd)) {
// i log di errore sono già gestiti nella funzione chiamata
bOk = false ;
}
@@ -648,6 +631,36 @@ ImportBtl::ReadObject( ObjType nType, 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)
@@ -902,7 +915,7 @@ ImportBtl::ReadReferenceSide( const string& sVal, int& nSide, bool& bAlign)
//----------------------------------------------------------------------------
bool
ImportBtl::ReadProcess( bool bObjRef, bool& bProcEnd)
ImportBtl::ReadProcess( bool& bProcEnd)
{
bProcEnd = false ;
string sLine ;
@@ -939,17 +952,16 @@ ImportBtl::ReadProcess( bool bObjRef, bool& bProcEnd)
FromString( vsItem[1], nProc) ;
int nSide = 0 ;
FromString( vsItem[2], nSide) ;
if ( nGroup != BTL_OBJECT_REF && ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_TOP))
if ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_TOP)
nSide = BTL_SIDE_FRONT ;
bool bParams = false ;
INTVECTOR vnDPar ;
int nSPar = 0 ;
int nSPar ;
DBLVECTOR vdPar ;
string sPar ;
int nProcId = 0 ;
Frame3d frRef ;
STRVECTOR vsUAtt ;
string sUID ;
// ciclo sulle linee
while ( true) {
// se fine file, concludo
@@ -983,17 +995,6 @@ ImportBtl::ReadProcess( bool bObjRef, 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())
@@ -1035,27 +1036,13 @@ ImportBtl::ReadProcess( bool bObjRef, bool& bProcEnd)
break ;
}
}
// 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 ;
}
// 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 ;
+5 -6
View File
@@ -26,20 +26,19 @@ class ImportBtl : public IImportBtl
public :
ImportBtl( void) ;
private :
enum ObjType { PART = 1, RAWPART = 2, COMPOSITE = 3} ;
private :
bool ReadHeader( void) ;
bool ReadGeneral( bool& bEnd) ;
bool ReadObject( ObjType nType, bool& bEnd) ;
bool ReadGeneral( void) ;
bool ReadRawPart( bool& bEnd) ;
bool ReadPart( bool& bEnd) ;
bool ReadComposite( 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 bObjRef, bool& bProcEnd) ;
bool ReadProcess( bool& bProcEnd) ;
bool SkipCurrSection( void) ;
bool SkipCurrProcess( void) ;
bool GetProcessParams( const std::string& sText, const std::string& sProcType,
+94 -97
View File
@@ -42,7 +42,7 @@ IImportBtlx*
CreateImportBtlx( void)
{
// verifico la chiave e le opzioni
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPADV, GetEExLogger()))
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPADV, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportBtlx*> ( new(nothrow) ImportBtlx) ;
@@ -62,18 +62,15 @@ ImportBtlx::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
// inizializzo il gestore geometria pezzi Btl
int nFlatVertPos = 0 ;
if (( nFlag & EIBFLAG_OUTL_FLAT_POS) != 0)
nFlatVertPos = 4 ;
else if (( nFlag & EIBFLAG_TS3_POS) != 0)
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, bTrimWithOutline, bUseUAttr)) {
if ( ! m_BtlGeom.Init( pGDB, nFlatVertPos, bSpecialTrim, bUseUAttr)) {
LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init") ;
return false ;
}
@@ -351,7 +348,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){
@@ -396,7 +393,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") {
@@ -408,55 +405,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 ;
@@ -471,40 +468,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
@@ -1561,7 +1558,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 ;
}
@@ -1581,8 +1578,8 @@ ImportBtlx::ReadShape( pugi::xml_node node)
return false ;
}
INTMATRIX vFacesVertices ;
PNTVECTOR vPoints ;
vector<INTVECTOR> vFacesVertices ;
vector<Point3d> vPoints ;
size_t str_start = 0 ;
size_t str_end ;
@@ -1591,10 +1588,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() ;
}
@@ -1608,17 +1605,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 ;
}
+15 -19
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: Moritise Shape is unknown") ;
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon Shape is unknown") ;
return false ;
}
@@ -980,14 +980,12 @@ 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" || sShape == "rounded" || sShape == "square" ) {
if ( sShape != "radius") // P12
vdPar[9] = MILL_DEF_RAD ;
vdPar[9] *= 2 ;
else if ( sShape == "radius") {
vdPar[9] *= 2 ; // P12
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")
@@ -995,7 +993,7 @@ ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& n
}
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail Tenon Shape is unknown") ;
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon Shape is unknown") ;
return false ;
}
@@ -1054,22 +1052,20 @@ 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" || sShape == "rounded" || sShape == "square") {
if ( sShape != "radius") // P12
vdPar[10] = MILL_DEF_RAD ;
else if ( sShape == "radius") {
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: Dovetail mortise Shape is unknown") ;
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Mortise Shape is unknown") ;
return false ;
}
+41 -63
View File
@@ -52,7 +52,7 @@ IImportCnc*
CreateImportCnc( void)
{
// verifico la chiave e le opzioni
if ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportCnc*> ( new(nothrow) ImportCnc) ;
@@ -139,8 +139,6 @@ 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 ;
@@ -192,14 +190,6 @@ 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 ;
@@ -320,8 +310,6 @@ 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/") ;
@@ -1129,20 +1117,25 @@ ImportCnc::VerifyArcCenter( const Vector3d& vtN)
if ( ! frOcs.Set( ORIG, vtN))
return A_ERROR ;
// porto i punti in questo riferimento
Point3d ptLloc = GetToLoc( m_ptLast, frOcs) ;
Point3d ptNloc = GetToLoc( m_ptNext, frOcs) ;
Point3d ptCloc = GetToLoc( m_ptCen, frOcs) ;
Vector3d vtOloc = GetToLoc( m_vtOffs, frOcs) ;
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) ;
// verifico se circonferenza
int nRet = ( SqDistXY( ptLloc, ptNloc) > EPS_SMALL * EPS_SMALL) ? A_ARC : A_CIRC ;
// se controllo Fanuc o Fagor, centro è sempre in relativo
if ( m_nCNC == CNC_FANUC || m_nCNC == CNC_FAGOR) {
// se controllo Fanuc, centro è sempre in relativo
if ( m_nCNC == CNC_FANUC) {
// centro in relativo
Point3d ptCrl = ptCloc + ptLloc ;
double dRadLast = DistXY( ptLloc, ptCrl) ;
double dRadNext = DistXY( ptNloc, ptCrl) ;
if ( abs( dRadNext - dRadLast) < 100 * EPS_SMALL) {
m_ptCen = GetToGlob( ptCrl, frOcs) ;
if ( abs( dRadNext - dRadLast) < 10 * EPS_SMALL) {
m_ptCen = ptCrl ;
m_ptCen.ToGlob( frOcs) ;
return nRet ;
}
}
@@ -1150,28 +1143,19 @@ ImportCnc::VerifyArcCenter( const Vector3d& vtN)
else if ( m_bAbsCoord) {
// centro in assoluto
Point3d ptCas = ptCloc + vtOloc ;
double dRadCasLast = DistXY( ptLloc, ptCas) ;
double dRadCasNext = DistXY( ptNloc, ptCas) ;
double dRadLast = DistXY( ptLloc, ptCas) ;
double dRadNext = DistXY( ptNloc, ptCas) ;
if ( abs( dRadNext - dRadLast) < 10 * EPS_SMALL) {
m_ptCen += m_vtOffs ;
return nRet ;
}
// 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 ;
}
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) ;
dRadLast = DistXY( ptLloc, ptCrl) ;
dRadNext = DistXY( ptNloc, ptCrl) ;
if ( abs( dRadNext - dRadLast) < 10 * EPS_SMALL) {
m_ptCen = ptCrl ;
m_ptCen.ToGlob( frOcs) ;
return nRet ;
}
}
@@ -1179,27 +1163,18 @@ ImportCnc::VerifyArcCenter( const Vector3d& vtN)
else {
// centro in relativo
Point3d ptCrl = ptCloc + ptLloc ;
double dRadCrlLast = DistXY( ptLloc, ptCrl) ;
double dRadCrlNext = DistXY( ptNloc, ptCrl) ;
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 ;
}
// centro in assoluto
Point3d ptCas = ptCloc + vtOloc ;
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) {
dRadLast = DistXY( ptLloc, ptCas) ;
dRadNext = DistXY( ptNloc, ptCas) ;
if ( abs( dRadNext - dRadLast) < 10 * EPS_SMALL) {
m_ptCen += m_vtOffs ;
return nRet ;
}
@@ -1218,9 +1193,12 @@ 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 = GetToLoc( ptCen, frOcs) ;
Point3d ptSloc = GetToLoc( ptStart, frOcs) ;
Point3d ptNEloc = GetToLoc( ptNearEnd, frOcs) ;
Point3d ptCloc = ptCen ;
ptCloc.ToLoc( frOcs) ;
Point3d ptSloc = ptStart ;
ptSloc.ToLoc( frOcs) ;
Point3d ptNEloc = ptNearEnd ;
ptNEloc.ToLoc( 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, CNC_FAGOR} ;
enum CncName { CNC_STD = 0, CNC_OSAI = 1, CNC_FANUC = 2, CNC_NUM = 3, CNC_SIEMENS = 4, CNC_TPA = 5, CNC_MAZAK = 6} ;
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 ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! 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 ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! 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 ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! 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 ( ! GetEExNetHwKey() && ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPBASE, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportStl*> ( new(nothrow) ImportStl) ;
+1
View File
@@ -31,6 +31,7 @@
#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")