54 unsigned face_nr_outside = 0;
55 unsigned face_nr_inside = 0;
56 unsigned face_nr_split = 0;
58 switch (face_location) {
59 case FPL_OUTSIDE + FPL_TOUCH_NOTHING:
60 case FPL_OUTSIDE + FPL_TOUCH_VERTEX:
61 case FPL_OUTSIDE + FPL_TOUCH_EDGE:
64 case FPL_INSIDE + FPL_TOUCH_NOTHING:
65 case FPL_INSIDE + FPL_TOUCH_VERTEX:
66 case FPL_INSIDE + FPL_TOUCH_EDGE:
71 case FPL_SPLIT_TWO_VERTICES:
72 case FPL_SPLIT_VERTEX_EDGE:
73 case FPL_SPLIT_TWO_EDGES:
77 std::cerr <<
"found an invalid face location" << std::endl;
83 if (face_nr_split > 0)
85 if (face_nr_inside == 0)
87 if (face_nr_outside == 0)
96 std::pair<int, int> halfedge(F.back(), F.front());
101 if (last_vertex_location == VPL_TOUCH && vertex_location == VPL_TOUCH)
104 last_vertex_location = vertex_location;
106 std::cerr <<
"could not find touching halfedge in face" << std::endl;
114 unsigned vertex_nr_locations[3] = { 0, 0, 0 };
115 unsigned edge_nr_touches = 0;
116 unsigned edge_nr_splits = 0;
117 unsigned nr_side_transitions = 0;
120 unsigned i = (unsigned)F.size() - 1;
125 while (i > 0 && last_vertex_side == VPL_TOUCH)
126 last_vertex_side = vertex_locations[F[--i]];
128 if (last_vertex_side == VPL_TOUCH)
129 return FPL_TOUCH_FACE;
132 for (i = 0; i < F.size(); ++i) {
136 ++vertex_nr_locations[
to_index(vertex_location)];
138 if (vertex_location == VPL_TOUCH) {
139 if (last_vertex_location == VPL_TOUCH)
143 if (last_vertex_location != VPL_TOUCH && vertex_location != last_vertex_location)
145 if (vertex_location != last_vertex_side)
146 ++nr_side_transitions;
147 last_vertex_side = vertex_location;
149 last_vertex_location = vertex_location;
156 if (vertex_nr_locations[
to_index(VPL_INSIDE)] == 0 || vertex_nr_locations[
to_index(VPL_OUTSIDE)] == 0) {
157 face_location = vertex_nr_locations[
to_index(VPL_INSIDE)] > 0 ? FPL_INSIDE : FPL_OUTSIDE;
158 if (vertex_nr_locations[
to_index(VPL_TOUCH)] == 1)
159 (
int&)face_location += (
int)FPL_TOUCH_VERTEX;
160 else if (vertex_nr_locations[
to_index(VPL_TOUCH)] == 2) {
161 if (edge_nr_touches == 1)
162 (
int&)face_location += (
int)FPL_TOUCH_EDGE;
164 if (edge_nr_touches != 0) {
165 std::cerr <<
"unconsidered case (v#+|-=0, v#0=2, e#0>1)" << std::endl;
168 face_location = FPL_TWO_NON_ADJACENT_VERTICES_TOUCH;
171 else if(vertex_nr_locations[
to_index(VPL_TOUCH)] != 0)
172 face_location = FPL_UNCONSIDERED_CASE;
176 if (nr_side_transitions == 2) {
177 if (vertex_nr_locations[
to_index(VPL_TOUCH)] == 2 && edge_nr_splits == 0)
178 face_location = FPL_SPLIT_TWO_VERTICES;
179 else if (vertex_nr_locations[
to_index(VPL_TOUCH)] == 1 && edge_nr_splits == 1)
180 face_location = FPL_SPLIT_VERTEX_EDGE;
181 else if (vertex_nr_locations[
to_index(VPL_TOUCH)] == 0 && edge_nr_splits == 2)
182 face_location = FPL_SPLIT_TWO_EDGES;
183 else if (vertex_nr_locations[
to_index(VPL_TOUCH)] + edge_nr_splits > 2)
184 face_location = FPL_TOUCH_AND_SPLIT;
186 face_location = FPL_UNCONSIDERED_CASE;
190 if (face_location == FPL_UNCONSIDERED_CASE) {
191 if (vertex_nr_locations[
to_index(VPL_TOUCH)] > 2)
192 face_location = FPL_INCOMLETE_TOUCH_FACE;
193 else if (nr_side_transitions % 2 == 1)
194 face_location = FPL_ODD_TRANSITION_NUMBER;
195 else if (nr_side_transitions > 2)
196 face_location = FPL_MULTI_SPLIT;
198 face_location = FPL_UNCONSIDERED_CASE;
201 return face_location;