/* * tin.h */ #ifndef __tin_h #define __tin_h #include #include #include #include #include "grid.h" #include "geom_tin.h" #include "triangle.h" #include "pqelement.h" #define X 0 #define Y 1 #define Z 2 #define IN 0 #define INBACK 1 #define OUT 2 #define OUTBACK 3 #define EDGE12 0 #define EDGE13 1 #define EDGE23 2 /////////////////////////////////////////////////////////////////////// // Type Definitions /////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// typedef char BOOL; typedef struct Edge { TRIANGLE *t1, *t2; COORD *p1, *p2; short type; } EDGE; typedef struct Tin { TRIANGLE *t; // lower left most tri COORD* v; // lower left vertex of t int nrows; // number of rows int ncols; // number of cols EDGE e; // lower left edge COORD nodata; } TIN; typedef struct TinListNode { TIN* t; int iOffset; int jOffset; struct TinListNode* next; } TINNODE; typedef TINNODE *TINLIST; /////////////////////////////////////////////////////////////////////// // Declare Functions ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // addTri - add trinagle to a TIN TRIANGLE* addTri(COORD* p1, COORD* p2, COORD* p3, TRIANGLE *t12, TRIANGLE *t13, TRIANGLE *t23); // removeTri - remove triangle from TIN and free memory void removeTri(TRIANGLE *t); // freePointList - given a triangle, free all the tnodes in the point list void freePointList(TRIANGLE* t); // printPointList - gmaiven a triangle,print its point list void printPointList(TRIANGLE* t); // numTris - given a TIN return the number of triangles int numTris(TIN s); TRIANGLE *nextEdge(TRIANGLE *t, COORD *v, EDGE *edge); // inTri - computes if a point z is in triangle ABC int inTri2D(POINT a, POINT b, POINT c, POINT z); // twoTris - given a TIN return 1 if it contains only 2 trianlges int twoTris(TIN s); void printTriangle(TRIANGLE* t); void printTriangleCoords(TRIANGLE* t); void printTin(TIN* tin); void printTinList(TINLIST tl); int getTileLength(double MEM); void printTinList(TINLIST t ); void pointNeighborTo(TRIANGLE *t,COORD *pa,COORD *pb,TRIANGLE *tn); TRIANGLE* whichTri(TRIANGLE *tn,COORD *pa,COORD *pb); int areaSign(COORD *a, COORD *b, COORD *c); // Validate that all points in a triangle's point list are actually in // that triangle void checkPointList(TRIANGLE* t); // Find the third point given two known points COORD* findThirdPoint(POINT p1, POINT p2, POINT p3, POINT pa, POINT pb); // Is a point an end point of a particular triangle int isEndPoint(TRIANGLE* t, POINT p); // Find the edge opposite to a point p EDGE findOpposite(TRIANGLE* t, POINT p); // Is a given edge in a triangle t? int edgeInTriangle(TRIANGLE* t, EDGE e); // Do two edges have equal valued points? int edgePointsEqual(EDGE e1, EDGE e2); // Validate that at least t1 and t2 are part of t. This is used to // debug that the triangles being created inside t are actually inside // triangle t void triangleCheck(TRIANGLE* t,TRIANGLE* t1,TRIANGLE* t2,TRIANGLE* t3); #endif