<DIV>hello all,</DIV>
<DIV>I am looking for help to resolve my problem in VTK for delaunay torus. I first use implicit bool operation to create torus and then extract the torus with vtkExtractGeometry, but the result is not as good as I expected since the result's zigzag. The code and results is as follows.</DIV>
<DIV> </DIV>
<DIV><EM> // create a boolean torus<BR> vtkSmartPointer<vtkQuadric> circle1 = vtkQuadric::New();<BR> circle1->SetCoefficients(1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0);</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM> vtkSmartPointer<vtkQuadric> circle2 = vtkQuadric::New();<BR> circle2->SetCoefficients(1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.25);</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM> vtkSmartPointer<vtkImplicitBoolean> subtract = vtkImplicitBoolean::New();<BR> subtract->SetOperationTypeToDifference();<BR> subtract->AddFunction(circle1);<BR> subtract->AddFunction(circle2);</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM> vtkSmartPointer<vtkSampleFunction> sample = vtkSampleFunction::New();<BR> sample->SetImplicitFunction(subtract);<BR> sample->SetSampleDimensions(30, 30, 30);<BR> sample->ComputeNormalsOff();</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM> vtkSmartPointer<vtkExtractGeometry> extract = vtkExtractGeometry::New();<BR> extract->SetInputConnection(sample->GetOutputPort());<BR> extract->SetImplicitFunction(subtract);<BR> extract->ExtractInsideOn();</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM> vtkSmartPointer<vtkDelaunay2D> del2D = vtkDelaunay2D::New();<BR> del2D->SetInputConnection(extract->GetOutputPort());<BR> del2D->SetAlpha(0.1);</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM> vtkSmartPointer<vtkDataSetMapper> mapper = vtkDataSetMapper::New();<BR> mapper->SetInputConnection(del2D->GetOutputPort());</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM> vtkSmartPointer<vtkActor> actor = vtkActor::New();<BR> actor->SetMapper(mapper);<BR> actor->GetProperty()->SetColor(1.0, 1.0, 1.0);<BR> <BR> vtkSmartPointer<vtkRenderer> renderer = vtkRenderer::New();<BR> vtkSmartPointer<vtkRenderWindow> renWin = vtkRenderWindow::New();<BR> vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkRenderWindowInteractor::New();<BR> vtkSmartPointer<vtkInteractorStyleTrackballCamera> style = vtkInteractorStyleTrackballCamera::New();</EM></DIV>
<DIV><EM> renderer->AddActor(actor);<BR> renderer->SetBackground(0.0, 0.0, 0.0);<BR> renderer->ResetCamera();</EM></DIV>
<DIV><EM> renWin->AddRenderer(renderer);<BR> renWin->SetSize(500, 500);<BR> renWin->Render();</EM></DIV>
<DIV><EM> iren->SetInteractorStyle(style);<BR> iren->SetRenderWindow(renWin);<BR> </EM><EM>iren->Initialize();<BR> iren->Start();</EM></DIV>
<DIV><IMG src="cid:7314ddd8$1$12f4dd37c8a$Coremail$blldw@163.com"></DIV>
<DIV>I would like to make the edge smooth so I add a vtkContourFilter before vtkExtractGeometryFilter, and before the vtkExtractGeometryFilter and vtkDelaunay2D is applied on the output of vtkContourFilter, the result looks good.</DIV>
<DIV><IMG src="cid:5ef0caee$2$12f4dd37c8a$Coremail$blldw@163.com"></DIV>
<DIV>the result is achieved by adding a vtkContourFilter without vtkExtractGeometry and vtkDelaunay2D applied:</DIV>
<DIV>// The code here is the same as above</DIV>
<DIV><EM>vtkSmartPointer<vtkSampleFunction> sample = vtkSampleFunction::New();<BR> sample->SetImplicitFunction(subtract);<BR> sample->SetSampleDimensions(30, 30, 30);<BR> sample->ComputeNormalsOff();</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><STRONG>vtkSmartPointer<vtkContourFilter> contour = vtkContourFilter::New();<BR> contour->SetInputConnection(sample->GetOutputPort());<BR> contour->SetValue(0, 0.0);</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><EM>vtkSmartPointer<vtkDataSetMapper> mapper = vtkDataSetMapper::New();<BR> mapper->SetInputConnection(contour->GetOutputPort());</EM></DIV>
<DIV><EM>// the following code is the same as above</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV>NOW I add vtkExtractGeometry and vtkDelaunay2D after vtkContourFilter:</DIV>
<DIV> </DIV>
<DIV><EM>// contour filter has been added</EM></DIV>
<DIV><EM>vtkSmartPointer<vtkExtractGeometry> extract = vtkExtractGeometry::New();<BR> extract->SetInputConnection(contour->GetOutputPort());<BR> extract->SetImplicitFunction(subtract);<BR> extract->ExtractInsideOn();</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM> vtkSmartPointer<vtkDelaunay2D> del2D = vtkDelaunay2D::New();<BR> del2D->SetInputConnection(extract->GetOutputPort());<BR> del2D->SetAlpha(0.1);</EM></DIV>
<DIV> </DIV>
<DIV>
<DIV><EM>vtkSmartPointer<vtkDataSetMapper> mapper = vtkDataSetMapper::New();<BR> mapper->SetInputConnection(del2D->GetOutputPort());</EM></DIV>
<DIV><EM>// The following code doesn't change</EM></DIV></DIV>
<DIV> </DIV>
<DIV>What I got is:</DIV>
<DIV><IMG src="cid:129afff4$3$12f4dd37c8a$Coremail$blldw@163.com"></DIV>
<DIV>What should I do in order to get delaunayed smooth torus, OR anyone could give me other methods to get the torus inside of which is delaunayed?</DIV>
<DIV> </DIV><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>