VISU::GetIntersection(aDataCellIds,
aGeometryCellMapper,
anIntersection);
-
- vtkIdType aNbTuples = anIntersection.size();
-
- VISU::TObjectId2TupleIdMap aDataCellId2TupleIdMap;
- VISU::GetObjectId2TupleIdMap(aDataCellIds, aDataCellId2TupleIdMap);
+
+ VISU::TObjectId2TupleGaussIdMap aDataCellId2TupleGaussIdMap;
+ VISU::GetObjectId2TupleGaussIdArray(aDataCellIds, aDataCellId2TupleGaussIdMap);
+
+ vtkIdType aNbTuples = 0;
+ for(vtkIdType i = 0;i < anIntersection.size();i++)
+ aNbTuples += aDataCellId2TupleGaussIdMap[anIntersection[i].first].size();
vtkPointSet* aScalarsDataSet = dynamic_cast<vtkPointSet*>(GetScalars());
vtkPoints* aDataPoints = aScalarsDataSet->GetPoints();
vtkIdList *aCellIds = vtkIdList::New();
vtkFloatingPointType aCoords[3];
- for(int aTupleId=0;aTupleId<aNbTuples;aTupleId++){
+ for(int aTupleId=0, aNewTupleId=0; aTupleId<anIntersection.size(); aTupleId++){
VISU::TObjectId& anObjectId = anIntersection[aTupleId];
+ VISU::TCellIdArray aCellIdArray = aDataCellId2TupleGaussIdMap[anObjectId.first];
+
+ for(vtkIdType i = 0; i < aCellIdArray.size();i++) {
+ vtkIdType aCellId = aCellIdArray[i];
+ vtkCell *aCell = GetScalars()->GetCell(aCellId);
+
+ aCellIds->Reset();
+ aCellIds->InsertNextId(aNewTupleId);
+ aNewTupleId++;
- vtkIdType aCellId = aDataCellId2TupleIdMap[anObjectId];
- vtkCell *aCell = GetScalars()->GetCell(aCellId);
-
- aCellIds->Reset();
- aCellIds->InsertNextId(aTupleId);
-
- vtkIdType aCellType = GetScalars()->GetCellType(aCellId);
- vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+ vtkIdType aCellType = GetScalars()->GetCellType(aCellId);
+ vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
- anOutputCellData->CopyData(anInputCellData, aCellId, aNewCellId);
- anOutputPointData->CopyData(anInputPointData, aCellId, aNewCellId);
+ anOutputCellData->CopyData(anInputCellData, aCellId, aNewCellId);
+ anOutputPointData->CopyData(anInputPointData, aCellId, aNewCellId);
- aDataPoints->GetPoint(aCellId, aCoords);
- anOutputPoints->SetPoint(aNewCellId, aCoords);
+ aDataPoints->GetPoint(aCellId, aCoords);
+ anOutputPoints->SetPoint(aNewCellId, aCoords);
+ }
}
}
}
}
}
-
+ //---------------------------------------------------------------
+ void
+ GetObjectId2TupleGaussIdArray(vtkIntArray *theArray,
+ TObjectId2TupleGaussIdMap& theObjectId2TupleGaussIdMap)
+ {
+ theObjectId2TupleGaussIdMap.clear();
+ int* aPointer = theArray->GetPointer(0);
+ int aNbTuples = theArray->GetNumberOfTuples();
+ for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+ int aCellId = *aPointer;
+ TObjectId2TupleGaussIdMap::iterator it = theObjectId2TupleGaussIdMap.find(aCellId);
+ if(it == theObjectId2TupleGaussIdMap.end()){
+ TCellIdArray anIdArray;
+ anIdArray.push_back(aTupleId);
+ theObjectId2TupleGaussIdMap.insert(make_pair(aCellId,anIdArray));
+ }
+ else{
+ (*it).second.push_back(aTupleId);
+ }
+ aPointer += 2;
+ }
+ }
+
//---------------------------------------------------------------
template<class TGetFieldData>
vtkIntArray*
typedef int TTupleId;
typedef std::map<TObjectId, TTupleId> TObjectId2TupleIdMap;
+
+ typedef int TTupleCellID;
+ typedef int GeometryCellID;
+ typedef std::vector<TTupleCellID> TCellIdArray;
+ typedef std::map<GeometryCellID, TCellIdArray> TObjectId2TupleGaussIdMap;
//---------------------------------------------------------------
typedef vtkFieldData* (vtkDataSet::* TGetFieldData)();
void
GetObjectId2TupleIdMap(vtkIntArray *theArray,
TObjectId2TupleIdMap& theObjectId2TupleIdMap);
+
+ void
+ GetObjectId2TupleGaussIdArray(vtkIntArray *theArray,
+ TObjectId2TupleGaussIdMap& theObjectId2TupleGaussIdMap);
template<class TGetFieldData>
vtkIntArray*