Branch data Line data Source code
1 : : /*
2 : : *
3 : : *
4 : : * Copyright (C) 2004 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000
5 : : * with Sandia Corporation, the U.S. Government retains certain rights in this software.
6 : : *
7 : : * This file is part of facetbool--contact via [email protected]
8 : : *
9 : : * This library is free software; you can redistribute it and/or
10 : : * modify it under the terms of the GNU Lesser General Public
11 : : * License as published by the Free Software Foundation; either
12 : : * version 2.1 of the License, or (at your option) any later version.
13 : : *
14 : : * This library is distributed in the hope that it will be useful,
15 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : * Lesser General Public License for more details.
18 : : *
19 : : * You should have received a copy of the GNU Lesser General Public
20 : : * License along with this library; if not, write to the Free Software
21 : : * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : : *
23 : : *
24 : : *
25 : : */
26 : :
27 : : #include <math.h>
28 : : #include <algorithm>
29 : : #include "FBRetriangulate.hpp"
30 : : #include "FBTiler.hpp"
31 : : #include "CubitMessage.hpp"
32 : :
33 : : #ifdef KEEP_BOYD10_KEEP
34 : : bool edgecf_less(const FB_Edge* efirst, const FB_Edge* esecond)
35 : : {
36 : : if ( efirst->quadrant < esecond->quadrant ) return true;
37 : : if ( efirst->quadrant > esecond->quadrant ) return false;
38 : :
39 : : if ( efirst->slope < esecond->slope ) return true;
40 : : else return false;
41 : :
42 : : }
43 : : #endif
44 : :
45 : 0 : FBRetriangulate::FBRetriangulate(std::vector<FB_Coord *>& my_verts,
46 : : std::vector<FB_Triangle *>& my_tris,
47 : : std::vector<int>& my_newfacets,
48 [ # # ]: 0 : std::vector<int>& my_newfacetsindex)
49 : : {
50 [ # # ]: 0 : verts = my_verts;
51 : 0 : tris = &my_tris;
52 : 0 : newfacets = &my_newfacets;
53 : 0 : newfacetsindex = &my_newfacetsindex;
54 : 0 : p_dir=0;
55 : 0 : s_dir=0;
56 : 0 : }
57 : :
58 : 0 : FBRetriangulate::FBRetriangulate(std::vector<FB_Coord *>& my_verts,
59 : : std::vector<FB_Triangle *>& my_tris,
60 [ # # ]: 0 : std::vector<int>& my_newfacets)
61 : : {
62 [ # # ]: 0 : verts = my_verts;
63 : 0 : tris = &my_tris;
64 : 0 : newfacets = &my_newfacets;
65 : 0 : newfacetsindex = 0;
66 : 0 : p_dir=0;
67 : 0 : s_dir=0;
68 : 0 : }
69 : :
70 [ # # ]: 0 : FBRetriangulate::~FBRetriangulate()
71 : : {
72 : :
73 : 0 : }
74 : :
75 : 0 : CubitStatus FBRetriangulate::retriangulate_this_tri(int sequence, std::vector<FB_Edge*> &orphaned_edges)
76 : : {
77 : : CubitStatus status;
78 : : double xspan, yspan, zspan;
79 [ # # ]: 0 : std::vector<FB_Triangle *>::iterator itt;
80 : :
81 [ # # ]: 0 : itt = tris->begin();
82 [ # # ]: 0 : itt += sequence;
83 [ # # ]: 0 : my_tri = *itt;
84 : 0 : status = CUBIT_SUCCESS;
85 : :
86 : : // tri = &itt;
87 : 0 : xspan = my_tri->boundingbox.xmax - my_tri->boundingbox.xmin;
88 : 0 : yspan = my_tri->boundingbox.ymax - my_tri->boundingbox.ymin;
89 : 0 : zspan = my_tri->boundingbox.zmax - my_tri->boundingbox.zmin;
90 [ # # ][ # # ]: 0 : if ( ( fabs(my_tri->c) >= fabs(my_tri->a) ) &&
91 : 0 : ( fabs(my_tri->c) >= fabs(my_tri->b) ) ) {
92 : 0 : p_dir = 1;
93 : 0 : s_dir = 0;
94 [ # # ]: 0 : if ( xspan > yspan ) {
95 : 0 : p_dir = 0;
96 : 0 : s_dir = 1;
97 : : }
98 : : }
99 [ # # ]: 0 : else if ( fabs(my_tri->b) >= fabs(my_tri->a) ) {
100 : 0 : p_dir = 2;
101 : 0 : s_dir = 0;
102 [ # # ]: 0 : if ( xspan > zspan ) {
103 : 0 : p_dir = 0;
104 : 0 : s_dir = 2;
105 : : }
106 : : }
107 : : else {
108 : 0 : p_dir = 1;
109 : 0 : s_dir = 2;
110 [ # # ]: 0 : if ( zspan > yspan ) {
111 : 0 : p_dir = 2;
112 : 0 : s_dir = 1;
113 : : }
114 : : }
115 : :
116 [ # # ]: 0 : if ( p_dir == 0 ) {
117 [ # # ]: 0 : if ( s_dir == 1 ) {
118 [ # # ]: 0 : if ( my_tri->c > 0.0 )
119 : 0 : winding = CCW;
120 : : else
121 : 0 : winding = CW;
122 : : }
123 [ # # ]: 0 : else if (s_dir == 2 ) {
124 [ # # ]: 0 : if ( my_tri->b > 0.0 )
125 : 0 : winding = CW;
126 : : else
127 : 0 : winding = CCW;
128 : : }
129 : : }
130 [ # # ]: 0 : else if ( p_dir == 1 ) {
131 [ # # ]: 0 : if ( s_dir == 0 ) {
132 [ # # ]: 0 : if ( my_tri->c > 0.0 )
133 : 0 : winding = CW;
134 : : else
135 : 0 : winding = CCW;
136 : : }
137 [ # # ]: 0 : else if (s_dir == 2 ) {
138 [ # # ]: 0 : if ( my_tri->a > 0.0 )
139 : 0 : winding = CW;
140 : : else
141 : 0 : winding = CCW;
142 : : }
143 : : }
144 [ # # ]: 0 : else if ( p_dir == 2 ) {
145 [ # # ]: 0 : if ( s_dir == 0 ) {
146 [ # # ]: 0 : if ( my_tri->b > 0.0 )
147 : 0 : winding = CCW;
148 : : else
149 : 0 : winding = CW;
150 : : }
151 [ # # ]: 0 : else if (s_dir == 1 ) {
152 [ # # ]: 0 : if ( my_tri->a > 0.0 )
153 : 0 : winding = CCW;
154 : : else
155 : 0 : winding = CW;
156 : : }
157 : : }
158 : : else{
159 [ # # ][ # # ]: 0 : PRINT_ERROR("Unexpected result.\n");
[ # # ][ # # ]
160 : 0 : return CUBIT_FAILURE;
161 : : }
162 : :
163 : : //if ( winding == CCW ) winding = CW;
164 : : //else winding = CCW;
165 [ # # ]: 0 : classify_edges();
166 : :
167 : : // Add edges around the perimeter of the triangle to its edge list.
168 [ # # ]: 0 : status = add_bdry_edges(orphaned_edges);
169 [ # # ]: 0 : make_vert_list();
170 : :
171 : : // Add internal edges where there is a local min or max
172 [ # # ]: 0 : status = remove_min_max();
173 : :
174 : : // Get the vertex chains that will be retriangulated.
175 : :
176 : 0 : bool chain_status = true;
177 [ # # ]: 0 : sort_vertstufflist_edges();
178 [ # # ][ # # ]: 0 : std::vector<int> *chainlist = new std::vector<int>;
179 : : // std::vector<FB_Triangle* > new_tris;
180 : : unsigned int i, nfsize;
181 [ # # ]: 0 : nfsize = newfacets->size();
182 [ # # ]: 0 : while (chain_status == true ) {
183 [ # # ]: 0 : chain_status = get_a_chain(chainlist);
184 [ # # ]: 0 : if ( chain_status == false ) break;
185 : : FBTiler *tiler = new FBTiler(verts,p_dir,s_dir,sequence,
186 [ # # ][ # # ]: 0 : my_tri->a,my_tri->b,my_tri->c,newfacets);
187 [ # # ]: 0 : status = tiler->Tile_Poly(chainlist);
188 [ # # ][ # # ]: 0 : delete tiler;
189 [ # # ]: 0 : chainlist->clear();
190 : :
191 : : }
192 : :
193 [ # # ][ # # ]: 0 : delete chainlist;
194 : : unsigned int number_new;
195 : : int e0index, e1index, e2index;
196 : :
197 [ # # ]: 0 : number_new = newfacets->size() - nfsize;
198 [ # # ]: 0 : if ( number_new > 0 ) {
199 [ # # ]: 0 : std::vector<int>::iterator itp;
200 [ # # ]: 0 : itp = newfacets->begin();
201 [ # # ]: 0 : itp += nfsize;
202 [ # # ]: 0 : for ( i = 0; i < number_new; i += 3 ) {
203 : : FB_Triangle *new_tri;
204 : 0 : e0index = e1index = e2index = 0;
205 [ # # ][ # # ]: 0 : get_edge_indices(*itp,*(itp+1),*(itp+2),sequence,
[ # # ][ # # ]
[ # # ]
206 [ # # ]: 0 : e0index, e1index, e2index);
207 [ # # ][ # # ]: 0 : new_tri = new FB_Triangle(*itp,*(itp+1),*(itp+2),
[ # # ][ # # ]
[ # # ]
208 : : sequence,my_tri->cubitsurfaceindex,
209 [ # # ][ # # ]: 0 : e0index, e1index, e2index);
210 [ # # ]: 0 : tris->push_back(new_tri);
211 [ # # ]: 0 : itp += 3;
212 : : }
213 [ # # ][ # # ]: 0 : if ( newfacetsindex ) newfacetsindex->push_back(nfsize);
214 : : }
215 [ # # ][ # # ]: 0 : for ( i = 0; i < vertstufflist.size(); i++ ) {
216 [ # # ][ # # ]: 0 : delete vertstufflist[i];
[ # # ]
217 : : }
218 : :
219 [ # # ]: 0 : vertstufflist.clear();
220 : :
221 : 0 : return status;
222 : :
223 : : }
224 : :
225 : 0 : CubitStatus FBRetriangulate::remove_min_max()
226 : : {
227 : : CubitStatus status;
228 : : FB_Edge *edge;
229 [ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe;
230 : : bool goes_down, goes_up;
231 : : VertexStuff *vstuff;
232 : : unsigned int i;
233 : : int this_vert, that_vert;
234 : : double this_vert_p_dir_coord, that_vert_p_dir_coord;
235 : :
236 : 0 : status = CUBIT_SUCCESS;
237 : :
238 [ # # ][ # # ]: 0 : for ( i = 0; i < vertstufflist.size(); i++ ) {
239 [ # # ]: 0 : vstuff = vertstufflist[i];
240 [ # # ]: 0 : if ( vstuff->v0type != INTERIOR_VERT ) continue;
241 : 0 : goes_down = goes_up = false;
242 : 0 : this_vert = vstuff->v0;
243 [ # # ]: 0 : this_vert_p_dir_coord = verts[this_vert]->coord[p_dir];
244 [ # # ]: 0 : dpe = vstuff->edge_list.begin();
245 [ # # ][ # # ]: 0 : while ( dpe != vstuff->edge_list.end() ) {
[ # # ]
246 [ # # ]: 0 : edge = *dpe;
247 [ # # ]: 0 : dpe++;
248 [ # # ]: 0 : if ( edge->v0 == this_vert ) that_vert = edge->v1;
249 : 0 : else that_vert = edge->v0;
250 [ # # ]: 0 : that_vert_p_dir_coord = verts[that_vert]->coord[p_dir];
251 [ # # ]: 0 : if ( that_vert_p_dir_coord < this_vert_p_dir_coord )
252 : 0 : goes_down = true;
253 [ # # ]: 0 : else if ( that_vert_p_dir_coord > this_vert_p_dir_coord )
254 : 0 : goes_up = true;
255 : : else {
256 : : double this_vert_s_dir_coord, that_vert_s_dir_coord;
257 [ # # ]: 0 : this_vert_s_dir_coord = verts[this_vert]->coord[s_dir];
258 [ # # ]: 0 : that_vert_s_dir_coord = verts[that_vert]->coord[s_dir];
259 [ # # ]: 0 : if ( this_vert_s_dir_coord < that_vert_s_dir_coord )
260 : 0 : goes_up = true;
261 : 0 : else goes_down = true;
262 : : }
263 : : }
264 : :
265 [ # # ]: 0 : if ( goes_down == false ) {
266 [ # # ]: 0 : add_edge_down(this_vert,i);
267 [ # # ]: 0 : } else if ( goes_up == false ) {
268 [ # # ]: 0 : add_edge_up(this_vert,i);
269 : : }
270 : : }
271 : :
272 : 0 : return status;
273 : :
274 : : }
275 : :
276 : 0 : CubitStatus FBRetriangulate::add_bdry_edges(std::vector<FB_Edge*> &orphaned_edges)
277 : : {
278 : : // For each triangle edge, make a list of pairs of edge points and
279 : : // vertex numbers that touch the edge. Then sort the list by distance
280 : : // from the start of the edge. (This was what we really put in the
281 : : // pair, not the point itself.) Finally, go through this sorted list
282 : : // and add edges to the edge_list. If the edge_list is empty, we
283 : : // still must add in the triangle edge itself.
284 : :
285 : : CubitStatus status;
286 : : FB_Edge *edge;
287 [ # # ][ # # ]: 0 : std::list< std::pair<double,int> > edge0_list, edge1_list, edge2_list;
[ # # ][ # # ]
[ # # ]
288 [ # # ]: 0 : std::list< std::pair<double,int> >::iterator dp;
289 [ # # ][ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe, dpe_orig;
290 : : double vx0, vy0, vz0, vx1, vy1, vz1, vx2, vy2, vz2, dist;
291 [ # # ]: 0 : std::pair<double,int> mypair;
292 : :
293 : 0 : status = CUBIT_SUCCESS;
294 : :
295 [ # # ]: 0 : vx0 = verts[my_tri->v0]->coord[0];
296 [ # # ]: 0 : vy0 = verts[my_tri->v0]->coord[1];
297 [ # # ]: 0 : vz0 = verts[my_tri->v0]->coord[2];
298 [ # # ]: 0 : vx1 = verts[my_tri->v1]->coord[0];
299 [ # # ]: 0 : vy1 = verts[my_tri->v1]->coord[1];
300 [ # # ]: 0 : vz1 = verts[my_tri->v1]->coord[2];
301 [ # # ]: 0 : vx2 = verts[my_tri->v2]->coord[0];
302 [ # # ]: 0 : vy2 = verts[my_tri->v2]->coord[1];
303 [ # # ]: 0 : vz2 = verts[my_tri->v2]->coord[2];
304 : :
305 [ # # ]: 0 : dpe = my_tri->edge_list.begin();
306 [ # # ][ # # ]: 0 : while ( dpe != my_tri->edge_list.end() ) {
[ # # ]
307 [ # # ]: 0 : edge = *dpe;
308 [ # # ]: 0 : dpe++;
309 [ # # ][ # # ]: 0 : if ( (edge->v0_type == INTERIOR_VERT) &&
310 : 0 : (edge->v1_type == INTERIOR_VERT) )
311 : 0 : continue;
312 [ # # ]: 0 : if ( edge->v0_type == EDGE_0 ) {
313 [ # # ]: 0 : dist = get_dist(vx0,vy0,vz0,verts[edge->v0]->coord[0],
314 [ # # ][ # # ]: 0 : verts[edge->v0]->coord[1],verts[edge->v0]->coord[2]);
[ # # ]
315 [ # # ][ # # ]: 0 : edge0_list.push_back(std::pair<double,int>(dist,edge->v0));
316 [ # # ]: 0 : } else if ( edge->v0_type == EDGE_1 ) {
317 [ # # ]: 0 : dist = get_dist(vx1,vy1,vz1,verts[edge->v0]->coord[0],
318 [ # # ][ # # ]: 0 : verts[edge->v0]->coord[1],verts[edge->v0]->coord[2]);
[ # # ]
319 [ # # ][ # # ]: 0 : edge1_list.push_back(std::pair<double,int>(dist,edge->v0));
320 [ # # ]: 0 : } else if ( edge->v0_type == EDGE_2 ) {
321 [ # # ]: 0 : dist = get_dist(vx2,vy2,vz2,verts[edge->v0]->coord[0],
322 [ # # ][ # # ]: 0 : verts[edge->v0]->coord[1],verts[edge->v0]->coord[2]);
[ # # ]
323 [ # # ][ # # ]: 0 : edge2_list.push_back(std::pair<double,int>(dist,edge->v0));
324 : : }
325 [ # # ]: 0 : if ( edge->v1_type == EDGE_0 ) {
326 [ # # ]: 0 : dist = get_dist(vx0,vy0,vz0,verts[edge->v1]->coord[0],
327 [ # # ][ # # ]: 0 : verts[edge->v1]->coord[1],verts[edge->v1]->coord[2]);
[ # # ]
328 [ # # ][ # # ]: 0 : edge0_list.push_back(std::pair<double,int>(dist,edge->v1));
329 [ # # ]: 0 : } else if ( edge->v1_type == EDGE_1 ) {
330 [ # # ]: 0 : dist = get_dist(vx1,vy1,vz1,verts[edge->v1]->coord[0],
331 [ # # ][ # # ]: 0 : verts[edge->v1]->coord[1],verts[edge->v1]->coord[2]);
[ # # ]
332 [ # # ][ # # ]: 0 : edge1_list.push_back(std::pair<double,int>(dist,edge->v1));
333 [ # # ]: 0 : } else if ( edge->v1_type == EDGE_2 ) {
334 [ # # ]: 0 : dist = get_dist(vx2,vy2,vz2,verts[edge->v1]->coord[0],
335 [ # # ][ # # ]: 0 : verts[edge->v1]->coord[1],verts[edge->v1]->coord[2]);
[ # # ]
336 [ # # ][ # # ]: 0 : edge2_list.push_back(std::pair<double,int>(dist,edge->v1));
337 : : }
338 : : }
339 : :
340 [ # # ]: 0 : edge0_list.sort();
341 [ # # ]: 0 : edge1_list.sort();
342 [ # # ]: 0 : edge2_list.sort();
343 : :
344 : : // Now we have to remove all BDRY_EDGEs because they will be made anew
345 : : // in what follows. Erasing elements from a vector is inefficient, but
346 : : // this shouldn't happen often.
347 [ # # ]: 0 : dpe = my_tri->edge_list.begin();
348 [ # # ]: 0 : dpe_orig = my_tri->edge_list.end();
349 : :
350 [ # # ][ # # ]: 0 : while ( dpe != dpe_orig ) {
351 [ # # ]: 0 : edge = *dpe;
352 [ # # ]: 0 : if ( edge->edge_type == BDRY_EDGE ) {
353 [ # # ]: 0 : dpe = my_tri->edge_list.erase(dpe);
354 [ # # ]: 0 : orphaned_edges.push_back(edge);
355 [ # # ]: 0 : dpe_orig = my_tri->edge_list.end();
356 : : } else {
357 [ # # ]: 0 : dpe++;
358 : : }
359 : : }
360 : : int newv0, newv1, newv0_type, newv1_type;
361 : 0 : newv0_type = newv1_type = EDGE_0;
362 : 0 : newv0 = my_tri->v0;
363 [ # # ]: 0 : dp = edge0_list.begin();
364 [ # # ][ # # ]: 0 : while ( dp != edge0_list.end() ) {
[ # # ]
365 [ # # ]: 0 : mypair = *dp;
366 : 0 : newv1 = mypair.second;
367 : : // It is possible to get the same vert more than once in the list.
368 : : // After sorting, they will be adjacent. The following if statement
369 : : // causes duplicate verts to be used only once.
370 [ # # ]: 0 : if ( newv0 != newv1 ) {
371 [ # # ]: 0 : add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
372 : 0 : newv0 = newv1;
373 : : }
374 [ # # ]: 0 : dp++;
375 : : }
376 : 0 : newv1 = my_tri->v1;
377 [ # # ]: 0 : if ( newv0 != newv1 )
378 [ # # ]: 0 : add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
379 : :
380 : 0 : newv0_type = newv1_type = EDGE_1;
381 : 0 : newv0 = my_tri->v1;
382 [ # # ]: 0 : dp = edge1_list.begin();
383 [ # # ][ # # ]: 0 : while ( dp != edge1_list.end() ) {
[ # # ]
384 [ # # ]: 0 : mypair = *dp;
385 : 0 : newv1 = mypair.second;
386 [ # # ]: 0 : if ( newv0 != newv1 ) {
387 [ # # ]: 0 : add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
388 : 0 : newv0 = newv1;
389 : : }
390 [ # # ]: 0 : dp++;
391 : : }
392 : 0 : newv1 = my_tri->v2;
393 [ # # ]: 0 : if ( newv0 != newv1 )
394 [ # # ]: 0 : add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
395 : :
396 : 0 : newv0_type = newv1_type = EDGE_2;
397 : 0 : newv0 = my_tri->v2;
398 [ # # ]: 0 : dp = edge2_list.begin();
399 [ # # ][ # # ]: 0 : while ( dp != edge2_list.end() ) {
[ # # ]
400 [ # # ]: 0 : mypair = *dp;
401 : 0 : newv1 = mypair.second;
402 [ # # ]: 0 : if ( newv0 != newv1 ) {
403 [ # # ]: 0 : add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
404 : 0 : newv0 = newv1;
405 : : }
406 [ # # ]: 0 : dp++;
407 : : }
408 : 0 : newv1 = my_tri->v0;
409 [ # # ]: 0 : if ( newv0 != newv1 )
410 [ # # ]: 0 : add_this_bdry_edge(newv0,newv1,newv0_type,newv1_type);
411 : :
412 [ # # ]: 0 : return status;
413 : :
414 : : }
415 : :
416 : 0 : void FBRetriangulate::add_this_bdry_edge(int v0, int v1, int v0_type,
417 : : int v1_type)
418 : : {
419 : : // Add an edge if it doesn't already exist.
420 [ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe;
421 : : bool ifoundit;
422 : : FB_Edge *edge, *new_edge;
423 : :
424 : 0 : ifoundit = false;
425 [ # # ]: 0 : dpe = my_tri->edge_list.begin();
426 [ # # ][ # # ]: 0 : while ( dpe != my_tri->edge_list.end() ) {
[ # # ]
427 [ # # ]: 0 : edge = *dpe;
428 [ # # ][ # # ]: 0 : if ( ( ((int)edge->v0 == v0) && ((int)edge->v1 == v1) ) ||
[ # # ]
429 [ # # ]: 0 : ( ((int)edge->v0 == v1) && ((int)edge->v1 == v0) ) ) {
430 : 0 : ifoundit = true;
431 : 0 : break;
432 : : }
433 [ # # ]: 0 : dpe++;
434 : : }
435 [ # # ]: 0 : if ( ifoundit == false ) {
436 [ # # ][ # # ]: 0 : new_edge = new FB_Edge(v0,v1,v0_type,v1_type,true);
437 : 0 : new_edge->edge_type = BDRY_EDGE;
438 [ # # ]: 0 : my_tri->edge_list.push_back(new_edge);
439 : : }
440 : 0 : }
441 : :
442 : 0 : void FBRetriangulate::make_vert_list()
443 : : {
444 : : unsigned int i;
445 : : int v0, v1;
446 : : FB_Edge *edge;
447 : : VertexStuff *vstuff;
448 [ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe;
449 : : bool foundv0, foundv1;
450 : :
451 [ # # ]: 0 : dpe = my_tri->edge_list.begin();
452 [ # # ][ # # ]: 0 : while ( dpe != my_tri->edge_list.end() ) {
[ # # ]
453 [ # # ]: 0 : edge = *dpe;
454 [ # # ]: 0 : dpe++;
455 : 0 : v0 = edge->v0;
456 : 0 : v1 = edge->v1;
457 : 0 : foundv0 = foundv1 = false;
458 : :
459 [ # # ][ # # ]: 0 : for ( i = 0; i < vertstufflist.size(); i++ ) {
460 [ # # ][ # # ]: 0 : if ( vertstufflist[i]->v0 == v0 ) {
461 [ # # ][ # # ]: 0 : vertstufflist[i]->edge_list.push_back(edge);
462 : 0 : foundv0 = true;
463 : : }
464 [ # # ][ # # ]: 0 : if ( vertstufflist[i]->v0 == v1 ) {
465 [ # # ][ # # ]: 0 : vertstufflist[i]->edge_list.push_back(edge);
466 : 0 : foundv1 = true;
467 : : }
468 : : }
469 [ # # ]: 0 : if ( foundv0 == false ) {
470 [ # # ]: 0 : vstuff = new VertexStuff(v0, edge->v0_type,verts[v0]->coord[p_dir],
471 [ # # ][ # # ]: 0 : verts[v0]->coord[s_dir]);
[ # # ]
472 [ # # ]: 0 : vstuff->edge_list.push_back(edge);
473 [ # # ]: 0 : vertstufflist.push_back(vstuff);
474 : : }
475 [ # # ]: 0 : if ( foundv1 == false ) {
476 [ # # ]: 0 : vstuff = new VertexStuff(v1, edge->v1_type,verts[v1]->coord[p_dir],
477 [ # # ][ # # ]: 0 : verts[v1]->coord[s_dir]);
[ # # ]
478 [ # # ]: 0 : vstuff->edge_list.push_back(edge);
479 [ # # ]: 0 : vertstufflist.push_back(vstuff);
480 : : }
481 : :
482 : : }
483 : :
484 [ # # ][ # # ]: 0 : std::vector<VertexStuff* >::iterator vitbegin, vitend;
485 [ # # ]: 0 : vitbegin = vertstufflist.begin();
486 [ # # ]: 0 : vitend = vertstufflist.end();
487 : :
488 [ # # ]: 0 : std::sort(vitbegin,vitend,vertstuffcompfn_less());
489 : :
490 : 0 : }
491 : :
492 : 0 : void FBRetriangulate::add_edge_up(int v0, int seq)
493 : : {
494 : : unsigned int i, k;
495 : : int v1, v0test, v1test, v0type, v1type;
496 : : bool foundit, crossed;
497 : : FB_Edge *edge;
498 [ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe;
499 : :
500 : 0 : v1 = 0; //To keep compiler from warning that v1 might be used uninitialized.
501 : 0 : v1type = 0;
502 [ # # ]: 0 : v0type = vertstufflist[seq]->v0type;
503 [ # # ][ # # ]: 0 : for ( k = seq+1; k < vertstufflist.size(); k++ ) {
504 : 0 : foundit = true;
505 [ # # ]: 0 : v1 = vertstufflist[k]->v0;
506 [ # # ][ # # ]: 0 : if ( fabs(verts[v1]->coord[p_dir]-verts[v0]->coord[p_dir]) < EPSILON )
[ # # ]
507 : 0 : continue;
508 [ # # ]: 0 : v1type = vertstufflist[k]->v0type;
509 : : // v0 to v1 is the putative new edge. Test whether it crosses any
510 : : // existing internal edge. Any such internal edge that it crosses
511 : : // has to have an endpoint higher than v1. If v1 is the next-to-top
512 : : // vertex, use it.
513 [ # # ][ # # ]: 0 : if ( k == vertstufflist.size() - 1 ) {
514 : 0 : foundit = true;
515 [ # # ]: 0 : add_tri_edge(v0,v1,v0type,v1type);
516 : 0 : return;
517 : : }
518 [ # # ][ # # ]: 0 : for ( i = k+1; i < vertstufflist.size()-1; i++ ) {
519 [ # # ][ # # ]: 0 : dpe = vertstufflist[i]->edge_list.begin();
520 : :
521 [ # # ][ # # ]: 0 : while ( dpe != vertstufflist[i]->edge_list.end() ) {
[ # # ][ # # ]
522 [ # # ]: 0 : edge = *dpe;
523 [ # # ]: 0 : dpe++;
524 [ # # ][ # # ]: 0 : if ( (edge->v0_type != INTERIOR_VERT) &&
525 : 0 : (edge->v1_type != INTERIOR_VERT) )
526 : 0 : continue;
527 : 0 : v0test = edge->v0;
528 : 0 : v1test = edge->v1;
529 [ # # ][ # # ]: 0 : if ( (v0test == v1) || (v1test == v1) ) continue;
530 [ # # ]: 0 : crossed = test_for_crossing(v0,v1,v0test,v1test);
531 [ # # ]: 0 : if ( crossed == true ) {
532 : 0 : foundit = false;
533 : 0 : break;
534 : : }
535 : : }
536 [ # # ]: 0 : if ( foundit == false ) break;
537 : : } // end of "for (i ...."
538 [ # # ]: 0 : if ( foundit == true ) break;
539 : : }
540 [ # # ]: 0 : add_tri_edge(v0,v1,v0type,v1type);
541 : : }
542 : :
543 : 0 : void FBRetriangulate::add_edge_down(int v0, int seq)
544 : : {
545 : : int i, k;
546 : : int v1, v0test, v1test, v0type, v1type;
547 : : bool foundit, crossed;
548 : : FB_Edge *edge;
549 [ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe;
550 : :
551 : 0 : v1 = 0; //To keep compiler from warning that v1 might be used uninitialized.
552 : 0 : v1type = 0;
553 [ # # ]: 0 : v0type = vertstufflist[seq]->v0type;
554 [ # # ]: 0 : for ( k = seq-1; k > -1; k-- ) {
555 : 0 : foundit = true;
556 [ # # ]: 0 : v1 = vertstufflist[k]->v0;
557 [ # # ][ # # ]: 0 : if ( fabs(verts[v1]->coord[p_dir]-verts[v0]->coord[p_dir]) < EPSILON ) continue;
[ # # ]
558 [ # # ]: 0 : v1type = vertstufflist[k]->v0type;
559 : : // v0 to v1 is the putative new edge. Test whether it crosses
560 : : // any existing internal edge. Any such internal edge that it
561 : : // crosses has to have an endpoint higher than v1. If v1 is the
562 : : // next-to-top vertex, use it.
563 [ # # ]: 0 : if ( k == 0 ) {
564 : 0 : foundit = true;
565 [ # # ]: 0 : add_tri_edge(v0,v1,v0type,v1type);
566 : 0 : return;
567 : : }
568 [ # # ]: 0 : for ( i = k-1; i > 0; i-- ) {
569 [ # # ][ # # ]: 0 : dpe = vertstufflist[i]->edge_list.begin();
570 : :
571 [ # # ][ # # ]: 0 : while ( dpe != vertstufflist[i]->edge_list.end() ) {
[ # # ][ # # ]
572 [ # # ]: 0 : edge = *dpe;
573 [ # # ]: 0 : dpe++;
574 [ # # ][ # # ]: 0 : if ( (edge->v0_type != INTERIOR_VERT) &&
575 : 0 : (edge->v1_type != INTERIOR_VERT) )
576 : 0 : continue;
577 : 0 : v0test = edge->v0;
578 : 0 : v1test = edge->v1;
579 [ # # ][ # # ]: 0 : if ( (v0test == v1) || (v1test == v1) ) continue;
580 [ # # ]: 0 : crossed = test_for_crossing(v0,v1,v0test,v1test);
581 [ # # ]: 0 : if ( crossed == true ) {
582 : 0 : foundit = false;
583 : 0 : break;
584 : : }
585 : : }
586 [ # # ]: 0 : if ( foundit == false ) break;
587 : : } // end of "for (i ...."
588 [ # # ]: 0 : if ( foundit == true ) break;
589 : : }
590 [ # # ]: 0 : add_tri_edge(v0,v1,v0type,v1type);
591 : : }
592 : :
593 : 0 : bool FBRetriangulate::test_for_crossing(int v0, int v1, int v2, int v3)
594 : : {
595 : : double x0, y0, x1, y1, x2, y2, x3, y3, dxa, dya, dxb, dyb, p01x, p01y;
596 : : double product, dasq, dbsq, prodsq;
597 : : double s, t;
598 : :
599 : 0 : x0 = verts[v0]->coord[p_dir]; y0 = verts[v0]->coord[s_dir];
600 : 0 : x1 = verts[v1]->coord[p_dir]; y1 = verts[v1]->coord[s_dir];
601 : 0 : x2 = verts[v2]->coord[p_dir]; y2 = verts[v2]->coord[s_dir];
602 : 0 : x3 = verts[v3]->coord[p_dir]; y3 = verts[v3]->coord[s_dir];
603 : 0 : dxa = x1 - x0; dya = y1 - y0;
604 : 0 : dxb = x3 - x2; dyb = y3 - y2;
605 : :
606 : 0 : product = dxa*dyb - dya*dxb;
607 : 0 : dasq = dxa*dxa + dya*dya;
608 : 0 : dbsq = dxb*dxb + dyb*dyb;
609 : 0 : prodsq = product*product;
610 : :
611 [ # # ]: 0 : if ( prodsq > EPSILON2*dasq*dbsq ) {
612 : 0 : p01x = x2 - x0;
613 : 0 : p01y = y2 - y0;
614 : 0 : s = (p01x*dyb - p01y*dxb)/product;
615 [ # # ][ # # ]: 0 : if ( (s < 0.0) || (s > 1.0) ) return false;
616 : :
617 : 0 : t = (p01x*dya - p01y*dxa)/product;
618 [ # # ][ # # ]: 0 : if ( (t < 0.0) || (t > 1.0) ) return false;
619 : :
620 : : }
621 : :
622 : 0 : return true;
623 : : }
624 : :
625 : 0 : void FBRetriangulate::add_tri_edge(int v0, int v1, int v0_type, int v1_type)
626 : : {
627 : : FB_Edge *edge;
628 : : unsigned int i;
629 : :
630 [ # # ][ # # ]: 0 : edge = new FB_Edge(v0,v1,v0_type,v1_type,false);
631 : 0 : edge->edge_type = INTERIOR_EDGE;
632 [ # # ]: 0 : my_tri->edge_list.push_back(edge);
633 [ # # ][ # # ]: 0 : for ( i = 0; i < vertstufflist.size(); i++ ) {
634 [ # # ][ # # ]: 0 : if ( vertstufflist[i]->v0 == v0 ) {
635 [ # # ][ # # ]: 0 : vertstufflist[i]->edge_list.push_back(edge);
636 : : }
637 [ # # ][ # # ]: 0 : if ( vertstufflist[i]->v0 == v1 ) {
638 [ # # ][ # # ]: 0 : vertstufflist[i]->edge_list.push_back(edge);
639 [ # # ]: 0 : v1_type = vertstufflist[i]->v0type;
640 : : }
641 : : }
642 : :
643 : 0 : }
644 : :
645 : 0 : bool FBRetriangulate::get_a_chain(std::vector<int> *chainlist)
646 : : {
647 : : bool status;
648 : : int vthis, vprev, vstart;
649 : : int direction;
650 : : FB_Edge *edge;
651 [ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe;
652 : 0 : status = false;
653 [ # # ]: 0 : dpe = my_tri->edge_list.begin();
654 : : // to keep compiler from warning that edge might be used uninitialized
655 : 0 : edge = 0;
656 : :
657 [ # # ][ # # ]: 0 : while ( dpe != my_tri->edge_list.end() ) {
[ # # ]
658 [ # # ]: 0 : edge = *dpe;
659 [ # # ]: 0 : dpe++;
660 : : // Skip edges that are not interior edges.
661 : : // if ( edge->v0_type == edge->v1_type ) continue;
662 [ # # ]: 0 : if ( edge->edge_type == BDRY_EDGE ) continue;
663 [ # # ]: 0 : if ( edge->num_times < 2 ) {
664 [ # # ][ # # ]: 0 : if ( (edge->edge_type == BDRY_EDGE) && (edge->num_times == 1) )
665 : 0 : continue;
666 : 0 : status = true;
667 : 0 : edge->num_times++;
668 : 0 : break;
669 : : }
670 : : }
671 [ # # ]: 0 : if ( status == true ) {
672 [ # # ]: 0 : if ( edge->num_times == 1 ) {
673 : 0 : vthis = edge->v1;
674 : 0 : vprev = edge->v0;
675 : 0 : direction = 1;
676 : : } else {
677 : 0 : vthis = edge->v0;
678 : 0 : vprev = edge->v1;
679 : 0 : direction = 1;
680 : : }
681 : 0 : vstart = vprev;
682 [ # # ]: 0 : chainlist->push_back(vthis);
683 : :
684 [ # # ]: 0 : while ( vthis != vstart ) {
685 [ # # ]: 0 : get_next_vert_in_chain(vthis,vprev,direction);
686 [ # # ]: 0 : chainlist->push_back(vthis);
687 : : }
688 : : }
689 : :
690 [ # # ]: 0 : if ( status == false ) { // There were no interior edges.
691 : : // So just go around the perimeter.
692 [ # # ]: 0 : dpe = my_tri->edge_list.begin();
693 [ # # ]: 0 : edge = *dpe;
694 [ # # ]: 0 : if ( edge->num_times != 0 ) {
695 : 0 : status = false;
696 : 0 : return status;
697 : : }
698 : 0 : edge->num_times = 1;
699 : 0 : vthis = edge->v0;
700 : 0 : vprev = edge->v1;
701 : 0 : direction = 1;
702 : 0 : vstart = vprev;
703 [ # # ]: 0 : chainlist->push_back(vthis);
704 : :
705 [ # # ]: 0 : while ( vthis != vstart ) {
706 [ # # ]: 0 : get_next_vert_in_chain(vthis,vprev,direction);
707 [ # # ]: 0 : chainlist->push_back(vthis);
708 : : }
709 : 0 : status = true;
710 : : }
711 : :
712 : 0 : return status;
713 : :
714 : : }
715 : :
716 : 0 : void FBRetriangulate::get_next_vert_in_chain(int& vthis,
717 : : int& vprev, int direction)
718 : : // Right now, direction always equals 1.
719 : : {
720 : : unsigned int i;
721 : : FB_Edge *edge;
722 [ # # ][ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe, dpebegin, dpeend;
[ # # ]
723 : :
724 [ # # ][ # # ]: 0 : for ( i = 0; i < vertstufflist.size(); i++ ) {
725 [ # # ][ # # ]: 0 : if ( vertstufflist[i]->v0 == (int)vthis ) break;
726 : : }
727 [ # # ][ # # ]: 0 : dpe = dpebegin = vertstufflist[i]->edge_list.begin();
728 [ # # ][ # # ]: 0 : dpeend = vertstufflist[i]->edge_list.end();
729 [ # # ][ # # ]: 0 : while ( dpe != dpeend ) {
730 [ # # ]: 0 : edge = *dpe;
731 [ # # ][ # # ]: 0 : if ( (edge->v0 == vprev) || (edge->v1 == vprev) ) break;
732 [ # # ]: 0 : dpe++;
733 : : }
734 [ # # ]: 0 : if ( direction == 1 ) {
735 [ # # ][ # # ]: 0 : if ( dpe == dpebegin )
736 [ # # ][ # # ]: 0 : dpe = vertstufflist[i]->edge_list.end();
737 [ # # ]: 0 : dpe--;
738 : : } else {
739 [ # # ]: 0 : dpe++;
740 [ # # ][ # # ]: 0 : if ( dpe == dpeend )
741 : 0 : dpe = dpebegin;
742 : : }
743 [ # # ]: 0 : edge = *dpe;
744 : 0 : vprev = vthis;
745 [ # # ]: 0 : if ( vthis == edge->v1 ) {
746 : : // Swap the edge verts. We do this so that next time we see this
747 : : // edge we will know that it was oriented to point in the direction
748 : : // of the previous loop. Thus we will know to proceed in the
749 : : // opposite direction next time.
750 : : // (see edge->num_times test in get_a_chain().)
751 : : unsigned int vtemp;
752 : 0 : vtemp = edge->v0;
753 : 0 : edge->v0 = edge->v1;
754 : 0 : edge->v1 = vtemp;
755 : 0 : vtemp = edge->v0_type;
756 : 0 : edge->v0_type = edge->v1_type;
757 : 0 : edge->v1_type = vtemp;
758 : : }
759 : 0 : vthis = edge->v1;
760 : 0 : edge->num_times++;
761 : :
762 : 0 : }
763 : :
764 : 0 : void FBRetriangulate::sort_vertstufflist_edges()
765 : : {
766 : : // For each vertex that has more than 2 edges, sort the edges in CCW order.
767 : : unsigned int i;
768 : : FB_Edge *edge;
769 [ # # ][ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe, dpebegin, dpeend;
[ # # ]
770 : : double x0, y0, x1, y1, slope;
771 : : int v0;
772 : : unsigned int quadrant;
773 : :
774 : 0 : quadrant = 0; // Initialize so compiler won't warn.
775 : :
776 [ # # ][ # # ]: 0 : for ( i = 0; i < vertstufflist.size(); i++ ) {
777 [ # # ][ # # ]: 0 : if ( vertstufflist[i]->edge_list.size() > 2 ) {
[ # # ]
778 [ # # ]: 0 : v0 = vertstufflist[i]->v0;
779 [ # # ]: 0 : x0 = verts[v0]->coord[p_dir];
780 [ # # ]: 0 : y0 = verts[v0]->coord[s_dir];
781 [ # # ][ # # ]: 0 : dpe = vertstufflist[i]->edge_list.begin();
782 [ # # ][ # # ]: 0 : while ( dpe != vertstufflist[i]->edge_list.end() ) {
[ # # ][ # # ]
783 [ # # ]: 0 : edge = *dpe;
784 [ # # ]: 0 : dpe++;
785 [ # # ]: 0 : if ( edge->v0 == v0 ) {
786 [ # # ]: 0 : x1 = verts[edge->v1]->coord[p_dir];
787 [ # # ]: 0 : y1 = verts[edge->v1]->coord[s_dir];
788 : : } else {
789 [ # # ]: 0 : x1 = verts[edge->v0]->coord[p_dir];
790 [ # # ]: 0 : y1 = verts[edge->v0]->coord[s_dir];
791 : : }
792 [ # # ]: 0 : if ( fabs(x1-x0) < EPSILON ) {
793 [ # # ]: 0 : if ( y1 > y0 ) {
794 : 0 : slope = CUBIT_DBL_MAX;
795 : 0 : quadrant = 1;
796 : : } else {
797 : 0 : slope = -CUBIT_DBL_MAX;
798 : 0 : quadrant = 4;
799 : : }
800 : : } else {
801 : 0 : slope = (y1-y0)/(x1-x0);
802 [ # # ][ # # ]: 0 : if ( (x1 >= x0) && (y1 >= y0) ) quadrant = 1;
803 [ # # ][ # # ]: 0 : else if ( (x1 < x0) && (y1 > y0) ) quadrant = 2;
804 [ # # ][ # # ]: 0 : else if ( (x1 <= x0) && (y1 <= y0) ) quadrant = 3;
805 [ # # ][ # # ]: 0 : else if ( (x1 > x0) && (y1 < y0) ) quadrant = 4;
806 : : }
807 : 0 : edge->slope = slope;
808 : 0 : edge->quadrant = quadrant;
809 : : }
810 : : // Now sort the edge list by the value of quadrant or slope.
811 : : // vertstufflist[i]->edge_list.sort(edgecompfn_less());
812 : : // vertstufflist[i]->edge_list.sort(edgecf_less);
813 [ # # ][ # # ]: 0 : dpebegin = vertstufflist[i]->edge_list.begin();
814 [ # # ][ # # ]: 0 : dpeend = vertstufflist[i]->edge_list.end();
815 : : // if ( winding == CW )
816 [ # # ]: 0 : std::sort(dpebegin,dpeend,edgecompfn_less());
817 : : // else
818 : : // std::sort(dpebegin,dpeend,edgecompfn_more());
819 : :
820 : : }
821 : :
822 [ # # ][ # # ]: 0 : dpe = vertstufflist[i]->edge_list.begin();
823 [ # # ][ # # ]: 0 : while ( dpe != vertstufflist[i]->edge_list.end() ) {
[ # # ][ # # ]
824 [ # # ]: 0 : edge = *dpe;
825 [ # # ]: 0 : dpe++;
826 : : }
827 : :
828 : :
829 : : }
830 : 0 : }
831 : :
832 : 0 : void FBRetriangulate::classify_edges()
833 : : {
834 : : // Flag boundary edges as such.
835 : : FB_Edge *edge;
836 [ # # ]: 0 : std::vector<FB_Edge*>::iterator dpe;
837 : : int type;
838 : :
839 [ # # ]: 0 : dpe = my_tri->edge_list.begin();
840 [ # # ][ # # ]: 0 : while ( dpe != my_tri->edge_list.end() ) {
[ # # ]
841 [ # # ]: 0 : edge = *dpe;
842 : :
843 [ # # ][ # # ]: 0 : if ( (edge->v0_type != INTERIOR_VERT) &&
844 : 0 : (edge->v1_type != INTERIOR_VERT) ) {
845 [ # # ]: 0 : if ( edge->v0_type == edge->v1_type )
846 : 0 : edge->edge_type = BDRY_EDGE;
847 : : else {
848 : 0 : type = UNKNOWN;
849 [ # # # # : 0 : switch( edge->v0_type ) {
# # # ]
850 : : case VERTEX_0:
851 [ # # ]: 0 : if ( edge->v1_type != EDGE_1 ) {
852 : 0 : type = BDRY_EDGE;
853 [ # # ]: 0 : if ( edge->edge_type == INTERSECTION_EDGE) {
854 [ # # ]: 0 : if ( edge->v1_type == VERTEX_1 )
855 : 0 : my_tri->cubitedge0index = INTERSECTION_EDGE;
856 [ # # ]: 0 : else if ( edge->v1_type == VERTEX_2 )
857 : 0 : my_tri->cubitedge2index = INTERSECTION_EDGE;
858 : : }
859 : : }
860 : 0 : break;
861 : : case VERTEX_1:
862 [ # # ]: 0 : if ( edge->v1_type != EDGE_2 ) {
863 : 0 : type = BDRY_EDGE;
864 [ # # ]: 0 : if ( edge->edge_type == INTERSECTION_EDGE) {
865 [ # # ]: 0 : if ( edge->v1_type == VERTEX_2 )
866 : 0 : my_tri->cubitedge1index = INTERSECTION_EDGE;
867 [ # # ]: 0 : else if ( edge->v1_type == VERTEX_0 )
868 : 0 : my_tri->cubitedge0index = INTERSECTION_EDGE;
869 : : }
870 : : }
871 : 0 : break;
872 : : case VERTEX_2:
873 [ # # ]: 0 : if ( edge->v1_type != EDGE_0 ) {
874 : 0 : type = BDRY_EDGE;
875 [ # # ]: 0 : if ( edge->edge_type == INTERSECTION_EDGE) {
876 [ # # ]: 0 : if ( edge->v1_type == VERTEX_1 )
877 : 0 : my_tri->cubitedge1index = INTERSECTION_EDGE;
878 [ # # ]: 0 : else if ( edge->v1_type == VERTEX_0 )
879 : 0 : my_tri->cubitedge2index = INTERSECTION_EDGE;
880 : : }
881 : : }
882 : 0 : break;
883 : : case EDGE_0:
884 [ # # ][ # # ]: 0 : if ( (edge->v1_type == VERTEX_0) ||
885 : 0 : (edge->v1_type == VERTEX_1) ) {
886 : 0 : type = BDRY_EDGE;
887 [ # # ]: 0 : if ( edge->edge_type == INTERSECTION_EDGE)
888 : 0 : my_tri->cubitedge0index = INTERSECTION_EDGE;
889 : : }
890 : 0 : break;
891 : : case EDGE_1:
892 [ # # ][ # # ]: 0 : if ( (edge->v1_type == VERTEX_1) ||
893 : 0 : (edge->v1_type == VERTEX_2) ) {
894 : 0 : type = BDRY_EDGE;
895 [ # # ]: 0 : if ( edge->edge_type == INTERSECTION_EDGE)
896 : 0 : my_tri->cubitedge1index = INTERSECTION_EDGE;
897 : : }
898 : 0 : break;
899 : : case EDGE_2:
900 [ # # ][ # # ]: 0 : if ( (edge->v1_type == VERTEX_2) ||
901 : 0 : (edge->v1_type == VERTEX_0) ) {
902 : 0 : type = BDRY_EDGE;
903 [ # # ]: 0 : if ( edge->edge_type == INTERSECTION_EDGE)
904 : 0 : my_tri->cubitedge2index = INTERSECTION_EDGE;
905 : : }
906 : 0 : break;
907 : : }
908 [ # # ]: 0 : if ( type == BDRY_EDGE ) edge->edge_type = BDRY_EDGE;
909 : : }
910 : : } // else edge->edge_type = INTERIOR_EDGE;
911 [ # # ]: 0 : dpe++;
912 : : }
913 : :
914 : 0 : }
915 : :
916 : 0 : void FBRetriangulate::get_edge_indices(int v0, int v1, int v2, int parent,
917 : : int &e0index, int &e1index,
918 : : int &e2index)
919 : : {
920 [ # # ]: 0 : std::vector<FB_Edge*>::iterator itt;
921 [ # # ]: 0 : std::vector<FB_Triangle*>::iterator itp;
922 : : FB_Edge *edge;
923 : : int e_v0, e_v1, e_type, e_v0type, e_v1type;
924 : :
925 [ # # ]: 0 : itp = tris->begin();
926 [ # # ]: 0 : itp += parent;
927 [ # # ][ # # ]: 0 : itt = (*itp)->edge_list.begin();
928 [ # # ][ # # ]: 0 : while ( itt != (*itp)->edge_list.end() ) {
[ # # ][ # # ]
929 [ # # ]: 0 : edge = *itt;
930 : 0 : e_v0 = edge->v0;
931 : 0 : e_v1 = edge->v1;
932 : 0 : e_v0type = edge->v0_type;
933 : 0 : e_v1type = edge->v1_type;
934 : 0 : e_type = edge->edge_type;
935 [ # # ][ # # ]: 0 : if ( ( (e_v0 == v0) && (e_v1 == v1) ) ||
[ # # ]
936 [ # # ]: 0 : ( (e_v0 == v1) && (e_v1 == v0) ) ) {
937 [ # # ]: 0 : if ( e_type == INTERSECTION_EDGE )
938 : 0 : e0index = INTERSECTION_EDGE;
939 [ # # ]: 0 : else if ( e_type == INTERIOR_EDGE )
940 : 0 : e0index = 0;
941 [ # # ][ # # ]: 0 : else if ( (e_v0type == EDGE_0) || (e_v1type == EDGE_0) )
942 [ # # ]: 0 : e0index = (*itp)->cubitedge0index;
943 [ # # ][ # # ]: 0 : else if ( (e_v0type == EDGE_1) || (e_v1type == EDGE_1) )
944 [ # # ]: 0 : e0index = (*itp)->cubitedge1index;
945 [ # # ][ # # ]: 0 : else if ( (e_v0type == EDGE_2) || (e_v1type == EDGE_2) )
946 [ # # ]: 0 : e0index = (*itp)->cubitedge2index;
947 [ # # ][ # # ]: 0 : else if ( ( (e_v0type == VERTEX_0) || (e_v0type == VERTEX_1) ) &
[ # # ]
948 [ # # ][ # # ]: 0 : ( (e_v1type == VERTEX_0) || (e_v1type == VERTEX_1) ) )
949 [ # # ]: 0 : e0index = (*itp)->cubitedge0index;
950 [ # # ][ # # ]: 0 : else if ( ( (e_v0type == VERTEX_1) || (e_v0type == VERTEX_2) ) &
[ # # ]
951 [ # # ][ # # ]: 0 : ( (e_v1type == VERTEX_1) || (e_v1type == VERTEX_2) ) )
952 [ # # ]: 0 : e1index = (*itp)->cubitedge1index;
953 [ # # ][ # # ]: 0 : else if ( ( (e_v0type == VERTEX_2) || (e_v0type == VERTEX_0) ) &
[ # # ]
954 [ # # ][ # # ]: 0 : ( (e_v1type == VERTEX_2) || (e_v1type == VERTEX_0) ) )
955 [ # # ]: 0 : e2index = (*itp)->cubitedge2index;
956 : : }
957 [ # # ][ # # ]: 0 : else if ( ( (e_v0 == v1) && (e_v1 == v2) ) ||
[ # # ]
958 [ # # ]: 0 : ( (e_v0 == v2) && (e_v1 == v1) ) ) {
959 [ # # ]: 0 : if ( e_type == INTERSECTION_EDGE )
960 : 0 : e1index = INTERSECTION_EDGE;
961 [ # # ]: 0 : else if ( e_type == INTERIOR_EDGE )
962 : 0 : e1index = 0;
963 [ # # ][ # # ]: 0 : else if ( (e_v0type == EDGE_0) || (e_v1type == EDGE_0) )
964 [ # # ]: 0 : e1index = (*itp)->cubitedge0index;
965 [ # # ][ # # ]: 0 : else if ( (e_v0type == EDGE_1) || (e_v1type == EDGE_1) )
966 [ # # ]: 0 : e1index = (*itp)->cubitedge1index;
967 [ # # ][ # # ]: 0 : else if ( (e_v0type == EDGE_2) || (e_v1type == EDGE_2) )
968 [ # # ]: 0 : e1index = (*itp)->cubitedge2index;
969 [ # # ][ # # ]: 0 : else if ( ( (e_v0type == VERTEX_0) || (e_v0type == VERTEX_1) ) &
[ # # ]
970 [ # # ][ # # ]: 0 : ( (e_v1type == VERTEX_0) || (e_v1type == VERTEX_1) ) )
971 [ # # ]: 0 : e0index = (*itp)->cubitedge0index;
972 [ # # ][ # # ]: 0 : else if ( ( (e_v0type == VERTEX_1) || (e_v0type == VERTEX_2) ) &
[ # # ]
973 [ # # ][ # # ]: 0 : ( (e_v1type == VERTEX_1) || (e_v1type == VERTEX_2) ) )
974 [ # # ]: 0 : e1index = (*itp)->cubitedge1index;
975 [ # # ][ # # ]: 0 : else if ( ( (e_v0type == VERTEX_2) || (e_v0type == VERTEX_0) ) &
[ # # ]
976 [ # # ][ # # ]: 0 : ( (e_v1type == VERTEX_2) || (e_v1type == VERTEX_0) ) )
977 [ # # ]: 0 : e2index = (*itp)->cubitedge2index;
978 : : }
979 [ # # ][ # # ]: 0 : else if ( ( (e_v0 == v2) && (e_v1 == v0) ) ||
[ # # ]
980 [ # # ]: 0 : ( (e_v0 == v0) && (e_v1 == v2) ) ) {
981 [ # # ]: 0 : if ( e_type == INTERSECTION_EDGE )
982 : 0 : e2index = INTERSECTION_EDGE;
983 [ # # ]: 0 : else if ( e_type == INTERIOR_EDGE )
984 : 0 : e2index = 0;
985 [ # # ][ # # ]: 0 : else if ( (e_v0type == EDGE_0) || (e_v1type == EDGE_0) )
986 [ # # ]: 0 : e2index = (*itp)->cubitedge0index;
987 [ # # ][ # # ]: 0 : else if ( (e_v0type == EDGE_1) || (e_v1type == EDGE_1) )
988 [ # # ]: 0 : e2index = (*itp)->cubitedge1index;
989 [ # # ][ # # ]: 0 : else if ( (e_v0type == EDGE_2) || (e_v1type == EDGE_2) )
990 [ # # ]: 0 : e2index = (*itp)->cubitedge2index;
991 [ # # ][ # # ]: 0 : else if ( ( (e_v0type == VERTEX_0) || (e_v0type == VERTEX_1) ) &
[ # # ]
992 [ # # ][ # # ]: 0 : ( (e_v1type == VERTEX_0) || (e_v1type == VERTEX_1) ) )
993 [ # # ]: 0 : e0index = (*itp)->cubitedge0index;
994 [ # # ][ # # ]: 0 : else if ( ( (e_v0type == VERTEX_1) || (e_v0type == VERTEX_2) ) &
[ # # ]
995 [ # # ][ # # ]: 0 : ( (e_v1type == VERTEX_1) || (e_v1type == VERTEX_2) ) )
996 [ # # ]: 0 : e1index = (*itp)->cubitedge1index;
997 [ # # ][ # # ]: 0 : else if ( ( (e_v0type == VERTEX_2) || (e_v0type == VERTEX_0) ) &
[ # # ]
998 [ # # ][ # # ]: 0 : ( (e_v1type == VERTEX_2) || (e_v1type == VERTEX_0) ) )
999 [ # # ]: 0 : e2index = (*itp)->cubitedge2index;
1000 : : }
1001 : :
1002 [ # # ]: 0 : itt++;
1003 : : }
1004 : :
1005 : 0 : }
1006 : :
1007 : :
|