// $Header$
//
#include "VISU_MergeFilterUtilities.hxx"
+#include "VISU_ConvertorUtils.hxx"
#include <vtkCellData.h>
#include <vtkObjectFactory.h>
vtkIdList *aCellIds = vtkIdList::New();
int aNbCells = theInput->GetNumberOfCells();
theOutput->Allocate(aNbCells);
- for(int aCellId = 0; aCellId < aNbCells; aCellId++){
- aCellIds->Reset();
- vtkCell *aCell = theInput->GetCell(aCellId);
- vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
- for(vtkIdType anId = 0; anId < aNbPointIds; anId++){
- vtkIdType aPointId = aCell->GetPointIds()->GetId(anId);
- int* aPointer = theGeometryPointMapper->GetPointer(aPointId * 2);
- TCellId aCellId = *aPointer;
- TEntityId anEntityId = *(aPointer + 1);
- TObjectId anObjectId(aCellId, anEntityId);
- TObjectId2TupleIdMap::iterator anIter = aDataObjectId2PointIdMap.find(anObjectId);
- if(anIter != aDataObjectId2PointIdMap.end()){
- aPointId = anIter->second;
- aCellIds->InsertNextId(aPointId);
- }else
- goto PASS_INSERT_NEXT_CELL;
- }
- {
- vtkIdType aCellType = theInput->GetCellType(aCellId);
- vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
- anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
- }
- PASS_INSERT_NEXT_CELL:
- continue;
- }
- aCellIds->Delete();
+ if(!VISU::IsElnoData(theScalarsDataSet)) {
+ for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+ aCellIds->Reset();
+ vtkCell *aCell = theInput->GetCell(aCellId);
+ vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
+ for(vtkIdType anId = 0; anId < aNbPointIds; anId++){
+ vtkIdType aPointId = aCell->GetPointIds()->GetId(anId);
+ int* aPointer = theGeometryPointMapper->GetPointer(aPointId * 2);
+ TCellId aCellId = *aPointer;
+ TEntityId anEntityId = *(aPointer + 1);
+ TObjectId anObjectId(aCellId, anEntityId);
+ TObjectId2TupleIdMap::iterator anIter = aDataObjectId2PointIdMap.find(anObjectId);
+ if(anIter != aDataObjectId2PointIdMap.end()){
+ aPointId = anIter->second;
+ aCellIds->InsertNextId(aPointId);
+ }else
+ goto PASS_INSERT_NEXT_CELL;
+ }
+ {
+ vtkIdType aCellType = theInput->GetCellType(aCellId);
+ vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+ anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
+ }
+ PASS_INSERT_NEXT_CELL:
+ continue;
+ }
+ aCellIds->Delete();
+ } else {
+ vtkIntArray* anInputCellIDMapper = GetIDMapper(theInput,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+ vtkIntArray* anScalarsCellIDMapper = GetIDMapper(theScalarsDataSet,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+ vtkIntArray *anInputArray = dynamic_cast<vtkIntArray*>(anInputCellIDMapper);
+ int aNbComp = anInputArray->GetNumberOfComponents();
+ TCellId inCellObjId = -1;
+ TEntityId inEntityId = -1;
+ TCellId scalarCellVtkId = -1;
+ vtkCell* inputCell = NULL;
+ vtkCell* scalarCell = NULL;
+
+ for(int aCellId = 0; aCellId < aNbCells; aCellId++) {
+ aCellIds->Reset();
+ int* anInPointer = anInputArray->GetPointer(aCellId*aNbComp);
+ inCellObjId = *anInPointer;
+ inEntityId = *(anInPointer+1);
+ if(inCellObjId == -1) continue;
+ scalarCellVtkId = VISU::GetVTKID(anScalarsCellIDMapper,inCellObjId,inEntityId);
+ if(scalarCellVtkId == -1) continue;
+ scalarCell = theScalarsDataSet->GetCell(scalarCellVtkId);
+ inputCell = theInput->GetCell(aCellId);
+ vtkIdType aCellType = inputCell->GetCellType();
+ if(scalarCell->GetCellType() == aCellType) {
+ aCellIds->DeepCopy(scalarCell->PointIds);
+ vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+ anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
+ }
+ }
+ }
// Copy geometry points
// 1. Create vtkPoints instance of the same data type