OpenMesh: OpenMesh/Tools/Subdivider/Uniform/Sqrt3InterpolatingSubdividerLabsikGreinerT.hh Source File

| OpenMesh

Sqrt3InterpolatingSubdividerLabsikGreinerT.hh
Go to the documentation of this file.
1 /* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openmesh.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenMesh. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 * ========================================================================= */
41
42 /*==========================================================================*\
43 * *
44 * $Revision: 410 $ *
45 * $Date: 2010-06-17 12:45:58 +0200 (Do, 17. Jun 2010) $ *
46 * *
47 \*==========================================================================*/
48
58 //=============================================================================
59 //
60 // CLASS InterpolatingSqrt3LGT
61 //
62 //=============================================================================
63
64 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_INTERP_SQRT3T_LABSIK_GREINER_HH
65 #define OPENMESH_SUBDIVIDER_UNIFORM_INTERP_SQRT3T_LABSIK_GREINER_HH
66
67
68 //== INCLUDES =================================================================
69
70 #include <OpenMesh/Core/Mesh/Handles.hh>
71 #include <OpenMesh/Core/System/config.hh>
72 #include <OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh>
73
74 #if defined(_DEBUG) || defined(DEBUG)
75 // Makes life lot easier, when playing/messing around with low-level topology
76 // changing methods of OpenMesh
77 # include <OpenMesh/Tools/Utils/MeshCheckerT.hh>
78 # define ASSERT_CONSISTENCY( T, m ) \
79 assert(OpenMesh::Utils::MeshCheckerT<T>(m).check())
80 #else
81 # define ASSERT_CONSISTENCY( T, m )
82 #endif
83 // -------------------- STL
84 #include <vector>
85 #if defined(OM_CC_MIPS)
86 # include <math.h>
87 #else
88 # include <cmath>
89 #endif
90
91 //#define MIRROR_TRIANGLES
92 //#define MIN_NORM
93
94 //== NAMESPACE ================================================================
95
96 namespace OpenMesh { // BEGIN_NS_OPENMESH
97 namespace Subdivider { // BEGIN_NS_DECIMATER
98 namespace Uniform { // BEGIN_NS_UNIFORM
99
100
101 //== CLASS DEFINITION =========================================================
102
103
112 template <typename MeshType, typename RealType = double>
113 class InterpolatingSqrt3LGT : public SubdividerT< MeshType, RealType >
114 {
115 public:
116
117 typedef RealType real_t;
118 typedef MeshType mesh_t;
119 typedef SubdividerT< mesh_t, real_t > parent_t;
120
121 typedef std::vector< std::vector<real_t> > weights_t;
122
123 public:
124
125
126 InterpolatingSqrt3LGT(void) : parent_t()
127 { init_weights(); }
128
129 InterpolatingSqrt3LGT(MeshType &_m) : parent_t(_m)
130 { init_weights(); }
131
132 virtual ~InterpolatingSqrt3LGT() {}
133
134
135 public:
136
137
138 const char *name() const { return "Uniform Interpolating Sqrt3"; }
139
141 void init_weights(size_t _max_valence=50)
142 {
143 weights_.resize(_max_valence);
144
145 weights_[3].resize(4);
146 weights_[3][0] = real_t(+4.0/27);
147 weights_[3][1] = real_t(-5.0/27);
148 weights_[3][2] = real_t(+4.0/27);
149 weights_[3][3] = real_t(+8.0/9);
150
151 weights_[4].resize(5);
152 weights_[4][0] = real_t(+2.0/9);
153 weights_[4][1] = real_t(-1.0/9);
154 weights_[4][2] = real_t(-1.0/9);
155 weights_[4][3] = real_t(+2.0/9);
156 weights_[4][4] = real_t(+7.0/9);
157
158 for(unsigned int K=5; K<_max_valence; ++K)
159 {
160 weights_[K].resize(K+1);
161 double aH = 2.0*cos(M_PI/static_cast<double>(K))/3.0;
162 weights_[K][K] = static_cast<real_t>(1.0 - aH*aH);
163 for(unsigned int i=0; i<K; ++i)
164 {
165
166 weights_[K][i] = static_cast<real_t>((aH*aH + 2.0*aH*cos(2.0*static_cast<double>(i)*M_PI/static_cast<double>(K) + M_PI/static_cast<double>(K)) +
167 2.0*aH*aH*cos(4.0*static_cast<double>(i)*M_PI/static_cast<double>(K) + 2.0*M_PI/static_cast<double>(K)))/static_cast<double>(K));
168 }
169 }
170
171 //just to be sure:
172 weights_[6].resize(0);
173
174 }
175
176
177 protected:
178
179
180 bool prepare( MeshType& _m )
181 {
182 _m.request_edge_status();
183 _m.add_property( fp_pos_ );
184 _m.add_property( ep_nv_ );
185 _m.add_property( mp_gen_ );
186 _m.property( mp_gen_ ) = 0;
187
188 return _m.has_edge_status()
189 && ep_nv_.is_valid() && mp_gen_.is_valid();
190 }
191
192
193 bool cleanup( MeshType& _m )
194 {
195 _m.release_edge_status();
196 _m.remove_property( fp_pos_ );
197 _m.remove_property( ep_nv_ );
198 _m.remove_property( mp_gen_ );
199 return true;
200 }
201
202
203 bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true)
204 {
205
207
208 typename MeshType::VertexIter vit;
209 typename MeshType::VertexVertexIter vvit;
210 typename MeshType::EdgeIter eit;
211 typename MeshType::FaceIter fit;
212 typename MeshType::FaceVertexIter fvit;
213 typename MeshType::FaceHalfedgeIter fheit;
214 typename MeshType::VertexHandle vh;
215 typename MeshType::HalfedgeHandle heh;
216 typename MeshType::Point pos(0,0,0), zero(0,0,0);
217 size_t &gen = _m.property( mp_gen_ );
218
219 for (size_t l=0; l<_n; ++l)
220 {
221 // tag existing edges
222 for (eit=_m.edges_begin(); eit != _m.edges_end();++eit)
223 {
224 _m.status( *eit ).set_tagged( true );
225 if ( (gen%2) && _m.is_boundary(*eit) )
226 compute_new_boundary_points( _m, *eit ); // *) creates new vertices
227 }
228
229 // insert new vertices, and store pos in vp_pos_
230 typename MeshType::FaceIter fend = _m.faces_end();
231 for (fit = _m.faces_begin();fit != fend; ++fit)
232 {
233 if (_m.is_boundary(*fit))
234 {
235 if(gen%2)
236 _m.property(fp_pos_, *fit).invalidate();
237 else
238 {
239 //find the interior boundary halfedge
240 for( heh = _m.halfedge_handle(*fit); !_m.is_boundary( _m.opposite_halfedge_handle(heh) ); heh = _m.next_halfedge_handle(heh) )
241 ;
242 assert(_m.is_boundary( _m.opposite_halfedge_handle(heh) ));
243 pos = zero;
244 //check for two boundaries case:
245 if( _m.is_boundary(_m.next_halfedge_handle(heh)) || _m.is_boundary(_m.prev_halfedge_handle(heh)) )
246 {
247 if(_m.is_boundary(_m.prev_halfedge_handle(heh)))
248 heh = _m.prev_halfedge_handle(heh); //ensure that the boundary halfedges are heh and heh->next
249 //check for three boundaries case:
250 if(_m.is_boundary(_m.next_halfedge_handle(_m.next_halfedge_handle(heh))))
251 {
252 //three boundaries, use COG of triangle
253 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(heh));
254 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
255 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(_m.prev_halfedge_handle(heh)));
256 }
257 else
258 {
259 #ifdef MIRROR_TRIANGLES
260 //two boundaries, mirror two triangles
261 pos += real_t(2.0/9) * _m.point(_m.to_vertex_handle(heh));
262 pos += real_t(4.0/9) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
263 pos += real_t(4.0/9) * _m.point(_m.to_vertex_handle(_m.prev_halfedge_handle(heh)));
264 pos += real_t(-1.0/9) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(_m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh)))));
265 #else
266 pos += real_t(7.0/24) * _m.point(_m.to_vertex_handle(heh));
267 pos += real_t(3.0/8) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
268 pos += real_t(3.0/8) * _m.point(_m.to_vertex_handle(_m.prev_halfedge_handle(heh)));
269 pos += real_t(-1.0/24) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(_m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh)))));
270 #endif
271 }
272 }
273 else
274 {
275 vh = _m.to_vertex_handle(_m.next_halfedge_handle(heh));
276 //check last vertex regularity
277 if((_m.valence(vh) == 6) || _m.is_boundary(vh))
278 {
279 #ifdef MIRROR_TRIANGLES
280 //use regular rule and mirror one triangle
281 pos += real_t(5.0/9) * _m.point(vh);
282 pos += real_t(3.0/9) * _m.point(_m.to_vertex_handle(heh));
283 pos += real_t(3.0/9) * _m.point(_m.to_vertex_handle(_m.opposite_halfedge_handle(heh)));
284 pos += real_t(-1.0/9) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(_m.opposite_halfedge_handle(_m.next_halfedge_handle(heh)))));
285 pos += real_t(-1.0/9) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(_m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh)))));
286 #else
287 #ifdef MIN_NORM
288 pos += real_t(1.0/9) * _m.point(vh);
289 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(heh));
290 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(_m.opposite_halfedge_handle(heh)));
291 pos += real_t(1.0/9) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(_m.opposite_halfedge_handle(_m.next_halfedge_handle(heh)))));
292 pos += real_t(1.0/9) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(_m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh)))));
293 #else
294 pos += real_t(1.0/2) * _m.point(vh);
295 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(heh));
296 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(_m.opposite_halfedge_handle(heh)));
297 pos += real_t(-1.0/12) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(_m.opposite_halfedge_handle(_m.next_halfedge_handle(heh)))));
298 pos += real_t(-1.0/12) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(_m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh)))));
299 #endif
300 #endif
301 }
302 else
303 {
304 //irregular setting, use usual irregular rule
305 unsigned int K = _m.valence(vh);
306 pos += weights_[K][K]*_m.point(vh);
307 heh = _m.opposite_halfedge_handle( _m.next_halfedge_handle(heh) );
308 for(unsigned int i = 0; i<K; ++i, heh = _m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh)) )
309 {
310 pos += weights_[K][i]*_m.point(_m.to_vertex_handle(heh));
311 }
312 }
313 }
314 vh = _m.add_vertex( pos );
315 _m.property(fp_pos_, *fit) = vh;
316 }
317 }
318 else
319 {
320 pos = zero;
321 int nOrdinary = 0;
322
323 //check number of extraordinary vertices
324 for(fvit = _m.fv_iter( *fit ); fvit.is_valid(); ++fvit)
325 if( (_m.valence(*fvit)) == 6 || _m.is_boundary(*fvit) )
326 ++nOrdinary;
327
328 if(nOrdinary==3)
329 {
330 for(fheit = _m.fh_iter( *fit ); fheit.is_valid(); ++fheit)
331 {
332 //one ring vertex has weight 32/81
333 heh = *fheit;
334 assert(_m.to_vertex_handle(heh).is_valid());
335 pos += real_t(32.0/81) * _m.point(_m.to_vertex_handle(heh));
336 //tip vertex has weight -1/81
337 heh = _m.opposite_halfedge_handle(heh);
338 assert(heh.is_valid());
339 assert(_m.next_halfedge_handle(heh).is_valid());
340 assert(_m.to_vertex_handle(_m.next_halfedge_handle(heh)).is_valid());
341 pos -= real_t(1.0/81) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
342 //outer vertices have weight -2/81
343 heh = _m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh));
344 assert(heh.is_valid());
345 assert(_m.next_halfedge_handle(heh).is_valid());
346 assert(_m.to_vertex_handle(_m.next_halfedge_handle(heh)).is_valid());
347 pos -= real_t(2.0/81) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
348 heh = _m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh));
349 assert(heh.is_valid());
350 assert(_m.next_halfedge_handle(heh).is_valid());
351 assert(_m.to_vertex_handle(_m.next_halfedge_handle(heh)).is_valid());
352 pos -= real_t(2.0/81) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
353 }
354 }
355 else
356 {
357 //only use irregular vertices:
358 for(fheit = _m.fh_iter( *fit ); fheit.is_valid(); ++fheit)
359 {
360 vh = _m.to_vertex_handle(*fheit);
361 if( (_m.valence(vh) != 6) && (!_m.is_boundary(vh)) )
362 {
363 unsigned int K = _m.valence(vh);
364 pos += weights_[K][K]*_m.point(vh);
365 heh = _m.opposite_halfedge_handle( *fheit );
366 for(unsigned int i = 0; i<K; ++i, heh = _m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh)) )
367 {
368 pos += weights_[K][i]*_m.point(_m.to_vertex_handle(heh));
369 }
370 }
371 }
372 pos *= real_t(1.0/(3-nOrdinary));
373 }
374
375 vh = _m.add_vertex( pos );
376 _m.property(fp_pos_, *fit) = vh;
377 }
378 }
379
380 //split faces
381 for (fit = _m.faces_begin();fit != fend; ++fit)
382 {
383 if ( _m.is_boundary(*fit) && (gen%2))
384 {
385 boundary_split( _m, *fit );
386 }
387 else
388 {
389 assert(_m.property(fp_pos_, *fit).is_valid());
390 _m.split( *fit, _m.property(fp_pos_, *fit) );
391 }
392 }
393
394 // flip old edges
395 for (eit=_m.edges_begin(); eit != _m.edges_end(); ++eit)
396 if ( _m.status( *eit ).tagged() && !_m.is_boundary( *eit ) )
397 _m.flip(*eit);
398
399 // Now we have an consistent mesh!
400 ASSERT_CONSISTENCY( MeshType, _m );
401
402 // increase generation by one
403 ++gen;
404 }
405 return true;
406 }
407
408 private:
409
410 // Pre-compute location of new boundary points for odd generations
411 // and store them in the edge property ep_nv_;
412 void compute_new_boundary_points( MeshType& _m,
413 const typename MeshType::EdgeHandle& _eh)
414 {
415 assert( _m.is_boundary(_eh) );
416
417 typename MeshType::HalfedgeHandle heh;
418 typename MeshType::VertexHandle vh1, vh2, vh3, vh4, vhl, vhr;
419 typename MeshType::Point zero(0,0,0), P1, P2, P3, P4;
420
421 /*
422 // *---------*---------*
423 // / \ / \ / \
424 // / \ / \ / \
425 // / \ / \ / \
426 // / \ / \ / \
427 // *---------*--#---#--*---------*
428 //
429 // ^ ^ ^ ^ ^ ^
430 // P1 P2 pl pr P3 P4
431 */
432 // get halfedge pointing from P3 to P2 (outer boundary halfedge)
433
434 heh = _m.halfedge_handle(_eh,
435 _m.is_boundary(_m.halfedge_handle(_eh,1)));
436
437 assert( _m.is_boundary( _m.next_halfedge_handle( heh ) ) );
438 assert( _m.is_boundary( _m.prev_halfedge_handle( heh ) ) );
439
440 vh1 = _m.to_vertex_handle( _m.next_halfedge_handle( heh ) );
441 vh2 = _m.to_vertex_handle( heh );
442 vh3 = _m.from_vertex_handle( heh );
443 vh4 = _m.from_vertex_handle( _m.prev_halfedge_handle( heh ));
444
445 P1 = _m.point(vh1);
446 P2 = _m.point(vh2);
447 P3 = _m.point(vh3);
448 P4 = _m.point(vh4);
449
450 vhl = _m.add_vertex(real_t(-5.0/81)*P1 + real_t(20.0/27)*P2 + real_t(10.0/27)*P3 + real_t(-4.0/81)*P4);
451 vhr = _m.add_vertex(real_t(-5.0/81)*P4 + real_t(20.0/27)*P3 + real_t(10.0/27)*P2 + real_t(-4.0/81)*P1);
452
453 _m.property(ep_nv_, _eh).first = vhl;
454 _m.property(ep_nv_, _eh).second = vhr;
455 }
456
457
458 void boundary_split( MeshType& _m, const typename MeshType::FaceHandle& _fh )
459 {
460 assert( _m.is_boundary(_fh) );
461
462 typename MeshType::VertexHandle vhl, vhr;
463 typename MeshType::FaceEdgeIter fe_it;
464 typename MeshType::HalfedgeHandle heh;
465
466 // find boundary edge
467 for( fe_it=_m.fe_iter( _fh ); fe_it.is_valid() && !_m.is_boundary( *fe_it ); ++fe_it ) {};
468
469 // use precomputed, already inserted but not linked vertices
470 vhl = _m.property(ep_nv_, *fe_it).first;
471 vhr = _m.property(ep_nv_, *fe_it).second;
472
473 /*
474 // *---------*---------*
475 // / \ / \ / \
476 // / \ / \ / \
477 // / \ / \ / \
478 // / \ / \ / \
479 // *---------*--#---#--*---------*
480 //
481 // ^ ^ ^ ^ ^ ^
482 // P1 P2 pl pr P3 P4
483 */
484 // get halfedge pointing from P2 to P3 (inner boundary halfedge)
485
486 heh = _m.halfedge_handle(*fe_it, _m.is_boundary(_m.halfedge_handle(*fe_it,0)));
487
488 typename MeshType::HalfedgeHandle pl_P3;
489
490 // split P2->P3 (heh) in P2->pl (heh) and pl->P3
491 boundary_split( _m, heh, vhl ); // split edge
492 pl_P3 = _m.next_halfedge_handle( heh ); // store next halfedge handle
493 boundary_split( _m, heh ); // split face
494
495 // split pl->P3 in pl->pr and pr->P3
496 boundary_split( _m, pl_P3, vhr );
497 boundary_split( _m, pl_P3 );
498
499 assert( _m.is_boundary( vhl ) && _m.halfedge_handle(vhl).is_valid() );
500 assert( _m.is_boundary( vhr ) && _m.halfedge_handle(vhr).is_valid() );
501 }
502
503 void boundary_split(MeshType& _m,
504 const typename MeshType::HalfedgeHandle& _heh,
505 const typename MeshType::VertexHandle& _vh)
506 {
507 assert( _m.is_boundary( _m.edge_handle(_heh) ) );
508
509 typename MeshType::HalfedgeHandle
510 heh(_heh),
511 opp_heh( _m.opposite_halfedge_handle(_heh) ),
512 new_heh, opp_new_heh;
513 typename MeshType::VertexHandle to_vh(_m.to_vertex_handle(heh));
514 typename MeshType::HalfedgeHandle t_heh;
515
516 /*
517 * P5
518 * *
519 * /|\
520 * / \
521 * / \
522 * / \
523 * / \
524 * /_ heh new \
525 * *-----\*-----\*\-----*
526 * ^ ^ t_heh
527 * _vh to_vh
528 *
529 * P1 P2 P3 P4
530 */
531 // Re-Setting Handles
532
533 // find halfedge point from P4 to P3
534 for(t_heh = heh;
535 _m.next_halfedge_handle(t_heh) != opp_heh;
536 t_heh = _m.opposite_halfedge_handle(_m.next_halfedge_handle(t_heh)))
537 {}
538
539 assert( _m.is_boundary( t_heh ) );
540
541 new_heh = _m.new_edge( _vh, to_vh );
542 opp_new_heh = _m.opposite_halfedge_handle(new_heh);
543
544 // update halfedge connectivity
545 _m.set_next_halfedge_handle(t_heh, opp_new_heh); // P4-P3 -> P3-P2
546 _m.set_next_halfedge_handle(new_heh, _m.next_halfedge_handle(heh)); // P2-P3 -> P3-P5
547 _m.set_next_halfedge_handle(heh, new_heh); // P1-P2 -> P2-P3
548 _m.set_next_halfedge_handle(opp_new_heh, opp_heh); // P3-P2 -> P2-P1
549
550 // both opposite halfedges point to same face
551 _m.set_face_handle(opp_new_heh, _m.face_handle(opp_heh));
552
553 // let heh finally point to new inserted vertex
554 _m.set_vertex_handle(heh, _vh);
555
556 // let heh and new_heh point to same face
557 _m.set_face_handle(new_heh, _m.face_handle(heh));
558
559 // let opp_new_heh be the new outgoing halfedge for to_vh
560 // (replaces for opp_heh)
561 _m.set_halfedge_handle( to_vh, opp_new_heh );
562
563 // let opp_heh be the outgoing halfedge for _vh
564 _m.set_halfedge_handle( _vh, opp_heh );
565 }
566
567 void boundary_split( MeshType& _m,
568 const typename MeshType::HalfedgeHandle& _heh)
569 {
570 assert( _m.is_boundary( _m.opposite_halfedge_handle( _heh ) ) );
571
572 typename MeshType::HalfedgeHandle
573 heh(_heh),
574 n_heh(_m.next_halfedge_handle(heh));
575
576 typename MeshType::VertexHandle
577 to_vh(_m.to_vertex_handle(heh));
578
579 typename MeshType::HalfedgeHandle
580 heh2(_m.new_edge(to_vh,
581 _m.to_vertex_handle(_m.next_halfedge_handle(n_heh)))),
582 heh3(_m.opposite_halfedge_handle(heh2));
583
584 typename MeshType::FaceHandle
585 new_fh(_m.new_face()),
586 fh(_m.face_handle(heh));
587
588 // Relink (half)edges
589 _m.set_face_handle(heh, new_fh);
590 _m.set_face_handle(heh2, new_fh);
591 _m.set_next_halfedge_handle(heh2, _m.next_halfedge_handle(_m.next_halfedge_handle(n_heh)));
592 _m.set_next_halfedge_handle(heh, heh2);
593 _m.set_face_handle( _m.next_halfedge_handle(heh2), new_fh);
594
595 _m.set_next_halfedge_handle(heh3, n_heh);
596 _m.set_next_halfedge_handle(_m.next_halfedge_handle(n_heh), heh3);
597 _m.set_face_handle(heh3, fh);
598
599 _m.set_halfedge_handle( fh, n_heh);
600 _m.set_halfedge_handle(new_fh, heh);
601
602
603 }
604
605 private:
606
607 weights_t weights_;
608 OpenMesh::FPropHandleT< typename MeshType::VertexHandle > fp_pos_;
609 OpenMesh::EPropHandleT< std::pair< typename MeshType::VertexHandle,
610 typename MeshType::VertexHandle> > ep_nv_;
611 OpenMesh::MPropHandleT< size_t > mp_gen_;
612 };
613
614
615 //=============================================================================
616 } // END_NS_UNIFORM
617 } // END_NS_SUBDIVIDER
618 } // END_NS_OPENMESH
619 //=============================================================================
620 #endif // OPENMESH_SUBDIVIDER_UNIFORM_SQRT3T_HH
621 //=============================================================================
OpenMesh::Subdivider::Uniform::SubdividerT
Abstract base class for uniform subdivision algorithms.
Definition: SubdividerT.hh:93
OpenMesh::Subdivider::Uniform::InterpolatingSqrt3LGT
Uniform Interpolating Sqrt3 subdivision algorithm
Definition: Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:113
OpenMesh::Subdivider::Uniform::InterpolatingSqrt3LGT::name
const char * name() const
Return name of subdivision algorithm.
Definition: Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:138
OpenMesh::Subdivider::Uniform::InterpolatingSqrt3LGT::subdivide
bool subdivide(MeshType &_m, size_t _n, const bool _update_points=true)
Subdivide mesh _m _n times.
Definition: Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:203
OpenMesh::Subdivider::Uniform::InterpolatingSqrt3LGT::init_weights
void init_weights(size_t _max_valence=50)
Pre-compute weights.
Definition: Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:141
OpenMesh::BaseHandle::is_valid
bool is_valid() const
The handle is valid iff the index is not negative.
Definition: Handles.hh:77
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
OpenMesh::Subdivider::Uniform::InterpolatingSqrt3LGT::cleanup
bool cleanup(MeshType &_m)
Cleanup mesh after usage, e.g. remove added properties.
Definition: Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:193
OpenMesh::Subdivider::Uniform::InterpolatingSqrt3LGT::prepare
bool prepare(MeshType &_m)
Prepare mesh, e.g. add properties.
Definition: Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:180
OpenMesh::FPropHandleT< typename MeshType::VertexHandle >
SubdividerT.hh
OpenMesh::EPropHandleT
Handle representing an edge property.
Definition: Property.hh:515
OpenMesh::MPropHandleT< size_t >