Salome HOME
Merge from V6_main 11/02/2013
[modules/geom.git] / src / OBJECT / GEOM_DeviceActor.cxx
1 // Copyright (C) 2007-2012  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.
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->SetInput(myPolyDataNormals->GetOutput()); 
42   myPolyDataMapper->SetInput(myStripper->GetOutput()); 
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(vtkPolyData* thePolyData, bool theUseStripper)
55
56   if(theUseStripper)
57     myPolyDataNormals->SetInput(thePolyData); 
58   else 
59     myPolyDataMapper->SetInput(thePolyData); 
60 }
61  
62 void 
63 GEOM_DeviceActor:: 
64 SetProperty(vtkProperty* theProperty)
65 {
66   myActor->SetProperty(theProperty);
67 }
68  
69 vtkProperty* 
70 GEOM_DeviceActor:: 
71 GetProperty()
72 {
73   return myActor->GetProperty();
74 }
75
76 void \r
77 GEOM_DeviceActor:: \r
78 SetBackfaceProperty(vtkProperty* theProperty)\r
79 {\r
80   myActor->SetBackfaceProperty(theProperty);\r
81 }\r
82  \r
83 vtkProperty* \r
84 GEOM_DeviceActor:: \r
85 GetBackfaceProperty()\r
86 {\r
87   return myActor->GetBackfaceProperty();\r
88 }\r
89  
90 void 
91 GEOM_DeviceActor:: 
92 SetVisibility(int theVisibility)
93 {
94   myActor->SetVisibility(theVisibility);
95 }
96  
97 int 
98 GEOM_DeviceActor:: 
99 GetVisibility()
100 {
101   return myActor->GetVisibility();
102 }
103  
104 void 
105 GEOM_DeviceActor:: 
106 AddToRender(vtkRenderer* theRenderer)
107 {
108   theRenderer->AddActor(myActor.GetPointer());
109 }
110
111 void 
112 GEOM_DeviceActor:: 
113 RemoveFromRender(vtkRenderer* theRenderer)
114 {
115   theRenderer->RemoveActor(myActor.GetPointer());
116 }