鉴于对有线表示中的网格进行了delaunay三角测量,我会这样做 喜欢在没有对角线的情况下展示表面,我只是想象一个整洁的正方形。 有没有选择来完成这个,也许是一个过滤器?
类似
delaunay->BoundingTriangulationOff();
delaunay->SetBoundingTriangulation(0);
但是这可以应用于所有对角线......
其他想法可能是将所有三角形转换为正方形,你知道c ++或c#中的n算法吗?
我使用了示例here
#include <vtkVersion.h>
#include <vtkCellArray.h>
#include <vtkPoints.h>
#include <vtkTriangle.h>
#include <vtkPolyData.h>
#include <vtkPointData.h>
#include <vtkLine.h>
#include <vtkCellLocator.h>
#include <vtkSmartPointer.h>
#include <vtkDelaunay2D.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkProperty.h>
#include <vtkVertexGlyphFilter.h>
int main(int, char *[])
{
// Create a set of heighs on a grid.
// This is often called a "terrain map".
vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
unsigned int GridSize = 10;
for(unsigned int x = 0; x < GridSize; x++)
{
for(unsigned int y = 0; y < GridSize; y++)
{
points->InsertNextPoint(x, y, (x+y)/(y+1));
}
}
// Add the grid points to a polydata object
vtkSmartPointer<vtkPolyData> polydata =
vtkSmartPointer<vtkPolyData>::New();
polydata->SetPoints(points);
// Triangulate the grid points
vtkSmartPointer<vtkDelaunay2D> delaunay =
vtkSmartPointer<vtkDelaunay2D>::New();
#if VTK_MAJOR_VERSION <= 5
delaunay->SetInput(polydata);
#else
delaunay->SetInputData(polydata);
#endif
delaunay->Update();
// Visualize
vtkSmartPointer<vtkPolyDataMapper> meshMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
meshMapper->SetInputConnection(delaunay->GetOutputPort());
vtkSmartPointer<vtkActor> meshActor =
vtkSmartPointer<vtkActor>::New();
meshActor->SetMapper(meshMapper);
vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
vtkSmartPointer<vtkVertexGlyphFilter>::New();
#if VTK_MAJOR_VERSION <= 5
glyphFilter->SetInputConnection(polydata->GetProducerPort());
#else
glyphFilter->SetInputData(polydata);
#endif
glyphFilter->Update();
vtkSmartPointer<vtkPolyDataMapper> pointMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
pointMapper->SetInputConnection(glyphFilter->GetOutputPort());
vtkSmartPointer<vtkActor> pointActor =
vtkSmartPointer<vtkActor>::New();
pointActor->GetProperty()->SetColor(1,0,0);
pointActor->GetProperty()->SetPointSize(3);
pointActor->SetMapper(pointMapper);
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
renderer->AddActor(meshActor);
renderer->AddActor(pointActor);
renderer->SetBackground(.3, .6, .3); // Background color green
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
答案 0 :(得分:1)
我已经从C#中的点找了三角形Tesselation而没有找到任何东西。当我到几个月后必须使用它时,我希望我必须实现自己的。与此同时,关于Delauney Tesselations的维基百科文章有点密集(难以理解),但它是我能找到的最好的起点(用于自己动手)。
在执行tesselation(我没有帮助过你)后,你应该将模型三角形变成三角形对象,这些对象是WPF的Viewport3D的MeshGeometry3D对象。这将隐藏更近的三角形覆盖的更多三角形。 Charles Petzold的书“3D Programming for Windows”帮助了我很多。但对我来说最有帮助的是Dario Solera的“WPF 3D Primer”http://www.codeproject.com/Articles/23332/WPF-3D-Primer我所做的一切都是为了得到一个相当不错的应用程序,从Solera的代码开始,一步一步修改它,直到我有一些与他的非常不同的东西项目,但没有他的项目,我无法做到。