Back to index

salome-geom  6.5.0
GEOM_DeviceActor.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "GEOM_DeviceActor.h" 
00021 
00022 #include <vtkObjectFactory.h> 
00023  
00024 #include <vtkPoints.h> 
00025 #include <vtkPolyData.h> 
00026 #include <vtkStripper.h>  
00027 #include <vtkPolyDataMapper.h>  
00028 #include <vtkPolyDataNormals.h>  
00029 #include <vtkActor.h> 
00030 #include <VTKViewer_Actor.h>
00031 #include <vtkRenderer.h> 
00032  
00033 vtkStandardNewMacro(GEOM_DeviceActor);
00034  
00035 GEOM_DeviceActor::GEOM_DeviceActor(): 
00036   myStripper(vtkStripper::New(),true), 
00037   myPolyDataMapper(vtkPolyDataMapper::New(),true), 
00038   myPolyDataNormals(vtkPolyDataNormals::New(),true), 
00039   myActor(VTKViewer_Actor::New(),true) 
00040 { 
00041   myStripper->SetInput(myPolyDataNormals->GetOutput()); 
00042   myPolyDataMapper->SetInput(myStripper->GetOutput()); 
00043  
00044   myActor->SetMapper(myPolyDataMapper.Get()); 
00045   myActor->PickableOff(); 
00046 } 
00047  
00048 GEOM_DeviceActor::~GEOM_DeviceActor() 
00049 { 
00050 } 
00051  
00052 void 
00053 GEOM_DeviceActor:: 
00054 SetInput(vtkPolyData* thePolyData, bool theUseStripper)
00055 { 
00056   if(theUseStripper)
00057     myPolyDataNormals->SetInput(thePolyData); 
00058   else 
00059     myPolyDataMapper->SetInput(thePolyData); 
00060 }
00061  
00062 void 
00063 GEOM_DeviceActor:: 
00064 SetProperty(vtkProperty* theProperty)
00065 {
00066   myActor->SetProperty(theProperty);
00067 }
00068  
00069 vtkProperty* 
00070 GEOM_DeviceActor:: 
00071 GetProperty()
00072 {
00073   return myActor->GetProperty();
00074 }
00075 
00076 void 
00077 GEOM_DeviceActor:: 
00078 SetVisibility(int theVisibility)
00079 {
00080   myActor->SetVisibility(theVisibility);
00081 }
00082  
00083 int 
00084 GEOM_DeviceActor:: 
00085 GetVisibility()
00086 {
00087   return myActor->GetVisibility();
00088 }
00089  
00090 void 
00091 GEOM_DeviceActor:: 
00092 AddToRender(vtkRenderer* theRenderer)
00093 {
00094   theRenderer->AddActor(myActor.GetPointer());
00095 }
00096 
00097 void 
00098 GEOM_DeviceActor:: 
00099 RemoveFromRender(vtkRenderer* theRenderer)
00100 {
00101   theRenderer->RemoveActor(myActor.GetPointer());
00102 }