我已经使用vtkDijkstraGraphGeodesicPath
类(例如:http://www.cmake.org/Wiki/VTK/Examples/Cxx/PolyData/DijkstraGraphGeodesicPath)来查找网格上两点之间的最短路径,我的下一步是将路径(曲线)投影到平面。在vtk中是否有类或函数将曲线投影到平面? 另一种方法是采样路径(曲线),然后将采样点投影到平面,那么如何对曲线进行采样并获取采样点?提前谢谢!如何在vtk中投影曲线到平面
1
A
回答
1
我从来没有找到一种方法来进行3D网格投影,但我不得不使用它,并且我选择了纹理化方法,允许在平面/圆柱体/球体上投影网格(对texzturize) 。
在这种情况下使用的主要方法是vtkTextureMapToPlane。
// your mesh
vtkSmartPointer<vtkPolyData> mainMesh = myFilter->GetOutput();
// extract your path from the poly data
// retrieve selected ids from dijkstra algo
vtkSmartPointer<vtkIdList> idList = dijkstra->GetIdList();
vtkSmartPointer<vtkIdTypeArray> ids = convertToIdTypeArr (idList); // custom method to convert id array
// Once the ID selections is done, the extraction is invoked
vtkSmartPointer<vtkSelectionNode> selectionNode = vtkSelectionNode::New();
selectionNode->SetFieldType (vtkSelectionNode::POINT);
selectionNode->SetContentType (vtkSelectionNode::INDICES);
selectionNode->SetSelectionList (ids);
vtkSmartPointer<vtkSelection> selection = vtkSelection::New();
selection->AddNode (selectionNode);
vtkSmartPointer<vtkExtractSelection> extract = vtkExtractSelection::New();
extract->SetInputData (0, pl);
extract->SetInputData (1, selection);
// convert result to polydata
vtkSmartPointer<vtkGeometryFilter> geoFilter = vtkGeometryFilter::New();
geoFilter->SetInputConnection (extract->GetOutputPort());
geoFilter->Update();
vtkSmartPointer<vtkPolyData> selected = geoFilter->GetOutput();
您有一个vtkpolyData
带有顶点的路径。您需要创建的平面和项目
// plane is sized with 800x600, on y-z directions
double orig[3] = {0, 0, 0};
double pt1[3] = {0, 600, 0};
double pt2[3] = {0, 0, 800};
// create TextureMapToPlan instance
vtkSmartPointer<vtkTextureMapToPlane> planeMapper = vtkTextureMapToPlane::New();
planeMapper->SetOrigin(orig);
planeMapper->SetPoint1(pt1);
planeMapper->SetPoint2(pt2);
planeMapper->SetInputData (selected);
planeMapper->Update(); // project
vtkSmartPointer<vtkPolyData> d = planeMapper->GetPolyDataOutput(); // retrieve result
由于这种算法用于组织化,需要检索纹理COORDS和成平面坐标转换它们。 (文本COORDS在[0,1]的高度和宽度的比所定义的)
vtkSmartPointer<vtkDataArray> textCoord = d->GetPointData()->GetTCoords();
vtkSmartPointer <vtkPoints> textPoints = vtkPoints::New();
for (int i = 0; i < textCoord->GetNumberOfTuples(); ++i)
{
textPoints->InsertNextPoint (textCoord->GetTuple2(i)[0] * 800,
textCoord->GetTuple2(i)[1] * 600, 0);
}
textPoints
这里得到了在平面上的路径的投影的2维的所有坐标。 /!\这个坐标取决于你的平面坐标。
相关问题
- 1. 将轴投影到平面
- 2. OpenCV中曲线的垂直和水平投影
- 3. 投影在三维空间曲线
- 4. glotho zox平面投影
- 5. 三维投影到二维XY平面
- 6. 3D网格投影到二维平面
- 7. 如何将矩形纹理投影到曲面区域?
- 8. 用于平面到平面投影的CSS变换矩阵
- 9. 如何将4个点标识的任意平面投影到2d平面上?
- 10. 如何在3D曲面重建中使用光线投射?
- 11. VTK如何平滑一条线
- 12. 表面与平面(threejs)相交并将其投影到平面XoY(3D)上
- 13. 如何平滑曲线
- 14. 如何投影ItemsPanelRoot到SwapChainPanel
- 15. 正交投影线
- 16. 如何计算观看平面上的一个点到场景中的平面上的逆正交投影?
- 17. R曲线下面的阴影区域
- 18. 如何在三维空间中投影平面上的多边形
- 19. 如何在投影机中投影我的iPad应用程序
- 20. 如何在openGL显示列表中投影/未投影
- 21. 将圆柱体内部的图像投影到平面2D [Matlab]
- 22. 将3D模型投影到2D平面上
- 23. C#XNA投影到3D平面的鼠标位置
- 24. 2D与平行投影3D
- 25. 我应该如何处理剪切到观看平面的3D点的投影?
- 26. 如何将Android手机实时投影到投影仪?
- 27. VTK图像扭曲?
- 28. 平滑曲线在Python
- 29. 三维矢量在各自平面上的投影
- 30. Silverlight中使用平面投影当转换坐标系统3