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 
88  vtkTypeMacro(vtkPolyData,vtkPointSet);
89  void PrintSelf(ostream& os, vtkIndent indent);
90 
93 
96  void CopyStructure(vtkDataSet *ds);
97 
99 
101  vtkCell *GetCell(vtkIdType cellId);
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 
126  void ComputeBounds();
127 
132  void Squeeze();
133 
135  int GetMaxCellSize();
136 
138  void SetVerts (vtkCellArray* v);
139 
142  vtkCellArray *GetVerts();
143 
145  void SetLines (vtkCellArray* l);
146 
149  vtkCellArray *GetLines();
150 
152  void SetPolys (vtkCellArray* p);
153 
156  vtkCellArray *GetPolys();
157 
159  void SetStrips (vtkCellArray* s);
160 
164  vtkCellArray *GetStrips();
165 
167 
168  vtkIdType GetNumberOfVerts();
169  vtkIdType GetNumberOfLines();
170  vtkIdType GetNumberOfPolys();
171  vtkIdType GetNumberOfStrips();
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 
210  vtkIdType InsertNextCell(int type, vtkIdList *pts);
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 
244  void GetCellEdgeNeighbors(vtkIdType cellId, vtkIdType p1, vtkIdType p2,
245  vtkIdList *cellIds);
247 
250  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType* &pts);
251 
254  int IsTriangle(int v1, int v2, int v3);
255 
261  int IsEdge(vtkIdType p1, vtkIdType p2);
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 
294  void RemoveDeletedCells();
295 
297 
303  vtkIdType InsertNextLinkedPoint(int numLinks);
304  vtkIdType InsertNextLinkedPoint(double x[3], int numLinks);
306 
310  vtkIdType InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
311 
318  void ReplaceLinkedCell(vtkIdType cellId, int npts, vtkIdType *pts);
319 
325  void RemoveCellReference(vtkIdType cellId);
326 
332  void AddCellReference(vtkIdType cellId);
333 
339  void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
340 
345  void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
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 
372  void ShallowCopy(vtkDataObject *src);
373  void DeepCopy(vtkDataObject *src);
375 
379  void RemoveGhostCells();
380 
381  //BTX
383 
385  static vtkPolyData* GetData(vtkInformationVector* v, int i=0);
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
416  int GetScalarFieldCriticalIndex (vtkIdType pointId,
417  vtkDataArray *scalarField);
418  int GetScalarFieldCriticalIndex (vtkIdType pointId, int fieldId);
419  int GetScalarFieldCriticalIndex (vtkIdType pointId, const char* fieldName);
421 
422 protected:
423  vtkPolyData();
424  ~vtkPolyData();
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
int GetDataObjectType()
Definition: vtkPolyData.h:92
vtkCellTypes * Cells
Definition: vtkPolyData.h:449
void ComputeBounds()
virtual vtkIdType GetNumberOfCells()=0
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
static vtkDataObject * New()
quickly locate points in 3-space
Store vtkAlgorithm input/output information.
void DeleteCell(vtkIdType cellId)
Definition: vtkCellTypes.h:74
vtkCellArray * Strips
Definition: vtkPolyData.h:442
void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId, vtkIdType newPtId)
Definition: vtkPolyData.h:558
vtkCellArray * Lines
Definition: vtkPolyData.h:440
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
a cell that represents a 3D point
Definition: vtkVertex.h:35
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
static vtkPointSet * GetData(vtkInformation *info)
void AddCellReference(vtkIdType cellId)
Definition: vtkPolyData.h:542
void CopyStructure(vtkDataSet *pd)
vtkPolyLine * PolyLine
Definition: vtkPolyData.h:430
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:40
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:44
void Initialize()
unsigned long GetActualMemorySize()
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:31
int vtkIdType
Definition: vtkType.h:275
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
cell represents a set of 0D vertices
Definition: vtkPolyVertex.h:37
void Squeeze()
void RemoveCellReference(vtkIdType cellId)
Definition: vtkPolyData.h:531
void DeletePoint(vtkIdType ptId)
Definition: vtkPolyData.h:521
provides thread-safe access to cells
vtkPolyVertex * PolyVertex
Definition: vtkPolyData.h:428
a cell that represents a triangle strip
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:61
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual int GetMaxCellSize()=0
int IsTriangle(int v1, int v2, int v3)
Definition: vtkPolyData.h:475
list of point or cell ids
Definition: vtkIdList.h:35
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:44
void ResizeCellList(vtkIdType ptId, int size)
Definition: vtkPolyData.h:553
vtkLine * Line
Definition: vtkPolyData.h:429
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
void PrintSelf(ostream &os, vtkIndent indent)
int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
Definition: vtkPolyData.h:505
vtkTriangle * Triangle
Definition: vtkPolyData.h:431
object to represent cell connectivity
Definition: vtkCellArray.h:49
vtkEmptyCell * EmptyCell
Definition: vtkPolyData.h:435
void DeepCopy(vtkDataObject *src)
vtkCellArray * Polys
Definition: vtkPolyData.h:441
a cell that represents a triangle
Definition: vtkTriangle.h:40
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
vtkQuad * Quad
Definition: vtkPolyData.h:432
Store zero or more vtkInformation instances.
vtkVertex * Vertex
Definition: vtkPolyData.h:427
vtkCellLinks * Links
Definition: vtkPolyData.h:450
void DeleteCell(vtkIdType cellId)
Definition: vtkPolyData.h:526
static vtkPolyDataDummyContainter DummyContainer
Definition: vtkPolyData.h:445
vtkCellArray * Verts
Definition: vtkPolyData.h:439
#define VTK_POLY_DATA
Definition: vtkType.h:66
void ShallowCopy(vtkDataObject *src)
general representation of visualization data
Definition: vtkDataObject.h:64
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:51
#define VTKCOMMONDATAMODEL_EXPORT
virtual vtkCell * GetCell(vtkIdType cellId)=0
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
cell represents a set of 1D lines
Definition: vtkPolyLine.h:41
virtual int GetCellType(vtkIdType cellId)=0
vtkPolygon * Polygon
Definition: vtkPolyData.h:433
vtkTriangleStrip * TriangleStrip
Definition: vtkPolyData.h:434