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 vtkTypeRevisionMacro(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 protected:
00399 vtkPolyData();
00400 ~vtkPolyData();
00401
00402
00403 vtkVertex *Vertex;
00404 vtkPolyVertex *PolyVertex;
00405 vtkLine *Line;
00406 vtkPolyLine *PolyLine;
00407 vtkTriangle *Triangle;
00408 vtkQuad *Quad;
00409 vtkPolygon *Polygon;
00410 vtkTriangleStrip *TriangleStrip;
00411 vtkEmptyCell *EmptyCell;
00412
00413
00414
00415 vtkCellArray *Verts;
00416 vtkCellArray *Lines;
00417 vtkCellArray *Polys;
00418 vtkCellArray *Strips;
00419
00420
00421 static vtkCellArray *Dummy;
00422
00423
00424
00425 vtkCellTypes *Cells;
00426 vtkCellLinks *Links;
00427
00428
00429
00430
00431
00432 virtual void Crop();
00433
00434
00435 private:
00436
00437
00439
00440 void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00441 {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00443
00444 private:
00445 vtkPolyData(const vtkPolyData&);
00446 void operator=(const vtkPolyData&);
00447 };
00448
00449 inline void vtkPolyData::GetPointCells(vtkIdType ptId, unsigned short& ncells,
00450 vtkIdType* &cells)
00451 {
00452 ncells = this->Links->GetNcells(ptId);
00453 cells = this->Links->GetCells(ptId);
00454 }
00455
00456 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
00457 {
00458 unsigned short int n1;
00459 int i, j, tVerts[3];
00460 vtkIdType *cells, *tVerts2, n2;
00461
00462 tVerts[0] = v1;
00463 tVerts[1] = v2;
00464 tVerts[2] = v3;
00465
00466 for (i=0; i<3; i++)
00467 {
00468 this->GetPointCells(tVerts[i], n1, cells);
00469 for (j=0; j<n1; j++)
00470 {
00471 this->GetCellPoints(cells[j], n2, tVerts2);
00472 if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
00473 tVerts[0] == tVerts2[2]) &&
00474 (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
00475 tVerts[1] == tVerts2[2]) &&
00476 (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
00477 tVerts[2] == tVerts2[2]) )
00478 {
00479 return 1;
00480 }
00481 }
00482 }
00483 return 0;
00484 }
00485
00486 inline int vtkPolyData::IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
00487 {
00488 vtkIdType *pts, npts;
00489
00490 this->GetCellPoints(cellId, npts, pts);
00491 for (vtkIdType i=0; i < npts; i++)
00492 {
00493 if ( pts[i] == ptId )
00494 {
00495 return 1;
00496 }
00497 }
00498
00499 return 0;
00500 }
00501
00502 inline void vtkPolyData::DeletePoint(vtkIdType ptId)
00503 {
00504 this->Links->DeletePoint(ptId);
00505 }
00506
00507 inline void vtkPolyData::DeleteCell(vtkIdType cellId)
00508 {
00509 this->Cells->DeleteCell(cellId);
00510 }
00511
00512 inline void vtkPolyData::RemoveCellReference(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->RemoveCellReference(cellId, pts[i]);
00520 }
00521 }
00522
00523 inline void vtkPolyData::AddCellReference(vtkIdType cellId)
00524 {
00525 vtkIdType *pts, npts;
00526
00527 this->GetCellPoints(cellId, npts, pts);
00528 for (vtkIdType i=0; i<npts; i++)
00529 {
00530 this->Links->AddCellReference(cellId, pts[i]);
00531 }
00532 }
00533
00534 inline void vtkPolyData::ResizeCellList(vtkIdType ptId, int size)
00535 {
00536 this->Links->ResizeCellList(ptId,size);
00537 }
00538
00539 inline void vtkPolyData::ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00540 vtkIdType newPtId)
00541 {
00542 int i;
00543 vtkIdType *verts, nverts;
00544
00545 this->GetCellPoints(cellId,nverts,verts);
00546 for ( i=0; i < nverts; i++ )
00547 {
00548 if ( verts[i] == oldPtId )
00549 {
00550 verts[i] = newPtId;
00551 return;
00552 }
00553 }
00554 }
00555
00556 #endif
00557
00558