<div dir="ltr">On Sun, Sep 27, 2015 at 5:16 AM, zhq <span dir="ltr"><<a href="mailto:15891495523@126.com" target="_blank">15891495523@126.com</a>></span> wrote:<div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Dear David:<br>
<br>
      I have read the example you give. And the input of<br>
vtkContourTriangulator is all surface, how can I input a set of points ?<br></blockquote><div><br></div><div>The input to to vtkContourTriangulator is lines, not a surface.  Join the points together into line segments.</div><div><br></div><div><br></div><div><div>#include <vtkVersion.h></div><div>#include <vtkCellArray.h></div><div>#include <vtkProperty.h></div><div>#include <vtkPolyDataMapper.h></div><div>#include <vtkActor.h></div><div>#include <vtkPoints.h></div><div>#include <vtkPolyData.h></div><div>#include <vtkPolygon.h></div><div>#include <vtkSmartPointer.h></div><div>#include <vtkContourTriangulator.h></div><div>#include <vtkMath.h></div><div>#include <vtkRenderer.h></div><div>#include <vtkRenderWindow.h></div><div>#include <vtkRenderWindowInteractor.h></div><div>#define PI 3.1415926</div><div><br></div><div>int main(int, char *[])</div><div>{</div><div>        // Generate two circular contours with line segments</div><div>        vtkSmartPointer<vtkPoints> points =</div><div>                vtkSmartPointer<vtkPoints>::New();</div><div>        vtkSmartPointer<vtkCellArray> aCellArray =</div><div>                vtkSmartPointer<vtkCellArray>::New();</div><div><br></div><div>        vtkIdType lastPointId = 35;</div><div>        for (int theta = 0;theta<360;theta+=10)</div><div>        {</div><div>                double x = 2*cos(theta*PI/180);</div><div>                double y = 2*sin(theta*PI/180);</div><div>                vtkIdType pointId = points->InsertNextPoint(x,y,0);</div><div>                aCellArray->InsertNextCell(2);</div><div>                aCellArray->InsertCellPoint(lastPointId);</div><div>                aCellArray->InsertCellPoint(pointId);</div><div>                lastPointId = pointId;</div><div>        }</div><div><br></div><div>        lastPointId = 71;</div><div>        for (int theta = 350;theta>=0;theta-=10)</div><div>        {</div><div>                double x = cos(theta*PI/180);</div><div>                double y = sin(theta*PI/180);</div><div>                vtkIdType pointId = points->InsertNextPoint(x,y,0);</div><div>                aCellArray->InsertNextCell(2);</div><div>                aCellArray->InsertCellPoint(lastPointId);</div><div>                aCellArray->InsertCellPoint(pointId);</div><div>                lastPointId = pointId;</div><div>        }</div><div><br></div><div>        // Create a polydata to store the contour.</div><div>        vtkSmartPointer<vtkPolyData> contour =</div><div>                vtkSmartPointer<vtkPolyData>::New();</div><div>        contour->SetPoints(points);</div><div>        contour->SetLines(aCellArray);</div><div>        contour->BuildCells();</div><div>        contour->BuildLinks();</div><div><br></div><div>        // Triangulate the grid points</div><div>        vtkSmartPointer<vtkContourTriangulator> triangulator =</div><div>                vtkSmartPointer<vtkContourTriangulator>::New();</div><div>#if VTK_MAJOR_VERSION <= 5</div><div>        triangulator->SetInput(contour);</div><div>#else</div><div>        triangulator->SetInputData(contour);</div><div>#endif</div><div>        triangulator->Update();</div><div><br></div><div>        // Visualize</div><div>        vtkSmartPointer<vtkPolyDataMapper> meshMapper =</div><div>                vtkSmartPointer<vtkPolyDataMapper>::New();</div><div>        meshMapper->SetInputConnection(triangulator->GetOutputPort());</div><div><br></div><div>        vtkSmartPointer<vtkActor> meshActor =</div><div>                vtkSmartPointer<vtkActor>::New();</div><div>        meshActor->SetMapper(meshMapper);</div><div>        //meshActor->GetProperty()->SetEdgeColor(0,0,1); // Why aren't the edges aren't visible unless we set the representation to wireframe?</div><div>        //meshActor->GetProperty()->SetInterpolationToFlat();</div><div>        meshActor->GetProperty()->SetRepresentationToWireframe();</div><div><br></div><div>        vtkSmartPointer<vtkPolyDataMapper> contourMapper =</div><div>                vtkSmartPointer<vtkPolyDataMapper>::New();</div><div>#if VTK_MAJOR_VERSION <= 5</div><div>        contourMapper->SetInputConnection(contour->GetProducerPort());</div><div>#else</div><div>        contourMapper->SetInputData(contour);</div><div>#endif</div><div><br></div><div>        vtkSmartPointer<vtkActor> contourActor =</div><div>                vtkSmartPointer<vtkActor>::New();</div><div>        contourActor->SetMapper(contourMapper);</div><div>        contourActor->GetProperty()->SetColor(1,0,0);</div><div><br></div><div>        // Create a renderer, render window, and interactor</div><div>        vtkSmartPointer<vtkRenderer> renderer =</div><div>                vtkSmartPointer<vtkRenderer>::New();</div><div>        vtkSmartPointer<vtkRenderWindow> renderWindow =</div><div>                vtkSmartPointer<vtkRenderWindow>::New();</div><div>        renderWindow->AddRenderer(renderer);</div><div>        vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =</div><div>                vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div>        renderWindowInteractor->SetRenderWindow(renderWindow);</div><div><br></div><div>        // Add the actor to the scene</div><div>        renderer->AddActor(meshActor);</div><div>        renderer->AddActor(contourActor);</div><div>        renderer->SetBackground(.3, .6, .3); // Background color green</div><div><br></div><div>        // Render and interact</div><div>        renderWindow->Render();</div><div>        renderWindowInteractor->Start();</div><div><br></div><div>        return EXIT_SUCCESS;</div><div>}</div></div></div></div></div></div>