00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00067 #ifndef __vtkPolyData_h
00068 #define __vtkPolyData_h
00069
00070 #include "vtkPointSet.h"
00071 #include "vtkPoints.h"
00072 #include "vtkCellArray.h"
00073 #include "vtkCellTypes.h"
00074 #include "vtkCellLinks.h"
00075
00076 class vtkVertex;
00077 class vtkPolyVertex;
00078 class vtkLine;
00079 class vtkPolyLine;
00080 class vtkTriangle;
00081 class vtkQuad;
00082 class vtkPolygon;
00083 class vtkTriangleStrip;
00084 class vtkEmptyCell;
00085
00086
00087
00088 class VTK_EXPORT vtkPolyData : public vtkPointSet
00089 {
00090 public:
00091 static vtkPolyData *New();
00092
00093 vtkTypeMacro(vtkPolyData,vtkPointSet);
00094 void PrintSelf(ostream& os, vtkIndent indent);
00095
00097 vtkDataObject *MakeObject() {return vtkPolyData::New();};
00098
00100 int GetDataObjectType() {return VTK_POLY_DATA;}
00101
00104 void CopyStructure(vtkDataSet *ds);
00105
00107 int GetNumberOfCells();
00108 vtkCell *GetCell(int cellId);
00109 void GetCell(int cellId, vtkGenericCell *cell);
00110 int GetCellType(int cellId);
00111 void GetCellBounds(int cellId, float bounds[6]);
00112 void GetCellNeighbors(int cellId, vtkIdList *ptIds, vtkIdList *cellIds);
00113
00118 void CopyCells(vtkPolyData *pd, vtkIdList *idList,
00119 vtkPointLocator *locator = NULL);
00120
00122 void GetCellPoints(int cellId, vtkIdList *ptIds);
00123
00126 void GetPointCells(int ptId, vtkIdList *cellIds);
00127
00129 void ComputeBounds();
00130
00135 void Squeeze();
00136
00138 int GetMaxCellSize();
00139
00141 void SetVerts (vtkCellArray* v);
00142
00145 vtkCellArray *GetVerts();
00146
00148 void SetLines (vtkCellArray* l);
00149
00152 vtkCellArray *GetLines();
00153
00155 void SetPolys (vtkCellArray* p);
00156
00159 vtkCellArray *GetPolys();
00160
00162 void SetStrips (vtkCellArray* s);
00163
00167 vtkCellArray *GetStrips();
00168
00170 int GetNumberOfVerts();
00171 int GetNumberOfLines();
00172 int GetNumberOfPolys();
00173 int GetNumberOfStrips();
00174
00179 void Allocate(int numCells=1000, int extSize=1000);
00180
00187 int InsertNextCell(int type, int npts, int *pts);
00188
00195 int InsertNextCell(int type, vtkIdList *pts);
00196
00199 void Reset();
00200
00202 void BuildCells();
00203
00206 void BuildLinks();
00207
00211 void DeleteCells();
00212
00214 void DeleteLinks();
00215
00217 void GetPointCells(int ptId, unsigned short& ncells, int* &cells);
00218
00222 void GetCellEdgeNeighbors(int cellId, int p1, int p2, vtkIdList *cellIds);
00223
00226 void GetCellPoints(int cellId, int& npts, int* &pts);
00227
00230 int IsTriangle(int v1, int v2, int v3);
00231
00234 int IsEdge(int v1, int v2);
00235
00238 int IsPointUsedByCell(int ptId, int cellId);
00239
00245 void ReplaceCell(int cellId, int npts, int *pts);
00246
00248 void ReplaceCellPoint(int cellId, int oldPtId, int newPtId);
00249
00251 void ReverseCell(int cellId);
00252
00254 void DeletePoint(int ptId);
00255 void DeleteCell(int cellId);
00256
00261 int InsertNextLinkedPoint(float x[3], int numLinks);
00262
00266 int InsertNextLinkedCell(int type, int npts, int *pts);
00267
00274 void ReplaceLinkedCell(int cellId, int npts, int *pts);
00275
00281 void RemoveCellReference(int cellId);
00282
00288 void AddCellReference(int cellId);
00289
00295 void RemoveReferenceToCell(int ptId, int cellId);
00296
00301 void AddReferenceToCell(int ptId, int cellId);
00302
00305 void ResizeCellList(int ptId, int size);
00306
00308 virtual void Initialize();
00309
00313 void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
00314 void SetUpdateExtent(int piece, int numPieces)
00315 {this->SetUpdateExtent(piece, numPieces, 0);}
00316 void GetUpdateExtent(int &piece, int &numPieces, int &ghostLevel);
00317
00319 vtkGetVector6Macro( UpdateExtent, int );
00320
00325 void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
00326 { this->vtkPointSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00327 void SetUpdateExtent( int ext[6] )
00328 { this->vtkPointSet::SetUpdateExtent( ext ); };
00329
00332 vtkGetMacro( Piece, int );
00333 vtkGetMacro( NumberOfPieces, int );
00334
00336 vtkGetMacro( GhostLevel, int );
00337
00343 unsigned long GetActualMemorySize();
00344
00346 void ShallowCopy(vtkDataObject *src);
00347 void DeepCopy(vtkDataObject *src);
00348
00349 #ifndef VTK_REMOVE_LEGACY_CODE
00350
00351 void GetCellPoints(int cellId, vtkIdList &ptIds)
00352 {VTK_LEGACY_METHOD(GetCellPoints,"3.2"); this->GetCellPoints(cellId, &ptIds);}
00353 void GetPointCells(int ptId, vtkIdList &cellIds)
00354 {VTK_LEGACY_METHOD(GetPointCells,"3.2"); this->GetPointCells(ptId, &cellIds);}
00355 int InsertNextCell(int type, vtkIdList &pts)
00356 {VTK_LEGACY_METHOD(InsertNextCell,"3.2"); return this->InsertNextCell(type, &pts);}
00357 void GetCellEdgeNeighbors(int cellId, int p1, int p2, vtkIdList& cellIds)
00358 {VTK_LEGACY_METHOD(GetCellEdgeNeighbors,"3.2"); this->GetCellEdgeNeighbors(cellId, p1, p2, &cellIds);}
00359 #endif
00360
00361 protected:
00362 vtkPolyData();
00363 ~vtkPolyData();
00364 vtkPolyData(const vtkPolyData&) {};
00365 void operator=(const vtkPolyData&) {};
00366
00367
00368 vtkVertex *Vertex;
00369 vtkPolyVertex *PolyVertex;
00370 vtkLine *Line;
00371 vtkPolyLine *PolyLine;
00372 vtkTriangle *Triangle;
00373 vtkQuad *Quad;
00374 vtkPolygon *Polygon;
00375 vtkTriangleStrip *TriangleStrip;
00376 vtkEmptyCell *EmptyCell;
00377
00378
00379
00380 vtkCellArray *Verts;
00381 vtkCellArray *Lines;
00382 vtkCellArray *Polys;
00383 vtkCellArray *Strips;
00384
00385
00386 static vtkCellArray *Dummy;
00387
00388
00389
00390 vtkCellTypes *Cells;
00391 vtkCellLinks *Links;
00392
00393 private:
00394
00395
00397 void GetCellNeighbors(int cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00398 {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00399
00400 };
00401
00402 inline void vtkPolyData::GetPointCells(int ptId, unsigned short& ncells,
00403 int* &cells)
00404 {
00405 ncells = this->Links->GetNcells(ptId);
00406 cells = this->Links->GetCells(ptId);
00407 }
00408
00409 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
00410 {
00411 unsigned short int n1;
00412 int i, j, n2, *cells, tVerts[3], *tVerts2;
00413
00414 tVerts[0] = v1;
00415 tVerts[1] = v2;
00416 tVerts[2] = v3;
00417
00418 for (i=0; i<3; i++)
00419 {
00420 this->GetPointCells(tVerts[i], n1, cells);
00421 for (j=0; j<n1; j++)
00422 {
00423 this->GetCellPoints(cells[j], n2, tVerts2);
00424 if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
00425 tVerts[0] == tVerts2[2]) &&
00426 (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
00427 tVerts[1] == tVerts2[2]) &&
00428 (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
00429 tVerts[2] == tVerts2[2]) )
00430 {
00431 return 1;
00432 }
00433 }
00434 }
00435 return 0;
00436 }
00437
00438 inline int vtkPolyData::IsPointUsedByCell(int ptId, int cellId)
00439 {
00440 int npts, *pts;
00441 this->GetCellPoints(cellId, npts, pts);
00442 for (int i=0; i < npts; i++)
00443 {
00444 if ( pts[i] == ptId )
00445 {
00446 return 1;
00447 }
00448 }
00449
00450 return 0;
00451 }
00452
00453 inline int vtkPolyData::IsEdge(int p1, int p2)
00454 {
00455 unsigned short int ncells;
00456 int i, *cells;
00457
00458 this->GetPointCells(p1,ncells,cells);
00459 for (i=0; i < ncells; i++)
00460 {
00461 if ( this->IsPointUsedByCell(p2,cells[i]) )
00462 {
00463 return 1;
00464 }
00465 }
00466
00467 return 0;
00468 }
00469
00470 inline void vtkPolyData::DeletePoint(int ptId)
00471 {
00472 this->Links->DeletePoint(ptId);
00473 }
00474
00475 inline void vtkPolyData::DeleteCell(int cellId)
00476 {
00477 this->Cells->DeleteCell(cellId);
00478 }
00479
00480 inline void vtkPolyData::RemoveCellReference(int cellId)
00481 {
00482 int npts, *pts;
00483 this->GetCellPoints(cellId, npts, pts);
00484 for (int i=0; i<npts; i++)
00485 {
00486 this->Links->RemoveCellReference(cellId, pts[i]);
00487 }
00488 }
00489
00490 inline void vtkPolyData::AddCellReference(int cellId)
00491 {
00492 int npts, *pts;
00493 this->GetCellPoints(cellId, npts, pts);
00494 for (int i=0; i<npts; i++)
00495 {
00496 this->Links->AddCellReference(cellId, pts[i]);
00497 }
00498 }
00499
00500 inline void vtkPolyData::ResizeCellList(int ptId, int size)
00501 {
00502 this->Links->ResizeCellList(ptId,size);
00503 }
00504
00505 inline void vtkPolyData::ReplaceCellPoint(int cellId, int oldPtId, int newPtId)
00506 {
00507 int nverts, *verts, i;
00508
00509 this->GetCellPoints(cellId,nverts,verts);
00510 for ( i=0; i < nverts; i++ )
00511 {
00512 if ( verts[i] == oldPtId )
00513 {
00514 verts[i] = newPtId;
00515 return;
00516 }
00517 }
00518 }
00519
00520 #endif
00521
00522