Salome HOME
Update copyright information
[modules/visu.git] / src / PIPELINE / VISU_OptionalDeformationPL.cxx
1 // Copyright (C) 2007-2012  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 #ifdef _DEBUG_
33 static int MYDEBUG = 0;
34 #else
35 static int MYDEBUG = 0;
36 #endif
37
38 //----------------------------------------------------------------------------
39 VISU_OptionalDeformationPL::VISU_OptionalDeformationPL():
40   VISU_DeformationPL(),
41   myIsDeformed(true)
42 {
43     if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::VISU_OptionalDeformationPL() - "<<this);
44 }
45
46 //----------------------------------------------------------------------------
47 VISU_OptionalDeformationPL::~VISU_OptionalDeformationPL()
48 {
49   if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::~VISU_OptionalDeformationPL() - "<<this);
50 }
51
52 //----------------------------------------------------------------------------
53 unsigned long int
54 VISU_OptionalDeformationPL::GetMTime(){
55   return Superclass::GetMTime();
56 }
57
58 //----------------------------------------------------------------------------
59 void VISU_OptionalDeformationPL::UseDeformation(bool flag){
60   if(myIsDeformed == flag)
61     return;
62
63   myIsDeformed = flag;
64   if(myIsDeformed)
65     OnDeformation();
66   else
67     OffDeformation();
68 }
69
70 //----------------------------------------------------------------------------
71 bool VISU_OptionalDeformationPL::IsDeformed(){
72   return myIsDeformed;
73 }
74
75 //----------------------------------------------------------------------------
76 void VISU_OptionalDeformationPL::OnDeformation(){
77
78   myCellDataToPointData->SetInput(myInputPassFilter->GetOutput());
79   myWarpVector->SetInput(myCellDataToPointData->GetOutput());
80   myOutputPassFiler->SetInput(myWarpVector->GetOutput());
81 }
82
83 //----------------------------------------------------------------------------
84 void VISU_OptionalDeformationPL::OffDeformation(){
85   myOutputPassFiler->SetInput(myInputPassFilter->GetOutput());
86 }
87
88
89
90 bool VISU_OptionalDeformationPL::CheckCanDeformate(vtkDataSet* theInput){
91   if(theInput) {
92     if(VISU::IsDataOnCells(theInput))
93       return theInput->GetCellData()->GetVectors() != NULL;
94     else if(VISU::IsDataOnPoints(theInput))
95       return theInput->GetPointData()->GetVectors() != NULL;
96   }
97   return false;
98 }