vtkPolydata中取点的坑
来源:互联网 发布:淘宝详情页好做吗 编辑:程序博客网 时间:2024/06/04 17:57
for (int i = 0; i < lines->GetNumberOfCells(); i++) { // 获取一条centerline vtkIdType nbCellPoints; vtkIdType* points; lines->GetNextCell(nbCellPoints, points); // 迭代该条centerline,获取小线段 for (int j = 0; j < nbCellPoints-1; j++) { vtkIdType pid1 = points[j]; vtkIdType pid2 = points[j + 1]; double* p1 = polydata->GetPoints()->GetPoint(pid1); double* p2 = polydata->GetPoints()->GetPoint(pid1); cout << "P1 : " << pid1 << " " << p1[0] / spacing[0] << "," << p1[1] / spacing[1] << "," << p1[2] / spacing[2] << endl; cout << "P2 : " << pid2 << " " << p2[0] / spacing[0] << "," << p2[1] / spacing[1] << "," << p2[2] / spacing[2] << endl; } }
输出结果:
P1 : 131 111,177,121P2 : 130 111,177,121P1 : 130 112,178,120P2 : 129 112,178,120P1 : 129 112,178,119P2 : 128 112,178,119P1 : 128 112,177,118P2 : 127 112,177,118P1 : 127 112,176,117P2 : 126 112,176,117P1 : 126 111,175,116...
发现每次输出P1跟P2坐标相同,好久没发现问题所在。追踪到源码,发现这么一段warning,细想一下,这样设计业很好理解。
// Description: // Return a pointer to a double point x[3] for a specific id. // WARNING: Just don't use this error-prone method, the returned pointer // and its values are only valid as long as another method invocation is not // performed. Prefer GetPoint() with the return value in argument. double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id); } // Description: // Copy point components into user provided array v[3] for specified // id. void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x); }
更新程序使用
double p1[3]; double p2[3]; polydata->GetPoints()->GetPoint(pid1, p1); polydata->GetPoints()->GetPoint(pid2, p2);
目标达成。
阅读全文
0 0
- vtkPolydata中取点的坑
- VtkPolyData的镜像操作
- vtkImagedata与vtkPolydata的减采样
- vtkPolyData中GetPoint函数冲掉上一个数据的问题
- 用于理解vtkPolyData和vtkCellArray的一段代码
- 求两个多边形数据 vtkPolyData 的相交线
- vtkPolyData 的空间变换(平移、旋转、缩放)
- vtkPolyData 转 vtkAlgorithmOutput
- vtkPolydata转换成QPixmap
- 【vtk】数据类型转换vtkpolydata转vtkImagedata
- angularJS遇到的的坑
- Google的Gson的坑
- 遇到的Hive的坑
- 遇到的Spark的坑
- php的curl的坑
- RadioGroup的OnCheckedChangeListener的坑
- html的坑,js的坑
- 坑坑的程序员
- HTML5_video视频
- JSP里的basePath
- hanlp for elasticsearch(基于hanlp的es分词插件)
- hdu 1131 卡特兰数,大数
- 求最大公约数和最小公倍数的三个算法
- vtkPolydata中取点的坑
- 【luogu1941】飞扬的小鸟(背包dp)
- linux-文件挂载
- 1057. 数零壹
- 函数crossvalind
- nginx学习笔记(一)
- Kibana使用的lucene查询语法
- Selection Sort(选择排序)
- django channels websocket 聊天室