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