OCC+VTK Interactor

liuxeme

Looking around for some CAD
Hello everyone,
Dose someone know after using VTK rendering, how to achieve the interaction of the model? Such as pick-up point, edge, surface, etc.And Prehighlight or highlight the model.
I notice the article in quaoar's blog and VTK Integration Services (VIS) in occ official artice to use IVtkTools_ShapePicker to get IVtk_ShapeIdList.But when I test ,in mouse OnLeftButtonDown() event i clicked the mode face but the pick num is always 0.
Have a simple method to implement pick and highlight?
Occt version: OpenCASCADE-7.7.0-vc14-64
Vtk Version: 9.2.5
Thanks in advance!
1675223944032.png1675223799816.png
 

natalia

Moderator
Staff member
Hello @liuxeme,

what about checking it in OpenCASCADE DRAW application? Related test is placed here: /tests/vtk/ivtk/selection_mode.
Just run DRAW and perform steps from this scenario.

Implementation for ivtk* commands is placed in IVtkDraw.cxx, just do the search for the Tcl command name(which is 'ivtksetselmode' here).

Best regards, Natalia
 

liuxeme

Looking around for some CAD
Hello @liuxeme,

what about checking it in OpenCASCADE DRAW application? Related test is placed here: /tests/vtk/ivtk/selection_mode.
Just run DRAW and perform steps from this scenario.

Implementation for ivtk* commands is placed in IVtkDraw.cxx, just do the search for the Tcl command name(which is 'ivtksetselmode' here).

Best regards, Natalia
Hello,Thanks your advice,i looked for some methods to implement this function.
the opencascade forum someone come up with the similar question.
after test i find need to use IVtkTools_ShapeObject::SetShapeSource to bind vtkActor and IVtkTools_ShapeDataSource(this function be mentioned in the article in quaoar's blog,but i missed😂)
but another problem arised,the highlight actor render incompletly,but when change view of a vertical ,i will be ok!whether it need to set render normal to avoid this phenomenon?
1675504983915.png 1675505128749.png
when test in draw, ivtksetselmode 2 1,can't to change the face shading mode,where can i find it?
1675505219369.png 1675505432550.png
Thanks again!
 

Quaoar

Administrator
Staff member
Not sure if I remember how it works in the original sample, but I can guess they render another data set on top of the existing geometry. This would inevitably lead to the "Z fighting" issue, where near-coincident geometries are rendered more or less in the same place. In Analysis Situs, we took another way around, and instead of rendering a new actor on top of the selectable object, we are rather changing the color scalar associated with the picked cell. If you keep using another actor rendered, you might want to play with the polygon offset props of the corresponding mapper. All these SetResolveCoincidentTopologyToPolygonOffset() functions, you know.
 

blobfish

CAD community veteran
In Analysis Situs, we took another way around, and instead of rendering a new actor on top of the selectable object, we are rather changing the color scalar associated with the picked cell.
I used the same method of altering colors for selection highlights in cadseer. I can remembering reading a post by Robert Osfield (lead on OSG, VSG) where he was suggesting the copy method. I think the idea is that it is faster to make a small copy of data and push it across to the GPU, than it is to make a small change and have to push a large data set across to the GPU.

I don't find polygon offsets very easy to use. It is like their values need to be relative to the current view. Bigger view volumes require bigger polygon offset values to get the desired affect and vice versa. Probably something that is better left for shaders.
 

Quaoar

Administrator
Staff member
I don't find polygon offsets very easy to use. It is like their values need to be relative to the current view. Bigger view volumes require bigger polygon offset values to get the desired affect and vice versa.
Yes, that's for sure. I have never been able to offset polygons in a visually appealing way. And I also had the feeling that I just had to sit down for several months and learn OpenGL, including shaders and stuff. But it's looking more and more like those things are left for the next life.
 

vispec dmis

Looking around for some CAD
Hello,Thanks your advice,i looked for some methods to implement this function.
the opencascade forum someone come up with the similar question.
after test i find need to use IVtkTools_ShapeObject::SetShapeSource to bind vtkActor and IVtkTools_ShapeDataSource(this function be mentioned in the article in quaoar's blog,but i missed😂)
Hello liuxeme,

I have encountered a problem where the shapeId value I obtained is very large and I feel that it is incorrect. And obtain IVtk_ ShapeIdList is null. I don't know where the problem is.

1689066538476.png1689066683277.png1689066871105.png
 
Last edited:
Top