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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File: VISU_PipeLine.cxx
25 // Author: Alexey PETROV
29 #include "VISU_IsoSurfacesPL.hxx"
30 #include "VISU_PipeLineUtils.hxx"
32 #include <vtkContourFilter.h>
34 vtkStandardNewMacro(VISU_IsoSurfacesPL);
36 VISU_IsoSurfacesPL::VISU_IsoSurfacesPL(){
37 myContourFilter = vtkContourFilter::New();
38 myCellDataToPointData = vtkCellDataToPointData::New();
39 myIsShrinkable = false;
42 VISU_IsoSurfacesPL::~VISU_IsoSurfacesPL(){
43 myContourFilter->UnRegisterAllOutputs();
44 myContourFilter->Delete();
46 myCellDataToPointData->UnRegisterAllOutputs();
47 myCellDataToPointData->Delete();
50 void VISU_IsoSurfacesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
51 if(VISU_IsoSurfacesPL *aPipeLine = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine)){
52 SetNbParts(aPipeLine->GetNbParts());
53 float aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
56 VISU_ScalarMapPL::ShallowCopy(thePipeLine);
59 int VISU_IsoSurfacesPL::GetNbParts() {
60 return myContourFilter->GetNumberOfContours();
62 void VISU_IsoSurfacesPL::SetNbParts(int theNb) {
63 myContourFilter->SetNumberOfContours(theNb);
68 void VISU_IsoSurfacesPL::SetScaling(int theScaling) {
69 VISU_ScalarMapPL::SetScaling(theScaling);
72 void VISU_IsoSurfacesPL::SetRange(float theRange[2]){
73 if(theRange[0] <= theRange[1]){
74 myRange[0] = theRange[0]; myRange[1] = theRange[1];
75 float aRange[2] = {myRange[0], myRange[1]};
76 if(GetScaling() == VTK_SCALE_LOG10)
77 VISU_LookupTable::ComputeLogRange(theRange,aRange);
78 myContourFilter->GenerateValues(GetNbParts(),aRange);
82 float VISU_IsoSurfacesPL::GetMin() {
85 float VISU_IsoSurfacesPL::GetMax() {
90 void VISU_IsoSurfacesPL::Init(){
91 VISU_ScalarMapPL::Init();
94 float aScalarRange[2];
95 GetSourceRange(aScalarRange);
96 SetRange(aScalarRange);
99 VISU_ScalarMapPL::THook* VISU_IsoSurfacesPL::DoHook(){
100 VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,GetInput2(),myFieldTransform);
101 return myContourFilter->GetOutput();
105 void VISU_IsoSurfacesPL::Update()
107 VISU_ScalarMapPL::Update();
110 void VISU_IsoSurfacesPL::SetMapScale(float theMapScale){
111 VISU_ScalarMapPL::SetMapScale(theMapScale);
113 float aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
114 float aNewRange[2] = {aRange[0], aRange[1]};
115 if(GetScaling() == VTK_SCALE_LOG10)
116 VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
117 myContourFilter->GenerateValues(GetNbParts(),aNewRange);