VTK
vtkPolyData.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPolyData.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
63 #ifndef vtkPolyData_h
64 #define vtkPolyData_h
65 
66 #include "vtkCommonDataModelModule.h" // For export macro
67 #include "vtkPointSet.h"
68 
69 #include "vtkCellTypes.h" // Needed for inline methods
70 #include "vtkCellLinks.h" // Needed for inline methods
71 
72 class vtkVertex;
73 class vtkPolyVertex;
74 class vtkLine;
75 class vtkPolyLine;
76 class vtkTriangle;
77 class vtkQuad;
78 class vtkPolygon;
79 class vtkTriangleStrip;
80 class vtkEmptyCell;
81 struct vtkPolyDataDummyContainter;
82 
84 {
85 public:
86  static vtkPolyData *New();
87 
89  void PrintSelf(ostream& os, vtkIndent indent);
90 
93 
97 
99 
102  void GetCell(vtkIdType cellId, vtkGenericCell *cell);
103  int GetCellType(vtkIdType cellId);
104  void GetCellBounds(vtkIdType cellId, double bounds[6]);
105  void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
106  vtkIdList *cellIds);
108 
110 
114  void CopyCells(vtkPolyData *pd, vtkIdList *idList,
115  vtkPointLocator *locator = NULL);
117 
119  void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
120 
123  void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
124 
127 
132  void Squeeze();
133 
136 
139 
143 
146 
150 
153 
157 
160 
165 
167 
173 
180  void Allocate(vtkIdType numCells=1000, int extSize=1000);
181 
183 
192  void Allocate(vtkPolyData *inPolyData, vtkIdType numCells=1000,
193  int extSize=1000);
195 
202  vtkIdType InsertNextCell(int type, int npts, vtkIdType *pts);
203 
211 
214  void Reset();
215 
217  void BuildCells();
218 
224  void BuildLinks(int initialSize=0);
225 
229  void DeleteCells();
230 
232  void DeleteLinks();
233 
235 
236  void GetPointCells(vtkIdType ptId, unsigned short& ncells,
237  vtkIdType* &cells);
239 
241 
245  vtkIdList *cellIds);
247 
250  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType* &pts);
251 
254  int IsTriangle(int v1, int v2, int v3);
255 
262 
265  int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId);
266 
272  void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
273 
275 
276  void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
277  vtkIdType newPtId);
279 
281  void ReverseCell(vtkIdType cellId);
282 
284 
285  void DeletePoint(vtkIdType ptId);
286  void DeleteCell(vtkIdType cellId);
288 
295 
297 
304  vtkIdType InsertNextLinkedPoint(double x[3], int numLinks);
306 
311 
318  void ReplaceLinkedCell(vtkIdType cellId, int npts, vtkIdType *pts);
319 
325  void RemoveCellReference(vtkIdType cellId);
326 
332  void AddCellReference(vtkIdType cellId);
333 
340 
346 
349  void ResizeCellList(vtkIdType ptId, int size);
350 
352  virtual void Initialize();
353 
355 
356  virtual int GetPiece();
357  virtual int GetNumberOfPieces();
359 
361  virtual int GetGhostLevel();
362 
368  unsigned long GetActualMemorySize();
369 
371 
375 
380 
381  //BTX
383 
386  //ETX
388 
389 //BTX
391 
405  enum
406  {
407  ERR_NO_SUCH_FIELD = -4,
408  ERR_INCORRECT_FIELD = -3,
409  ERR_NON_MANIFOLD_STAR = -2,
410  REGULAR_POINT = -1,
411  MINIMUM = 0,
412  SADDLE = 1,
413  MAXIMUM = 2
414  };
415 //ETX
417  vtkDataArray *scalarField);
418  int GetScalarFieldCriticalIndex (vtkIdType pointId, int fieldId);
419  int GetScalarFieldCriticalIndex (vtkIdType pointId, const char* fieldName);
421 
422 protected:
425 
426  // constant cell objects returned by GetCell called.
436 
437  // points inherited
438  // point data (i.e., scalars, vectors, normals, tcoords) inherited
443 
444  // dummy static member below used as a trick to simplify traversal
445  static vtkPolyDataDummyContainter DummyContainer;
446 
447  // supporting structures for more complex topological operations
448  // built only when necessary
451 
452 private:
453  // Hide these from the user and the compiler.
454 
456 
457  void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
458  {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
460 
461  void Cleanup();
462 
463 private:
464  vtkPolyData(const vtkPolyData&); // Not implemented.
465  void operator=(const vtkPolyData&); // Not implemented.
466 };
467 
468 inline void vtkPolyData::GetPointCells(vtkIdType ptId, unsigned short& ncells,
469  vtkIdType* &cells)
470 {
471  ncells = this->Links->GetNcells(ptId);
472  cells = this->Links->GetCells(ptId);
473 }
474 
475 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
476 {
477  unsigned short int n1;
478  int i, j, tVerts[3];
479  vtkIdType *cells, *tVerts2, n2;
480 
481  tVerts[0] = v1;
482  tVerts[1] = v2;
483  tVerts[2] = v3;
484 
485  for (i=0; i<3; i++)
486  {
487  this->GetPointCells(tVerts[i], n1, cells);
488  for (j=0; j<n1; j++)
489  {
490  this->GetCellPoints(cells[j], n2, tVerts2);
491  if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
492  tVerts[0] == tVerts2[2]) &&
493  (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
494  tVerts[1] == tVerts2[2]) &&
495  (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
496  tVerts[2] == tVerts2[2]) )
497  {
498  return 1;
499  }
500  }
501  }
502  return 0;
503 }
504 
506 {
507  vtkIdType *pts, npts;
508 
509  this->GetCellPoints(cellId, npts, pts);
510  for (vtkIdType i=0; i < npts; i++)
511  {
512  if ( pts[i] == ptId )
513  {
514  return 1;
515  }
516  }
517 
518  return 0;
519 }
520 
522 {
523  this->Links->DeletePoint(ptId);
524 }
525 
527 {
528  this->Cells->DeleteCell(cellId);
529 }
530 
532 {
533  vtkIdType *pts, npts;
534 
535  this->GetCellPoints(cellId, npts, pts);
536  for (vtkIdType i=0; i<npts; i++)
537  {
538  this->Links->RemoveCellReference(cellId, pts[i]);
539  }
540 }
541 
543 {
544  vtkIdType *pts, npts;
545 
546  this->GetCellPoints(cellId, npts, pts);
547  for (vtkIdType i=0; i<npts; i++)
548  {
549  this->Links->AddCellReference(cellId, pts[i]);
550  }
551 }
552 
554 {
555  this->Links->ResizeCellList(ptId,size);
556 }
557 
559  vtkIdType newPtId)
560 {
561  int i;
562  vtkIdType *verts, nverts;
563 
564  this->GetCellPoints(cellId,nverts,verts);
565  for ( i=0; i < nverts; i++ )
566  {
567  if ( verts[i] == oldPtId )
568  {
569  verts[i] = newPtId; // this is very nasty! direct write!
570  return;
571  }
572  }
573 }
574 
575 #endif
vtkPolyData::RemoveGhostCells
void RemoveGhostCells()
vtkPolyData::GetScalarFieldCriticalIndex
int GetScalarFieldCriticalIndex(vtkIdType pointId, const char *fieldName)
vtkPolyData::SetStrips
void SetStrips(vtkCellArray *s)
vtkgl::v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: vtkgl.h:12016
vtkPolyData::New
static vtkPolyData * New()
vtkPolyData::GetCellType
int GetCellType(vtkIdType cellId)
vtkPolyData::GetPointCells
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
vtkgl::v2
GLfloat GLfloat GLfloat v2
Definition: vtkgl.h:12015
vtkCellTypes
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:52
vtkPolyData::InsertNextLinkedCell
vtkIdType InsertNextLinkedCell(int type, int npts, vtkIdType *pts)
vtkPolyData::ReplaceCellPoint
void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId, vtkIdType newPtId)
Definition: vtkPolyData.h:558
vtkPolyData::GetNumberOfCells
vtkIdType GetNumberOfCells()
vtkPolyData::GetCell
void GetCell(vtkIdType cellId, vtkGenericCell *cell)
vtkPointSet.h
vtkPolyData::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkCommonDataModelModule.h
vtkCellTypes.h
vtkPolygon
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:45
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkPointLocator
quickly locate points in 3-space
Definition: vtkPointLocator.h:53
vtkEmptyCell
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:32
vtkPolyData::GetDataObjectType
int GetDataObjectType()
Definition: vtkPolyData.h:92
vtkPolyData::Strips
vtkCellArray * Strips
Definition: vtkPolyData.h:442
vtkPolyData::GetScalarFieldCriticalIndex
int GetScalarFieldCriticalIndex(vtkIdType pointId, vtkDataArray *scalarField)
vtkgl::s
GLdouble s
Definition: vtkgl.h:11594
vtkPolyData::SetPolys
void SetPolys(vtkCellArray *p)
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkPolyData::PolyVertex
vtkPolyVertex * PolyVertex
Definition: vtkPolyData.h:428
vtkPolyData::InsertNextCell
vtkIdType InsertNextCell(int type, int npts, vtkIdType *pts)
vtkPolyData::GetNumberOfPolys
vtkIdType GetNumberOfPolys()
vtkPolyData::ReplaceLinkedCell
void ReplaceLinkedCell(vtkIdType cellId, int npts, vtkIdType *pts)
vtkPolyData::GetPiece
virtual int GetPiece()
vtkgl::v
const GLdouble * v
Definition: vtkgl.h:11595
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkPolyData::SetLines
void SetLines(vtkCellArray *l)
vtkPolyData::RemoveCellReference
void RemoveCellReference(vtkIdType cellId)
Definition: vtkPolyData.h:531
vtkPolyData::~vtkPolyData
~vtkPolyData()
vtkPolyData::Initialize
virtual void Initialize()
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkPolyData::RemoveReferenceToCell
void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId)
vtkPolyData::GetStrips
vtkCellArray * GetStrips()
vtkPolyData::Lines
vtkCellArray * Lines
Definition: vtkPolyData.h:440
vtkVertex
a cell that represents a 3D point
Definition: vtkVertex.h:36
vtkPolyData::InsertNextCell
vtkIdType InsertNextCell(int type, vtkIdList *pts)
vtkgl::v1
GLfloat GLfloat v1
Definition: vtkgl.h:12014
vtkPolyData::ShallowCopy
void ShallowCopy(vtkDataObject *src)
vtkPolyData::RemoveDeletedCells
void RemoveDeletedCells()
vtkLine
cell represents a 1D line
Definition: vtkLine.h:35
vtkPolyData::GetNumberOfVerts
vtkIdType GetNumberOfVerts()
vtkPolyData::GetCellNeighbors
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
vtkPolyData::Reset
void Reset()
vtkPolyData::DeletePoint
void DeletePoint(vtkIdType ptId)
Definition: vtkPolyData.h:521
vtkPolyData::GetLines
vtkCellArray * GetLines()
vtkPolyData::GetData
static vtkPolyData * GetData(vtkInformation *info)
vtkPolyData::GetScalarFieldCriticalIndex
int GetScalarFieldCriticalIndex(vtkIdType pointId, int fieldId)
vtkPolyData::AddCellReference
void AddCellReference(vtkIdType cellId)
Definition: vtkPolyData.h:542
vtkPolyData::PolyLine
vtkPolyLine * PolyLine
Definition: vtkPolyData.h:430
vtkPolyLine
cell represents a set of 1D lines
Definition: vtkPolyLine.h:42
vtkPolyData::GetData
static vtkPolyData * GetData(vtkInformationVector *v, int i=0)
vtkPolyData::DeepCopy
void DeepCopy(vtkDataObject *src)
vtkDataSet::GetCellNeighbors
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
vtkgl::src
GLenum src
Definition: vtkgl.h:12525
vtkPolyData::GetGhostLevel
virtual int GetGhostLevel()
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:62
vtkPolyData::GetVerts
vtkCellArray * GetVerts()
vtkPolyData::CopyCells
void CopyCells(vtkPolyData *pd, vtkIdList *idList, vtkPointLocator *locator=NULL)
vtkDataSet::GetPointCells
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
vtkPolyData::ComputeBounds
void ComputeBounds()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:50
vtkPolyData::IsTriangle
int IsTriangle(int v1, int v2, int v3)
Definition: vtkPolyData.h:475
vtkPolyData::Line
vtkLine * Line
Definition: vtkPolyData.h:429
vtkPolyData::EmptyCell
vtkEmptyCell * EmptyCell
Definition: vtkPolyData.h:435
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkPolyData::SetVerts
void SetVerts(vtkCellArray *v)
vtkTriangle
a cell that represents a triangle
Definition: vtkTriangle.h:41
vtkPolyData::GetNumberOfPieces
virtual int GetNumberOfPieces()
vtkPolyData::Vertex
vtkVertex * Vertex
Definition: vtkPolyData.h:427
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkPolyData::DeleteLinks
void DeleteLinks()
vtkPolyData::ReplaceCell
void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts)
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkPolyData::BuildLinks
void BuildLinks(int initialSize=0)
vtkCellTypes::DeleteCell
void DeleteCell(vtkIdType cellId)
Definition: vtkCellTypes.h:74
vtkPolyData::Quad
vtkQuad * Quad
Definition: vtkPolyData.h:432
vtkPolyData::IsPointUsedByCell
int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
Definition: vtkPolyData.h:505
vtkPolyData::Squeeze
void Squeeze()
vtkPolyData::BuildCells
void BuildCells()
vtkPolyData::InsertNextLinkedPoint
vtkIdType InsertNextLinkedPoint(double x[3], int numLinks)
vtkPolyData::ReverseCell
void ReverseCell(vtkIdType cellId)
vtkPolyData::ResizeCellList
void ResizeCellList(vtkIdType ptId, int size)
Definition: vtkPolyData.h:553
vtkPolyData::GetCell
vtkCell * GetCell(vtkIdType cellId)
vtkPolyData::GetNumberOfLines
vtkIdType GetNumberOfLines()
vtkPointSet
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:45
vtkPolyData::GetCellEdgeNeighbors
void GetCellEdgeNeighbors(vtkIdType cellId, vtkIdType p1, vtkIdType p2, vtkIdList *cellIds)
vtkPolyData::Polys
vtkCellArray * Polys
Definition: vtkPolyData.h:441
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkPolyData::DummyContainer
static vtkPolyDataDummyContainter DummyContainer
Definition: vtkPolyData.h:445
vtkPolyData::Allocate
void Allocate(vtkPolyData *inPolyData, vtkIdType numCells=1000, int extSize=1000)
vtkPolyData::InsertNextLinkedPoint
vtkIdType InsertNextLinkedPoint(int numLinks)
vtkPolyData::CopyStructure
void CopyStructure(vtkDataSet *ds)
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:42
vtkPolyData::GetPolys
vtkCellArray * GetPolys()
vtkPolyData::GetActualMemorySize
unsigned long GetActualMemorySize()
vtkgl::p
GLfloat GLfloat p
Definition: vtkgl.h:15717
vtkPolyData::Allocate
void Allocate(vtkIdType numCells=1000, int extSize=1000)
vtkPolyData::Triangle
vtkTriangle * Triangle
Definition: vtkPolyData.h:431
vtkPolyData::GetMaxCellSize
int GetMaxCellSize()
vtkPolyData::GetNumberOfStrips
vtkIdType GetNumberOfStrips()
vtkPolyData::AddReferenceToCell
void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId)
VTKCOMMONDATAMODEL_EXPORT
#define VTKCOMMONDATAMODEL_EXPORT
Definition: vtkCommonDataModelModule.h:15
vtkPolyData::Links
vtkCellLinks * Links
Definition: vtkPolyData.h:450
vtkPolyData::DeleteCells
void DeleteCells()
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:65
vtkPolyData::DeleteCell
void DeleteCell(vtkIdType cellId)
Definition: vtkPolyData.h:526
vtkPolyData::Verts
vtkCellArray * Verts
Definition: vtkPolyData.h:439
vtkgl::type
GLuint GLuint GLsizei GLenum type
Definition: vtkgl.h:11315
vtkPolyData::GetCellPoints
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
vtkPolyData::Polygon
vtkPolygon * Polygon
Definition: vtkPolyData.h:433
VTK_POLY_DATA
#define VTK_POLY_DATA
Definition: vtkType.h:66
vtkPolyData::TriangleStrip
vtkTriangleStrip * TriangleStrip
Definition: vtkPolyData.h:434
vtkTriangleStrip
a cell that represents a triangle strip
Definition: vtkTriangleStrip.h:43
vtkPolyData::vtkPolyData
vtkPolyData()
vtkPolyData::GetCellBounds
void GetCellBounds(vtkIdType cellId, double bounds[6])
vtkPolyData::GetCellPoints
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType *&pts)
vtkQuad
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:41
vtkPolyData::IsEdge
int IsEdge(vtkIdType p1, vtkIdType p2)
vtkgl::size
GLsizeiptr size
Definition: vtkgl.h:11843
vtkPolyData::Cells
vtkCellTypes * Cells
Definition: vtkPolyData.h:449
vtkPolyVertex
cell represents a set of 0D vertices
Definition: vtkPolyVertex.h:38