Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / PIPELINE / VISU_CutPlanesPL.cxx
index a6cb0665877de8c077a48367cc21ea1ec8c13f5c..63dd3e5a42966a4dee8b3c794f1fe08e2b8a42a2 100644 (file)
@@ -1,23 +1,23 @@
 //  VISU OBJECT : interactive object for VISU entities implementation
 //
 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
 //
 //
 // File:    VISU_PipeLine.cxx
@@ -27,7 +27,7 @@
 
 #include "VISU_CutPlanesPL.hxx"
 #include "VISU_PipeLineUtils.hxx"
-#include "SALOME_GeometryFilter.h"
+#include "VTKViewer_GeometryFilter.h"
 
 #include <vtkAppendPolyData.h>
 #include <vtkCutter.h>
@@ -41,6 +41,7 @@ vtkStandardNewMacro(VISU_CutPlanesPL);
 
 VISU_CutPlanesPL::VISU_CutPlanesPL(){
   myAppendPolyData = vtkAppendPolyData::New();
+  myIsShrinkable = false;
 }
 
 VISU_CutPlanesPL::~VISU_CutPlanesPL(){
@@ -48,16 +49,15 @@ VISU_CutPlanesPL::~VISU_CutPlanesPL(){
 }
 
 void VISU_CutPlanesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
-  VISU_ScalarMapPL::ShallowCopy(thePipeLine);
   if(VISU_CutPlanesPL *aPipeLine = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine)){
-    SetPlaneOrientation(aPipeLine->GetPlaneOrientation());
+    SetOrientation(aPipeLine->GetPlaneOrientation(),
+                  aPipeLine->GetRotateX(),aPipeLine->GetRotateY());
     SetDisplacement(aPipeLine->GetDisplacement());
     SetNbParts(aPipeLine->GetNbParts());
     for (int i = 0, iend = GetNbParts(); i < iend; i++)
       if(!aPipeLine->IsPartDefault(i))         SetPartPosition(i, aPipeLine->GetPartPosition(i));
-    SetRotateX(aPipeLine->GetRotateX());
-    SetRotateY(aPipeLine->GetRotateY());
   }
