00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00052 #ifndef __vtkPolyData_h
00053 #define __vtkPolyData_h
00054
00055 #include "vtkPointSet.h"
00056
00057 #include "vtkCellTypes.h"
00058 #include "vtkCellLinks.h"
00059
00060 class vtkVertex;
00061 class vtkPolyVertex;
00062 class vtkLine;
00063 class vtkPolyLine;
00064 class vtkTriangle;
00065 class vtkQuad;
00066 class vtkPolygon;
00067 class vtkTriangleStrip;
00068 class vtkEmptyCell;
00069
00070 class VTK_FILTERING_EXPORT vtkPolyData : public vtkPointSet
00071 {
00072 public:
00073 static vtkPolyData *New();
00074
00075 vtkTypeRevisionMacro(vtkPolyData,vtkPointSet);
00076 void PrintSelf(ostream& os, vtkIndent indent);
00077
00079 int GetDataObjectType() {return VTK_POLY_DATA;}
00080
00083 void CopyStructure(vtkDataSet *ds);
00084
00086
00087 vtkIdType GetNumberOfCells();
00088 vtkCell *GetCell(vtkIdType cellId);
00089 void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00090 int GetCellType(vtkIdType cellId);
00091 void GetCellBounds(vtkIdType cellId, double bounds[6]);
00092 void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00093 vtkIdList *cellIds);
00095
00097
00101 void CopyCells(vtkPolyData *pd, vtkIdList *idList,
00102 vtkPointLocator *locator = NULL);
00104
00106 void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00107
00110 void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
00111
00113 void ComputeBounds();
00114
00119 void Squeeze();
00120
00122 int GetMaxCellSize();
00123
00125 void SetVerts (vtkCellArray* v);
00126
00129 vtkCellArray *GetVerts();
00130
00132 void SetLines (vtkCellArray* l);
00133
00136 vtkCellArray *GetLines();
00137
00139 void SetPolys (vtkCellArray* p);
00140
00143 vtkCellArray *GetPolys();
00144
00146 void SetStrips (vtkCellArray* s);
00147
00151 vtkCellArray *GetStrips();
00152
00154
00155 vtkIdType GetNumberOfVerts();
00156 vtkIdType GetNumberOfLines();
00157 vtkIdType GetNumberOfPolys();
00158 vtkIdType GetNumberOfStrips();
00160
00165 void Allocate(vtkIdType numCells=1000, int extSize=1000);
00166
00168
00177 void Allocate(vtkPolyData *inPolyData, vtkIdType numCells=1000,
00178 int extSize=1000);
00180
00187 int InsertNextCell(int type, int npts, vtkIdType *pts);
00188
00195 int InsertNextCell(int type, vtkIdList *pts);
00196
00199 void Reset();
00200
00202 void BuildCells();
00203
00209 void BuildLinks(int initialSize=0);
00210
00214 void DeleteCells();
00215
00217 void DeleteLinks();
00218
00220
00221 void GetPointCells(vtkIdType ptId, unsigned short& ncells,
00222 vtkIdType* &cells);
00224
00226
00229 void GetCellEdgeNeighbors(vtkIdType cellId, vtkIdType p1, vtkIdType p2,
00230 vtkIdList *cellIds);
00232
00235 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType* &pts);
00236
00239 int IsTriangle(int v1, int v2, int v3);
00240
00246 int IsEdge(vtkIdType p1, vtkIdType p2);
00247
00250 int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId);
00251
00257 void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
00258
00260
00261 void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00262 vtkIdType newPtId);
00264
00266 void ReverseCell(vtkIdType cellId);
00267
00269
00270 void DeletePoint(vtkIdType ptId);
00271 void DeleteCell(vtkIdType cellId);
00273
00275
00281 int InsertNextLinkedPoint(int numLinks);
00282 int InsertNextLinkedPoint(double x[3], int numLinks);
00284
00288 int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
00289
00296 void ReplaceLinkedCell(vtkIdType cellId, int npts, vtkIdType *pts);
00297
00303 void RemoveCellReference(vtkIdType cellId);
00304
00310 void AddCellReference(vtkIdType cellId);
00311
00317 void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00318
00323 void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00324
00327 void ResizeCellList(vtkIdType ptId, int size);
00328
00330 virtual void Initialize();
00331
00333
00336 void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
00337 void SetUpdateExtent(int piece, int numPieces)
00338 {this->SetUpdateExtent(piece, numPieces, 0);}
00339 void GetUpdateExtent(int &piece, int &numPieces, int &ghostLevel);
00341
00343
00344 virtual int* GetUpdateExtent();
00345 virtual void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
00346 int& z0, int& z1);
00347 virtual void GetUpdateExtent(int extent[6]);
00349
00351
00355 void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
00356 { this->vtkPointSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00357 void SetUpdateExtent( int ext[6] )
00358 { this->vtkPointSet::SetUpdateExtent( ext ); };
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 protected:
00388 vtkPolyData();
00389 ~vtkPolyData();
00390
00391
00392 vtkVertex *Vertex;
00393 vtkPolyVertex *PolyVertex;
00394 vtkLine *Line;
00395 vtkPolyLine *PolyLine;
00396 vtkTriangle *Triangle;
00397 vtkQuad *Quad;
00398 vtkPolygon *Polygon;
00399 vtkTriangleStrip *TriangleStrip;
00400 vtkEmptyCell *EmptyCell;
00401
00402
00403
00404 vtkCellArray *Verts;
00405 vtkCellArray *Lines;
00406 vtkCellArray *Polys;
00407 vtkCellArray *Strips;
00408
00409
00410 static vtkCellArray *Dummy;
00411
00412
00413
00414 vtkCellTypes *Cells;
00415 vtkCellLinks *Links;
00416
00417
00418
00419
00420
00421 virtual void Crop();
00422
00423
00424 private:
00425
00426
00428
00429 void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00430 {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00432
00433 private:
00434 vtkPolyData(const vtkPolyData&);
00435 void operator=(const vtkPolyData&);
00436 };
00437
00438 inline void vtkPolyData::GetPointCells(vtkIdType ptId, unsigned short& ncells,
00439 vtkIdType* &cells)
00440 {
00441 ncells = this->Links->GetNcells(ptId);
00442 cells = this->Links->GetCells(ptId);
00443 }
00444
00445 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
00446 {
00447 unsigned short int n1;
00448 int i, j, tVerts[3];
00449 vtkIdType *cells, *tVerts2, n2;
00450
00451 tVerts[0] = v1;
00452 tVerts[1] = v2;
00453 tVerts[2] = v3;
00454
00455 for (i=0; i<3; i++)
00456 {
00457 this->GetPointCells(tVerts[i], n1, cells);
00458 for (j=0; j<n1; j++)
00459 {
00460 this->GetCellPoints(cells[j], n2, tVerts2);
00461 if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
00462 tVerts[0] == tVerts2[2]) &&
00463 (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
00464 tVerts[1] == tVerts2[2]) &&
00465 (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
00466 tVerts[2] == tVerts2[2]) )
00467 {
00468 return 1;
00469 }
00470 }
00471 }
00472 return 0;
00473 }
00474
00475 inline int vtkPolyData::IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
00476 {
00477 vtkIdType *pts, npts;
00478
00479 this->GetCellPoints(cellId, npts, pts);
00480 for (vtkIdType i=0; i < npts; i++)
00481 {
00482 if ( pts[i] == ptId )
00483 {
00484 return 1;
00485 }
00486 }
00487
00488 return 0;
00489 }
00490
00491 inline void vtkPolyData::DeletePoint(vtkIdType ptId)
00492 {
00493 this->Links->DeletePoint(ptId);
00494 }
00495
00496 inline void vtkPolyData::DeleteCell(vtkIdType cellId)
00497 {
00498 this->Cells->DeleteCell(cellId);
00499 }
00500
00501 inline void vtkPolyData::RemoveCellReference(vtkIdType cellId)
00502 {
00503 vtkIdType *pts, npts;
00504
00505 this->GetCellPoints(cellId, npts, pts);
00506 for (vtkIdType i=0; i<npts; i++)
00507 {
00508 this->Links->RemoveCellReference(cellId, pts[i]);
00509 }
00510 }
00511
00512 inline void vtkPolyData::AddCellReference(vtkIdType cellId)
00513 {
00514 vtkIdType *pts, npts;
00515
00516 this->GetCellPoints(cellId, npts, pts);
00517 for (vtkIdType i=0; i<npts; i++)
00518 {
00519 this->Links->AddCellReference(cellId, pts[i]);
00520 }
00521 }
00522
00523 inline void vtkPolyData::ResizeCellList(vtkIdType ptId, int size)
00524 {
00525 this->Links->ResizeCellList(ptId,size);
00526 }
00527
00528 inline void vtkPolyData::ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00529 vtkIdType newPtId)
00530 {
00531 int i;
00532 vtkIdType *verts, nverts;
00533
00534 this->GetCellPoints(cellId,nverts,verts);
00535 for ( i=0; i < nverts; i++ )
00536 {
00537 if ( verts[i] == oldPtId )
00538 {
00539 verts[i] = newPtId;
00540 return;
00541 }
00542 }
00543 }
00544
00545 #endif
00546
00547