1

私は3D空間にポイントをプロットする次のコードを持っています:

     vtkSmartPointer<vtkPoints> points =
            vtkSmartPointer<vtkPoints>::New();

        for(int in = 0; in<x.size(); in++)
        {
            points->InsertNextPoint (x[in], y[in], ry[in]);
        }

          vtkSmartPointer<vtkPolyData> pointsPolydata =
            vtkSmartPointer<vtkPolyData>::New();

          pointsPolydata->SetPoints(points);

          vtkSmartPointer<vtkVertexGlyphFilter> vertexFilter =
            vtkSmartPointer<vtkVertexGlyphFilter>::New();
        #if VTK_MAJOR_VERSION <= 5
          vertexFilter->SetInputConnection(pointsPolydata->GetProducerPort());
        #else
          vertexFilter->SetInputData(pointsPolydata);
        #endif
          vertexFilter->Update();

          vtkSmartPointer<vtkPolyData> polydata =
            vtkSmartPointer<vtkPolyData>::New();
          polydata->ShallowCopy(vertexFilter->GetOutput());

          // Setup colors
          unsigned char red[3] = {255, 0, 0};
          unsigned char green[3] = {0, 255, 0};
          unsigned char blue[3] = {0, 0, 255};

          vtkSmartPointer<vtkUnsignedCharArray> colors =
            vtkSmartPointer<vtkUnsignedCharArray>::New();
          colors->SetNumberOfComponents(3);
          colors->SetName ("Colors");
          colors->InsertNextTupleValue(red);
          colors->InsertNextTupleValue(green);
          colors->InsertNextTupleValue(blue);

          polydata->GetPointData()->SetScalars(colors);

          // Visualization
          vtkSmartPointer<vtkPolyDataMapper> mapper =
            vtkSmartPointer<vtkPolyDataMapper>::New();
        #if VTK_MAJOR_VERSION <= 5
          mapper->SetInputConnection(polydata->GetProducerPort());
        #else
          mapper->SetInputData(polydata);
        #endif

          vtkSmartPointer<vtkActor> actor =
            vtkSmartPointer<vtkActor>::New();
          actor->SetMapper(mapper);
          actor->GetProperty()->SetPointSize(5);

          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(actor);

          this->ui->qvtkWidget->GetRenderWindow()->AddRenderer(renderer);
          renderWindowInteractor->Start();

結果のプロットを取得すると。すべてのポイントがプロットされていますが、デフォルトの縮尺では何も見えません。よくわからないのは、z 軸でビューを拡大する方法です。どんな助けでも大歓迎です。

4

0 に答える 0