Version: 9.12.0
VTKViewer_Actor.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
24 // File : SALOME_Actor.h
25 // Author : Nicolas REJNERI
26 
27 #ifndef VTKVIEVER_ACTOR_H
28 #define VTKVIEVER_ACTOR_H
29 
30 #include "VTKViewer.h"
31 
32 #include <string>
33 #include <vector>
34 #include <limits>
35 
36 #include <NCollection_IndexedMap.hxx>
37 #include <NCollection_Map.hxx>
38 
39 #include <vtkLODActor.h>
40 #include <vtkProperty.h>
41 
42 class vtkCell;
43 class vtkPointPicker;
44 class vtkCellPicker;
45 class vtkDataSet;
46 class vtkCamera;
47 class vtkProperty;
48 class vtkRenderer;
49 class vtkPassThrough;
50 
54 
55 extern int VTKViewer_POINT_SIZE;
56 extern int VTKViewer_LINE_WIDTH;
57 
58 namespace VTKViewer
59 {
60  namespace Representation
61  {
62  typedef int Type;
63  const Type Points = VTK_POINTS;
64  const Type Wireframe = VTK_WIREFRAME;
65  const Type Surface = VTK_SURFACE;
66  const Type Insideframe = Surface + 1;
68  }
69 }
70 
71 #ifdef WIN32
72 #pragma warning ( disable:4251 )
73 #endif
74 
79 {
80  public:
81  static VTKViewer_Actor* New();
82 
84 
85  //----------------------------------------------------------------------------
87  virtual
88  const char*
89  getName();
90 
92  virtual
93  void
94  setName(const char* theName);
95 
96  //----------------------------------------------------------------------------
98  virtual
99  void
100  SetOpacity(double theOpacity);
101 
103  virtual
104  double
105  GetOpacity();
106 
108  virtual
109  void
110  SetColor(double r,
111  double g,
112  double b);
113 
115  virtual
116  void
117  GetColor(double& r,
118  double& g,
119  double& b);
120 
122  virtual
123  void
124  SetColor(const double theRGB[3]);
125 
127  virtual
128  void
129  SetMaterial(std::vector<vtkProperty*> theProps);
130 
132  virtual
133  vtkProperty*
134  GetFrontMaterial();
135 
137  virtual
138  vtkProperty*
139  GetBackMaterial();
140 
141  //----------------------------------------------------------------------------
142  // For selection mapping purpose
144  virtual
145  vtkIdType
146  GetNodeObjId(vtkIdType theVtkID);
147 
149  virtual
150  double*
151  GetNodeCoord(vtkIdType theObjID);
152 
154  virtual
155  vtkIdType
156  GetNodeVtkId(vtkIdType theObjID);
157 
159  virtual
160  vtkIdType
161  GetElemObjId(vtkIdType theVtkID);
162 
164  virtual
165  vtkCell*
166  GetElemCell(vtkIdType theObjID);
167 
168  //----------------------------------------------------------------------------
170  virtual
171  int
172  GetObjDimension( const vtkIdType theObjId );
173 
175  virtual
176  void
177  SetMapper(vtkMapper* theMapper);
178 
180  virtual
181  vtkDataSet*
182  GetInput();
183 
185  virtual
186  void
187  SetTransform(VTKViewer_Transform* theTransform);
188 
190  virtual
192  GetMTime();
193 
194  //----------------------------------------------------------------------------
196  virtual
197  void
198  SetRepresentation(int theMode);
199 
201  virtual
202  int
203  GetRepresentation();
204 
206  virtual
207  int
208  getDisplayMode();
209 
211  virtual
212  void
213  setDisplayMode(int theMode);
214 
215  //----------------------------------------------------------------------------
217 
221  void
222  SetInfinitive(bool theIsInfinite);
223 
225  virtual
226  bool
227  IsInfinitive();
228 
230  virtual
231  double*
232  GetBounds();
233 
235  void
236  GetBounds(double bounds[6]);
237 
238  //----------------------------------------------------------------------------
239  virtual
240  bool
241  IsSetCamera() const;
242 
243  virtual
244  bool
245  IsResizable() const;
246 
247  virtual
248  void
249  SetSize( const double );
250 
251  virtual
252  void
253  SetCamera( vtkCamera* );
254 
255  //----------------------------------------------------------------------------
257  void
258  SetResolveCoincidentTopology(bool theIsResolve);
259 
261  void
262  SetPolygonOffsetParameters(double factor,
263  double units);
264 
266  void
267  GetPolygonOffsetParameters(double& factor,
268  double& units);
269 
271  static
272  void
273  GetDefaultPolygonOffsetParameters(double& factor,
274  double& units);
275 
276  virtual
277  void
278  Render(vtkRenderer *, vtkMapper *);
279 
280  //----------------------------------------------------------------------------
282  virtual
283  double
284  GetShrinkFactor();
285 
287  virtual
288  bool
289  IsShrunkable();
290 
292  virtual
293  bool
294  IsShrunk();
295 
297  virtual
298  void
299  SetShrink();
300 
302  virtual
303  void
304  UnShrink();
305 
306  //----------------------------------------------------------------------------
308  virtual
309  void
310  AddToRender(vtkRenderer* theRendere);
311 
313  virtual
314  void
315  RemoveFromRender(vtkRenderer* theRendere);
316 
318  virtual
319  void
320  GetChildActors(vtkActorCollection*);
321 
322  //----------------------------------------------------------------------------
324  virtual
325  void
326  EnableSelection( bool /*enable*/ ) {}
327 
329  virtual
330  bool
331  hasHighlight();
332 
334  virtual
335  bool
336  isHighlighted();
337 
339  virtual
340  bool
341  isPreselected();
342 
344  virtual
345  void
346  SetPreSelected(bool thePreselect = false);
347 
348  //----------------------------------------------------------------------------
350  virtual
351  void
352  highlight(bool theHighlight);
353 
354  void
355  SetPreviewProperty(vtkProperty* theProperty);
356 
357  //----------------------------------------------------------------------------
359  virtual void SetQuadraticArcMode(bool theFlag);
360  virtual bool GetQuadraticArcMode() const;
361 
362  virtual void SetQuadraticArcAngle(double theMaxAngle);
363  virtual double GetQuadraticArcAngle() const;
364 
365  //----------------------------------------------------------------------------
367  virtual vtkDataSet* GetHighlightedDataSet();
368 
369  protected:
370  //----------------------------------------------------------------------------
374 
375  std::string myName;
376 
377  double myOpacity;
380 
384  std::vector<vtkPassThrough*> myPassFilter;
385 
387  vtkProperty *myProperty;
388 
389  void
390  InitPipeLine(vtkMapper* theMapper);
391 
393  ~VTKViewer_Actor();
394 
395  protected:
396  vtkProperty *PreviewProperty;
399 };
400 
402 {
403  static int HashCode(const vtkIdType theValue, const int theUpperBound)
404  {
405  return static_cast<int> ((theValue & (std::numeric_limits<vtkIdType>::max)()) % theUpperBound + 1);
406  }
407 
408  static bool IsEqual( const vtkIdType& id1, const vtkIdType& id2 )
409  {
410  return id1 == id2;
411  }
412 };
413 
414 typedef NCollection_Map< vtkIdType, vtkIdHasher > TVtkIDsMap;
415 typedef NCollection_IndexedMap<vtkIdType,vtkIdHasher> TIndexedMapOfVtkId;
416 
417 #ifdef WIN32
418 #pragma warning ( default:4251 )
419 #endif
420 
421 #endif // VTKVIEVER_ACTOR_H
unsigned long int vtkMTimeType
Definition: VTKViewer.h:42
#define VTKVIEWER_EXPORT
Definition: VTKViewer.h:33
int VTKViewer_LINE_WIDTH
Definition: VTKViewer_Actor.cxx:54
int VTKViewer_POINT_SIZE
Definition: VTKViewer_Actor.cxx:53
NCollection_Map< vtkIdType, vtkIdHasher > TVtkIDsMap
Definition: VTKViewer_Actor.h:414
NCollection_IndexedMap< vtkIdType, vtkIdHasher > TIndexedMapOfVtkId
Definition: VTKViewer_Actor.h:415
Definition: VTKViewer_Actor.h:79
virtual void EnableSelection(bool)
Is notified on enabling/disabling selection.
Definition: VTKViewer_Actor.h:326
int myRepresentation
Definition: VTKViewer_Actor.h:386
double myOpacity
Definition: VTKViewer_Actor.h:377
vtkProperty * PreviewProperty
Definition: VTKViewer_Actor.h:396
std::vector< vtkPassThrough * > myPassFilter
Definition: VTKViewer_Actor.h:384
double myPolygonOffsetUnits
Definition: VTKViewer_Actor.h:373
double myPolygonOffsetFactor
Definition: VTKViewer_Actor.h:372
std::string myName
Definition: VTKViewer_Actor.h:375
bool myIsHighlighted
Definition: VTKViewer_Actor.h:398
bool myIsPreselected
Definition: VTKViewer_Actor.h:397
VTKViewer_TransformFilter * myTransformFilter
Definition: VTKViewer_Actor.h:383
int myDisplayMode
Definition: VTKViewer_Actor.h:378
VTKViewer_GeometryFilter * myGeomFilter
Definition: VTKViewer_Actor.h:382
bool myStoreMapping
Definition: VTKViewer_Actor.h:381
bool myIsResolveCoincidentTopology
Definition: VTKViewer_Actor.h:371
static VTKViewer_Actor * New()
vtkProperty * myProperty
Definition: VTKViewer_Actor.h:387
bool myIsInfinite
Definition: VTKViewer_Actor.h:379
vtkTypeMacro(VTKViewer_Actor, vtkLODActor) virtual const char *getName()
Get its name.
void SetPreviewProperty(vtkProperty *theProperty)
This class used same as vtkGeometryFilter. See documentation on VTK for more information.
Definition: VTKViewer_GeometryFilter.h:42
Definition: VTKViewer_TransformFilter.h:34
Describes linear transformations via a 4x4 matrix.
Definition: VTKViewer_Transform.h:34
For more information see VTK documentation
int Type
Definition: VTKViewer_Actor.h:62
const Type Wireframe
Definition: VTKViewer_Actor.h:64
const Type Insideframe
Definition: VTKViewer_Actor.h:66
const Type SurfaceWithEdges
Definition: VTKViewer_Actor.h:67
const Type Points
Definition: VTKViewer_Actor.h:63
const Type Surface
Definition: VTKViewer_Actor.h:65
Definition: VTKViewer_Actor.h:59
Definition: VTKViewer_Actor.h:402
static int HashCode(const vtkIdType theValue, const int theUpperBound)
Definition: VTKViewer_Actor.h:403
static bool IsEqual(const vtkIdType &id1, const vtkIdType &id2)
Definition: VTKViewer_Actor.h:408