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
23 // File: VISU_PipeLine.cxx
24 // Author: Alexey PETROV
28 #include "VISU_DeformedShapePL.hxx"
29 #include "VISU_PipeLineUtils.hxx"
30 #include "SALOME_Transform.h"
32 #include <vtkWarpVector.h>
35 static int MYDEBUG = 1;
37 static int MYDEBUG = 0;
40 vtkStandardNewMacro(VISU_DeformedShapePL);
42 VISU_DeformedShapePL::VISU_DeformedShapePL(){
43 myWarpVector = vtkWarpVector::New();
44 myCellDataToPointData = vtkCellDataToPointData::New();
47 VISU_DeformedShapePL::~VISU_DeformedShapePL(){
48 myWarpVector->UnRegisterAllOutputs();
49 myWarpVector->Delete();
51 myCellDataToPointData->UnRegisterAllOutputs();
52 myCellDataToPointData->Delete();
55 void VISU_DeformedShapePL::ShallowCopy(VISU_PipeLine *thePipeLine){
56 VISU_ScalarMapPL::ShallowCopy(thePipeLine);
57 if(VISU_DeformedShapePL *aPipeLine = dynamic_cast<VISU_DeformedShapePL*>(thePipeLine)){
58 SetScale(aPipeLine->GetScale());
62 float VISU_DeformedShapePL::GetScaleFactor(vtkDataSet* theDataSet){
63 if(!theDataSet) return 0.0;
65 int aNbCells = theDataSet->GetNumberOfCells();
66 int aNbPoints = theDataSet->GetNumberOfPoints();
67 int aNbElem = aNbCells? aNbCells: aNbPoints;
68 float* aBounds = theDataSet->GetBounds();
69 float aVolume = 1, aVol, idim = 0;
70 for(int i = 0; i < 6; i += 2){
71 aVol = fabs(aBounds[i+1] - aBounds[i]);
78 return pow(aVolume,float(1.0/idim));
82 void VISU_DeformedShapePL::SetScale(float theScale) {
83 if(myScaleFactor == theScale) return;
84 myScaleFactor = theScale;
85 myWarpVector->SetScaleFactor(myScaleFactor);
88 float VISU_DeformedShapePL::GetScale() {
89 return myWarpVector->GetScaleFactor();
92 void VISU_DeformedShapePL::Init(){
93 VISU_ScalarMapPL::Init();
94 float aScalarRange[2];
95 GetSourceRange(aScalarRange);
96 SetScale(GetScaleFactor(myInput)/aScalarRange[1]);
99 VISU_ScalarMapPL::THook* VISU_DeformedShapePL::DoHook(){
100 VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,myInput,myFieldTransform);
101 return myWarpVector->GetOutput();
104 void VISU_DeformedShapePL::Update(){
105 VISU_ScalarMapPL::Update();
108 void VISU_DeformedShapePL::SetMapScale(float theMapScale){
109 VISU_ScalarMapPL::SetMapScale(theMapScale);
111 myWarpVector->SetScaleFactor(myScaleFactor*theMapScale);