1 // Copyright (C) 2007-2010 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
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File: VISU_PipeLine.cxx
25 // Author: Alexey PETROV
28 #include "VISU_IsoSurfacesPL.hxx"
29 #include "VISU_LookupTable.hxx"
31 #include "VISU_PipeLineUtils.hxx"
32 #include "VISU_LabelPointsFilter.hxx"
34 #include <vtkContourFilter.h>
36 #define GAP_COEFFICIENT 0.0001
39 //----------------------------------------------------------------------------
40 vtkStandardNewMacro(VISU_IsoSurfacesPL);
43 //----------------------------------------------------------------------------
45 ::VISU_IsoSurfacesPL()
47 SetIsShrinkable(false);
48 SetIsFeatureEdgesAllowed(false);
50 SetElnoDisassembleState( true );
52 myContourFilter = vtkContourFilter::New();
54 myCellDataToPointData = VISU_CellDataToPointData::New();
58 //----------------------------------------------------------------------------
60 ::~VISU_IsoSurfacesPL()
62 myContourFilter->Delete();
63 myContourFilter = NULL;
65 myCellDataToPointData->Delete();
66 myCellDataToPointData = NULL;
70 //----------------------------------------------------------------------------
75 unsigned long int aTime = Superclass::GetMTime();
77 aTime = std::max(aTime, myCellDataToPointData->GetMTime());
78 aTime = std::max(aTime, myContourFilter->GetMTime());
84 //----------------------------------------------------------------------------
87 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
90 Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
92 if(VISU_IsoSurfacesPL *aPipeLine = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine)){
93 SetNbParts(aPipeLine->GetNbParts());
94 vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
96 SetRangeFixed(aPipeLine->IsRangeFixed());
101 //----------------------------------------------------------------------------
106 return myContourFilter->GetNumberOfContours();
109 //----------------------------------------------------------------------------
114 return myContourFilter->GetValue(i);
118 //----------------------------------------------------------------------------
121 ::SetNbParts(int theNb)
123 myContourFilter->SetNumberOfContours(theNb);
127 //----------------------------------------------------------------------------
130 ::SetScalarRange( vtkFloatingPointType theRange[2] )
132 Superclass::SetScalarRange( theRange );
137 //----------------------------------------------------------------------------
140 ::SetRange(vtkFloatingPointType theRange[2], bool theIsForced)
142 if(VISU::CheckIsSameRange(myRange, theRange) && !theIsForced)
145 if(theRange[0] <= theRange[1]){
146 myRange[0] = theRange[0];
147 myRange[1] = theRange[1];
148 vtkFloatingPointType aRange[2] = {theRange[0], theRange[1]};
149 if( IsRangeFixed() ) {
150 double aDelta = fabs( aRange[1] - aRange[0] ) * GAP_COEFFICIENT;
154 if(GetScaling() == VTK_SCALE_LOG10)
155 VISU_LookupTable::ComputeLogRange(theRange, aRange);
156 myContourFilter->GenerateValues(GetNbParts(), aRange);
161 //----------------------------------------------------------------------------
170 //----------------------------------------------------------------------------
179 //----------------------------------------------------------------------------
182 ::SetRangeFixed(bool theIsFixed)
184 myIsRangeFixed = theIsFixed;
185 SetRange( myRange, true );
189 //----------------------------------------------------------------------------
194 return myIsRangeFixed;
199 //----------------------------------------------------------------------------
207 vtkFloatingPointType aScalarRange[2];
208 GetSourceRange(aScalarRange);
209 SetRange(aScalarRange);
214 //----------------------------------------------------------------------------
221 VISU::CellDataToPoint(myContourFilter,
222 myCellDataToPointData,
228 //----------------------------------------------------------------------------
234 return myContourFilter->GetOutput();
238 //----------------------------------------------------------------------------
243 unsigned long int aSize = Superclass::GetMemorySize();
245 if(vtkDataSet* aDataSet = myContourFilter->GetOutput())
246 aSize += aDataSet->GetActualMemorySize() * 1024;
248 if(myCellDataToPointData->GetInput())
249 if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
250 aSize += aDataSet->GetActualMemorySize() * 1024;
256 //----------------------------------------------------------------------------
259 ::SetMapScale(vtkFloatingPointType theMapScale)
261 Superclass::SetMapScale(theMapScale);
263 vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
264 vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]};
265 if( IsRangeFixed() ) {
266 double aDelta = fabs( aNewRange[1] - aNewRange[0] ) * GAP_COEFFICIENT;
267 aNewRange[0] += aDelta;
268 aNewRange[1] -= aDelta;
270 if(GetScaling() == VTK_SCALE_LOG10)
271 VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
272 myContourFilter->GenerateValues(GetNbParts(), aNewRange);
276 //----------------------------------------------------------------------------