Commit 3046c0a6 authored by Todd Martin's avatar Todd Martin

Add size hints and const to [in] arrays

The abstract public methods InsertNextCell()/ReplaceCell() were replaced with non-virtual methods which call protected virtual methods, in order to eliminate the need for duplicate annotations and source code documentation throughout the class hierarchy.
parent bba264b6
......@@ -262,14 +262,14 @@ MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdList* vtkNotUsed(ptIds
}
vtkIdType
MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts), vtkIdType *vtkNotUsed(ptIds))
MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts), const vtkIdType vtkNotUsed(ptIds)[])
{
vtkWarningMacro(<<"Read only block\n");
return -1;
}
vtkIdType
MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts), vtkIdType *vtkNotUsed(ptIds),
MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts), const vtkIdType vtkNotUsed(ptIds)[],
vtkIdType vtkNotUsed(nfaces), vtkIdType *vtkNotUsed(faces))
{
vtkWarningMacro(<<"Read only block\n");
......@@ -277,7 +277,7 @@ MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts),
}
void
MappedGridImpl::ReplaceCell(vtkIdType vtkNotUsed(cellId), int vtkNotUsed(npts), vtkIdType *vtkNotUsed(pts))
MappedGridImpl::ReplaceCell(vtkIdType vtkNotUsed(cellId), int vtkNotUsed(npts), const vtkIdType vtkNotUsed(pts)[])
{
vtkWarningMacro(<<"Read only block\n");
}
......
......@@ -172,11 +172,6 @@ public:
void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array) override;
int IsHomogeneous() override;
void Allocate(vtkIdType numCells, int extSize = 1000) override;
vtkIdType InsertNextCell(int type, vtkIdList *ptIds) override;
vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds) override;
vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds,
vtkIdType nfaces, vtkIdType *faces) override;
void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts) override;
vtkMTimeType GetMTime() override;
void SetImplementation(ImplementationType *impl);
......@@ -191,6 +186,12 @@ protected:
vtkSmartPointer<ImplementationType> Impl;
vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
vtkIdType InternalInsertNextCell(int type, vtkIdList *ptIds) override;
vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[],
vtkIdType nfaces, const vtkIdType faces[]) override;
void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
private:
vtkMappedUnstructuredGrid(const vtkMappedUnstructuredGrid &) = delete;
void operator=(const vtkMappedUnstructuredGrid &) = delete;
......
......@@ -162,7 +162,7 @@ void vtkMappedUnstructuredGrid<Implementation, CellIterator>
//------------------------------------------------------------------------------
template <class Implementation, class CellIterator>
vtkIdType vtkMappedUnstructuredGrid<Implementation, CellIterator>
::InsertNextCell(int type, vtkIdList *ptIds)
::InternalInsertNextCell(int type, vtkIdList *ptIds)
{
return this->Impl->InsertNextCell(type, ptIds);
}
......@@ -170,7 +170,7 @@ vtkIdType vtkMappedUnstructuredGrid<Implementation, CellIterator>
//------------------------------------------------------------------------------
template <class Implementation, class CellIterator>
vtkIdType vtkMappedUnstructuredGrid<Implementation, CellIterator>
::InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds)
::InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[])
{
return this->Impl->InsertNextCell(type, npts, ptIds);
}
......@@ -178,8 +178,8 @@ vtkIdType vtkMappedUnstructuredGrid<Implementation, CellIterator>
//------------------------------------------------------------------------------
template <class Implementation, class CellIterator>
vtkIdType vtkMappedUnstructuredGrid<Implementation, CellIterator>
::InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds, vtkIdType nfaces,
vtkIdType *faces)
::InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[], vtkIdType nfaces,
const vtkIdType faces[])
{
return this->Impl->InsertNextCell(type, npts, ptIds, nfaces, faces);
}
......@@ -187,7 +187,7 @@ vtkIdType vtkMappedUnstructuredGrid<Implementation, CellIterator>
//------------------------------------------------------------------------------
template <class Implementation, class CellIterator>
void vtkMappedUnstructuredGrid<Implementation, CellIterator>
::ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts)
::InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[])
{
this->Impl->ReplaceCell(cellId, npts, pts);
}
......
......@@ -981,7 +981,7 @@ vtkIdType vtkUnstructuredGrid::GetNumberOfCells()
// 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::InsertNextCell(int type, vtkIdList *ptIds)
vtkIdType vtkUnstructuredGrid::InternalInsertNextCell(int type, vtkIdList *ptIds)
{
if (type == VTK_POLYHEDRON)
{
......@@ -1014,8 +1014,8 @@ vtkIdType vtkUnstructuredGrid::InsertNextCell(int type, vtkIdList *ptIds)
// 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::InsertNextCell(int type, vtkIdType npts,
vtkIdType *ptIds)
vtkIdType vtkUnstructuredGrid::InternalInsertNextCell(int type, vtkIdType npts,
const vtkIdType ptIds[])
{
if (type != VTK_POLYHEDRON)
{
......@@ -1072,8 +1072,8 @@ vtkIdType vtkUnstructuredGrid::InsertNextCell(int type, vtkIdType npts,
// defining cell topology. This method is meant for face-explicit cells (e.g.
// polyhedron).
vtkIdType vtkUnstructuredGrid::
InsertNextCell(int type, vtkIdType npts, vtkIdType *pts,
vtkIdType nfaces, vtkIdType *faces)
InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType pts[],
vtkIdType nfaces, const vtkIdType faces[])
{
if (type != VTK_POLYHEDRON)
{
......@@ -1106,16 +1106,16 @@ InsertNextCell(int type, vtkIdType npts, vtkIdType *pts,
this->FaceLocations->InsertNextValue(
this->Faces->GetMaxId() + 1);
this->Faces->InsertNextValue(nfaces);
vtkIdType i, *face=faces;
for (int faceNum=0; faceNum < nfaces; ++faceNum)
{
npts = face[0];
npts = faces[0];
this->Faces->InsertNextValue(npts);
for (i=1; i <= npts; ++i)
for (vtkIdType i=1; i <= npts; ++i)
{
this->Faces->InsertNextValue(face[i]);
this->Faces->InsertNextValue(faces[i]);
}
face += npts + 1;
faces += npts + 1;
} //for all faces
return this->Types->InsertNextValue(static_cast<unsigned char>(type));
......@@ -1605,8 +1605,8 @@ void vtkUnstructuredGrid::ResizeCellList(vtkIdType ptId, int size)
// operator is (typically) used when links from points to cells have not been
// built (i.e., BuildLinks() has not been executed). Use the operator
// ReplaceLinkedCell() to replace a cell when cell structure has been built.
void vtkUnstructuredGrid::ReplaceCell(vtkIdType cellId, int npts,
vtkIdType *pts)
void vtkUnstructuredGrid::InternalReplaceCell(vtkIdType cellId, int npts,
const vtkIdType pts[])
{
vtkIdType loc;
......@@ -1619,7 +1619,7 @@ void vtkUnstructuredGrid::ReplaceCell(vtkIdType cellId, int npts,
// built). This method adds the cell and then updates the links from the points
// to the cells. (Memory is allocated as necessary.)
vtkIdType vtkUnstructuredGrid::InsertNextLinkedCell(int type, int npts,
vtkIdType *pts)
const vtkIdType pts[])
{
vtkIdType i, id;
......@@ -2111,7 +2111,7 @@ void vtkUnstructuredGrid::DecomposeAPolyhedronCell(vtkIdType *cellStream,
//----------------------------------------------------------------------------
void vtkUnstructuredGrid::DecomposeAPolyhedronCell(vtkIdType nCellFaces,
vtkIdType * cellStream, vtkIdType & numCellPts,
const vtkIdType cellStream[], vtkIdType & numCellPts,
vtkCellArray * cellArray, vtkIdTypeArray * faces)
{
std::set<vtkIdType> cellPointSet;
......
......@@ -100,39 +100,6 @@ public:
*/
void Allocate(vtkIdType numCells=1000, int extSize=1000) override;
/**
* Insert/create cell in object by type and list of point ids defining
* cell topology. Most cells require just a type which implicitly defines
* a set of points and their ordering. For non-polyhedron cell type, npts
* is the number of unique points in the cell. pts are the list of global
* point Ids. For polyhedron cell, a special input format is required.
* npts is the number of faces in the cell. ptIds is the list of face stream:
* (numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...)
* Make sure you have called Allocate() before calling this method
*/
vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds) override;
/**
* Insert/create cell in object by a list of point ids defining
* cell topology. Most cells require just a type which implicitly defines
* a set of points and their ordering. For non-polyhedron cell type, ptIds
* is the list of global Ids of unique cell points. For polyhedron cell,
* a special ptIds input format is required:
* (numCellFaces, numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...)
* Make sure you have called Allocate() before calling this method
*/
vtkIdType InsertNextCell(int type, vtkIdList *ptIds) override;
// Description:
// Insert/create a polyhedron cell. npts is the number of unique points in
// the cell. pts is the list of the unique cell point Ids. nfaces is the
// number of faces in the cell. faces is the face-stream
// [numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...].
// All point Ids are global.
// Make sure you have called Allocate() before calling this method
vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds,
vtkIdType nfaces, vtkIdType *faces) override;
//@{
/**
* Standard vtkDataSet methods; see vtkDataSet.h for documentation.
......@@ -202,8 +169,7 @@ public:
//@}
vtkCellArray *GetCells() {return this->Connectivity;};
void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts) override;
vtkIdType InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
vtkIdType InsertNextLinkedCell(int type, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
void ResizeCellList(vtkIdType ptId, int size);
......@@ -342,7 +308,7 @@ public:
* be touched.
*/
static void DecomposeAPolyhedronCell(vtkIdType nCellFaces,
vtkIdType * inFaceStream,
const vtkIdType * inFaceStream,
vtkIdType & nCellpts,
vtkCellArray * cellArray,
vtkIdTypeArray * faces);
......@@ -428,6 +394,12 @@ protected:
vtkIdTypeArray *Faces;
vtkIdTypeArray *FaceLocations;
vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) override;
vtkIdType InternalInsertNextCell(int type, vtkIdList *ptIds) override;
vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[],
vtkIdType nfaces, const vtkIdType faces[]) override;
void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) override;
private:
// Hide these from the user and the compiler.
vtkUnstructuredGrid(const vtkUnstructuredGrid&) = delete;
......
......@@ -59,3 +59,28 @@ vtkUnstructuredGridBase::GetData(vtkInformationVector* v, int i)
{
return vtkUnstructuredGridBase::GetData(v->GetInformationObject(i));
}
//----------------------------------------------------------------------------
vtkIdType vtkUnstructuredGridBase::InsertNextCell(vtkIdType cellId, int npts, const vtkIdType pts[])
{
return this->InternalInsertNextCell(cellId, npts, pts);
}
//----------------------------------------------------------------------------
vtkIdType vtkUnstructuredGridBase::InsertNextCell(int type, vtkIdList *ptIds)
{
return this->InternalInsertNextCell(type, ptIds);
}
//----------------------------------------------------------------------------
vtkIdType vtkUnstructuredGridBase::InsertNextCell(vtkIdType cellId, int npts, const vtkIdType pts[],
vtkIdType nfaces, const vtkIdType faces[])
{
return this->InternalInsertNextCell(cellId, npts, pts, nfaces, faces);
}
//----------------------------------------------------------------------------
void vtkUnstructuredGridBase::ReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[])
{
this->InternalReplaceCell(cellId, npts, pts);
}
......@@ -60,9 +60,9 @@ public:
* point Ids. For polyhedron cell, a special input format is required.
* npts is the number of faces in the cell. ptIds is the list of face stream:
* (numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...)
* Make sure you have called Allocate() before calling this method
*/
virtual vtkIdType InsertNextCell(int type, vtkIdType npts,
vtkIdType *ptIds) = 0;
vtkIdType InsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) VTK_SIZEHINT(ptIds, npts);
/**
* Insert/create cell in object by a list of point ids defining
......@@ -71,8 +71,9 @@ public:
* is the list of global Ids of unique cell points. For polyhedron cell,
* a special ptIds input format is required:
* (numCellFaces, numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...)
* Make sure you have called Allocate() before calling this method
*/
virtual vtkIdType InsertNextCell(int type, vtkIdList *ptIds) = 0;
vtkIdType InsertNextCell(int type, vtkIdList *ptIds);
// Description:
// Insert/create a polyhedron cell. npts is the number of unique points in
......@@ -80,8 +81,9 @@ public:
// number of faces in the cell. faces is the face-stream
// [numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...].
// All point Ids are global.
virtual vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds,
vtkIdType nfaces, vtkIdType *faces) = 0;
// Make sure you have called Allocate() before calling this method
vtkIdType InsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[],
vtkIdType nfaces, const vtkIdType faces[]) VTK_SIZEHINT(ptIds, npts) VTK_SIZEHINT(faces, nfaces);
/**
* Replace the points defining cell "cellId" with a new set of points. This
......@@ -89,7 +91,7 @@ public:
* built (i.e., BuildLinks() has not been executed). Use the operator
* ReplaceLinkedCell() to replace a cell when cell structure has been built.
*/
virtual void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts) = 0;
void ReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
/**
* Fill vtkIdTypeArray container with list of cell Ids. This
......@@ -115,6 +117,12 @@ protected:
vtkUnstructuredGridBase();
~vtkUnstructuredGridBase() override;
virtual vtkIdType InternalInsertNextCell(int type, vtkIdList *ptIds) = 0;
virtual vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) = 0;
virtual vtkIdType InternalInsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[],
vtkIdType nfaces, const vtkIdType faces[]) = 0;
virtual void InternalReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) = 0;
private:
vtkUnstructuredGridBase(const vtkUnstructuredGridBase&) = delete;
void operator=(const vtkUnstructuredGridBase&) = delete;
......
......@@ -184,7 +184,7 @@ vtkIdType vtkCPExodusIIElementBlockImpl::InsertNextCell(int, vtkIdList*)
}
//------------------------------------------------------------------------------
vtkIdType vtkCPExodusIIElementBlockImpl::InsertNextCell(int, vtkIdType, vtkIdType*)
vtkIdType vtkCPExodusIIElementBlockImpl::InsertNextCell(int, vtkIdType, const vtkIdType[])
{
vtkErrorMacro("Read only container.")
return -1;
......@@ -192,14 +192,14 @@ vtkIdType vtkCPExodusIIElementBlockImpl::InsertNextCell(int, vtkIdType, vtkIdTyp
//------------------------------------------------------------------------------
vtkIdType vtkCPExodusIIElementBlockImpl::InsertNextCell(
int, vtkIdType, vtkIdType*, vtkIdType, vtkIdType*)
int, vtkIdType, const vtkIdType[], vtkIdType, const vtkIdType[])
{
vtkErrorMacro("Read only container.")
return -1;
}
//------------------------------------------------------------------------------
void vtkCPExodusIIElementBlockImpl::ReplaceCell(vtkIdType, int, vtkIdType*)
void vtkCPExodusIIElementBlockImpl::ReplaceCell(vtkIdType, int, const vtkIdType[])
{
vtkErrorMacro("Read only container.")
}
......
......@@ -66,10 +66,10 @@ public:
// warning.
void Allocate(vtkIdType numCells, int extSize = 1000);
vtkIdType InsertNextCell(int type, vtkIdList *ptIds);
vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds);
vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds,
vtkIdType nfaces, vtkIdType *faces);
void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
vtkIdType InsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[]) VTK_SIZEHINT(ptIds, npts);
vtkIdType InsertNextCell(int type, vtkIdType npts, const vtkIdType ptIds[],
vtkIdType nfaces, const vtkIdType faces[]) VTK_SIZEHINT(ptIds, npts) VTK_SIZEHINT(faces, nfaces);
void ReplaceCell(vtkIdType cellId, int npts, const vtkIdType pts[]) VTK_SIZEHINT(pts, npts);
protected:
vtkCPExodusIIElementBlockImpl();
......
......@@ -261,14 +261,14 @@ MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdList* vtkNotUsed(ptIds
}
vtkIdType
MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts), vtkIdType *vtkNotUsed(ptIds))
MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts), const vtkIdType vtkNotUsed(ptIds)[])
{
vtkWarningMacro(<<"Read only block\n");
return -1;
}
vtkIdType
MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts), vtkIdType *vtkNotUsed(ptIds),
MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts), const vtkIdType vtkNotUsed(ptIds)[],
vtkIdType vtkNotUsed(nfaces), vtkIdType *vtkNotUsed(faces))
{
vtkWarningMacro(<<"Read only block\n");
......@@ -276,7 +276,7 @@ MappedGridImpl::InsertNextCell(int vtkNotUsed(type), vtkIdType vtkNotUsed(npts),
}
void
MappedGridImpl::ReplaceCell(vtkIdType vtkNotUsed(cellId), int vtkNotUsed(npts), vtkIdType *vtkNotUsed(pts))
MappedGridImpl::ReplaceCell(vtkIdType vtkNotUsed(cellId), int vtkNotUsed(npts), const vtkIdType vtkNotUsed(pts)[])
{
vtkWarningMacro(<<"Read only block\n");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment