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_MESH_ACTION_H__
|
34 |
#define __P2TC_REFINE_MESH_ACTION_H__
|
35 |
|
36 |
#include <glib.h>
|
37 |
|
38 |
/**
|
39 |
* \defgroup P2trMeshAction P2trMeshAction - Mesh Action Recording
|
40 |
* Action recording state objects for mesh objects. These may be
|
41 |
* inspected by code outside of the library, but objects of this type
|
42 |
* should not be created or manipulated by external code!
|
43 |
* @{
|
44 |
*/
|
45 |
|
46 |
/**
|
47 |
* The type of the geometric primitive affected by a mesh action
|
48 |
*/
|
49 |
typedef enum
|
50 |
{
|
51 |
P2TR_MESH_ACTION_POINT,
|
52 |
P2TR_MESH_ACTION_EDGE,
|
53 |
P2TR_MESH_ACTION_TRIANGLE
|
54 |
} P2trMeshActionType;
|
55 |
|
56 |
/**
|
57 |
* A struct representing any single action on a mesh. A single atomic
|
58 |
* action may be the insertion/removal of a point/edge/triangle.
|
59 |
*
|
60 |
* Note that such an action only treats the direct geometric operation
|
61 |
* related to the specific geometric primitve, without any of its
|
62 |
* dependencies.
|
63 |
*
|
64 |
* For example, if removing a point requires the removal of several
|
65 |
* edges and triangles, then the removal of each one of those should be
|
66 |
* recorded in its own action object.
|
67 |
*/
|
68 |
typedef struct P2trMeshAction_
|
69 |
{
|
70 |
/** The type of geometric primitive affected by the action */
|
71 |
P2trMeshActionType type;
|
72 |
/** A flag specifying whether the primitive was added or removed */
|
73 |
gboolean added;
|
74 |
/** A reference count to the action object */
|
75 |
gint refcount;
|
76 |
/** Specific additional information which is needed for each type
|
77 |
* of action */
|
78 |
union {
|
79 |
/** Information required to undo a point action */
|
80 |
struct {
|
81 |
/** The point that was added/deleted */
|
82 |
P2trPoint *point;
|
83 |
} action_point;
|
84 |
|
85 |
/** Information required to undo an edge action */
|
86 |
struct {
|
87 |
/** A virtual edge representing the added/deleted edge */
|
88 |
P2trVEdge *vedge;
|
89 |
/** A flag specifying whether the edge is constrained */
|
90 |
gboolean constrained;
|
91 |
} action_edge;
|
92 |
|
93 |
/** Information required to undo a triangle action */
|
94 |
struct {
|
95 |
/** A virtual triangle representing the added/deleted triangle */
|
96 |
P2trVTriangle *vtri;
|
97 |
} action_tri;
|
98 |
} action;
|
99 |
} P2trMeshAction;
|
100 |
|
101 |
/**
|
102 |
* Create a new mesh action describing the addition of a new point
|
103 |
* @param point The point that is added to the mesh
|
104 |
* @return An object representing the point addition action
|
105 |
*/
|
106 |
P2trMeshAction* p2tr_mesh_action_new_point (P2trPoint *point);
|
107 |
|
108 |
/**
|
109 |
* Create a new mesh action describing the deletion of an existing point
|
110 |
* @param point The point that is deleted from the mesh
|
111 |
* @return An object representing the point deletion action
|
112 |
*/
|
113 |
P2trMeshAction* p2tr_mesh_action_del_point (P2trPoint *point);
|
114 |
|
115 |
/**
|
116 |
* Create a new mesh action describing the addition of a new edge
|
117 |
* @param edge The edge that is added to the mesh
|
118 |
* @return An object representing the edge addition action
|
119 |
*/
|
120 |
P2trMeshAction* p2tr_mesh_action_new_edge (P2trEdge *edge);
|
121 |
|
122 |
/**
|
123 |
* Create a new mesh action describing the deletion of an existing edge
|
124 |
* @param edge The edge that is deleted from the mesh
|
125 |
* @return An object representing the edge deletion action
|
126 |
*/
|
127 |
P2trMeshAction* p2tr_mesh_action_del_edge (P2trEdge *edge);
|
128 |
|
129 |
/**
|
130 |
* Create a new mesh action describing the addition of a triangle
|
131 |
* @param tri The triangle that is added to the mesh
|
132 |
* @return An object representing the triangle addition action
|
133 |
*/
|
134 |
P2trMeshAction* p2tr_mesh_action_new_triangle (P2trTriangle *tri);
|
135 |
|
136 |
/**
|
137 |
* Create a new mesh action describing the deletion of an existing
|
138 |
* triangle
|
139 |
* @param tri The triangle that is deleted from the mesh
|
140 |
* @return An object representing the triangle deletion action
|
141 |
*/
|
142 |
P2trMeshAction* p2tr_mesh_action_del_triangle (P2trTriangle *tri);
|
143 |
|
144 |
/**
|
145 |
* Increase the reference count to this mesh action by 1
|
146 |
* @param self The mesh action whose reference count should be increased
|
147 |
*/
|
148 |
P2trMeshAction* p2tr_mesh_action_ref (P2trMeshAction *self);
|
149 |
|
150 |
/**
|
151 |
* Decrease the reference count to this mesh action by 1
|
152 |
* @param self The mesh action whose reference count should be decreased
|
153 |
*/
|
154 |
void p2tr_mesh_action_unref (P2trMeshAction *self);
|
155 |
|
156 |
/**
|
157 |
* Free the memory used by a mesh action data structure
|
158 |
* @param self The mesh action whose memory should be freed
|
159 |
*/
|
160 |
void p2tr_mesh_action_free (P2trMeshAction *self);
|
161 |
|
162 |
/**
|
163 |
* Undo the action described by the given mesh action object
|
164 |
* @param self The mesh action to undo
|
165 |
* @param mesh The mesh on which this action was applied
|
166 |
*/
|
167 |
void p2tr_mesh_action_undo (P2trMeshAction *self,
|
168 |
P2trMesh *mesh);
|
169 |
|
170 |
#endif
|