eltopo3d/surftrack.cpp
// --------------------------------------------------------
///
/// Fire an assert if any triangle has repeated vertices or if any zero-volume tets are found.
///
// --------------------------------------------------------
Fire an assert if any triangle has repeated vertices or if any zero-volume tets are found.
Fire an assert if any triangle has repeated vertices or if any zero - volume tets are found .
void SurfTrack::assert_no_degenerate_triangles( )
{
    for ( size_t i = 0; i < m_mesh.num_triangles(); ++i )
    {
        const Vec3st& current_triangle = m_mesh.get_triangle(i);
        if ( (current_triangle[0] == 0) && (current_triangle[1] == 0) && (current_triangle[2] == 0) ) 
        {
            continue;
        }
         check if triangle has repeated vertices
        assert ( !( (current_triangle[0] == current_triangle[1]) || 
                   (current_triangle[1] == current_triangle[2]) || 
                   (current_triangle[2] == current_triangle[0]) ) );
         look for flaps
        const Vec3st& tri_edges = m_mesh.m_triangle_to_edge_map[i];
        bool flap_found = false;
        for ( unsigned int e = 0; e < 3 && flap_found == false; ++e )
        {
            const std::vector<size_t>& edge_tris = m_mesh.m_edge_to_triangle_map[ tri_edges[e] ];
            for ( size_t t = 0; t < edge_tris.size(); ++t )
            {
                if ( edge_tris[t] == i )
                {
                    continue;
                }
                size_t other_triangle_index = edge_tris[t];
                const Vec3st& other_triangle = m_mesh.get_triangle( other_triangle_index );
                if ( (other_triangle[0] == other_triangle[1]) || 
                    (other_triangle[1] == other_triangle[2]) || 
                    (other_triangle[2] == other_triangle[0]) ) 
                {
                    assert( !"repeated vertices" );
                }
                if ( ((current_triangle[0] == other_triangle[0]) || (current_triangle[0] == other_triangle[1]) || (current_triangle[0] == other_triangle[2])) &&
                    ((current_triangle[1] == other_triangle[0]) || (current_triangle[1] == other_triangle[1]) || (current_triangle[1] == other_triangle[2])) &&
                    ((current_triangle[2] == other_triangle[0]) || (current_triangle[2] == other_triangle[1]) || (current_triangle[2] == other_triangle[2])) ) 
                {
                    size_t common_edge = tri_edges[e];
                    if ( m_mesh.oriented( m_mesh.m_edges[common_edge][0], m_mesh.m_edges[common_edge][1], current_triangle ) == 
                        m_mesh.oriented( m_mesh.m_edges[common_edge][0], m_mesh.m_edges[common_edge][1], other_triangle ) )
                    { 
                        assert( false );
                        continue;
                    }
                    assert( false );
                }
            }         
        }
    }
}
void SurfTrack :: assert_no_degenerate_triangles ( ) { for ( size_t i = 0 ; i < m_mesh . num_triangles ( ) ; ++ i ) { const Vec3st & current_triangle = m_mesh . get_triangle ( i ) ; if ( ( current_triangle [ 0 ] == 0 ) && ( current_triangle [ 1 ] == 0 ) && ( current_triangle [ 2 ] == 0 ) ) { continue ; } assert ( ! ( ( current_triangle [ 0 ] == current_triangle [ 1 ] ) || ( current_triangle [ 1 ] == current_triangle [ 2 ] ) || ( current_triangle [ 2 ] == current_triangle [ 0 ] ) ) ) ; const Vec3st & tri_edges = m_mesh . m_triangle_to_edge_map [ i ] ; bool flap_found = false ; for ( unsigned int e = 0 ; e < 3 && flap_found == false ; ++ e ) { const std :: vector < size_t > & edge_tris = m_mesh . m_edge_to_triangle_map [ tri_edges [ e ] ] ; for ( size_t t = 0 ; t < edge_tris . size ( ) ; ++ t ) { if ( edge_tris [ t ] == i ) { continue ; } size_t other_triangle_index = edge_tris [ t ] ; const Vec3st & other_triangle = m_mesh . get_triangle ( other_triangle_index ) ; if ( ( other_triangle [ 0 ] == other_triangle [ 1 ] ) || ( other_triangle [ 1 ] == other_triangle [ 2 ] ) || ( other_triangle [ 2 ] == other_triangle [ 0 ] ) ) { assert ( ! " " ) ; } if ( ( ( current_triangle [ 0 ] == other_triangle [ 0 ] ) || ( current_triangle [ 0 ] == other_triangle [ 1 ] ) || ( current_triangle [ 0 ] == other_triangle [ 2 ] ) ) && ( ( current_triangle [ 1 ] == other_triangle [ 0 ] ) || ( current_triangle [ 1 ] == other_triangle [ 1 ] ) || ( current_triangle [ 1 ] == other_triangle [ 2 ] ) ) && ( ( current_triangle [ 2 ] == other_triangle [ 0 ] ) || ( current_triangle [ 2 ] == other_triangle [ 1 ] ) || ( current_triangle [ 2 ] == other_triangle [ 2 ] ) ) ) { size_t common_edge = tri_edges [ e ] ; if ( m_mesh . oriented ( m_mesh . m_edges [ common_edge ] [ 0 ] , m_mesh . m_edges [ common_edge ] [ 1 ] , current_triangle ) == m_mesh . oriented ( m_mesh . m_edges [ common_edge ] [ 0 ] , m_mesh . m_edges [ common_edge ] [ 1 ] , other_triangle ) ) { assert ( false ) ; continue ; } assert ( false ) ; } } } } }
Fire an assert if any triangle has repeated vertices or if any zero-volume tets are found.
Fire an assert if any triangle has repeated vertices or if any zero - volume tets are found .
// for each triangle on the surface // deleted triangle // // check if triangle has repeated vertices // // // look for flaps //