Common/DataModel/vtkUnstructuredGrid.cxx
//----------------------------------------------------------------------------
// Insert/create cell in object by type and list of point ids defining
// cell topology. Using a special input format, this function also support
// polyhedron cells.
Insert/create cell in object by type and list of point ids defining
cell topology. Using a special input format, this function also support
polyhedron cells.
Insert / create cell in object by type and list of point ids defining cell topology . Using a special input format this function also support polyhedron cells .
vtkIdType vtkUnstructuredGrid::InternalInsertNextCell(int type, vtkIdType npts,
                                              const vtkIdType ptIds[])
{
  if (type != VTK_POLYHEDRON)
  {
    this->Connectivity->InsertNextCell(npts,ptIds);
    vtkDebugMacro(<< "insert location "
                  << this->Connectivity->GetInsertLocation(npts));
    this->Locations->InsertNextValue(
      this->Connectivity->GetInsertLocation(npts));
    if ( this->FaceLocations )
    {
      this->FaceLocations->InsertNextValue(-1);
    }
  }
  else
  {
    vtkIdType realnpts;
    if ( ! this->Faces )
    {
      this->Faces = vtkIdTypeArray::New();
      this->Faces->Allocate(this->Types->GetSize());
      this->FaceLocations = vtkIdTypeArray::New();
      this->FaceLocations->Allocate(this->Types->GetSize());
      for(vtkIdType i = 0; i <= this->Types->GetMaxId(); i++)
      {
        this->FaceLocations->InsertNextValue(-1);
      }
    }
    this->Locations->InsertNextValue(this->Connectivity->GetData()->GetMaxId()+1);
    this->FaceLocations->InsertNextValue(this->Faces->GetMaxId()+1);
    vtkUnstructuredGrid::DecomposeAPolyhedronCell(
        npts, ptIds, realnpts, this->Connectivity, this->Faces);
  }
  return this->Types->InsertNextValue(static_cast<unsigned char>(type));
}
vtkIdType vtkUnstructuredGrid :: InternalInsertNextCell ( int type , vtkIdType npts , const vtkIdType ptIds [ ] ) { if ( type != VTK_POLYHEDRON ) { this -> Connectivity -> InsertNextCell ( npts , ptIds ) ; vtkDebugMacro ( << " " << this -> Connectivity -> GetInsertLocation ( npts ) ) ; this -> Locations -> InsertNextValue ( this -> Connectivity -> GetInsertLocation ( npts ) ) ; if ( this -> FaceLocations ) { this -> FaceLocations -> InsertNextValue ( -1 ) ; } } else { vtkIdType realnpts ; if ( ! this -> Faces ) { this -> Faces = vtkIdTypeArray :: New ( ) ; this -> Faces -> Allocate ( this -> Types -> GetSize ( ) ) ; this -> FaceLocations = vtkIdTypeArray :: New ( ) ; this -> FaceLocations -> Allocate ( this -> Types -> GetSize ( ) ) ; for ( vtkIdType i = 0 ; i <= this -> Types -> GetMaxId ( ) ; i ++ ) { this -> FaceLocations -> InsertNextValue ( -1 ) ; } } this -> Locations -> InsertNextValue ( this -> Connectivity -> GetData ( ) -> GetMaxId ( ) + 1 ) ; this -> FaceLocations -> InsertNextValue ( this -> Faces -> GetMaxId ( ) + 1 ) ; vtkUnstructuredGrid :: DecomposeAPolyhedronCell ( npts , ptIds , realnpts , this -> Connectivity , this -> Faces ) ; } return this -> Types -> InsertNextValue ( static_cast < unsigned char > ( type ) ) ; }
Insert/create cell in object by type and list of point ids defining
cell topology.
Insert / create cell in object by type and list of point ids defining cell topology .
// insert connectivity // insert type and storage information // If faces have been created, we need to pad them (we are not creating // a polyhedral cell in this method) // For polyhedron, npts is actually number of faces, ptIds is of format: // (numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...) // We defer allocation for the faces because they are not commonly used and // we only want to allocate when necessary. // FaceLocations must be padded until the current position // insert cell location // insert face location // insert cell connectivity and faces stream