vtk.js-Clips processing of VTP

I have data in VTP format, I want to cut the section of this data and keep its remaining scalar properties(for coloring), what should I do?
I used to call vtkTableBasedClipDataSet() by encapsulating the C++ version of vtk to achieve the effect of cross section. But the VTK file is read (the data in the VTK file I have only has meshed volume data, and there is no information about the original wireframe of the model after cutting). I want to render the original wireframe of the model after cutting information, can you give me some interesting suggestions?

For the example of VTK operation, I copied it based on ClipUnstructuredGridWithPlane

vtkNew <vtkTableBasedClipDataSet clipper;

For the data input of vtkTableBasedClipDataSet, I only see UnstructuredGrid and vtkRectilinearGrid; I don’t know if I can modify it into polydata input format according to my own needs.
Glad you could tell me about these input data issues or some other help!

I saw the legend in vtkTableBasedClipDataSet in the document, vtkTableBasedClipDataSet inherits from vtkUnstructuredGridAlgorithm, so it can use such data input, it does not inherit from polydata, so polydata cannot be used as its data input, is my understanding correct?

What about vtkClipClosedSurface ? it does not do what you want ?

Thank you for your reply
I’ve looked at the vtkClipClosedSurface, which itself cannot set a specific gradient color based on a scalar, only a fixed color.

Not sure to understand what you are trying to do. Do you mind sharing a screenshot of your expected result ?

I’d be happy to share my expected results!
Based on what I said at the beginning, I’ve now done something like this:

The above screenshot is obtained by processing the VTK(the data format is unstructuredgrid) file. However, the VTK is the result after meshing, and there is no wireframe of the initial model.
Because the VTP(Polydata) file I have at hand contains the initial wireframe of the model, I want to perform cross-section processing on the VTP file, and I hope the result of the processing is like this:

VTK.js does not support volumetric mesh, only surface mesh. It means that when “cutting”/“slicing” in the middle of your mesh would not get any scalar value inside the mesh (scalar values are only at the outer surface).

Thank you for your prompt reply!
The data on my side is the surface mesh.Because the VTP file extracts the surface mesh of VTK for storage (in other words, the model rendered by the VTP file is an empty shell, only the surface data)
This cut model is divided into two parts, one is the cross section face and the other is the cross section body.
I only need to think about the cross section body now, how to cut and show the color I want.

If you only need the body, then I believe vtkClipClosedSurface is what you need.
Having said that, maybe vtkClipClosedSurface does not propagate correctly the “scalars” to the output clipped mesh. You would have to investigate the code of the filter for that.

Thanks for the advice!
I will try to implement it according to your instructions!

Great !

(PRs are welcomed :slight_smile: )

Unfortunately, I seem to have failed, I can change the facet to the color I want, but he still has a situation:
If the vertices involved in the slice are 300 400 500 and so on, I set the value of these vertices in PointData to red (this color should be according to the value defined in ColorMap).
For example, vertex 300 will undergo color gradient processing to the adjacent vertices (290-300), which is not obvious in wireframe mode, but very obvious in surface mode
(set according to actor.getProperty().setRepresentation(); )

I still have a question about the Lines attribute in my VTP. Why does the Lines attribute disappear after the vtkClipClosedSurface class is processed? I didn’t see how this reason works in the source code ( I will continue to check later), if you know the relevant reason, if you can, I hope you can share it with me.

I’m sorry but I fail to understand the problem. Would you mind sharing the dataset you would like to clip ?

I’m happy to share!This is my model dataset:
beam.vtp (589.9 KB)
Let me explain my problem again:
When I import a Polydata dataset containing Lines and Polys properties into the ClipClosedSurface class,

ClipClosedSurface will return a the FilterData after section processing contains Polys attributes (Polydata format)

I don’t know why this happens. My personal understanding is that ClipClosedSurface integrates Lines into Polys after cutting Lines.
I don’t know if the question is clarified this time, if not, please tell me the ambiguity of the question.
Looking forward to your reply!

Thanks, I better understand.

Can you check what the C++/Python vtkClipClosedSurface does ? Does it behave the same ?

Not very familiar with Python and C language, but I can try to check!
If there is the latest advancement, I will continue to update !
If you have related ideas, I am very happy that you can share them with me!