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_PipeLine.cxx
25 // Author: Alexey PETROV
29 #include "VISU_IsoSurfacesPL.hxx"
30 #include "VISU_LookupTable.hxx"
32 #include "VISU_PipeLineUtils.hxx"
34 #include <vtkContourFilter.h>
37 //----------------------------------------------------------------------------
38 vtkStandardNewMacro(VISU_IsoSurfacesPL);
41 //----------------------------------------------------------------------------
43 ::VISU_IsoSurfacesPL()
45 SetIsShrinkable(false);
47 myContourFilter = vtkContourFilter::New();
49 myCellDataToPointData = vtkCellDataToPointData::New();
53 //----------------------------------------------------------------------------
55 ::~VISU_IsoSurfacesPL()
57 myContourFilter->Delete();
58 myContourFilter = NULL;
60 myCellDataToPointData->Delete();
61 myCellDataToPointData = NULL;
65 //----------------------------------------------------------------------------
70 unsigned long int aTime = Superclass::GetMTime();
72 aTime = std::max(aTime, myCellDataToPointData->GetMTime());
73 aTime = std::max(aTime, myContourFilter->GetMTime());
79 //----------------------------------------------------------------------------
82 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
85 Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
87 if(VISU_IsoSurfacesPL *aPipeLine = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine)){
88 SetNbParts(aPipeLine->GetNbParts());
89 vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
95 //----------------------------------------------------------------------------
100 return myContourFilter->GetNumberOfContours();
104 //----------------------------------------------------------------------------
107 ::SetNbParts(int theNb)
109 myContourFilter->SetNumberOfContours(theNb);
113 //----------------------------------------------------------------------------
116 ::SetScalarRange(vtkFloatingPointType theRange[2])
118 Superclass::SetScalarRange(theRange);
123 //----------------------------------------------------------------------------
126 ::SetRange(vtkFloatingPointType theRange[2])
128 if(VISU::CheckIsSameRange(myRange, theRange))
131 if(theRange[0] <= theRange[1]){
132 myRange[0] = theRange[0];
133 myRange[1] = theRange[1];
134 vtkFloatingPointType aRange[2] = {theRange[0], theRange[1]};
135 if(GetScaling() == VTK_SCALE_LOG10)
136 VISU_LookupTable::ComputeLogRange(theRange, aRange);
137 myContourFilter->GenerateValues(GetNbParts(), aRange);
142 //----------------------------------------------------------------------------
151 //----------------------------------------------------------------------------
161 //----------------------------------------------------------------------------
169 vtkFloatingPointType aScalarRange[2];
170 GetSourceRange(aScalarRange);
171 SetRange(aScalarRange);
174 //----------------------------------------------------------------------------
181 VISU::CellDataToPoint(myContourFilter,
182 myCellDataToPointData,
187 //----------------------------------------------------------------------------
193 return myContourFilter->GetOutput();
197 //----------------------------------------------------------------------------
202 unsigned long int aSize = Superclass::GetMemorySize();
204 if(vtkDataSet* aDataSet = myContourFilter->GetOutput())
205 aSize += aDataSet->GetActualMemorySize() * 1024;
207 if(myCellDataToPointData->GetInput())
208 if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
209 aSize += aDataSet->GetActualMemorySize() * 1024;
215 //----------------------------------------------------------------------------
218 ::SetMapScale(vtkFloatingPointType theMapScale)
220 Superclass::SetMapScale(theMapScale);
222 vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
223 vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]};
224 if(GetScaling() == VTK_SCALE_LOG10)
225 VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
226 myContourFilter->GenerateValues(GetNbParts(), aNewRange);
230 //----------------------------------------------------------------------------