Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用Matlab';s内置类';Delaunay三角测量&x27;墨西哥_C++_Matlab_Mex - Fatal编程技术网

C++ 使用Matlab';s内置类';Delaunay三角测量&x27;墨西哥

C++ 使用Matlab';s内置类';Delaunay三角测量&x27;墨西哥,c++,matlab,mex,C++,Matlab,Mex,我想使用Matlab的类在mex函数中构建一组3D点的三角剖分,p[nx3矩阵] 在Matlab中 DT=delaunay三角剖分(p) 使用“Points”和“ConnectionyList”作为DT的类属性计算三角剖分 如何在mex文件中执行相同的操作 void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { .... int n; int elements = n*3; double*

我想使用Matlab的类在mex函数中构建一组3D点的三角剖分,p[nx3矩阵]

在Matlab中

DT=delaunay三角剖分(p)

使用“Points”和“ConnectionyList”作为DT的类属性计算三角剖分

如何在mex文件中执行相同的操作

void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { 
....

int n;
int elements = n*3;

double* P_ptr; /*contains 3D coordinates*/
P_ptr = mxMalloc(elements * sizeof(double));

/* fill up P_ptr with coordinates */

mxArray *DT, *P;

mxSetPr(P,P_ptr); /* Set P_ptr to mxArray P */
mxSetM(P, n);
mxSetN(P, 3);

mexCallMATLAB(1, &DT, 1, &P, "delaunayTriangulation");

....

}
走这条路对吗?另外,如果上面的代码是正确的,那么如何从输出mxArray*DT访问类属性(Points,ConnectivityList)

谢谢

编辑:将
DT
更改为
&DT
,以确保上述代码的正确性。此外,基于Sam的解决方案,我能够通过以下代码访问属性(例如“ConnectionyList”):


mxArray*variable_name=mxGetProperty(DT,0,“ConnectivityList”)

您应该能够使用来访问
mxArray
中对象的属性,谢谢Sam!这很有效。另外,我刚刚在上面的代码中计算,
mexCallMATLAB(1,DT,1,&P,“delaunayTriangulation”)
应替换为
mexCallMATLAB(1,&DT,1,&P,“delaunayTriangulation”)
@yellowmatercustard,如果答案适合您,请按答案左侧的勾选按钮将其标记为已接受。这有助于其他用户找到答案。此外,您还可以编辑问题,对您提到的代码进行更改。