00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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_COMMON_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, float 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
00214 void BuildLinks();
00215
00219 void DeleteCells();
00220
00222 void DeleteLinks();
00223
00225
00226 void GetPointCells(vtkIdType ptId, unsigned short& ncells,
00227 vtkIdType* &cells);
00229
00231
00234 void GetCellEdgeNeighbors(vtkIdType cellId, vtkIdType p1, vtkIdType p2,
00235 vtkIdList *cellIds);
00237
00240 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType* &pts);
00241
00244 int IsTriangle(int v1, int v2, int v3);
00245
00248 int IsEdge(int v1, int v2);
00249
00252 int IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId);
00253
00259 void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts);
00260
00262
00263 void ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00264 vtkIdType newPtId);
00266
00268 void ReverseCell(vtkIdType cellId);
00269
00271
00272 void DeletePoint(vtkIdType ptId);
00273 void DeleteCell(vtkIdType cellId);
00275
00280 int InsertNextLinkedPoint(float x[3], int numLinks);
00281
00285 int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
00286
00293 void ReplaceLinkedCell(vtkIdType cellId, int npts, vtkIdType *pts);
00294
00300 void RemoveCellReference(vtkIdType cellId);
00301
00307 void AddCellReference(vtkIdType cellId);
00308
00314 void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00315
00320 void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00321
00324 void ResizeCellList(vtkIdType ptId, int size);
00325
00327 virtual void Initialize();
00328
00330
00333 void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
00334 void SetUpdateExtent(int piece, int numPieces)
00335 {this->SetUpdateExtent(piece, numPieces, 0);}
00336 void GetUpdateExtent(int &piece, int &numPieces, int &ghostLevel);
00338
00340
00341 vtkGetVector6Macro( UpdateExtent, int );
00343
00345
00349 void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
00350 { this->vtkPointSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00351 void SetUpdateExtent( int ext[6] )
00352 { this->vtkPointSet::SetUpdateExtent( ext ); };
00354
00356
00358 vtkGetMacro( Piece, int );
00359 vtkGetMacro( NumberOfPieces, int );
00361
00363
00364 vtkGetMacro( GhostLevel, int );
00366
00372 unsigned long GetActualMemorySize();
00373
00375
00376 void ShallowCopy(vtkDataObject *src);
00377 void DeepCopy(vtkDataObject *src);
00379
00382 void RemoveGhostCells(int level);
00383
00384 protected:
00385 vtkPolyData();
00386 ~vtkPolyData();
00387
00388
00389 vtkVertex *Vertex;
00390 vtkPolyVertex *PolyVertex;
00391 vtkLine *Line;
00392 vtkPolyLine *PolyLine;
00393 vtkTriangle *Triangle;
00394 vtkQuad *Quad;
00395 vtkPolygon *Polygon;
00396 vtkTriangleStrip *TriangleStrip;
00397 vtkEmptyCell *EmptyCell;
00398
00399
00400
00401 vtkCellArray *Verts;
00402 vtkCellArray *Lines;
00403 vtkCellArray *Polys;
00404 vtkCellArray *Strips;
00405
00406
00407 static vtkCellArray *Dummy;
00408
00409
00410
00411 vtkCellTypes *Cells;
00412 vtkCellLinks *Links;
00413
00414
00415
00416
00417
00418 virtual void Crop();
00419
00420
00421 private:
00422
00423
00425
00426 void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00427 {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00429
00430 private:
00431 vtkPolyData(const vtkPolyData&);
00432 void operator=(const vtkPolyData&);
00433 };
00434
00435 inline void vtkPolyData::GetPointCells(vtkIdType ptId, unsigned short& ncells,
00436 vtkIdType* &cells)
00437 {
00438 ncells = this->Links->GetNcells(ptId);
00439 cells = this->Links->GetCells(ptId);
00440 }
00441
00442 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
00443 {
00444 unsigned short int n1;
00445 int i, j, tVerts[3];
00446 vtkIdType *cells, *tVerts2, n2;
00447
00448 tVerts[0] = v1;
00449 tVerts[1] = v2;
00450 tVerts[2] = v3;
00451
00452 for (i=0; i<3; i++)
00453 {
00454 this->GetPointCells(tVerts[i], n1, cells);
00455 for (j=0; j<n1; j++)
00456 {
00457 this->GetCellPoints(cells[j], n2, tVerts2);
00458 if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
00459 tVerts[0] == tVerts2[2]) &&
00460 (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
00461 tVerts[1] == tVerts2[2]) &&
00462 (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
00463 tVerts[2] == tVerts2[2]) )
00464 {
00465 return 1;
00466 }
00467 }
00468 }
00469 return 0;
00470 }
00471
00472 inline int vtkPolyData::IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
00473 {
00474 vtkIdType *pts, npts;
00475
00476 this->GetCellPoints(cellId, npts, pts);
00477 for (vtkIdType i=0; i < npts; i++)
00478 {
00479 if ( pts[i] == ptId )
00480 {
00481 return 1;
00482 }
00483 }
00484
00485 return 0;
00486 }
00487
00488 inline int vtkPolyData::IsEdge(int p1, int p2)
00489 {
00490 unsigned short int ncells;
00491 int i;
00492 vtkIdType *cells;
00493
00494 this->GetPointCells(p1,ncells,cells);
00495 for (i=0; i < ncells; i++)
00496 {
00497 if ( this->IsPointUsedByCell(p2,cells[i]) )
00498 {
00499 return 1;
00500 }
00501 }
00502
00503 return 0;
00504 }
00505
00506 inline void vtkPolyData::DeletePoint(vtkIdType ptId)
00507 {
00508 this->Links->DeletePoint(ptId);
00509 }
00510
00511 inline void vtkPolyData::DeleteCell(vtkIdType cellId)
00512 {
00513 this->Cells->DeleteCell(cellId);
00514 }
00515
00516 inline void vtkPolyData::RemoveCellReference(vtkIdType cellId)
00517 {
00518 vtkIdType *pts, npts;
00519
00520 this->GetCellPoints(cellId, npts, pts);
00521 for (vtkIdType i=0; i<npts; i++)
00522 {
00523 this->Links->RemoveCellReference(cellId, pts[i]);
00524 }
00525 }
00526
00527 inline void vtkPolyData::AddCellReference(vtkIdType cellId)
00528 {
00529 vtkIdType *pts, npts;
00530
00531 this->GetCellPoints(cellId, npts, pts);
00532 for (vtkIdType i=0; i<npts; i++)
00533 {
00534 this->Links->AddCellReference(cellId, pts[i]);
00535 }
00536 }
00537
00538 inline void vtkPolyData::ResizeCellList(vtkIdType ptId, int size)
00539 {
00540 this->Links->ResizeCellList(ptId,size);
00541 }
00542
00543 inline void vtkPolyData::ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00544 vtkIdType newPtId)
00545 {
00546 int i;
00547 vtkIdType *verts, nverts;
00548
00549 this->GetCellPoints(cellId,nverts,verts);
00550 for ( i=0; i < nverts; i++ )
00551 {
00552 if ( verts[i] == oldPtId )
00553 {
00554 verts[i] = newPtId;
00555 return;
00556 }
00557 }
00558 }
00559
00560 #endif
00561
00562