]> SALOME platform Git repositories - modules/visu.git/blob - src/PIPELINE/VISU_MapperHolder.cxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / PIPELINE / VISU_MapperHolder.cxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  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 //
24 // File:    VISU_MapperHolder.cxx
25 // Author:  Alexey PETROV
26 // Module : VISU
27
28
29 #include "VISU_MapperHolder.hxx"
30 #include "VISU_PipeLine.hxx"
31
32 #include "VISU_PipeLineUtils.hxx"
33
34 #include <vtkDataSet.h>
35
36 #ifdef _DEBUG_
37 static int MYDEBUG = 0;
38 #else
39 static int MYDEBUG = 0;
40 #endif
41
42
43 //----------------------------------------------------------------------------
44 VISU_MapperHolder
45 ::VISU_MapperHolder():
46   myPipeLine(NULL)
47 {
48   if(MYDEBUG) 
49     MESSAGE("VISU_MapperHolder::VISU_MapperHolder - "<<this);
50 }
51
52
53 //----------------------------------------------------------------------------
54 VISU_MapperHolder
55 ::~VISU_MapperHolder()
56 {
57   if(MYDEBUG)
58     MESSAGE("VISU_MapperHolder::~VISU_MapperHolder - "<<this);
59 }
60
61
62 //----------------------------------------------------------------------------
63 void 
64 VISU_MapperHolder
65 ::ShallowCopy(VISU_MapperHolder *theMapperHolder,
66               bool theIsCopyInput)
67 {
68   if(theIsCopyInput)
69     SetIDMapper(theMapperHolder->GetIDMapper());
70
71   VISU::CopyMapper(GetMapper(), 
72                    theMapperHolder->GetMapper(), 
73                    theIsCopyInput);
74 }
75
76
77 //----------------------------------------------------------------------------
78 unsigned long int
79 VISU_MapperHolder
80 ::GetMemorySize()
81 {
82   unsigned long int aSize = 0;
83
84   if(myMapper.GetPointer())
85     if(vtkDataSet* aDataSet = myMapper->GetInput())
86       aSize = aDataSet->GetActualMemorySize() * 1024;
87   
88   if(myIDMapper)
89     aSize += myIDMapper->GetMemorySize();
90   
91   return aSize;
92 }
93
94
95 //----------------------------------------------------------------------------
96 unsigned long int 
97 VISU_MapperHolder
98 ::GetMTime()
99 {
100   unsigned long int aTime = Superclass::GetMTime();
101
102   if(myIDMapper)
103     if(vtkDataSet* aDataSet = myIDMapper->GetOutput())
104       aTime = std::max(aTime, aDataSet->GetMTime());
105
106   if(myMapper.GetPointer())
107     aTime = std::max(aTime, myMapper->GetMTime());
108
109   return aTime;
110 }
111
112
113 //----------------------------------------------------------------------------
114 void
115 VISU_MapperHolder
116 ::SetPipeLine(VISU_PipeLine* thePipeLine)
117 {
118   myPipeLine = thePipeLine;
119 }
120
121
122 //----------------------------------------------------------------------------
123 void
124 VISU_MapperHolder
125 ::SetIDMapper(const VISU::PIDMapper& theIDMapper)
126 {
127   if(myIDMapper == theIDMapper)
128     return;
129
130   myIDMapper = theIDMapper;
131
132   if(myPipeLine && GetInput())
133     if(!GetMapper()->GetInput()){
134       myPipeLine->Build();
135       myPipeLine->Init();
136       myPipeLine->Update();
137     }
138
139   Modified();
140 }
141
142
143 //----------------------------------------------------------------------------
144 const VISU::PIDMapper&  
145 VISU_MapperHolder
146 ::GetIDMapper()
147 {
148   return myIDMapper;
149 }
150
151
152 //----------------------------------------------------------------------------
153 vtkDataSet* 
154 VISU_MapperHolder
155 ::GetInput()
156 {
157   if(myIDMapper)
158     return myIDMapper->GetOutput();
159
160   return NULL;
161 }
162
163
164 //----------------------------------------------------------------------------
165 vtkMapper* 
166 VISU_MapperHolder
167 ::GetMapper()
168 {
169   if(!myMapper.GetPointer())
170     OnCreateMapper();
171
172   return myMapper.GetPointer();
173 }
174
175
176 //----------------------------------------------------------------------------
177 vtkDataSet* 
178 VISU_MapperHolder
179 ::GetOutput()
180 {
181   if(myMapper.GetPointer())
182     return myMapper->GetInput();
183
184   return NULL;
185 }
186
187
188 //----------------------------------------------------------------------------
189 void 
190 VISU_MapperHolder
191 ::Update()
192 {
193   if(myMapper.GetPointer())
194     return myMapper->Update();
195 }
196
197
198 //----------------------------------------------------------------------------
199 void
200 VISU_MapperHolder
201 ::SetMapper(vtkMapper* theMapper)
202 {
203   myMapper = theMapper;
204 }
205
206
207 //----------------------------------------------------------------------------
208 vtkIdType 
209 VISU_MapperHolder
210 ::GetNodeObjID(vtkIdType theID)
211 {
212   return myIDMapper->GetNodeObjID(theID);
213 }
214
215 //----------------------------------------------------------------------------
216 vtkIdType 
217 VISU_MapperHolder
218 ::GetNodeVTKID(vtkIdType theID)
219 {
220   return myIDMapper->GetNodeVTKID(theID);
221 }
222
223 //----------------------------------------------------------------------------
224 vtkFloatingPointType* 
225 VISU_MapperHolder
226 ::GetNodeCoord(vtkIdType theObjID)
227 {
228   return myIDMapper->GetNodeCoord(theObjID);
229 }
230
231
232 //----------------------------------------------------------------------------
233 vtkIdType 
234 VISU_MapperHolder
235 ::GetElemObjID(vtkIdType theID)
236 {
237   return myIDMapper->GetElemObjID(theID);
238 }
239
240 //----------------------------------------------------------------------------
241 vtkIdType
242 VISU_MapperHolder
243 ::GetElemVTKID(vtkIdType theID)
244 {
245   return myIDMapper->GetElemVTKID(theID);
246 }
247
248 //----------------------------------------------------------------------------
249 vtkCell* 
250 VISU_MapperHolder
251 ::GetElemCell(vtkIdType  theObjID)
252 {
253   return myIDMapper->GetElemCell(theObjID);
254 }
255
256
257 //----------------------------------------------------------------------------