EgtGeomKernel 2.1i1 :

- migliorie a ChainCurves
- aggiunta GetFeatureChaines a VolZmap.
This commit is contained in:
Dario Sassi
2019-09-12 07:43:35 +00:00
parent e79caee914
commit bd1efafbc0
7 changed files with 398 additions and 44 deletions
+182
View File
@@ -20,6 +20,7 @@
#include "PolygonPlane.h"
#include "/EgtDev/Include/EGkIntervals.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkChainCurves.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Extern/Eigen/Core"
#include "/EgtDev/Extern/Eigen/SVD"
@@ -4453,3 +4454,184 @@ VolZmap::Remove( FlatVoxelContainer& VoxCont, int nI, int nJ, int nK) const
return false ;
return ( VoxCont.erase( nN) > 0) ;
}
//----------------------------------------------------------------------------
bool
VolZmap::GetFeatureChaines( ICURVEPOVECTOR& vpCurve) const
{
// Garantisco grafica aggiornata
UpdateTripleMapGraphics() ;
// Vettore delle curve di feature
vector<CurveComposite> vLine ;
// Ciclo sui triangoli feature all'interno dei blocchi
for ( int nBlock = 0 ; nBlock < m_nNumBlock ; ++ nBlock) {
// Numero di voxel in cui si presentano sharp feature
int nVoxelNum = int( m_BlockSharpTria[nBlock].size()) ;
// Ciclo sui voxel con sharp feature
for ( int n1 = 0 ; n1 < nVoxelNum ; ++ n1) {
const SharpTriaStruct& SharpTria1 = m_BlockSharpTria[nBlock][n1] ;
for ( int n2 = n1 ; n2 < nVoxelNum ; ++ n2) {
const SharpTriaStruct& SharpTria2 = m_BlockSharpTria[nBlock][n2] ;
// Se non adiacenti o coincidenti vado oltre
if ( abs( SharpTria2.i - SharpTria1.i) > 1 ||
abs( SharpTria2.j - SharpTria1.j) > 1 ||
abs( SharpTria2.k - SharpTria1.k) > 1)
continue ;
// Ciclo sulle componenti connesse del primo voxel
int nNumCompo1 = int( SharpTria1.ptCompoVert.size()) ;
for ( int nCompo1 = 0 ; nCompo1 < nNumCompo1 ; ++ nCompo1) {
const TRIA3DEXVECTOR& vTria1 = SharpTria1.vCompoTria[nCompo1] ;
// Numero di triangoli della componente connessa
int nTriNum1 = int( vTria1.size()) ;
// Ciclo sulle componenti connesse del secondo voxel
int nNumCompo2 = int( SharpTria2.ptCompoVert.size()) ;
int nCompo2 = ( n1 == n2 ? nCompo1 + 1 : 0) ;
for ( ; nCompo2 < nNumCompo2 ; ++ nCompo2) {
const TRIA3DEXVECTOR& vTria2 = SharpTria2.vCompoTria[nCompo2] ;
// Numero di triangoli della componente connessa
int nTriNum2 = int( vTria2.size()) ;
for ( int nTri1 = 0 ; nTri1 < nTriNum1 ; ++ nTri1) {
for ( int nTri2 = 0 ; nTri2 < nTriNum2 ; ++ nTri2) {
// Punti che devono essere in comune fra i due triangoli
const Point3d& ptP10 = vTria1[nTri1].GetP( 0) ;
const Point3d& ptP11 = vTria1[nTri1].GetP( 1) ;
const Point3d& ptP20 = vTria2[nTri2].GetP( 0) ;
const Point3d& ptP21 = vTria2[nTri2].GetP( 1) ;
// I triangoli sono sono stati flippati
if ( AreSamePointEpsilon( ptP10, ptP21, EPS_ZERO) &&
AreSamePointEpsilon( ptP11, ptP20, EPS_ZERO) &&
! AreSameVectorApprox( vTria1[nTri1].GetN(), vTria2[nTri2].GetN())) {
// Segmento che congiunge le sharp-features
CurveComposite cvLine ;
if ( cvLine.AddPoint( ptP10) && cvLine.AddLine( ptP11))
vLine.emplace_back( cvLine) ;
}
}
}
}
}
}
}
}
// Ciclo sui triangoli feature al confine tra blocchi
for ( int tFB = 0 ; tFB < m_nNumBlock ; ++ tFB) {
int nFBijk[3] ;
GetBlockIJKFromN( int( tFB), nFBijk) ;
for ( int tLB = tFB ; tLB < m_nNumBlock ; ++ tLB) {
int nLBijk[3] ;
GetBlockIJKFromN( int( tLB), nLBijk) ;
// Se i blocchi non sono adiacenti salto l'iterazione
if ( abs( nFBijk[0] - nLBijk[0]) > 1 ||
abs( nFBijk[1] - nLBijk[1]) > 1 ||
abs( nFBijk[2] - nLBijk[2]) > 1)
continue ;
// Numero di voxel nei blocchi correnti
int nVoxelNumFB = int( m_InterBlockSharpTria[tFB].size()) ;
int nVoxelNumLB = int( m_InterBlockSharpTria[tLB].size()) ;
// Ciclo sui voxel dei due blocchi
for ( int tVFB = 0 ; tVFB < nVoxelNumFB ; ++ tVFB) {
for ( int tVLB = 0 ; tVLB < nVoxelNumLB ; ++ tVLB) {
// Se i voxel non sono adiacenti salto l'iterazione
if ( abs( m_InterBlockSharpTria[tFB][tVFB].i - m_InterBlockSharpTria[tLB][tVLB].i) > 1 ||
abs( m_InterBlockSharpTria[tFB][tVFB].j - m_InterBlockSharpTria[tLB][tVLB].j) > 1 ||
abs( m_InterBlockSharpTria[tFB][tVFB].k - m_InterBlockSharpTria[tLB][tVLB].k) > 1)
continue ;
// Numero di componenti connesse dei voxel
int nCompoVFBNum = int( m_InterBlockSharpTria[tFB][tVFB].ptCompoVert.size()) ;
int nCompoVLBNum = int( m_InterBlockSharpTria[tLB][tVLB].ptCompoVert.size()) ;
// Ciclo sulle componenti connesse
for ( int tCmpF = 0 ; tCmpF < nCompoVFBNum ; ++ tCmpF) {
for ( int tCmpL = 0 ; tCmpL < nCompoVLBNum ; ++ tCmpL) {
// Numero di triangoli delle componenti connesse
int nTriFBNum = int( m_InterBlockSharpTria[tFB][tVFB].vCompoTria[tCmpF].size()) ;
int nTriLBNum = int( m_InterBlockSharpTria[tLB][tVLB].vCompoTria[tCmpL].size()) ;
// Ciclo sui triangoli
for ( int tTriFB = 0 ; tTriFB < nTriFBNum ; ++ tTriFB) {
for ( int tTriLB = 0 ; tTriLB < nTriLBNum ; ++ tTriLB) {
// Punti che devono essere in comune fra i due triangoli
Point3d ptPF0 = m_InterBlockSharpTria[tFB][tVFB].vCompoTria[tCmpF][tTriFB].GetP( 0) ;
Point3d ptPF1 = m_InterBlockSharpTria[tFB][tVFB].vCompoTria[tCmpF][tTriFB].GetP( 1) ;
Point3d ptPL0 = m_InterBlockSharpTria[tLB][tVLB].vCompoTria[tCmpL][tTriLB].GetP( 0) ;
Point3d ptPL1 = m_InterBlockSharpTria[tLB][tVLB].vCompoTria[tCmpL][tTriLB].GetP( 1) ;
// I triangoli sono stati flippati
if ( AreSamePointEpsilon( ptPF0, ptPL1, EPS_ZERO) &&
AreSamePointEpsilon( ptPF1, ptPL0, EPS_ZERO) &&
! AreSameVectorApprox( m_InterBlockSharpTria[tFB][tVFB].vCompoTria[tCmpF][tTriFB].GetN(),
m_InterBlockSharpTria[tLB][tVLB].vCompoTria[tCmpL][tTriLB].GetN())) {
// Segmento che congiunge le sharp-features
CurveComposite cvLine ;
if ( cvLine.AddPoint( ptPF0) && cvLine.AddLine( ptPF1))
vLine.emplace_back( cvLine) ;
}
}
}
}
}
}
}
}
}
// Creo le curve
for ( int n = 0 ; n < int( vLine.size()) ; ++ n) {
bool bExpanded = false ;
int nNumSt = 0 ;
int nNumEn = 0 ;
int nMSt = - 1 ;
int nMEn = - 1 ;
Point3d ptSt, ptEn ;
vLine[n].GetStartPoint( ptSt) ;
vLine[n].GetEndPoint( ptEn) ;
for ( int m = 0 ; m < int( vLine.size()) ; ++ m) {
if ( m == n)
continue ;
Point3d ptStM, ptEnM ;
vLine[m].GetStartPoint( ptStM) ;
vLine[m].GetEndPoint( ptEnM) ;
if ( AreSamePointEpsilon( ptSt, ptStM, 100 * EPS_SMALL) || AreSamePointEpsilon( ptSt, ptEnM, 100 * EPS_SMALL)) {
nMSt = m ;
++ nNumSt ;
}
if ( AreSamePointEpsilon( ptEn, ptStM, 100 * EPS_SMALL) || AreSamePointEpsilon( ptEn, ptEnM, 100 * EPS_SMALL)) {
nMEn = m ;
++ nNumEn ;
}
}
if ( nNumSt == 1) {
Point3d ptStM ;
vLine[nMSt].GetStartPoint( ptStM) ;
if ( AreSamePointEpsilon( ptSt, ptStM, 100 * EPS_SMALL))
vLine[nMSt].Invert() ;
bool bAdded = vLine[n].AddCurve( vLine[nMSt], false) ;
vLine.erase( vLine.begin() + nMSt) ;
bExpanded = true ;
}
else if ( nNumEn == 1) {
Point3d ptEnM ;
vLine[nMEn].GetEndPoint( ptEnM) ;
if ( AreSamePointEpsilon( ptEn, ptEnM, 100 * EPS_SMALL))
vLine[nMEn].Invert() ;
bool bAdded = vLine[n].AddCurve( vLine[nMEn]) ;
vLine.erase( vLine.begin() + nMEn) ;
bExpanded = true ;
}
if ( bExpanded)
-- n ;
nMSt = - 1 ;
nMEn = - 1 ;
}
for ( int n = 0 ; n < int( vLine.size()) ; ++ n) {
PtrOwner<CurveComposite> pCurve( vLine[n].Clone()) ;
if ( IsNull( pCurve))
return false ;
pCurve->MergeCurves( EPS_SMALL, ANG_TOL_STD_DEG) ;
// Inserisco la curva composita nella raccolta da ritornare
vpCurve.emplace_back( Release( pCurve)) ;
}
return true ;
}