EgtGeomKernel 2.1b5 :
- in Zmap grafica migliorato controllo triangoli ribaltati
This commit is contained in:
Binary file not shown.
@@ -42,7 +42,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
|
||||
@@ -331,6 +331,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool GetFirstVoxIJK( int& i, int& j, int& k) const ;
|
||||
bool GetLastVoxIJK( int& i, int& j, int& k) const ;
|
||||
bool IsVoxelOnBoxEdge( int i, int j, int k) const ;
|
||||
bool CheckForFanNodeInterferance( AppliedVector CompVecField[], Point3d& ptFanVert,
|
||||
int nBasePointNum, int nVoxConfig, int nVoxI, int nVoxJ, int nVoxK) const ;
|
||||
bool IsTriangleOnBorder( const Triangle3dEx& trTria, const int nBlockLimits[], const int nVoxIJK[]) const ;
|
||||
// Funzioni per facce canoniche con grandi triangoli
|
||||
bool ProcessVoxContXY( FlatVoxelContainer& VoxContXY, int nBlock, bool bPlus) const ;
|
||||
|
||||
+91
-81
@@ -1411,6 +1411,7 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
}
|
||||
// Topologia indefinita: la calcolo
|
||||
if ( ! bDefTopology && bReg) {
|
||||
// Test sulla topologia
|
||||
Point3d ptFirstBar = ( CompoVert[0][0].ptPApp + CompoVert[0][1].ptPApp +
|
||||
CompoVert[0][2].ptPApp + CompoVert[0][3].ptPApp) / 4 ;
|
||||
Point3d ptSecondBar = ( CompoVert[1][0].ptPApp + CompoVert[1][1].ptPApp +
|
||||
@@ -1959,93 +1960,49 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
// Esprimo la soluzione nel sistema di riferimento z-map
|
||||
Point3d ptSol = ptGravityCenter + vtFeature ;
|
||||
|
||||
// Gestisco i ribaltamenti dei triangoli
|
||||
bool bExtConfirmed = true ;
|
||||
Vector3d vtNullSpace( dMatrixV( 0, 2), dMatrixV( 1, 2), dMatrixV( 2, 2)) ;
|
||||
if ( nFeatureType == EDGE && vtNullSpace.Normalize() && ! IsPointInsideVoxelApprox( i, j, k, ptSol)) {
|
||||
bool bVertMoved = false ;
|
||||
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 ;
|
||||
if ( vtDist.SqLen() < dMaxDist * dMaxDist) {
|
||||
ptSol = CompoVert[nComp][ni].ptPApp ;
|
||||
bVertMoved = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
// Gestione del caso configurazione 2 lungo creste di sharp-feature
|
||||
if ( ! bVertMoved && nAllConfig[nIndex] == 2) {
|
||||
// La tabella ha i vertici disposti in due modalità
|
||||
int nV0 = 0 ;
|
||||
int nV1 = 1 ;
|
||||
int nV2 = 2 ;
|
||||
int nV3 = 3 ;
|
||||
if ( ! Config2VertOrder( nIndex)) {
|
||||
int nTempV = nV3 ;
|
||||
nV3 = nV2 ;
|
||||
nV2 = nV1 ;
|
||||
nV1 = nV0 ;
|
||||
nV0 = nTempV ;
|
||||
}
|
||||
// Se le normali sono a due a due qauasi parallele e posizionate da dar origine a un ribaltamento
|
||||
if ( AreSameVectorApprox( CompoVert[nComp][nV0].vtVec, CompoVert[nComp][nV1].vtVec) &&
|
||||
AreSameVectorApprox( CompoVert[nComp][nV2].vtVec, CompoVert[nComp][nV3].vtVec)) {
|
||||
// Triangolo di prova
|
||||
Triangle3d trHintTria ;
|
||||
trHintTria.Set( ptSol, CompoVert[nComp][nV1].ptPApp, CompoVert[nComp][nV0].ptPApp) ;
|
||||
trHintTria.Validate( true) ;
|
||||
// Se avviene un ribaltamento non confermiamo ExtMC
|
||||
if ( trHintTria.GetN() * CompoVert[nComp][nV0].vtVec < - 0.9)
|
||||
bExtConfirmed = false ;
|
||||
if ( bExtConfirmed) {
|
||||
trHintTria.Set( ptSol, CompoVert[nComp][nV3].ptPApp, CompoVert[nComp][nV2].ptPApp) ;
|
||||
trHintTria.Validate( true) ;
|
||||
if ( trHintTria.GetN() * CompoVert[nComp][nV2].vtVec < - 0.9)
|
||||
bExtConfirmed = false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! bVertMoved && nAllConfig[nIndex] == 8) {
|
||||
bool bSpecialCase = false ;
|
||||
int nCouple[4] = { -1, -1, -1, -1} ;
|
||||
int nFirstFree = 0 ;
|
||||
for ( int a = 0 ; a < 4 ; ++ a) {
|
||||
int nNa = ( a + 1) % 4 ;
|
||||
if ( CompoVert[nComp][a].vtVec * CompoVert[nComp][nNa].vtVec > 0.9) {
|
||||
bool bNewCoupleValid = true ;
|
||||
for ( int b = 0 ; b < nFirstFree ; ++ b) {
|
||||
if ( nCouple[b] == a || nCouple[b] == nNa) {
|
||||
bNewCoupleValid = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( bNewCoupleValid) {
|
||||
nCouple[nFirstFree] = a ;
|
||||
nCouple[nFirstFree + 1] = nNa ;
|
||||
nFirstFree += 2 ;
|
||||
int nNewAdjVoxIJK[3] ;
|
||||
if ( GetPointVoxel( ptSol, nNewAdjVoxIJK[0], nNewAdjVoxIJK[1], nNewAdjVoxIJK[2])) {
|
||||
int nNewAdjVoxIndex = CalcIndex( nNewAdjVoxIJK[0], nNewAdjVoxIJK[1], nNewAdjVoxIJK[2]) ;
|
||||
if ( nNewAdjVoxIndex != 0) {
|
||||
bool bOverTurning = false ;
|
||||
for ( int m = 0 ; m < nVertComp[nComp] ; ++ m) {
|
||||
int l = ( m + 1) % nVertComp[nComp] ;
|
||||
Vector3d vtNlm = ( CompoVert[nComp][l].ptPApp - ptSol) ^ ( CompoVert[nComp][m].ptPApp - ptSol) ;
|
||||
vtNlm.Normalize() ;
|
||||
double dDotl = vtNlm * CompoVert[nComp][l].vtVec ;
|
||||
double dDotm = vtNlm * CompoVert[nComp][m].vtVec;
|
||||
if ( dDotl < - 0.8 || dDotm < - 0.8) {
|
||||
bOverTurning = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( bOverTurning) {
|
||||
Point3d ptMinDiag( ( i * N_DEXVOXRATIO + 0.5) * m_dStep,
|
||||
( j * N_DEXVOXRATIO + 0.5) * m_dStep,
|
||||
( k * N_DEXVOXRATIO + 0.5) * m_dStep) ;
|
||||
Point3d ptMaxDiag( ( ( i + 1) * N_DEXVOXRATIO + 0.5) * m_dStep,
|
||||
( ( j + 1) * N_DEXVOXRATIO + 0.5) * m_dStep,
|
||||
( ( k + 1) * N_DEXVOXRATIO + 0.5) * m_dStep) ;
|
||||
double dNewU1, dNewU2 ;
|
||||
if ( IntersLineBox( ptSol, vtNullSpace, ptMinDiag, ptMaxDiag, dNewU1, dNewU2)) {
|
||||
if ( dNewU1 < dNewU2) {
|
||||
ptSol += ( dNewU1 + EPS_SMALL * ( dNewU2 - dNewU1)) * vtNullSpace ;
|
||||
}
|
||||
else {
|
||||
ptSol += ( dNewU2 + EPS_SMALL * ( dNewU1 - dNewU2)) * vtNullSpace ;
|
||||
}
|
||||
}
|
||||
else
|
||||
bExtConfirmed = nVertComp[nComp] < 6 ? false : true ;
|
||||
}
|
||||
}
|
||||
if ( nCouple[3] != -1)
|
||||
bSpecialCase = true ;
|
||||
// Se le normali sono a due a due quasi parallele e posizionate da dar origine a un ribaltamento
|
||||
if ( bSpecialCase) {
|
||||
// Triangolo di prova
|
||||
Triangle3d trHintTria ;
|
||||
trHintTria.Set( ptSol, CompoVert[nComp][nCouple[1]].ptPApp, CompoVert[nComp][nCouple[0]].ptPApp) ;
|
||||
trHintTria.Validate( true) ;
|
||||
// Se avviene un ribaltamento non confermiamo ExtMC
|
||||
if ( trHintTria.GetN() * CompoVert[nComp][nCouple[0]].vtVec < - 0.9)
|
||||
bExtConfirmed = false ;
|
||||
if ( bExtConfirmed) {
|
||||
trHintTria.Set( ptSol, CompoVert[nComp][nCouple[3]].ptPApp, CompoVert[nComp][nCouple[2]].ptPApp) ;
|
||||
trHintTria.Validate( true) ;
|
||||
if ( trHintTria.GetN() * CompoVert[nComp][nCouple[2]].vtVec < - 0.9)
|
||||
bExtConfirmed = false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ExtMC confermato
|
||||
if ( bExtConfirmed) {
|
||||
int tOldCompo = VoxConf.nNumComp ;
|
||||
@@ -2060,8 +2017,8 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
VoxConf.Compo[tOldCompo].bCorner = ( nFeatureType == CORNER) ;
|
||||
}
|
||||
// ExtMC non confermato
|
||||
else
|
||||
CreateSmoothTriangle( nIndex, nVertComp[nComp], CompoTriVert[nComp], true, VoxSmoothTria) ;
|
||||
else
|
||||
CreateSmoothTriangle( nIndex, nVertComp[nComp], CompoTriVert[nComp], true, VoxSmoothTria) ;
|
||||
}
|
||||
// Standard MC
|
||||
else if ( m_nShape != BOX) {
|
||||
@@ -4085,6 +4042,59 @@ VolZmap::IsTriangleOnBorder( const Triangle3dEx& trTria, const int nBlockLimits[
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CheckForFanNodeInterferance( AppliedVector BaseVecField[], Point3d& ptFanVert,
|
||||
int nBasePointNum, int nVoxConfig, int nVoxI, int nVoxJ, int nVoxK) const
|
||||
{
|
||||
bool bInterferance = false ;
|
||||
int nFilterIndex = 1 ;
|
||||
for ( int n = 0 ; n < 7 ; ++ n) {
|
||||
bool bNodeInside = true ;
|
||||
if ( ( nVoxConfig & nFilterIndex) != 0) {
|
||||
int nNodeI = nVoxI ;
|
||||
int nNodeJ = nVoxJ ;
|
||||
int nNodeK = nVoxK ;
|
||||
if ( ( n + 1) % 4 >= 2)
|
||||
++ nNodeI ;
|
||||
if ( n % 4 >= 2)
|
||||
++ nNodeJ ;
|
||||
if ( n / 4 == 1)
|
||||
++ nNodeK ;
|
||||
Point3d ptNodeP( ( nNodeI * N_DEXVOXRATIO + 0.5) * m_dStep,
|
||||
( nNodeJ * N_DEXVOXRATIO + 0.5) * m_dStep,
|
||||
( nNodeK * N_DEXVOXRATIO + 0.5) * m_dStep) ;
|
||||
for ( int nV = 0 ; nV < nBasePointNum ; ++ nV) {
|
||||
int nW = ( nV + 1) % nBasePointNum ;
|
||||
Plane3d plPlane ;
|
||||
Vector3d vtN = ( BaseVecField[nW].ptPApp - ptFanVert) ^ ( BaseVecField[nV].ptPApp - ptFanVert) ;
|
||||
if ( plPlane.Set( ptFanVert, vtN) && DistPointPlane( ptNodeP, plPlane) > -EPS_SMALL) {
|
||||
bNodeInside = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( bNodeInside) {
|
||||
for ( int nV = 2 ; nV < nBasePointNum ; ++ nV) {
|
||||
Plane3d plPlane ;
|
||||
Vector3d vtN = ( BaseVecField[nV - 1].ptPApp - BaseVecField[0].ptPApp) ^ ( BaseVecField[nV].ptPApp - BaseVecField[0].ptPApp) ;
|
||||
if ( plPlane.Set( BaseVecField[0].ptPApp, vtN) && DistPointPlane( ptNodeP, plPlane) > -EPS_SMALL) {
|
||||
bNodeInside = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
bNodeInside = false ;
|
||||
|
||||
bInterferance = bInterferance || bNodeInside ;
|
||||
|
||||
nFilterIndex *= 2 ;
|
||||
}
|
||||
|
||||
return bInterferance ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::ProcessVoxContXY( FlatVoxelContainer& VoxContXY, int nBlock, bool bPlus) const
|
||||
|
||||
Reference in New Issue
Block a user