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 //----------------------------------------------------------------------------
47 //----------------------------------------------------------------------------
50 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
53 Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
55 if(VISU_CutLinesPL *aPipeLine = dynamic_cast<VISU_CutLinesPL*>(thePipeLine)){
56 SetOrientation(aPipeLine->GetPlaneOrientation(1),
57 aPipeLine->GetRotateX(1),aPipeLine->GetRotateY(1),1);
58 SetDisplacement(aPipeLine->GetDisplacement(1),1);
59 if (aPipeLine->IsDefault())
62 SetPosition(aPipeLine->GetPosition());
67 //----------------------------------------------------------------------------
76 myDisplacement[0] = myDisplacement[1] = 0.5;
77 myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
78 myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0;
85 //----------------------------------------------------------------------------
88 ::SetPosition(vtkFloatingPointType thePosition)
90 bool anIsSameValue = VISU::CheckIsSameValue(myPosition, thePosition);
91 anIsSameValue &= (myCondition == 0);
95 myPosition = thePosition;
104 return myAppendPolyData->GetOutput();
107 //----------------------------------------------------------------------------
112 vtkFloatingPointType aPosition = myPosition;
114 vtkFloatingPointType aBounds[6];
115 GetMergedInput()->GetBounds(aBounds);
117 vtkFloatingPointType aDir[3];
122 vtkFloatingPointType aBoundPrj[3];
123 GetBoundProject(aBoundPrj,
127 aPosition = aBoundPrj[0] + aBoundPrj[2] * myDisplacement[0];
133 //----------------------------------------------------------------------------
146 //----------------------------------------------------------------------------
155 //----------------------------------------------------------------------------
160 vtkDataSet* aMergedInput = GetMergedInput();
161 if(VISU::IsQuadraticData(aMergedInput)) // Bug 0020123, note 0005343
162 throw std::runtime_error("Impossible to build presentation");
164 ClearAppendPolyData(myAppendPolyData);
168 vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New();
171 vtkFloatingPointType aBaseBounds[6];
172 GetMergedInput()->GetBounds(aBaseBounds);
174 vtkFloatingPointType aDir[2][3];
179 CutWithPlanes(anAppendPolyData,
188 vtkDataSet *aDataSet = anAppendPolyData->GetOutput();
191 if(aDataSet->GetNumberOfCells() == 0)
192 aDataSet = GetMergedInput();
194 vtkFloatingPointType aBounds[6];
195 aDataSet->GetBounds(aBounds);
201 VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,
210 // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myAppendPolyData.vtk";
211 // VISU::WriteToFile(myAppendPolyData->GetOutput(), aFileName);
213 anAppendPolyData->Delete();
215 //Calculate values for building of table
216 vtkMath::Cross(aDir[0],aDir[1],myDirLn);
217 for (int i = 0; i<3 ; i++) {
218 myRealDirLn[i] = myDirLn[i];
220 myDirLn[i] = -1.0*myDirLn[i];//enk:: correction of bug Bug PAL10401
223 GetBoundProject(myBoundPrjLn,
231 CorrectPnt(myBasePnt,
234 VISU_ScalarMapPL::Update();
238 //----------------------------------------------------------------------------
241 ::CutWithPlanes(vtkAppendPolyData* theAppendPolyData,
242 vtkDataSet* theDataSet,
244 vtkFloatingPointType theDir[3],
245 vtkFloatingPointType theBounds[6],
246 vtkFloatingPointType thePartPosition,
247 int thePartCondition,
248 vtkFloatingPointType theDisplacement)
250 std::vector<vtkFloatingPointType> aPartPosition(1,thePartPosition);
251 std::vector<int> aPartCondition(1,thePartCondition);
252 VISU_CutPlanesPL::CutWithPlanes(theAppendPolyData,
263 //----------------------------------------------------------------------------