1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: VISU_PipeLine.cxx
23 // Author: Alexey PETROV
26 #include "VISU_CutLinesPL.hxx"
27 #include "VISU_FieldTransform.hxx"
28 #include "VISU_PipeLineUtils.hxx"
29 #include "VTKViewer_GeometryFilter.h"
31 #include <vtkAppendPolyData.h>
34 //----------------------------------------------------------------------------
35 vtkStandardNewMacro(VISU_CutLinesPL);
38 //----------------------------------------------------------------------------
42 SetIsShrinkable(false);
43 SetIsFeatureEdgesAllowed(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;
107 return myAppendPolyData->GetOutput();
110 //----------------------------------------------------------------------------
115 vtkFloatingPointType aPosition = myPosition;
117 vtkFloatingPointType aBounds[6];
118 GetMergedInput()->GetBounds(aBounds);
120 vtkFloatingPointType aDir[3];
125 vtkFloatingPointType aBoundPrj[3];
126 GetBoundProject(aBoundPrj,
130 aPosition = aBoundPrj[0] + aBoundPrj[2] * myDisplacement[0];
136 //----------------------------------------------------------------------------
149 //----------------------------------------------------------------------------
158 //----------------------------------------------------------------------------
163 ClearAppendPolyData(myAppendPolyData);
167 vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New();
170 vtkFloatingPointType aBaseBounds[6];
171 GetMergedInput()->GetBounds(aBaseBounds);
173 vtkFloatingPointType aDir[2][3];
178 CutWithPlanes(anAppendPolyData,
187 vtkDataSet *aDataSet = anAppendPolyData->GetOutput();
190 if(aDataSet->GetNumberOfCells() == 0)
191 aDataSet = GetMergedInput();
193 vtkFloatingPointType aBounds[6];
194 aDataSet->GetBounds(aBounds);
200 VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,
209 // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myAppendPolyData.vtk";
210 // VISU::WriteToFile(myAppendPolyData->GetOutput(), aFileName);
212 anAppendPolyData->Delete();
214 //Calculate values for building of table
215 vtkMath::Cross(aDir[0],aDir[1],myDirLn);
216 for (int i = 0; i<3 ; i++) {
217 myRealDirLn[i] = myDirLn[i];
219 myDirLn[i] = -1.0*myDirLn[i];//enk:: correction of bug Bug PAL10401
222 GetBoundProject(myBoundPrjLn,
230 CorrectPnt(myBasePnt,
233 VISU_ScalarMapPL::Update();
237 //----------------------------------------------------------------------------
240 ::CutWithPlanes(vtkAppendPolyData* theAppendPolyData,
241 vtkDataSet* theDataSet,
243 vtkFloatingPointType theDir[3],
244 vtkFloatingPointType theBounds[6],
245 vtkFloatingPointType thePartPosition,
246 int thePartCondition,
247 vtkFloatingPointType theDisplacement)
249 std::vector<vtkFloatingPointType> aPartPosition(1,thePartPosition);
250 std::vector<int> aPartCondition(1,thePartCondition);
251 VISU_CutPlanesPL::CutWithPlanes(theAppendPolyData,
262 //----------------------------------------------------------------------------