Salome HOME
171b919efcc0b47e82b6c5cad12143a731792a15
[modules/visu.git] / src / OBJECT / VISU_VectorsAct.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, 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.
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 //  VISU OBJECT : interactive object for VISU entities implementation
24 //  File   : VISU_VectorsAct.cxx
25 //  Author : Laurent CORNABE with help of Nicolas REJNERI
26 //  Module : VISU
27 //
28 #include "VISU_VectorsAct.h"
29 #include "VISU_VectorsPL.hxx"
30 #include <SVTK_Actor.h>
31  
32 // VTK Includes
33 #include <vtkObjectFactory.h>
34 #include <vtkDataSetMapper.h>
35 #include <vtkPolyDataMapper.h>
36 #include <vtkPolyData.h>
37 #include <vtkPassThroughFilter.h>
38 #include <VISU_UsedPointsFilter.hxx>
39 #include <vtkUnstructuredGrid.h>
40 #include <VISU_MergeFilter.hxx>
41
42 //----------------------------------------------------------------------------
43 vtkStandardNewMacro(VISU_VectorsAct);
44
45
46 //----------------------------------------------------------------------------
47 VISU_VectorsAct
48 ::VISU_VectorsAct():
49   myVectorsPL(NULL)
50 {}
51
52
53 //----------------------------------------------------------------------------
54 VISU_VectorsAct
55 ::~VISU_VectorsAct()
56 {}
57
58
59 //----------------------------------------------------------------------------
60 void 
61 VISU_VectorsAct
62 ::SetPipeLine(VISU_PipeLine* thePipeLine) 
63 {
64   myVectorsPL = dynamic_cast<VISU_VectorsPL*>( thePipeLine );
65
66   Superclass::SetPipeLine( myVectorsPL.GetPointer() );
67 }
68
69
70 //----------------------------------------------------------------------------
71 vtkDataSet* 
72 VISU_VectorsAct
73 ::GetInput()
74 {
75   return GetCurrentPL()->GetOutput();
76 }
77
78
79 //----------------------------------------------------------------------------
80 void
81 VISU_VectorsAct
82 ::SetTransform(VTKViewer_Transform* theTransform)
83 {
84   // To perform only vector's specific action,
85   // there is nothing to be done for the Superclass
86   myVectorsPL->SetTransform( theTransform );
87 }
88
89
90 //----------------------------------------------------------------------------
91 void
92 VISU_VectorsAct
93 ::SetMapper(vtkMapper* theMapper)
94 {
95   if(theMapper){
96     myPassFilter[0]->SetInput(theMapper->GetInput());
97     
98     myPassFilter[1]->SetInput(myPassFilter[0]->GetPolyDataOutput());
99
100     myPassFilter[2]->SetInput(myPassFilter[1]->GetPolyDataOutput());
101
102     myPassFilter[3]->SetInput(myPassFilter[2]->GetPolyDataOutput());
103
104     if(vtkDataSetMapper* aMapper = dynamic_cast<vtkDataSetMapper*>(theMapper))
105       aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput());
106     else if(vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>(theMapper))
107       aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput());
108   }
109
110   vtkLODActor::SetMapper(theMapper);
111 }
112
113
114 //----------------------------------------------------------------------------
115 unsigned long int
116 VISU_VectorsAct
117 ::GetMemorySize()
118 {
119   unsigned long int aSize = Superclass::GetMemorySize();
120
121   aSize += GetPipeLine()->GetMemorySize();
122
123   return aSize;
124 }
125
126 //----------------------------------------------------------------------------
127 vtkDataSet*
128 VISU_VectorsAct
129 ::GetValLabelsInput()
130 {
131   VISU_VectorsPL* aPL = dynamic_cast<VISU_VectorsPL*>( GetPipeLine() );
132   if ( aPL )
133   {
134     return aPL->GetMergedInput();
135     /*VISU_UsedPointsFilter* aFilter = aPL->GetUsedPointsFilter();
136     vtkSmartPointer< VISU_MergeFilter > aFilter = aPL->myMergeFilter;
137     if ( aFilter )
138     {
139       aFilter->Update();
140       return aFilter->GetOutput();
141     }*/
142   }
143
144   return Superclass::GetValLabelsInput();
145 }
146
147 //--------------------------------------------------------------------------------------
148 vtkDataSet* VISU_VectorsAct::GetHighlightedDataSet() {
149   return myPassFilter[3]->GetOutput();
150 }