From 42fa94881d4c85461cf15c1426ac1b7a86ac7dd2 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 19 Apr 2018 16:44:40 +0000 Subject: [PATCH] EgtGeomKernel : - correzioni a calcolo grafica di Zmap. --- VolZmapGraphics.cpp | 53 +++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/VolZmapGraphics.cpp b/VolZmapGraphics.cpp index 80a3c16..3729038 100644 --- a/VolZmapGraphics.cpp +++ b/VolZmapGraphics.cpp @@ -1404,8 +1404,8 @@ VolZmap::ExtMarchingCubes( int nBlock, TRIA3DEXLIST& lstTria, VoxelContainer& vV // Ciclo su tutti i voxel del blocco for ( int i = nLimits[0] ; i < nLimits[1] ; ++ i) { for ( int j = nLimits[2] ; j < nLimits[3] ; ++ j) { - for ( int k = nLimits[4] ; k < nLimits[5] ; ++ k) { - + for ( int k = nLimits[4] ; k < nLimits[5] ; ++ k) { + // Classificazione dei vertici: interni o esterni al materiale int nIndex = CalcIndex( i, j, k) ; @@ -1570,7 +1570,7 @@ VolZmap::ExtMarchingCubes( int nBlock, TRIA3DEXLIST& lstTria, VoxelContainer& vV dDotSum -= CompoVert[1][nTVI].vtVec * CompoVert[1][nTVJ].vtVec ; } } - bool bTestOnSum = dDotSum > 0 ; + bool bTestOnSum = dDotSum > - EPS_SMALL ; // Si passa alla seconda topologia if ( bTestOnSum) { // Ricerca del caso corrispondente della nuova topologia @@ -1794,15 +1794,29 @@ VolZmap::ExtMarchingCubes( int nBlock, TRIA3DEXLIST& lstTria, VoxelContainer& vV Vector3d vtFeature( dUnknownVector( 0), dUnknownVector( 1), dUnknownVector( 2)) ; // Esprimo la soluzione nel sistema di riferimento z-map Point3d ptSol = ptGravityCenter + vtFeature ; + + Vector3d vtNullSpace( dMatrixV( 0, 2), dMatrixV( 1, 2), dMatrixV( 2, 2)) ; + if ( nFeatureType == EDGE && vtNullSpace.Normalize() && ! IsPointInsideVoxelApprox( i, j, k, ptSol)) { + for ( int ni = 0 ; ni < nVertComp[nComp] ; ++ ni) { + Vector3d vtBaseVert = CompoVert[nComp][ni].ptPApp - ptSol ; + Vector3d vtDist = vtBaseVert - vtBaseVert * vtNullSpace * vtNullSpace ; + double dMaxDist = 0.005 * N_DEXVOXRATIO * m_dStep ; + double bau = vtDist.Len() ; + if ( vtDist.SqLen() < dMaxDist * dMaxDist) { + ptSol = CompoVert[nComp][ni].ptPApp ; + break ; + } + } + } size_t tOldCompo = VoxConf.nNumComp ; ++ VoxConf.nNumComp ; VoxConf.Compo[tOldCompo].nVertNum = nVertComp[nComp] ; for ( int nV = 0 ; nV < nVertComp[nComp] ; ++ nV) { VoxConf.Compo[tOldCompo].CompVecField[nV] = CompoVert[nComp][nV] ; - } + } VoxConf.Compo[tOldCompo].ptVert = ptSol ; - VoxConf.Compo[tOldCompo].bInside = IsPointInsideVoxelApprox( i, j, k, ptSol, 0) ; + VoxConf.Compo[tOldCompo].bInside = IsPointInsideVoxelApprox( i, j, k, ptSol, EPS_SMALL) ; VoxConf.Compo[tOldCompo].bCorner = ( nFeatureType == CORNER) ; } // Standard MC @@ -1897,9 +1911,7 @@ VolZmap::RegulateFeaturesChain( std::vector& vVecVox) const Voxel& CurVox = itVox->second ; GetVoxNFromIJK( CurVox.i, CurVox.j, CurVox.k, nVox) ; // Ciclo sulle componenti - for ( int nComp = 0 ; nComp < CurVox.nNumComp ; ++ nComp) { - if ( nBlock == 1 && nVox == 41024 && nComp == 0) - int a = 1 ; + for ( int nComp = 0 ; nComp < CurVox.nNumComp ; ++ nComp) { // Vertice fuori dal suo voxel if ( ! CurVox.Compo[nComp].bInside) { // Caso corner @@ -3255,30 +3267,9 @@ bool VolZmap::IsATriangleOnBorder( const Triangle3dEx& trTria, const Point3d& ptVert, const int nBlockLimits[], const int nVoxIJK[]) const { - // Se il triangolo ha area nulla, esco - if ( trTria.GetArea() < EPS_SMALL) - return false ; - - // Determino i punti del triangolo sulla griglia - int nNotVert[2] ; - int nCount = 0 ; - for ( int nV = 0 ; nV < 3 ; ++ nV) { - if ( SqDist( trTria.GetP( nV), ptVert) > SQ_EPS_SMALL) { - if ( nCount == 0) - nNotVert[nCount] = nV ; - else if ( nCount == 1) - nNotVert[nCount] = nV ; - nCount ++ ; - } - } - - // Se non ho trovato due punti, errore - if ( nCount != 2) - return false ; - // Punti del triangolo sulla griglia - Point3d ptFirstGrPt = trTria.GetP( nNotVert[0]) ; - Point3d ptSecondGrPt = trTria.GetP( nNotVert[1]) ; + Point3d ptFirstGrPt = trTria.GetP( 1) ; + Point3d ptSecondGrPt = trTria.GetP( 2) ; // Verifico se tali punti sono sulla griglia for ( int nC = 0 ; nC < 3 ; ++ nC) {