Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / PIPELINE / VISU_CutPlanesPL.cxx
index 8ca1b31167f173f894824592dae6153b9f2cac32..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
@@ -41,6 +41,7 @@ vtkStandardNewMacro(VISU_CutPlanesPL);
 
 VISU_CutPlanesPL::VISU_CutPlanesPL(){
   myAppendPolyData = vtkAppendPolyData::New();
+  myIsShrinkable = false;
 }
 
 VISU_CutPlanesPL::~VISU_CutPlanesPL(){
@@ -48,7 +49,6 @@ VISU_CutPlanesPL::~VISU_CutPlanesPL(){
 }
 
 void VISU_CutPlanesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
-  VISU_ScalarMapPL::ShallowCopy(thePipeLine);
   if(VISU_CutPlanesPL *aPipeLine = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine)){
     SetOrientation(aPipeLine->GetPlaneOrientation(),
                   aPipeLine->GetRotateX(),aPipeLine->GetRotateY());
@@ -57,6 +57,7 @@ void VISU_CutPlanesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
     for (int i = 0, iend = GetNbParts(); i < iend; i++)
       if(!aPipeLine->IsPartDefault(i))         SetPartPosition(i, aPipeLine->GetPartPosition(i));
   }
+  VISU_ScalarMapPL::ShallowCopy(thePipeLine);
 }
 
 void VISU_CutPlanesPL::Init(){
@@ -78,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]);
@@ -107,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];
 }
 
@@ -134,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,9 +151,9 @@ void VISU_CutPlanesPL::GetBoundProject(float BoundPrj[3], const float BoundBox[6
 }
 
 
-void VISU_CutPlanesPL::SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient, 
+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;
@@ -167,7 +168,7 @@ void VISU_CutPlanesPL::SetOrientation(const VISU_CutPlanesPL::PlaneOrientation&
 }
 
 
-const VISU_CutPlanesPL::PlaneOrientation& VISU_CutPlanesPL::GetPlaneOrientation(int theNum){ 
+const VISU_CutPlanesPL::PlaneOrientation& VISU_CutPlanesPL::GetPlaneOrientation(int theNum){
   return myBasePlane[theNum];
 }
 
@@ -190,7 +191,7 @@ float VISU_CutPlanesPL::GetRotateY(int theNum){
 }
 
 
-void VISU_CutPlanesPL::SetNbParts(int theNb) { 
+void VISU_CutPlanesPL::SetNbParts(int theNb) {
   myNbParts = theNb;
   myPartPosition.resize(myNbParts);
   myPartCondition.resize(myNbParts,1);
@@ -209,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){
@@ -218,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;
 }
@@ -236,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])
 {
@@ -272,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();
@@ -283,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)
 {