diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index a96df26..db53337 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -1012,6 +1012,76 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& GetBBox( frBox, b3Box) ; frOCS.Translate( b3Box.GetMin().z * frOCS.VersZ()) ; +#if 0 + // *** 1° Sfruttando le adiacenze *** + // Non funziona perchè genera loop con anelli + // Copio la superficie + PtrOwner pStm( Clone()) ; + if ( IsNull( pStm)) + return false ; + + // Elimino i triangoli con normale non equiversa alla direzione scelta + for ( int i = 0 ; i < int( pStm->m_vTria.size()) ; ++ i) { + // se già cancellato, passo oltre + if ( pStm->m_vTria[i].nIdVert[0] == SVT_DEL) + continue ; + // verifico la normale + if ( pStm->m_vTria[i].vtN * vtVers < EPS_ZERO) + pStm->RemoveTriangle( i) ; + } + // dichiaro facce non calcolate + pStm->m_bFaceted = false ; + + // Proietto la superficie + pStm->Scale( frOCS, 1, 1, 0) ; + + // Recupero i loop della nuova superficie + POLYLINEVECTOR vMyPL ; + if ( pStm->GetLoops( vMyPL)) { + // calcolo la regione della superficie proiettata + bool bOk = true ; + PtrOwner pSfr ; + for ( int i = 0 ; i < int( vMyPL.size()) && bOk ; ++ i) { + // Regione di un loop + PtrOwner pSfrPart( GetSurfFlatRegionFromPolyLine( vMyPL[i])) ; + if ( ! IsNull( pSfrPart)) { + pSfrPart->Offset( dTol, ICurve::OFF_FILLET) ; + if ( IsNull( pSfr)) + if ( pSfrPart->GetNormVersor() * vtVers > 0) + bOk = pSfr.Set( Release( pSfrPart)) ; + else + bOk = false ; + else { + if ( pSfrPart->GetNormVersor() * vtVers > 0) + bOk = pSfr->Add( *pSfrPart) ; + else { + pSfrPart->Invert() ; + bOk = pSfr->Subtract( *pSfrPart) ; + } + } + } + else + bOk = false ; + } + // Verifico esistenza della regione + if ( bOk && ! IsNull( pSfr)) { + // Effettuo contro-offset + pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ; + // Recupero i contorni della regione + for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) { + for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) { + PolyLine PL ; + if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL)) + vPL.emplace_back( PL) ; + } + } + return true ; + } + } + vPL.clear() ; +#endif + + // *** 2° Mediante unione delle regioni dei triangoli proiettati *** // calcolo la regione dei triangoli proiettati PtrOwner pSfr ; Triangle3d Tria ; @@ -1050,30 +1120,6 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& } return true ; - -#if 0 - - // Copio la superficie - PtrOwner pStm( Clone()) ; - if ( IsNull( pStm)) - return false ; - - // Elimino i triangoli con normale non equiversa alla direzione scelta - for ( int i = 0 ; i < int( pStm->m_vTria.size()) ; ++ i) { - // se già cancellato, passo oltre - if ( pStm->m_vTria[i].nIdVert[0] == SVT_DEL) - continue ; - // verifico la normale - if ( pStm->m_vTria[i].vtN * vtVers < - EPS_ZERO) - pStm->RemoveTriangle( i) ; - } - // dichiaro facce non calcolate - pStm->m_bFaceted = false ; - - // Recupero i loop della nuova superficie - return pStm->GetLoops( vPL) ; - -#endif } //----------------------------------------------------------------------------