From 729f405ec7271a6f967141cbf8932b0a90a40647 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 21 Nov 2019 11:41:49 +0000 Subject: [PATCH] EgtGeomKernel 2.1k5 : - correzioni alle booleane di superfici per facce risultanti con buchi - aggiunte a VolZmap funzioni GetPartLocalBBox e GetPartBBox. --- EgtGeomKernel.rc | Bin 11718 -> 11718 bytes SurfTriMeshBooleans.cpp | 13 +++-- VolZmap.cpp | 110 ++++++++++++++++++++++++++++++++++++++++ VolZmap.h | 10 ++-- 4 files changed, 125 insertions(+), 8 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 69065106d884c71139331fa3bc1fde0e00c0310f..3ee506642103fc935514e87dbf93fc0e33719705 100644 GIT binary patch delta 110 zcmX>WeJpyzA2vqQ&G-4vGfl1&(wY2&Q;pGdvZAo=W*@FeEMOU1X1ItOWeJpyzA2vpl&G-4vGfl1&(wY2&Q;pGNvZAo=W*@FeEMOU1X1ItOApproxWithLines( LIN_TOL_FINE, ANG_TOL_STD_DEG, ICurve::APL_STD, PolyOutline) ; + POLYLINEVECTOR LoopVector ; + int nChunkLoopNum = Facet.GetLoopCount( nChunk) ; + for ( int nChunkLoop = 0 ; nChunkLoop < nChunkLoopNum ; ++ nChunkLoop) { + ICurve* pOutline = Facet.GetLoop( nChunk, nChunkLoop) ; + PolyLine PolyOutline ; + pOutline->ApproxWithLines( LIN_TOL_FINE, ANG_TOL_STD_DEG, ICurve::APL_STD, PolyOutline) ; + LoopVector.emplace_back( PolyOutline) ; + } PNTVECTOR vPt ; INTVECTOR vTr ; - if ( Triangulate().Make( PolyOutline, vPt, vTr)) { + if ( Triangulate().Make( LoopVector, vPt, vTr)) { // Inserisco i nuovi triangoli for ( int n = 0 ; n < int( vTr.size()) - 2 ; n += 3) { int nNewTriaVertId[3] = { vTr[n], vTr[n + 1], vTr[n + 2] }; diff --git a/VolZmap.cpp b/VolZmap.cpp index 1979695..31ec874 100644 --- a/VolZmap.cpp +++ b/VolZmap.cpp @@ -491,6 +491,116 @@ VolZmap::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const return true ; } +//---------------------------------------------------------------------------- +bool +VolZmap::GetPartLocalBBox( int nPart, BBox3d& b3Loc, int nFlag) const +{ + // Verifico lo stato. + if ( m_nStatus != OK) + return false ; + // Se una sola mappa o il numero di componenti è indefinito, vi è un errore. + if ( m_nMapNum == 1 || m_nConnectedCompoCount == - 1) + return false ; + // Se la componente richiesta non esiste, vi è un errore. + if ( nPart < 0 || nPart > m_nConnectedCompoCount - 1) + return false ; + // Calcolo Bounding-box + for ( int nMap = 0 ; nMap < 3 ; ++ nMap) { + for ( int nDex = 0 ; nDex < m_nDim[nMap] ; ++ nDex) { + for ( int nInt = 0 ; nInt < int( m_Values[nMap][nDex].size()) ; ++ nInt) { + if ( m_Values[nMap][nDex][nInt].nCompo == nPart) { + // Indici del dexel + int nI = nDex % m_nNx[nMap] ; + int nJ = nDex / m_nNx[nMap] ; + // Posizione del dexel + double dX = ( nI + 0.5) * m_dStep ; + double dY = ( nJ + 0.5) * m_dStep ; + // Definisco i punti nel sistema locale + Point3d ptP, ptPSt, ptPEn ; + if ( nMap == 0) { + ptP = m_MapFrame.Orig() + dX * m_MapFrame.VersX() + dY * m_MapFrame.VersY() ; + ptPSt = ptP + m_Values[nMap][nDex][nInt].dMin * m_MapFrame.VersZ() ; + ptPEn = ptP + m_Values[nMap][nDex][nInt].dMax * m_MapFrame.VersZ() ; + } + else if ( nMap == 1) { + ptP = m_MapFrame.Orig() + dX * m_MapFrame.VersY() + dY * m_MapFrame.VersZ() ; + ptPSt = ptP + m_Values[nMap][nDex][nInt].dMin * m_MapFrame.VersX() ; + ptPEn = ptP + m_Values[nMap][nDex][nInt].dMax * m_MapFrame.VersX() ; + } + else { + ptP = m_MapFrame.Orig() + dX * m_MapFrame.VersZ() + dY * m_MapFrame.VersX() ; + ptPSt = ptP + m_Values[nMap][nDex][nInt].dMin * m_MapFrame.VersY() ; + ptPEn = ptP + m_Values[nMap][nDex][nInt].dMax * m_MapFrame.VersY() ; + } + // Aggiungo i punti al bounding-box + b3Loc.Add( ptPSt) ; + b3Loc.Add( ptPEn) ; + } + } + } + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::GetPartBBox( int nPart, const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const +{ + // Verifico lo stato. + if ( m_nStatus != OK) + return false ; + // Se una sola mappa o il numero di componenti è indefinito, vi è un errore. + if ( m_nMapNum == 1 || m_nConnectedCompoCount == - 1) + return false ; + // Se la componente richiesta non esiste, vi è un errore. + if ( nPart < 0 || nPart > m_nConnectedCompoCount - 1) + return false ; + // Calcolo Bounding-box + Point3d ptMapFrameOrig = m_MapFrame.Orig() ; + Vector3d vtMapFrameVersX = m_MapFrame.VersX() ; + Vector3d vtMapFrameVersY = m_MapFrame.VersY() ; + Vector3d vtMapFrameVersZ = m_MapFrame.VersZ() ; + ptMapFrameOrig.ToGlob( frRef) ; + vtMapFrameVersX.ToGlob( frRef) ; + vtMapFrameVersY.ToGlob( frRef) ; + vtMapFrameVersZ.ToGlob( frRef) ; + for ( int nMap = 0 ; nMap < 3 ; ++ nMap) { + for ( int nDex = 0 ; nDex < m_nDim[nMap] ; ++ nDex) { + for ( int nInt = 0 ; nInt < int( m_Values[nMap][nDex].size()) ; ++ nInt) { + if ( m_Values[nMap][nDex][nInt].nCompo == nPart) { + // Indici del dexel + int nI = nDex % m_nNx[nMap] ; + int nJ = nDex / m_nNx[nMap] ; + // Posizione del dexel + double dX = ( nI + 0.5) * m_dStep ; + double dY = ( nJ + 0.5) * m_dStep ; + // Definisco i punti nel sistema locale + Point3d ptP, ptPSt, ptPEn ; + if ( nMap == 0) { + ptP = ptMapFrameOrig + dX * vtMapFrameVersX + dY * vtMapFrameVersY ; + ptPSt = ptP + m_Values[nMap][nDex][nInt].dMin * vtMapFrameVersZ ; + ptPEn = ptP + m_Values[nMap][nDex][nInt].dMax * vtMapFrameVersZ ; + } + else if ( nMap == 1) { + ptP = ptMapFrameOrig + dX * vtMapFrameVersY + dY * vtMapFrameVersZ ; + ptPSt = ptP + m_Values[nMap][nDex][nInt].dMin * vtMapFrameVersX ; + ptPEn = ptP + m_Values[nMap][nDex][nInt].dMax * vtMapFrameVersX ; + } + else { + ptP = ptMapFrameOrig + dX * vtMapFrameVersZ + dY * vtMapFrameVersX ; + ptPSt = ptP + m_Values[nMap][nDex][nInt].dMin * vtMapFrameVersY ; + ptPEn = ptP + m_Values[nMap][nDex][nInt].dMax * vtMapFrameVersY ; + } + // Aggiungo i punti al bounding-box + b3Ref.Add( ptPSt) ; + b3Ref.Add( ptPEn) ; + } + } + } + } + return true ; +} + //---------------------------------------------------------------------------- bool VolZmap::Translate( const Vector3d& vtMove) diff --git a/VolZmap.h b/VolZmap.h index 50cbd5f..6b80f62 100644 --- a/VolZmap.h +++ b/VolZmap.h @@ -73,8 +73,6 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool GetBlockTriangles( int nBlock, TRIA3DEXVECTOR& vTria) const override ; bool GetEdges( ICURVEPOVECTOR& vpCurve) const override ; bool GetVolume( double& dVol) const override ; - int GetPartCount( void) const override ; - bool GetPartVolume( int nPart, double& dVol) const override ; bool GetDexelLines( int nDir, int nPos1, int nPos2, POLYLINELIST& lstPL) const override ; bool SetTolerances( double dLinTol, double dAngTolDeg = 90) override ; bool SetStdTool( const std::string& sToolName, double dH, double dR, double dCornR, int nFlag) override ; @@ -97,10 +95,14 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool AvoidBox( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist) const override ; bool AvoidSphere( const Point3d& ptCenter, double dRad, double dSafeDist) const override ; bool AvoidCylinder( const Frame3d& frCyl, double dH, double dR, double dSafeDist) const override ; - VolZmap* ClonePart( int nPart) const override ; - bool RemovePart( int nPart) override ; bool Cut( const Plane3d& plPlane) override ; bool Compact( void) override ; + int GetPartCount( void) const override ; + bool GetPartVolume( int nPart, double& dVol) const override ; + bool GetPartLocalBBox( int nPart, BBox3d& b3Loc, int nFlag = BBF_STANDARD) const override ; + bool GetPartBBox( int nPart, const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const override ; + VolZmap* ClonePart( int nPart) const override ; + bool RemovePart( int nPart) override ; public : // IGeoObjRW int GetNgeId( void) const override ;