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 #include "VISU_MergeFilterUtilities.hxx"
30 #include <vtkCellData.h>
31 #include <vtkObjectFactory.h>
32 #include <vtkPointData.h>
33 #include <vtkPolyData.h>
34 #include <vtkRectilinearGrid.h>
35 #include <vtkStructuredGrid.h>
36 #include <vtkStructuredPoints.h>
37 #include <vtkUnstructuredGrid.h>
39 #include <vtkIdList.h>
47 #if !defined(VTK_XVERSION)
48 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
56 //---------------------------------------------------------------
57 template<class TDataSet>
60 CopyDataOnCells(TDataSet *theInput,
61 vtkIntArray *theGeometryCellMapper,
62 vtkIntArray *theDataCellMapper,
63 vtkDataSet* theScalarsDataSet,
64 vtkDataSet* theVectorsDataSet,
65 vtkDataSet* theNormalsDataSet,
66 vtkDataSet* theTCoordsDataSet,
67 vtkDataSet* theTensorsDataSet,
68 VISU::TFieldList* theFieldList,
71 if(IsDifferent(theGeometryCellMapper, theDataCellMapper)){
72 TObjectIdArray anIntersection;
73 GetIntersection(theGeometryCellMapper,
77 TObjectId2TupleIdMap aGeomObjectId2TupleIdMap;
78 GetObjectId2TupleIdMap(theGeometryCellMapper, aGeomObjectId2TupleIdMap);
80 TObjectId2TupleIdMap aDataObjectId2TupleIdMap;
81 GetObjectId2TupleIdMap(theDataCellMapper, aDataObjectId2TupleIdMap);
83 vtkCellData *aCellData = theScalarsDataSet->GetCellData();
84 vtkCellData *anOutputCellData = theOutput->GetCellData();
85 anOutputCellData->CopyAllocate(aCellData);
87 if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet)
88 anOutputCellData->CopyVectorsOff();
90 vtkIdType aNbTuples = anIntersection.size();
91 theOutput->Allocate(aNbTuples);
92 vtkIdList *aCellIds = vtkIdList::New();
93 for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
94 TObjectId& anObjectId = anIntersection[aTupleId];
95 vtkIdType aCellId = aGeomObjectId2TupleIdMap[anObjectId];
96 vtkCell *aCell = theInput->GetCell(aCellId);
98 vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
99 for(vtkIdType anId = 0; anId < aNbPointIds; anId++)
100 aCellIds->InsertNextId(aCell->GetPointIds()->GetId(anId));
101 vtkIdType aCellType = theInput->GetCellType(aCellId);
102 vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
103 vtkIdType aDataCellId = aDataObjectId2TupleIdMap[anObjectId];
104 anOutputCellData->CopyData(aCellData, aDataCellId, aNewCellId);
108 theOutput->SetPoints(theInput->GetPoints());
111 theOutput->CopyStructure(theInput);
112 theOutput->GetCellData()->ShallowCopy(theScalarsDataSet->GetCellData());
114 theOutput->GetPointData()->ShallowCopy(theInput->GetPointData());
116 //If need, copy vectors data.
117 if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet){
118 bool isVectorsOnCells = theVectorsDataSet->GetCellData()->GetVectors() != NULL;
119 bool isVectorsDataOnPoints = theVectorsDataSet->GetPointData()->GetVectors() != NULL;
120 if(isVectorsOnCells) {
121 CopyVectorsOnCells(theVectorsDataSet,theOutput);
123 else if(isVectorsDataOnPoints){
124 CopyVectorsOnPoints(theVectorsDataSet,theOutput);
129 void CopyVectorsOnCells(vtkDataSet *theVectorsDataSet,
130 vtkDataSet *theOutput)
132 vtkDataArray *anInputVectors = theVectorsDataSet->GetCellData()->GetVectors();
133 vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
135 //Clear output vector data
136 theOutput->GetCellData()->SetVectors(NULL);
139 vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
141 "VISU_CELLS_MAPPER");
143 vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
145 "VISU_CELLS_MAPPER");
147 TObjectIdArray anIntersection;
148 GetIntersection(anOutputIDMapper,
152 vtkIdType aNbTuples = anIntersection.size();
153 anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
154 anOutputVectors->SetNumberOfTuples(aNbTuples);
155 theOutput->GetCellData()->SetVectors(anOutputVectors);
156 anOutputVectors->Delete();
158 TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
159 GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
161 TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
162 GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
164 for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
165 TObjectId &anObjectId = anIntersection[iTupleId];
166 vtkIdType anOutputCellId = anOutputObjectId2TupleIdMap[anObjectId];
167 vtkIdType anInputCellId = anInputObjectId2TupleIdMap[anObjectId];
168 anOutputVectors->SetTuple(anOutputCellId,anInputVectors->GetTuple(anInputCellId));
172 //---------------------------------------------------------------
173 template<class TDataSet>
175 CopyDataOnPoints(TDataSet *theInput,
176 vtkIntArray *theGeometryPointMapper,
177 vtkIntArray *theDataPointMapper,
178 vtkDataSet* theScalarsDataSet,
179 vtkDataSet* theVectorsDataSet,
180 vtkDataSet* theNormalsDataSet,
181 vtkDataSet* theTCoordsDataSet,
182 vtkDataSet* theTensorsDataSet,
183 VISU::TFieldList* theFieldList,
186 if(IsDifferent(theGeometryPointMapper, theDataPointMapper)){
187 TObjectId2TupleIdMap aDataObjectId2PointIdMap;
188 GetObjectId2TupleIdMap(theDataPointMapper, aDataObjectId2PointIdMap);
190 vtkCellData *aCellData = theInput->GetCellData();
191 vtkCellData *anOutputCellData = theOutput->GetCellData();
192 anOutputCellData->CopyAllocate(aCellData);
194 vtkIdList *aCellIds = vtkIdList::New();
195 int aNbCells = theInput->GetNumberOfCells();
196 theOutput->Allocate(aNbCells);
197 for(int aCellId = 0; aCellId < aNbCells; aCellId++){
199 vtkCell *aCell = theInput->GetCell(aCellId);
200 vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
201 for(vtkIdType anId = 0; anId < aNbPointIds; anId++){
202 vtkIdType aPointId = aCell->GetPointIds()->GetId(anId);
203 int* aPointer = theGeometryPointMapper->GetPointer(aPointId * 2);
204 TCellId aCellId = *aPointer;
205 TEntityId anEntityId = *(aPointer + 1);
206 TObjectId anObjectId(aCellId, anEntityId);
207 TObjectId2TupleIdMap::iterator anIter = aDataObjectId2PointIdMap.find(anObjectId);
208 if(anIter != aDataObjectId2PointIdMap.end()){
209 aPointId = anIter->second;
210 aCellIds->InsertNextId(aPointId);
212 goto PASS_INSERT_NEXT_CELL;
215 vtkIdType aCellType = theInput->GetCellType(aCellId);
216 vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
217 anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
219 PASS_INSERT_NEXT_CELL:
224 // Copy geometry points
225 // 1. Create vtkPoints instance of the same data type
226 vtkPointSet* aScalarsDataSet = dynamic_cast<vtkPointSet*>(theScalarsDataSet);
227 vtkPoints* anGeometryPoints = theInput->GetPoints();
228 vtkPoints* aDataPoints = aScalarsDataSet->GetPoints();
229 vtkPoints* anOutputPoints = vtkPoints::New(aDataPoints->GetDataType());
230 theOutput->SetPoints(anOutputPoints);
231 anOutputPoints->Delete();
233 // 2. Perform mapping of geometry points
234 TObjectId2TupleIdMap aGeomObjectId2TupleIdMap;
235 GetObjectId2TupleIdMap(theGeometryPointMapper, aGeomObjectId2TupleIdMap);
237 // 3. Loop over all data points
238 int aNbDataPoints = theDataPointMapper->GetNumberOfTuples();
239 anOutputPoints->SetNumberOfPoints(aNbDataPoints);
240 for(int aPointId = 0; aPointId < aNbDataPoints; aPointId++){
241 int* aPointer = theDataPointMapper->GetPointer(aPointId * 2);
242 TCellId aCellId = *aPointer;
243 TEntityId anEntityId = *(aPointer + 1);
244 TObjectId anObjectId(aCellId, anEntityId);
245 TObjectId2TupleIdMap::iterator anIter = aGeomObjectId2TupleIdMap.find(anObjectId);
246 if(anIter != aGeomObjectId2TupleIdMap.end()){
247 // If the point exists in the geometry put it to output
248 int aGeometryPointId = anIter->second;
249 vtkFloatingPointType aCoords[3];
250 anGeometryPoints->GetPoint(aGeometryPointId, aCoords);
251 anOutputPoints->SetPoint(aPointId, aCoords);
253 // If no, the point from data should be used
254 vtkFloatingPointType aCoords[3];
255 aDataPoints->GetPoint(aPointId, aCoords);
256 anOutputPoints->SetPoint(aPointId, aCoords);
260 theOutput->CopyStructure(theInput);
261 theOutput->GetCellData()->ShallowCopy(theInput->GetCellData());
263 theOutput->GetPointData()->ShallowCopy(theScalarsDataSet->GetPointData());
265 //If need, copy vectors data.
266 if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet){
267 bool isVectorsOnCells = theVectorsDataSet->GetCellData()->GetVectors() != NULL;
268 bool isVectorsDataOnPoints = theVectorsDataSet->GetPointData()->GetVectors() != NULL;
270 //Merge cells if need
272 if(!IsDifferent(theGeometryPointMapper, theDataPointMapper)){
273 vtkIntArray* theGeometryCellMapper = GetIDMapper(theVectorsDataSet,
275 "VISU_CELLS_MAPPER");
277 vtkIntArray* theDataCellMapper = GetIDMapper(theScalarsDataSet,
279 "VISU_CELLS_MAPPER");
282 if(IsDifferent(theGeometryCellMapper, theDataCellMapper)){
283 TObjectIdArray anIntersection;
285 GetIntersection(theGeometryCellMapper,
289 TObjectId2TupleIdMap aGeomObjectId2TupleIdMap;
290 GetObjectId2TupleIdMap(theGeometryCellMapper, aGeomObjectId2TupleIdMap);
292 TObjectId2TupleIdMap aDataObjectId2TupleIdMap;
293 GetObjectId2TupleIdMap(theDataCellMapper, aDataObjectId2TupleIdMap);
295 vtkCellData *aCellData = theScalarsDataSet->GetCellData();
296 vtkCellData *anOutputCellData = theOutput->GetCellData();
297 anOutputCellData->CopyAllocate(aCellData);
299 vtkIdType aNbTuples = anIntersection.size();
300 theOutput->Allocate(aNbTuples);
301 vtkIdList *aCellIds = vtkIdList::New();
302 for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
303 TObjectId& anObjectId = anIntersection[aTupleId];
304 vtkIdType aCellId = aGeomObjectId2TupleIdMap[anObjectId];
305 vtkCell *aCell = theInput->GetCell(aCellId);
307 vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
308 for(vtkIdType anId = 0; anId < aNbPointIds; anId++)
309 aCellIds->InsertNextId(aCell->GetPointIds()->GetId(anId));
310 vtkIdType aCellType = theInput->GetCellType(aCellId);
311 vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
312 vtkIdType aDataCellId = aDataObjectId2TupleIdMap[anObjectId];
313 anOutputCellData->CopyData(aCellData, aDataCellId, aNewCellId);
320 if(isVectorsOnCells) {
321 CopyVectorsOnCells(theVectorsDataSet,theOutput);
323 else if(isVectorsDataOnPoints){
324 CopyVectorsOnPoints(theVectorsDataSet,theOutput);
329 void CopyVectorsOnPoints(vtkDataSet *theVectorsDataSet,
330 vtkDataSet *theOutput)
332 vtkDataArray *anInputVectors = theVectorsDataSet->GetPointData()->GetVectors();
334 //Clear output vector data
335 theOutput->GetPointData()->SetVectors(NULL);
337 vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
340 vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
342 "VISU_POINTS_MAPPER");
344 vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
346 "VISU_POINTS_MAPPER");
347 TObjectIdArray anIntersection;
349 GetIntersection(anOutputIDMapper,
353 vtkIdType aNbTuples = anIntersection.size();
354 anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
355 anOutputVectors->SetNumberOfTuples(aNbTuples);
359 TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
360 GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
362 TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
363 GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
365 for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
366 TObjectId& anObjectId = anIntersection[iTupleId];
367 vtkIdType anOutputPointId = anOutputObjectId2TupleIdMap[anObjectId];
368 vtkIdType anInputPointId = anInputObjectId2TupleIdMap[anObjectId];
369 anOutputVectors->SetTuple(anOutputPointId,anInputVectors->GetTuple(anInputPointId));
372 theOutput->GetPointData()->SetVectors(anOutputVectors);
373 anOutputVectors->Delete();
377 //---------------------------------------------------------------
378 typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)();
379 #if (VTK_XVERSION < 0x050100)
380 typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*);
382 typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkAbstractArray*);
383 typedef int (vtkDataSetAttributes::* TSetDataAttribute)(vtkDataArray*);
387 #if (VTK_XVERSION >= 0x050100)
390 CopyArray(vtkDataArray* theDataArray,
391 vtkDataSetAttributes* theOutput,
392 TSetDataAttribute theSetAttribute,
393 vtkIdType theFixedNbTuples)
396 vtkIdType aNbTuples = theDataArray->GetNumberOfTuples();
397 if(theFixedNbTuples == aNbTuples)
398 (theOutput->*theSetAttribute)(theDataArray);
405 CopyArray(vtkDataArray* theDataArray,
406 vtkDataSetAttributes* theOutput,
407 TSetAttribute theSetAttribute,
408 vtkIdType theFixedNbTuples)
411 vtkIdType aNbTuples = theDataArray->GetNumberOfTuples();
412 if(theFixedNbTuples == aNbTuples)
413 (theOutput->*theSetAttribute)(theDataArray);
418 //---------------------------------------------------------------
421 CopyAttribute(vtkDataSetAttributes* theInput,
422 TGetAttribute theGetAttribute,
423 vtkDataSetAttributes* theOutput,
424 #if (VTK_XVERSION < 0x050100)
425 TSetAttribute theSetAttribute,
427 TSetDataAttribute theSetAttribute,
429 vtkIdType theFixedNbTuples)
431 CopyArray((theInput->*theGetAttribute)(),
432 theOutput, theSetAttribute,
437 //---------------------------------------------------------------
440 CopyDataSetAttribute(vtkDataSet *theInput,
441 TGetAttribute theGetAttribute,
442 vtkDataSet *theOutput,
443 #if (VTK_XVERSION < 0x050100)
444 TSetAttribute theSetAttribute,
446 TSetDataAttribute theSetAttribute,
448 vtkIdType theNbPoints,
449 vtkIdType theNbCells)
451 CopyAttribute(theInput->GetPointData(),
453 theOutput->GetPointData(),
456 CopyAttribute(theInput->GetCellData(),
458 theOutput->GetCellData(),
464 //---------------------------------------------------------------
467 CopyField(vtkDataSetAttributes* theInput,
468 const char* theFieldName,
469 vtkDataSetAttributes* theOutput,
470 vtkIdType theFixedNbTuples)
472 CopyArray(theInput->GetArray(theFieldName),
474 #if (VTK_XVERSION < 0x050100)
475 &vtkDataSetAttributes::AddArray,
477 &vtkFieldData::AddArray,
483 //---------------------------------------------------------------
486 CopyDataSetField(vtkDataSet* theInput,
487 const char* theFieldName,
488 vtkDataSet* theOutput,
489 vtkIdType theNbPoints,
490 vtkIdType theNbCells)
493 CopyField(theInput->GetPointData(),
495 theOutput->GetPointData(),
497 CopyField(theInput->GetCellData(),
499 theOutput->GetCellData(),
504 //---------------------------------------------------------------
506 BasicExecute(vtkDataSet *theInput,
507 vtkDataSet* theScalarsDataSet,
508 vtkDataSet* theVectorsDataSet,
509 vtkDataSet* theNormalsDataSet,
510 vtkDataSet* theTCoordsDataSet,
511 vtkDataSet* theTensorsDataSet,
512 VISU::TFieldList* theFieldList,
513 vtkDataSet *theOutput)
515 theOutput->CopyStructure(theInput);
517 vtkIdType aNbPoints = theInput->GetNumberOfPoints();
518 vtkIdType aNbCells = theInput->GetNumberOfCells();
520 // merge data only if it is consistent
521 if(theScalarsDataSet)
522 CopyDataSetAttribute(theScalarsDataSet,
523 &vtkDataSetAttributes::GetScalars,
525 &vtkDataSetAttributes::SetScalars,
529 if(theVectorsDataSet)
530 CopyDataSetAttribute(theVectorsDataSet,
531 &vtkDataSetAttributes::GetVectors,
533 &vtkDataSetAttributes::SetVectors,
537 if(theNormalsDataSet)
538 CopyDataSetAttribute(theNormalsDataSet,
539 &vtkDataSetAttributes::GetNormals,
541 &vtkDataSetAttributes::SetNormals,
545 if(theTCoordsDataSet)
546 CopyDataSetAttribute(theTCoordsDataSet,
547 &vtkDataSetAttributes::GetTCoords,
549 &vtkDataSetAttributes::SetTCoords,
553 if(theTensorsDataSet)
554 CopyDataSetAttribute(theTensorsDataSet,
555 &vtkDataSetAttributes::GetTensors,
557 &vtkDataSetAttributes::SetTensors,
561 VISU::TFieldListIterator anIter(theFieldList);
562 for(anIter.Begin(); !anIter.End() ; anIter.Next()){
563 vtkDataSet *aDataSet = anIter.Get()->Ptr;
564 const char* aFieldName = anIter.Get()->GetName();
565 CopyDataSetField(aDataSet,
574 //---------------------------------------------------------------
575 template<class TDataSet>
577 Execute(TDataSet *theInput,
578 vtkDataSet* theScalarsDataSet,
579 vtkDataSet* theVectorsDataSet,
580 vtkDataSet* theNormalsDataSet,
581 vtkDataSet* theTCoordsDataSet,
582 vtkDataSet* theTensorsDataSet,
583 VISU::TFieldList* theFieldList,
584 bool theIsMergingInputs,
587 if(theIsMergingInputs){
588 vtkCellData *aCellData = theInput->GetCellData();
589 if(vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER")){
590 bool anIsDataOnCells = false;
591 if(vtkDataSet* aDataSet = theScalarsDataSet)
592 if(vtkCellData* aCellData = aDataSet->GetCellData())
593 anIsDataOnCells = (aCellData->GetArray("VISU_FIELD") != NULL);
595 vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper);
596 vtkIntArray* aDataCellMapper = GetIDMapper(theFieldList,
598 "VISU_CELLS_MAPPER");
599 CopyDataOnCells(theInput,
610 vtkPointData *aPointData = theInput->GetPointData();
611 vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
612 vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
613 vtkIntArray* aDataPointMapper = GetIDMapper(theFieldList,
615 "VISU_POINTS_MAPPER");
616 CopyDataOnPoints(theInput,
617 aGeometryPointMapper,
629 BasicExecute(theInput,
645 //---------------------------------------------------------------
647 GetObjectIdSet(vtkIntArray *theArray,
648 TObjectIdSet& theObjectIdSet)
650 theObjectIdSet.clear();
651 int aMaxId = theArray->GetMaxId();
652 int* aPointer = theArray->GetPointer(0);
653 int* anEndPointer = theArray->GetPointer(aMaxId + 1);
654 for(; aPointer != anEndPointer; aPointer += 2){
655 TCellId aCellId = *aPointer;
656 TEntityId anEntityId = *(aPointer + 1);
657 TObjectId anObjectId(aCellId, anEntityId);
658 theObjectIdSet.insert(anObjectId);
663 //---------------------------------------------------------------
665 GetObjectId2TupleIdMap(vtkIntArray *theArray,
666 TObjectId2TupleIdMap& theObjectId2TupleIdMap)
668 theObjectId2TupleIdMap.clear();
669 int* aPointer = theArray->GetPointer(0);
670 int aNbTuples = theArray->GetNumberOfTuples();
671 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++, aPointer += 2){
672 TCellId aCellId = *aPointer;
673 TEntityId anEntityId = *(aPointer + 1);
674 TObjectId anObjectId(aCellId, anEntityId);
675 theObjectId2TupleIdMap[anObjectId] = aTupleId;
679 //---------------------------------------------------------------
681 GetObjectId2TupleGaussIdArray(vtkIntArray *theArray,
682 TObjectId2TupleGaussIdMap& theObjectId2TupleGaussIdMap)
684 theObjectId2TupleGaussIdMap.clear();
685 int* aPointer = theArray->GetPointer(0);
686 int aNbTuples = theArray->GetNumberOfTuples();
687 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
688 int aCellId = *aPointer;
689 TObjectId2TupleGaussIdMap::iterator it = theObjectId2TupleGaussIdMap.find(aCellId);
690 if(it == theObjectId2TupleGaussIdMap.end()){
691 TCellIdArray anIdArray;
692 anIdArray.push_back(aTupleId);
693 theObjectId2TupleGaussIdMap.insert(make_pair(aCellId,anIdArray));
696 (*it).second.push_back(aTupleId);
702 //---------------------------------------------------------------
703 template<class TGetFieldData>
705 GetIDMapper(VISU::TFieldList* theFieldList,
706 TGetFieldData theGetFieldData,
707 const char* theFieldName)
709 VISU::TFieldListIterator anIter(theFieldList);
710 for(anIter.Begin(); !anIter.End() ; anIter.Next()){
711 const char* aFieldName = anIter.Get()->GetName();
712 if(strcmp(aFieldName, theFieldName) == 0){
713 vtkDataSet* aDataSet = anIter.Get()->Ptr;
714 vtkFieldData *aFieldData = theGetFieldData(aDataSet);
715 vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName);
716 return dynamic_cast<vtkIntArray*>(anIDMapper);
723 //---------------------------------------------------------------
724 template<class TGetFieldData>
726 GetIDMapper(vtkDataSet* theIDMapperDataSet,
727 TGetFieldData theGetFieldData,
728 const char* theFieldName)
730 vtkFieldData *aFieldData = theGetFieldData(theIDMapperDataSet);
731 vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName);
732 return dynamic_cast<vtkIntArray*>(anIDMapper);
736 //---------------------------------------------------------------
738 IsDifferent(vtkIntArray *theFirstIDMapper,
739 vtkIntArray *theSecondIDMapper)
741 vtkIdType aFirstNbTuples = theFirstIDMapper->GetNumberOfTuples();
742 vtkIdType aSecondNbTuples = theSecondIDMapper->GetNumberOfTuples();
743 if(aFirstNbTuples != aSecondNbTuples)
746 int aMaxId = theFirstIDMapper->GetMaxId();
747 int* aFirstPointer = theFirstIDMapper->GetPointer(0);
748 int* aSecondPointer = theSecondIDMapper->GetPointer(0);
749 for(int anId = 0; anId <= aMaxId; anId++){
750 if(*aFirstPointer++ != *aSecondPointer++)
758 //---------------------------------------------------------------
760 GetIntersection(vtkIntArray *theFirstIDMapper,
761 vtkIntArray *theSecondIDMapper,
762 TObjectIdArray& theResult)
764 TObjectIdSet aFirstObjectIdSet;
765 GetObjectIdSet(theFirstIDMapper, aFirstObjectIdSet);
767 TObjectIdSet aSecondObjectIdSet;
768 GetObjectIdSet(theSecondIDMapper, aSecondObjectIdSet);
770 size_t aMaxLength = std::max(aFirstObjectIdSet.size(), aSecondObjectIdSet.size());
771 theResult.resize(aMaxLength);
772 TObjectIdArray::iterator anArrayIter = theResult.begin();
773 anArrayIter = std::set_intersection(aFirstObjectIdSet.begin(),
774 aFirstObjectIdSet.end(),
775 aSecondObjectIdSet.begin(),
776 aSecondObjectIdSet.end(),
778 theResult.erase(anArrayIter, theResult.end());
781 //---------------------------------------------------------------
783 Execute(vtkUnstructuredGrid *theInput,
784 vtkUnstructuredGrid *theOutput,
785 vtkDataSet* theScalarsDataSet,
786 vtkDataSet* theVectorsDataSet,
787 vtkDataSet* theNormalsDataSet,
788 vtkDataSet* theTCoordsDataSet,
789 vtkDataSet* theTensorsDataSet,
790 TFieldList* theFieldList,
791 bool theIsMergingInputs)
793 return ::Execute(theInput,
805 //---------------------------------------------------------------
807 Execute(vtkPolyData *theInput,
808 vtkPolyData *theOutput,
809 vtkDataSet* theScalarsDataSet,
810 vtkDataSet* theVectorsDataSet,
811 vtkDataSet* theNormalsDataSet,
812 vtkDataSet* theTCoordsDataSet,
813 vtkDataSet* theTensorsDataSet,
814 TFieldList* theFieldList,
815 bool theIsMergingInputs)
817 return ::Execute(theInput,