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 // VISU OBJECT : interactive object for VISU entities implementation
24 // File: VISU_PipeLine.hxx
25 // Author: Alexey PETROV
28 #ifndef VISU_PipeLineUtils_HeaderFile
29 #define VISU_PipeLineUtils_HeaderFile
31 #include "VISUPipeline.hxx"
32 #include "VISU_ConvertorUtils.hxx"
33 #include "VISU_CellDataToPointData.hxx"
35 #include <vtkProperty.h>
36 #include <vtkObjectFactory.h>
37 #include <vtkDataSetMapper.h>
38 #include <vtkUnstructuredGrid.h>
40 #include <vtkPointData.h>
41 #include <vtkCellData.h>
42 #include <vtkPolyData.h>
47 #define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl
50 #define EXCEPT(msg) QString(QString(__FILE__) + "[" + QString::number(__LINE__) + "]::" + msg)
53 #define EXCEPTION(msg) EXCEPT(msg).latin1()
57 class VISU_OpenGLPointSpriteMapper;
61 //----------------------------------------------------------------------------
63 Mul(const vtkFloatingPointType A[3],
64 vtkFloatingPointType b,
65 vtkFloatingPointType C[3]); // C = A * b
68 //----------------------------------------------------------------------------
70 Sub(const vtkFloatingPointType A[3],
71 const vtkFloatingPointType B[3],
72 vtkFloatingPointType C[3]); // C = A - B
75 //----------------------------------------------------------------------------
76 template<class TOutputFilter>
78 CellDataToPoint(TOutputFilter* theOutputFilter,
79 VISU_CellDataToPointData *theCellDataToPointData,
80 vtkDataSet* theDataSet)
83 if(VISU::IsDataOnCells(theDataSet)){
84 theCellDataToPointData->SetInput(theDataSet);
85 theCellDataToPointData->PassCellDataOn();
86 theOutputFilter->SetInput(theCellDataToPointData->GetUnstructuredGridOutput());
88 theOutputFilter->SetInput(theDataSet);
91 //----------------------------------------------------------------------------
92 //! Checks whether the float values are the same or not
93 bool VISU_PIPELINE_EXPORT
94 CheckIsSameValue(vtkFloatingPointType theTarget,
95 vtkFloatingPointType theSource);
97 //! Checks whether the scalar range is the same or not
98 bool VISU_PIPELINE_EXPORT
99 CheckIsSameRange(vtkFloatingPointType* theTarget,
100 vtkFloatingPointType* theSource);
102 //! Customizes vtkMapper::ShallowCopy
103 void VISU_PIPELINE_EXPORT
104 CopyMapper(vtkMapper* theTarget,
105 vtkMapper* theSource,
106 bool theIsCopyInput);
108 //! Customizes vtkDataSetMapper::ShallowCopy
109 void VISU_PIPELINE_EXPORT
110 CopyDataSetMapper(vtkDataSetMapper* theTarget,
111 vtkDataSetMapper* theSource,
112 bool theIsCopyInput);
114 //! Customizes vtkPolyDataMapper::ShallowCopy
115 void VISU_PIPELINE_EXPORT
116 CopyPolyDataMapper(vtkPolyDataMapper* theTarget,
117 vtkPolyDataMapper* theSource,
118 bool theIsCopyInput);
120 //! Customizes VISU_OpenGLPointSpriteMapper::ShallowCopy
121 void VISU_PIPELINE_EXPORT
122 CopyPointSpriteDataMapper(VISU_OpenGLPointSpriteMapper* theTarget,
123 VISU_OpenGLPointSpriteMapper* theSource,
124 bool theIsCopyInput);
127 //----------------------------------------------------------------------------
128 void VISU_PIPELINE_EXPORT
129 ComputeBoundsParam(vtkFloatingPointType theBounds[6],
130 vtkFloatingPointType theDirection[3],
131 vtkFloatingPointType theMinPnt[3],
132 vtkFloatingPointType& theMaxBoundPrj,
133 vtkFloatingPointType& theMinBoundPrj);
136 //----------------------------------------------------------------------------
137 void VISU_PIPELINE_EXPORT
138 DistanceToPosition(vtkFloatingPointType theBounds[6],
139 vtkFloatingPointType theDirection[3],
140 vtkFloatingPointType theDist,
141 vtkFloatingPointType thePos[3]);
144 //----------------------------------------------------------------------------
145 void VISU_PIPELINE_EXPORT
146 PositionToDistance(vtkFloatingPointType theBounds[6],
147 vtkFloatingPointType theDirection[3],
148 vtkFloatingPointType thePos[3],
149 vtkFloatingPointType& theDist);
152 //----------------------------------------------------------------------------
153 bool VISU_PIPELINE_EXPORT
154 IsQuadraticData(vtkDataSet* theDataSet);
156 //----------------------------------------------------------------------------
157 void VISU_PIPELINE_EXPORT
158 ComputeVisibleBounds(vtkDataSet* theDataSet,
159 vtkFloatingPointType theBounds[6]);
161 //----------------------------------------------------------------------------
162 void VISU_PIPELINE_EXPORT
163 ComputeBoxCenter(vtkFloatingPointType theBounds[6], vtkFloatingPointType theCenter[3]);
165 //----------------------------------------------------------------------------
166 double VISU_PIPELINE_EXPORT
167 ComputeBoxDiagonal(vtkFloatingPointType theBounds[6]);