0032340: OCCT Documentation - highlight C++ code snippets
[occt.git] / dox / user_guides / vis / vis.md
CommitLineData
beb18c1f 1 VTK Integration Services (VIS) {#occt_user_guides__vis}
2============================
3
4@tableofcontents
5
6@section occt_vis_1 Introduction
7VIS component provides adaptation functionality for visualization of OCCT topological shapes by means of VTK library. This User’s Guide describes how to apply VIS classes in application dealing with 3D visualization based on VTK library.
8
d6b4d3d0 9@figure{/user_guides/vis/images/vis_image001.png,"3D visualization based on VTK library",421}
18006a0f 10
beb18c1f 11There are two ways to use VIS in the application:
12* Use a **high-level API**. It is a simple scenario to use VTK viewer with displayed OCCT shapes. It considers usage of tools provided with VIS component such as a specific VTK data source, a picker class and specific VTK filters. Basically, in this scenario you enrich your custom VTK pipeline with extensions coming from VIS.
13* Use a **low-level API**. It is an advanced scenario for the users with specific needs, which are not addressed by the higher-level utilities of VIS. It presumes implementation of custom VTK algorithms (such as filters) with help of low-level API of VIS component.
14This document describes both scenarios of VIS integration into application. To understand this document, it is necessary to be familiar with VTK and OCCT libraries.
15
16@section occt_vis_2 Component Architecture
17@subsection occt_vis_2_1 Common structure
18VIS component consists of the following packages:
3f812249 19* **IVtk** -- common interfaces which define the principal objects playing as foundation of VIS.
20* **IVtkOCC** -- implementation of interfaces related to CAD domain. The classes from this package deal with topological shapes, faceting and interactive selection facilities of OCCT;
21* **IVtkVTK** -- implementation of interfaces related to VTK visualization toolkit;
22* **IVtkTools** -- high-level tools designed for integration into VTK visualization pipelines.
beb18c1f 23
d6b4d3d0 24@figure{/user_guides/vis/images/vis_image002.png, "Dependencies of VIS packages",200}
beb18c1f 25
26The idea behind the mentioned organization of packages is separation of interfaces from their actual implementations by their dependencies from a particular library (OCCT, VTK). Besides providing of semantic separation, such splitting helps to avoid excessive dependencies on other OCCT toolkits and VTK.
27* **IVtk** package does not depend on VTK libraries at all and needs OCCT libraries only because of collections usage (*TKernel* library);
28* Implementation classes from **IVtkOCC** package depend on OCCT libraries only and do not need VTK;
29* **IVtkVTK** package depends on VTK libraries only and does not need any OCCT functionality except collections.
30
d6b4d3d0 31@figure{/user_guides/vis/images/vis_image003.png, "Dependencies of VIS packages", 240}
beb18c1f 32
33Basically, it is enough to use the first three packages in the end user’s application (*IVtk, IVtkOCC* and *IVtkVTK*) to be able to work with OCCT shapes in VTK viewer. However, *IVtkTools* package is also provided as a part of the component to make the work more comfortable.
18006a0f 34
35
beb18c1f 36@subsection occt_vis_2_2 IVtk package
37**IVtk** package contains the following classes:
3f812249 38* *IVtk_Interface* -- Base class for all interfaces of the component. Provides inheritance for *Handle* (OCCT “smart pointer”) functionality.
39* *IVtk_IShape* -- Represents a 3D shape of arbitrary nature. Provides its ID property. Implementation of this interface should maintain unique IDs for all visualized shapes. These IDs can be easily converted into original shape objects at the application level.
40* *IVtk_IShapeData* -- Represents faceted data. Provides methods for adding coordinates and cells (vertices, lines, triangles).
41* *IVtk_IShapeMesher* -- Interface for faceting, i.e. constructing *IVtk_IShapeData* from *IVtk_IShape* input shape.
42* *IVtk_IShapePickerAlgo* -- Algorithmic interface for interactive picking of shapes in a scene. Provides methods for finding shapes and their parts (sub-shapes) at a given location according to the chosen selection mode.
43* *IVtk_IView* -- Interface for obtaining view transformation parameters. It is used by *IVtk_IShapePickerAlgo*.
beb18c1f 44
45@subsection occt_vis_2_3 IVtkOCC package
46
47**IVtkOCC** package contains the implementation of classes depending on OCCT:
3f812249 48* *IVtkOCC_Shape* -- Implementation of *IVtk_IShape* interface as a wrapper for *TopoDS_Shape*.
49* *IVtkOCC_ShapeMesher* -- Implementation of *IVtk_IShapeMesher* interface for construction of facets from *TopoDS* shapes.
50* *IVtkOCC_ShapePickerAlgo* -- Implementation of interactive picking algorithm. It provides enabling/disabling of selection modes for shapes (*IVtk_IShape* instances) and picking facilities for a given position of cursor.
51* *IVtkOCC_ViewerSelector* -- Interactive selector, which implements *Pick()* methods for the picking algorithm *IVtkOCC_ShapePickerAlgo* and connects to the visualization layer with help of abstract *IView* interface.
beb18c1f 52
53*IVtkOCC_ViewerSelector* is a descendant of OCCT native *SelectMgr_ViewerSelector*, so it implements OCCT selection mechanism for *IVtkVTK_View* (similarly to *StdSelect_ViewerSelector3D* which implements *SelectMgr_ViewerSelector* for OCCT native *V3d_View*). *IVtkOCC_ViewerSelector* encapsulates all projection transformations for the picking mechanism. These transformations are extracted from *vtkCamera* instance available via VTK Renderer. *IVtkOCC_ViewerSelector* operates with native OCCT *SelectMgr_Selection* entities. Each entity represents one selection mode of an OCCT selectable object. *ViewerSelector* is an internal class, so it is not a part of the public API.
3f812249 54
55* *IVtkOCC_SelectableObject* -- OCCT shape wrapper used in the picking algorithm for computation of selection primitives of a shape for a chosen selection mode.
beb18c1f 56
57@subsection occt_vis_2_4 IVtkVtk package
3f812249 58**IVtkVTK** package contains implementation of classes depending on VTK:
59* *IVtkVTK_ShapeData* -- Implementation of *IVtk_IShapeData* interface for VTK polydata. This class also stores information related to sub-shape IDs and sub-shape mesh type *IVtk_MeshType* (free vertex, shared vertex, free edge, boundary edge, shared edge, wireframe face or shaded face). This information is stored in VTK data arrays for cells.
60* *IVtkVTK_View* -- Implementation of *IVtk_IView* interface for VTK viewer. This implementation class is used to connect *IVtkOCC_ViewerSelector* to VTK renderer.
beb18c1f 61
62@subsection occt_vis_2_5 IVtkTools package
63**IVtkTools** package gives you a ready-to-use toolbox of algorithms facilitating the integration of OCCT shapes into visualization pipeline of VTK. This package contains the following classes:
3f812249 64* *IVtkTools_ShapeDataSource* -- VTK polygonal data source for OCCT shapes. It inherits *vtkPolyDataAlgorithm* class and provides a faceted representation of OCCT shape for visualization pipelines.
65* *IVtkTools_ShapeObject* -- Auxiliary wrapper class for OCCT shapes to pass them through pipelines by means of VTK information keys.
66* *IVtkTools_ShapePicker* -- VTK picker for shape actors. Uses OCCT selection algorithm internally.
67* *IVtkTools_DisplayModeFilter* -- VTK filter for extracting cells of a particular mesh type according to a given display mode *IVtk_DisplayMode* (Wireframe or Shading).
68* *IVtkTools_SubPolyDataFilter* -- VTK filter for extracting the cells corresponding to a given set of sub-shape IDs.
beb18c1f 69
70Additionally, *IVtkTools* package contains auxiliary methods in *IVtkTools* namespace. E.g. there is a convenience function populating *vtkLookupTable* instances to set up a color scheme for better visualization of sub-shapes.
71
18006a0f 72@section occt_vis_3 Using high-level API (simple scenario)
beb18c1f 73@subsection occt_vis_3_1 OCCT shape presentation in VTK viewer
74
75To visualize an OCCT topological shape in VTK viewer, it is necessary to perform the following steps:
76
771. Create *IVtkOCC_Shape* instance (VIS wrapper for OCCT shape) and initialize it with *TopoDS_Shape* object containing the actual geometry:
77d94fd1 78~~~~{.cpp}
beb18c1f 79TopoDS_Shape aShape;
80
81// Initialize aShape variable: e.g. load it from BREP file
82
83IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape(aShape);
84~~~~
852. Create VTK polygonal data source for the target OCCT topological shape and initialize it with created *IVtkOCC_Shape* instance. At this stage the faceter is implicitly plugged:
77d94fd1 86~~~~{.cpp}
beb18c1f 87vtkSmartPointer<IVtkTools_ShapeDataSource> DS = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
88
89DS->SetShape(aShapeImpl);
90~~~~
913. Visualize the loaded shape in usual VTK way starting a pipeline from the newly created specific source:
77d94fd1 92~~~~{.cpp}
beb18c1f 93vtkSmartPointer<vtkPolyDataMapper> Mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
94
95Mapper->SetInputConnection(aDS->GetOutputPort());
96vtkSmartPointer<vtkActor> Actor = vtkSmartPointer<vtkActor>::New();
97
98Actor->SetMapper(Mapper);
99~~~~
100
101It is always possible to access the shape data source from VTK actor by means of dedicated methods from *IVtkTools_ShapeObject* class:
77d94fd1 102~~~~{.cpp}
beb18c1f 103IVtkTools_ShapeDataSource* DS = IVtkTools_ShapeObject::GetShapeSource(Actor);
104
105IVtkOCC_Shape::Handle occShape = IVtkTools_ShapeObject::GetOccShape(Actor);
106~~~~
107
108It is also possible to get a shape wrapper from the shape data source:
77d94fd1 109~~~~{.cpp}
beb18c1f 110IVtkOCC_Shape::Handle occShape = DS->GetShape();
111~~~~
112
113@subsection occt_vis_3_2 Color schemes
114@subsubsection occt_vis_3_2_1 Default OCCT color scheme
115
116To colorize different parts of a shape according to the default OCCT color scheme, it is possible to configure the corresponding VTK mapper using a dedicated auxiliary function of *IVtkTools* namespace:
117
77d94fd1 118~~~~{.cpp}
beb18c1f 119IVtkTools::InitShapeMapper(Mapper);
120~~~~
121It is possible to get an instance of *vtkLookupTable class* with a default OCCT color scheme by means of the following method:
122
77d94fd1 123~~~~{.cpp}
a2f76b15 124vtkSmartPointer<vtkLookupTable> Table = IVtkTools::InitLookupTable();
beb18c1f 125~~~~
126
127@subsubsection occt_vis_3_2_2 Custom color scheme
128To set up application-specific colors for a shape presentation, use *InitShapeMapper* function with an additional argument passing a custom lookup table:
129
77d94fd1 130~~~~{.cpp}
beb18c1f 131IVtkTools::InitShapeMapper(Mapper, Table);
132~~~~
133
134@subsubsection occt_vis_3_2_3 Setting custom colors for sub-shapes
135
136It is also possible to bind custom colors to any sub-shape type listed in *IVtk_MeshType* enumeration. For example, to access the color bound to *free edge* entities, the following calls are available in *IVtkTools* namespace:
77d94fd1 137~~~~{.cpp}
beb18c1f 138SetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B);
139SetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B, A);
140GetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B);
141GetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B, A);
142~~~~
143Here *R, G, B* are double values of red, green and blue components of a color from the range [0, 1]. The optional parameter *A* stands for the alpha value (the opacity) as a double from the same range [0, 1]. By default alpha value is 1, i.e. a color is not transparent.
144
145@subsubsection occt_vis_3_2_4 Using color scheme of mapper
146
147As VTK color mapping approach is based on associating scalar data arrays to VTK cells, the coloring of shape components can be turned on/off in the following way:
148
77d94fd1 149~~~~{.cpp}
beb18c1f 150Mapper->ScalarVisibilityOn(); // use colors from lookup table
151Mapper->ScalarVisibilityOff(); // use a color of actor’s property
152~~~~
153
154For example, the scalar-based coloring can be disabled to bind a single color to the entire VTK actor representing the shape.
155
156@subsection occt_vis_3_3 Display modes
157The output of the shape data source can be presented in wireframe or shading display mode. A specific filter from class *IVtkTools_DisplayModeFilter* can be applied to select the display mode. The filter passes only the cells corresponding to the given mode. The set of available modes is defined by *IVtk_DisplayMode* enumeration.
158
d6b4d3d0 159@figure{/user_guides/vis/images/vis_image004.png,"",360}
18006a0f 160
beb18c1f 161For example, the shading representation can be obtained in the following way:
162
77d94fd1 163~~~~{.cpp}
beb18c1f 164vtkSmartPointer<IVtkTools_ShapeDataSource> DS = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
165
166vtkSmartPointer<IVtkTools_DisplayModeFilter> DMFilter = vtkSmartPointer<IVtkTools_DisplayModeFilter>::New();
167
168DMFilter->AddInputConnection(DS->GetOutputPort());
169DMFilter->SetDisplayMode(DM_Shading);
170
171vtkSmartPointer<vtkDataSetMapper> M = vtkSmartPointer<vtkDataSetMapper>::New();
172M->SetInputConnection(DMFilter->GetOutputPort());
173~~~~
174
175By default, the display mode filter works in a wireframe mode.
176
177TIP: to make the shading representation smooth, use additional *vtkPolyDataNormals* filter. This filter must be applied after the display mode filter.
178
d6b4d3d0 179@figure{/user_guides/vis/images/vis_image005.png,"",360}
18006a0f 180
beb18c1f 181@subsection occt_vis_3_4 Interactive selection
182*IVtkTools* package provides *IVtkTools_ShapePicker* class to perform selection of OCCT shapes and sub-shapes in VTK viewer and access the picking results. The typical usage of *IVtkTools_ShapePicker* tool consists in the following sequence of actions:
1831. Create a picker and set its renderer to your active VTK renderer:
77d94fd1 184~~~~{.cpp}
beb18c1f 185vtkSmartPointer<IVtkTools_ShapePicker> aPicker = vtkSmartPointer<IVtkTools_ShapePicker>::New();
186
187aPicker->SetRenderer(aRenderer);
188~~~~
1892. Activate the desired selection mode by choosing the corresponding sub-shape types from *IVtk_SelectionMode* enumeration. For example, the following call allows selection of edges on all selectable shape actors of the renderer:
77d94fd1 190~~~~{.cpp}
beb18c1f 191aPicker->SetSelectionMode(SM_Edge);
192~~~~
193If it is necessary to limit selection by a particular shape actor, one can use the mentioned *SetSelectionMode* method with *IVtk_IShape* handle or *vtkActor* pointer as the first argument:
77d94fd1 194~~~~{.cpp}
beb18c1f 195IVtk_IShape::Handle aShape = new IVtkOCC_Shape(occShape);
196aPicker->SetSelectionMode(aShape, SM_Edge); // If shape handle is available
197aPicker->SetSelectionMode(anActor, SM_Edge); // If shape actor is available
198~~~~
199Different selection modes can be turned on/off for a picker at the same time independently from each other.
77d94fd1 200~~~~{.cpp}
beb18c1f 201aPicker->SetSelectionMode(SM_Edge);
202aPicker->SetSelectionMode(SM_Face);
203~~~~
204To turn off a selection mode, the additional optional Boolean parameter is used with *false* value, for example:
77d94fd1 205~~~~{.cpp}
beb18c1f 206aPicker->SetSelectionMode(aShape, SM_Edge, false);
207~~~~
2083. Call *Pick* method passing the mouse display coordinates:
77d94fd1 209~~~~{.cpp}
beb18c1f 210aPicker->Pick(x, y, 0);
211~~~~
212By default, the renderer passed in the step 1 is used. In order to perform pick operation for another renderer an additional optional parameter can be specified:
77d94fd1 213~~~~{.cpp}
beb18c1f 214aPicker->Pick(x, y, 0, aRenderer);
215~~~~
2164. Obtain the top-level picking results as a collection of picked VTK actors:
77d94fd1 217~~~~{.cpp}
beb18c1f 218vtkActorCollection* anActorCollection = aPicker->GetPickedActors();
219~~~~
220or as a collection of picked shape IDs:
77d94fd1 221~~~~{.cpp}
beb18c1f 222IVtk_ShapeIdList ids = aPicker->GetPickedShapesIds();
223~~~~
224These methods return a single top picked actor or a shape by default. To get all the picked actors or shapes it is necessary to send “true” value in the optional Boolean parameter:
77d94fd1 225~~~~{.cpp}
beb18c1f 226anActorCollection = aPicker->GetPickedActors(true);
227ids = aPicker->GetPickedShapesIds(true);
228~~~~
2295. Obtain the picked sub-shape IDs:
77d94fd1 230~~~~{.cpp}
beb18c1f 231IVtk_ShapeIdList subShapeIds = aPicker->GetPickedSubShapesIds(shapeId);
232~~~~
233This method also returns a single ID of a top-level picked sub-shape and has the same optional Boolean parameter to get all the picked sub-shapes of a shape:
77d94fd1 234~~~~{.cpp}
beb18c1f 235subShapeIds = aPicker->GetPickedSubShapesIds(shapeId, true);
236~~~~
237
238It should be noted that it is more efficient to create a sole picker instance and feed it with the renderer only once. The matter is that the picking algorithm performs internal calculations each time the renderer or some of its parameters are changed. Therefore, it makes sense to minimize the number of such updates.
239
240OCCT picking algorithm *IVtkTools_ShapePicker* calculates a new transformation matrix for building of projection each time some parameters of a view are changed. Likewise, the shape selection primitives for each selection mode are built once an appropriate selection mode is turned on for this shape in *SetSelectionMode* method.
241
242WARNING: VIS picker essentially works on the initial topological data structures rather than on the actually visualized actors. This peculiarity allows VIS to take advantage of standard OCCT selection mechanism, but puts strict limitations on the corresponding visualization pipelines. Once constructed, the faceted shape representation should not be morphed or translated anyhow. Otherwise, the picking results will lose their associativity with the source geometry. E.g. you should never use *vtkTransform* filter, but rather apply OCCT isometric transformation on the initial model in order to work on already relocated facet. These limitations are often acceptable for CAD visualization. If not, consider usage of a custom VTK-style picker working on the actually visualized actors.
243
d6b4d3d0 244@figure{/user_guides/vis/images/vis_image006.png,"",420}
18006a0f 245
beb18c1f 246@subsubsection occt_vis_3_5 Selection of sub-shapes
247
248*IVtkTools_SubPolyDataFilter* is a handy VTK filter class which allows extraction of polygonal cells corresponding to the sub-shapes of the initial shape. It can be used to produce a *vtkPolyData* object from the input *vtkPolyData* object, using selection results from *IVTkTools_ShapePicker* tool.
249
250For example, sub-shapes can be represented in VTK viewer in the following way:
251
77d94fd1 252~~~~{.cpp}
beb18c1f 253// Load a shape into data source (see 3.1)
254...
255vtkSmartPointer<IVtkTools_ShapeDataSource> DS = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
256
257DS->SetShape(shapeImpl);
258...
259
260// Create a new sub-polydata filter for sub-shapes filtering
261vtkSmartPointer<IVtkTools_SubPolyDataFilter> subShapesFilter = IVtkTools_SubPolyDataFilter::New();
262
3f812249 263// Set a shape source as an input of the sub-polydata filter
beb18c1f 264subShapesFilter->SetInputConnection(DS->GetOutputPort());
265
266// Get all picked sub-shapes ids of the shape from a picker (see 3.4)
267IVtk_ShapeIdList subShapeIds = aPicker->GetPickedSubShapesIds(ds->GetId(), true);
268
269// Set ids to the filter to pass only picked sub-shapes
270subShapesFilter->SetData(subShapeIds);
271subShapesFilter->Modified();
272
273// Output the result into a mapper
274vtkSmartPointer<vtkPolyDataMapper> aMapper = vtkPolyDataMapper::New();
275aMapper->AddInputConnection(subShapesFilter->GetOutputPort());
276...
277~~~~
278
279@section occt_vis_4 Using of low-level API (advanced scenario)
280@subsection occt_vis_4_1 Shape presentation
281The usage of low-level tools is justified in cases when the utilities from *IVtkTools* are not enough.
282
283The low-level scenario of VIS usage in VTK pipeline is shown in the figure below. The Mesher component produces shape facet (VTK polygonal data) using implementation of *IShapeData* interface. Then result can be retrieved from this implementation as a *vtkPolyData* instance.
284
d6b4d3d0 285@figure{/user_guides/vis/images/vis_image007.svg "Low-level VIS usage with VTK", 420}
18006a0f 286
beb18c1f 287The visualization pipeline for OCCT shape presentation can be initialized as follows:
2881. Create an instance of *IShape* class initialized by OCCT topological shape:
77d94fd1 289~~~~{.cpp}
beb18c1f 290TopoDS_Shape aShape;
291
292// Load or create a TopoDS_Shape in the variable a Shape
293...
294IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape(aShape);
295~~~~
2962. Create an empty instance of IShapeData implementation for VTK:
77d94fd1 297~~~~{.cpp}
beb18c1f 298IVtk_IShapeData::Handle aDataImpl = new IVtkVTK_ShapeData();
299~~~~
3003 Create an instance of *IShapeMesher* implementation for OCCT (any faceter can be used at this stage):
77d94fd1 301~~~~{.cpp}
beb18c1f 302IVtk_IShapeMesher::Handle aMesher = new IVtkOCC_ShapeMesher();
303~~~~
3044 Triangulate the OCCT topological shape by means of the Mesher and access the result:
77d94fd1 305~~~~{.cpp}
beb18c1f 306aMesher->Build (aShapeImpl, aDataImpl);
307
308vtkPolyData* aPolyData = aDataImpl->GetVtkPolyData();
309~~~~
310
311The resulting *vtkPolyData* instance can be used for initialization of VTK pipelines.
312*IVtkVTK_ShapeData* object is used to keep and pass the mapping between sub-shapes, their mesh types and the resulting mesh cells through a pipeline. It stores sub-shape IDs and mesh type in VTK data arrays for each generated cell. As a result, the generated VTK cells get the following data arrays populated:
3f812249 313* *SUBSHAPE_IDS* - array of *vtkIdTypeArray* type. It contains the shape IDs the corresponding cells were generated for. The name of this array is defined in *ARRNAME_SUBSHAPE_IDS* constant of *IVtkVTK_ShapeData* class.
314* *MESH_TYPES* - array of *vtkShortArray type*. It contains the type tags of the shape parts the corresponding cells were generated for. The name of this array is defined in *ARRNAME_MESH_TYPES* constant of *IVtkVTK_ShapeData* class.
beb18c1f 315
316@subsection occt_vis_4_2 Usage of OCCT picking algorithm
317
318It is possible to create a custom VTK picker for interactive selection of OCCT 3D shapes using an instance of the picking algorithm *IVtk_IShapePickerAlgo*.
319
320Picking algorithm uses an instance of viewer selector (OCCT term), which manages picking along with activation and deactivation of selection modes. VIS component implements OCCT selection principle in *IVtkOCC_ShapePickerAlgo* and *IVtkOCC_ViewerSelector* classes. *IVtkOCC_ViewerSelector* is an internal class that implements OCCT selection mechanism applied in *IVtkVTK_View*.
321
322*IVtkOCC_ShapePickerAlgo* has to be used to activate/deactivate selection modes for shapes *IVtk_IShape*. *IVtkOCC_ShapePickerAlgo* is the implementation of *IVtk_IShapePickerAlgo* interface.
323
324The typical usage of *IVtk_IShapePickerAlgo* consists in the following sequence of actions:
3251. Create an instance of the picker class:
77d94fd1 326~~~~{.cpp}
beb18c1f 327IVtkOCC_ShapePickerAlgo::Handle Picker = new IVtkOCC_ShapePickerAlgo();
328~~~~
329
3302. Set an instance of *IVtk_IView* class to the algorithm in order to define the viewer parameters:
77d94fd1 331~~~~{.cpp}
beb18c1f 332IVtkVTK_View::Handle View = new IVtkVTK_View(Renderer);
333Picker->SetView(View);
334~~~~
3353. Activate the desired selection modes using values from *IVtk_SelectionMode* enumeration. For example, the following call allows selection of edges:
77d94fd1 336~~~~{.cpp}
beb18c1f 337TopoDS_Shape aShape;
338// Load or create a TopoDS_Shape in the variable a Shape
339...
340IVtk_IShape::Handle shapeImpl = new IVtkOCC_Shape(aShape);
341...
342myOccPickerAlgo->SetSelectionMode(occShape, SM_Edge);
343~~~~
344Different selection modes can be turned on/off for a picker at the same time independently from each other.
345To turn off a selection mode the additional optional Boolean parameter is used with *false* value, for example:
77d94fd1 346~~~~{.cpp}
beb18c1f 347myOccPickerAlgo->SetSelectionMode(occShape, SM_Edge, false);
348~~~~
3494. Call *Pick* method passing the mouse coordinates:
77d94fd1 350~~~~{.cpp}
beb18c1f 351myOccPickerAlgo->Pick(x, y);
352~~~~
3535. Obtain top-level picking results as IDs of the picked top-level shapes:
77d94fd1 354~~~~{.cpp}
beb18c1f 355IVtk_ShapeIdList ids = myOccPickerAlgo->ShapesPicked();
356~~~~
3576. Obtain IDs of the picked sub-shapes:
77d94fd1 358~~~~{.cpp}
beb18c1f 359IVtk_ShapeIdList subShapeIds
360 = myOccPickerAlgo->SubShapesPicked(shapeId);
18006a0f 361~~~~
beb18c1f 362
363@section occt_vis_5 DRAW Test Harness
364
365*TKIVtkDraw* toolkit contains classes for embedding VIS functionality into DRAW Test Harness with possibility of simple interactions, including detection and highlighting.
3f812249 366* *IVtkDraw_HighlightAndSelectionPipeline* -- Creates VTK pipeline with OCCT shape data source and properly initialized VIS filters.
367* *IVtkDraw_Interactor* -- Controls simple interactive actions, such as detection and selection of the displayed shapes.
d6b4d3d0 368