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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: VISU_PipeLine.cxx
23 // Author: Alexey PETROV
27 #include "VISU_CutLinesPL.hxx"
28 #include "VISU_FieldTransform.hxx"
29 #include "VISU_PipeLineUtils.hxx"
30 #include "VTKViewer_GeometryFilter.h"
32 #include <vtkAppendPolyData.h>
35 //----------------------------------------------------------------------------
36 vtkStandardNewMacro(VISU_CutLinesPL);
39 //----------------------------------------------------------------------------
43 SetIsShrinkable(false);
50 //----------------------------------------------------------------------------
53 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
56 Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
58 if(VISU_CutLinesPL *aPipeLine = dynamic_cast<VISU_CutLinesPL*>(thePipeLine)){
59 SetOrientation(aPipeLine->GetPlaneOrientation(1),
60 aPipeLine->GetRotateX(1),aPipeLine->GetRotateY(1),1);
61 SetDisplacement(aPipeLine->GetDisplacement(1),1);
62 if (aPipeLine->IsDefault())
65 SetPosition(aPipeLine->GetPosition());
70 //----------------------------------------------------------------------------
79 myDisplacement[0] = myDisplacement[1] = 0.5;
80 myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
81 myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0;
88 //----------------------------------------------------------------------------
91 ::SetPosition(vtkFloatingPointType thePosition)
93 bool anIsSameValue = VISU::CheckIsSameValue(myPosition, thePosition);
94 anIsSameValue &= (myCondition == 0);
98 myPosition = thePosition;
104 //----------------------------------------------------------------------------
109 vtkFloatingPointType aPosition = myPosition;
111 vtkFloatingPointType aBounds[6];
112 GetMergedInput()->GetBounds(aBounds);
114 vtkFloatingPointType aDir[3];
119 vtkFloatingPointType aBoundPrj[3];
120 GetBoundProject(aBoundPrj,
124 aPosition = aBoundPrj[0] + aBoundPrj[2] * myDisplacement[0];
130 //----------------------------------------------------------------------------
143 //----------------------------------------------------------------------------
152 //----------------------------------------------------------------------------
157 ClearAppendPolyData(myAppendPolyData);
161 vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New();
164 vtkFloatingPointType aBaseBounds[6];
165 GetMergedInput()->GetBounds(aBaseBounds);
167 vtkFloatingPointType aDir[2][3];
172 CutWithPlanes(anAppendPolyData,
181 vtkDataSet *aDataSet = anAppendPolyData->GetOutput();
184 if(aDataSet->GetNumberOfCells() == 0)
185 aDataSet = GetMergedInput();
187 vtkFloatingPointType aBounds[6];
188 aDataSet->GetBounds(aBounds);
194 VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,
203 // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myAppendPolyData.vtk";
204 // VISU::WriteToFile(myAppendPolyData->GetOutput(), aFileName);
206 anAppendPolyData->Delete();
208 //Calculate values for building of table
209 vtkMath::Cross(aDir[0],aDir[1],myDirLn);
210 for (int i = 0; i<3 ; i++) {
211 myRealDirLn[i] = myDirLn[i];
213 myDirLn[i] = -1.0*myDirLn[i];//enk:: correction of bug Bug PAL10401
216 GetBoundProject(myBoundPrjLn,
224 CorrectPnt(myBasePnt,
227 VISU_ScalarMapPL::Update();
231 //----------------------------------------------------------------------------
234 ::CutWithPlanes(vtkAppendPolyData* theAppendPolyData,
235 vtkDataSet* theDataSet,
237 vtkFloatingPointType theDir[3],
238 vtkFloatingPointType theBounds[6],
239 vtkFloatingPointType thePartPosition,
240 int thePartCondition,
241 vtkFloatingPointType theDisplacement)
243 std::vector<vtkFloatingPointType> aPartPosition(1,thePartPosition);
244 std::vector<int> aPartCondition(1,thePartCondition);
245 VISU_CutPlanesPL::CutWithPlanes(theAppendPolyData,
256 //----------------------------------------------------------------------------