diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 237e2dd..f256780 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/VolTriZmapCalculus.cpp b/VolTriZmapCalculus.cpp index 1bed074..bd41a1c 100644 --- a/VolTriZmapCalculus.cpp +++ b/VolTriZmapCalculus.cpp @@ -12,7 +12,6 @@ //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- - #include "stdafx.h" #include "CurveLine.h" #include "VolZmap.h" @@ -20,7 +19,6 @@ #include "IntersLineSurfTm.h" #include "/EgtDev/Include/EgtNumUtils.h" - using namespace std ; //---------------------------------------------------------------------------- @@ -957,12 +955,9 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d& //---------------------------------------------------------------------------- bool VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLineDir, - const Frame3d& PolyFrame, double dLenX, double dLenY, double dLenZ, double dDeltaX, - Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2) + const Frame3d& PolyFrame, double dLenX, double dLenY, double dLenZ, double dDeltaX, + Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2) { - - double SqIndet = EPS_SMALL * EPS_SMALL ; - Point3d ptP = ptLineSt ; Vector3d vtV = vtLineDir ; @@ -1026,15 +1021,12 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine // Intersezione con la seconda faccia if ( ptI2.y >= 0 && ptI2.y <= dLenY && ptI2.x * dLenY >= dDeltaX * ptI2.y && ( ptI2.x - dLenX) * dLenY <= dDeltaX * ptI2.y) { - if ( nIntNum == 0) { - ptInt1 = ptI2 ; vtN1 = Z_AX ; ++ nIntNum ; } - else if ( ( ptInt1 - ptI2).SqLen() > SqIndet) { - + else if ( ( ptInt1 - ptI2).SqLen() > SQ_EPS_SMALL) { ptInt2 = ptI2 ; vtN2 = Z_AX ; ++ nIntNum ; @@ -1045,15 +1037,12 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine if ( nIntNum < 2 && ptI3.x >= 0 && ptI3.x <= dLenX && ptI3.z >= - ptFacet135.z && ptI3.z <= ptFacet135.z) { - if ( nIntNum == 0) { - ptInt1 = ptI3 ; vtN1 = Y_AX ; ++ nIntNum ; } - else if ( ( ptInt1 - ptI3).SqLen() > SqIndet) { - + else if ( ( ptInt1 - ptI3).SqLen() > SQ_EPS_SMALL) { ptInt2 = ptI3 ; vtN2 = Y_AX ; ++ nIntNum ; @@ -1064,15 +1053,12 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine if ( nIntNum < 2 && ptI4.x >= dDeltaX && ptI4.x <= dLenX + dDeltaX && ptI4.z >= - ptFacet135.z && ptI4.z <= ptFacet135.z) { - if ( nIntNum == 0) { - ptInt1 = ptI4 ; vtN1 = - Y_AX ; ++ nIntNum ; } - else if ( ( ptInt1 - ptI4).SqLen() > SqIndet) { - + else if ( ( ptInt1 - ptI4).SqLen() > SQ_EPS_SMALL) { ptInt2 = ptI4 ; vtN2 = - Y_AX ; ++ nIntNum ; @@ -1083,15 +1069,12 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine if ( nIntNum < 2 && ptI5.y >= 0 && ptI5.y <= dLenY && ptI5.z >= - ptFacet135.z && ptI5.z <= ptFacet135.z) { - if ( nIntNum == 0) { - ptInt1 = ptI5 ; vtN1 = vtOb ; ++ nIntNum ; } - else if ( ( ptInt1 - ptI5).SqLen() > SqIndet) { - + else if ( ( ptInt1 - ptI5).SqLen() > SQ_EPS_SMALL) { ptInt2 = ptI5 ; vtN2 = vtOb ; ++ nIntNum ; @@ -1102,32 +1085,79 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine if ( nIntNum < 2 && ptI6.y >= 0 && ptI6.y <= dLenY && ptI6.z >= - ptFacet135.z && ptI6.z <= ptFacet135.z) { - if ( nIntNum == 0) { - ptInt1 = ptI6; vtN1 = - vtOb ; ++ nIntNum ; } - else if ( ( ptInt1 - ptI6).SqLen() > SqIndet) { - + else if ( ( ptInt1 - ptI6).SqLen() > SQ_EPS_SMALL) { ptInt2 = ptI6; vtN2 = - vtOb ; ++ nIntNum ; } } - if ( nIntNum == 2) { - ptInt1.ToGlob( PolyFrame) ; ptInt2.ToGlob( PolyFrame) ; - vtN1.ToGlob( PolyFrame) ; vtN2.ToGlob( PolyFrame) ; - return true ; } else return false ; } + +//---------------------------------------------------------------------------- +bool +VolZmap::GetVolume( double& dVol) const +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + // Eseguo il calcolo della lunghezza totale degli spilloni + double dLen = 0 ; + for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) { + for ( int nDex = 0 ; nDex < int( m_Values[nMap].size()) ; ++ nDex) { + for ( int nInt = 0 ; nInt < int( m_Values[nMap][nDex].size()) ; ++ nInt) { + dLen += m_Values[nMap][nDex][nInt].dMax - m_Values[nMap][nDex][nInt].dMin ; + } + } + } + // Il volume si trova moltiplicando per l'area di ogni spillone e dividendo per il numero di mappe + dVol = dLen * ( m_dStep * m_dStep) / m_nMapNum ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::GetPartVolume( int nPart, double& dVol) const +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + // Se una sola mappa o il numero di componenti è indefinito, errore + if ( m_nMapNum == 1 || m_nConnectedCompoCount == -1) + return false ; + // Se la componente richiesta non esiste, errore + if ( nPart < 0 || nPart > m_nConnectedCompoCount - 1) + return false ; + + // Eseguo il calcolo della lunghezza totale degli spilloni + double dLen = 0 ; + for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) { + for ( int nDex = 0 ; nDex < int( m_Values[nMap].size()) ; ++ nDex) { + for ( int nInt = 0 ; nInt < int( m_Values[nMap][nDex].size()) ; ++ nInt) { + // se il pezzo di spillone appartiene alla parte, ne aggiungo la lunghezza + if ( m_Values[nMap][nDex][nInt].nCompo == nPart + 1) { + dLen += m_Values[nMap][nDex][nInt].dMax - m_Values[nMap][nDex][nInt].dMin ; + } + } + } + } + // Il volume si trova moltiplicando per l'area di ogni spillone e dividendo per il numero di mappe + dVol = dLen * ( m_dStep * m_dStep) / 3 ; + + return true ; +} diff --git a/VolTriZmapVolume.cpp b/VolTriZmapVolume.cpp index d0f6eda..9cb3644 100644 --- a/VolTriZmapVolume.cpp +++ b/VolTriZmapVolume.cpp @@ -641,7 +641,7 @@ bool VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe) { // Controllo sull'effettiva esisenza del movimento - if ( AreSamePointApprox( ptPs, ptPe) && AreSameVectorApprox( vtDs, vtDe)) + if ( AreSamePointApprox( ptPs, ptPe) && AreSameVectorApprox( vtDs, vtDe)) return true ; // Punti nei sistemi di riferimento intrinseci dello Zmap @@ -669,7 +669,6 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& ptLe[1].x = 0 ; ptLe[1].y = 0 ; ptLe[1].z = 0 ; ptLe[2].x = 0 ; ptLe[2].y = 0 ; ptLe[2].z = 0 ; } - // Vettori nei sistemi di riferimento intrinseci dello Zmap Vector3d vtLs[3] ; diff --git a/VolZmap.cpp b/VolZmap.cpp index 53538c9..0ad9b72 100644 --- a/VolZmap.cpp +++ b/VolZmap.cpp @@ -899,12 +899,14 @@ VolZmap::ExpandFromZInterval( IntContaier& IntCont) VolZmap* VolZmap::ClonePart( int nPart) const { - // Se è usata una sola griglia, i risultati non - // sarebbero attendibili; restituisco nullptr. + // verifico lo stato + if ( m_nStatus != OK) + return nullptr ; + // Se è definita una sola griglia non sono definibili le parti, errore if ( m_nMapNum == 1) - return nullptr ; + return nullptr ; // Se è richiesta una componente fuori intervallo restituisco nullptr. - if ( nPart < 0 || nPart >= m_nConnectedCompoCount) + if ( nPart < 0 || nPart >= m_nConnectedCompoCount) return nullptr ; // Se il numero di componenti è indefinito, lo ricalcolo. if ( m_nConnectedCompoCount == - 1) @@ -921,6 +923,7 @@ VolZmap::ClonePart( int nPart) const pVolume->m_dStep = m_dStep ; pVolume->m_nMapNum = m_nMapNum ; + // Minimi e massimi indici i,j della componente per le tre griglie int nMinIndI[3] ; int nMaxIndI[3] ; int nMinIndJ[3] ; @@ -928,15 +931,15 @@ VolZmap::ClonePart( int nPart) const // Coordinate dell'origine del sistema di riferimento // del nuovo Zmap double dNewOx, dNewOy, dNewOz ; - // Ciclo sulle mappe + // Ciclo sulle mappe for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) { nMinIndI[nMap] = m_nNx[nMap] ; nMinIndJ[nMap] = m_nNy[nMap] ; nMaxIndI[nMap] = 0 ; nMaxIndJ[nMap] = 0 ; - // Della componente connessa in questione calcolo - // indici i e j massimi e minimi. + // Della componente connessa in questione calcolo + // indici i e j massimi e minimi. for ( int nIndI = 0 ; nIndI < int( m_nNx[nMap]) ; ++ nIndI) { for ( int nIndJ = 0 ; nIndJ < int( m_nNy[nMap]) ; ++ nIndJ) { @@ -1053,3 +1056,48 @@ VolZmap::ClonePart( int nPart) const // Restituisco il nuovo solido return Release( pVolume) ; } + +//---------------------------------------------------------------------------- +bool +VolZmap::RemovePart( int nPart) +{ + // verifico lo stato + if ( m_nStatus != OK) + return false ; + // Se è definita una sola griglia non sono definibili le parti, errore + if ( m_nMapNum == 1) + return false ; + // Se il numero di componenti è indefinito, lo ricalcolo + if ( m_nConnectedCompoCount == - 1) + CheckMapConnection() ; + // Se non vi sono componenti, abbiamo finito + if ( m_nConnectedCompoCount == 0) + return true ; + + // Elimino i segmenti con indice nPart + 1 e aggiorno quelli con indice superiore + // Ciclo sulle mappe. + for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) { + // Ciclo sui dexel della mappa. + for ( int nDex = 0 ; nDex < int( m_Values[nMap].size()) ; ++ nDex) { + // Ciclo sugli intervalli del dexel. + for ( int nInt = 0 ; nInt < int( m_Values[nMap][nDex].size()) ; ++ nInt) { + // Se l'intervallo appartiene alla componente da eliminare, lo cancello. + if ( m_Values[nMap][nDex][nInt].nCompo == nPart + 1) { + m_Values[nMap][nDex].erase( m_Values[nMap][nDex].begin() + nInt) ; + -- nInt ; + } + else if ( m_Values[nMap][nDex][nInt].nCompo > nPart + 1) + m_Values[nMap][nDex][nInt].nCompo -= 1 ; + } + } + } + + // Decremento il numero di componenti. + m_nConnectedCompoCount -= 1 ; + + // Imposto ricalcolo grafica + m_OGrMgr.Reset() ; + + return true ; +} + diff --git a/VolZmap.h b/VolZmap.h index d9b6551..a9efbb7 100644 --- a/VolZmap.h +++ b/VolZmap.h @@ -82,7 +82,9 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool CreateFromTriMesh( const ISurfTriMesh& Surf, double dPrec, bool bTriDex) override ; bool GetAllTriangles( TRIA3DLIST& lstTria) const override ; int GetBlockCount( void) const override ; + bool GetVolume( double& dVol) const override ; int GetPartCount( void) const override ; + bool GetPartVolume( int nPart, double& dVol) const override ; bool GetTriangles( bool bAllBlocks, INTVECTOR& nModifiedBlocks, TRIA3DLISTVECTOR& vLstTria) const override ; bool GetDexelLines( int nDir, int nPos1, int nPos2, POLYLINELIST& lstPL) const override ; bool SetTolerances( double dLinTol, double dAngTolDeg = 90) override ; @@ -97,6 +99,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool GetDepth( const Point3d& ptP, const Vector3d& vtDir, double& dInLength, double& dOutLength) const override ; bool AvoidBox( const Frame3d& frBox, const Vector3d& vtDiag) const override ; VolZmap* ClonePart( int nPart) const override ; + bool RemovePart( int nPart) override ; public : // IGeoObjRW virtual int GetNgeId( void) const ;