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 // SALOME VTKViewer : build VTK viewer into Salome desktop
28 #ifndef VISU_MergeFilterUtilities_H
29 #define VISU_MergeFilterUtilities_H
32 #include <vtkDataSet.h>
36 class vtkUnstructuredGrid;
49 typedef int TEntityId;
50 typedef std::pair<TCellId, TEntityId> TObjectId;
52 typedef std::set<TObjectId> TObjectIdSet;
53 typedef std::vector<TObjectId> TObjectIdArray;
56 typedef std::map<TObjectId, TTupleId> TObjectId2TupleIdMap;
58 typedef int TTupleCellID;
59 typedef int GeometryCellID;
60 typedef std::vector<TTupleCellID> TCellIdArray;
61 typedef std::map<GeometryCellID, TCellIdArray> TObjectId2TupleGaussIdMap;
63 //---------------------------------------------------------------
64 typedef vtkFieldData* (vtkDataSet::* TGetFieldData)();
66 //---------------------------------------------------------------
70 operator()(vtkDataSet* theDataSet)
72 return (vtkFieldData*)(theDataSet->GetCellData());
77 //---------------------------------------------------------------
81 operator()(vtkDataSet* theDataSet)
83 return (vtkFieldData*)(theDataSet->GetPointData());
88 GetObjectId2TupleIdMap(vtkIntArray *theArray,
89 TObjectId2TupleIdMap& theObjectId2TupleIdMap);
92 GetObjectId2TupleGaussIdArray(vtkIntArray *theArray,
93 TObjectId2TupleGaussIdMap& theObjectId2TupleGaussIdMap);
95 template<class TGetFieldData>
97 GetIDMapper(VISU::TFieldList* theFieldList,
98 TGetFieldData theGetFieldData,
99 const char* theFieldName);
101 template<class TGetFieldData>
103 GetIDMapper(vtkDataSet* theIDMapperDataSet,
104 TGetFieldData theGetFieldData,
105 const char* theFieldName);
108 IsDifferent(vtkIntArray *theFirstIDMapper,
109 vtkIntArray *theSecondIDMapper);
112 GetIntersection(vtkIntArray *theFirstIDMapper,
113 vtkIntArray *theSecondIDMapper,
114 TObjectIdArray& theResult);
116 //---------------------------------------------------------------
118 Execute(vtkUnstructuredGrid *theInput,
119 vtkUnstructuredGrid *theOutput,
120 vtkDataSet* theScalarsDataSet,
121 vtkDataSet* theVectorsDataSet,
122 vtkDataSet* theNormalsDataSet,
123 vtkDataSet* theTCoordsDataSet,
124 vtkDataSet* theTensorsDataSet,
125 TFieldList* theFieldList,
126 bool theIsMergingInputs);
129 //---------------------------------------------------------------
131 Execute(vtkPolyData *theInput,
132 vtkPolyData *theOutput,
133 vtkDataSet* theScalarsDataSet,
134 vtkDataSet* theVectorsDataSet,
135 vtkDataSet* theNormalsDataSet,
136 vtkDataSet* theTCoordsDataSet,
137 vtkDataSet* theTensorsDataSet,
138 TFieldList* theFieldList,
139 bool theIsMergingInputs);
141 //---------------------------------------------------------------
145 TFieldNode(const char* name, vtkDataSet* ptr=0)
147 int length = static_cast<int>(strlen(name));
149 this->Name = new char[length+1];
150 strcpy(this->Name, name);
162 const char* GetName()
169 TFieldNode(const TFieldNode&) {}
170 void operator=(const TFieldNode&) {}
175 //---------------------------------------------------------------
186 TFieldNode* node = this->First;
196 void Add(const char* name, vtkDataSet* ptr)
198 TFieldNode* newNode = new TFieldNode(name, ptr);
200 this->First = newNode;
201 this->Last = newNode;
203 this->Last->Next = newNode;
204 this->Last = newNode;
208 friend class TFieldListIterator;
216 //---------------------------------------------------------------
217 class TFieldListIterator
220 TFieldListIterator(TFieldList* list)
227 this->Position = this->List->First;
231 if (this->Position) {
232 this->Position = this->Position->Next;
237 return this->Position ? 0 : 1;
241 return this->Position;
245 TFieldNode* Position;
250 //---------------------------------------------------------------