Salome HOME
496ebd19343273cd5ef0c36af51ac7df5e1526d4
[modules/visu.git] / src / PIPELINE / VISU_OptionalDeformationPL.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File:    VISU_ScalarMapPL.cxx
23 // Author:  Roman NIKOLAEV
24 // Module : VISU
25 //Salome includes
26 //
27 #include "VISU_OptionalDeformationPL.hxx"
28 #include "VISU_PipeLineUtils.hxx"
29
30 //VTK includes
31 #include <vtkDataSet.h>
32 #include <vtkPassThroughFilter.h>
33 #include <vtkWarpVector.h>
34 #include <vtkCellDataToPointData.h>
35 #ifdef _DEBUG_
36 static int MYDEBUG = 0;
37 #else
38 static int MYDEBUG = 0;
39 #endif
40
41 //----------------------------------------------------------------------------
42 VISU_OptionalDeformationPL::VISU_OptionalDeformationPL():
43   VISU_DeformationPL(),
44   myIsDeformed(true)
45 {
46     if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::VISU_OptionalDeformationPL() - "<<this);
47 }
48
49 //----------------------------------------------------------------------------
50 VISU_OptionalDeformationPL::~VISU_OptionalDeformationPL()
51 {
52   if(MYDEBUG) MESSAGE("VISU_OptionalDeformationPL()::~VISU_OptionalDeformationPL() - "<<this);
53 }
54
55 //----------------------------------------------------------------------------
56 unsigned long int
57 VISU_OptionalDeformationPL::GetMTime(){
58   return Superclass::GetMTime();
59 }
60
61 //----------------------------------------------------------------------------
62 void VISU_OptionalDeformationPL::UseDeformation(bool flag){
63   if(myIsDeformed == flag)
64     return;
65
66   myIsDeformed = flag;
67   if(myIsDeformed)
68     OnDeformation();
69   else
70     OffDeformation();
71 }
72
73 //----------------------------------------------------------------------------
74 bool VISU_OptionalDeformationPL::IsDeformed(){
75   return myIsDeformed;
76 }
77
78 //----------------------------------------------------------------------------
79 void VISU_OptionalDeformationPL::OnDeformation(){
80
81   myCellDataToPointData->SetInput(myInputPassFilter->GetOutput());
82   myWarpVector->SetInput(myCellDataToPointData->GetOutput());
83   myOutputPassFiler->SetInput(myWarpVector->GetOutput());
84 }
85
86 //----------------------------------------------------------------------------
87 void VISU_OptionalDeformationPL::OffDeformation(){
88   myOutputPassFiler->SetInput(myInputPassFilter->GetOutput());
89 }
90
91
92
93 bool VISU_OptionalDeformationPL::CheckCanDeformate(vtkDataSet* theInput){
94   if(theInput) {
95     if(VISU::IsDataOnCells(theInput))
96       return theInput->GetCellData()->GetVectors() != NULL;
97     else if(VISU::IsDataOnPoints(theInput))
98       return theInput->GetPointData()->GetVectors() != NULL;
99   }
100   return false;
101 }