Filters/General/vtkMergeCells.cxx
//-----------------------------------------------------------------------------
// Use an array of global node ids to map all points to
// their new ids in the merged grid.
Use an array of global node ids to map all points to
their new ids in the merged grid.
Use an array of global node ids to map all points to their new ids in the merged grid .
vtkIdType* vtkMergeCells::MapPointsToIdsUsingGlobalIds(vtkDataSet* set)
{
  if (!this->GlobalNodeIdAccessStart(set))
  {
    vtkErrorMacro("global id array is not available");
    return nullptr;
  }
  vtkIdType npoints = set->GetNumberOfPoints();
  vtkIdType* idMap = new vtkIdType[npoints];
  vtkIdType nextNewLocalId = static_cast<vtkIdType>(this->GlobalIdMap->IdTypeMap.size());
  for (vtkIdType oldId = 0; oldId < npoints; oldId++)
  {
    vtkIdType globalId = this->GlobalNodeIdAccessGetId(oldId);
    std::pair<std::map<vtkIdType, vtkIdType>::iterator, bool> inserted =
      this->GlobalIdMap->IdTypeMap.insert(
        std::map<vtkIdType, vtkIdType>::value_type(globalId, nextNewLocalId));
    if (inserted.second)
    {
      idMap[oldId] = nextNewLocalId;
      nextNewLocalId++;
    }
    else
    {
      idMap[oldId] = inserted.first->second;
    }
  }
  return idMap;
}
vtkIdType * vtkMergeCells :: MapPointsToIdsUsingGlobalIds ( vtkDataSet * set ) { if ( ! this -> GlobalNodeIdAccessStart ( set ) ) { vtkErrorMacro ( " " ) ; return nullptr ; } vtkIdType npoints = set -> GetNumberOfPoints ( ) ; vtkIdType * idMap = new vtkIdType [ npoints ] ; vtkIdType nextNewLocalId = static_cast < vtkIdType > ( this -> GlobalIdMap -> IdTypeMap . size ( ) ) ; for ( vtkIdType oldId = 0 ; oldId < npoints ; oldId ++ ) { vtkIdType globalId = this -> GlobalNodeIdAccessGetId ( oldId ) ; std :: pair < std :: map < vtkIdType , vtkIdType > :: iterator , bool > inserted = this -> GlobalIdMap -> IdTypeMap . insert ( std :: map < vtkIdType , vtkIdType > :: value_type ( globalId , nextNewLocalId ) ) ; if ( inserted . second ) { idMap [ oldId ] = nextNewLocalId ; nextNewLocalId ++ ; } else { idMap [ oldId ] = inserted . first -> second ; } } return idMap ; }
Use an array of global node ids to map all points to
their new ids in the merged grid.
Use an array of global node ids to map all points to their new ids in the merged grid .
// map global point ids to ids in the new data set // this is a new global node id // a repeat, it was not inserted