1 // Copyright (C) 2007-2010 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
23 // File: VISU_PipeLine.cxx
24 // 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 //----------------------------------------------------------------------------
48 //----------------------------------------------------------------------------
51 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
54 Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
56 if(VISU_CutLinesPL *aPipeLine = dynamic_cast<VISU_CutLinesPL*>(thePipeLine)){
57 SetOrientation(aPipeLine->GetPlaneOrientation(1),
58 aPipeLine->GetRotateX(1),aPipeLine->GetRotateY(1),1);
59 SetDisplacement(aPipeLine->GetDisplacement(1),1);
60 if (aPipeLine->IsDefault())
63 SetPosition(aPipeLine->GetPosition());
68 //----------------------------------------------------------------------------
77 myDisplacement[0] = myDisplacement[1] = 0.5;
78 myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
79 myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0;
86 //----------------------------------------------------------------------------
89 ::SetPosition(vtkFloatingPointType thePosition)
91 bool anIsSameValue = VISU::CheckIsSameValue(myPosition, thePosition);
92 anIsSameValue &= (myCondition == 0);
96 myPosition = thePosition;
105 return myAppendPolyData->GetOutput();
108 //----------------------------------------------------------------------------
113 vtkFloatingPointType aPosition = myPosition;
115 vtkFloatingPointType aBounds[6];
116 GetMergedInput()->GetBounds(aBounds);
118 vtkFloatingPointType aDir[3];
123 vtkFloatingPointType aBoundPrj[3];
124 GetBoundProject(aBoundPrj,
128 aPosition = aBoundPrj[0] + aBoundPrj[2] * myDisplacement[0];
134 //----------------------------------------------------------------------------
147 //----------------------------------------------------------------------------
156 //----------------------------------------------------------------------------
161 vtkDataSet* aMergedInput = GetMergedInput();
162 if(VISU::IsQuadraticData(aMergedInput)) // Bug 0020123, note 0005343
163 throw std::runtime_error("Impossible to build presentation");
165 ClearAppendPolyData(myAppendPolyData);
169 vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New();
172 vtkFloatingPointType aBaseBounds[6];
173 GetMergedInput()->GetBounds(aBaseBounds);
175 vtkFloatingPointType aDir[2][3];
180 CutWithPlanes(anAppendPolyData,
189 vtkDataSet *aDataSet = anAppendPolyData->GetOutput();
192 if(aDataSet->GetNumberOfCells() == 0)
193 aDataSet = GetMergedInput();
195 vtkFloatingPointType aBounds[6];
196 aDataSet->GetBounds(aBounds);
202 VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,
211 // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myAppendPolyData.vtk";
212 // VISU::WriteToFile(myAppendPolyData->GetOutput(), aFileName);
214 anAppendPolyData->Delete();
216 //Calculate values for building of table
217 vtkMath::Cross(aDir[0],aDir[1],myDirLn);
218 for (int i = 0; i<3 ; i++) {
219 myRealDirLn[i] = myDirLn[i];
221 myDirLn[i] = -1.0*myDirLn[i];//enk:: correction of bug Bug PAL10401
224 GetBoundProject(myBoundPrjLn,
232 CorrectPnt(myBasePnt,
235 VISU_ScalarMapPL::Update();
239 //----------------------------------------------------------------------------
242 ::CutWithPlanes(vtkAppendPolyData* theAppendPolyData,
243 vtkDataSet* theDataSet,
245 vtkFloatingPointType theDir[3],
246 vtkFloatingPointType theBounds[6],
247 vtkFloatingPointType thePartPosition,
248 int thePartCondition,
249 vtkFloatingPointType theDisplacement)
251 std::vector<vtkFloatingPointType> aPartPosition(1,thePartPosition);
252 std::vector<int> aPartCondition(1,thePartCondition);
253 VISU_CutPlanesPL::CutWithPlanes(theAppendPolyData,
264 //----------------------------------------------------------------------------