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