Man Page for vtkTriangle
Table of Contents

NAME

vtkTriangle - a cell that represents a triangle

SYNOPSIS


#include "/opt/vtk-c++/common/vtkTriangle.h"

class VTK_EXPORT vtkTriangle : public vtkCell

vtkTriangle();
vtkTriangle(const vtkTriangle& t);
static vtkTriangle *New() {return new vtkTriangle;};
const char *GetClassName() {return "vtkTriangle";};
vtkCell *MakeObject() {return new vtkTriangle(*this);};
int GetCellType() {return VTK_TRIANGLE;};
int GetCellDimension() {return 2;};
int GetNumberOfEdges() {return 3;};
int GetNumberOfFaces() {return 0;};
vtkCell *GetEdge(int edgeId);
vtkCell *GetFace(int) {return 0;};
int CellBoundary(int subId, float pcoords[3], vtkIdList& pts);
void Contour(float value, vtkFloatScalars *cellScalars,
vtkPointLocator *locator, vtkCellArray *verts,
vtkCellArray *lines, vtkCellArray *polys,
vtkPointData *inPd, vtkPointData *outPd);
void Clip(float value, vtkFloatScalars *cellScalars,
vtkPointLocator *locator, vtkCellArray *polys,
vtkPointData *inPd, vtkPointData *outPd, int insideOut);
int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float *weights);
void EvaluateLocation(int& subId, float pcoords[3], float x[3],
float *weights);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkIdList &ptIds, vtkFloatPoints &pts);
void Derivatives(int subId, float pcoords[3], float *values,
int dim, float *derivs);
static void TriangleCenter(float p1[3], float p2[3], float p3[3],
float center[3]);
static float TriangleArea(float p1[3], float p2[3], float p3[3]);
static float Circumcircle(float p1[2], float p2[2], float p3[2],
float center[2]);
static int BarycentricCoords(float x[2], float x1[2], float x2[2],
float x3[2], float bcoords[3]);
static int ProjectTo2D(float x1[3], float x2[3], float x3[3],
float v1[2], float v2[2], float v3[2]);
static void ComputeNormal(vtkPoints *p, int numPts, int *pts, float n[3]);
static void ComputeNormal(float v1[3], float v2[3], float v3[3], float n[3]);
static int PointInTriangle(float x[3], float x1[3], float x2[3], float x3[3],
float tol2);

DESCRIPTION

vtkTriangle is a concrete implementation of vtkCell to represent a triangle located in 3-space.

SUMMARY

void ComputeNormal(float v1[3], float v2[3],
Compute the triangle normal from three points.

void TriangleCenter(float p1[3], float p2[3], float p3[3], Compute the center of the triangle.

float TriangleArea(float p1[3], float p2[3], float p3[3]) Compute the area of a triangle in 3D.

vtkTriangle()
Construct the triangle with three points.

vtkTriangle(const vtkTriangle& t)
Deep copy of cell.

void ComputeNormal(vtkPoints *p, int vtkNotUsed(numPts), int *pts,
float n[3])
Compute the triangle normal from a points list, and a list of point ids that index into the points list.

float Circumcircle(float x1[2], float x2[2], float x3[2], float center[2])
Compute the circumcenter (center[3]) and radius (method return value) of a triangle defined by the three points x1, x2, and x3. (Note that the coordinates are 2D. 3D points can be used but the z-component will be ignored.)

int BarycentricCoords(float x[2], float x1[2], float x2[2], float x3[2], float bcoords[3])
Given a 2D point x[2], determine the barycentric coordinates of the point. Barycentric coordinates are a
natural coordinate system for simplices that express a position as a linear combination of the vertices. For a triangle, there are three barycentric coordinates (because there are fourthree vertices), and the sum of the coordinates must equal 1. If a point x is inside a simplex, then all three coordinates will be strictly positive. If two coordinates are zero (so the third =1), then the point x is on a vertex. If one coordinates are zero, the point x is on an edge. In this method, you must specify the vertex coordinates x1->x3. Returns 0 if triangle is degenerate.

int ProjectTo2D(float x1[3], float x2[3], float x3[3], float v1[2], float v2[2], float v3[2])
Project triangle defined in 3D to 2D coordinates. Returns 0 if degenerate triangle; non-zero value otherwise. Input points are x1->x3; output 2D points are v1->v3.

void Clip(float value, vtkFloatScalars *cellScalars,
vtkPointLocator *locator, vtkCellArray *tris,
vtkPointData *inPd, vtkPointData *outPd,
int insideOut)
Clip this triangle using scalar value provided. Like contouring, except that it cuts the triangle to produce other triangles.

int PointInTriangle(float x[3], float p1[3], float p2[3], float p3[3], float tol2) Given a point x, determine whether it is inside (within the tolerance squared, tol2) the triangle defined by the three coordinate values p1, p2, p3. Method is via comparing dor products. (Note: in current implementation the tolerance only works in the neighborhood of the three vertices of the triangle.


Table of Contents