00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00060 #ifndef __vtkPolyData_h
00061 #define __vtkPolyData_h
00062
00063 #include "vtkPointSet.h"
00064
00065 #include "vtkCellTypes.h"
00066 #include "vtkCellLinks.h"
00067
00068 class vtkVertex;
00069 class vtkPolyVertex;
00070 class vtkLine;
00071 class vtkPolyLine;
00072 class vtkTriangle;
00073 class vtkQuad;
00074 class vtkPolygon;
00075 class vtkTriangleStrip;
00076 class vtkEmptyCell;
00077
00078 class VTK_FILTERING_EXPORT vtkPolyData : public vtkPointSet
00079 {
00080 public:
00081 static vtkPolyData *New();
00082
00083 vtkTypeRevisionMacro(vtkPolyData,vtkPointSet);
00084 void PrintSelf(ostream& os, vtkIndent indent);
00085
00087 int GetDataObjectType() {return VTK_POLY_DATA;}
00088
00091 void CopyStructure(vtkDataSet *ds);
00092
00094
00095 vtkIdType GetNumberOfCells();
00096 vtkCell *GetCell(vtkIdType cellId);
00097 void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00098 int GetCellType(vtkIdType cellId);
00099 void GetCellBounds(vtkIdType cellId, double bounds[6]);
00100 void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00101 vtkIdList *cellIds);
00103
00105
00109 void CopyCells(vtkPolyData *pd, vtkIdList *idList,
00110 vtkPointLocator *locator = NULL);
00112
00114 void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00115
00118 void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
00119
00121 void ComputeBounds();
00122
00127 void Squeeze();
00128
00130 int GetMaxCellSize();
00131
00133 void SetVerts (vtkCellArray* v);
00134
00137 vtkCellArray *GetVerts();
00138
00140 void SetLines (vtkCellArray* l);
00141
00144 vtkCellArray *GetLines();
00145
00147 void SetPolys (vtkCellArray* p);
00148
00151 vtkCellArray *GetPolys();
00152
00154 void SetStrips (vtkCellArray* s);
00155
00159 vtkCellArray *GetStrips();
00160
00162
00163 vtkIdType GetNumberOfVerts();
00164 vtkIdType GetNumberOfLines();
00165 vtkIdType GetNumberOfPolys();
00166 vtkIdType GetNumberOfStrips();
00168
00173 void Allocate(vtkIdType numCells=1000, int extSize=1000);
00174
00176
00185 void Allocate(vtkPolyData *inPolyData, vtkIdType numCells=1000,
00186 int extSize=1000);
00188
00195 int InsertNextCell(int type, int npts, vtkIdType *pts);
00196
00203 int InsertNextCell(int type, vtkIdList *pts);
00204
00207 void Reset();
00208
00210 void BuildCells();
00211
00217 void BuildLinks(int initialSize=0);
00218
00222 void DeleteCells();
00223
00225 void DeleteLinks();
00226
00228
00229 void GetPointCells(vtkIdType ptId, unsigned short& ncells,
00230 vtkIdType* &cells);
00232
00234
00237 void GetCellEdgeNeighbors(vtkIdType cellId, vtkIdType p1, vtkIdType p2,
00238 vtkIdList *cellIds);
00240
00243 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType* &pts);
00244
00247 int IsTriangle(int v1, int v2, int v3);
00248
00254 int IsEdge(vtkIdType p1, vtkIdType p2);
00255
00258 int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId);
00259
00265 void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
00266
00268
00269 void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00270 vtkIdType newPtId);
00272
00274 void ReverseCell(vtkIdType cellId);
00275
00277
00278 void DeletePoint(vtkIdType ptId);
00279 void DeleteCell(vtkIdType cellId);
00281
00288 void RemoveDeletedCells();
00289
00291
00297 int InsertNextLinkedPoint(int numLinks);
00298 int InsertNextLinkedPoint(double x[3], int numLinks);
00300
00304 int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
00305
00312 void ReplaceLinkedCell(vtkIdType cellId, int npts, vtkIdType *pts);
00313
00319 void RemoveCellReference(vtkIdType cellId);
00320
00326 void AddCellReference(vtkIdType cellId);
00327
00333 void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00334
00339 void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00340
00343 void ResizeCellList(vtkIdType ptId, int size);
00344
00346 virtual void Initialize();
00347
00351 void GetUpdateExtent(int &piece, int &numPieces, int &ghostLevel);
00352
00354
00355 virtual int* GetUpdateExtent();
00356 virtual void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
00357 int& z0, int& z1);
00358 virtual void GetUpdateExtent(int extent[6]);
00360
00362
00363 virtual int GetPiece();
00364 virtual int GetNumberOfPieces();
00366
00368 virtual int GetGhostLevel();
00369
00375 unsigned long GetActualMemorySize();
00376
00378
00379 void ShallowCopy(vtkDataObject *src);
00380 void DeepCopy(vtkDataObject *src);
00382
00385 void RemoveGhostCells(int level);
00386
00387
00389
00390 static vtkPolyData* GetData(vtkInformation* info);
00391 static vtkPolyData* GetData(vtkInformationVector* v, int i=0);
00392
00394
00395 protected:
00396 vtkPolyData();
00397 ~vtkPolyData();
00398
00399
00400 vtkVertex *Vertex;
00401 vtkPolyVertex *PolyVertex;
00402 vtkLine *Line;
00403 vtkPolyLine *PolyLine;
00404 vtkTriangle *Triangle;
00405 vtkQuad *Quad;
00406 vtkPolygon *Polygon;
00407 vtkTriangleStrip *TriangleStrip;
00408 vtkEmptyCell *EmptyCell;
00409
00410
00411
00412 vtkCellArray *Verts;
00413 vtkCellArray *Lines;
00414 vtkCellArray *Polys;
00415 vtkCellArray *Strips;
00416
00417
00418 static vtkCellArray *Dummy;
00419
00420
00421
00422 vtkCellTypes *Cells;
00423 vtkCellLinks *Links;
00424
00425
00426
00427
00428
00429 virtual void Crop();
00430
00431
00432 private:
00433
00434
00436
00437 void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00438 {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00440
00441 private:
00442 vtkPolyData(const vtkPolyData&);
00443 void operator=(const vtkPolyData&);
00444 };
00445
00446 inline void vtkPolyData::GetPointCells(vtkIdType ptId, unsigned short& ncells,
00447 vtkIdType* &cells)
00448 {
00449 ncells = this->Links->GetNcells(ptId);
00450 cells = this->Links->GetCells(ptId);
00451 }
00452
00453 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
00454 {
00455 unsigned short int n1;
00456 int i, j, tVerts[3];
00457 vtkIdType *cells, *tVerts2, n2;
00458
00459 tVerts[0] = v1;
00460 tVerts[1] = v2;
00461 tVerts[2] = v3;
00462
00463 for (i=0; i<3; i++)
00464 {
00465 this->GetPointCells(tVerts[i], n1, cells);
00466 for (j=0; j<n1; j++)
00467 {
00468 this->GetCellPoints(cells[j], n2, tVerts2);
00469 if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
00470 tVerts[0] == tVerts2[2]) &&
00471 (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
00472 tVerts[1] == tVerts2[2]) &&
00473 (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
00474 tVerts[2] == tVerts2[2]) )
00475 {
00476 return 1;
00477 }
00478 }
00479 }
00480 return 0;
00481 }
00482
00483 inline int vtkPolyData::IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
00484 {
00485 vtkIdType *pts, npts;
00486
00487 this->GetCellPoints(cellId, npts, pts);
00488 for (vtkIdType i=0; i < npts; i++)
00489 {
00490 if ( pts[i] == ptId )
00491 {
00492 return 1;
00493 }
00494 }
00495
00496 return 0;
00497 }
00498
00499 inline void vtkPolyData::DeletePoint(vtkIdType ptId)
00500 {
00501 this->Links->DeletePoint(ptId);
00502 }
00503
00504 inline void vtkPolyData::DeleteCell(vtkIdType cellId)
00505 {
00506 this->Cells->DeleteCell(cellId);
00507 }
00508
00509 inline void vtkPolyData::RemoveCellReference(vtkIdType cellId)
00510 {
00511 vtkIdType *pts, npts;
00512
00513 this->GetCellPoints(cellId, npts, pts);
00514 for (vtkIdType i=0; i<npts; i++)
00515 {
00516 this->Links->RemoveCellReference(cellId, pts[i]);
00517 }
00518 }
00519
00520 inline void vtkPolyData::AddCellReference(vtkIdType cellId)
00521 {
00522 vtkIdType *pts, npts;
00523
00524 this->GetCellPoints(cellId, npts, pts);
00525 for (vtkIdType i=0; i<npts; i++)
00526 {
00527 this->Links->AddCellReference(cellId, pts[i]);
00528 }
00529 }
00530
00531 inline void vtkPolyData::ResizeCellList(vtkIdType ptId, int size)
00532 {
00533 this->Links->ResizeCellList(ptId,size);
00534 }
00535
00536 inline void vtkPolyData::ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00537 vtkIdType newPtId)
00538 {
00539 int i;
00540 vtkIdType *verts, nverts;
00541
00542 this->GetCellPoints(cellId,nverts,verts);
00543 for ( i=0; i < nverts; i++ )
00544 {
00545 if ( verts[i] == oldPtId )
00546 {
00547 verts[i] = newPtId;
00548 return;
00549 }
00550 }
00551 }
00552
00553 #endif
00554
00555