VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
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  int InsertNextCell(int type, int npts, vtkIdType *pts);
203 
210  int 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  int InsertNextLinkedPoint(int numLinks);
304  int InsertNextLinkedPoint(double x[3], int numLinks);
306 
310  int 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 
373  void DeepCopy(vtkDataObject *src);
375 
378  void RemoveGhostCells(int level);
379 
380  //BTX
382 
384  static vtkPolyData* GetData(vtkInformationVector* v, int i=0);
385  //ETX
387 
388 //BTX
390 
404  enum
405  {
406  ERR_NO_SUCH_FIELD = -4,
407  ERR_INCORRECT_FIELD = -3,
408  ERR_NON_MANIFOLD_STAR = -2,
409  REGULAR_POINT = -1,
410  MINIMUM = 0,
411  SADDLE = 1,
412  MAXIMUM = 2
413  };
414 //ETX
415  int GetScalarFieldCriticalIndex (vtkIdType pointId,
416  vtkDataArray *scalarField);
417  int GetScalarFieldCriticalIndex (vtkIdType pointId, int fieldId);
418  int GetScalarFieldCriticalIndex (vtkIdType pointId, const char* fieldName);
420 
421 protected:
422  vtkPolyData();
423  ~vtkPolyData();
424 
425  // constant cell objects returned by GetCell called.
435 
436  // points inherited
437  // point data (i.e., scalars, vectors, normals, tcoords) inherited
442 
443  // dummy static member below used as a trick to simplify traversal
444  static vtkPolyDataDummyContainter DummyContainer;
445 
446  // supporting structures for more complex topological operations
447  // built only when necessary
450 
451 private:
452  // Hide these from the user and the compiler.
453 
455 
456  void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
457  {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
459 
460  void Cleanup();
461 
462 private:
463  vtkPolyData(const vtkPolyData&); // Not implemented.
464  void operator=(const vtkPolyData&); // Not implemented.
465 };
466 
467 inline void vtkPolyData::GetPointCells(vtkIdType ptId, unsigned short& ncells,
468  vtkIdType* &cells)
469 {
470  ncells = this->Links->GetNcells(ptId);
471  cells = this->Links->GetCells(ptId);
472 }
473 
474 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
475 {
476  unsigned short int n1;
477  int i, j, tVerts[3];
478  vtkIdType *cells, *tVerts2, n2;
479 
480  tVerts[0] = v1;
481  tVerts[1] = v2;
482  tVerts[2] = v3;
483 
484  for (i=0; i<3; i++)
485  {
486  this->GetPointCells(tVerts[i], n1, cells);
487  for (j=0; j<n1; j++)
488  {
489  this->GetCellPoints(cells[j], n2, tVerts2);
490  if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
491  tVerts[0] == tVerts2[2]) &&
492  (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
493  tVerts[1] == tVerts2[2]) &&
494  (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
495  tVerts[2] == tVerts2[2]) )
496  {
497  return 1;
498  }
499  }
500  }
501  return 0;
502 }
503 
505 {
506  vtkIdType *pts, npts;
507 
508  this->GetCellPoints(cellId, npts, pts);
509  for (vtkIdType i=0; i < npts; i++)
510  {
511  if ( pts[i] == ptId )
512  {
513  return 1;
514  }
515  }
516 
517  return 0;
518 }
519 
521 {
522  this->Links->DeletePoint(ptId);
523 }
524 
526 {
527  this->Cells->DeleteCell(cellId);
528 }
529 
531 {
532  vtkIdType *pts, npts;
533 
534  this->GetCellPoints(cellId, npts, pts);
535  for (vtkIdType i=0; i<npts; i++)
536  {
537  this->Links->RemoveCellReference(cellId, pts[i]);
538  }
539 }
540 
542 {
543  vtkIdType *pts, npts;
544 
545  this->GetCellPoints(cellId, npts, pts);
546  for (vtkIdType i=0; i<npts; i++)
547  {
548  this->Links->AddCellReference(cellId, pts[i]);
549  }
550 }
551 
553 {
554  this->Links->ResizeCellList(ptId,size);
555 }
556 
558  vtkIdType newPtId)
559 {
560  int i;
561  vtkIdType *verts, nverts;
562 
563  this->GetCellPoints(cellId,nverts,verts);
564  for ( i=0; i < nverts; i++ )
565  {
566  if ( verts[i] == oldPtId )
567  {
568  verts[i] = newPtId; // this is very nasty! direct write!
569  return;
570  }
571  }
572 }
573 
574 #endif
575 
576 
GLsizeiptr size
Definition: vtkgl.h:11843
int GetDataObjectType()
Definition: vtkPolyData.h:92
vtkCellTypes * Cells
Definition: vtkPolyData.h:448
GLuint GLuint GLsizei GLenum type
Definition: vtkgl.h:11315
void ComputeBounds()
virtual vtkIdType GetNumberOfCells()=0
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
const GLdouble * v
Definition: vtkgl.h:11595
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:441
void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId, vtkIdType newPtId)
Definition: vtkPolyData.h:557
vtkCellArray * Lines
Definition: vtkPolyData.h:439
abstract class to specify dataset behavior
Definition: vtkDataSet.h:60
a cell that represents a 3D point
Definition: vtkVertex.h:35
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
GLint level
Definition: vtkgl.h:11316
static vtkPointSet * GetData(vtkInformation *info)
void AddCellReference(vtkIdType cellId)
Definition: vtkPolyData.h:541
void CopyStructure(vtkDataSet *pd)
vtkPolyLine * PolyLine
Definition: vtkPolyData.h:429
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:40
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:41
void Initialize()
unsigned long GetActualMemorySize()
an empty cell used as a place-holder during processing
Definition: vtkEmptyCell.h:31
int vtkIdType
Definition: vtkType.h:268
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:530
void DeletePoint(vtkIdType ptId)
Definition: vtkPolyData.h:520
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
provides thread-safe access to cells
vtkPolyVertex * PolyVertex
Definition: vtkPolyData.h:427
a cell that represents a triangle strip
GLfloat GLfloat GLfloat GLfloat v3
Definition: vtkgl.h:12016
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:58
GLfloat GLfloat GLfloat v2
Definition: vtkgl.h:12015
GLenum src
Definition: vtkgl.h:12525
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:474
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:53
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:44
void ResizeCellList(vtkIdType ptId, int size)
Definition: vtkPolyData.h:552
vtkLine * Line
Definition: vtkPolyData.h:428
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
void PrintSelf(ostream &os, vtkIndent indent)
int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
Definition: vtkPolyData.h:504
vtkTriangle * Triangle
Definition: vtkPolyData.h:430
object to represent cell connectivity
Definition: vtkCellArray.h:49
vtkEmptyCell * EmptyCell
Definition: vtkPolyData.h:434
void DeepCopy(vtkDataObject *src)
GLfloat GLfloat v1
Definition: vtkgl.h:12014
vtkCellArray * Polys
Definition: vtkPolyData.h:440
a cell that represents a triangle
Definition: vtkTriangle.h:40
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
vtkQuad * Quad
Definition: vtkPolyData.h:431
GLdouble s
Definition: vtkgl.h:11594
Store zero or more vtkInformation instances.
vtkVertex * Vertex
Definition: vtkPolyData.h:426
vtkCellLinks * Links
Definition: vtkPolyData.h:449
void DeleteCell(vtkIdType cellId)
Definition: vtkPolyData.h:525
static vtkPolyDataDummyContainter DummyContainer
Definition: vtkPolyData.h:444
vtkCellArray * Verts
Definition: vtkPolyData.h:438
#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
GLfloat GLfloat p
Definition: vtkgl.h:15717
vtkPolygon * Polygon
Definition: vtkPolyData.h:432
vtkTriangleStrip * TriangleStrip
Definition: vtkPolyData.h:433