FMS 2025.01-dev
Flexible Modeling System
Loading...
Searching...
No Matches
tree_utils.h
1/***********************************************************************
2 * gnu lesser general Public license
3 *
4 * this file is part of the gfdl flexible modeling system(fms).
5 *
6 * fms is free software: you can redistribute it and/or modify it under
7 * the terms of the gnu lesser general Public license as published by
8 * the free software foundation, either version 3 of the license, or(at
9 * your option) any later version.
10 *
11 * fms is distributed in the hope that it will be useful, but without
12 * any warranty; without even the implied warranty of merchantability or
13 * fitness for a particular purpose. see the gnu general Public license
14 * for more details.
15 *
16 * you should have received a copy of the gnu lesser general Public
17 * license along with fms. If not, see <http://www.gnu.org/licenses/>.
18 **********************************************************************/
19/***********************************************************************
20 mosaic_util.h
21 this header file provide some utilities routine that will be used in many tools.
22
23 contact: zhi.liang@noaa.gov
24***********************************************************************/
25#ifndef TREE_UTILS_H_
26#define TREE_UTILS_H_
27
28#ifndef MAXNODELIST
29#define MAXNODELIST 100
30#endif
31
32struct node{
33 double x, y, z, u, u_clip;
34 int intersect; /* indicate if this point is an intersection, 0 = no, 1= yes, 2=both intersect and vertices */
35 int inbound; /* -1 uninitialized, 0 coincident, 1 outbound, 2 inbound */
36 int initialized; /* = 0 means empty list */
37 int isinside; /* = 1 means one point is inside the other polygon, 0 is not, -1 undecided. */
38 int subj_index; /* the index of subject point that an intersection follow. */
39 int clip_index; /* the index of clip point that an intersection follow */
40 struct node *next;
41};
42
43void rewindlist(void);
44
45struct node *getnext();
46
47void initnode(struct node *node);
48
49void addend(struct node *list, double x, double y, double z, int intersect, double u, int inbound, int inside);
50
51int addintersect(struct node *list, double x, double y, double z, int intersect, double u1, double u2,
52 int inbound, int is1, int ie1, int is2, int ie2);
53
54int length(struct node *list);
55
56int samenode(struct node node1, struct node node2);
57
58void addnode(struct node *list, struct node nodein);
59
60struct node *getnode(struct node *list, struct node innode);
61
62struct node *getnextnode(struct node *list);
63
64void copynode(struct node *node_out, struct node node_in);
65
66void printnode(struct node *list, char *str);
67
68int intersectinlist(struct node *list, double x, double y, double z);
69
70void insertintersect(struct node *list, double x, double y, double z, double u1, double u2, int inbound,
71 double x2, double y2, double z2);
72
73void insertafter(struct node *list, double x, double y, double z, int intersect, double u, int inbound,
74 double x2, double y2, double z2);
75
76double gridarea(struct node *grid);
77
78int isintersect(struct node node);
79
80int getinbound( struct node node );
81
82struct node *getlast(struct node *list);
83
84int getfirstinbound( struct node *list, struct node *nodeout);
85
86void getcoordinate(struct node node, double *x, double *y, double *z);
87
88void getcoordinates(struct node *node, double *p);
89
90void setcoordinate(struct node *node, double x, double y, double z);
91
92void setinbound(struct node *interlist, struct node *list);
93
94int isinside(struct node *node);
95
96int insidepolygon( struct node *node, struct node *list);
97
98#endif