[Paraview] python scripting inside Paraview

Robert Maynard thorin.hax at gmail.com
Tue Jun 12 14:33:33 EDT 2007


If I run the following script, Paraview crashes to the console with the
error:
terminate called after throwing an instance of 'std::bad_alloc'
  what():  St9bad_alloc
Aborted

As I said if I remove the line
 disp = paraview.CreateDisplay(line, activeView)
the script will complete correctly, but I would have to manual turn on each
element
something that I want the script to do

#!/usr/bin/env python
import paraview

# Locate the view to which we'll add the "display". All views are
# registered in the group "view_modules" with the proxy manager.
pxm = paraview.pyProxyManager()
iter = pxm.group_iter("view_modules");
activeView = None
for proxy in iter:
  if proxy.IsA("vtkSMRenderModuleProxy"):
    activeView = proxy
    break
if activeView:
  for z in range (0, 10):
    for y in range (0, 10):
      for cc in range (0, 10):
        # create a display for the source in the active view.
        line = paraview.CreateProxy("sources","LineSource","sources",
"line.%d.%d.%d"%(cc,y,z))
        print cc, " ", y, " ", z
        line.SetPoint1(cc,y,z)
        line.SetPoint2(0,0,0)
        line.UpdateVTKObjects();
        disp = paraview.CreateDisplay(line, activeView);
  activeView.StillRender();


