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>
35 #define GAP_COEFFICIENT 0.0001
38 //----------------------------------------------------------------------------
39 vtkStandardNewMacro(VISU_IsoSurfacesPL);
42 //----------------------------------------------------------------------------
44 ::VISU_IsoSurfacesPL()
46 SetIsShrinkable(false);
47 SetIsFeatureEdgesAllowed(false);
49 SetElnoDisassembleState( true );
51 myContourFilter = vtkContourFilter::New();
53 myCellDataToPointData = vtkCellDataToPointData::New();
57 //----------------------------------------------------------------------------
59 ::~VISU_IsoSurfacesPL()
61 myContourFilter->Delete();
62 myContourFilter = NULL;
64 myCellDataToPointData->Delete();
65 myCellDataToPointData = NULL;
69 //----------------------------------------------------------------------------
74 unsigned long int aTime = Superclass::GetMTime();
76 aTime = std::max(aTime, myCellDataToPointData->GetMTime());
77 aTime = std::max(aTime, myContourFilter->GetMTime());
83 //----------------------------------------------------------------------------
86 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
89 Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
91 if(VISU_IsoSurfacesPL *aPipeLine = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine)){
92 SetNbParts(aPipeLine->GetNbParts());
93 vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
95 SetRangeFixed(aPipeLine->IsRangeFixed());
100 //----------------------------------------------------------------------------
105 return myContourFilter->GetNumberOfContours();
108 //----------------------------------------------------------------------------
113 return myContourFilter->GetValue(i);
117 //----------------------------------------------------------------------------
120 ::SetNbParts(int theNb)
122 myContourFilter->SetNumberOfContours(theNb);
126 //----------------------------------------------------------------------------
129 ::SetScalarRange( vtkFloatingPointType theRange[2] )
131 Superclass::SetScalarRange( theRange );
136 //----------------------------------------------------------------------------
139 ::SetRange(vtkFloatingPointType theRange[2], bool theIsForced)
141 if(VISU::CheckIsSameRange(myRange, theRange) && !theIsForced)
144 if(theRange[0] <= theRange[1]){
145 myRange[0] = theRange[0];
146 myRange[1] = theRange[1];
147 vtkFloatingPointType aRange[2] = {theRange[0], theRange[1]};
148 if( IsRangeFixed() ) {
149 double aDelta = fabs( aRange[1] - aRange[0] ) * GAP_COEFFICIENT;
153 if(GetScaling() == VTK_SCALE_LOG10)
154 VISU_LookupTable::ComputeLogRange(theRange, aRange);
155 myContourFilter->GenerateValues(GetNbParts(), aRange);
160 //----------------------------------------------------------------------------
169 //----------------------------------------------------------------------------
178 //----------------------------------------------------------------------------
181 ::SetRangeFixed(bool theIsFixed)
183 myIsRangeFixed = theIsFixed;
184 SetRange( myRange, true );
188 //----------------------------------------------------------------------------
193 return myIsRangeFixed;
198 //----------------------------------------------------------------------------
206 vtkFloatingPointType aScalarRange[2];
207 GetSourceRange(aScalarRange);
208 SetRange(aScalarRange);
213 //----------------------------------------------------------------------------
220 VISU::CellDataToPoint(myContourFilter,
221 myCellDataToPointData,
227 //----------------------------------------------------------------------------
233 return myContourFilter->GetOutput();
237 //----------------------------------------------------------------------------
242 unsigned long int aSize = Superclass::GetMemorySize();
244 if(vtkDataSet* aDataSet = myContourFilter->GetOutput())
245 aSize += aDataSet->GetActualMemorySize() * 1024;
247 if(myCellDataToPointData->GetInput())
248 if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
249 aSize += aDataSet->GetActualMemorySize() * 1024;
255 //----------------------------------------------------------------------------
258 ::SetMapScale(vtkFloatingPointType theMapScale)
260 Superclass::SetMapScale(theMapScale);
262 vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
263 vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]};
264 if( IsRangeFixed() ) {
265 double aDelta = fabs( aNewRange[1] - aNewRange[0] ) * GAP_COEFFICIENT;
266 aNewRange[0] += aDelta;
267 aNewRange[1] -= aDelta;
269 if(GetScaling() == VTK_SCALE_LOG10)
270 VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
271 myContourFilter->GenerateValues(GetNbParts(), aNewRange);
275 //----------------------------------------------------------------------------