Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / PIPELINE / VISU_IsoSurfacesPL.cxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 // File:    VISU_PipeLine.cxx
25 // Author:  Alexey PETROV
26 // Module : VISU
27
28
29 #include "VISU_IsoSurfacesPL.hxx"
30 #include "VISU_PipeLineUtils.hxx"
31
32 #include <vtkContourFilter.h>
33
34 vtkStandardNewMacro(VISU_IsoSurfacesPL);
35
36 VISU_IsoSurfacesPL
37 ::VISU_IsoSurfacesPL()
38 {
39   myContourFilter = vtkContourFilter::New();
40   myCellDataToPointData = vtkCellDataToPointData::New();
41   myIsShrinkable = false;
42 }
43
44 VISU_IsoSurfacesPL
45 ::~VISU_IsoSurfacesPL()
46 {
47   myContourFilter->UnRegisterAllOutputs();
48   myContourFilter->Delete();
49
50   myCellDataToPointData->UnRegisterAllOutputs();
51   myCellDataToPointData->Delete();
52 }
53
54 void
55 VISU_IsoSurfacesPL
56 ::ShallowCopy(VISU_PipeLine *thePipeLine)
57 {
58   if(VISU_IsoSurfacesPL *aPipeLine = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine)){
59     SetNbParts(aPipeLine->GetNbParts());
60     vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
61     SetRange(aRange);
62   }
63   VISU_ScalarMapPL::ShallowCopy(thePipeLine);
64 }
65
66 int
67 VISU_IsoSurfacesPL
68 ::GetNbParts() 
69 {
70   return myContourFilter->GetNumberOfContours();
71 }
72 void
73 VISU_IsoSurfacesPL
74 ::SetNbParts(int theNb) 
75 {
76   myContourFilter->SetNumberOfContours(theNb);
77   Modified();
78 }
79
80
81 void
82 VISU_IsoSurfacesPL
83 ::SetScaling(int theScaling) 
84 {
85   VISU_ScalarMapPL::SetScaling(theScaling);
86   SetRange(myRange);
87 }
88 void
89 VISU_IsoSurfacesPL
90 ::SetRange(vtkFloatingPointType theRange[2])
91 {
92   if(theRange[0] <= theRange[1]){
93     myRange[0] = theRange[0];  myRange[1] = theRange[1];
94     vtkFloatingPointType aRange[2] = {myRange[0], myRange[1]};
95     if(GetScaling() == VTK_SCALE_LOG10)
96       VISU_LookupTable::ComputeLogRange(theRange,aRange);
97     myContourFilter->GenerateValues(GetNbParts(),aRange);
98     Modified();
99   }
100 }
101
102 vtkFloatingPointType
103 VISU_IsoSurfacesPL
104 ::GetMin() 
105 {
106   return myRange[0];
107 }
108
109 vtkFloatingPointType
110 VISU_IsoSurfacesPL
111 ::GetMax() 
112 {
113   return myRange[1];
114 }
115
116
117 void
118 VISU_IsoSurfacesPL
119 ::Init()
120 {
121   VISU_ScalarMapPL::Init();
122
123   SetNbParts(10);
124   vtkFloatingPointType aScalarRange[2];
125   GetSourceRange(aScalarRange);
126   SetRange(aScalarRange);
127 }
128
129 VISU_ScalarMapPL::THook* 
130 VISU_IsoSurfacesPL
131 ::DoHook()
132 {
133   VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,GetInput2(),myFieldTransform);
134   return myContourFilter->GetOutput();
135 }
136
137
138 void
139 VISU_IsoSurfacesPL
140 ::Update()
141 {
142   VISU_ScalarMapPL::Update();
143 }
144
145 void
146 VISU_IsoSurfacesPL
147 ::SetMapScale(vtkFloatingPointType theMapScale)
148 {
149   VISU_ScalarMapPL::SetMapScale(theMapScale);
150
151   vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
152   vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]};
153   if(GetScaling() == VTK_SCALE_LOG10)
154     VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
155   myContourFilter->GenerateValues(GetNbParts(),aNewRange);
156   Modified();
157 }