00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00046
#ifndef __vtkPolyData_h
00047
#define __vtkPolyData_h
00048
00049
#include "vtkPointSet.h"
00050
00051
#include "vtkCellTypes.h"
00052
#include "vtkCellLinks.h"
00053
00054
class vtkVertex;
00055
class vtkPolyVertex;
00056
class vtkLine;
00057
class vtkPolyLine;
00058
class vtkTriangle;
00059
class vtkQuad;
00060
class vtkPolygon;
00061
class vtkTriangleStrip;
00062
class vtkEmptyCell;
00063
00064 class VTK_COMMON_EXPORT vtkPolyData :
public vtkPointSet
00065 {
00066
public:
00067
static vtkPolyData *
New();
00068
00069 vtkTypeRevisionMacro(vtkPolyData,
vtkPointSet);
00070
void PrintSelf(ostream& os,
vtkIndent indent);
00071
00073 int GetDataObjectType() {
return VTK_POLY_DATA;}
00074
00077
void CopyStructure(
vtkDataSet *ds);
00078
00080
00081
vtkIdType GetNumberOfCells();
00082
vtkCell *
GetCell(
vtkIdType cellId);
00083
void GetCell(
vtkIdType cellId,
vtkGenericCell *cell);
00084
int GetCellType(
vtkIdType cellId);
00085
void GetCellBounds(
vtkIdType cellId,
float bounds[6]);
00086
void GetCellNeighbors(
vtkIdType cellId,
vtkIdList *ptIds,
00087
vtkIdList *cellIds);
00089
00091
00095
void CopyCells(vtkPolyData *pd,
vtkIdList *idList,
00096
vtkPointLocator *locator = NULL);
00098
00100
void GetCellPoints(
vtkIdType cellId,
vtkIdList *ptIds);
00101
00104
void GetPointCells(
vtkIdType ptId,
vtkIdList *cellIds);
00105
00107
void ComputeBounds();
00108
00113
void Squeeze();
00114
00116
int GetMaxCellSize();
00117
00119
void SetVerts (
vtkCellArray* v);
00120
00123
vtkCellArray *GetVerts();
00124
00126
void SetLines (
vtkCellArray* l);
00127
00130
vtkCellArray *GetLines();
00131
00133
void SetPolys (
vtkCellArray* p);
00134
00137
vtkCellArray *GetPolys();
00138
00140
void SetStrips (
vtkCellArray* s);
00141
00145
vtkCellArray *GetStrips();
00146
00148
00149
vtkIdType GetNumberOfVerts();
00150
vtkIdType GetNumberOfLines();
00151
vtkIdType GetNumberOfPolys();
00152
vtkIdType GetNumberOfStrips();
00154
00159
void Allocate(
vtkIdType numCells=1000,
int extSize=1000);
00160
00162
00171
void Allocate(vtkPolyData *inPolyData,
vtkIdType numCells=1000,
00172
int extSize=1000);
00174
00181
int InsertNextCell(
int type,
int npts,
vtkIdType *pts);
00182
00189
int InsertNextCell(
int type,
vtkIdList *pts);
00190
00193
void Reset();
00194
00196
void BuildCells();
00197
00203
void BuildLinks(
int initialSize=0);
00204
00208
void DeleteCells();
00209
00211
void DeleteLinks();
00212
00214
00215
void GetPointCells(
vtkIdType ptId,
unsigned short& ncells,
00216
vtkIdType* &cells);
00218
00220
00223
void GetCellEdgeNeighbors(
vtkIdType cellId,
vtkIdType p1,
vtkIdType p2,
00224
vtkIdList *cellIds);
00226
00229
void GetCellPoints(
vtkIdType cellId,
vtkIdType& npts,
vtkIdType* &pts);
00230
00233
int IsTriangle(
int v1,
int v2,
int v3);
00234
00237
int IsEdge(
int v1,
int v2);
00238
00241
int IsPointUsedByCell(
vtkIdType ptId,
vtkIdType cellId);
00242
00248
void ReplaceCell(
vtkIdType cellId,
int npts,
vtkIdType *pts);
00249
00251
00252
void ReplaceCellPoint(
vtkIdType cellId,
vtkIdType oldPtId,
00253
vtkIdType newPtId);
00255
00257
void ReverseCell(
vtkIdType cellId);
00258
00260
00261
void DeletePoint(
vtkIdType ptId);
00262
void DeleteCell(
vtkIdType cellId);
00264
00266
00272
int InsertNextLinkedPoint(
int numLinks);
00273
int InsertNextLinkedPoint(
float x[3],
int numLinks);
00275
00279
int InsertNextLinkedCell(
int type,
int npts,
vtkIdType *pts);
00280
00287
void ReplaceLinkedCell(
vtkIdType cellId,
int npts,
vtkIdType *pts);
00288
00294
void RemoveCellReference(
vtkIdType cellId);
00295
00301
void AddCellReference(
vtkIdType cellId);
00302
00308
void RemoveReferenceToCell(
vtkIdType ptId,
vtkIdType cellId);
00309
00314
void AddReferenceToCell(
vtkIdType ptId,
vtkIdType cellId);
00315
00318
void ResizeCellList(
vtkIdType ptId,
int size);
00319
00321
virtual void Initialize();
00322
00324
00327
void SetUpdateExtent(
int piece,
int numPieces,
int ghostLevel);
00328 void SetUpdateExtent(
int piece,
int numPieces)
00329 {this->
SetUpdateExtent(piece, numPieces, 0);}
00330
void GetUpdateExtent(
int &piece,
int &numPieces,
int &ghostLevel);
00332
00334
00335 vtkGetVector6Macro( UpdateExtent,
int );
00337
00339
00343 void SetUpdateExtent(
int x1,
int x2,
int y1,
int y2,
int z1,
int z2 )
00344 { this->
vtkPointSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00345 void SetUpdateExtent(
int ext[6] )
00346 { this->
vtkPointSet::SetUpdateExtent( ext ); };
00348
00350
00352 vtkGetMacro( Piece,
int );
00353 vtkGetMacro( NumberOfPieces,
int );
00355
00357
00358 vtkGetMacro( GhostLevel,
int );
00360
00366
unsigned long GetActualMemorySize();
00367
00369
00370
void ShallowCopy(
vtkDataObject *src);
00371
void DeepCopy(
vtkDataObject *src);
00373
00376
void RemoveGhostCells(
int level);
00377
00378
protected:
00379 vtkPolyData();
00380 ~vtkPolyData();
00381
00382
00383 vtkVertex *Vertex;
00384 vtkPolyVertex *PolyVertex;
00385 vtkLine *Line;
00386 vtkPolyLine *PolyLine;
00387 vtkTriangle *Triangle;
00388 vtkQuad *Quad;
00389 vtkPolygon *Polygon;
00390 vtkTriangleStrip *TriangleStrip;
00391 vtkEmptyCell *EmptyCell;
00392
00393
00394
00395 vtkCellArray *Verts;
00396 vtkCellArray *Lines;
00397 vtkCellArray *Polys;
00398 vtkCellArray *Strips;
00399
00400
00401 static vtkCellArray *Dummy;
00402
00403
00404
00405 vtkCellTypes *Cells;
00406 vtkCellLinks *Links;
00407
00408
00409
00410
00411
00412
virtual void Crop();
00413
00414
00415
private:
00416
00417
00419
00420
void GetCellNeighbors(
vtkIdType cellId,
vtkIdList& ptIds,
vtkIdList& cellIds)
00421 {this->
GetCellNeighbors(cellId, &ptIds, &cellIds);}
00423
00424
private:
00425 vtkPolyData(
const vtkPolyData&);
00426
void operator=(
const vtkPolyData&);
00427 };
00428
00429 inline void vtkPolyData::GetPointCells(
vtkIdType ptId,
unsigned short& ncells,
00430
vtkIdType* &cells)
00431 {
00432 ncells = this->
Links->
GetNcells(ptId);
00433 cells = this->
Links->
GetCells(ptId);
00434 }
00435
00436 inline int vtkPolyData::IsTriangle(
int v1,
int v2,
int v3)
00437 {
00438
unsigned short int n1;
00439
int i, j, tVerts[3];
00440
vtkIdType *cells, *tVerts2, n2;
00441
00442 tVerts[0] = v1;
00443 tVerts[1] = v2;
00444 tVerts[2] = v3;
00445
00446
for (i=0; i<3; i++)
00447 {
00448 this->
GetPointCells(tVerts[i], n1, cells);
00449
for (j=0; j<n1; j++)
00450 {
00451 this->
GetCellPoints(cells[j], n2, tVerts2);
00452
if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
00453 tVerts[0] == tVerts2[2]) &&
00454 (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
00455 tVerts[1] == tVerts2[2]) &&
00456 (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
00457 tVerts[2] == tVerts2[2]) )
00458 {
00459
return 1;
00460 }
00461 }
00462 }
00463
return 0;
00464 }
00465
00466 inline int vtkPolyData::IsPointUsedByCell(
vtkIdType ptId,
vtkIdType cellId)
00467 {
00468
vtkIdType *pts, npts;
00469
00470 this->
GetCellPoints(cellId, npts, pts);
00471
for (
vtkIdType i=0; i < npts; i++)
00472 {
00473
if ( pts[i] == ptId )
00474 {
00475
return 1;
00476 }
00477 }
00478
00479
return 0;
00480 }
00481
00482 inline int vtkPolyData::IsEdge(
int p1,
int p2)
00483 {
00484
unsigned short int ncells;
00485
int i;
00486
vtkIdType *cells;
00487
00488 this->
GetPointCells(p1,ncells,cells);
00489
for (i=0; i < ncells; i++)
00490 {
00491
if ( this->
IsPointUsedByCell(p2,cells[i]) )
00492 {
00493
return 1;
00494 }
00495 }
00496
00497
return 0;
00498 }
00499
00500 inline void vtkPolyData::DeletePoint(
vtkIdType ptId)
00501 {
00502 this->
Links->
DeletePoint(ptId);
00503 }
00504
00505 inline void vtkPolyData::DeleteCell(
vtkIdType cellId)
00506 {
00507 this->
Cells->
DeleteCell(cellId);
00508 }
00509
00510 inline void vtkPolyData::RemoveCellReference(
vtkIdType cellId)
00511 {
00512
vtkIdType *pts, npts;
00513
00514 this->
GetCellPoints(cellId, npts, pts);
00515
for (
vtkIdType i=0; i<npts; i++)
00516 {
00517 this->
Links->
RemoveCellReference(cellId, pts[i]);
00518 }
00519 }
00520
00521 inline void vtkPolyData::AddCellReference(
vtkIdType cellId)
00522 {
00523
vtkIdType *pts, npts;
00524
00525 this->
GetCellPoints(cellId, npts, pts);
00526
for (
vtkIdType i=0; i<npts; i++)
00527 {
00528 this->
Links->
AddCellReference(cellId, pts[i]);
00529 }
00530 }
00531
00532 inline void vtkPolyData::ResizeCellList(
vtkIdType ptId,
int size)
00533 {
00534 this->
Links->
ResizeCellList(ptId,size);
00535 }
00536
00537 inline void vtkPolyData::ReplaceCellPoint(
vtkIdType cellId,
vtkIdType oldPtId,
00538
vtkIdType newPtId)
00539 {
00540
int i;
00541
vtkIdType *verts, nverts;
00542
00543 this->
GetCellPoints(cellId,nverts,verts);
00544
for ( i=0; i < nverts; i++ )
00545 {
00546
if ( verts[i] == oldPtId )
00547 {
00548 verts[i] = newPtId;
00549
return;
00550 }
00551 }
00552 }
00553
00554
#endif
00555
00556