]> granicus.if.org Git - poly2tri-c/blob - refine/edge.h
Make functions on point/edge/triangle/mesh return reffed objects
[poly2tri-c] / refine / edge.h
1 #ifndef __P2TC_REFINE_EDGE_H__
2 #define __P2TC_REFINE_EDGE_H__
3
4 #include <glib.h>
5 #include "circle.h"
6 #include "triangulation.h"
7
8 /**
9  * @struct P2trEdge_
10  * A struct for an edge in a triangular mesh
11  */
12 struct P2trEdge_
13 {
14   /** The end point of this mesh */
15   P2trPoint    *end;
16
17   /** The edge going in the opposite direction from this edge */
18   P2trEdge     *mirror;
19   
20   /** Is this a constrained edge? */
21   gboolean      constrained;
22   
23   /** The triangle where this edge goes clockwise along its outline */
24   P2trTriangle *tri;
25
26   /**
27    * The angle of the direction of this edge. Although it can be
28    * computed anytime using atan2 on the vector of this edge, we cache
29    * it here since it's heavily used and the computation is expensive.
30    * The angle increases as we go CCW, and it's in the range [-PI,+PI]
31    */
32   gdouble       angle;
33   
34   /**
35    * Is this edge a delaunay edge? This field is used by the refinement
36    * algorithm and should not be used elsewhere!
37    */
38   gboolean      delaunay;
39
40   /** A count of references to the edge */
41   guint         refcount;
42 };
43
44 #define P2TR_EDGE_START(E) ((E)->mirror->end)
45
46 P2trEdge*   p2tr_edge_new                  (P2trPoint *start,
47                                             P2trPoint *end,
48                                             gboolean   constrained);
49
50 P2trEdge*   p2tr_edge_ref                  (P2trEdge *self);
51
52 void        p2tr_edge_unref                (P2trEdge *self);
53
54 void        p2tr_edge_free                 (P2trEdge *self);
55
56 void        p2tr_edge_remove               (P2trEdge *self);
57
58 P2trMesh*   p2tr_edge_get_mesh             (P2trEdge *self);
59
60 gboolean    p2tr_edge_is_removed           (P2trEdge *self);
61
62 gdouble     p2tr_edge_get_length           (P2trEdge* self);
63
64 gdouble     p2tr_edge_get_length_squared   (P2trEdge* self);
65
66 gdouble     p2tr_edge_angle_between        (P2trEdge *e1,
67                                             P2trEdge *e2);
68
69 #endif