Beginner Question About VTK.js Proxies

Is a VTK.js proxy an implementation of the structural design pattern which:

“lets you provide a substitute or placeholder for another object…controls access to the original object, allow[s] you to perform something either before or after the request gets through to the original object.” (refactoring.guru)

If so, under what circumstances should I be using a proxy? For example, the ManyRenderers example doesn’t use a proxy. Is that for simplicity sake or is there another reason?

What are the most common benefits folks are looking for when using a proxy?

Thanks!

1 Like

examples tends to just focus on one aspect of vtk code that it try to show off.
Proxy mainly for representations and views are meant to bundle a set of classes into a single entity while providing a convenient easy to use API.

The vtk.js proxies tend to map to the ParaView ones at the API level while skipping the distributed aspect that is inherent to ParaView. This allow more compact coding for mainstream/common viz actions.

1 Like

Thanks @Sebastien_Jourdain! Let me repeat that back in my own words to make sure I’m comprehending correctly:

  1. The examples focus on demonstrating a single aspect of vtk and thus often don’t use proxies (makes sense).
  2. Proxies, when used with representations or views, are a means of bundling a set of classes into a single entity to provide streamlined/centralized access to the API in the end-user application.
  3. The proxies in vtk generally were made to map to needs within ParaView at the API level although they don’t integration the parallelization native in ParaView.

Am I on the right path?

Yes that’s it. For 2, the proxy benefits are easier to understand for view and representation as they actually encapsulate a bunch of classes (represention = mapper + actor + properties) and expose the high level features (representation: suface, surfaceWithEdges, wireframe, point), not all the method calls across classes.

1 Like

Also because proxies are managed by a ProxyManager, the proxy manager give you import/export state capabilities.
Also proxies get described in a meta fashion (json), you can describe different behavior across apps (property link).

HTH and not confuse more… :wink:

1 Like

Thanks @Sebastien_Jourdain, this is all very helpful.