Salome HOME
c46519875f9e6912ecec221e90d11c3f8cf83b21
[modules/geom.git] / src / OBJECT / GEOM_DeviceActor.cxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "GEOM_DeviceActor.h" 
21
22 #include <vtkObjectFactory.h> 
23  
24 #include <vtkPoints.h> 
25 #include <vtkPolyData.h> 
26 #include <vtkStripper.h>  
27 #include <vtkPolyDataMapper.h>  
28 #include <vtkPolyDataNormals.h>  
29 #include <vtkActor.h>
30 #include <vtkRenderer.h> 
31
32 #include <VTKViewer_Actor.h>
33 #include <VTKViewer_Transform.h>
34 #include <VTKViewer_TransformFilter.h>
35
36  
37 vtkStandardNewMacro(GEOM_DeviceActor)
38  
39 GEOM_DeviceActor::GEOM_DeviceActor() :
40   myPolyDataNormals(vtkPolyDataNormals::New(), true),
41   myPolyDataMapper(vtkPolyDataMapper::New(), true),
42   myStripper(vtkStripper::New(), true),
43   myActor(VTKViewer_Actor::New(), true),
44   myTransformFilter(VTKViewer_TransformFilter::New())
45
46   myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort());
47   myTransformFilter->SetInputConnection(myStripper->GetOutputPort());
48   myPolyDataMapper->SetInputConnection(myTransformFilter->GetOutputPort());
49  
50   myActor->SetMapper(myPolyDataMapper.Get()); 
51   myActor->PickableOff(); 
52
53  
54 GEOM_DeviceActor::~GEOM_DeviceActor() 
55
56
57  
58 void 
59 GEOM_DeviceActor:: 
60 SetInput(vtkAlgorithmOutput* thePolyData, bool theUseStripper)
61
62   if(theUseStripper)
63   {
64     myPolyDataNormals->SetInputConnection(thePolyData); 
65     myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort());
66     myTransformFilter->SetInputConnection(myStripper->GetOutputPort());
67     myPolyDataMapper->SetInputConnection(myTransformFilter->GetOutputPort());
68   }
69   else {
70     myTransformFilter->SetInputConnection(thePolyData);
71     myPolyDataMapper->SetInputConnection(myTransformFilter->GetOutputPort());
72   }
73 }
74  
75 void 
76 GEOM_DeviceActor:: 
77 SetProperty(vtkProperty* theProperty)
78 {
79   myActor->SetProperty(theProperty);
80 }
81  
82 vtkProperty* 
83 GEOM_DeviceActor:: 
84 GetProperty()
85 {
86   return myActor->GetProperty();
87 }
88  
89 void
90 GEOM_DeviceActor::
91 SetBackfaceProperty(vtkProperty* theProperty)
92 {
93   myActor->SetBackfaceProperty(theProperty);
94 }
95  
96 vtkProperty*
97 GEOM_DeviceActor::
98 GetBackfaceProperty()
99 {
100   return myActor->GetBackfaceProperty();
101 }
102  
103 void 
104 GEOM_DeviceActor:: 
105 SetVisibility(int theVisibility)
106 {
107   myActor->SetVisibility(theVisibility);
108 }
109  
110 int 
111 GEOM_DeviceActor:: 
112 GetVisibility()
113 {
114   return myActor->GetVisibility();
115 }
116  
117 void 
118 GEOM_DeviceActor:: 
119 AddToRender(vtkRenderer* theRenderer)
120 {
121   theRenderer->AddActor(myActor.GetPointer());
122 }
123
124 void 
125 GEOM_DeviceActor:: 
126 RemoveFromRender(vtkRenderer* theRenderer)
127 {
128   theRenderer->RemoveActor(myActor.GetPointer());
129 }
130
131 void
132 GEOM_DeviceActor
133 ::SetTransform(VTKViewer_Transform* theTransform)
134 {
135   myTransformFilter->SetTransform(theTransform);
136 }