How to disable surface picking with CellPicker ?

Hi all,

I’m using vtk.js. I’ve a CubeSource with a wireframe representation and I’ve a CellPicker. I want the cell picker pick operation to be successful only when edges are clicked, not surfaces (as the cube is represented in wireframe, that does not make much sense to be able to pick invisible surfaces).

The problem was solved in a very similar algorithm but written with the Java binding of VTK:

            // cuboid object is a simple pojo
            vtkCubeSource cube = new vtkCubeSource();
            cube.SetCenter(cuboid.getX0() + cuboid.getSizeX() / 2, cuboid.getY0() + cuboid.getSizeY() / 2,
                    cuboid.getZ0() + cuboid.getSizeZ() / 2);
            cube.SetXLength(cuboid.getSizeX());
            cube.SetYLength(cuboid.getSizeY());
            cube.SetZLength(cuboid.getSizeZ());

            // When cuboid is setup for a wireframe display, then we want selection to happen only when
            // user clicks on edges. So we have to transform polygonal cells to edges for the picker to work
            vtk.vtkDataSetMapper mapper = new vtk.vtkDataSetMapper();
            vtkExtractEdges edgesFilter = new vtkExtractEdges();
            edgesFilter.SetInputConnection(cube.GetOutputPort());
            mapper.SetInputConnection(edgesFilter.GetOutputPort());
            mapper.ScalarVisibilityOn();
            cuboid.SetMapper(mapper);
            cuboid.GetProperty().SetRepresentationToWireframe();
            Color edgeColor = cuboid.getColor();
            float[] rgbComponents = edgeColor.getRGBColorComponents(null);
            cuboid.GetProperty().SetColor(rgbComponents[0], rgbComponents[1], rgbComponents[2]);
            cuboid.GetProperty().SetEdgeColor(rgbComponents[0], rgbComponents[1], rgbComponents[2]);
            cuboid.GetProperty().SetEdgeVisibility(1);
            cuboid.GetProperty().SetLineWidth(2);

I don’t think vtkExtractEdges is available in vtk.js. Do you see any other way to proceed ?

Having vtkExtractEdges in vtk.js would be helpful, but we don’t have it yet. I think the only way is to manually populate your polydata with the cube lines (aka a cube edges extractor).