Exemplo n.º 1
0
int main(int argc, char ** argv)
{
    QString volcR10("C:/develop/$sync/GFZ/data/VTK XML data/Volcano 2 topo.vtp");


    auto object = Loader::readFile(
        volcR10
        );

    double bounds[6];
    auto & dataSet = *object->dataSet();
    dataSet.GetBounds(bounds);

    vtkVector2d A{ bounds[0], 0 };
    vtkVector2d B{ bounds[1], 0 };

    auto inputPolyData = dynamic_cast<PolyDataObject *>(object.get());

    auto selector = vtkSmartPointer<LineOnCellsSelector2D>::New();
    selector->SetInputData(&dataSet);
    selector->SetCellCentersConnection(inputPolyData->cellCentersOutputPort());
    selector->SetStartPoint(A);
    selector->SetEndPoint(B);

    //auto extractSelection = vtkSmartPointer<vtkExtractSelectedPolyDataIds>::New();
    //extractSelection->SetInputData(&dataSet);
    //extractSelection->SetInputConnection(1, selector->GetOutputPort());

    //extractSelection->Update();

    //auto vPoly = extractSelection->GetOutput();

    //auto extractSelection = vtkSmartPointer<vtkExtractSelection>::New();
    //extractSelection->SetInputData(&dataSet);
    //extractSelection->SetSelectionConnection(selector->GetOutputPort());
    //extractSelection->Update();
    //auto outputData = vtkUnstructuredGrid::SafeDownCast(extractSelection->GetOutput());

    //auto vPoly = vtkSmartPointer<vtkPolyData>::New();
    //vPoly->SetPoints(outputData->GetPoints());
    //vPoly->SetPolys(outputData->GetCells());
    //vPoly->GetCellData()->PassData(outputData->GetCellData());
    //vPoly->GetPointData()->PassData(outputData->GetPointData());

    selector->Update();
    auto vPoly = selector->GetExtractedPoints();

    auto poly = std::make_unique<PolyDataObject>("extraction", *vPoly);

    QApplication app(argc, argv);

    ColorMappingChooser cmc;
    cmc.show();
    RenderConfigWidget rcw;
    rcw.show();
    RendererConfigWidget rrcw;
    rrcw.show();

    DataSetHandler dsh;
    DataMapping dm(dsh);
    auto view = dm.openInRenderView({ poly.get(), object.get() });

    auto pointsVis = dynamic_cast<RenderedPolyData *>(view->visualizationFor(poly.get()));
    pointsVis->mainActor()->GetProperty()->SetPointSize(5);
    pointsVis->mainActor()->PickableOn();

    auto baseVis = dynamic_cast<RenderedPolyData *>(view->visualizationFor(object.get()));
    baseVis->mainActor()->GetProperty()->SetOpacity(0.2);
    baseVis->mainActor()->PickableOff();

    view->show();
    cmc.setCurrentRenderView(view);
    rcw.setCurrentRenderView(view);
    rcw.setSelectedData(poly.get());
    rrcw.setCurrentRenderView(view);

    return app.exec();
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
    QString fileName{ "C:/develop/$sync/GFZ/data/VTK XML data/Volcano 2 topo.vtp" };

    auto data = Loader::readFile(fileName);

    QApplication app(argc, argv);
    QMainWindow window;
    window.show();

    DataSetHandler dataSetHandler;
    DataMapping dataMapping(dataSetHandler);

    RenderView renderView(dataMapping, -1);
    window.addDockWidget(Qt::TopDockWidgetArea, renderView.dockWidgetParent());
    app.setActiveWindow(&renderView);

    RenderConfigWidget renderConfig;
    renderConfig.setCurrentRenderView(&renderView);
    renderConfig.show();

    RendererConfigWidget rendererConfig;
    rendererConfig.setCurrentRenderView(&renderView);
    rendererConfig.show();

    ColorMappingChooser colorMapping;
    colorMapping.setCurrentRenderView(&renderView);
    colorMapping.show();

    GlyphMappingChooser glyphs;
    glyphs.setCurrentRenderView(&renderView);
    glyphs.show();


    QPushButton button;
    button.connect(&button, &QPushButton::clicked, [&renderView, &data] (){
        QList<DataObject *> incomp;
        renderView.showDataObjects({ data.get() }, incomp);
    });
    button.show();

    QPushButton exitButton("quit");
    exitButton.connect(&exitButton, &QPushButton::clicked, &app, &QApplication::quit);
    exitButton.show();

    return app.exec();

    /*auto renderer = vtkSmartPointer<vtkRenderer>::New();
    renderer->SetBackground(0.7, 0.7, 0.7);

    QScopedPointer<RenderedData> rendered{ data->createRendered() };

    rendered->viewProps()->InitTraversal();
    while (auto && it = rendered->viewProps()->GetNextProp())
    {
        renderer->AddViewProp(it);
    }

    auto renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
    renderWindow->AddRenderer(renderer);

    auto rwInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
    rwInteractor->SetRenderWindow(renderWindow);

    rwInteractor->Start();


    return 0;*/
}