1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File: VISU_PipeLine.cxx
24 // Author: Alexey PETROV
27 #include "VISU_IsoSurfacesPL.hxx"
28 #include "VISU_LookupTable.hxx"
30 #include "VISU_PipeLineUtils.hxx"
31 #include "VISU_LabelPointsFilter.hxx"
33 #include <vtkContourFilter.h>
37 //----------------------------------------------------------------------------
38 vtkStandardNewMacro(VISU_IsoSurfacesPL);
41 //----------------------------------------------------------------------------
43 ::VISU_IsoSurfacesPL()
45 SetIsShrinkable(false);
46 SetIsFeatureEdgesAllowed(false);
48 SetElnoDisassembleState( true );
50 myContourFilter = vtkContourFilter::New();
52 myCellDataToPointData = vtkCellDataToPointData::New();
56 //----------------------------------------------------------------------------
58 ::~VISU_IsoSurfacesPL()
60 myContourFilter->Delete();
61 myContourFilter = NULL;
63 myCellDataToPointData->Delete();
64 myCellDataToPointData = NULL;
68 //----------------------------------------------------------------------------
73 unsigned long int aTime = Superclass::GetMTime();
75 aTime = std::max(aTime, myCellDataToPointData->GetMTime());
76 aTime = std::max(aTime, myContourFilter->GetMTime());
82 //----------------------------------------------------------------------------
85 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
88 Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
90 if(VISU_IsoSurfacesPL *aPipeLine = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine)){
91 SetNbParts(aPipeLine->GetNbParts());
92 vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
98 //----------------------------------------------------------------------------
103 return myContourFilter->GetNumberOfContours();
106 //----------------------------------------------------------------------------
111 return myContourFilter->GetValue(i);
115 //----------------------------------------------------------------------------
118 ::SetNbParts(int theNb)
120 myContourFilter->SetNumberOfContours(theNb);
124 //----------------------------------------------------------------------------
127 ::SetScalarRange( vtkFloatingPointType theRange[2] )
129 Superclass::SetScalarRange( theRange );
134 //----------------------------------------------------------------------------
137 ::SetRange(vtkFloatingPointType theRange[2])
139 if(VISU::CheckIsSameRange(myRange, theRange))
142 if(theRange[0] <= theRange[1]){
143 myRange[0] = theRange[0];
144 myRange[1] = theRange[1];
145 vtkFloatingPointType aRange[2] = {theRange[0], theRange[1]};
146 if(GetScaling() == VTK_SCALE_LOG10)
147 VISU_LookupTable::ComputeLogRange(theRange, aRange);
148 myContourFilter->GenerateValues(GetNbParts(), aRange);
153 //----------------------------------------------------------------------------
162 //----------------------------------------------------------------------------
172 //----------------------------------------------------------------------------
180 vtkFloatingPointType aScalarRange[2];
181 GetSourceRange(aScalarRange);
182 SetRange(aScalarRange);
185 //----------------------------------------------------------------------------
192 VISU::CellDataToPoint(myContourFilter,
193 myCellDataToPointData,
199 //----------------------------------------------------------------------------
205 return myContourFilter->GetOutput();
209 //----------------------------------------------------------------------------
214 unsigned long int aSize = Superclass::GetMemorySize();
216 if(vtkDataSet* aDataSet = myContourFilter->GetOutput())
217 aSize += aDataSet->GetActualMemorySize() * 1024;
219 if(myCellDataToPointData->GetInput())
220 if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
221 aSize += aDataSet->GetActualMemorySize() * 1024;
227 //----------------------------------------------------------------------------
230 ::SetMapScale(vtkFloatingPointType theMapScale)
232 Superclass::SetMapScale(theMapScale);
234 vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
235 vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]};
236 if(GetScaling() == VTK_SCALE_LOG10)
237 VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
238 myContourFilter->GenerateValues(GetNbParts(), aNewRange);
242 //----------------------------------------------------------------------------