2 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
3 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File: VISU_PipeLine.cxx
23 // Author: Alexey PETROV
27 #include "VISU_CutLinesPL.hxx"
28 #include "VISU_PipeLineUtils.hxx"
29 #include "SALOME_GeometryFilter.h"
31 #include <vtkAppendPolyData.h>
35 vtkStandardNewMacro(VISU_CutLinesPL);
37 VISU_CutLinesPL::VISU_CutLinesPL(){}
39 void VISU_CutLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
40 VISU_CutPlanesPL::ShallowCopy(thePipeLine);
41 if(VISU_CutLinesPL *aPipeLine = dynamic_cast<VISU_CutLinesPL*>(thePipeLine)){
42 SetOrientation(aPipeLine->GetPlaneOrientation(1),
43 aPipeLine->GetRotateX(1),aPipeLine->GetRotateY(1),1);
44 SetDisplacement(aPipeLine->GetDisplacement(1),1);
46 if (!aPipeLine->IsDefault()) SetPosition(aPipeLine->GetPosition());
50 void VISU_CutLinesPL::Init(){
51 VISU_CutPlanesPL::Init();
55 myDisplacement[0] = myDisplacement[1] = 0.5;
56 myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
57 myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0;
64 void VISU_CutLinesPL::SetPosition(float thePosition){
65 myPosition = thePosition;
69 float VISU_CutLinesPL::GetPosition(){
70 float aPosition = myPosition;
72 float aDir[3], aBounds[6], aBoundPrj[3];
73 myInput->GetBounds(aBounds);
74 GetDir(aDir,myAng[0],myBasePlane[0]);
75 GetBoundProject(aBoundPrj,aBounds,aDir);
76 aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[0];
81 void VISU_CutLinesPL::SetDefault(){
85 int VISU_CutLinesPL::IsDefault(){
90 void VISU_CutLinesPL::Update(){
91 ClearAppendPolyData(myAppendPolyData);
93 vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New();
95 float aDir[2][3], aBaseBounds[6];
96 myInput->GetBounds(aBaseBounds);
97 GetDir(aDir[0],myAng[0],myBasePlane[0]);
98 vtkUnstructuredGrid* anUnstructuredGrid =
99 myFieldTransform->GetUnstructuredGridOutput();
100 CutWithPlanes(anAppendPolyData,anUnstructuredGrid,1,aDir[0],aBaseBounds,
101 myPosition,myCondition,myDisplacement[0]);
104 vtkDataSet *aDataSet = anAppendPolyData->GetOutput();
106 if(aDataSet->GetNumberOfCells() == 0)
107 aDataSet = anUnstructuredGrid;
108 aDataSet->GetBounds(aBounds);
109 GetDir(aDir[1],myAng[1],myBasePlane[1]);
110 VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,aDataSet,GetNbParts(),aDir[1],aBounds,
111 myPartPosition,myPartCondition,myDisplacement[1]);
112 anAppendPolyData->Register(myAppendPolyData);
113 anAppendPolyData->Delete();
114 //Calculate values for building of table
115 vtkMath::Cross(aDir[0],aDir[1],myDirLn);
116 GetBoundProject(myBoundPrjLn, aBaseBounds, myDirLn);
117 VISU::Mul(myDirLn,myBoundPrjLn[0],myBasePnt);
118 CorrectPnt(myBasePnt,aBaseBounds);
120 VISU_ScalarMapPL::Update();
124 void VISU_CutLinesPL::CutWithPlanes(vtkAppendPolyData* theAppendPolyData, vtkDataSet* theDataSet,
125 int theNbPlanes, float theDir[3], float theBounds[6],
126 float thePartPosition, int thePartCondition,
127 float theDisplacement)
129 vector<float> aPartPosition(1,thePartPosition);
130 vector<int> aPartCondition(1,thePartCondition);
131 VISU_CutPlanesPL::CutWithPlanes(theAppendPolyData,theDataSet,theNbPlanes,theDir,theBounds,
132 aPartPosition,aPartCondition,theDisplacement);