1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // SALOME VTKViewer : build VTK viewer into Salome desktop
26 #ifndef VISU_MergeFilterUtilities_H
27 #define VISU_MergeFilterUtilities_H
30 #include <vtkDataSet.h>
34 class vtkUnstructuredGrid;
47 typedef int TEntityId;
48 typedef std::pair<TCellId, TEntityId> TObjectId;
50 typedef std::set<TObjectId> TObjectIdSet;
51 typedef std::vector<TObjectId> TObjectIdArray;
54 typedef std::map<TObjectId, TTupleId> TObjectId2TupleIdMap;
56 typedef int TTupleCellID;
57 typedef int GeometryCellID;
58 typedef std::vector<TTupleCellID> TCellIdArray;
59 typedef std::map<GeometryCellID, TCellIdArray> TObjectId2TupleGaussIdMap;
61 //---------------------------------------------------------------
62 typedef vtkFieldData* (vtkDataSet::* TGetFieldData)();
64 //---------------------------------------------------------------
68 operator()(vtkDataSet* theDataSet)
70 return (vtkFieldData*)(theDataSet->GetCellData());
75 //---------------------------------------------------------------
79 operator()(vtkDataSet* theDataSet)
81 return (vtkFieldData*)(theDataSet->GetPointData());
86 GetObjectId2TupleIdMap(vtkIntArray *theArray,
87 TObjectId2TupleIdMap& theObjectId2TupleIdMap);
90 GetObjectId2TupleGaussIdArray(vtkIntArray *theArray,
91 TObjectId2TupleGaussIdMap& theObjectId2TupleGaussIdMap);
93 template<class TGetFieldData>
95 GetIDMapper(VISU::TFieldList* theFieldList,
96 TGetFieldData theGetFieldData,
97 const char* theFieldName);
99 template<class TGetFieldData>
101 GetIDMapper(vtkDataSet* theIDMapperDataSet,
102 TGetFieldData theGetFieldData,
103 const char* theFieldName);
106 IsDifferent(vtkIntArray *theFirstIDMapper,
107 vtkIntArray *theSecondIDMapper);
110 GetIntersection(vtkIntArray *theFirstIDMapper,
111 vtkIntArray *theSecondIDMapper,
112 TObjectIdArray& theResult);
114 //---------------------------------------------------------------
116 Execute(vtkUnstructuredGrid *theInput,
117 vtkUnstructuredGrid *theOutput,
118 vtkDataSet* theScalarsDataSet,
119 vtkDataSet* theVectorsDataSet,
120 vtkDataSet* theNormalsDataSet,
121 vtkDataSet* theTCoordsDataSet,
122 vtkDataSet* theTensorsDataSet,
123 TFieldList* theFieldList,
124 bool theIsMergingInputs);
127 //---------------------------------------------------------------
129 Execute(vtkPolyData *theInput,
130 vtkPolyData *theOutput,
131 vtkDataSet* theScalarsDataSet,
132 vtkDataSet* theVectorsDataSet,
133 vtkDataSet* theNormalsDataSet,
134 vtkDataSet* theTCoordsDataSet,
135 vtkDataSet* theTensorsDataSet,
136 TFieldList* theFieldList,
137 bool theIsMergingInputs);
139 //---------------------------------------------------------------
143 TFieldNode(const char* name, vtkDataSet* ptr=0)
145 int length = static_cast<int>(strlen(name));
147 this->Name = new char[length+1];
148 strcpy(this->Name, name);
160 const char* GetName()
167 TFieldNode(const TFieldNode&) {}
168 void operator=(const TFieldNode&) {}
173 //---------------------------------------------------------------
184 TFieldNode* node = this->First;
194 void Add(const char* name, vtkDataSet* ptr)
196 TFieldNode* newNode = new TFieldNode(name, ptr);
198 this->First = newNode;
199 this->Last = newNode;
201 this->Last->Next = newNode;
202 this->Last = newNode;
206 friend class TFieldListIterator;
214 //---------------------------------------------------------------
215 class TFieldListIterator
218 TFieldListIterator(TFieldList* list)
225 this->Position = this->List->First;
229 if (this->Position) {
230 this->Position = this->Position->Next;
235 return this->Position ? 0 : 1;
239 return this->Position;
243 TFieldNode* Position;
248 //---------------------------------------------------------------