|
VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkPolyhedron.h 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 =========================================================================*/ 00037 #ifndef __vtkPolyhedron_h 00038 #define __vtkPolyhedron_h 00039 00040 #include "vtkCell3D.h" 00041 00042 class vtkIdTypeArray; 00043 class vtkCellArray; 00044 class vtkTriangle; 00045 class vtkQuad; 00046 class vtkTetra; 00047 class vtkPolygon; 00048 class vtkLine; 00049 class vtkPointIdMap; 00050 class vtkIdToIdVectorMapType; 00051 class vtkIdToIdMapType; 00052 class vtkEdgeTable; 00053 class vtkPolyData; 00054 class vtkCellLocator; 00055 class vtkGenericCell; 00056 class vtkPointLocator; 00057 00058 class VTK_FILTERING_EXPORT vtkPolyhedron : public vtkCell3D 00059 { 00060 public: 00062 00063 static vtkPolyhedron *New(); 00064 vtkTypeMacro(vtkPolyhedron,vtkCell3D); 00065 void PrintSelf(ostream& os, vtkIndent indent); 00067 00069 00070 virtual void GetEdgePoints(int vtkNotUsed(edgeId), int* &vtkNotUsed(pts)) {} 00071 virtual void GetFacePoints(int vtkNotUsed(faceId), int* &vtkNotUsed(pts)) {} 00072 virtual double *GetParametricCoords(); 00074 00076 virtual int GetCellType() {return VTK_POLYHEDRON;} 00077 00079 00080 virtual int RequiresInitialization() {return 1;} 00081 virtual void Initialize(); 00083 00085 00087 virtual int GetNumberOfEdges(); 00088 virtual vtkCell *GetEdge(int); 00089 virtual int GetNumberOfFaces(); 00090 virtual vtkCell *GetFace(int faceId); 00092 00094 00098 virtual void Contour(double value, vtkDataArray *scalars, 00099 vtkIncrementalPointLocator *locator, vtkCellArray *verts, 00100 vtkCellArray *lines, vtkCellArray *polys, 00101 vtkPointData *inPd, vtkPointData *outPd, 00102 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd); 00104 00106 00114 virtual void Clip(double value, vtkDataArray *scalars, 00115 vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, 00116 vtkPointData *inPd, vtkPointData *outPd, 00117 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, 00118 int insideOut); 00120 00122 00128 virtual int EvaluatePosition(double x[3], double* closestPoint, 00129 int& subId, double pcoords[3], 00130 double& dist2, double *weights); 00132 00134 00136 virtual void EvaluateLocation(int& subId, double pcoords[3], double x[3], 00137 double *weights); 00139 00141 00145 virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double& t, 00146 double x[3], double pcoords[3], int& subId); 00148 00162 virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts); 00163 00165 00170 virtual void Derivatives(int subId, double pcoords[3], double *values, 00171 int dim, double *derivs); 00173 00176 virtual int CellBoundary(int subId, double pcoords[3], vtkIdList *pts); 00177 00180 virtual int GetParametricCenter(double pcoords[3]); 00181 00183 int IsPrimaryCell() {return 1;} 00184 00186 00189 virtual void InterpolateFunctions(double x[3], double *sf); 00190 virtual void InterpolateDerivs(double x[3], double *derivs); 00192 00194 00200 virtual int RequiresExplicitFaceRepresentation() {return 1;} 00201 virtual void SetFaces(vtkIdType *faces); 00202 virtual vtkIdType *GetFaces(); 00204 00205 // Descriprion: 00206 // A method particular to vtkPolyhedron. It determines whether a point x[3] 00207 // is inside the polyhedron or not (returns 1 is the point is inside, 0 00208 // otherwise). The tolerance is expressed in normalized space; i.e., a 00209 // fraction of the size of the bounding box. 00210 int IsInside(double x[3], double tolerance); 00211 00213 vtkPolyData* GetPolyData(); 00214 00215 protected: 00216 vtkPolyhedron(); 00217 ~vtkPolyhedron(); 00218 00219 // Internal classes for supporting operations on this cell 00220 vtkLine *Line; 00221 vtkTriangle *Triangle; 00222 vtkQuad *Quad; 00223 vtkPolygon *Polygon; 00224 vtkTetra *Tetra; 00225 vtkIdTypeArray *GlobalFaces; //these are numbered in gloabl id space 00226 vtkIdTypeArray *FaceLocations; 00227 00228 // vtkCell has the data members Points (x,y,z coordinates) and PointIds 00229 // (global cell ids corresponsing to cell canonical numbering (0,1,2,....)). 00230 // These data members are implicitly organized in canonical space, i.e., where 00231 // the cell point ids are (0,1,...,npts-1). The PointIdMap maps global point id 00232 // back to these canonoical point ids. 00233 vtkPointIdMap *PointIdMap; 00234 00235 // If edges are needed. Note that the edge numbering is in 00236 // canonical space. 00237 int EdgesGenerated; //true/false 00238 vtkEdgeTable *EdgeTable; //keep track of all edges 00239 vtkIdTypeArray *Edges; //edge pairs kept in this list, in canonical id space 00240 int GenerateEdges(); //method populates the edge table and edge array 00241 00242 // If faces need renumbering into canonical numbering space these members 00243 // are used. When initiallly loaded, the face numbering uses global dataset 00244 // ids. Once renumbered, they are converted to canonical space. 00245 vtkIdTypeArray *Faces; //these are numbered in canonical id space 00246 int FacesGenerated; 00247 void GenerateFaces(); 00248 00249 // Bounds management 00250 int BoundsComputed; 00251 void ComputeBounds(); 00252 void ComputeParametricCoordinate(double x[3], double pc[3]); 00253 void ComputePositionFromParametricCoordinate(double pc[3], double x[3]); 00254 00255 // Members for supporting geometric operations 00256 int PolyDataConstructed; 00257 vtkPolyData *PolyData; 00258 vtkCellArray *Polys; 00259 vtkIdTypeArray *PolyConnectivity; 00260 void ConstructPolyData(); 00261 int LocatorConstructed; 00262 vtkCellLocator *CellLocator; 00263 void ConstructLocator(); 00264 vtkIdList *CellIds; 00265 vtkGenericCell *Cell; 00266 00267 // This is the internal implementation of contouring a polyhedron. It is used 00268 // by both Clip and Contour functions. 00269 int InternalContour(double value, 00270 int insideOut, 00271 vtkIncrementalPointLocator *locator, 00272 vtkDataArray *inScalars, 00273 vtkDataArray *outScalars, 00274 vtkPointData *inPd, 00275 vtkPointData *outPd, 00276 vtkCellArray *contourPolys, 00277 vtkIdToIdVectorMapType & faceToPointsMap, 00278 vtkIdToIdVectorMapType & pointToFacesMap, 00279 vtkIdToIdMapType & pointIdMap); 00280 00281 00282 // Check if the polyhedron cell intersect with the contour/clip function. 00283 // If intersect, return 0. Otherwise return 1 or -1 when the polyhedron cell 00284 // is on the positive or negative side of contour/clip function respectively. 00285 int IntersectWithContour(double value, 00286 int insideOut, 00287 vtkDataArray *inScalars); 00288 00289 private: 00290 vtkPolyhedron(const vtkPolyhedron&); // Not implemented. 00291 void operator=(const vtkPolyhedron&); // Not implemented. 00292 00293 //BTX 00294 class vtkInternal; 00295 vtkInternal * Internal; 00296 //ETX 00297 }; 00298 00299 //---------------------------------------------------------------------------- 00300 inline int vtkPolyhedron::GetParametricCenter(double pcoords[3]) 00301 { 00302 pcoords[0] = pcoords[1] = pcoords[2] = 0.5; 00303 return 0; 00304 } 00305 00306 #endif
1.7.5.1