Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkPolyData.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkPolyData.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00063 #ifndef __vtkPolyData_h
00064 #define __vtkPolyData_h
00065 
00066 #include "vtkPointSet.h"
00067 
00068 #include "vtkCellTypes.h" // Needed for inline methods
00069 #include "vtkCellLinks.h" // Needed for inline methods
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 
00286 
00292   int InsertNextLinkedPoint(int numLinks); 
00293   int InsertNextLinkedPoint(double x[3], int numLinks); 
00295   
00299   int InsertNextLinkedCell(int type, int npts, vtkIdType *pts); 
00300 
00307   void ReplaceLinkedCell(vtkIdType cellId, int npts, vtkIdType *pts);
00308 
00314   void RemoveCellReference(vtkIdType cellId);
00315 
00321   void AddCellReference(vtkIdType cellId);
00322 
00328   void RemoveReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00329 
00334   void AddReferenceToCell(vtkIdType ptId, vtkIdType cellId);
00335 
00338   void ResizeCellList(vtkIdType ptId, int size);
00339 
00341   virtual void Initialize();
00342 
00346   void GetUpdateExtent(int &piece, int &numPieces, int &ghostLevel);
00347 
00349 
00350   virtual int* GetUpdateExtent();
00351   virtual void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
00352                                int& z0, int& z1);
00353   virtual void GetUpdateExtent(int extent[6]);
00355 
00357 
00358   virtual int GetPiece();
00359   virtual int GetNumberOfPieces();
00361 
00363   virtual int GetGhostLevel();
00364   
00370   unsigned long GetActualMemorySize();
00371   
00373 
00374   void ShallowCopy(vtkDataObject *src);  
00375   void DeepCopy(vtkDataObject *src);
00377 
00380   void RemoveGhostCells(int level);
00381 
00382   //BTX
00384 
00385   static vtkPolyData* GetData(vtkInformation* info);
00386   static vtkPolyData* GetData(vtkInformationVector* v, int i=0);
00387   //ETX
00389 
00390 protected:
00391   vtkPolyData();
00392   ~vtkPolyData();
00393 
00394   // constant cell objects returned by GetCell called.
00395   vtkVertex *Vertex;
00396   vtkPolyVertex *PolyVertex;
00397   vtkLine *Line;
00398   vtkPolyLine *PolyLine;
00399   vtkTriangle *Triangle;
00400   vtkQuad *Quad;
00401   vtkPolygon *Polygon;
00402   vtkTriangleStrip *TriangleStrip;
00403   vtkEmptyCell *EmptyCell;
00404   
00405   // points inherited
00406   // point data (i.e., scalars, vectors, normals, tcoords) inherited
00407   vtkCellArray *Verts;
00408   vtkCellArray *Lines;
00409   vtkCellArray *Polys;
00410   vtkCellArray *Strips;
00411 
00412   // dummy static member below used as a trick to simplify traversal
00413   static vtkCellArray *Dummy;
00414 
00415   // supporting structures for more complex topological operations
00416   // built only when necessary
00417   vtkCellTypes *Cells;
00418   vtkCellLinks *Links;
00419 
00420   // This method is called during an update.  
00421   // If the CropFilter is set, the user reqquested a piece which the 
00422   // source cannot generate, then it will break up the
00423   // data set in order to satisfy the request.
00424   virtual void Crop();
00425 
00426 
00427 private:
00428   // Hide these from the user and the compiler.
00429   
00431 
00432   void GetCellNeighbors(vtkIdType cellId, vtkIdList& ptIds, vtkIdList& cellIds)
00433     {this->GetCellNeighbors(cellId, &ptIds, &cellIds);}
00435 
00436 private:
00437   vtkPolyData(const vtkPolyData&);  // Not implemented.
00438   void operator=(const vtkPolyData&);  // Not implemented.
00439 };
00440 
00441 inline void vtkPolyData::GetPointCells(vtkIdType ptId, unsigned short& ncells, 
00442                                        vtkIdType* &cells)
00443 {
00444   ncells = this->Links->GetNcells(ptId);
00445   cells = this->Links->GetCells(ptId);
00446 }
00447 
00448 inline int vtkPolyData::IsTriangle(int v1, int v2, int v3)
00449 {
00450   unsigned short int n1;
00451   int i, j, tVerts[3];
00452   vtkIdType *cells, *tVerts2, n2;
00453   
00454   tVerts[0] = v1;
00455   tVerts[1] = v2;
00456   tVerts[2] = v3;
00457 
00458   for (i=0; i<3; i++) 
00459     {
00460     this->GetPointCells(tVerts[i], n1, cells);
00461     for (j=0; j<n1; j++) 
00462       {
00463       this->GetCellPoints(cells[j], n2, tVerts2);
00464       if ( (tVerts[0] == tVerts2[0] || tVerts[0] == tVerts2[1] ||
00465             tVerts[0] == tVerts2[2]) &&
00466            (tVerts[1] == tVerts2[0] || tVerts[1] == tVerts2[1] ||
00467             tVerts[1] == tVerts2[2]) &&
00468            (tVerts[2] == tVerts2[0] || tVerts[2] == tVerts2[1] ||
00469             tVerts[2] == tVerts2[2]) )
00470         {
00471         return 1;
00472         }
00473       }
00474     }
00475   return 0;
00476 }
00477 
00478 inline int vtkPolyData::IsPointUsedByCell(vtkIdType ptId, vtkIdType cellId)
00479 {
00480   vtkIdType *pts, npts;
00481   
00482   this->GetCellPoints(cellId, npts, pts);
00483   for (vtkIdType i=0; i < npts; i++)
00484     {
00485     if ( pts[i] == ptId )
00486       {
00487       return 1;
00488       }
00489     }
00490 
00491   return 0;
00492 }
00493 
00494 inline void vtkPolyData::DeletePoint(vtkIdType ptId)
00495 {
00496   this->Links->DeletePoint(ptId);
00497 }
00498 
00499 inline void vtkPolyData::DeleteCell(vtkIdType cellId)
00500 {
00501   this->Cells->DeleteCell(cellId);
00502 }
00503 
00504 inline void vtkPolyData::RemoveCellReference(vtkIdType cellId)
00505 {
00506   vtkIdType *pts, npts;
00507   
00508   this->GetCellPoints(cellId, npts, pts);
00509   for (vtkIdType i=0; i<npts; i++)
00510     {
00511     this->Links->RemoveCellReference(cellId, pts[i]);
00512     }
00513 }
00514 
00515 inline void vtkPolyData::AddCellReference(vtkIdType cellId)
00516 {
00517   vtkIdType *pts, npts;
00518   
00519   this->GetCellPoints(cellId, npts, pts);
00520   for (vtkIdType i=0; i<npts; i++)
00521     {
00522     this->Links->AddCellReference(cellId, pts[i]);
00523     }
00524 }
00525 
00526 inline void vtkPolyData::ResizeCellList(vtkIdType ptId, int size)
00527 {
00528   this->Links->ResizeCellList(ptId,size);
00529 }
00530 
00531 inline void vtkPolyData::ReplaceCellPoint(vtkIdType cellId, vtkIdType oldPtId,
00532                                           vtkIdType newPtId)
00533 {
00534   int i;
00535   vtkIdType *verts, nverts;
00536   
00537   this->GetCellPoints(cellId,nverts,verts);
00538   for ( i=0; i < nverts; i++ )
00539     {
00540     if ( verts[i] == oldPtId ) 
00541       {
00542       verts[i] = newPtId; // this is very nasty! direct write!
00543       return;
00544       }
00545     }
00546 }
00547 
00548 #endif
00549 
00550 

Generated on Mon Jan 21 23:07:20 2008 for VTK by  doxygen 1.4.3-20050530