1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File: VISU_PolyDataPL.cxx
25 // Author: Alexey PETROV
29 #include "VISU_PolyDataPL.hxx"
30 #include "SALOME_ExtractPolyDataGeometry.h"
32 #include "VISU_PipeLineUtils.hxx"
37 #include <vtkPolyDataMapper.h>
38 #include <vtkPolyData.h>
41 #include <vtkImplicitBoolean.h>
42 #include <vtkImplicitFunction.h>
43 #include <vtkImplicitFunctionCollection.h>
47 static int MYDEBUG = 0;
49 static int MYDEBUG = 0;
52 //----------------------------------------------------------------------------
55 myExtractPolyDataGeometry(SALOME_ExtractPolyDataGeometry::New())
57 if(MYDEBUG) MESSAGE("VISU_PolyDataPL::VISU_PolyDataPL - "<<this);
59 // Clipping functionality
60 myExtractPolyDataGeometry->Delete();
61 myExtractPolyDataGeometry->SetStoreMapping(true);
63 vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
64 myExtractPolyDataGeometry->SetImplicitFunction(anImplicitBoolean);
65 anImplicitBoolean->SetOperationTypeToIntersection();
66 anImplicitBoolean->Delete();
70 //----------------------------------------------------------------------------
75 MESSAGE("VISU_PolyDataPL::~VISU_PolyDataPL - "<<this);
79 //----------------------------------------------------------------------------
82 ::SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper)
84 myExtractPolyDataGeometry->SetInput(theIDMapper->GetPolyDataOutput());
85 myPolyDataIDMapper = theIDMapper;
86 SetIDMapper(theIDMapper);
90 //----------------------------------------------------------------------------
91 const VISU::PPolyDataIDMapper&
93 ::GetPolyDataIDMapper() const
95 return myPolyDataIDMapper;
99 //----------------------------------------------------------------------------
104 if(myPolyDataIDMapper)
105 return myPolyDataIDMapper->GetPolyDataOutput();
111 //----------------------------------------------------------------------------
114 ::GetClippedInput() const
116 vtkPolyData* aDataSet = myExtractPolyDataGeometry->GetOutput();
122 //----------------------------------------------------------------------------
127 myPolyDataMapper = vtkPolyDataMapper::New();
128 myPolyDataMapper->Delete();
129 SetMapper(myPolyDataMapper.GetPointer());
133 //----------------------------------------------------------------------------
136 ::SetPolyDataMapper(vtkPolyDataMapper* theMapper)
138 myPolyDataMapper = theMapper;
139 SetMapper(theMapper);
143 //----------------------------------------------------------------------------
146 ::GetPolyDataMapper()
148 return myPolyDataMapper.GetPointer();
152 //----------------------------------------------------------------------------
155 ::DoCopyMapper(VISU_PipeLine *thePipeLine,
158 if(VISU_PolyDataPL* aPipeLine = dynamic_cast<VISU_PolyDataPL*>(thePipeLine)){
160 SetPolyDataIDMapper(aPipeLine->GetPolyDataIDMapper());
162 VISU::CopyPolyDataMapper(GetPolyDataMapper(),
163 aPipeLine->GetPolyDataMapper(),
169 //----------------------------------------------------------------------------
172 ::SetLookupTable(VISU_LookupTable* theLookupTable)
174 myPolyDataMapper->SetLookupTable(theLookupTable);
178 //----------------------------------------------------------------------------
183 unsigned long int aSize = 0;
184 if(myExtractPolyDataGeometry->GetInput())
185 if(vtkDataSet* aDataSet = myExtractPolyDataGeometry->GetOutput())
186 aSize = aDataSet->GetActualMemorySize() * 1024;
188 aSize += Superclass::GetMemorySize();
194 //------------------------ Clipping planes -----------------------------------
197 ::AddClippingPlane(vtkPlane* thePlane)
200 if (vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()) {
201 vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
202 aFunction->AddItem(thePlane);
203 // Check, that at least one cell present after clipping.
204 // This check was introduced because of bug IPAL8849.
205 vtkDataSet* aClippedDataSet = GetClippedInput();
206 if(aClippedDataSet->GetNumberOfCells() < 1)
213 //----------------------------------------------------------------------------
216 ::GetClippingPlane(vtkIdType theID) const
218 vtkPlane* aPlane = NULL;
219 if(theID >= 0 && theID < GetNumberOfClippingPlanes()){
220 if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){
221 vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
222 vtkImplicitFunction* aFun = NULL;
223 aFunction->InitTraversal();
224 for(vtkIdType anID = 0; anID <= theID; anID++)
225 aFun = aFunction->GetNextItem();
226 aPlane = dynamic_cast<vtkPlane*>(aFun);
232 //----------------------------------------------------------------------------
235 ::RemoveAllClippingPlanes()
237 if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){
238 vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
239 aFunction->RemoveAllItems();
240 aBoolean->Modified(); // VTK bug
244 //----------------------------------------------------------------------------
247 ::GetNumberOfClippingPlanes() const
249 if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){
250 vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
251 return aFunction->GetNumberOfItems();
256 //----------------------------------------------------------------------------
259 ::GetNodeObjID(vtkIdType theID)
261 vtkIdType anID = myExtractPolyDataGeometry->GetNodeObjId(theID);
262 return Superclass::GetNodeObjID(anID);
267 ::GetNodeVTKID(vtkIdType theID)
269 vtkIdType anID = Superclass::GetNodeVTKID(theID);
270 return myExtractPolyDataGeometry->GetNodeVTKId(anID);
273 vtkFloatingPointType*
275 ::GetNodeCoord(int theObjID)
277 return Superclass::GetNodeCoord(theObjID);
281 //----------------------------------------------------------------------------
284 ::GetElemObjID(vtkIdType theID)
286 vtkIdType anID = myExtractPolyDataGeometry->GetElemObjId(theID);
287 return Superclass::GetElemObjID(anID);
292 ::GetElemVTKID(vtkIdType theID)
294 vtkIdType anID = Superclass::GetElemVTKID(theID);
295 return myExtractPolyDataGeometry->GetElemVTKId(anID);
300 ::GetElemCell(vtkIdType theObjID)
302 return Superclass::GetElemCell(theObjID);
306 //----------------------------------------------------------------------------
309 ::SetImplicitFunction(vtkImplicitFunction *theFunction)
311 myExtractPolyDataGeometry->SetImplicitFunction(theFunction);
314 vtkImplicitFunction *
316 ::GetImplicitFunction()
318 return myExtractPolyDataGeometry->GetImplicitFunction();
321 SALOME_ExtractPolyDataGeometry*
323 ::GetExtractPolyDataGeometryFilter()
325 return myExtractPolyDataGeometry.GetPointer();
329 //----------------------------------------------------------------------------