Octave 如何将delaunay三角形列表排序为八度有序渗流列表?

Octave 如何将delaunay三角形列表排序为八度有序渗流列表?,octave,delaunay,Octave,Delaunay,给出所有三角形的列表 v2_T = delaunay(v2_p) 从所有点v2_p的列表中,并给出所有三角形邻域的列表 v2_N = neighbors(v2_T) 如何对v2_T进行排序,以便从第一个三角形开始,在v2_T中找到的下一个三角形始终至少有一个我前面列出的三角形邻居。我能想到的执行类似任务的壁橱函数可能是二叉树搜索或涉及递归算法的东西 有人能提供八度音阶的代码吗?谢谢。这是我对上述问题未承诺的解决方案。这是一个用C++编写的八度音动态链接函数,文件名为DLFI- PyCalAT

给出所有三角形的列表

v2_T = delaunay(v2_p)
从所有点v2_p的列表中,并给出所有三角形邻域的列表

v2_N = neighbors(v2_T)
如何对v2_T进行排序,以便从第一个三角形开始,在v2_T中找到的下一个三角形始终至少有一个我前面列出的三角形邻居。我能想到的执行类似任务的壁橱函数可能是二叉树搜索或涉及递归算法的东西


有人能提供八度音阶的代码吗?谢谢。

这是我对上述问题未承诺的解决方案。这是一个用C++编写的八度音动态链接函数,文件名为DLFI- PyCalAT.CC。要编译此函数,请在倍频程终端中使用命令系统“mkoctfile filedirectory/dlf_percolate.cc”或替代命令mkoctfile filedirectory/dlf_percolate.cc,其中必须指定保存文件dlf_percolate.cc的文件目录filedirectory。要测试函数v1_I=dlf_percolatev2_N,需要一个生成的邻域列表v2_N=neightrsv2_T,其中v2_T是生成的delaunay三角形列表,而neights是一个在倍频程中还不存在的函数。可以使用包msh中使用的函数来计算邻居v2_N。一旦有了v2_N,就可以计算渗流顺序的数字标记三角形的顺序为v1_I=dlf_percolatev2_N,v_first_neigh,其中v_first_neigh是第一个开始计算列出的三角形v1_I的渗流顺序的三角形

#include <octave/oct.h>
void func_perc
    (
        Matrix & v2_neigh_list
        ,
        ColumnVector & v1_perc_list
        ,
        ColumnVector & b1_toggled_neigh
        ,
        int & v0_perc_index
        ,
        int v0_next_neigh
    ) ;
DEFUN_DLD (dlf_percolate, args, ,
"Returns a list of sorted indices of the neighbors in percolated order."
) {
    int v0_first_neigh = 1 ;
    switch( args.length() )
    {
    case 1:
        // v0_first_neigh = 1 default value
        break;
    case 2:
        v0_first_neigh = args(1).scalar_value() ;
        break;
    default:
        error("Only one or two inputs are needed!") ;
        return args;
        break;
    }
    octave_value_list o1_retval ;
    Matrix v2_neigh_list = args(0).matrix_value() ;
    int v0_cols = v2_neigh_list.cols();
    int v0_rows = v2_neigh_list.rows();
    if( ( v0_first_neigh <= 0 ) || ( v0_rows < v0_first_neigh ) )
    {
        error("v0_first_neigh must be a valid member of the list!") ;
        return args;
    }
    ColumnVector v1_perc_list(v0_rows,0);
    ColumnVector b1_toggled_neigh(v0_rows,false);
    int v0_perc_index = 0 ;
    func_perc
        (
            v2_neigh_list
            ,
            v1_perc_list
            ,
            b1_toggled_neigh
            ,
            v0_perc_index
            ,
            v0_first_neigh
        ) ;
    o1_retval(0) = v1_perc_list ;
    return o1_retval ;
}
void func_perc
    (
        Matrix & v2_neigh_list
        ,
        ColumnVector & v1_perc_list
        ,
        ColumnVector & b1_toggled_neigh
        ,
        int & v0_perc_index
        ,
        int v0_next_neigh
    )
    {
        if
            (
                ( v0_next_neigh > 0 )
                &&
                ( ( v0_perc_index ) < v1_perc_list.length() )
                &&
                ( b1_toggled_neigh( v0_next_neigh - 1 ) == false )
            )
            {
                v1_perc_list( v0_perc_index ) = v0_next_neigh ;
                v0_perc_index++;
                b1_toggled_neigh( v0_next_neigh - 1 ) = true ;
                for( int v0_i = 0 ; v0_i < v2_neigh_list.cols() ; v0_i++ )
                    {
                        func_perc
                            (
                                v2_neigh_list
                                ,
                                v1_perc_list
                                ,
                                b1_toggled_neigh
                                ,
                                v0_perc_index
                                ,
                                v2_neigh_list( v0_next_neigh - 1 , v0_i )
                            ) ;
                    }
            }
        return ;
    }
我相信任何计算出的渗流路径都必须包含一个递归算法。如果不是,递归至少可以使代码实现更容易地解决这些类型的问题。我在Octave脚本中为此函数设计的第一个构建递归地调用了Octave函数,该函数在递归算法的每一步都运行得越来越慢。我相信在倍频程函数中的递归不是很有效,因为解释语言的函数过于复杂。在八度字节中编写C++中的本机函数是一种更好的实现递归算法的方法。C++函数是一个递归算法,它在DLFI-渗流中使用。