Salome HOME
ae8527c3eba98f2c9f05106688cac97213aff7ff
[modules/visu.git] / src / PIPELINE / VISU_OptionalDeformationPL.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File:    VISU_ScalarMapPL.cxx
21 // Author:  Roman NIKOLAEV
22 // Module : VISU
23 //Salome includes
24 //
25 #include "VISU_OptionalDeformationPL.hxx"
26 #include "VISU_PipeLineUtils.hxx"
27
28 //VTK includes
29 #include <vtkDataSet.h>
30 #include <vtkPassThroughFilter.h>
31 #include <vtkWarpVector.h>
32 #include <vtkCellDataToPointData.h>
33 #ifdef _DEBUG_
34 static int MYDEBUG = 0;
35 #else
36 static int MYDEBUG = 0;
37 #endif
38
39 //----------------------------------------------------------------------------
40 VISU_OptionalDeformationPL::VISU_OptionalDeformationPL():
41   VISU_DeformationPL(),
42   myIsDeformed(true)
43 {
44     if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::VISU_OptionalDeformationPL() - "<<this);
45 }
46
47 //----------------------------------------------------------------------------
48 VISU_OptionalDeformationPL::~VISU_OptionalDeformationPL()
49 {
50   if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::~VISU_OptionalDeformationPL() - "<<this);
51 }
52
53 //----------------------------------------------------------------------------
54 unsigned long int
55 VISU_OptionalDeformationPL::GetMTime(){
56   return Superclass::GetMTime();
57 }
58
59 //----------------------------------------------------------------------------
60 void VISU_OptionalDeformationPL::UseDeformation(bool flag){
61   if(myIsDeformed == flag)
62     return;
63
64   myIsDeformed = flag;
65   if(myIsDeformed)
66     OnDeformation();
67   else
68     OffDeformation();
69 }
70
71 //----------------------------------------------------------------------------
72 bool VISU_OptionalDeformationPL::IsDeformed(){
73   return myIsDeformed;
74 }
75
76 //----------------------------------------------------------------------------
77 void VISU_OptionalDeformationPL::OnDeformation(){
78
79   myCellDataToPointData->SetInput(myInputPassFilter->GetOutput());
80   myWarpVector->SetInput(myCellDataToPointData->GetOutput());
81   myOutputPassFiler->SetInput(myWarpVector->GetOutput());
82 }
83
84 //----------------------------------------------------------------------------
85 void VISU_OptionalDeformationPL::OffDeformation(){
86   myOutputPassFiler->SetInput(myInputPassFilter->GetOutput());
87 }
88
89
90
91 bool VISU_OptionalDeformationPL::CheckCanDeformate(vtkDataSet* theInput){
92   if(theInput) {
93     if(VISU::IsDataOnCells(theInput))
94       return theInput->GetCellData()->GetVectors() != NULL;
95     else if(VISU::IsDataOnPoints(theInput))
96       return theInput->GetPointData()->GetVectors() != NULL;
97   }
98   return false;
99 }