Common/DataModel/vtkUnstructuredGrid.cxx
//----------------------------------------------------------------------------
// Insert/create cell in object by type and list of point and face ids
// defining cell topology. This method is meant for face-explicit cells (e.g.
// polyhedron).
Insert/create cell in object by type and list of point and face ids
defining cell topology. This method is meant for face-explicit cells .
Insert / create cell in object by type and list of point and face ids defining cell topology . This method is meant for face - explicit cells .
vtkIdType vtkUnstructuredGrid::
InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType pts[],
               vtkIdType nfaces, const vtkIdType faces[])
{
  if (type != VTK_POLYHEDRON)
  {
    return this->InsertNextCell(type, npts, pts);
  }
  this->Connectivity->InsertNextCell(npts,pts);
  this->Locations->InsertNextValue(
    this->Connectivity->GetInsertLocation(npts));
  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->FaceLocations->InsertNextValue(
    this->Faces->GetMaxId() + 1);
  this->Faces->InsertNextValue(nfaces);
  for (int faceNum=0; faceNum < nfaces; ++faceNum)
  {
    npts = faces[0];
    this->Faces->InsertNextValue(npts);
    for (vtkIdType i=1; i <= npts; ++i)
    {
      this->Faces->InsertNextValue(faces[i]);
    }
    faces += npts + 1;
  } 
  return this->Types->InsertNextValue(static_cast<unsigned char>(type));
}
vtkIdType vtkUnstructuredGrid :: InternalInsertNextCell ( int type , vtkIdType npts , const vtkIdType pts [ ] , vtkIdType nfaces , const vtkIdType faces [ ] ) { if ( type != VTK_POLYHEDRON ) { return this -> InsertNextCell ( type , npts , pts ) ; } this -> Connectivity -> InsertNextCell ( npts , pts ) ; this -> Locations -> InsertNextValue ( this -> Connectivity -> GetInsertLocation ( npts ) ) ; 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 -> FaceLocations -> InsertNextValue ( this -> Faces -> GetMaxId ( ) + 1 ) ; this -> Faces -> InsertNextValue ( nfaces ) ; for ( int faceNum = 0 ; faceNum < nfaces ; ++ faceNum ) { npts = faces [ 0 ] ; this -> Faces -> InsertNextValue ( npts ) ; for ( vtkIdType i = 1 ; i <= npts ; ++ i ) { this -> Faces -> InsertNextValue ( faces [ i ] ) ; } faces += npts + 1 ; } return this -> Types -> InsertNextValue ( static_cast < unsigned char > ( type ) ) ; }
Insert/create cell in object by type and list of point and face ids
defining cell topology.
Insert / create cell in object by type and list of point and face ids defining cell topology .
// Insert connectivity (points that make up polyhedron) // Insert location of cell in connectivity array // Now insert faces; allocate storage if necessary. // 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 // Okay the faces go in //for all faces