Salome HOME
a6026293af0bef7a6a13515413458e9b160e35d0
[modules/visu.git] / src / PIPELINE / VISU_PipeLineUtils.hxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 // File:    VISU_PipeLine.hxx
25 // Author:  Alexey PETROV
26 // Module : VISU
27 //
28 #ifndef VISU_PipeLineUtils_HeaderFile
29 #define VISU_PipeLineUtils_HeaderFile
30
31 #include "VISUPipeline.hxx"
32 #include "VISU_ConvertorUtils.hxx"
33
34 #include <vtkProperty.h>
35 #include <vtkObjectFactory.h>
36 #include <vtkDataSetMapper.h>
37 #include <vtkUnstructuredGrid.h>
38
39 #include <vtkCellDataToPointData.h>
40 #include <vtkCellCenters.h>
41 #include <vtkPointData.h>
42 #include <vtkCellData.h>
43 #include <vtkPolyData.h>
44
45 #include <vtkMath.h>
46
47 #ifndef MESSAGE
48 #define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl
49
50 #undef EXCEPT
51 #define EXCEPT(msg) QString(QString(__FILE__) + "[" + QString::number(__LINE__) + "]::" + msg)
52
53 #undef EXCEPTION
54 #define EXCEPTION(msg) EXCEPT(msg).latin1()
55
56 #endif
57
58 class VISU_OpenGLPointSpriteMapper;
59
60 namespace VISU
61 {
62   //----------------------------------------------------------------------------
63   void
64   Mul(const vtkFloatingPointType A[3], 
65       vtkFloatingPointType b, 
66       vtkFloatingPointType C[3]); // C = A * b
67   
68
69   //----------------------------------------------------------------------------
70   void
71   Sub(const vtkFloatingPointType A[3], 
72       const vtkFloatingPointType B[3], 
73       vtkFloatingPointType C[3]); // C = A - B
74
75
76   //----------------------------------------------------------------------------
77   template<class TOutputFilter> 
78   void
79   CellDataToPoint(TOutputFilter* theOutputFilter, 
80                   vtkCellDataToPointData *theCellDataToPointData,
81                   vtkDataSet* theDataSet)
82
83   {
84     if(VISU::IsDataOnCells(theDataSet)){
85       theCellDataToPointData->SetInput(theDataSet);
86       theCellDataToPointData->PassCellDataOn();
87       theOutputFilter->SetInput(theCellDataToPointData->GetUnstructuredGridOutput());
88     }else
89       theOutputFilter->SetInput(theDataSet);
90   }
91
92   //----------------------------------------------------------------------------
93   //! Checks whether the float values are the same or not
94   bool VISU_PIPELINE_EXPORT
95   CheckIsSameValue(vtkFloatingPointType theTarget,
96                    vtkFloatingPointType theSource);
97
98   //! Checks whether the scalar range is the same or not
99   bool VISU_PIPELINE_EXPORT
100   CheckIsSameRange(vtkFloatingPointType* theTarget,
101                    vtkFloatingPointType* theSource);
102
103   //! Customizes vtkMapper::ShallowCopy
104   void VISU_PIPELINE_EXPORT
105   CopyMapper(vtkMapper* theTarget, 
106              vtkMapper* theSource,
107              bool theIsCopyInput);
108
109   //! Customizes vtkDataSetMapper::ShallowCopy
110   void VISU_PIPELINE_EXPORT
111   CopyDataSetMapper(vtkDataSetMapper* theTarget, 
112                     vtkDataSetMapper* theSource,
113                     bool theIsCopyInput);
114
115   //! Customizes vtkPolyDataMapper::ShallowCopy
116   void VISU_PIPELINE_EXPORT
117   CopyPolyDataMapper(vtkPolyDataMapper* theTarget, 
118                      vtkPolyDataMapper* theSource,
119                      bool theIsCopyInput);
120
121   //! Customizes VISU_OpenGLPointSpriteMapper::ShallowCopy
122   void VISU_PIPELINE_EXPORT
123   CopyPointSpriteDataMapper(VISU_OpenGLPointSpriteMapper* theTarget, 
124                             VISU_OpenGLPointSpriteMapper* theSource,
125                             bool theIsCopyInput);
126
127
128   //----------------------------------------------------------------------------
129   void VISU_PIPELINE_EXPORT
130   ComputeBoundsParam(vtkDataSet* theDataSet,
131                      vtkFloatingPointType theDirection[3], 
132                      vtkFloatingPointType theMinPnt[3],
133                      vtkFloatingPointType& theMaxBoundPrj, 
134                      vtkFloatingPointType& theMinBoundPrj);
135
136
137   //----------------------------------------------------------------------------
138   void VISU_PIPELINE_EXPORT
139   DistanceToPosition(vtkDataSet* theDataSet,
140                      vtkFloatingPointType theDirection[3], 
141                      vtkFloatingPointType theDist, 
142                      vtkFloatingPointType thePos[3]);
143
144
145   //----------------------------------------------------------------------------
146   void VISU_PIPELINE_EXPORT
147   PositionToDistance(vtkDataSet* theDataSet,
148                      vtkFloatingPointType theDirection[3], 
149                      vtkFloatingPointType thePos[3], 
150                      vtkFloatingPointType& theDist);
151
152
153   //----------------------------------------------------------------------------
154   bool VISU_PIPELINE_EXPORT
155   IsQuadraticData(vtkDataSet* theDataSet);
156 }
157
158 #endif
159