On 6/12/07, Utkarsh Ayachit <utkarsh.ayachit at kitware.com> wrote:
>
> Hmm weird,
>
> Here's my script to create a 1000 spheres. It seems to work just fine
> for me.
>
> Can you post your script?
>
> import paraview
>
> # Locate the view to which we'll add the "display". All views are
> # registered in the group "view_modules" with the proxy manager.
> pxm = paraview.pyProxyManager()
> iter = pxm.group_iter("view_modules");
> activeView = None
> for proxy in iter:
>    if proxy.IsA("vtkSMRenderModuleProxy"):
>      activeView = proxy
>      break
> if activeView:
>    for z in range (0, 10):
>      for y in range (0, 10):
>        for cc in range (0, 10):
>          # create a display for the source in the active view.
>          sphere = \
>           paraview.CreateProxy("sources","SphereSource","sources",
>              "sphere.%d.%d.%d"% (cc,y,z))
>          sphere.SetCenter(cc, y, z);
>          sphere.UpdateVTKObjects();
>          disp = paraview.CreateDisplay(sphere, activeView);
>    activeView.StillRender();
>
> Utkarsh
>
> Robert Maynard wrote:
> > Thank you for the reply. I tried something similar to this but by doing
> > it this way:
> >
> > renModule = paraview.GetRenderModule()
> > paraview.CreateDisplay(sphere, renModule):
> >
> > The major problem I get is that for both of these ways to add the item
> > to a Display proxy, is that while it works nicely for a small dataset.
> > When I try to create with python 200 sphere's, and 1000 lines. The
> python
> > parser slows right down, and really slows down the render. It seems that
> > this
> > way extra display proxies are created, becuase when I try to save the
> > state, or close paraview
> > I get the following error.
> >
> > The program 'modpython' received an X Window System error.
> > This probably reflects a bug in the program.
> > The error was 'BadWindow (invalid Window parameter)'.
> >   (Details: serial 366766 error_code 3 request_code 15 minor_code 0)
> >   (Note to programmers: normally, X errors are reported asynchronously;
> >    that is, you will receive the error a while after causing it.
> >    To debug your program, run it with the --sync command line
> >    option to change this behavior. You can then get a meaningful
> >    backtrace from your debugger if you break on the gdk_x_error()
> function.)
> > vtkDebugLeaks has detected LEAKS!
> > Class "vtkSMSourceProxy" has 1645 instances still around.
> > Class "vtkSMPWriterProxy" has 8 instances still around.
> > Class "vtkPVAxesActor" has 1 instance still around.
> > Class "vtkFixedPointVolumeRayCastCompositeHelper" has 129 instances
> > still around.
> > Class "vtkOpenGLScalarsToColorsPainter" has 273 instances still around.
> > Class "pqPendingDisplayUndoElement" has 1 instance still around.
> > Class "vtkXOpenGLRenderWindow" has 1 instance still around.
> > Class "vtkSMAxesProxy" has 1 instance still around.
> > Class "vtkSMMaterialLoaderProxy" has 129 instances still around.
> > Class "pqOptions" has 1 instance still around.
> > Class "vtkSMSimpleIntInformationHelper" has 13 instances still around.
> > Class "vtkSMTimeStepsInformationHelper" has 17 instances still around.
> > Class "vtkSMEnumerationDomain" has 1884 instances still around.
> > Class "vtkSMPropertyModificationUndoElement" has 1 instance still
> around.
> > Class "vtkSMLODDisplayProxy" has 129 instances still around.
> > Class "vtkSelfConnection" has 2 instances still around.
> > Class "vtkCellTypes" has 1 instance still around.
> > Class "vtkPVXMLElement" has 29275 instances still around.
> > Class "vtkCellData" has 1494 instances still around.
> > Class "vtkSMInputProperty" has 1948 instances still around.
> > Class "vtkClientServerInterpreter" has 1 instance still around.
> > Class "vtkCollection" has 7512 instances still around.
> > Class "vtkSMDoubleVectorProperty" has 4086 instances still around.
> > Class "vtkSMExtentDomain" has 2 instances still around.
> > Class "vtkFrustumCoverageCuller" has 3 instances still around.
> > Class "vtkPointsPainter" has 138 instances still around.
> > Class "vtkCursor3D" has 4 instances still around.
> > Class "vtkInformationVector" has 8430 instances still around.
> > Class "vtkSMDataTypeDomain" has 1283 instances still around.
> > Class "vtkPVFileInformationHelper" has 2 instances still around.
> > Class "vtkSMIntArrayInformationHelper" has 2 instances still around.
> > Class "vtkPerspectiveTransform" has 6 instances still around.
> > Class "vtkPVTrackballZoom" has 3 instances still around.
> > Class "vtkSMMultiViewRenderModuleProxy" has 1 instance still around.
> > Class "vtkOpenGLPainterDeviceAdapter" has 1 instance still around.
> > Class "vtkPVTrackballRoll" has 1 instance still around.
> > Class "vtkPVOpenGLExtensionsInformation" has 1 instance still around.
> > Class "vtkSMWriterProxy" has 12 instances still around.
> > Class "vtkQuad" has 11 instances still around.
> > Class "vtkPointData" has 1623 instances still around.
> > Class "vtkOpenGLDisplayListPainter" has 273 instances still around.
> > Class "vtkSMXDMFInformationHelper" has 6 instances still around.
> > Class "vtkVectorText" has 3 instances still around.
> > Class "vtkProperty2D" has 1 instance still around.
> > Class "vtkPVUpdateSuppressor" has 387 instances still around.
> > Class "vtkPriorityQueue" has 129 instances still around.
> > Class "vtkPointPlacer" has 4 instances still around.
> > Class "vtkWidgetEventTranslator" has 4 instances still around.
> > Class "vtkCacheSizeKeeper" has 1 instance still around.
> > Class "vtkPolygonsPainter" has 138 instances still around.
> > Class "vtkCompositeDataPipeline" has 1420 instances still around.
> > Class "vtkFixedPointRayCastImage" has 129 instances still around.
> > Class "vtkTrivialProducer" has 277 instances still around.
> > Class "vtkProp3DCollection" has 4 instances still around.
> > Class "vtkQuadricClustering" has 129 instances still around.
> > Class "vtkSMArraySelectionInformationHelper" has 139 instances still
> > around.
> > Class "vtkMatrix4x4" has 3316 instances still around.
> > Class "vtkFeatureEdges" has 129 instances still around.
> > Class "vtkSphericalDirectionEncoder" has 129 instances still around.
> > Class "vtkPVMain" has 1 instance still around.
> > Class "pqStateLoader" has 1 instance still around.
> > Class "vtkSMFixedTypeDomain" has 1 instance still around.
> > Class "vtkCoordinate" has 11 instances still around.
> > Class "vtkBox" has 1 instance still around.
> > Class "vtkSMFileListDomain" has 104 instances still around.
> > Class "vtkSMProxyGroupDomain" has 3509 instances still around.
> > Class "vtkSMExtractLocationsProxy" has 1 instance still around.
> > Class "vtkFollower" has 3 instances still around.
> > Class "vtkSimpleTransform" has 21 instances still around.
> > Class "vtkDataSetSurfaceFilter" has 129 instances still around.
> > Class "vtkPVLODVolume" has 129 instances still around.
> > Class "vtkSMStringVectorProperty" has 1637 instances still around.
> > Class "vtkFiniteDifferenceGradientEstimator" has 129 instances still
> around.
> > Class "vtkDummyController" has 2 instances still around.
> > Class "vtkEventQtSlotConnect" has 716 instances still around.
> > Class "vtkSMDoubleRangeDomain" has 3888 instances still around.
> > Class "vtkSMProxyRegisterUndoElement" has 1 instance still around.
> > Class "vtkPoints" has 644 instances still around.
> > Class "vtkIntArray" has 1 instance still around.
> > Class "vtkEncodedGradientShader" has 129 instances still around.
> > Class "vtkInformation" has 23589 instances still around.
> > Class "vtkUnstructuredGridVolumeRayCastMapper" has 129 instances still
> > around.
> > Class "vtkSMUpdateSuppressorProxy" has 388 instances still around.
> > Class "vtkLine" has 46 instances still around.
> > Class "vtkSMUndoStackUndoSet" has 908 instances still around.
> > Class "vtkSMProxyLink" has 1420 instances still around.
> > Class "vtkSMCameraProxy" has 1 instance still around.
> > Class "pqRenderViewProxy" has 1 instance still around.
> > Class "vtkActorCollection" has 7 instances still around.
> > Class "vtkAxes" has 1 instance still around.
> > Class "vtkSMPart" has 645 instances still around.
> > Class "vtkPointHandleRepresentation3D" has 4 instances still around.
> > Class "vtkProcessModule" has 1 instance still around.
> > Class "vtkLightKit" has 1 instance still around.
> > Class "vtkSMViewModuleProxy" has 1 instance still around.
> > Class "vtkSMPVAnimationSceneProxy" has 1 instance still around.
> > Class "vtkPVClassNameInformation" has 645 instances still around.
> > Class "vtkUnstructuredGridBunykRayCastFunction" has 129 instances still
> > around.
> > Class "vtkSMDomainIterator" has 18999 instances still around.
> > Class "vtkVolumeCollection" has 3 instances still around.
> > Class "vtkMultiThreader" has 387 instances still around.
> > Class "vtkInteractorStyleRubberBandPick" has 1 instance still around.
> > Class "vtkPropCollection" has 9 instances still around.
> > Class "vtkSMProxyManager" has 1 instance still around.
> > Class "vtkOpenGLCoincidentTopologyResolutionPainter" has 273 instances
> > still around.
> > Class "vtkOpenGLLightingPainter" has 273 instances still around.
> > Class "vtkPolyData" has 1491 instances still around.
> > Class "vtkGenericCell" has 133 instances still around.
> > Class "vtkLookupTable" has 1 instance still around.
> > Class "vtkPVPythonInterpretor" has 1 instance still around.
> > Class "vtkUnstructuredGridVolumeZSweepMapper" has 129 instances still
> > around.
> > Class "vtkPVDataInformation" has 2704 instances still around.
> > Class "vtkSMNumberOfGroupsDomain" has 4 instances still around.
> > Class "vtkSelfConnectionUndoSet" has 925 instances still around.
> > Class "vtkCylinderSource" has 1 instance still around.
> > Class "vtkSMBooleanDomain" has 4326 instances still around.
> > Class "vtkSMSummaryHelperProxy" has 7 instances still around.
> > Class "vtkOrderedTriangulator" has 129 instances still around.
> > Class "pqOutputWindowAdapter" has 1 instance still around.
> > Class "vtkPVArrayInformation" has 3345 instances still around.
> > Class "vtkSMUpdateInformationUndoElement" has 1 instance still around.
> > Class "vtkBiQuadraticQuad" has 4 instances still around.
> > Class "vtkPiecewiseFunction" has 5 instances still around.
> > Class "vtkOpenGLRayCastImageDisplayHelper" has 387 instances still
> around.
> > Class "vtkPainterPolyDataMapper" has 273 instances still around.
> > Class "vtkPVCompositeDataInformation" has 2833 instances still around.
> > Class "vtkHexahedron" has 2 instances still around.
> > Class "vtkActor2D" has 1 instance still around.
> > Class "vtkPropPicker" has 1 instance still around.
> > Class "vtkPVLODPartDisplayInformation" has 129 instances still around.
> > Class "vtkPVOptionsXMLParser" has 1 instance still around.
> > Class "vtkTriQuadraticHexahedron" has 1 instance still around.
> > Class "vtkOpenGLCamera" has 3 instances still around.
> > Class "vtkPVServerInformation" has 1 instance still around.
> > Class "vtkSMArraySelectionDomain" has 137 instances still around.
> > Class "vtkOpenGLActor" has 146 instances still around.
> > Class "vtkLineWidget2" has 1 instance still around.
> > Class "vtkSMProxyListDomain" has 11 instances still around.
> > Class "vtkSMFieldDataDomain" has 3 instances still around.
> > Class "vtkIdList" has 369 instances still around.
> > Class "vtkWorldPointPicker" has 1 instance still around.
> > Class "ProcessModuleGUIHelper" has 1 instance still around.
> > Class "vtkQuadraticLinearQuad" has 2 instances still around.
> > Class "vtkSMPropertyLink" has 266 instances still around.
> > Class "vtkConeSource" has 1 instance still around.
> > Class "vtkEmptyCell" has 133 instances still around.
> > Class "vtkTStripsPainter" has 138 instances still around.
> > Class "vtkOpenGLProjectedTetrahedraMapper" has 129 instances still
> around.
> > Class "vtkObserverMediator" has 1 instance still around.
> > Class "vtkDoubleArray" has 783 instances still around.
> > Class "vtkInformationDoubleValue" has 138 instances still around.
> > Class "vtkMatrixToLinearTransform" has 132 instances still around.
> > Class "vtkDefaultPainter" has 273 instances still around.
> > Class "vtkAlgorithmOutput" has 937 instances still around.
> > Class "vtkCullerCollection" has 3 instances still around.
> > Class "vtkDataSetTriangleFilter" has 129 instances still around.
> > Class "vtkOpenGLRenderer" has 3 instances still around.
> > Class "vtkCellCenterDepthSort" has 129 instances still around.
> > Class "vtkInformationIntegerValue" has 36597 instances still around.
> > Class "vtkSMInputArrayDomain" has 28 instances still around.
> > Class "vtkSMShrunkContoursProxy" has 1 instance still around.
> > Class "vtkQuadraticTriangle" has 2 instances still around.
> > Class "vtkOpenGLPolyDataMapper2D" has 1 instance still around.
> > Class "vtkOpenGLLight" has 7 instances still around.
> > Class "vtkPVInteractorStyle" has 1 instance still around.
> > Class "vtkSMUndoStack" has 2 instances still around.
> > Class "vtkSMArrayRangeDomain" has 7 instances still around.
> > Class "vtkSMExtractSelectionProxy" has 4 instances still around.
> > Class "vtkSMNumberOfPartsDomain" has 2 instances still around.
> > Class "vtkBiQuadraticQuadraticHexahedron" has 1 instance still around.
> > Class "vtkUndoStack" has 1 instance still around.
> > Class "vtkCellArray" has 147 instances still around.
> > Class "vtkSMProxyProperty" has 2490 instances still around.
> > Class "vtkSMArrayListDomain" has 1052 instances still around.
> > Class "vtkSMBoundsDomain" has 14 instances still around.
> > Class "vtkUnstructuredGrid" has 1 instance still around.
> > Class "vtkQuadraticLinearWedge" has 1 instance still around.
> > Class "vtkRendererCollection" has 1 instance still around.
> > Class "vtkStandardPolyDataPainter" has 552 instances still around.
> > Class "vtkFixedPointVolumeRayCastMapper" has 129 instances still around.
> > Class "vtkFixedPointVolumeRayCastMIPHelper" has 129 instances still
> around.
> > Class "vtkProcessModuleConnectionManager" has 1 instance still around.
> > Class "vtkSMStringListDomain" has 144 instances still around.
> > Class "pqProxyUnRegisterUndoElement" has 1 instance still around.
> > Class "pqCloseViewUndoElement" has 1 instance still around.
> > Class "vtkPVRenderModuleHelper" has 1 instance still around.
> > Class "vtkSMSimpleStringInformationHelper" has 11 instances still
> around.
> > Class "vtkHeap" has 258 instances still around.
> > Class "vtkChooserPainter" has 273 instances still around.
> > Class "vtkSMIntRangeDomain" has 1661 instances still around.
> > Class "pqHelperProxyRegisterUndoElement" has 1 instance still around.
> > Class "vtkSMProxy" has 667 instances still around.
> > Class "vtkWedge" has 2 instances still around.
> > Class "vtkSMSimpleDoubleInformationHelper" has 8 instances still around.
> > Class "vtkPVGeometryFilter" has 129 instances still around.
> > Class "vtkSMApplication" has 1 instance still around.
> > Class "vtkInformationStringValue" has 1449 instances still around.
> > Class "vtkFloatArray" has 1054 instances still around.
> > Class "vtkBiQuadraticQuadraticWedge" has 1 instance still around.
> > Class "vtkPVLODActor" has 129 instances still around.
> > Class "vtkVolumeProperty" has 129 instances still around.
> > Class "vtkInformationExecutivePortVectorValue" has 661 instances still
> > around.
> > Class "vtkPVDataSetAttributesInformation" has 5666 instances still
> around.
> > Class "vtkIdTypeArray" has 663 instances still around.
> > Class "pqUndoStackBuilder" has 1 instance still around.
> > Class "vtkSMUndoRedoStateLoader" has 1 instance still around.
> > Class "vtkTransform" has 1069 instances still around.
> > Class "vtkSocketCollection" has 1 instance still around.
> > Class "vtkSMDocumentation" has 7783 instances still around.
> > Class "vtkPVAxesWidget" has 1 instance still around.
> > Class "vtkPVFileInformation" has 2 instances still around.
> > Class "vtkFixedPointVolumeRayCastCompositeShadeHelper" has 129 instances
> > still around.
> > Class "vtkSMNew3DWidgetProxy" has 1 instance still around.
> > Class "vtkTriangle" has 15 instances still around.
> > Class "vtkEdgeTable" has 129 instances still around.
> > Class "vtkOutlineSource" has 131 instances still around.
> > Class "vtkOpenGLClipPlanesPainter" has 273 instances still around.
> > Class "vtkCollectionIterator" has 2 instances still around.
> > Class "vtkOpenGLHAVSVolumeMapper" has 129 instances still around.
> > Class "vtkLineRepresentation" has 1 instance still around.
> > Class "vtkFieldData" has 1497 instances still around.
> > Class "pqSplitViewUndoElement" has 1 instance still around.
> > Class "vtkQuadraticQuad" has 1 instance still around.
> > Class "vtkLODProp3D" has 129 instances still around.
> > Class "vtkFixedPointVolumeRayCastCompositeGOShadeHelper" has 129
> > instances still around.
> > Class "vtkSMTimeRangeInformationHelper" has 2 instances still around.
> > Class "vtkPVAnimationScene" has 1 instance still around.
> > Class "vtkOpenGLProperty" has 151 instances still around.
> > Class "vtkSMInteractionUndoStackBuilder" has 1 instance still around.
> > Class "vtkTrackballPan" has 2 instances still around.
> > Class "vtkSMIntVectorProperty" has 7770 instances still around.
> > Class "vtkSMProxyUnRegisterUndoElement" has 1 instance still around.
> > Class "vtkSMIdTypeVectorProperty" has 14 instances still around.
> > Class "vtkLineSource" has 3 instances still around.
> > Class "vtkInformationDoubleVectorValue" has 1177 instances still around.
> > Class "vtkInformationKeyVectorValue" has 777 instances still around.
> > Class "vtkUnsignedCharArray" has 134 instances still around.
> > Class "vtkLightCollection" has 3 instances still around.
> > Class "vtkSphereSource" has 131 instances still around.
> > Class "vtkEvent" has 32 instances still around.
> > Class "vtkWidgetCallbackMapper" has 4 instances still around.
> > Class "vtkKWProcessStatistics" has 1 instance still around.
> > Class "vtkLinesPainter" has 138 instances still around.
> > Class "vtkPVGeometryInformation" has 129 instances still around.
> > Class "vtkPVProgressHandler" has 1 instance still around.
> > Class "vtkStreamingDemandDrivenPipeline" has 438 instances still around.
> > Class "vtkSMProperty" has 1054 instances still around.
> > Class "vtkSMXDMFPropertyDomain" has 2 instances still around.
> > Class "vtkCellPicker" has 4 instances still around.
> > Class "vtkUpdateSuppressorPipeline" has 387 instances still around.
> > Class "vtkOpenGLRepresentationPainter" has 273 instances still around.
> > Class "vtkActor2DCollection" has 3 instances still around.
> > Class "vtkGenericGeometryFilter" has 129 instances still around.
> > Class "vtkHandleWidget" has 3 instances still around.
> > Class "vtkTimerLog" has 4211 instances still around.
> > Class "vtkSMLODRenderModuleProxy" has 1 instance still around.
> > Class "vtkFixedPointVolumeRayCastCompositeGOHelper" has 129 instances
> > still around.
> > Class "vtkCommand or subclass" has 33652 instances still around.
> > Class "vtkQuadraticEdge" has 13 instances still around.
> > Class "vtkMultiProcessControllerRMI" has 2 instances still around.
> > Class "vtkInformationExecutivePortValue" has 937 instances still around.
> > Class "vtkUndoSet" has 2 instances still around.
> > Class "vtkPVGenericRenderWindowInteractor" has 1 instance still around.
> > Class "vtkPVTrackballRotate" has 3 instances still around.
> >
> >
> >
> >
> > This problem does not happen, if I do not add the objects to the display
> > proxy, than after the script is over, I manually click on each one, and
> > turn on its visibility.
> >
> >
> >
> > On 6/12/07, *Utkarsh Ayachit* <utkarsh.ayachit at kitware.com
> > <mailto:utkarsh.ayachit at kitware.com>> wrote:
> >
> >     Hi Robert,
> >
> >     To make a source visible one needs to create what we call a
> "display"
> >     for that source. "Display" is a proxy which encapsulates the
> >     vtkMapper,vtkActor etc. Once must create the display for the source
> and
> >     then add it to the render module in which we want to "see" the
> source.
> >
> >     Here's the script that one can use to do the same:
> >
> >     import paraview
> >     sphere = paraview.CreateProxy("sources","SphereSource","sources")
> >
> >
> >     # Locate the view to which we'll add the "display". All views are
> >     # registered in the group "view_modules" with the proxy manager.
> >     pxm = paraview.pyProxyManager()
> >
> >     # Create a iterator that iterates over all proxies registered in
> >     # a particular group.
> >     iter = pxm.group_iter("view_modules");
> >     activeView = None
> >     for proxy in iter:
> >        # Locate a 3D render view.
> >        if proxy.IsA("vtkSMRenderModuleProxy"):
> >          activeView = proxy
> >          break
> >     if activeView:
> >        # create a display for the source in the active view.
> >        disp = paraview.CreateDisplay(sphere, activeView);
> >        # Trigger a render.
> >        activeView.StillRender();
> >
> >     Utkarsh
> >
> >
> >     Robert Maynard wrote:
> >      > Currently I am stumped on how to turn on or off the visibility of
> >     items
> >      > from
> >      > inside the paraview console.
> >      >
> >      > Currently I am constructing Line and Sphere sources by doing
> >      > sphere = paraview.CreateProxy("sources","SphereSource","sources")
> >      >
> >      > But these always are constructed with their visibility turned
> off. I
> >      > have tried
> >      > getting the properties of these objects using the vtkSMProxy
> >      > ListMethods() but
> >      > that does not list it.
> >      >
> >      > What do I need to access to be able to control their visibility?
> >      >
> >      >
> >      >
> >
> ------------------------------------------------------------------------
> >
> >      >
> >      > _______________________________________________
> >      > ParaView mailing list
> >      > ParaView at paraview.org <mailto:ParaView at paraview.org>
> >      > http://www.paraview.org/mailman/listinfo/paraview
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/paraview/attachments/20070612/4ab173dd/attachment.htm


More information about the ParaView mailing list