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 "vtkPointSet.h"
67 
68 #include "vtkCellTypes.h" // Needed for inline methods
69 #include "vtkCellLinks.h" // Needed for inline methods
70 
71 class vtkVertex;
72 class vtkPolyVertex;
73 class vtkLine;
74 class vtkPolyLine;
75 class vtkTriangle;
76 class vtkQuad;
77 class vtkPolygon;
78 class vtkTriangleStrip;
79 class vtkEmptyCell;
80 
82 {
83 public:
84  static vtkPolyData *New();
85 
86  vtkTypeMacro(vtkPolyData,vtkPointSet);
87  void PrintSelf(ostream& os, vtkIndent indent);
88 
91 
94  void CopyStructure(vtkDataSet *ds);
95 
97 
99  vtkCell *GetCell(vtkIdType cellId);
100  void GetCell(vtkIdType cellId, vtkGenericCell *cell);
101  int GetCellType(vtkIdType cellId);
102  void GetCellBounds(vtkIdType cellId, double bounds[6]);
103  void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
104  vtkIdList *cellIds);
106 
108 
112  void CopyCells(vtkPolyData *pd, vtkIdList *idList,
113  vtkPointLocator *locator = NULL);
115 
117  void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
118 
121  void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
122 
124  void ComputeBounds();
125 
130  void Squeeze();
131 
133  int GetMaxCellSize();
134 
136  void SetVerts (vtkCellArray* v);
137 
140  vtkCellArray *GetVerts();
141 
143  void SetLines (vtkCellArray* l);
144 
147  vtkCellArray *GetLines();
148 
150  void SetPolys (vtkCellArray* p);
151 
154  vtkCellArray *GetPolys();
155 
157  void SetStrips (vtkCellArray* s);
158 
162  vtkCellArray *GetStrips();
163 
165 
166  vtkIdType GetNumberOfVerts();
167  vtkIdType GetNumberOfLines();
168  vtkIdType GetNumberOfPolys();
169  vtkIdType GetNumberOfStrips();
171 
176  void Allocate(vtkIdType numCells=1000, int extSize=1000);
177 
179 
188  void Allocate(vtkPolyData *inPolyData, vtkIdType numCells=1000,
189  int extSize=1000);
191 
198  int InsertNextCell(int type, int npts, vtkIdType *pts);
199 
206  int InsertNextCell(int type, vtkIdList *pts);
207 
210  void Reset();
211 
213  void BuildCells();
214 
220  void BuildLinks(int initialSize=0);
221 
225  void DeleteCells();
226 
228  void DeleteLinks();
229 
231 
232  void GetPointCells(vtkIdType ptId, unsigned short& ncells,
233  vtkIdType* &cells);
235 
237 
240  void GetCellEdgeNeighbors(vtkIdType cellId, vtkIdType p1, vtkIdType p2,
241  vtkIdList *cellIds);
243 
246  void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType* &pts);
247 
250  int IsTriangle(int v1, int v2, int v3);
251 
257  int IsEdge(vtkIdType p1, vtkIdType p2);
258 
261  int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId);
262 
268  void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
269 
271 
272  void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
273  vtkIdType newPtId);
275 
277  void ReverseCell(vtkIdType cellId);
278 
280 
281  void DeletePoint(vtkIdType ptId);
282  void DeleteCell(vtkIdType cellId);
284 
291  void RemoveDeletedCells();
292 
294 
300  int InsertNextLinkedPoint(int numLinks);
301  int InsertNextLinkedPoint(double x[3], int numLinks);
303 
307  int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
308 
315  void ReplaceLinkedCell(vtkIdType cellId, int npts, vtkIdType *pts);
316 
322  void RemoveCellReference(vtkIdType cellId);
323 
329  void AddCellReference(vtkIdType cellId);
330 
336  void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
337 
342  void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
343 
346  void ResizeCellList(vtkIdType ptId, int size);
347 
349  virtual void Initialize();
350 
354  void GetUpdateExtent(int &piece, int &numPieces, int &ghostLevel);
355 
357 
358  virtual int* GetUpdateExtent();
359  virtual void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
360  int& z0, int& z1);
361  virtual void GetUpdateExtent(int extent[6]);
363 
365 
366  virtual int GetPiece();
367  virtual int GetNumberOfPieces();
369 
371  virtual int GetGhostLevel();
372 
378  unsigned long GetActualMemorySize();
379 
381 
382  void ShallowCopy(vtkDataObject *src);
383  void DeepCopy(vtkDataObject *src);
385 
388  void RemoveGhostCells(int level);
389 
390  //BTX
392 
393  static vtkPolyData* GetData(vtkInformation* info);
394  static vtkPolyData* GetData(vtkInformationVector* v, int i=0);
395  //ETX
397 
398 //BTX
400 
414  enum
415  {
416  ERR_NO_SUCH_FIELD = -4,
417  ERR_INCORRECT_FIELD = -3,
418  ERR_NON_MANIFOLD_STAR = -2,
419  REGULAR_POINT = -1,
420  MINIMUM = 0,
421  SADDLE = 1,
422  MAXIMUM = 2
423  };
424 //ETX
425  int GetScalarFieldCriticalIndex (vtkIdType pointId,
426  vtkDataArray *scalarField);
427  int GetScalarFieldCriticalIndex (vtkIdType pointId, int fieldId);
428  int GetScalarFieldCriticalIndex (vtkIdType pointId, const char* fieldName);
430 
431 protected:
432  vtkPolyData();
433  ~vtkPolyData();
434 
435  // constant cell objects returned by GetCell called.
439  vtkPolyLine *PolyLine;
445 
446  // points inherited
447  // point data (i.e., scalars, vectors, normals, tcoords) inherited
452 
453  // dummy static member below used as a trick to simplify traversal
455 
456  // supporting structures for more complex topological operations
457  // built only when necessary
460 
461  // This method is called during an update.
462  // If the CropFilter is set, the user reqquested a piece which the
463  // source cannot generate, then it will break up the
464  // data set in order to satisfy the request.
465  virtual void Crop();
466 
467 
468 private:
469  // Hide these from the user and the compiler.
470 
472 
473  void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
474  {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
476 
477  void Cleanup();
478 
479 private:
480  vtkPolyData(const vtkPolyData&); // Not implemented.
481  void operator=(const vtkPolyData&); // Not implemented.
482 };
483 
484 inline void vtkPolyData::GetPointCells(vtkIdType ptId, unsigned short& ncells,
485  vtkIdType* &cells)
486 {
487  ncells = this->Links->GetNcells(ptId);
488  cells = this->Links->GetCells(ptId);
489 }
490 
491 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
492 {
493  unsigned short int n1;
494  int i, j, tVerts[3];
495  vtkIdType *cells, *tVerts2, n2;
496 
497  tVerts[0] = v1;
498  tVerts[1] = v2;
499  tVerts[2] = v3;
500 
501  for (i=0; i<3; i++)
502  {
503  this->GetPointCells(tVerts[i], n1, cells);
504  for (j=0; j<n1; j++)
505  {
506  this->GetCellPoints(cells[j], n2, tVerts2);
507  if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
508  tVerts[0] == tVerts2[2]) &&
509  (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
510  tVerts[1] == tVerts2[2]) &&
511  (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
512  tVerts[2] == tVerts2[2]) )
513  {
514  return 1;
515  }
516  }
517  }
518  return 0;
519 }
520 
522 {
523  vtkIdType *pts, npts;
524 
525  this->GetCellPoints(cellId, npts, pts);
526  for (vtkIdType i=0; i < npts; i++)
527  {
528  if ( pts[i] == ptId )
529  {
530  return 1;
531  }
532  }
533 
534  return 0;
535 }
536 
538 {
539  this->Links->DeletePoint(ptId);
540 }
541 
543 {
544  this->Cells->DeleteCell(cellId);
545 }
546 
548 {
549  vtkIdType *pts, npts;
550 
551  this->GetCellPoints(cellId, npts, pts);
552  for (vtkIdType i=0; i<npts; i++)
553  {
554  this->Links->RemoveCellReference(cellId, pts[i]);
555  }
556 }
557 
559 {
560  vtkIdType *pts, npts;
561 
562  this->GetCellPoints(cellId, npts, pts);
563  for (vtkIdType i=0; i<npts; i++)
564  {
565  this->Links->AddCellReference(cellId, pts[i]);
566  }
567 }
568 
569 inline void vtkPolyData::ResizeCellList(vtkIdType ptId, int size)
570 {
571  this->Links->ResizeCellList(ptId,size);
572 }
573 
575  vtkIdType newPtId)
576 {
577  int i;
578  vtkIdType *verts, nverts;
579 
580  this->GetCellPoints(cellId,nverts,verts);
581  for ( i=0; i < nverts; i++ )
582  {
583  if ( verts[i] == oldPtId )
584  {
585  verts[i] = newPtId; // this is very nasty! direct write!
586  return;
587  }
588  }
589 }
590 
591 #endif
592 
593 
static vtkCellArray * Dummy
Definition: vtkPolyData.h:454
int GetDataObjectType()
Definition: vtkPolyData.h:90
vtkCellTypes * Cells
Definition: vtkPolyData.h:458
void ComputeBounds()
virtual vtkIdType GetNumberOfCells()=0
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
Store vtkAlgorithm input/output information.
void DeleteCell(vtkIdType cellId)
Definition: vtkCellTypes.h:73
vtkCellArray * Strips
Definition: vtkPolyData.h:451
void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId, vtkIdType newPtId)
Definition: vtkPolyData.h:574
#define VTK_FILTERING_EXPORT
vtkCellArray * Lines
Definition: vtkPolyData.h:449
abstract class to specify dataset behavior
Definition: vtkDataSet.h:58
a cell that represents a 3D point
Definition: vtkVertex.h:34
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
static vtkPointSet * GetData(vtkInformation *info)
void AddCellReference(vtkIdType cellId)
Definition: vtkPolyData.h:558
void CopyStructure(vtkDataSet *pd)
vtkPolyLine * PolyLine
Definition: vtkPolyData.h:439
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:39
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:40
void Initialize()
unsigned long GetActualMemorySize()
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:30
int vtkIdType
Definition: vtkType.h:255
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:81
cell represents a set of 0D vertices
Definition: vtkPolyVertex.h:36
void Squeeze()
void RemoveCellReference(vtkIdType cellId)
Definition: vtkPolyData.h:547
void DeletePoint(vtkIdType ptId)
Definition: vtkPolyData.h:537
provides thread-safe access to cells
vtkPolyVertex * PolyVertex
Definition: vtkPolyData.h:437
a cell that represents a triangle strip
cell represents a 1D line
Definition: vtkLine.h:33
a simple class to control print indentation
Definition: vtkIndent.h:37
virtual int GetMaxCellSize()=0
int IsTriangle(int v1, int v2, int v3)
Definition: vtkPolyData.h:491
list of point or cell ids
Definition: vtkIdList.h:34
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:43
void ResizeCellList(vtkIdType ptId, int size)
Definition: vtkPolyData.h:569
vtkLine * Line
Definition: vtkPolyData.h:438
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
void PrintSelf(ostream &os, vtkIndent indent)
int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
Definition: vtkPolyData.h:521
vtkTriangle * Triangle
Definition: vtkPolyData.h:440
object to represent cell connectivity
Definition: vtkCellArray.h:48
vtkEmptyCell * EmptyCell
Definition: vtkPolyData.h:444
void DeepCopy(vtkDataObject *src)
vtkCellArray * Polys
Definition: vtkPolyData.h:450
a cell that represents a triangle
Definition: vtkTriangle.h:39
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
vtkQuad * Quad
Definition: vtkPolyData.h:441
Store zero or more vtkInformation instances.
vtkVertex * Vertex
Definition: vtkPolyData.h:436
vtkCellLinks * Links
Definition: vtkPolyData.h:459
void DeleteCell(vtkIdType cellId)
Definition: vtkPolyData.h:542
vtkCellArray * Verts
Definition: vtkPolyData.h:448
#define VTK_POLY_DATA
Definition: vtkType.h:66
void ShallowCopy(vtkDataObject *src)
helper class to get VTK data object types as string and instantiate them
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:50
virtual vtkCell * GetCell(vtkIdType cellId)=0
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
virtual int GetCellType(vtkIdType cellId)=0
vtkPolygon * Polygon
Definition: vtkPolyData.h:442
vtkTriangleStrip * TriangleStrip
Definition: vtkPolyData.h:443