00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00063 #ifndef __vtkPolyData_h
00064 #define __vtkPolyData_h
00065
00066 #include "vtkPointSet.h"
00067
00068 #include "vtkCellTypes.h"
00069 #include "vtkCellLinks.h"
00070
00071 class vtkVertex;
00072 class vtkPolyVertex;
00073 class vtkLine;
00074 class vtkPolyLine;
00075 class vtkTriangle;
00076 class vtkQuad;
00077 class vtkPolygon;
00078 class vtkTriangleStrip;
00079 class vtkEmptyCell;
00080
00081 class VTK_FILTERING_EXPORT vtkPolyData : public vtkPointSet
00082 {
00083 public:
00084 static vtkPolyData *New();
00085
00086 vtkTypeMacro(vtkPolyData,vtkPointSet);
00087 void PrintSelf(ostream& os, vtkIndent indent);
00088
00090 int GetDataObjectType() {return VTK_POLY_DATA;}
00091
00094 void CopyStructure(vtkDataSet *ds);
00095
00097
00098 vtkIdType GetNumberOfCells();
00099 vtkCell *GetCell(vtkIdType cellId);
00100 void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00101 int GetCellType(vtkIdType cellId);
00102 void GetCellBounds(vtkIdType cellId, double bounds[6]);
00103 void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00104 vtkIdList *cellIds);
00106
00108
00112 void CopyCells(vtkPolyData *pd, vtkIdList *idList,
00113 vtkPointLocator *locator = NULL);
00115
00117 void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00118
00121 void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
00122
00124 void ComputeBounds();
00125
00130 void Squeeze();
00131
00133 int GetMaxCellSize();
00134
00136 void SetVerts (vtkCellArray* v);
00137
00140 vtkCellArray *GetVerts();
00141
00143 void SetLines (vtkCellArray* l);
00144
00147 vtkCellArray *GetLines();
00148
00150 void SetPolys (vtkCellArray* p);
00151
00154 vtkCellArray *GetPolys();
00155
00157 void SetStrips (vtkCellArray* s);
00158
00162 vtkCellArray *GetStrips();
00163
00165
00166 vtkIdType GetNumberOfVerts();
00167 vtkIdType GetNumberOfLines();
00168 vtkIdType GetNumberOfPolys();
00169 vtkIdType GetNumberOfStrips();
00171
00176 void Allocate(vtkIdType numCells=1000, int extSize=1000);
00177
00179
00188 void Allocate(vtkPolyData *inPolyData, vtkIdType numCells=1000,
00189 int extSize=1000);
00191
00198 int InsertNextCell(int type, int npts, vtkIdType *pts);
00199
00206 int InsertNextCell(int type, vtkIdList *pts);
00207
00210 void Reset();
00211
00213 void BuildCells();
00214
00220 void BuildLinks(int initialSize=0);
00221
00225 void DeleteCells();
00226
00228 void DeleteLinks();
00229
00231
00232 void GetPointCells(vtkIdType ptId, unsigned short& ncells,
00233 vtkIdType* &cells);
00235
00237
00240 void GetCellEdgeNeighbors(vtkIdType cellId, vtkIdType p1, vtkIdType p2,
00241 vtkIdList *cellIds);
00243
00246 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType* &pts);
00247
00250 int IsTriangle(int v1, int v2, int v3);
00251
00257 int IsEdge(vtkIdType p1, vtkIdType p2);
00258
00261 int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId);
00262
00268 void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
00269
00271
00272 void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00273 vtkIdType newPtId);
00275
00277 void ReverseCell(vtkIdType cellId);
00278
00280
00281 void DeletePoint(vtkIdType ptId);
00282 void DeleteCell(vtkIdType cellId);
00284
00291 void RemoveDeletedCells();
00292
00294
00300 int InsertNextLinkedPoint(int numLinks);
00301 int InsertNextLinkedPoint(double x[3], int numLinks);
00303
00307 int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
00308
00315 void ReplaceLinkedCell(vtkIdType cellId, int npts, vtkIdType *pts);
00316
00322 void RemoveCellReference(vtkIdType cellId);
00323
00329 void AddCellReference(vtkIdType cellId);
00330
00336 void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00337
00342 void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00343
00346 void ResizeCellList(vtkIdType ptId, int size);
00347
00349 virtual void Initialize();
00350
00354 void GetUpdateExtent(int &piece, int &numPieces, int &ghostLevel);
00355
00357
00358 virtual int* GetUpdateExtent();
00359 virtual void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
00360 int& z0, int& z1);
00361 virtual void GetUpdateExtent(int extent[6]);
00363
00365
00366 virtual int GetPiece();
00367 virtual int GetNumberOfPieces();
00369
00371 virtual int GetGhostLevel();
00372
00378 unsigned long GetActualMemorySize();
00379
00381
00382 void ShallowCopy(vtkDataObject *src);
00383 void DeepCopy(vtkDataObject *src);
00385
00388 void RemoveGhostCells(int level);
00389
00390
00392
00393 static vtkPolyData* GetData(vtkInformation* info);
00394 static vtkPolyData* GetData(vtkInformationVector* v, int i=0);
00395
00397
00398
00400
00414 enum
00415 {
00416 ERR_NO_SUCH_FIELD = -4,
00417 ERR_INCORRECT_FIELD = -3,
00418 ERR_NON_MANIFOLD_STAR = -2,
00419 REGULAR_POINT = -1,
00420 MINIMUM = 0,
00421 SADDLE = 1,
00422 MAXIMUM = 2
00423 };
00424
00425 int GetScalarFieldCriticalIndex (vtkIdType pointId,
00426 vtkDataArray *scalarField);
00427 int GetScalarFieldCriticalIndex (vtkIdType pointId, int fieldId);
00428 int GetScalarFieldCriticalIndex (vtkIdType pointId, const char* fieldName);
00430
00431 protected:
00432 vtkPolyData();
00433 ~vtkPolyData();
00434
00435
00436 vtkVertex *Vertex;
00437 vtkPolyVertex *PolyVertex;
00438 vtkLine *Line;
00439 vtkPolyLine *PolyLine;
00440 vtkTriangle *Triangle;
00441 vtkQuad *Quad;
00442 vtkPolygon *Polygon;
00443 vtkTriangleStrip *TriangleStrip;
00444 vtkEmptyCell *EmptyCell;
00445
00446
00447
00448 vtkCellArray *Verts;
00449 vtkCellArray *Lines;
00450 vtkCellArray *Polys;
00451 vtkCellArray *Strips;
00452
00453
00454 static vtkCellArray *Dummy;
00455
00456
00457
00458 vtkCellTypes *Cells;
00459 vtkCellLinks *Links;
00460
00461
00462
00463
00464
00465 virtual void Crop();
00466
00467
00468 private:
00469
00470
00472
00473 void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00474 {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00476
00477 void Cleanup();
00478
00479 private:
00480 vtkPolyData(const vtkPolyData&);
00481 void operator=(const vtkPolyData&);
00482 };
00483
00484 inline void vtkPolyData::GetPointCells(vtkIdType ptId, unsigned short& ncells,
00485 vtkIdType* &cells)
00486 {
00487 ncells = this->Links->GetNcells(ptId);
00488 cells = this->Links->GetCells(ptId);
00489 }
00490
00491 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
00492 {
00493 unsigned short int n1;
00494 int i, j, tVerts[3];
00495 vtkIdType *cells, *tVerts2, n2;
00496
00497 tVerts[0] = v1;
00498 tVerts[1] = v2;
00499 tVerts[2] = v3;
00500
00501 for (i=0; i<3; i++)
00502 {
00503 this->GetPointCells(tVerts[i], n1, cells);
00504 for (j=0; j<n1; j++)
00505 {
00506 this->GetCellPoints(cells[j], n2, tVerts2);
00507 if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
00508 tVerts[0] == tVerts2[2]) &&
00509 (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
00510 tVerts[1] == tVerts2[2]) &&
00511 (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
00512 tVerts[2] == tVerts2[2]) )
00513 {
00514 return 1;
00515 }
00516 }
00517 }
00518 return 0;
00519 }
00520
00521 inline int vtkPolyData::IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
00522 {
00523 vtkIdType *pts, npts;
00524
00525 this->GetCellPoints(cellId, npts, pts);
00526 for (vtkIdType i=0; i < npts; i++)
00527 {
00528 if ( pts[i] == ptId )
00529 {
00530 return 1;
00531 }
00532 }
00533
00534 return 0;
00535 }
00536
00537 inline void vtkPolyData::DeletePoint(vtkIdType ptId)
00538 {
00539 this->Links->DeletePoint(ptId);
00540 }
00541
00542 inline void vtkPolyData::DeleteCell(vtkIdType cellId)
00543 {
00544 this->Cells->DeleteCell(cellId);
00545 }
00546
00547 inline void vtkPolyData::RemoveCellReference(vtkIdType cellId)
00548 {
00549 vtkIdType *pts, npts;
00550
00551 this->GetCellPoints(cellId, npts, pts);
00552 for (vtkIdType i=0; i<npts; i++)
00553 {
00554 this->Links->RemoveCellReference(cellId, pts[i]);
00555 }
00556 }
00557
00558 inline void vtkPolyData::AddCellReference(vtkIdType cellId)
00559 {
00560 vtkIdType *pts, npts;
00561
00562 this->GetCellPoints(cellId, npts, pts);
00563 for (vtkIdType i=0; i<npts; i++)
00564 {
00565 this->Links->AddCellReference(cellId, pts[i]);
00566 }
00567 }
00568
00569 inline void vtkPolyData::ResizeCellList(vtkIdType ptId, int size)
00570 {
00571 this->Links->ResizeCellList(ptId,size);
00572 }
00573
00574 inline void vtkPolyData::ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00575 vtkIdType newPtId)
00576 {
00577 int i;
00578 vtkIdType *verts, nverts;
00579
00580 this->GetCellPoints(cellId,nverts,verts);
00581 for ( i=0; i < nverts; i++ )
00582 {
00583 if ( verts[i] == oldPtId )
00584 {
00585 verts[i] = newPtId;
00586 return;
00587 }
00588 }
00589 }
00590
00591 #endif
00592
00593