+  VISU_ScalarMapPL::ShallowCopy(thePipeLine);
 }
 
 void VISU_CutPlanesPL::Init(){
@@ -79,7 +79,7 @@ void VISU_CutPlanesPL::Update(){
   float aDir[3];
   GetDir(aDir,myAng[0],myBasePlane[0]);
   float aBounds[6];
-  myInput->GetBounds(aBounds);
+  GetInput2()->GetBounds(aBounds);
   vtkDataSet* aDataSet = myFieldTransform->GetUnstructuredGridOutput();
   CutWithPlanes(myAppendPolyData,aDataSet,myNbParts,aDir,aBounds,
                myPartPosition,myPartCondition,myDisplacement[0]);
@@ -108,16 +108,16 @@ float* VISU_CutPlanesPL::GetRx(float theRx[3][3], float thaAng){
 
 float* VISU_CutPlanesPL::GetRy(float theRy[3][3], float thaAng){
   theRy[0][0] = cos(thaAng);    theRy[0][1] = 0.0;            theRy[0][2] = sin(thaAng);
-  theRy[1][0] = 0.0;            theRy[1][1] = 1.0;            theRy[1][2] = 0.0;   
-  theRy[2][0] = -sin(thaAng);   theRy[2][1] = 0.0;            theRy[2][2] = cos(thaAng);   
+  theRy[1][0] = 0.0;            theRy[1][1] = 1.0;            theRy[1][2] = 0.0;
+  theRy[2][0] = -sin(thaAng);   theRy[2][1] = 0.0;            theRy[2][2] = cos(thaAng);
   return theRy[0];
 }
 
 
 float* VISU_CutPlanesPL::GetRz(float theRz[3][3], float thaAng){
   theRz[0][0] = cos(thaAng);    theRz[0][1] = -sin(thaAng);   theRz[0][2] = 0.0;
-  theRz[1][0] = sin(thaAng);    theRz[1][1] = cos(thaAng);    theRz[1][2] = 0.0;   
-  theRz[2][0] = 0.0;            theRz[2][1] = 0.0;            theRz[2][2] = 1.0;   
+  theRz[1][0] = sin(thaAng);    theRz[1][1] = cos(thaAng);    theRz[1][2] = 0.0;
+  theRz[2][0] = 0.0;            theRz[2][1] = 0.0;            theRz[2][2] = 1.0;
   return theRz[0];
 }
 
@@ -135,8 +135,8 @@ void VISU_CutPlanesPL::GetBoundProject(float BoundPrj[3], const float BoundBox[6
                              {BoundBox[0],BoundBox[3],BoundBox[4]},
                              {BoundBox[1],BoundBox[3],BoundBox[4]},
                              {BoundBox[0],BoundBox[2],BoundBox[5]},
-                             {BoundBox[1],BoundBox[2],BoundBox[5]}, 
-                             {BoundBox[0],BoundBox[3],BoundBox[5]}, 
+                             {BoundBox[1],BoundBox[2],BoundBox[5]},
+                             {BoundBox[0],BoundBox[3],BoundBox[5]},
                              {BoundBox[1],BoundBox[3],BoundBox[5]}};
   BoundPrj[0] = vtkMath::Dot(Dir,BoundPoints[0]), BoundPrj[1] = BoundPrj[0];
   for(int i = 1; i < 8; i++){
@@ -150,28 +150,35 @@ void VISU_CutPlanesPL::GetBoundProject(float BoundPrj[3], const float BoundBox[6
   BoundPrj[2] = BoundPrj[1] - BoundPrj[0];
 }
 
-void VISU_CutPlanesPL::SetRotateX(float theAng, int theNum){
+
+void VISU_CutPlanesPL::SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient,
+                                     float theXAng, float theYAng, int theNum)
+{
+  myBasePlane[theNum] = theOrient;
+  switch(myBasePlane[theNum]){
+  case XY: myAng[theNum][0] = theXAng; break;
+  case YZ: myAng[theNum][1] = theXAng; break;
+  case ZX: myAng[theNum][2] = theXAng; break;
+  }
   switch(myBasePlane[theNum]){
-  case XY: myAng[theNum][0] = theAng; break;
-  case YZ: myAng[theNum][1] = theAng; break;
-  case ZX: myAng[theNum][2] = theAng; break;
+  case XY: myAng[theNum][1] = theYAng; break;
+  case YZ: myAng[theNum][2] = theYAng; break;
+  case ZX: myAng[theNum][0] = theYAng; break;
   }
 }
 
+
+const VISU_CutPlanesPL::PlaneOrientation& VISU_CutPlanesPL::GetPlaneOrientation(int theNum){
+  return myBasePlane[theNum];
+}
+
 float VISU_CutPlanesPL::GetRotateX(int theNum){
   switch(myBasePlane[theNum]){
   case XY: return myAng[theNum][0];
   case YZ: return myAng[theNum][1];
   case ZX: return myAng[theNum][2];
   }
-}
-
-void VISU_CutPlanesPL::SetRotateY(float theAng, int theNum){
-  switch(myBasePlane[theNum]){
-  case XY: myAng[theNum][1] = theAng; break;
-  case YZ: myAng[theNum][2] = theAng; break;
-  case ZX: myAng[theNum][0] = theAng; break;
-  }
+  return 0;
 }
 
 float VISU_CutPlanesPL::GetRotateY(int theNum){
@@ -180,10 +187,11 @@ float VISU_CutPlanesPL::GetRotateY(int theNum){
   case YZ: return myAng[theNum][2];
   case ZX: return myAng[theNum][0];
   }
+  return 0;
 }
 
 
-void VISU_CutPlanesPL::SetNbParts(int theNb) { 
+void VISU_CutPlanesPL::SetNbParts(int theNb) {
   myNbParts = theNb;
   myPartPosition.resize(myNbParts);
   myPartCondition.resize(myNbParts,1);
@@ -202,7 +210,7 @@ float VISU_CutPlanesPL::GetPartPosition(int thePartNumber, int theNum){
   float aPosition = myPartPosition[thePartNumber];
   if(myPartCondition[thePartNumber]){
       float aDir[3], aBounds[6], aBoundPrj[3];
-      myInput->GetBounds(aBounds);
+      GetInput2()->GetBounds(aBounds);
       GetDir(aDir,myAng[theNum],myBasePlane[theNum]);
       GetBoundProject(aBoundPrj,aBounds,aDir);
       if (myNbParts > 1){
@@ -211,7 +219,7 @@ float VISU_CutPlanesPL::GetPartPosition(int thePartNumber, int theNum){
        float aStartPosition = aBoundPrj[0] - 0.5*aDBoundPrj + aDisplacement;
        aPosition = aStartPosition + thePartNumber*aDBoundPrj;
       }else
-       aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[theNum];    
+       aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[theNum];
   }
   return aPosition;
 }
@@ -229,35 +237,38 @@ int VISU_CutPlanesPL::IsPartDefault(int thePartNumber){
 }
 
 
-void VISU_CutPlanesPL::GetDir(float theDir[3], float theAng[3], const PlaneOrientation& theBasePlane){
+void VISU_CutPlanesPL::GetDir(float theDir[3],
+                              const float theAng[3],
+                              const PlaneOrientation& theBasePlane)
+{
   int iPlane = 0;
   float aRx[3][3], aRy[3][3], aRz[3][3], aRotation[3][3];
   switch(theBasePlane){
-  case XY: 
+  case XY:
     if(fabs(theAng[0]) > EPS) GetRx(aRx,theAng[0]); else vtkMath::Identity3x3(aRx);
     if(fabs(theAng[1]) > EPS) GetRy(aRy,theAng[1]); else vtkMath::Identity3x3(aRy);
     vtkMath::Multiply3x3(aRx,aRy,aRotation);
     iPlane = 2;
     break;
-  case YZ: 
+  case YZ:
     if(fabs(theAng[1]) > EPS) GetRy(aRy,theAng[1]); else vtkMath::Identity3x3(aRy);
     if(fabs(theAng[2]) > EPS) GetRz(aRz,theAng[2]); else vtkMath::Identity3x3(aRz);
     vtkMath::Multiply3x3(aRy,aRz,aRotation);
     iPlane = 0;
     break;
-  case ZX: 
+  case ZX:
     if(fabs(theAng[2]) > EPS) GetRz(aRz,theAng[2]); else vtkMath::Identity3x3(aRz);
     if(fabs(theAng[0]) > EPS) GetRx(aRx,theAng[0]); else vtkMath::Identity3x3(aRx);
     vtkMath::Multiply3x3(aRz,aRx,aRotation);
     iPlane = 1;
     break;
   }
-  for(int i = 0; i < 3; i++)  
+  for(int i = 0; i < 3; i++)
     theDir[i] = aRotation[i][iPlane];
 }
 
 
-void VISU_CutPlanesPL::CutWithPlane(vtkAppendPolyData* theAppendPolyData, 
+void VISU_CutPlanesPL::CutWithPlane(vtkAppendPolyData* theAppendPolyData,
                                    vtkDataSet* theDataSet,
                                    float theDir[3], float theOrig[3])
 {
@@ -265,7 +276,7 @@ void VISU_CutPlanesPL::CutWithPlane(vtkAppendPolyData* theAppendPolyData,
   aCutPlane->SetInput(theDataSet);
   vtkPlane *aPlane = vtkPlane::New();
   aPlane->SetOrigin(theOrig);
-  
+
   aPlane->SetNormal(theDir);
   aCutPlane->SetCutFunction(aPlane);
   aPlane->Delete();
@@ -276,8 +287,8 @@ void VISU_CutPlanesPL::CutWithPlane(vtkAppendPolyData* theAppendPolyData,
 
 
 void VISU_CutPlanesPL::CutWithPlanes(vtkAppendPolyData* theAppendPolyData, vtkDataSet* theDataSet,
-                                    int theNbPlanes, float theDir[3], float theBounds[6], 
-                                    const vector<float>& thePlanePosition, 
+                                    int theNbPlanes, float theDir[3], float theBounds[6],
+                                    const vector<float>& thePlanePosition,
                                     const vector<int>& thePlaneCondition,
                                     float theDisplacement)
 {
@@ -289,7 +300,6 @@ void VISU_CutPlanesPL::CutWithPlanes(vtkAppendPolyData* theAppendPolyData, vtkDa
     float aStartPosition = aBoundPrj[0] - 0.5*aDBoundPrj + aDisplacement;
     for (int i = 0; i < theNbPlanes; i++){
       aPosition = aStartPosition + i*aDBoundPrj;
-      float aDelta = (aBoundPrj[0] - aPosition) / aBoundPrj[2];
       if(thePlaneCondition[i]){
        aPosition = aStartPosition + i*aDBoundPrj;
       }else