Skip to content

WIP: Shapely integration with SMTK

Christos Tsolakis requested to merge christos.tsolakis/smtk:demo into master

This commit attempts to create an extension for smtk that introduces new resource, components and operations that are implemented entirely in python and communicate with the rest of smtk through pybind11.

  • The target library is shapely which provides tools for analyzing and manipulating planar geometries.

  • Pybindings for many smtk classes like geometry::Resource, resource::Component, geometry::Geometry, extension::vtk::Geometry etc. have been extended and should be able to support more python extensions in the future.

  • The extensions provides operations for creating 2D entities like points lines, disks and polygons and exposes some of shapely's operations like binary operations (intersection,union,etc) and more advanced operations like ConveHull and Delaunay triangulations.

  • A paraview plugin is included for modelbuilder.

  • read and write to file operations to Well-known text representation of geometry (.wkt) are included

  • Tested on ubuntu 18.04, shapely was installed using pip3 executable of cmb-superbuild

Known issues:

  • runtime errors on mac:
libc++abi.dylib: terminating with uncaught exception of type pybind11::error_already_set: TypeError: (): incompatible function arguments. The following argument types are supported:

    1. (self: smtk.extension.vtk.geometry._smtkPybindVTKGeometry.CacheEntry, arg0: vtkDataObject) -> None

Invoked with: <smtk.extension.vtk.geometry._smtkPybindVTKGeometry.CacheEntry object at 0x158347af0>, (vtkmodules.vtkCommonDataModel.vtkPolyData)0x158337460

At:
  /Users/tjcorona/Development/cmb/smtk/build2/lib/python3.8/site-packages/smtk/extension/shapely/geometry.py(140): _updatePoint
  /Users/tjcorona/Development/cmb/smtk/build2/lib/python3.8/site-packages/smtk/extension/shapely/geometry.py(59): queryGeometry
  • when used in modelbuilder shapely operations (with exception of ReadFile) do not trigger a render update. see also workaround here. Maybe has to do with the fact that resource is created in the python side ?

  • modelbuilder does not really know what is showing and thus icons for components are generic.

  • ShapelyResource.queryOperation does not follow smtk attribute rules

  • introduces smtk/geometry/RegisterPythonResource.cxx which is 99% same with smtk/resource/RegisterPythonResource.cxx it would be nice to merge these two

  • PYTHONPATH needs to be set properly as enviromental to point to .../build-smtk/lib/python3.7/site-packages where python files for resource,components etc live

  • XML Multi-block writer does not work for this type of resources see here

236: 2020-08-07 17:04:59.892 (   0.698s) [        8A1F52C0]       vtkExecutive.cxx:753    ERR| vtkCompositeDataPipeline (0x555844db4a00): Algorithm vtkXMLMultiBlockDataWriter(0x555844d9bf10) returned failure for request: vtkInformation (0x555844da3c00)
236:   Debug: Off
236:   Modified Time: 1473
236:   Reference Count: 1
236:   Registered Events: (none)
236:   Request: REQUEST_DATA
236:   FROM_OUTPUT_PORT: -1
236:   ALGORITHM_AFTER_FORWARD: 1
236:   FORWARD_DIRECTION: 0
236: 
236:
Edited by Christos Tsolakis

Merge request reports