Salome HOME
Update copyrights
[modules/geom.git] / src / OBJECT / GEOM_DeviceActor.cxx
1 // Copyright (C) 2007-2019  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 <VTKViewer_Actor.h>
31 #include <vtkRenderer.h> 
32  
33 vtkStandardNewMacro(GEOM_DeviceActor);
34  
35 GEOM_DeviceActor::GEOM_DeviceActor(): 
36   myStripper(vtkStripper::New(),true), 
37   myPolyDataMapper(vtkPolyDataMapper::New(),true), 
38   myPolyDataNormals(vtkPolyDataNormals::New(),true), 
39   myActor(VTKViewer_Actor::New(),true) 
40
41   myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort()); 
42   myPolyDataMapper->SetInputConnection(myStripper->GetOutputPort()); 
43  
44   myActor->SetMapper(myPolyDataMapper.Get()); 
45   myActor->PickableOff(); 
46
47  
48 GEOM_DeviceActor::~GEOM_DeviceActor() 
49
50
51  
52 void 
53 GEOM_DeviceActor:: 
54 SetInput(vtkAlgorithmOutput* thePolyData, bool theUseStripper)
55
56   if(theUseStripper)
57   {
58     myPolyDataNormals->SetInputConnection(thePolyData); 
59     myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort()); 
60     myPolyDataMapper->SetInputConnection(myStripper->GetOutputPort()); 
61   }
62   else 
63     myPolyDataMapper->SetInputConnection(thePolyData); 
64 }
65  
66 void 
67 GEOM_DeviceActor:: 
68 SetProperty(vtkProperty* theProperty)
69 {
70   myActor->SetProperty(theProperty);
71 }
72  
73 vtkProperty* 
74 GEOM_DeviceActor:: 
75 GetProperty()
76 {
77   return myActor->GetProperty();
78 }
79  
80 void
81 GEOM_DeviceActor::
82 SetBackfaceProperty(vtkProperty* theProperty)
83 {
84   myActor->SetBackfaceProperty(theProperty);
85 }
86  
87 vtkProperty*
88 GEOM_DeviceActor::
89 GetBackfaceProperty()
90 {
91   return myActor->GetBackfaceProperty();
92 }
93  
94 void 
95 GEOM_DeviceActor:: 
96 SetVisibility(int theVisibility)
97 {
98   myActor->SetVisibility(theVisibility);
99 }
100  
101 int 
102 GEOM_DeviceActor:: 
103 GetVisibility()
104 {
105   return myActor->GetVisibility();
106 }
107  
108 void 
109 GEOM_DeviceActor:: 
110 AddToRender(vtkRenderer* theRenderer)
111 {
112   theRenderer->AddActor(myActor.GetPointer());
113 }
114
115 void 
116 GEOM_DeviceActor:: 
117 RemoveFromRender(vtkRenderer* theRenderer)
118 {
119   theRenderer->RemoveActor(myActor.GetPointer());
120 }