Exemplo n.º 1
0
void AbstractRenderView::onSetSelection(const DataSelection & selection)
{
    assert(selection.dataObject && dataObjects().contains(selection.dataObject));

    const auto vis = visualizationFor(selection.dataObject);
    assert(vis);

    auto && newVisSelection = VisualizationSelection(
        selection,
        vis,
        vis->defaultVisualizationPort()
    );

    setVisualizationSelection(newVisSelection);
}
Exemplo n.º 2
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();
}