Kitware / glance

Kitware Glance is an open-source web application developed at Kitware for visualizing volumetric images, molecular structures, geometric objects, and point clouds. It is part of the ParaView platform and can serve as a foundation for building custom web-based visualization applications involving ITK.js and VTK.js.
https://kitware.github.io/glance
BSD 3-Clause "New" or "Revised" License
249 stars 87 forks source link

how to use proxyFilter.js? #333

Closed KevinJJH closed 2 years ago

KevinJJH commented 4 years ago

Hi,can you tell me how to use proxyFilter.js? now I need to use WindowedSincPolyDataFilter or ImageMarchingCubes,but I don't know how to use it in this project. thx

floryst commented 4 years ago

@jourdain Do you know how proxyFilter is handled? I forget, and would need to look around for this.

KevinJJH commented 4 years ago

@jourdain Do you know how proxyFilter is handled? I forget, and would need to look around for this.

take a look, you defined proxyFilter but never use it Thanks for your help!

floryst commented 4 years ago

Ah, I looked through it and now see what happened. I deleted proxyFilter references since we weren't using that anymore (i.e. we don't have that exposed in the current UI). Take a look here. You can add it back in as a Source. Then, when you want to run your image through the Contour filter, you do:

const contourSource = proxyManager.createProxy('Sources', 'Contour', { name: '', ... });
contourSource.setInputProxy(myImageSource);

And don't forget to re-add Contour as a vtkImageData!

Let me know if you need anymore clarification.

KevinJJH commented 4 years ago

How can you run your image through the filter? is there any other way to use filter in this project?I want to use WindowedSincPolyDataFilter to make image more smooth, it seems ImageMarchingCubes can do it too. but when I refer vtk document WindowedSincPolyDataFilter I still don't know how to use it, how to setInputConnection with mySource;

I followed your advice,but It doesn't work. ERROR:Invalid or missing input.please check my code:

const contourSource = this.$proxyManager.createProxy('Sources', 'Contour');//this doesn't work,ERROR:Invalid or missing input. contourSource.setInputProxy(this.$proxyManager.getProxyById(this.activeSourceId));

I followed code and found:

if (model.algo && model.inputProxy) {
  model.algo.setInputData(model.inputProxy.getDataset());
}

if (model.updateDomain && model.inputProxy) {
  model.updateDomain(publicAPI, model.inputProxy.getDataset());
}

if (model.algo) {
  publicAPI.setInputData(model.algo.getOutputData(), model.type);//problem is here
}//model.algo.getOutputData() will output 'Invalid or missing input'

that would be great if write some filter demo in the current UI. Because vtk's docutmentation is too brief for me and hard to understand.. I really need your help, Thank you!

floryst commented 4 years ago

The median filter currently in Glance uses itk.js to run the algorithm.

As for your issue, you should be able to get it to work via:

const contourSource = this.$proxyManager.createProxy('Sources', 'Contour', {
  inputProxy: <your proxy here>,
});

I'm surprised that you get an invalid input error on createProxy. I'll take a look.

KevinJJH commented 4 years ago

thx, now it work.but when I do:

const contourSource = this.$proxyManager.createProxy('Sources', 'Contour',{inputProxy:myProxy})
this.$nextTick(() => { contourSource.setComputeNormals(true) this.$forceUpdate(); });

I am confused why it doesn't have any change on my window. I would like to WindowedSincPolyDataFilter in the current UI, should I write another filter like proxyFilter? WechatIMG6 I try to use it by this way but failed. And ui you had define in proxyFilter seems useless,I want to know how to use proxyFilter and WindowedSincPolyDataFilter in the current UI, can you write them in your UI so that I can clone the project and watch directly?I am depressed :( that these problems confused me a few days and I have checked your commit history,still not found where you use the proxyFilter in the UI.Though you defined proxy;Please teach me,thank you ;

KevinJJH commented 4 years ago

Hi,are you still there? I need more clarification

floryst commented 4 years ago

Hi! this dropped off my radar. Right now Glance needs a bit of tweaking before you can comfortably use filters, since those were unfortunately not expanded upon after testing it early on. I can quickly outline a few things that would need to be changed:

This requires a bit more plumbing work going into Glance, and I currently don't have available time to provide concrete code. However, I'll try to provide guidance so you can get this to work. :)

floryst commented 4 years ago

Addendum: You probably are better off doing something similar to how MedianFilter is done. That way, your filtered datasets will automatically show up in Glance without modifying internal plumbing.

KevinJJH commented 4 years ago

Thank you,I will try. Talk later