diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 2d4b37f..31f66b9 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index a4a2790..94a85d7 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -4338,7 +4338,7 @@ GdbExecutor::ExecuteCopy( const string& sCmd2, const STRVECTOR& vsParams) if ( vsParams.size() != 3 && vsParams.size() != 4) return false ; // recupero tipo di inserimento della copia - int nSonBeforeAfter = GDB_SON ; + int nSonBeforeAfter = GDB_LAST_SON ; if ( vsParams.size() == 4) { string sFlag = vsParams[3] ; ToUpper( sFlag) ; @@ -4346,6 +4346,10 @@ GdbExecutor::ExecuteCopy( const string& sCmd2, const STRVECTOR& vsParams) nSonBeforeAfter = GDB_BEFORE ; else if ( sFlag == "AFTER") nSonBeforeAfter = GDB_AFTER ; + else if ( sFlag == "FIRST_SON") + nSonBeforeAfter = GDB_FIRST_SON ; + else // default "LAST_SON" + nSonBeforeAfter = GDB_LAST_SON ; } // recupero flag per globale bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ; @@ -4375,7 +4379,7 @@ GdbExecutor::ExecuteRelocate( const string& sCmd2, const STRVECTOR& vsParams) if ( ! GetNamesParam( vsParams[0], vnNames)) return false ; // recupero tipo di inserimento - int nSonBeforeAfter = GDB_SON ; + int nSonBeforeAfter = GDB_LAST_SON ; if ( vsParams.size() == 3) { string sFlag = vsParams[2] ; ToUpper( sFlag) ; @@ -4383,6 +4387,10 @@ GdbExecutor::ExecuteRelocate( const string& sCmd2, const STRVECTOR& vsParams) nSonBeforeAfter = GDB_BEFORE ; else if ( sFlag == "AFTER") nSonBeforeAfter = GDB_AFTER ; + else if ( sFlag == "FIRST_SON") + nSonBeforeAfter = GDB_FIRST_SON ; + else // default "LAST_SON" + nSonBeforeAfter = GDB_LAST_SON ; } // recupero flag per globale bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ; diff --git a/GeomDB.cpp b/GeomDB.cpp index 6dd2588..ecd04aa 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -239,7 +239,7 @@ GeomDB::LoadOneObj( NgeReader& ngeIn, int nGroupId, int nBaseGdbId, const INTVEC nMat > 0 && nMat < int( vBaseMatId.size())) pGdbObj->SetMaterial( vBaseMatId[nMat]) ; // se inserimento nel DB va bene, ritorno con successo - if ( InsertInGeomDB( pGdbObj, nParentId, GDB_SON)) + if ( InsertInGeomDB( pGdbObj, nParentId, GDB_LAST_SON)) return true ; } // altrimenti errore @@ -391,7 +391,7 @@ GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTe // oggetto e riferimento non possono essere la stessa cosa if ( pGObj->m_nId == nRefId) - return ( nSonBeforeAfter != GDB_SON) ; + return ( ! IS_GDB_SON( nSonBeforeAfter)) ; // cerco il riferimento GdbObj* pGRef = GetGdbObj( nRefId) ; @@ -402,15 +402,24 @@ GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTe pGObj->SetGeomDB( this) ; // inserisco prima del riferimento - if ( nSonBeforeAfter <= GDB_BEFORE) { + if ( nSonBeforeAfter == GDB_BEFORE) { if ( ! pGObj->InsertBefore( pGRef)) return false ; } // inserisco dopo il riferimento - else if ( nSonBeforeAfter >= GDB_AFTER) { + else if ( nSonBeforeAfter == GDB_AFTER) { if ( ! pGObj->InsertAfter( pGRef)) return false ; } + // inserisco come figlio, in testa alla lista del padre + else if ( nSonBeforeAfter == GDB_FIRST_SON){ + GdbGroup* pGroup = dynamic_cast ( pGRef) ; + if ( pGroup == nullptr) + return false ; + // inserisco in testa alla lista del padre + if ( ! pGObj->AddHead( pGroup)) + return false ; + } // inserisco come figlio, in coda alla lista del padre else { GdbGroup* pGroup = dynamic_cast ( pGRef) ; @@ -432,7 +441,7 @@ GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTe int GeomDB::AddGroup( int nId, int nParentId, const Frame3d& frFrame) { - return InsertGroup( nId, nParentId, GDB_SON, frFrame) ; + return InsertGroup( nId, nParentId, GDB_LAST_SON, frFrame) ; } //---------------------------------------------------------------------------- @@ -468,7 +477,7 @@ GeomDB::InsertGroup( int nId, int nRefId, int nSonBeforeAfter, const Frame3d& fr int GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj) { - return InsertGeoObj( nId, nParentId, GDB_SON, pGeoObj) ; + return InsertGeoObj( nId, nParentId, GDB_LAST_SON, pGeoObj) ; } //---------------------------------------------------------------------------- @@ -845,7 +854,7 @@ GeomDB::Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGl return GDB_ID_NULL ; // cerco il padre di destinazione - int nParentIdDest = (( nSonBeforeAfter == GDB_SON) ? nRefId : GetParentId( nRefId)) ; + int nParentIdDest = ( IS_GDB_SON( nSonBeforeAfter) ? nRefId : GetParentId( nRefId)) ; GdbGroup* pGroupDest = GetGdbGroup( nParentIdDest) ; if ( pGroupDest == nullptr) return GDB_ID_NULL ; @@ -884,7 +893,7 @@ GeomDB::Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob) { // l'oggetto e il riferimento non possono coincidere if ( nId == nRefId) - return ( nSonBeforeAfter != GDB_SON) ; + return ( ! IS_GDB_SON( nSonBeforeAfter)) ; // verifico esistenza dell'oggetto GdbObj* pGdbObj = GetGdbObj( nId) ; @@ -897,13 +906,13 @@ GeomDB::Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob) return false ; // cerco il nuovo padre - int nNewParentId = (( nSonBeforeAfter == GDB_SON) ? nRefId : GetParentId( nRefId)) ; + int nNewParentId = ( IS_GDB_SON( nSonBeforeAfter) ? nRefId : GetParentId( nRefId)) ; GdbGroup* pNewGroup = GetGdbGroup( nNewParentId) ; if ( pNewGroup == nullptr) return false ; // se riferimento al padre e vecchio e nuovo padre coincidono, non devo fare alcunché - if ( nSonBeforeAfter == GDB_SON && pGroup->m_nId == pNewGroup->m_nId) + if ( IS_GDB_SON( nSonBeforeAfter) && pGroup->m_nId == pNewGroup->m_nId) return true ; // se rilocazione in globale diff --git a/GeomDB.h b/GeomDB.h index 82fbb91..9a6e689 100644 --- a/GeomDB.h +++ b/GeomDB.h @@ -64,13 +64,13 @@ class GeomDB : public IGeomDB virtual bool GetLocalBBox( int nId, BBox3d& b3Loc, int nFlag = BBF_STANDARD) const ; virtual bool GetGlobalBBox( int nId, BBox3d& b3Glob, int nFlag = BBF_STANDARD) const ; virtual bool GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const ; - virtual int Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_SON) + virtual int Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_LAST_SON) { return Copy( nIdSou, nIdDest, nRefId, nSonBeforeAfter, false) ; } - virtual int CopyGlob( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_SON) + virtual int CopyGlob( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_LAST_SON) { return Copy( nIdSou, nIdDest, nRefId, nSonBeforeAfter, true) ; } - virtual bool Relocate( int nId, int nRefId, int nSonBeforeAfter = GDB_SON) + virtual bool Relocate( int nId, int nRefId, int nSonBeforeAfter = GDB_LAST_SON) { return Relocate( nId, nRefId, nSonBeforeAfter, false) ; } - virtual bool RelocateGlob( int nId, int nRefId, int nSonBeforeAfter = GDB_SON) + virtual bool RelocateGlob( int nId, int nRefId, int nSonBeforeAfter = GDB_LAST_SON) { return Relocate( nId, nRefId, nSonBeforeAfter, true) ; } virtual bool ChangeId( int nId, int nNewId) ; virtual bool Erase( int nId) ; diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index 1df4a46..2a33e14 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -1155,6 +1155,9 @@ SurfTriMesh::AdjustTopology( void) // verifica chiusura if ( ! TestSealing()) return false ; + // verifica sfaccettatura + if ( ! VerifyFaceting()) + return false ; return true ; } @@ -2206,7 +2209,7 @@ SurfTriMesh::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& m_vVert[i].ptP.Shear( ptOn, vtNorm, vtDir, dCoeff) ; } - // aggiorno le facce + // aggiorno i triangoli for ( int i = 0 ; i < GetTriangleSize() ; ++ i) { if ( m_vTria[i].nIdVert[0] != SVT_DEL) { // aggiorno la normale @@ -2239,6 +2242,12 @@ SurfTriMesh::ToGlob( const Frame3d& frRef) m_vVert[i].ptP.ToGlob( frRef) ; } + // trasformo le normali dei triangoli + for ( int i = 0 ; i < GetTriangleSize() ; ++ i) { + if ( m_vTria[i].nIdVert[0] != SVT_DEL) + m_vTria[i].vtN.ToGlob( frRef) ; + } + return true ; } @@ -2263,6 +2272,12 @@ SurfTriMesh::ToLoc( const Frame3d& frRef) m_vVert[i].ptP.ToLoc( frRef) ; } + // trasformo le normali dei triangoli + for ( int i = 0 ; i < GetTriangleSize() ; ++ i) { + if ( m_vTria[i].nIdVert[0] != SVT_DEL) + m_vTria[i].vtN.ToLoc( frRef) ; + } + return true ; } @@ -2291,6 +2306,12 @@ SurfTriMesh::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) m_vVert[i].ptP.LocToLoc( frOri, frDest) ; } + // trasformo le normali dei triangoli + for ( int i = 0 ; i < GetTriangleSize() ; ++ i) { + if ( m_vTria[i].nIdVert[0] != SVT_DEL) + m_vTria[i].vtN.LocToLoc( frOri, frDest) ; + } + return true ; } diff --git a/SurfTriMeshFaceting.cpp b/SurfTriMeshFaceting.cpp index 927744a..400bcca 100644 --- a/SurfTriMeshFaceting.cpp +++ b/SurfTriMeshFaceting.cpp @@ -47,6 +47,7 @@ SurfTriMesh::UpdateFaceting( void) m_vTria[i].nIdFacet = SVT_NULL ; // ricostruisco le sfaccettature + bool bOk = true ; int nFacet = 0 ; for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) { if ( m_vTria[i].nIdVert[0] != SVT_DEL && @@ -65,13 +66,17 @@ SurfTriMesh::UpdateFaceting( void) if ( nAdjT != SVT_NULL && m_vTria[nAdjT].nIdFacet == SVT_NULL) { if ( ! UpdateTriaFaceting( i, m_vTria[i].nIdFacet, plPlane, nAdjT)) - return false ; + bOk = false ; } } } } - // calcolo facce piane riuscito + // se ci sono stati problemi, salvo nel log + if ( ! bOk) + LOG_ERROR( GetEGkLogger(), "SurfTM : UpdateFaceting error") + + // calcolo facce piane effettuato m_bFaceted = true ; return true ; } @@ -98,15 +103,16 @@ SurfTriMesh::UpdateTriaFaceting( int nRefT, int nFacet, const Plane3d& plPlane, // il triangolo fa parte della faccia m_vTria[nT].nIdFacet = nFacet ; // aggiorno i triangoli adiacenti + bool bOk = true ; for ( int j = 0 ; j < 3 ; ++ j) { int nAdjT = m_vTria[nT].nIdAdjac[j] ; if ( nAdjT != SVT_NULL && m_vTria[nAdjT].nIdFacet == SVT_NULL) { if ( ! UpdateTriaFaceting( nT, nFacet, plPlane, nAdjT)) - return false ; + bOk = false ; } } - return true ; + return bOk ; } //----------------------------------------------------------------------------