1 |
/*
|
2 |
* This file is a part of Poly2Tri-C
|
3 |
* (c) Barak Itkin <lightningismyname@gmail.com>
|
4 |
* http://code.google.com/p/poly2tri-c/
|
5 |
*
|
6 |
* All rights reserved.
|
7 |
*
|
8 |
* Redistribution and use in source and binary forms, with or without modification,
|
9 |
* are permitted provided that the following conditions are met:
|
10 |
*
|
11 |
* * Redistributions of source code must retain the above copyright notice,
|
12 |
* this list of conditions and the following disclaimer.
|
13 |
* * Redistributions in binary form must reproduce the above copyright notice,
|
14 |
* this list of conditions and the following disclaimer in the documentation
|
15 |
* and/or other materials provided with the distribution.
|
16 |
* * Neither the name of Poly2Tri nor the names of its contributors may be
|
17 |
* used to endorse or promote products derived from this software without specific
|
18 |
* prior written permission.
|
19 |
*
|
20 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
24 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
25 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
26 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
27 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
28 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
29 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
30 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31 |
*/
|
32 |
|
33 |
#ifndef __P2TC_REFINE_VEDGE_H__
|
34 |
#define __P2TC_REFINE_VEDGE_H__
|
35 |
|
36 |
#include <glib.h>
|
37 |
#include "utils.h"
|
38 |
#include "triangulation.h"
|
39 |
|
40 |
/**
|
41 |
* @struct P2trVEdge_
|
42 |
* A struct for representing a potential ("virtual") edge in a
|
43 |
* triangular mesh
|
44 |
*/
|
45 |
struct P2trVEdge_
|
46 |
{
|
47 |
/** The start point of this virtual edge */
|
48 |
P2trPoint *start;
|
49 |
/** The end point of this virtual edge */
|
50 |
P2trPoint *end;
|
51 |
/** A flag to make whether this is a constrained edge */
|
52 |
gboolean constrained;
|
53 |
/** A count of references to the virtual edge */
|
54 |
guint refcount;
|
55 |
};
|
56 |
|
57 |
P2trVEdge* p2tr_vedge_new (P2trPoint *start,
|
58 |
P2trPoint *end,
|
59 |
gboolean constrained);
|
60 |
|
61 |
P2trVEdge* p2tr_vedge_new2 (P2trEdge *real);
|
62 |
|
63 |
P2trVEdge* p2tr_vedge_ref (P2trVEdge *self);
|
64 |
|
65 |
void p2tr_vedge_unref (P2trVEdge *self);
|
66 |
|
67 |
void p2tr_vedge_free (P2trVEdge *self);
|
68 |
|
69 |
P2trMesh* p2tr_vedge_get_mesh (P2trVEdge *self);
|
70 |
|
71 |
P2trEdge* p2tr_vedge_is_real (P2trVEdge *self);
|
72 |
|
73 |
void p2tr_vedge_create (P2trVEdge *self);
|
74 |
|
75 |
void p2tr_vedge_remove (P2trVEdge *self);
|
76 |
|
77 |
P2trEdge* p2tr_vedge_get (P2trVEdge *self);
|
78 |
|
79 |
/**
|
80 |
* Try get a real edge from a virtual edge, and then
|
81 |
* unref the virtual edge. IF A MATCHING REAL EDGE IS
|
82 |
* RETURNED, IT MUST BE UNREFFED BY THE CALLER!
|
83 |
* @param self The virtual edge to test
|
84 |
* @param real The place to store the matching real edge
|
85 |
* @return TRUE if a real edge was returned, FALSE if no
|
86 |
* matching edge exists.
|
87 |
*/
|
88 |
gboolean p2tr_vedge_try_get_and_unref (P2trVEdge *self,
|
89 |
P2trEdge **real);
|
90 |
|
91 |
/**
|
92 |
* A set of edges to flip is basically a hash set, with unique equality
|
93 |
* and hashing function to prevent the same edge from appearing twice
|
94 |
* in different directions
|
95 |
*/
|
96 |
typedef P2trHashSet P2trVEdgeSet;
|
97 |
|
98 |
/**
|
99 |
* Create a new flip-set - a set of virtual edges that should possibly
|
100 |
* be flipped to restore the Constrained Delaunay property to a
|
101 |
* triangulation
|
102 |
*/
|
103 |
P2trVEdgeSet* p2tr_vedge_set_new ();
|
104 |
|
105 |
/**
|
106 |
* Add the given edge to the flip set. THE EDGE MUST HAVE BEEN REFFED
|
107 |
* BEFORE THE CALL TO THIS FUNCTION!
|
108 |
*/
|
109 |
void p2tr_vedge_set_add (P2trVEdgeSet *self,
|
110 |
P2trEdge *to_flip);
|
111 |
|
112 |
/**
|
113 |
* Add the given virtual edge to the flip set. THE VIRTUAL EDGE MUST
|
114 |
* HAVE BEEN REFFED BEFORE THE CALL TO THIS FUNCTION!
|
115 |
*/
|
116 |
void p2tr_vedge_set_add2 (P2trVEdgeSet *self,
|
117 |
P2trVEdge *to_flip);
|
118 |
|
119 |
/**
|
120 |
* Try popping a virtual edge from the set. If succeeds, THE RETURNED
|
121 |
* VIRTUAL EDGE MUST BE UNREFFED!
|
122 |
*/
|
123 |
gboolean p2tr_vedge_set_pop (P2trVEdgeSet *self,
|
124 |
P2trVEdge **value);
|
125 |
|
126 |
/**
|
127 |
* Returns the amount of virtual edges currently in the set
|
128 |
*/
|
129 |
guint p2tr_vedge_set_size (P2trVEdgeSet *self);
|
130 |
|
131 |
/**
|
132 |
* Free the flip set. IT IS THE REPONSIBILITY OF THE CALLER TO MAKE
|
133 |
* SURE NO VIRTUAL EDGES WERE LEFT IN THE SET!
|
134 |
*/
|
135 |
void p2tr_vedge_set_free (P2trVEdgeSet *self);
|
136 |
|
137 |
gboolean p2tr_vedge_undirected_equals (const P2trVEdge *e1,
|
138 |
const P2trVEdge *e2);
|
139 |
|
140 |
guint p2tr_vedge_undirected_hash (const P2trVEdge *edge);
|
141 |
|
142 |
|
143 |
#endif
|