EgtGeomKernel 2.1b4 :
- modifiche a Zmap per gestione ambiguità topologia nei casi 3, 6, 7 e 10.
This commit is contained in:
+227
-129
@@ -58,6 +58,17 @@ Config2VertOrder( int nInd)
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Config3Duality(int nInd)
|
||||
{
|
||||
if (nInd == 5 || nInd == 10 || nInd == 18 || nInd == 24 || nInd == 33 || nInd == 36 ||
|
||||
nInd == 66 || nInd == 72 || nInd == 80 || nInd == 129 || nInd == 132 || nInd == 160)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Config6Duality( int nInd)
|
||||
@@ -70,6 +81,16 @@ Config6Duality( int nInd)
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Config7Duality( int nInd)
|
||||
{
|
||||
if ( nInd == 26 || nInd == 37 || nInd == 74 || nInd == 82 ||
|
||||
nInd == 88 || nInd == 133 || nInd == 161 || nInd == 164)
|
||||
return true ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
TestOnNormal( const AppliedVector CompoField[], int nCompoElem)
|
||||
@@ -1157,114 +1178,151 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
}
|
||||
|
||||
// Configurazione 3
|
||||
if ( nAllConfig[nIndex] == 3) {
|
||||
if (nAllConfig[nIndex] == 3) {
|
||||
// Test sulla topologia
|
||||
bool bDefTopology = false ;
|
||||
bool bNewTopology = false ;
|
||||
bool bMatOnSlice = false ;
|
||||
int nCount = 0 ;
|
||||
while ( nIndexConfig3[nCount] != nIndex)
|
||||
++ nCount ;
|
||||
// Vedo se la topologia è definita: se sì uso l'informazione
|
||||
// passata dall'altro voxel, altrimenti la calcolo
|
||||
// Vedo se la topologia è definita: se sì uso l'informazione
|
||||
// passata dall'altro voxel, altrimenti la calcolo
|
||||
int nIJKSl[3] = { ( nAdjVox3[nCount] != 1 ? i : i + 1),
|
||||
( nAdjVox3[nCount] != 2 ? j : j + 1),
|
||||
( nAdjVox3[nCount] != 3 ? k : k + 1)} ;
|
||||
( nAdjVox3[nCount] != 3 ? k : k + 1) } ;
|
||||
int nSliceN ;
|
||||
int nSlBlockN ;
|
||||
if ( GetVoxNFromIJK( nIJKSl[0], nIJKSl[1], nIJKSl[2], nSliceN)) {
|
||||
if ( GetVoxNFromIJK(nIJKSl[0], nIJKSl[1], nIJKSl[2], nSliceN)) {
|
||||
int nSlBlockIJK[3] ;
|
||||
GetVoxelBlockIJK( nIJKSl, nSlBlockIJK) ;
|
||||
GetVoxelBlockIJK(nIJKSl, nSlBlockIJK) ;
|
||||
if ( abs( nAdjVox3[nCount]) == 1) {
|
||||
auto it = SliceYZ.find( nSliceN) ;
|
||||
if ( it != SliceYZ.end()) {
|
||||
bNewTopology = it->second ;
|
||||
if ( it != SliceYZ.end()) {
|
||||
bMatOnSlice = it->second ;
|
||||
bDefTopology = true ;
|
||||
}
|
||||
if ( GetBlockNFromIJK( nSlBlockIJK, nSlBlockN)) {
|
||||
auto it = m_SliceYZ[nSlBlockN].find( nSliceN) ;
|
||||
if ( it != m_SliceYZ[nSlBlockN].end()) {
|
||||
bNewTopology = it->second ;
|
||||
bMatOnSlice = it->second ;
|
||||
bDefTopology = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( abs( nAdjVox3[nCount]) == 2) {
|
||||
auto it = SliceXZ.find( nSliceN) ;
|
||||
if ( it != SliceXZ.end()) {
|
||||
bNewTopology = it->second ;
|
||||
if ( it != SliceXZ.end()) {
|
||||
bMatOnSlice = it->second ;
|
||||
bDefTopology = true ;
|
||||
}
|
||||
if ( GetBlockNFromIJK( nSlBlockIJK, nSlBlockN)) {
|
||||
auto it = m_SliceXZ[nSlBlockN].find( nSliceN);
|
||||
auto it = m_SliceXZ[nSlBlockN].find( nSliceN) ;
|
||||
if ( it != m_SliceXZ[nSlBlockN].end()) {
|
||||
bNewTopology = it->second ;
|
||||
bMatOnSlice = it->second ;
|
||||
bDefTopology = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( abs( nAdjVox3[nCount]) == 3) {
|
||||
auto it = SliceXY.find( nSliceN) ;
|
||||
if ( it != SliceXY.end()) {
|
||||
bNewTopology = it->second ;
|
||||
if ( it != SliceXY.end()) {
|
||||
bMatOnSlice = it->second ;
|
||||
bDefTopology = true ;
|
||||
}
|
||||
if ( GetBlockNFromIJK( nSlBlockIJK, nSlBlockN)) {
|
||||
auto it = m_SliceXY[nSlBlockN].find( nSliceN) ;
|
||||
if ( it != m_SliceXY[nSlBlockN].end()) {
|
||||
bNewTopology = it->second ;
|
||||
bMatOnSlice = it->second ;
|
||||
bDefTopology = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// La topologia è indefinita: calcolo la topologia
|
||||
// La topologia è indefinita: calcolo la topologia
|
||||
if ( ! bDefTopology && bReg) {
|
||||
double dDotSum = 0 ;
|
||||
for ( int nFV = 0 ; nFV < 3 ; ++ nFV) {
|
||||
for ( int nTV = 0 ; nTV < 2 ; ++ nTV) {
|
||||
dDotSum += CompoVert[0][nFV].vtVec * CompoVert[1][nTV].vtVec ;
|
||||
}
|
||||
|
||||
Point3d ptFirstBar = ( CompoVert[0][0].ptPApp + CompoVert[0][1].ptPApp + CompoVert[0][2].ptPApp) / 3 ;
|
||||
Point3d ptSecondBar = ( CompoVert[1][0].ptPApp + CompoVert[1][1].ptPApp + CompoVert[1][2].ptPApp) / 3 ;
|
||||
Vector3d vtDiagBar = ptSecondBar - ptFirstBar ;
|
||||
vtDiagBar.Normalize() ;
|
||||
int nSum = 0 ;
|
||||
for ( int nVec = 0 ; nVec < 3 ; ++ nVec) {
|
||||
if ( CompoVert[0][nVec].vtVec * vtDiagBar > 0.7)
|
||||
++ nSum ;
|
||||
else if ( CompoVert[0][nVec].vtVec * vtDiagBar < -0.7)
|
||||
-- nSum;
|
||||
if ( CompoVert[1][nVec].vtVec * vtDiagBar < -0.7)
|
||||
++ nSum ;
|
||||
else if ( CompoVert[1][nVec].vtVec * vtDiagBar > 0.7)
|
||||
-- nSum ;
|
||||
}
|
||||
for ( int nFVI = 0 ; nFVI < 2 ; ++ nFVI) {
|
||||
for ( int nFVJ = nFVI + 1 ; nFVJ < 3 ; ++ nFVJ) {
|
||||
dDotSum -= CompoVert[0][nFVI].vtVec * CompoVert[0][nFVJ].vtVec ;
|
||||
|
||||
if ( nSum < - 2)
|
||||
bMatOnSlice = true ;
|
||||
if ( nSum <= 2) {
|
||||
Vector3d vtVoxCentre ;
|
||||
if ( nAdjVox3[nCount] == - 1)
|
||||
vtVoxCentre = X_AX ;
|
||||
else if ( nAdjVox3[nCount] == 1)
|
||||
vtVoxCentre = - X_AX ;
|
||||
else if ( nAdjVox3[nCount] == - 2)
|
||||
vtVoxCentre = Y_AX ;
|
||||
else if ( nAdjVox3[nCount] == 2)
|
||||
vtVoxCentre = - Y_AX ;
|
||||
else if ( nAdjVox3[nCount] == - 3)
|
||||
vtVoxCentre = Z_AX ;
|
||||
else if ( nAdjVox3[nCount] == 3)
|
||||
vtVoxCentre = - Z_AX ;
|
||||
|
||||
int nPlusNum = 0 ;
|
||||
int nMinusNum = 0 ;
|
||||
for ( int nVec = 0 ; nVec < 3 ; ++ nVec) {
|
||||
if ( CompoVert[0][nVec].vtVec * vtVoxCentre > EPS_SMALL)
|
||||
++ nPlusNum ;
|
||||
else if ( CompoVert[0][nVec].vtVec * vtVoxCentre < - EPS_SMALL)
|
||||
-- nMinusNum ;
|
||||
if ( CompoVert[1][nVec].vtVec * vtVoxCentre > EPS_SMALL)
|
||||
++ nPlusNum ;
|
||||
else if ( CompoVert[1][nVec].vtVec * vtVoxCentre < - EPS_SMALL)
|
||||
-- nMinusNum ;
|
||||
}
|
||||
|
||||
if ( nPlusNum >= nMinusNum)
|
||||
bMatOnSlice = true ;
|
||||
}
|
||||
for ( int nTVI = 0 ; nTVI < 2 ; ++ nTVI) {
|
||||
for ( int nTVJ = nTVI + 1 ; nTVJ < 3 ; ++ nTVJ) {
|
||||
dDotSum -= CompoVert[1][nTVI].vtVec * CompoVert[1][nTVJ].vtVec ;
|
||||
}
|
||||
}
|
||||
bNewTopology = dDotSum > - EPS_SMALL ;
|
||||
else
|
||||
;
|
||||
}
|
||||
// Conservo l'informazione per i voxel successivi
|
||||
// Conservo l'informazione per i voxel successivi
|
||||
if ( GetVoxNFromIJK( nIJKSl[0], nIJKSl[1], nIJKSl[2], nSliceN)) {
|
||||
if ( abs(nAdjVox3[nCount]) == 1) {
|
||||
if ( nSlBlockN == nBlock)
|
||||
SliceYZ.emplace( nSliceN, ! bNewTopology) ;
|
||||
SliceYZ.emplace( nSliceN, bMatOnSlice) ;
|
||||
else
|
||||
m_SliceYZ[nSlBlockN].emplace( nSliceN, ! bNewTopology) ;
|
||||
}
|
||||
m_SliceYZ[nSlBlockN].emplace( nSliceN, bMatOnSlice) ;
|
||||
}
|
||||
else if ( abs(nAdjVox3[nCount]) == 2) {
|
||||
if ( nSlBlockN == nBlock)
|
||||
SliceXZ.emplace( nSliceN, ! bNewTopology) ;
|
||||
SliceXZ.emplace( nSliceN, bMatOnSlice) ;
|
||||
else
|
||||
m_SliceXZ[nSlBlockN].emplace( nSliceN, ! bNewTopology) ;
|
||||
m_SliceXZ[nSlBlockN].emplace( nSliceN, bMatOnSlice) ;
|
||||
}
|
||||
else if (abs(nAdjVox3[nCount]) == 3) {
|
||||
else if ( abs(nAdjVox3[nCount]) == 3) {
|
||||
if ( nSlBlockN == nBlock)
|
||||
SliceXY.emplace( nSliceN, ! bNewTopology) ;
|
||||
SliceXY.emplace(nSliceN, bMatOnSlice) ;
|
||||
else
|
||||
m_SliceXY[nSlBlockN].emplace( nSliceN, ! bNewTopology) ;
|
||||
}
|
||||
m_SliceXY[nSlBlockN].emplace( nSliceN, bMatOnSlice) ;
|
||||
}
|
||||
}
|
||||
|
||||
bool bNewTopology = Config3Duality( nIndex) ? bMatOnSlice : ! bMatOnSlice ;
|
||||
|
||||
// Si passa alla seconda topologia
|
||||
if ( bNewTopology) {
|
||||
// Ricerca del caso corrispondente della nuova topologia
|
||||
int nt = 0 ;
|
||||
while ( nIndexVsIndex3[nt][0] != nIndex)
|
||||
++ nt ;
|
||||
++ nt;
|
||||
int nRotCase = nIndexVsIndex3[nt][1] ;
|
||||
// Aggiorno numero di componenti
|
||||
nComponents = Cases3Plus[nRotCase][1][0] ;
|
||||
@@ -1279,10 +1337,10 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
for ( int nFanVert = 0 ; nFanVert < nVertComp[nC - 1] ; ++ nFanVert)
|
||||
CompoVert[nC - 1][nFanVert] = VecField[Cases3Plus[nRotCase][1][nFanVert + nExtTabOff + 1]] ;
|
||||
// Matrici dei vertici dei triangoli in assenza di sharp feature
|
||||
for ( int nTriVert = 0 ; nTriVert < 3 * ( nVertComp[nC - 1] - 2) ; nTriVert += 3) {
|
||||
CompoTriVert[nC - 1][nTriVert] = VecField[Cases3Plus[nRotCase][0][nStdTabOff + nTriVert+2]] ;
|
||||
CompoTriVert[nC - 1][nTriVert+1] = VecField[Cases3Plus[nRotCase][0][nStdTabOff + nTriVert+1]] ;
|
||||
CompoTriVert[nC - 1][nTriVert+2] = VecField[Cases3Plus[nRotCase][0][nStdTabOff + nTriVert]] ;
|
||||
for ( int nTriVert = 0 ; nTriVert < 3 * (nVertComp[nC - 1] - 2) ; nTriVert += 3) {
|
||||
CompoTriVert[nC - 1][nTriVert] = VecField[Cases3Plus[nRotCase][0][nStdTabOff + nTriVert + 2]] ;
|
||||
CompoTriVert[nC - 1][nTriVert + 1] = VecField[Cases3Plus[nRotCase][0][nStdTabOff + nTriVert + 1]] ;
|
||||
CompoTriVert[nC - 1][nTriVert + 2] = VecField[Cases3Plus[nRotCase][0][nStdTabOff + nTriVert]] ;
|
||||
}
|
||||
// Aggiorno gli offsets per raggiungere i vertici della componente successiva.
|
||||
nExtTabOff += nVertComp[nC - 1] ;
|
||||
@@ -1354,26 +1412,64 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
}
|
||||
// Topologia indefinita: la calcolo
|
||||
if ( ! bDefTopology && bReg) {
|
||||
// Test sulla topologia
|
||||
double dDotSum = 0 ;
|
||||
for ( int nFV = 0 ; nFV < 4 ; ++ nFV) {
|
||||
for ( int nTV = 0 ; nTV < 3 ; ++ nTV) {
|
||||
dDotSum += CompoVert[0][nFV].vtVec * CompoVert[1][nTV].vtVec ;
|
||||
}
|
||||
Point3d ptFirstBar = ( CompoVert[0][0].ptPApp + CompoVert[0][1].ptPApp +
|
||||
CompoVert[0][2].ptPApp + CompoVert[0][3].ptPApp) / 3 ;
|
||||
Point3d ptSecondBar = ( CompoVert[1][0].ptPApp + CompoVert[1][1].ptPApp +
|
||||
CompoVert[1][2].ptPApp) / 3 ;
|
||||
Vector3d vtDiagBar = ptSecondBar - ptFirstBar ;
|
||||
vtDiagBar.Normalize() ;
|
||||
int nSum = 0 ;
|
||||
for ( int nVec = 0 ; nVec < 4 ; ++ nVec) {
|
||||
if ( CompoVert[0][nVec].vtVec * vtDiagBar > 0.7)
|
||||
++ nSum ;
|
||||
else if ( CompoVert[0][nVec].vtVec * vtDiagBar < - 0.7)
|
||||
-- nSum ;
|
||||
}
|
||||
for ( int nFVI = 0 ; nFVI < 3 ; ++ nFVI) {
|
||||
for ( int nFVJ = nFVI + 1 ; nFVJ < 4 ; ++ nFVJ) {
|
||||
dDotSum -= CompoVert[0][nFVI].vtVec * CompoVert[0][nFVJ].vtVec ;
|
||||
}
|
||||
for ( int nVec = 0 ; nVec < 3 ; ++ nVec) {
|
||||
if ( CompoVert[1][nVec].vtVec * vtDiagBar < - 0.7)
|
||||
++ nSum ;
|
||||
else if ( CompoVert[1][nVec].vtVec * vtDiagBar > 0.7)
|
||||
-- nSum ;
|
||||
}
|
||||
for ( int nTVI = 0 ; nTVI < 2 ; ++ nTVI) {
|
||||
for ( int nTVJ = nTVI + 1 ; nTVJ < 3 ; ++ nTVJ) {
|
||||
dDotSum -= CompoVert[1][nTVI].vtVec * CompoVert[1][nTVJ].vtVec ;
|
||||
|
||||
if ( nSum < - 3)
|
||||
bMatOnSlice = true ;
|
||||
else if ( nSum <= 3) {
|
||||
Vector3d vtVoxCentre ;
|
||||
if ( nAdjVox6[nCount] == -1)
|
||||
vtVoxCentre = X_AX ;
|
||||
else if ( nAdjVox6[nCount] == 1)
|
||||
vtVoxCentre = - X_AX ;
|
||||
else if ( nAdjVox6[nCount] == -2)
|
||||
vtVoxCentre = Y_AX ;
|
||||
else if ( nAdjVox6[nCount] == 2)
|
||||
vtVoxCentre = - Y_AX ;
|
||||
else if ( nAdjVox6[nCount] == -3)
|
||||
vtVoxCentre = Z_AX ;
|
||||
else if ( nAdjVox6[nCount] == 3)
|
||||
vtVoxCentre = - Z_AX ;
|
||||
|
||||
int nPlusNum = 0 ;
|
||||
int nMinusNum = 0 ;
|
||||
for ( int nVec = 0 ; nVec < 4 ; ++ nVec) {
|
||||
if ( CompoVert[0][nVec].vtVec * vtVoxCentre > EPS_SMALL)
|
||||
++ nPlusNum ;
|
||||
else if ( CompoVert[0][nVec].vtVec * vtVoxCentre < -EPS_SMALL)
|
||||
-- nMinusNum ;
|
||||
}
|
||||
for ( int nVec = 0 ; nVec < 3 ; ++ nVec) {
|
||||
if ( CompoVert[1][nVec].vtVec * vtVoxCentre > EPS_SMALL)
|
||||
++ nPlusNum ;
|
||||
else if ( CompoVert[1][nVec].vtVec * vtVoxCentre < -EPS_SMALL)
|
||||
-- nMinusNum ;
|
||||
}
|
||||
|
||||
if ( nPlusNum >= nMinusNum)
|
||||
bMatOnSlice = true ;
|
||||
|
||||
}
|
||||
bMatOnSlice = dDotSum > - 4 ;
|
||||
if ( Config6Duality( nIndex))
|
||||
bMatOnSlice = ! bMatOnSlice ;
|
||||
else
|
||||
;
|
||||
}
|
||||
// Conservo l'informazione
|
||||
if ( GetVoxNFromIJK( nIJKSl[0], nIJKSl[1], nIJKSl[2], nSliceN)) {
|
||||
@@ -1446,35 +1542,37 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
// Vedo se la topologia è definita: se sì uso l'informazione già posseduta,
|
||||
// altrimenti devo calcolare la topologia
|
||||
|
||||
// Numerazione delle facce del voxel: 0: XZ- 1: YZ+ 2: XZ+ 3: YZ- 4: XY- 5: XY+
|
||||
// Numerazione delle facce del voxel: 0: YZ- 1: XZ- 2: YZ+ 3: XZ+ 4: XY- 5: XY+
|
||||
// - 1 faccia non in gioco, 0 faccia in gioco ma con topologia non definita,
|
||||
// 1 faccia in gioco con topologia definita
|
||||
int nFace[6] = { -1, -1, -1, -1, -1, -1} ;
|
||||
// Facce in gioco
|
||||
int nCurFaceYZ = 3 ;
|
||||
int nCurFaceXZ = 0 ;
|
||||
int nCurFaceYZ = 0 ;
|
||||
int nCurFaceXZ = 1 ;
|
||||
int nCurFaceXY = 4 ;
|
||||
|
||||
int nIJKSlYZ[3] = { i, j, k} ;
|
||||
if ( nAdjVox7[nCount][0] == 1) {
|
||||
++ nIJKSlYZ[0] ;
|
||||
nCurFaceYZ = 1 ;
|
||||
nCurFaceYZ = 2 ;
|
||||
}
|
||||
int nIJKSlXZ[3] = { i, j, k} ;
|
||||
if ( nAdjVox7[nCount][1] == 1) {
|
||||
if ( nAdjVox7[nCount][1] == 2) {
|
||||
++ nIJKSlXZ[1] ;
|
||||
nCurFaceXZ = 2 ;
|
||||
nCurFaceXZ = 3 ;
|
||||
}
|
||||
int nIJKSlXY[3] = { i, j, k} ;
|
||||
if ( nAdjVox7[nCount][2] == 1) {
|
||||
if ( nAdjVox7[nCount][2] == 3) {
|
||||
++ nIJKSlXY[2] ;
|
||||
nCurFaceXY = 5 ;
|
||||
}
|
||||
// Assegno l'indice zero alle facce in gioco. L'indice zero è per le facce in gioco
|
||||
// su cui non si è certi se ci sia o meno materiale.
|
||||
nFace[nCurFaceYZ] = 0 ;
|
||||
nFace[nCurFaceXZ] = 0 ;
|
||||
nFace[nCurFaceXY] = 0 ;
|
||||
|
||||
|
||||
// Per ogni faccia in gioco vediamo se c'è materiale: se sì assegnamo l'indice 1
|
||||
int nSlYZN ;
|
||||
int nSlYZBlockN ;
|
||||
if ( GetVoxNFromIJK( nIJKSlYZ[0], nIJKSlYZ[1], nIJKSlYZ[2], nSlYZN)) {
|
||||
@@ -1548,11 +1646,12 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
}
|
||||
}
|
||||
|
||||
// Numerazione delle facce del voxel 0: XZ- 1: YZ+ 2: XZ+ 3: YZ- 4: XY- 5: XY+
|
||||
// Gli spigoli sono ordinati in senso antiorario dal punto di vista di un osservatore esterno del voxel
|
||||
static int nSliceEdges[6][4] = { { 0, 9, 4, 8}, { 1, 10, 5, 9}, { 2, 11, 6, 10},
|
||||
{ 3, 8, 7, 11}, { 0, 3, 2, 1}, { 4, 5, 6, 7}} ;
|
||||
// nFace[nCurFaceXY] * nFace[nCurFaceXZ] * nFace[nCurFaceYZ] == 0
|
||||
// Numerazione delle facce del voxel 0: YZ- 1: XZ- 2: YZ+ 3: XZ+ 4: XY- 5: XY+
|
||||
// Gli spigoli sono ordinati in senso antiorario dal punto di vista di un osservatore esterno al voxel
|
||||
static int nSliceEdges[6][4] = { { 3, 8, 7, 11}, { 0, 9, 4, 8}, { 1, 10, 5, 9}, { 2, 11, 6, 10},
|
||||
{ 0, 3, 2, 1}, { 4, 5, 6, 7} } ;
|
||||
// Le facce in gioco hano indici nCurFaceXY, nCurFaceXZ e nCurFaceYZ. Se per almeno una faccia non si sa se c'è materiale,
|
||||
// ovvero almeno una faccia ha indice 0, e il campo vettoriale normale è regolare verifico la presenza di materiale.
|
||||
if ( ( nFace[nCurFaceXY] == 0 || nFace[nCurFaceXZ] == 0 || nFace[nCurFaceYZ] == 0) && bReg) {
|
||||
// Ciclo sulle facce
|
||||
for ( int nFaceN = 0 ; nFaceN < 6 ; ++ nFaceN) {
|
||||
@@ -1561,14 +1660,13 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
// Dalla tabella determino le due componenti connesse che si appoggiano alla faccia
|
||||
int nFaceCompo1 = 0 ;
|
||||
int nFaceCompo2 = 0 ;
|
||||
|
||||
// Ciclo sulle componenti connesse del voxel
|
||||
for ( int nCurComp = 1 ; nCurComp <= 3 ; ++ nCurComp) {
|
||||
int nMatchEdge = 0 ;
|
||||
// Ciclo sugli edge della componente
|
||||
for ( int nEdge = 0 ; nEdge < 3 ; ++ nEdge) {
|
||||
// Ciclo sugli edge della faccia
|
||||
for ( int nFaceEdge = 0 ; nFaceEdge < 3 ; ++ nFaceEdge) {
|
||||
for ( int nFaceEdge = 0 ; nFaceEdge < 4 ; ++ nFaceEdge) {
|
||||
// Edge della componente coincide con quello della faccia
|
||||
if ( nSliceEdges[nFaceN][nFaceEdge] == TriangleTableEn[nIndex][1][3 + nCurComp - 1 + nEdge]) {
|
||||
++ nMatchEdge ;
|
||||
@@ -1606,42 +1704,43 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
bMatOnSliceXY = dDotSum > 0. ;
|
||||
}
|
||||
}
|
||||
int nFaceWithMatNum = 0 ;
|
||||
if ( bMatOnSliceXZ)
|
||||
++ nFaceWithMatNum ;
|
||||
if ( bMatOnSliceYZ)
|
||||
++ nFaceWithMatNum ;
|
||||
if ( bMatOnSliceXY)
|
||||
++ nFaceWithMatNum ;
|
||||
if ( nFaceWithMatNum == 1) {
|
||||
int nFaceCase = ( bMatOnSliceYZ ? 0 : ( bMatOnSliceXZ ? 1 : 2)) ;
|
||||
// Aggiorno numero di componenti
|
||||
nComponents = Cases7Plus[nCount][nFaceCase][1][0] ;
|
||||
// Riaggiorno gli offsets
|
||||
nExtTabOff = nComponents ;
|
||||
nStdTabOff = 0 ;
|
||||
// Modifico le matrici
|
||||
for ( int nC = 1 ; nC <= nComponents ; ++ nC) {
|
||||
// Numero vertici per componenti
|
||||
nVertComp[nC - 1] = Cases7Plus[nCount][nFaceCase][1][nC] ;
|
||||
// Matrice dei vertici della base del fan
|
||||
for ( int nFanVert = 0 ; nFanVert < nVertComp[nC - 1] ; ++ nFanVert)
|
||||
CompoVert[nC - 1][nFanVert] = VecField[Cases7Plus[nCount][nFaceCase][1][nFanVert + nExtTabOff + 1]] ;
|
||||
// Matrici dei vertici dei triangoli in assenza di sharp feature
|
||||
for ( int nTriVert = 0 ; nTriVert < 3 * ( nVertComp[nC - 1] - 2) ; nTriVert += 3) {
|
||||
CompoTriVert[nC - 1][nTriVert] = VecField[Cases7Plus[nCount][nFaceCase][0][nStdTabOff + nTriVert+2]] ;
|
||||
CompoTriVert[nC - 1][nTriVert+1] = VecField[Cases7Plus[nCount][nFaceCase][0][nStdTabOff + nTriVert+1]] ;
|
||||
CompoTriVert[nC - 1][nTriVert+2] = VecField[Cases7Plus[nCount][nFaceCase][0][nStdTabOff + nTriVert]] ;
|
||||
}
|
||||
// Aggiorno gli offsets per raggiungere i vertici della componente successiva.
|
||||
nExtTabOff += nVertComp[nC - 1] ;
|
||||
nStdTabOff += 3 * ( nVertComp[nC - 1] - 2) ;
|
||||
}
|
||||
// Uso le informazioni per scegliere la topologia
|
||||
int nFaceWithMatNum = 0 ;
|
||||
if ( bMatOnSliceXZ)
|
||||
++ nFaceWithMatNum ;
|
||||
if ( bMatOnSliceYZ)
|
||||
++ nFaceWithMatNum ;
|
||||
if ( bMatOnSliceXY)
|
||||
++ nFaceWithMatNum ;
|
||||
if ( nFaceWithMatNum == 1) {
|
||||
int nFaceCase = ( bMatOnSliceYZ ? 0 : (bMatOnSliceXZ ? 1 : 2)) ;
|
||||
// Aggiorno numero di componenti
|
||||
nComponents = Cases7Plus[nCount][nFaceCase][1][0] ;
|
||||
// Riaggiorno gli offsets
|
||||
nExtTabOff = nComponents ;
|
||||
nStdTabOff = 0 ;
|
||||
// Modifico le matrici
|
||||
for ( int nC = 1 ; nC <= nComponents ; ++ nC) {
|
||||
// Numero vertici per componenti
|
||||
nVertComp[nC - 1] = Cases7Plus[nCount][nFaceCase][1][nC] ;
|
||||
// Matrice dei vertici della base del fan
|
||||
for ( int nFanVert = 0 ; nFanVert < nVertComp[nC - 1] ; ++ nFanVert)
|
||||
CompoVert[nC - 1][nFanVert] = VecField[Cases7Plus[nCount][nFaceCase][1][nFanVert + nExtTabOff + 1]] ;
|
||||
// Matrici dei vertici dei triangoli in assenza di sharp feature
|
||||
for ( int nTriVert = 0 ; nTriVert < 3 * (nVertComp[nC - 1] - 2) ; nTriVert += 3) {
|
||||
CompoTriVert[nC - 1][nTriVert] = VecField[Cases7Plus[nCount][nFaceCase][0][nStdTabOff + nTriVert + 2]] ;
|
||||
CompoTriVert[nC - 1][nTriVert + 1] = VecField[Cases7Plus[nCount][nFaceCase][0][nStdTabOff + nTriVert + 1]] ;
|
||||
CompoTriVert[nC - 1][nTriVert + 2] = VecField[Cases7Plus[nCount][nFaceCase][0][nStdTabOff + nTriVert]] ;
|
||||
}
|
||||
}
|
||||
else if ( nFaceWithMatNum == 2) {
|
||||
;
|
||||
}
|
||||
}
|
||||
// Aggiorno gli offsets per raggiungere i vertici della componente successiva.
|
||||
nExtTabOff += nVertComp[nC - 1] ;
|
||||
nStdTabOff += 3 * (nVertComp[nC - 1] - 2) ;
|
||||
}
|
||||
}
|
||||
else if ( nFaceWithMatNum == 2) {
|
||||
;
|
||||
}
|
||||
// Conservo l'informazione
|
||||
if ( GetVoxNFromIJK( nIJKSlYZ[0], nIJKSlYZ[1], nIJKSlYZ[2], nSlYZN)) {
|
||||
if ( nSlYZBlockN == nBlock)
|
||||
@@ -1666,7 +1765,7 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
else if ( nAllConfig[nIndex] == 10) {
|
||||
// Test sulla topologia
|
||||
bool bDefStTopology = false ;
|
||||
bool bNewTopology = false ;
|
||||
bool bMatOnSlice = false ;
|
||||
int nCount = 0 ;
|
||||
while ( nIndexConfig10[nCount] != nIndex)
|
||||
++ nCount ;
|
||||
@@ -1683,21 +1782,21 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
if ( abs( nAdjVox10[nCount]) == 1) {
|
||||
auto itSt = SliceYZ.find( nSliceStN) ;
|
||||
if ( itSt != SliceYZ.end()) {
|
||||
bNewTopology = itSt->second ;
|
||||
bMatOnSlice = itSt->second ;
|
||||
bDefStTopology = true ;
|
||||
}
|
||||
}
|
||||
else if ( abs( nAdjVox10[nCount]) == 2) {
|
||||
auto itSt = SliceXZ.find( nSliceStN) ;
|
||||
if ( itSt != SliceXZ.end()) {
|
||||
bNewTopology = itSt->second ;
|
||||
bMatOnSlice = itSt->second ;
|
||||
bDefStTopology = true ;
|
||||
}
|
||||
}
|
||||
else if ( abs( nAdjVox10[nCount]) == 3) {
|
||||
auto itSt = SliceXY.find( nSliceStN) ;
|
||||
if ( itSt != SliceXY.end()) {
|
||||
bNewTopology = itSt->second ;
|
||||
bMatOnSlice = itSt->second ;
|
||||
bDefStTopology = true ;
|
||||
}
|
||||
}
|
||||
@@ -1709,7 +1808,7 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
Vector3d vtCmpAvg0, vtCmpAvg1 ;
|
||||
bool bTest0 = DotTest( CompoVert[0], 4, vtCmpAvg0, 0.0) ;
|
||||
bool bTest1 = DotTest( CompoVert[1], 4, vtCmpAvg1, 0.0) ;
|
||||
bNewTopology = ( ! bTest0 || ! bTest1) ;
|
||||
bMatOnSlice = ( ! bTest0 || ! bTest1) ;
|
||||
}
|
||||
// Conservo l'informazioe e la trasmetto al voxel successivo
|
||||
if ( GetVoxNFromIJK( nIJKSlSt[0], nIJKSlSt[1], nIJKSlSt[2], nSliceStN) &&
|
||||
@@ -1718,40 +1817,40 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
if ( GetBlockNFromIJK( nIJKSlEn, nSlBlockEnN)) {
|
||||
auto it = m_SliceYZ[nSlBlockEnN].find( nSliceEnN) ;
|
||||
if ( it != m_SliceYZ[nSlBlockEnN].end()) {
|
||||
if ( it->second != bNewTopology)
|
||||
if ( it->second != bMatOnSlice)
|
||||
m_BlockToUpdate[nSlBlockEnN] = true ;
|
||||
it->second = bNewTopology ;
|
||||
it->second = bMatOnSlice ;
|
||||
}
|
||||
else
|
||||
m_SliceYZ[nSlBlockEnN].emplace( nSliceEnN, bNewTopology) ;
|
||||
m_SliceYZ[nSlBlockEnN].emplace( nSliceEnN, bMatOnSlice) ;
|
||||
}
|
||||
}
|
||||
else if ( abs( nAdjVox6[nCount]) == 2) {
|
||||
if ( GetBlockNFromIJK( nIJKSlEn, nSlBlockEnN)) {
|
||||
auto it = m_SliceXZ[nSlBlockEnN].find( nSliceEnN) ;
|
||||
if ( it != m_SliceXZ[nSlBlockEnN].end()) {
|
||||
if ( it->second != bNewTopology)
|
||||
if ( it->second != bMatOnSlice)
|
||||
m_BlockToUpdate[nSlBlockEnN] = true ;
|
||||
it->second = bNewTopology ;
|
||||
it->second = bMatOnSlice ;
|
||||
}
|
||||
else
|
||||
m_SliceXZ[nSlBlockEnN].emplace( nSliceEnN, bNewTopology) ;
|
||||
m_SliceXZ[nSlBlockEnN].emplace( nSliceEnN, bMatOnSlice) ;
|
||||
}
|
||||
}
|
||||
else if ( abs( nAdjVox6[nCount]) == 3) {
|
||||
if ( GetBlockNFromIJK( nIJKSlEn, nSlBlockEnN)) {
|
||||
auto it = m_SliceXY[nSlBlockEnN].find( nSliceEnN) ;
|
||||
if ( it != m_SliceXY[nSlBlockEnN].end()) {
|
||||
if ( it->second != bNewTopology)
|
||||
if ( it->second != bMatOnSlice)
|
||||
m_BlockToUpdate[nSlBlockEnN] = true ;
|
||||
it->second = bNewTopology ;
|
||||
it->second = bMatOnSlice ;
|
||||
}
|
||||
else
|
||||
m_SliceXY[nSlBlockEnN].emplace( nSliceEnN, bNewTopology) ;
|
||||
m_SliceXY[nSlBlockEnN].emplace( nSliceEnN, bMatOnSlice) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool bNewTopology = bMatOnSlice ;
|
||||
// Si passa alla seconda topologia
|
||||
if ( bNewTopology) {
|
||||
// Ricerca del caso corrispondente della nuova topologia
|
||||
@@ -1781,7 +1880,6 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Voxel VoxConf ;
|
||||
VoxConf.nNumComp = 0 ;
|
||||
|
||||
Reference in New Issue
Block a user