Skip to content

Development Item: python displaying infrastructure #5615

Description

@asalzburger

Currently, various options exist to display geometry and other objects using the python bindings.
Either direct converters (to obj, svg are used), or python plotting backends are used directly in scripts.

The aim of this project is to centralize this infrastructure, clearly divide workload on the C++ and on the python side, and make coherent entry point for extendable displaying options.

Geometry visualization

All geometry objects are composed by surfaces, hence supporting a display for surfaces (or compounds of) should be the basis of the geometry visualization.

Surfaces can be visited for display, using the IVisualization3D visitor pattern:

  /// Visualize the surface for debugging and inspection
  /// @param helper Visualization helper for 3D rendering
  /// @param gctx Geometry context for coordinate transformations
  /// @param viewConfig Visual configuration (color, style, etc.)
  void visualize(IVisualization3D& helper, const GeometryContext& gctx,
                 const ViewConfig& viewConfig = s_viewSurface) const;

There exist some specific implementations Obj, Ply that transform this directly into text based formats.


Workplan first steps:

  • Create a GenericVisualization implementation that visits surfaces and gathers the needed information, e.g. 3D point cloud, 2D projects, identifier, coloring
  • Interface this to python and display with a chosen python plotting backend

Suggested design principle

classDiagram
      class IVisualization3D {
          <<abstract>>
          +vertex(Vector3, Color)
          +face(vector~Vector3~, Color)
          +faces(vector~Vector3~, vector~FaceType~, Color)
          +line(Vector3, Vector3, Color)
          +write(path)
          +clear()
      }

      class GenericVisualization {
          -m_vertices : vector~tuple~Vector3,Color~~
          -m_faces : vector~tuple~vector~int~,Color~~
          -m_lines : vector~tuple~Vector3,Vector3,Color~~
          +vertex(Vector3, Color)
          +face(vector~Vector3~, Color)
          +faces(vector~Vector3~, vector~FaceType~, Color)
          +line(Vector3, Vector3, Color)
          +write(path)
          +clear()
          +vertices() vector~tuple~Vector3,Color~~
          +faces() vector~tuple~vector~int~,Color~~
          +lines() vector~tuple~Vector3,Vector3,Color~~
      }

      class pybind11Bindings {
          <<Python module: acts>>
          +GenericVisualization()
          +.vertices → list[tuple]
          +.faces → list[tuple]
          +.lines → list[tuple]
      }

      class MatplotlibBackend {
          <<python>>
          +plot(viz: GenericVisualization)
          +uses Poly3DCollection
          +uses Line3D
      }

      class PlotlyBackend {
          <<python>>
          +plot(viz: GenericVisualization)
          +uses go.Mesh3d
          +uses go.Scatter3d
      }

      IVisualization3D <|-- GenericVisualization : extends
      IVisualization3D <|-- ObjVisualization3D : extends
      IVisualization3D <|-- PlyVisualization3D : extends
      GenericVisualization --> pybind11Bindings : exposed via pybind11
      pybind11Bindings --> MatplotlibBackend : feeds data
      pybind11Bindings --> PlotlyBackend : feeds data
Loading

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions