[Paraview] How to Get Active Selection and Extract it?

SCHROEDER, Martin Martin.SCHROEDER at mtu.de
Mon Jan 28 07:50:42 EST 2013


How to Get Active Selection and Extract it?

Hello,
I'm struggling with a problem.
I want to write a filter, that copies selected points form a vtkPolyData into a vtkDataObject without using the apply button, I try to use 3 custom buttons in order to copy the data into different Objects. Aim is to access the point data of the selected points. I've already tried this in Python and it works as expected.
Doing the same in C++ doesn't seem as straight forward as it was in Python...


How can I pass the output port from a vtkSMSourceProxy to a vtkAlgorithm input port. Is there any way to do that?
My code looks very similar to this:

  vtkSMProxyManager* pxm = vtkSMProxyManager::GetProxyManager();

  vtkSMSessionProxyManager* spxm = pxm->GetActiveSessionProxyManager();

  vtkSMProxySelectionModel* selmodel = spxm->GetSelectionModel("ActiveSources");

  vtkSmartPointer<vtkSMSourceProxy> FilterProxy =
      vtkSMSourceProxy::SafeDownCast(selmodel->GetCurrentProxy());

  vtkSmartPointer<vtkSMSourceProxy> SourceProxy =
      vtkSMSourceProxy::SafeDownCast(FilterProxy->GetProducerProxy((uint)0));

  vtkSmartPointer<vtkSMSourceProxy> active_selection =
      vtkSMSourceProxy::SafeDownCast(SourceProxy->GetSelectionInput(0));

  vtkSmartPointer<vtkExtractSelection> ExtrSelFltr = vtkSmartPointer<vtkExtractSelection>::New();

  ExtrSelFltr-> SetInputConnection(0, this->GetInputAlgorithm()->GetOutputPort((uint)0));
  ExtrSelFltr-> SetInputConnection(1, active_selection->GetOutputPort((uint)0));   //Not the right way!

  ExtrSelFltr->Update();


The functionality I want to implement written in Python:

def GetSelectionSource(proxy=None):
    """If a selection has exists for the proxy (if proxy is not specified then
       the active source is used), returns that selection source"""
    if not proxy:
        proxy = GetActiveSource()
    if not proxy:
        raise RuntimeError, \
        "GetSelectionSource() needs a proxy argument of that an active source is set."
    return proxy.GetSelectionInput(proxy.Port)


active_selection = GetSelectionSource()
# Create extract selection
Extr_Sel = ExtractSelection(Selection=active_selection)
# Access raw data of Extr_Sel
Extr_Sel_raw = servermanager.Fetch(Extr_Sel)

Any comment is appreciated and
thanks in advance.


Mit freundlichen Gruessen / Best regards

Martin Schröder, FIEA
MTU Aero Engines GmbH
Engineering Systems (CAE)
Dachauer Str. 665
80995 Muenchen
Germany

Tel  +49 (0)89  14 89 57 20
Fax  +49 (0)89  14 89-96 89 4
mailto:martin.schroeder at mtu.de
http://www.mtu.de


--
MTU Aero Engines GmbH
Geschaeftsfuehrung/Board of Management: Egon W. Behle, Vorsitzender/CEO; Dr. Rainer Martens, Dr. Stefan Weingartner, Reiner Winkler
Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: Klaus Eberhardt
Sitz der Gesellschaft/Registered Office: Muenchen
Handelsregister/Commercial Register: Muenchen HRB 154230

Diese E-Mail sowie ihre Anhaenge enthalten MTU-eigene vertrauliche oder rechtlich geschuetzte Informationen.
Wenn Sie nicht der beabsichtigte Empfaenger sind, informieren Sie bitte den Absender und loeschen Sie diese
E-Mail sowie die Anhaenge. Das unbefugte Speichern, Kopieren oder Weiterleiten ist nicht gestattet.

This e-mail and any attached documents are proprietary to MTU, confidential or protected by law.
If you are not the intended recipient, please advise the sender and delete this message and its attachments.
Any unauthorised storing, copying or distribution is prohibited.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20130128/acba858b/attachment.htm>


More information about the ParaView mailing list