Commit cd856dbd authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH:Renamed vtkCellList->vtkCellTypes and vtkLinkList->vtkCellLinks

parent 49214133
......@@ -43,7 +43,8 @@ vtkBitScalars \
vtkBitmap \
vtkByteSwap \
vtkCellArray \
vtkCellList \
vtkCellLinks \
vtkCellTypes \
vtkCharArray \
vtkCollection \
vtkContourValues \
......@@ -69,7 +70,6 @@ vtkIntArray \
vtkIntPoints \
vtkIntScalars \
vtkLine \
vtkLinkList \
vtkLogLookupTable \
vtkLookupTable \
vtkMath \
......
......@@ -65,7 +65,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkFloatPoints.h"
#include "vtkFloatScalars.h"
#include "vtkIdList.h"
#include "vtkCellType.h"
#include "vtkCellTypes.h"
class vtkCellArray;
class vtkPointLocator;
......
......@@ -49,10 +49,10 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
// Advantages of this data structure are its compactness, simplicity, and
// easy interface to external data. However, it is totally inadequate for
// random access. This functionality (when necessary) is accomplished by
// using the vtkCellList and vtkLinkList objects to extend the definition of
// using the vtkCellTypes and vtkCellLinks objects to extend the definition of
// the data structure.
// .SECTION See Also
// vtkCellList vtkLinkList
// vtkCellTypes vtkCellLinks
#ifndef __vtkCellArray_h
#define __vtkCellArray_h
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCellList.cxx
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 1993-1996 Ken Martin, Will Schroeder, Bill Lorensen.
This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
The following terms apply to all files associated with the software unless
explicitly disclaimed in individual files. This copyright specifically does
not apply to the related textbook "The Visualization Toolkit" ISBN
013199837-4 published by Prentice Hall which is covered by its own copyright.
The authors hereby grant permission to use, copy, and distribute this
software and its documentation for any purpose, provided that existing
copyright notices are retained in all copies and that this notice is included
verbatim in any distributions. Additionally, the authors grant permission to
modify this software and its documentation for any purpose, provided that
such modifications are not distributed without the explicit consent of the
authors and that existing copyright notices are retained in all copies. Some
of the algorithms implemented by this software are patented, observe all
applicable patent law.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
#include "vtkCellList.h"
vtkCellList::vtkCellList(const int sz, const int ext)
{
this->Size = sz;
this->Array = new _vtkCell_s[sz];
this->Extend = ext;
this->MaxId = -1;
}
vtkCellList::~vtkCellList()
{
delete [] this->Array;
}
// Description:
// Add a cell at specified id.
void vtkCellList::InsertCell(const int cellId, const unsigned char type, const int loc)
{
_vtkCell_s *cell;
if ( cellId >= this->Size ) this->Resize(cellId);
if ( cellId > this->MaxId ) this->MaxId = cellId;
cell = this->Array + cellId;
cell->type = type;
cell->loc = loc;
return;
}
// Description:
// Add a cell to the object in the next available slot.
int vtkCellList::InsertNextCell(const unsigned char type, const int loc)
{
this->InsertCell (++this->MaxId,type,loc);
return this->MaxId;
}
// Description:
// Reclaim any extra memory.
void vtkCellList::Squeeze()
{
this->Resize (this->MaxId+1);
}
// Description:
// Initialize object without releasing memory.
void vtkCellList::Reset()
{
this->MaxId = -1;
}
//
// Private function does "reallocate"
//
_vtkCell_s *vtkCellList::Resize(const int sz)
{
int i;
_vtkCell_s *newArray;
int newSize;
if ( sz >= this->Size ) newSize = this->Size +
this->Extend*(((sz-this->Size)/this->Extend)+1);
else newSize = sz;
newArray = new _vtkCell_s[newSize];
for (i=0; i<sz && i<this->Size; i++)
newArray[i] = this->Array[i];
this->Size = newSize;
delete [] this->Array;
this->Array = newArray;
return this->Array;
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCellList.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 1993-1996 Ken Martin, Will Schroeder, Bill Lorensen.
This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
The following terms apply to all files associated with the software unless
explicitly disclaimed in individual files. This copyright specifically does
not apply to the related textbook "The Visualization Toolkit" ISBN
013199837-4 published by Prentice Hall which is covered by its own copyright.
The authors hereby grant permission to use, copy, and distribute this
software and its documentation for any purpose, provided that existing
copyright notices are retained in all copies and that this notice is included
verbatim in any distributions. Additionally, the authors grant permission to
modify this software and its documentation for any purpose, provided that
such modifications are not distributed without the explicit consent of the
authors and that existing copyright notices are retained in all copies. Some
of the algorithms implemented by this software are patented, observe all
applicable patent law.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
// .NAME vtkCellList - object provides direct access to cells in vtkCellArray
// .SECTION Description
// Supplemental object to vtkCellArray to allow random access into cells.
// The "location" field is the location in the vtkCellArray list in terms of
// an integer offset. An integer offset was used instead of a pointer for
// easy storage and inter-process communication.
// .SECTION See Also
// vtkCellArray vtkLinkList
#ifndef __vtkCellList_h
#define __vtkCellList_h
#include "vtkReferenceCount.h"
#include "vtkCellType.h"
struct _vtkCell_s {
unsigned char type; //from CellTypes.h
int loc; //location in associated CellArray object
};
class VTK_EXPORT vtkCellList : public vtkReferenceCount
{
public:
vtkCellList() : Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
vtkCellList(const int sz, const int ext);
~vtkCellList();
static vtkCellList *New() {return new vtkCellList;};
char *GetClassName() {return "vtkCellList";};
_vtkCell_s &GetCell(const int id);
unsigned char GetCellType(const int id);
int GetCellLocation(const int id);
void InsertCell(const int id, const unsigned char type, const int loc);
int InsertNextCell(const unsigned char type, const int loc);
void DeleteCell(int cellId);
void Squeeze();
void Reset();
private:
_vtkCell_s *Array; // pointer to data
int Size; // allocated size of data
int MaxId; // maximum index inserted thus far
int Extend; // grow array by this point
_vtkCell_s *Resize(const int sz); // function to resize data
};
// Description:
// Return a reference to a cell list structure.
inline _vtkCell_s &vtkCellList::GetCell(const int id)
{
return this->Array[id];
}
// Description:
// Return the type of cell.
inline unsigned char vtkCellList::GetCellType(const int cellId)
{
return this->Array[cellId].type;
}
// Description:
// Return the location of the cell in the associated vtkCellArray.
inline int vtkCellList::GetCellLocation(const int cellId)
{
return this->Array[cellId].loc;
}
// Description:
// Delete cell by setting to NULL cell type.
inline void vtkCellList::DeleteCell(int cellId)
{
this->Array[cellId].type = VTK_NULL_ELEMENT;
}
#endif
......@@ -47,7 +47,8 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkByteSwap.h"
#include "vtkCell.h"
#include "vtkCellArray.h"
#include "vtkCellList.h"
#include "vtkCellLinks.h"
#include "vtkCellTypes.h"
#include "vtkCollection.h"
#include "vtkColorScalars.h"
#include "vtkDataSet.h"
......@@ -75,7 +76,6 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkIntPoints.h"
#include "vtkIntScalars.h"
#include "vtkLine.h"
#include "vtkLinkList.h"
#include "vtkLocator.h"
#include "vtkLogLookupTable.h"
#include "vtkLookupTable.h"
......
......@@ -270,17 +270,18 @@ void vtkDataSet::GetCellNeighbors(int cellId, vtkIdList &ptIds,
}
}
void vtkDataSet::GetCellTypes(vtkIdList *types)
void vtkDataSet::GetCellTypes(vtkCellTypes *types)
{
int cellId, type, numCells=this->GetNumberOfCells();
int cellId, numCells=this->GetNumberOfCells();
unsigned char type;
types->Reset();
for (cellId=0; cellId < numCells; cellId++)
{
type = this->GetCellType(cellId);
if ( ! types->IsId(type) )
if ( ! types->IsType(type) )
{
types->InsertNextId(type);
types->InsertNextType(type);
}
}
}
......
......@@ -122,7 +122,7 @@ public:
// For example a dataset 5 triangles, 3 lines, and 100 hexahedra would
// result a list of three entries, corresponding to the types VTK_TRIANGLE,
// VTK_LINE, and VTK_HEXAHEDRON.
virtual void GetCellTypes(vtkIdList *types);
virtual void GetCellTypes(vtkCellTypes *types);
// Description:
// Topological inquiry to get points defining cell.
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkLinkList.cxx
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 1993-1996 Ken Martin, Will Schroeder, Bill Lorensen.
This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
The following terms apply to all files associated with the software unless
explicitly disclaimed in individual files. This copyright specifically does
not apply to the related textbook "The Visualization Toolkit" ISBN
013199837-4 published by Prentice Hall which is covered by its own copyright.
The authors hereby grant permission to use, copy, and distribute this
software and its documentation for any purpose, provided that existing
copyright notices are retained in all copies and that this notice is included
verbatim in any distributions. Additionally, the authors grant permission to
modify this software and its documentation for any purpose, provided that
such modifications are not distributed without the explicit consent of the
authors and that existing copyright notices are retained in all copies. Some
of the algorithms implemented by this software are patented, observe all
applicable patent law.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
#include "vtkLinkList.h"
#include "vtkDataSet.h"
vtkLinkList::vtkLinkList(int sz, int ext)
{
static _vtkLink_s linkInit = {0,NULL};
this->Size = sz;
this->Array = new _vtkLink_s[sz];
this->Extend = ext;
this->MaxId = -1;
for (int i=0; i < sz; i++) this->Array[i] = linkInit;
}
vtkLinkList::~vtkLinkList()
{
if ( this->Array == NULL ) return;
for (int i=0; i<=this->MaxId; i++)
{
if ( this->Array[i].cells != NULL )
delete [] this->Array[i].cells;
}
delete [] this->Array;
}
// Description:
// Allocate memory for the list of lists of cell ids.
void vtkLinkList::AllocateLinks(int n)
{
for (int i=0; i < n; i++)
{
this->Array[i].cells = new int[this->Array[i].ncells];
}
}
// Description:
// Reclaim any unused memory.
void vtkLinkList::Squeeze()
{
this->Resize (this->MaxId+1);
}
void vtkLinkList::Reset()
{
this->MaxId = -1;
}
//
// Private function does "reallocate"
//
_vtkLink_s *vtkLinkList::Resize(int sz)
{
int i;
_vtkLink_s *newArray;
int newSize;
_vtkLink_s linkInit = {0,NULL};
if ( sz >= this->Size ) newSize = this->Size +
this->Extend*(((sz-this->Size)/this->Extend)+1);
else newSize = sz;
newArray = new _vtkLink_s[newSize];
for (i=0; i<newSize && i<this->Size; i++) newArray[i] = this->Array[i];
for (i=this->Size; i < newSize ; i++) newArray[i] = linkInit;
this->Size = newSize;
delete [] this->Array;
this->Array = newArray;
return this->Array;
}
// Description:
// Build the link list array.
void vtkLinkList::BuildLinks(vtkDataSet *data)
{
int numPts = data->GetNumberOfPoints();
int numCells = data->GetNumberOfCells();
int i, j, ptId, cellId;
vtkCell *cell;
unsigned short *linkLoc;
// traverse data to determine number of uses of each point
for (cellId=0; cellId < numCells; cellId++)
{
cell = data->GetCell(cellId);
for (j=0; j < cell->GetNumberOfPoints(); j++)
{
this->IncrementLinkCount(cell->PointIds.GetId(j));
}
}
// now allocate storage for the links
this->AllocateLinks(numPts);
this->MaxId = numPts - 1;
// fill out lists with references to cells
linkLoc = new unsigned short[numPts];
for (i=0; i < numPts; i++) linkLoc[i] = 0;
for (cellId=0; cellId < numCells; cellId++)
{
cell = data->GetCell(cellId);
for (j=0; j < cell->GetNumberOfPoints(); j++)
{
ptId = cell->PointIds.GetId(j);
this->InsertCellReference(ptId, (linkLoc[ptId])++, cellId);
}
}
delete [] linkLoc;
}
// Description:
// Insert a new point into the linked-list data structure. The size parameter
// is the initial size of the linked-list requested.
int vtkLinkList::InsertNextPoint(int numLinks)
{
if ( ++this->MaxId >= this->Size ) this->Resize(this->MaxId);
this->Array[this->MaxId].cells = new int[numLinks];
return this->MaxId;
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkLinkList.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 1993-1996 Ken Martin, Will Schroeder, Bill Lorensen.
This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
The following terms apply to all files associated with the software unless
explicitly disclaimed in individual files. This copyright specifically does
not apply to the related textbook "The Visualization Toolkit" ISBN
013199837-4 published by Prentice Hall which is covered by its own copyright.
The authors hereby grant permission to use, copy, and distribute this
software and its documentation for any purpose, provided that existing
copyright notices are retained in all copies and that this notice is included
verbatim in any distributions. Additionally, the authors grant permission to
modify this software and its documentation for any purpose, provided that
such modifications are not distributed without the explicit consent of the
authors and that existing copyright notices are retained in all copies. Some
of the algorithms implemented by this software are patented, observe all
applicable patent law.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
// .NAME vtkLinkList - object represents upward pointers from points to list of cells using each point
// .SECTION Description
// vtkLinkList is a supplemental object to vtkCellArray and vtkCellList,
// enabling access from points to the cells using the points. vtkLinkList is
// a list of Links, each link represents a dynamic list of cell id's using the
// point. The information provided by this object can be used to determine
// neighbors and construct other local topological information.
// .SECTION See Also
// vtkCellArray vtkCellList
#ifndef __vtkLinkList_h
#define __vtkLinkList_h
#include "vtkReferenceCount.h"
class vtkDataSet;
struct _vtkLink_s {
unsigned short ncells;
int *cells;
};
class VTK_EXPORT vtkLinkList : public vtkReferenceCount
{
public:
vtkLinkList():Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
vtkLinkList(int sz, int ext=1000);
~vtkLinkList();
static vtkLinkList *New() {return new vtkLinkList;};
char *GetClassName() {return "vtkLinkList";};
_vtkLink_s &GetLink(int ptId);
unsigned short GetNcells(int ptId);
void BuildLinks(vtkDataSet *data);
int *GetCells(int ptId);
int InsertNextPoint(int numLinks);
void InsertNextCellReference(int ptId, int cellId);
void DeletePoint(int ptId);
void RemoveCellReference(int cellId, int ptId);
void AddCellReference(int cellId, int ptId);
void ResizeCellList(int ptId, int size);
void Squeeze();
void Reset();
private:
void IncrementLinkCount(int ptId);
void AllocateLinks(int n);
void InsertCellReference(int ptId, unsigned short pos, int cellId);
_vtkLink_s *Array; // pointer to data
int Size; // allocated size of data
int MaxId; // maximum index inserted thus far
int Extend; // grow array by this point
_vtkLink_s *Resize(int sz); // function to resize data
};
// Description:
// Get a link structure given a point id.
inline _vtkLink_s &vtkLinkList::GetLink(int ptId) {return this->Array[ptId];};
// Description:
// Get the number of cells using the point specified by ptId.
inline unsigned short vtkLinkList::GetNcells(int ptId)
{
return this->Array[ptId].ncells;
}
// Description:
// Return a list of cell ids using the point.
inline int *vtkLinkList::GetCells(int ptId) {return this->Array[ptId].cells;};
// Description:
// Increment the count of the number of cells using the point.
inline void vtkLinkList::IncrementLinkCount(int ptId)
{
this->Array[ptId].ncells++;
}
// Description:
// Insert a cell id into the list of cells using the point.
inline void vtkLinkList::InsertCellReference(int ptId, unsigned short pos, int cellId)
{
this->Array[ptId].cells[pos] = cellId;
}
// Description:
// Delete point (and storage) by destroying links to using cells.