Can the API returned from the onCreated prop be used to manipulate a second volume generated at a time after the initial volume?

Hello,

I am working on the OHIF viewer to extend the functionality provided by the VTK extension. The current feature I am working on now is adding fusion. At this point, I have successfully brought in a second volume for fusion, but now I am trying to manipulate that layer using VTK’s native methods, by utilizing the API that is provided on the creation of the View2D / View3D components.

Here is a code snippet of the API I am referring to:

const mergeProps = (propsFromState, propsFromDispatch, ownProps) => {
  const { afterCreation } = propsFromState;

  const props = {
    ...propsFromState,
    ...propsFromDispatch,
    ...ownProps,
    /**
     * Our component sets up the underlying dom element on "componentDidMount"
     * for use with VTK.
     *
     * The onCreated prop passes back an Object containing many of the internal
     * components of the VTK scene. We can grab a reference to these here, to
     * make playing with VTK's native methods easier.
     *
     * A similar approach is taken with the Cornerstone extension.
     */
    onCreated: api => {
      // Store the API details for later
      //setViewportSpecificData({ vtkApi: api });

      if (afterCreation && typeof afterCreation === 'function') {
        afterCreation(api);
      }
    },
  };
  return props;
};

the full code can be found here Viewers/ConnectedVTKViewport.js at master · OHIF/Viewers · GitHub

My problem is that when I initialize the View2D / View3D components, they do not have 2 volumes, only the initial CT scan. It is not until a user picks a corresponding PET scan to perform fusion with that a second volume is generated. Therefore, the API provided to me is not aware of the second volume and I cannot use it to implement VTK’s native methods.

Am I able to simply push my second volume into the volumes array within the API? Or does the API need to be aware of any volumes it will be manipulating upon instantiation? Thanks for any help you can offer.

Hi, this appears to be an OHIF-specific question. I’d first see if there is an API to tell OHIF that you’ve updated the volumes array in order to render your second volume.