Commit 143675ac authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Finalized Cell interface.

parent a209d8b8
......@@ -49,6 +49,7 @@ public:
vtkCell(): Points(MAX_CELL_SIZE), PointIds(MAX_CELL_SIZE) {};
void Initialize(int npts, int *pts, vtkPoints *p);
char *GetClassName() {return "vtkCell";};
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Create concrete copy of this cell.
......@@ -105,8 +106,15 @@ public:
// Description:
// Given a point x[3] return inside(=1) or outside(=0) cell; evaluate
// parametric coordinates, sub-cell id (!=0 only if cell is composite),
// distance squared of point x[3] to cell (in particular, the sub-cell
// indicated), and interpolation weights in cell.
// distance squared of point x[3] to cell (in particular, the sub-cell
// indicated), closest point on cell to x[3], and interpolation weights
// in cell. Note: on rare occasions a -1 is returned from the method. This
// means that numerical error has occured and all data returned from this method
// should be ignored. Also, inside/outside is determine parametrically. That
// is, a point is inside if it satisfies parametric limits. This can cause
// problems for cells of topological dimension 2 or less, since a point in
// 3D can project onto the cell within parametric limits but be "far" from
// the cell. Thus the value dist2 may be checked to determine true in/out.
virtual int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[MAX_CELL_SIZE]) = 0;
......@@ -130,6 +138,30 @@ public:
virtual int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId) = 0;
// Description:
// Generate simplices of proper dimension. If cell is 3D, tetrahedron are
// generated; if 2D triangles; if 1D lines; if 0D points. The form of the
// output is a sequence of points, each n+1 points (where n is topological
// cell dimension) defining a simplex. The index is a parameter that controls
// which triangulation to use (if more than one is possible). If numerical
// degeneracy encountered, 0 is returned, otherwise 1 is returned.
virtual int Triangulate(int index, vtkFloatPoints &pts) = 0;
// Description:
// Compute derivatives given cell subId and parametric coordinates. The values
// array is a series of data value(s) at the cell points. There is a one-to-one
// correspondance between cell point and data value(s). Dim is the number of
// data values per cell point. Derivs are derivaties in the x-y-z coordinate
// directions for each data value. Thus, if computing derivatives for a
// scalar function in a hexahedron, dim=1, 8 values are supplied, and 3 deriv
// values are returned (i.e., derivatives in x-y-z directions). On the other
// hand, if computing derivates of velocity (vx,vy,vz) dim=3, 24 values are
// supplied ((vx,vy,vz)1, (vx,vy,vz)2, ....()8), and 9 deriva values are
// returned ((d(vx)/dx),(d(vx)/dy),(d(vx)/dz), (d(vy)/dx),(d(vy)/dy),
// (d(vy)/dz), (d(vz)/dx),(d(vz)/dy),(d(vz)/dz)).
virtual void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs) = 0;
void GetBounds(float bounds[6]);
float *GetBounds();
float GetLength2();
......
......@@ -30,6 +30,7 @@ public:
vtkHexahedron(const vtkHexahedron& h);
char *GetClassName() {return "vtkHexahedron";};
// cell methods
vtkCell *MakeObject() {return new vtkHexahedron(*this);};
int GetCellType() {return vtkHEXAHEDRON;};
int GetCellDimension() {return 3;};
......@@ -49,7 +50,11 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
// Hexahedron specific
void InterpolationFunctions(float pcoords[3], float weights[8]);
void InterpolationDerivs(float pcoords[3], float derivs[24]);
......
......@@ -29,6 +29,7 @@ public:
vtkLine(const vtkLine& l);
char *GetClassName() {return "vtkLine";};
// cell methods
vtkCell *MakeObject() {return new vtkLine(*this);};
int GetCellType() {return vtkLINE;};
int GetCellDimension() {return 1;};
......@@ -49,12 +50,18 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
// line specific methods
int Intersection(float x[3], float xray[3], float x1[3], float x2[3],
float& u, float& v);
float DistanceToLine (float x[3], float p1[3], float p2[3]);
float DistanceToLine(float x[3], float p1[3], float p2[3],
float &t, float closestPoint[3]);
float DistanceToLine(float x[3], float p1[3], float p2[3]);
};
#endif
......
......@@ -31,6 +31,7 @@ public:
vtkPixel(const vtkPixel& r);
char *GetClassName() {return "vtkPixel";};
// cell methods
vtkCell *MakeObject() {return new vtkPixel(*this);};
int GetCellType() {return vtkPIXEL;};
int GetCellDimension() {return 2;};
......@@ -50,7 +51,11 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
// pixel specific
void InterpolationFunctions(float pcoords[3], float weights[4]);
};
......
......@@ -36,6 +36,7 @@ public:
int GenerateNormals(vtkPoints *, vtkCellArray *, vtkFloatNormals *);
int GenerateSlidingNormals(vtkPoints *, vtkCellArray *, vtkFloatNormals *);
// cell methods
vtkCell *MakeObject() {return new vtkPolyLine(*this);};
int GetCellType() {return vtkPOLY_LINE;};
int GetCellDimension() {return 1;};
......@@ -56,6 +57,10 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
};
#endif
......
......@@ -30,6 +30,7 @@ public:
vtkPolyVertex(const vtkPolyVertex& pp);
char *GetClassName() {return "vtkPolyVertex";};
// cell methods
vtkCell *MakeObject() {return new vtkPolyVertex(*this);};
int GetCellType() {return vtkPOLY_VERTEX;};
int GetCellDimension() {return 0;};
......@@ -49,7 +50,9 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
};
......
......@@ -36,6 +36,7 @@ public:
void ComputeNormal(float v1[3], float v2[3], float v3[3], float n[3]);
void ComputeNormal(vtkFloatPoints *p, float n[3]);
// Cell interface
vtkCell *MakeObject() {return new vtkPolygon(*this);};
int GetCellType() {return vtkPOLYGON;};
int GetCellDimension() {return 2;};
......@@ -55,7 +56,11 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
// Polygon specific
void ComputeWeights(float x[3], float weights[MAX_CELL_SIZE]);
int ParameterizePolygon(float p0[3], float p10[3], float &l10,
......
......@@ -30,6 +30,7 @@ public:
vtkQuad(const vtkQuad& q);
char *GetClassName() {return "vtkQuad";};
// cell methods
vtkCell *MakeObject() {return new vtkQuad(*this);};
int GetCellType() {return vtkQUAD;};
int GetCellDimension() {return 2;};
......@@ -49,6 +50,11 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
// quad specific
void InterpolationFunctions(float pcoords[3], float sf[4]);
void InterpolationDerivs(float pcoords[3], float derivs[12]);
......
......@@ -30,6 +30,7 @@ public:
vtkTetra(const vtkTetra& t);
char *GetClassName() {return "vtkTetra";};
// cell methods
vtkCell *MakeObject() {return new vtkTetra(*this);};
int GetCellType() {return vtkTETRA;};
int GetCellDimension() {return 3;};
......@@ -49,7 +50,9 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
};
#endif
......
......@@ -34,6 +34,7 @@ public:
vtkTriangleStrip(const vtkTriangleStrip& ts);
char *GetClassName() {return "vtkTriangleStrip";};
// cell methods
vtkCell *MakeObject() {return new vtkTriangleStrip(*this);};
int GetCellType() {return vtkTRIANGLE_STRIP;};
int GetCellDimension() {return 2;};
......@@ -54,6 +55,9 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
};
#endif
......
......@@ -31,6 +31,7 @@ public:
vtkTriangle(const vtkTriangle& t);
char *GetClassName() {return "vtkTriangle";};
// cell methods
vtkCell *MakeObject() {return new vtkTriangle(*this);};
int GetCellType() {return vtkTRIANGLE;};
int GetCellDimension() {return 2;};
......@@ -51,15 +52,13 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
// triangle specific
void TriangleCenter(float p1[3], float p2[3], float p3[3], float center[3]);
float TriangleArea(float p1[3], float p2[3], float p3[3]);
private:
int _EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[MAX_CELL_SIZE]);
};
// Description:
......
......@@ -48,8 +48,9 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
};
#endif
......
......@@ -32,6 +32,7 @@ public:
vtkVoxel(const vtkVoxel& b);
char *GetClassName() {return "vtkVoxel";};
// cell methods
vtkCell *MakeObject() {return new vtkVoxel(*this);};
int GetCellType() {return vtkVOXEL;};
int GetCellDimension() {return 3;};
......@@ -51,7 +52,11 @@ public:
float weights[MAX_CELL_SIZE]);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
// voxel specific
void InterpolationFunctions(float pcoords[3], float weights[8]);
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment