0022859: Developers guide with code samples
[occt.git] / dox / user_guides / vis / vis.md
1  VTK Integration Services (VIS)  {#occt_user_guides__vis}
2 ============================
3
4 @tableofcontents
5
6 @section occt_vis_1     Introduction
7 VIS 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
9 @figure{/user_guides/vis/images/vis_image001.png}
10  
11 There 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.
14 This 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
18 VIS component consists of the following packages:
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.
23
24 @figure{/user_guides/vis/images/vis_image002.png "Dependencies of VIS packages"}
25
26 The 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
31 @figure{/user_guides/vis/images/vis_image003.png "Dependencies of VIS packages"}
32
33 Basically, 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.
34  
35  
36 @subsection occt_vis_2_2         IVtk package
37 **IVtk** package contains the following classes:
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*.
44
45 @subsection occt_vis_2_3         IVtkOCC package
46
47 **IVtkOCC** package contains the implementation of classes depending on OCCT:
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. 
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.
54 * *IVtkOCC_SelectableObject* - OCCT shape wrapper used in the picking algorithm for computation of selection primitives of a shape for a chosen selection mode.
55
56 @subsection occt_vis_2_4 IVtkVtk package
57 **IVtkVTK** package contains implementation classes depending on VTK:
58 * *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.
59 * *IVtkVTK_View* - Implementation of *IVtk_IView* interface for VTK viewer. This implementation class is used to connect *IVtkOCC_ViewerSelector* to VTK renderer.
60
61 @subsection occt_vis_2_5         IVtkTools package
62 **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:
63 * *IVtkTools_ShapeDataSource* - VTK polygonal data source for OCCT shapes. It inherits *vtkPolyDataAlgorithm* class and provides a faceted representation of OCCT shape for visualization pipelines.
64 * *IVtkTools_ShapeObject* - Auxiliary wrapper class for OCCT shapes to pass them through pipelines by means of VTK information keys.
65 * *IVtkTools_ShapePicker* - VTK picker for shape actors. Uses OCCT selection algorithm internally.
66 * *IVtkTools_DisplayModeFilter* - VTK filter for extracting cells of a particular mesh type according to a given display mode *IVtk_DisplayMode* (Wireframe or Shading).
67 * *IVtkTools_SubPolyDataFilter* - VTK filter for extracting the cells corresponding to a given set of sub-shape IDs.
68
69 Additionally, *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.
70
71 @section occt_vis_3     Using high-level API (simple scenario) 
72 @subsection occt_vis_3_1        OCCT shape presentation in VTK viewer
73
74 To visualize an OCCT topological shape in VTK viewer, it is necessary to perform the following steps:
75
76 1. Create *IVtkOCC_Shape* instance (VIS wrapper for OCCT shape) and initialize it with *TopoDS_Shape* object containing the actual geometry:
77 ~~~~
78 TopoDS_Shape aShape;
79
80 // Initialize aShape variable: e.g. load it from BREP file
81
82 IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape(aShape);
83 ~~~~
84 2. 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:
85 ~~~~
86 vtkSmartPointer<IVtkTools_ShapeDataSource> DS = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
87
88 DS->SetShape(aShapeImpl);
89 ~~~~
90 3. Visualize the loaded shape in usual VTK way starting a pipeline from the newly created specific source:
91 ~~~~
92 vtkSmartPointer<vtkPolyDataMapper> Mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
93
94 Mapper->SetInputConnection(aDS->GetOutputPort());
95 vtkSmartPointer<vtkActor> Actor = vtkSmartPointer<vtkActor>::New();
96
97 Actor->SetMapper(Mapper);
98 ~~~~
99
100 It is always possible to access the shape data source from VTK actor by means of dedicated methods from *IVtkTools_ShapeObject* class:
101 ~~~~
102 IVtkTools_ShapeDataSource* DS = IVtkTools_ShapeObject::GetShapeSource(Actor);
103
104 IVtkOCC_Shape::Handle occShape = IVtkTools_ShapeObject::GetOccShape(Actor);
105 ~~~~
106
107 It is also possible to get a shape wrapper from the shape data source:
108 ~~~~
109 IVtkOCC_Shape::Handle occShape = DS->GetShape();
110 ~~~~
111
112 @subsection occt_vis_3_2         Color schemes
113 @subsubsection occt_vis_3_2_1   Default OCCT color scheme
114
115 To 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:
116
117 ~~~~
118 IVtkTools::InitShapeMapper(Mapper);
119 ~~~~
120 It is possible to get an instance of *vtkLookupTable class* with a default OCCT color scheme by means of the following method:
121
122 ~~~~
123 vtkLookupTable* Table = IVtkTools::InitLookupTable();
124 ~~~~
125
126 @subsubsection occt_vis_3_2_2   Custom color scheme
127 To set up application-specific colors for a shape presentation, use *InitShapeMapper* function with an additional argument passing a custom lookup table:
128
129 ~~~~
130 IVtkTools::InitShapeMapper(Mapper, Table);
131 ~~~~
132
133 @subsubsection occt_vis_3_2_3   Setting custom colors for sub-shapes
134
135 It 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:
136 ~~~~
137 SetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B);
138 SetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B, A);
139 GetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B);
140 GetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B, A);
141 ~~~~
142 Here *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.
143
144 @subsubsection occt_vis_3_2_4   Using color scheme of mapper
145
146 As 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:
147
148 ~~~~
149 Mapper->ScalarVisibilityOn();  // use colors from lookup table
150 Mapper->ScalarVisibilityOff(); // use a color of actor’s property
151 ~~~~
152
153 For example, the scalar-based coloring can be disabled to bind a single color to the entire VTK actor representing the shape.
154
155 @subsection occt_vis_3_3         Display modes
156 The 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.
157
158 @figure{/user_guides/vis/images/vis_image004.png}
159  
160 For example, the shading representation can be obtained in the following way:
161
162 ~~~~
163 vtkSmartPointer<IVtkTools_ShapeDataSource> DS = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
164
165 vtkSmartPointer<IVtkTools_DisplayModeFilter> DMFilter = vtkSmartPointer<IVtkTools_DisplayModeFilter>::New();
166
167 DMFilter->AddInputConnection(DS->GetOutputPort());
168 DMFilter->SetDisplayMode(DM_Shading);
169
170 vtkSmartPointer<vtkDataSetMapper> M = vtkSmartPointer<vtkDataSetMapper>::New();
171 M->SetInputConnection(DMFilter->GetOutputPort());
172 ~~~~
173
174 By default, the display mode filter works in a wireframe mode.
175
176 TIP: to make the shading representation smooth, use additional *vtkPolyDataNormals* filter. This filter must be applied after the display mode filter.
177
178 @figure{/user_guides/vis/images/vis_image005.png}
179  
180 @subsection occt_vis_3_4         Interactive selection
181 *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:
182 1. Create a picker and set its renderer to your active VTK renderer:
183 ~~~~
184 vtkSmartPointer<IVtkTools_ShapePicker> aPicker = vtkSmartPointer<IVtkTools_ShapePicker>::New();
185
186 aPicker->SetRenderer(aRenderer);
187 ~~~~
188 2. 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:
189 ~~~~
190 aPicker->SetSelectionMode(SM_Edge);
191 ~~~~
192 If 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:
193 ~~~~
194 IVtk_IShape::Handle aShape = new IVtkOCC_Shape(occShape);
195 aPicker->SetSelectionMode(aShape, SM_Edge); // If shape handle is available
196 aPicker->SetSelectionMode(anActor, SM_Edge); // If shape actor is available
197 ~~~~
198 Different selection modes can be turned on/off for a picker at the same time independently from each other.
199 ~~~~
200 aPicker->SetSelectionMode(SM_Edge);
201 aPicker->SetSelectionMode(SM_Face);
202 ~~~~
203 To turn off a selection mode, the additional optional Boolean parameter is used with *false* value, for example:
204 ~~~~
205 aPicker->SetSelectionMode(aShape, SM_Edge, false);
206 ~~~~
207 3. Call *Pick* method passing the mouse display coordinates:
208 ~~~~
209 aPicker->Pick(x, y, 0);
210 ~~~~
211 By 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:
212 ~~~~
213 aPicker->Pick(x, y, 0, aRenderer);
214 ~~~~
215 4. Obtain the top-level picking results as a collection of picked VTK actors:
216 ~~~~
217 vtkActorCollection* anActorCollection = aPicker->GetPickedActors();
218 ~~~~
219 or as a collection of picked shape IDs:
220 ~~~~
221 IVtk_ShapeIdList ids = aPicker->GetPickedShapesIds();
222 ~~~~
223 These 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:
224 ~~~~
225 anActorCollection = aPicker->GetPickedActors(true);
226 ids = aPicker->GetPickedShapesIds(true);
227 ~~~~
228 5. Obtain the picked sub-shape IDs:
229 ~~~~
230 IVtk_ShapeIdList subShapeIds = aPicker->GetPickedSubShapesIds(shapeId);
231 ~~~~
232 This 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:
233 ~~~~
234 subShapeIds = aPicker->GetPickedSubShapesIds(shapeId, true);
235 ~~~~
236
237 It 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.
238
239 OCCT 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.
240
241 WARNING: 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.
242
243 @figure{/user_guides/vis/images/vis_image006.png}
244  
245 @subsubsection occt_vis_3_5      Selection of sub-shapes
246
247 *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.
248
249 For example, sub-shapes can be represented in VTK viewer in the following way:
250
251 ~~~~
252 // Load a shape into data source (see 3.1)
253 ...
254 vtkSmartPointer<IVtkTools_ShapeDataSource> DS = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
255
256 DS->SetShape(shapeImpl);
257 ...
258
259 // Create a new sub-polydata filter for sub-shapes filtering
260 vtkSmartPointer<IVtkTools_SubPolyDataFilter> subShapesFilter = IVtkTools_SubPolyDataFilter::New();
261
262 // Set a shape source as an input of the subpolydata filter
263 subShapesFilter->SetInputConnection(DS->GetOutputPort());
264
265 // Get all picked sub-shapes ids of the shape from a picker (see 3.4)
266 IVtk_ShapeIdList subShapeIds = aPicker->GetPickedSubShapesIds(ds->GetId(), true);
267
268 // Set ids to the filter to pass only picked sub-shapes
269 subShapesFilter->SetData(subShapeIds);
270 subShapesFilter->Modified();
271
272 // Output the result into a mapper
273 vtkSmartPointer<vtkPolyDataMapper> aMapper = vtkPolyDataMapper::New();
274 aMapper->AddInputConnection(subShapesFilter->GetOutputPort());
275 ...
276 ~~~~
277
278 @section occt_vis_4     Using of low-level API (advanced scenario)
279 @subsection occt_vis_4_1        Shape presentation
280 The usage of low-level tools is justified in cases when the utilities from *IVtkTools* are not enough.
281
282 The 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.
283
284 @figure{/user_guides/vis/images/vis_image007.png "Low-level VIS usage with VTK"}
285  
286 The visualization pipeline for OCCT shape presentation can be initialized as follows:
287 1. Create an instance of *IShape* class initialized by OCCT topological shape:
288 ~~~~
289 TopoDS_Shape aShape;
290
291 // Load or create a TopoDS_Shape in the variable a Shape
292 ...
293 IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape(aShape);
294 ~~~~
295 2. Create an empty instance of IShapeData implementation for VTK:
296 ~~~~
297 IVtk_IShapeData::Handle aDataImpl = new IVtkVTK_ShapeData();
298 ~~~~
299 3 Create an instance of *IShapeMesher* implementation for OCCT (any faceter can be used at this stage):
300 ~~~~
301 IVtk_IShapeMesher::Handle aMesher = new IVtkOCC_ShapeMesher();
302 ~~~~
303 4 Triangulate the OCCT topological shape by means of the Mesher and access the result:
304 ~~~~
305 aMesher->Build (aShapeImpl, aDataImpl);
306
307 vtkPolyData* aPolyData = aDataImpl->GetVtkPolyData();
308 ~~~~
309
310 The resulting *vtkPolyData* instance can be used for initialization of VTK pipelines.
311 *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:
312 * *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.
313 * *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.
314
315 @subsection occt_vis_4_2         Usage of OCCT picking algorithm
316
317 It is possible to create a custom VTK picker for interactive selection of OCCT 3D shapes using an instance of the picking algorithm *IVtk_IShapePickerAlgo*.
318
319 Picking 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*.
320
321 *IVtkOCC_ShapePickerAlgo* has to be used to activate/deactivate selection modes for shapes *IVtk_IShape*. *IVtkOCC_ShapePickerAlgo* is the implementation of *IVtk_IShapePickerAlgo* interface.
322
323 The typical usage of *IVtk_IShapePickerAlgo* consists in the following sequence of actions:
324 1. Create an instance of the picker class:
325 ~~~~
326 IVtkOCC_ShapePickerAlgo::Handle Picker = new IVtkOCC_ShapePickerAlgo();
327 ~~~~
328
329 2. Set an instance of *IVtk_IView* class to the algorithm in order to define the viewer parameters:
330 ~~~~
331 IVtkVTK_View::Handle View = new IVtkVTK_View(Renderer);
332 Picker->SetView(View);
333 ~~~~
334 3. Activate the desired selection modes using values from *IVtk_SelectionMode* enumeration. For example, the following call allows selection of edges:
335 ~~~~
336 TopoDS_Shape aShape;
337 // Load or create a TopoDS_Shape in the variable a Shape
338 ...
339 IVtk_IShape::Handle shapeImpl = new IVtkOCC_Shape(aShape);
340 ...
341 myOccPickerAlgo->SetSelectionMode(occShape, SM_Edge);
342 ~~~~
343 Different selection modes can be turned on/off for a picker at the same time independently from each other.
344 To turn off a selection mode the additional optional Boolean parameter is used with *false* value, for example:
345 ~~~~
346 myOccPickerAlgo->SetSelectionMode(occShape, SM_Edge, false);
347 ~~~~
348 4. Call *Pick* method passing the mouse coordinates:
349 ~~~~
350 myOccPickerAlgo->Pick(x, y);
351 ~~~~
352 5. Obtain top-level picking results as IDs of the picked top-level shapes:
353 ~~~~
354 IVtk_ShapeIdList ids = myOccPickerAlgo->ShapesPicked();
355 ~~~~
356 6. Obtain IDs of the picked sub-shapes:
357 ~~~~
358 IVtk_ShapeIdList subShapeIds
359   = myOccPickerAlgo->SubShapesPicked(shapeId);
360 ~~~~  
361
362 @section occt_vis_5     DRAW Test Harness
363
364 *TKIVtkDraw* toolkit contains classes for embedding VIS functionality into DRAW Test Harness with possibility of simple interactions, including detection and highlighting.
365 * *IVtkDraw_HighlightAndSelectionPipeline* - Creates VTK pipeline with OCCT shape data source and properly initialized VIS filters.
366 * *IVtkDraw_Interactor* - Controls simple interactive actions, such as detection and selection of the displayed shapes.
367
368 @section occt_vis_6     Test Harness Commands
369 A specific plugin with alias *VIS* should be loaded to have access to VIS functionality in DRAW Test Harness:
370
371 ~~~~
372 \> pload VIS
373 ~~~~
374
375 Typical use cases are available in non-regression tests scripts
376 @subsection occt_vis_6_1        ivtkinit
377
378 Purpose: Creates a window for VTK viewer.
379
380 Syntax:         *ivtkinit*
381
382 @figure{/user_guides/vis/images/vis_image008.png}
383  
384 @subsection occt_vis_6_2        ivtkdisplay
385
386 Purpose: Displays named objects.
387
388 Syntax:         <i>ivtkdisplay name1 [name2] …[name n]</i>
389
390 Example
391
392 ~~~~
393 ivtkinit
394 # create cone
395 pcone c 5 0 10
396 ivtkdisplay c
397 ~~~~
398
399 @figure{/user_guides/vis/images/vis_image009.png}
400  
401 @subsection occt_vis_6_3        ivtkerase
402
403 Purpose: Erases named objects. If no arguments are passed, erases all displayed objects.
404
405 Syntax:         <i>ivtkerase [name1] [name2] … [name n] </i>
406
407 Example
408 ~~~~
409 ivtkinit
410 # create a sphere
411 psphere s 10
412 # create a cone
413 pcone c 5 0 10
414 # create a cylinder
415 pcylinder cy 5 10
416 # display objects
417 ivtkdisplay s c cy
418 # erase only the cylinder
419 ivtkerase cy
420 # erase the sphere and the cone
421 ivtkerase s c
422 ~~~~
423
424 @subsection occt_vis_6_4         ivtkfit
425
426 Purpose: Automatic zoom/panning.
427
428 Syntax:         *ivtkfit*
429
430 @subsection occt_vis_6_5        ivtkdispmode
431
432 Purpose: Sets display mode for a named object. If no arguments are passed, sets the given display mode for all displayed objects
433 The possible modes are: 0 (WireFrame) and 1 (Shading).
434
435 Syntax:         <i>ivtksetdispmode [name] mode(0,1)</i>
436
437 Example
438
439 ~~~~
440 ivtkinit
441 # create a cone
442 pcone c 5 0 10
443 # display the cone
444 ivtkdisplay c
445 # set shading mode for the cone
446 ivtksetdispmode c 1
447 ~~~~
448
449 @figure{/user_guides/vis/images/vis_image010.png}
450  
451 @subsection occt_vis_6_6        ivtksetselmode
452
453 Purpose: Sets selection mode for a named object. If no arguments are passed, sets the given selection mode for all the displayed objects
454
455 Syntax:         <i>ivtksetselmode [name] mode on/off(0/1)</i>
456
457 Example
458 ~~~~
459 ivtkinit
460 # load a shape from file
461 restore CrankArm.brep a
462 # display the loaded shape
463 ivtkdisplay a
464 # set the face selection mode
465 ivtksetselmode a 4 1
466 ~~~~
467
468 @figure{/user_guides/vis/images/vis_image011.png}
469  
470 @subsection occt_vis_6_7        ivtkmoveto
471
472 Purpose: Imitates mouse cursor moving to point with the given display coordinates.
473
474 Syntax:         <i>ivtkmoveto x y</i>
475
476 Example
477 ~~~~
478 ivtkinit
479 pcone c 5 0 10
480 ivtkdisplay c
481 ivtkmoveto 40 50
482 ~~~~
483
484 @subsection occt_vis_6_8        ivtkselect
485
486 Purpose: Imitates mouse cursor moving to point with the given display coordinates and performs selection at this point.
487
488 Syntax:         <i>ivtkselect x y</i>
489
490 Example
491 ~~~~
492 ivtkinit
493 pcone c 5 0 10
494 ivtkdisplay c
495 ivtkselect 40 50
496 ~~~~
497
498 @subsection occt_vis_6_9        ivtkdump
499
500 Purpose: Dumps the contents of VTK viewer to image. It supports:
501 * dumping in different raster graphics formats: PNG, BMP, JPEG, TIFF or PNM.
502 * dumping of different buffers: RGB, RGBA or depth buffer.
503 * defining of image sizes (width and height in pixels).
504 * dumping of stereo projections (left or right).
505
506 Syntax:  <i>    ivtkdump *filename* [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}] </i>
507
508 Example
509 ~~~~
510 ivtkinit
511 pcone c 5 0 10
512 ivtkdisplay c
513 ivtkdump D:/ConeSnapshot.png rgb 768 768
514 ~~~~
515
516 @subsection occt_vis_6_10       ivtkbgcolor
517
518 Purpose: Sets uniform background color or gradient background if second triple of parameters is set. Color parameters r,g,b have to be chosen in the interval  [0..255].
519
520 Syntax:         <i> ivtkbgcolor r g b [r2 g2 b2] </i>
521
522 Example
523 ~~~~
524 ivtkinit
525 ivtkbgcolor 200 220 250
526 ~~~~
527  
528 @figure{/user_guides/vis/images/vis_image012.png}
529
530 ~~~~
531 ivtkbgcolor 10 30 80 255 255 255
532 ~~~~
533
534 @figure{/user_guides/vis/images/vis_image013.png}
535
536 @section occt_vis_7     Non-regression tests
537 The test scenarios are available in <i> /test/v3d/ivtk </i> directory to test the functionality of VIS component. This directory contains test cases for all DRAW commands described above.
538
539
540