1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkConvexPointSet.h,v $
6 Date: $Date: 2002/12/26 18:24:21 $
7 Version: $Revision: 1.12 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkConvexPointSet - a 3D cell defined by a set of convex points
19 // .SECTION Description
20 // vtkConvexPointSet is a concrete implementation that represents a 3D cell
21 // defined by a convex set of points. An example of such a cell is an octant
22 // (from an octree). vtkConvexPointSet uses the ordered triangulations
23 // approach (vtkOrderedTriangulator) to create triangulations guaranteed to
24 // be compatible across shared faces. This allows a general approach to
25 // processing complex, convex cell types.
27 #ifndef __vtkConvexPointSet_h
28 #define __vtkConvexPointSet_h
30 #include "vtkCell3D.h"
32 class vtkUnstructuredGrid;
38 class VTK_COMMON_EXPORT vtkConvexPointSet : public vtkCell3D
41 static vtkConvexPointSet *New();
42 vtkTypeRevisionMacro(vtkConvexPointSet,vtkCell3D);
45 // See vtkCell3D API for description of these methods.
46 virtual void GetEdgePoints(int vtkNotUsed(edgeId), int* &vtkNotUsed(pts)) {}
47 virtual void GetFacePoints(int vtkNotUsed(faceId), int* &vtkNotUsed(pts)) {}
48 virtual float *GetParametricCoords();
51 // See the vtkCell API for descriptions of these methods.
52 virtual int GetCellType() {return VTK_CONVEX_POINT_SET;}
55 // This cell requires that it be initialized prior to access.
56 virtual int RequiresInitialization() {return 1;}
57 virtual void Initialize();
60 // A convex point set has no explicit cell edge or faces; however
61 // implicitly (after triangulation) it does. Currently the method
62 // GetNumberOfEdges() always returns 0 while the GetNumberOfFaces() returns
63 // the number of boundary triangles of the triangulation of the convex
64 // point set. The method GetNumberOfFaces() triggers a triangulation of the
65 // convex point set; repeated calls to GetFace() then return the boundary
66 // faces. (Note: GetNumberOfEdges() currently returns 0 because it is a
67 // rarely used method and hard to implement. It can be changed in the future.
68 virtual int GetNumberOfEdges() {return 0;}
69 virtual vtkCell *GetEdge(int) {return NULL;}
70 virtual int GetNumberOfFaces();
71 virtual vtkCell *GetFace(int faceId);
74 // Satisfy the vtkCell API. This method contours by triangulating the
75 // cell and then contouring the resulting tetrahedra.
76 virtual void Contour(float value, vtkDataArray *cellScalars,
77 vtkPointLocator *locator, vtkCellArray *verts,
78 vtkCellArray *lines, vtkCellArray *polys,
79 vtkPointData *inPd, vtkPointData *outPd,
80 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
83 // Satisfy the vtkCell API. This method contours by triangulating the
84 // cell and then adding clip-edge intersection points into the
85 // triangulation; extracting the clipped region.
86 virtual void Clip(float value, vtkDataArray *cellScalars,
87 vtkPointLocator *locator, vtkCellArray *connectivity,
88 vtkPointData *inPd, vtkPointData *outPd,
89 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
93 // Satisfy the vtkCell API. This method determines the subId, pcoords,
94 // and weights by triangulating the convex point set, and then
95 // determining which tetrahedron the point lies in.
96 virtual int EvaluatePosition(float x[3], float* closestPoint,
97 int& subId, float pcoords[3],
98 float& dist2, float *weights);
101 // The inverse of EvaluatePosition.
102 virtual void EvaluateLocation(int& subId, float pcoords[3], float x[3],
106 // Triangulates the cells and then intersects them to determine the
107 // intersection point.
108 virtual int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
109 float x[3], float pcoords[3], int& subId);
112 // Triangulate using methods of vtkOrderedTriangulator.
113 virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
116 // Computes derivatives by triangulating and from subId and pcoords,
117 // evaluating derivatives on the resulting tetrahedron.
118 virtual void Derivatives(int subId, float pcoords[3], float *values,
119 int dim, float *derivs);
122 // Returns the set of points forming a face of the triangulation of these
123 // points that are on the boundary of the cell that are closest
124 // parametrically to the point specified.
125 virtual int CellBoundary(int subId, float pcoords[3], vtkIdList *pts);
128 // Return the center of the cell in parametric coordinates.
129 virtual int GetParametricCenter(float pcoords[3]);
133 ~vtkConvexPointSet();
137 vtkPoints *TetraPoints;
138 vtkFloatArray *TetraScalars;
140 vtkCellArray *BoundaryTris;
141 vtkTriangle *Triangle;
142 vtkFloatArray *ParametricCoords;
145 vtkConvexPointSet(const vtkConvexPointSet&); // Not implemented.
146 void operator=(const vtkConvexPointSet&); // Not implemented.
149 inline int vtkConvexPointSet::GetParametricCenter(float pcoords[3])
151 pcoords[0] = pcoords[1] = pcoords[2] = 0.5;