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();
46 VISU_DeformedShapePL::~VISU_DeformedShapePL(){
47 myWarpVector->Delete();
50 void VISU_DeformedShapePL::ShallowCopy(VISU_PipeLine *thePipeLine){
51 VISU_ScalarMapPL::ShallowCopy(thePipeLine);
52 if(VISU_DeformedShapePL *aPipeLine = dynamic_cast<VISU_DeformedShapePL*>(thePipeLine)){
53 SetScale(aPipeLine->GetScale());
57 float VISU_DeformedShapePL::GetScaleFactor(vtkDataSet* theDataSet){
58 if(!theDataSet) return 0.0;
60 int aNbCells = theDataSet->GetNumberOfCells();
61 int aNbPoints = theDataSet->GetNumberOfPoints();
62 int aNbElem = aNbCells? aNbCells: aNbPoints;
63 float* aBounds = theDataSet->GetBounds();
64 float aVolume = 1, aVol, idim = 0;
65 for(int i = 0; i < 6; i += 2){
66 aVol = fabs(aBounds[i+1] - aBounds[i]);
73 return pow(aVolume,float(1.0/idim));
77 void VISU_DeformedShapePL::SetScale(float theScale) {
78 if(myScaleFactor == theScale) return;
79 myScaleFactor = theScale;
80 myWarpVector->SetScaleFactor(myScaleFactor);
83 float VISU_DeformedShapePL::GetScale() {
84 return myWarpVector->GetScaleFactor();
87 void VISU_DeformedShapePL::Init(){
88 VISU_ScalarMapPL::Init();
89 float aScalarRange[2];
90 GetSourceRange(aScalarRange);
91 SetScale(GetScaleFactor(myInput)/aScalarRange[1]);
94 VISU_ScalarMapPL::THook* VISU_DeformedShapePL::DoHook(){
95 VISU::CellDataToPoint(myWarpVector,myInput,myFieldTransform);
96 return myWarpVector->GetOutput();
99 void VISU_DeformedShapePL::Update(){
100 VISU_ScalarMapPL::Update();
103 void VISU_DeformedShapePL::SetMapScale(float theMapScale){
104 VISU_ScalarMapPL::SetMapScale(theMapScale);
106 myWarpVector->SetScaleFactor(myScaleFactor*theMapScale);