OpenMesh
Loading...
Searching...
No Matches
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>
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
96namespace OpenMesh { // BEGIN_NS_OPENMESH
97namespace Subdivider { // BEGIN_NS_DECIMATER
98namespace Uniform { // BEGIN_NS_UNIFORM
99
100
101//== CLASS DEFINITION =========================================================
102
103
112template <typename MeshType, typename RealType = float>
113class InterpolatingSqrt3LGT : public SubdividerT< MeshType, RealType >
114{
115public:
116
117 typedef RealType real_t;
118 typedef MeshType mesh_t;
120
121 typedef std::vector< std::vector<real_t> > weights_t;
122
123public:
124
125
127 { init_weights(); }
128
129 InterpolatingSqrt3LGT(MeshType &_m) : parent_t(_m)
130 { init_weights(); }
131
132 virtual ~InterpolatingSqrt3LGT() {}
133
134
135public:
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 real_t aH = 2.0*cos(M_PI/K)/3.0;
162 weights_[K][K] = 1.0 - aH*aH;
163 for(unsigned int i=0; i<K; ++i)
164 {
165 weights_[K][i] = (aH*aH + 2.0*aH*cos(2.0*i*M_PI/K + M_PI/K) + 2.0*aH*aH*cos(4.0*i*M_PI/K + 2.0*M_PI/K))/K;
166 }
167 }
168
169 //just to be sure:
170 weights_[6].resize(0);
171
172 }
173
174
175protected:
176
177
178 bool prepare( MeshType& _m )
179 {
180 _m.request_edge_status();
181 _m.add_property( fp_pos_ );
182 _m.add_property( ep_nv_ );
183 _m.add_property( mp_gen_ );
184 _m.property( mp_gen_ ) = 0;
185
186 return _m.has_edge_status()
187 && ep_nv_.is_valid() && mp_gen_.is_valid();
188 }
189
190
191 bool cleanup( MeshType& _m )
192 {
193 _m.release_edge_status();
194 _m.remove_property( fp_pos_ );
195 _m.remove_property( ep_nv_ );
196 _m.remove_property( mp_gen_ );
197 return true;
198 }
199
200
201 bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true)
202 {
203
205
206 typename MeshType::VertexIter vit;
207 typename MeshType::VertexVertexIter vvit;
208 typename MeshType::EdgeIter eit;
209 typename MeshType::FaceIter fit;
210 typename MeshType::FaceVertexIter fvit;
211 typename MeshType::FaceHalfedgeIter fheit;
212 typename MeshType::VertexHandle vh;
213 typename MeshType::HalfedgeHandle heh;
214 typename MeshType::Point pos(0,0,0), zero(0,0,0);
215 size_t &gen = _m.property( mp_gen_ );
216
217 for (size_t l=0; l<_n; ++l)
218 {
219 // tag existing edges
220 for (eit=_m.edges_begin(); eit != _m.edges_end();++eit)
221 {
222 _m.status( *eit ).set_tagged( true );
223 if ( (gen%2) && _m.is_boundary(*eit) )
224 compute_new_boundary_points( _m, *eit ); // *) creates new vertices
225 }
226
227 // insert new vertices, and store pos in vp_pos_
228 typename MeshType::FaceIter fend = _m.faces_end();
229 for (fit = _m.faces_begin();fit != fend; ++fit)
230 {
231 if (_m.is_boundary(*fit))
232 {
233 if(gen%2)
234 _m.property(fp_pos_, *fit).invalidate();
235 else
236 {
237 //find the interior boundary halfedge
238 for( heh = _m.halfedge_handle(*fit); !_m.is_boundary( _m.opposite_halfedge_handle(heh) ); heh = _m.next_halfedge_handle(heh) )
239 ;
240 assert(_m.is_boundary( _m.opposite_halfedge_handle(heh) ));
241 pos = zero;
242 //check for two boundaries case:
243 if( _m.is_boundary(_m.next_halfedge_handle(heh)) || _m.is_boundary(_m.prev_halfedge_handle(heh)) )
244 {
245 if(_m.is_boundary(_m.prev_halfedge_handle(heh)))
246 heh = _m.prev_halfedge_handle(heh); //ensure that the boundary halfedges are heh and heh->next
247 //check for three boundaries case:
248 if(_m.is_boundary(_m.next_halfedge_handle(_m.next_halfedge_handle(heh))))
249 {
250 //three boundaries, use COG of triangle
251 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(heh));
252 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
253 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(_m.prev_halfedge_handle(heh)));
254 }
255 else
256 {
257#ifdef MIRROR_TRIANGLES
258 //two boundaries, mirror two triangles
259 pos += real_t(2.0/9) * _m.point(_m.to_vertex_handle(heh));
260 pos += real_t(4.0/9) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
261 pos += real_t(4.0/9) * _m.point(_m.to_vertex_handle(_m.prev_halfedge_handle(heh)));
262 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)))));
263#else
264 pos += real_t(7.0/24) * _m.point(_m.to_vertex_handle(heh));
265 pos += real_t(3.0/8) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
266 pos += real_t(3.0/8) * _m.point(_m.to_vertex_handle(_m.prev_halfedge_handle(heh)));
267 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)))));
268#endif
269 }
270 }
271 else
272 {
273 vh = _m.to_vertex_handle(_m.next_halfedge_handle(heh));
274 //check last vertex regularity
275 if((_m.valence(vh) == 6) || _m.is_boundary(vh))
276 {
277#ifdef MIRROR_TRIANGLES
278 //use regular rule and mirror one triangle
279 pos += real_t(5.0/9) * _m.point(vh);
280 pos += real_t(3.0/9) * _m.point(_m.to_vertex_handle(heh));
281 pos += real_t(3.0/9) * _m.point(_m.to_vertex_handle(_m.opposite_halfedge_handle(heh)));
282 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)))));
283 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)))));
284#else
285#ifdef MIN_NORM
286 pos += real_t(1.0/9) * _m.point(vh);
287 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(heh));
288 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(_m.opposite_halfedge_handle(heh)));
289 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)))));
290 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)))));
291#else
292 pos += real_t(1.0/2) * _m.point(vh);
293 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(heh));
294 pos += real_t(1.0/3) * _m.point(_m.to_vertex_handle(_m.opposite_halfedge_handle(heh)));
295 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)))));
296 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)))));
297#endif
298#endif
299 }
300 else
301 {
302 //irregular setting, use usual irregular rule
303 unsigned int K = _m.valence(vh);
304 pos += weights_[K][K]*_m.point(vh);
305 heh = _m.opposite_halfedge_handle( _m.next_halfedge_handle(heh) );
306 for(unsigned int i = 0; i<K; ++i, heh = _m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh)) )
307 {
308 pos += weights_[K][i]*_m.point(_m.to_vertex_handle(heh));
309 }
310 }
311 }
312 vh = _m.add_vertex( pos );
313 _m.property(fp_pos_, *fit) = vh;
314 }
315 }
316 else
317 {
318 pos = zero;
319 int nOrdinary = 0;
320
321 //check number of extraordinary vertices
322 for(fvit = _m.fv_iter( *fit ); fvit.is_valid(); ++fvit)
323 if( (_m.valence(*fvit)) == 6 || _m.is_boundary(*fvit) )
324 ++nOrdinary;
325
326 if(nOrdinary==3)
327 {
328 for(fheit = _m.fh_iter( *fit ); fheit.is_valid(); ++fheit)
329 {
330 //one ring vertex has weight 32/81
331 heh = *fheit;
332 assert(_m.to_vertex_handle(heh).is_valid());
333 pos += real_t(32.0/81) * _m.point(_m.to_vertex_handle(heh));
334 //tip vertex has weight -1/81
335 heh = _m.opposite_halfedge_handle(heh);
336 assert(heh.is_valid());
337 assert(_m.next_halfedge_handle(heh).is_valid());
338 assert(_m.to_vertex_handle(_m.next_halfedge_handle(heh)).is_valid());
339 pos -= real_t(1.0/81) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
340 //outer vertices have weight -2/81
341 heh = _m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh));
342 assert(heh.is_valid());
343 assert(_m.next_halfedge_handle(heh).is_valid());
344 assert(_m.to_vertex_handle(_m.next_halfedge_handle(heh)).is_valid());
345 pos -= real_t(2.0/81) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
346 heh = _m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh));
347 assert(heh.is_valid());
348 assert(_m.next_halfedge_handle(heh).is_valid());
349 assert(_m.to_vertex_handle(_m.next_halfedge_handle(heh)).is_valid());
350 pos -= real_t(2.0/81) * _m.point(_m.to_vertex_handle(_m.next_halfedge_handle(heh)));
351 }
352 }
353 else
354 {
355 //only use irregular vertices:
356 for(fheit = _m.fh_iter( *fit ); fheit.is_valid(); ++fheit)
357 {
358 vh = _m.to_vertex_handle(*fheit);
359 if( (_m.valence(vh) != 6) && (!_m.is_boundary(vh)) )
360 {
361 unsigned int K = _m.valence(vh);
362 pos += weights_[K][K]*_m.point(vh);
363 heh = _m.opposite_halfedge_handle( *fheit );
364 for(unsigned int i = 0; i<K; ++i, heh = _m.opposite_halfedge_handle(_m.prev_halfedge_handle(heh)) )
365 {
366 pos += weights_[K][i]*_m.point(_m.to_vertex_handle(heh));
367 }
368 }
369 }
370 pos *= real_t(1.0/(3-nOrdinary));
371 }
372
373 vh = _m.add_vertex( pos );
374 _m.property(fp_pos_, *fit) = vh;
375 }
376 }
377
378 //split faces
379 for (fit = _m.faces_begin();fit != fend; ++fit)
380 {
381 if ( _m.is_boundary(*fit) && (gen%2))
382 {
383 boundary_split( _m, *fit );
384 }
385 else
386 {
387 assert(_m.property(fp_pos_, *fit).is_valid());
388 _m.split( *fit, _m.property(fp_pos_, *fit) );
389 }
390 }
391
392 // flip old edges
393 for (eit=_m.edges_begin(); eit != _m.edges_end(); ++eit)
394 if ( _m.status( *eit ).tagged() && !_m.is_boundary( *eit ) )
395 _m.flip(*eit);
396
397 // Now we have an consistent mesh!
398 ASSERT_CONSISTENCY( MeshType, _m );
399
400 // increase generation by one
401 ++gen;
402 }
403 return true;
404 }
405
406private:
407
408 // Pre-compute location of new boundary points for odd generations
409 // and store them in the edge property ep_nv_;
410 void compute_new_boundary_points( MeshType& _m,
411 const typename MeshType::EdgeHandle& _eh)
412 {
413 assert( _m.is_boundary(_eh) );
414
415 typename MeshType::HalfedgeHandle heh;
416 typename MeshType::VertexHandle vh1, vh2, vh3, vh4, vhl, vhr;
417 typename MeshType::Point zero(0,0,0), P1, P2, P3, P4;
418
419 /*
420 // *---------*---------*
421 // / \ / \ / \
422 // / \ / \ / \
423 // / \ / \ / \
424 // / \ / \ / \
425 // *---------*--#---#--*---------*
426 //
427 // ^ ^ ^ ^ ^ ^
428 // P1 P2 pl pr P3 P4
429 */
430 // get halfedge pointing from P3 to P2 (outer boundary halfedge)
431
432 heh = _m.halfedge_handle(_eh,
433 _m.is_boundary(_m.halfedge_handle(_eh,1)));
434
435 assert( _m.is_boundary( _m.next_halfedge_handle( heh ) ) );
436 assert( _m.is_boundary( _m.prev_halfedge_handle( heh ) ) );
437
438 vh1 = _m.to_vertex_handle( _m.next_halfedge_handle( heh ) );
439 vh2 = _m.to_vertex_handle( heh );
440 vh3 = _m.from_vertex_handle( heh );
441 vh4 = _m.from_vertex_handle( _m.prev_halfedge_handle( heh ));
442
443 P1 = _m.point(vh1);
444 P2 = _m.point(vh2);
445 P3 = _m.point(vh3);
446 P4 = _m.point(vh4);
447
448 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);
449 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);
450
451 _m.property(ep_nv_, _eh).first = vhl;
452 _m.property(ep_nv_, _eh).second = vhr;
453 }
454
455
456 void boundary_split( MeshType& _m, const typename MeshType::FaceHandle& _fh )
457 {
458 assert( _m.is_boundary(_fh) );
459
460 typename MeshType::VertexHandle vhl, vhr;
461 typename MeshType::FaceEdgeIter fe_it;
462 typename MeshType::HalfedgeHandle heh;
463
464 // find boundary edge
465 for( fe_it=_m.fe_iter( _fh ); fe_it.is_valid() && !_m.is_boundary( *fe_it ); ++fe_it ) {};
466
467 // use precomputed, already inserted but not linked vertices
468 vhl = _m.property(ep_nv_, *fe_it).first;
469 vhr = _m.property(ep_nv_, *fe_it).second;
470
471 /*
472 // *---------*---------*
473 // / \ / \ / \
474 // / \ / \ / \
475 // / \ / \ / \
476 // / \ / \ / \
477 // *---------*--#---#--*---------*
478 //
479 // ^ ^ ^ ^ ^ ^
480 // P1 P2 pl pr P3 P4
481 */
482 // get halfedge pointing from P2 to P3 (inner boundary halfedge)
483
484 heh = _m.halfedge_handle(*fe_it, _m.is_boundary(_m.halfedge_handle(*fe_it,0)));
485
486 typename MeshType::HalfedgeHandle pl_P3;
487
488 // split P2->P3 (heh) in P2->pl (heh) and pl->P3
489 boundary_split( _m, heh, vhl ); // split edge
490 pl_P3 = _m.next_halfedge_handle( heh ); // store next halfedge handle
491 boundary_split( _m, heh ); // split face
492
493 // split pl->P3 in pl->pr and pr->P3
494 boundary_split( _m, pl_P3, vhr );
495 boundary_split( _m, pl_P3 );
496
497 assert( _m.is_boundary( vhl ) && _m.halfedge_handle(vhl).is_valid() );
498 assert( _m.is_boundary( vhr ) && _m.halfedge_handle(vhr).is_valid() );
499 }
500
501 void boundary_split(MeshType& _m,
502 const typename MeshType::HalfedgeHandle& _heh,
503 const typename MeshType::VertexHandle& _vh)
504 {
505 assert( _m.is_boundary( _m.edge_handle(_heh) ) );
506
507 typename MeshType::HalfedgeHandle
508 heh(_heh),
509 opp_heh( _m.opposite_halfedge_handle(_heh) ),
510 new_heh, opp_new_heh;
511 typename MeshType::VertexHandle to_vh(_m.to_vertex_handle(heh));
512 typename MeshType::HalfedgeHandle t_heh;
513
514 /*
515 * P5
516 * *
517 * /|\
518 * / \
519 * / \
520 * / \
521 * / \
522 * /_ heh new \
523 * *-----\*-----\*\-----*
524 * ^ ^ t_heh
525 * _vh to_vh
526 *
527 * P1 P2 P3 P4
528 */
529 // Re-Setting Handles
530
531 // find halfedge point from P4 to P3
532 for(t_heh = heh;
533 _m.next_halfedge_handle(t_heh) != opp_heh;
534 t_heh = _m.opposite_halfedge_handle(_m.next_halfedge_handle(t_heh)))
535 {}
536
537 assert( _m.is_boundary( t_heh ) );
538
539 new_heh = _m.new_edge( _vh, to_vh );
540 opp_new_heh = _m.opposite_halfedge_handle(new_heh);
541
542 // update halfedge connectivity
543 _m.set_next_halfedge_handle(t_heh, opp_new_heh); // P4-P3 -> P3-P2
544 _m.set_next_halfedge_handle(new_heh, _m.next_halfedge_handle(heh)); // P2-P3 -> P3-P5
545 _m.set_next_halfedge_handle(heh, new_heh); // P1-P2 -> P2-P3
546 _m.set_next_halfedge_handle(opp_new_heh, opp_heh); // P3-P2 -> P2-P1
547
548 // both opposite halfedges point to same face
549 _m.set_face_handle(opp_new_heh, _m.face_handle(opp_heh));
550
551 // let heh finally point to new inserted vertex
552 _m.set_vertex_handle(heh, _vh);
553
554 // let heh and new_heh point to same face
555 _m.set_face_handle(new_heh, _m.face_handle(heh));
556
557 // let opp_new_heh be the new outgoing halfedge for to_vh
558 // (replaces for opp_heh)
559 _m.set_halfedge_handle( to_vh, opp_new_heh );
560
561 // let opp_heh be the outgoing halfedge for _vh
562 _m.set_halfedge_handle( _vh, opp_heh );
563 }
564
565 void boundary_split( MeshType& _m,
566 const typename MeshType::HalfedgeHandle& _heh)
567 {
568 assert( _m.is_boundary( _m.opposite_halfedge_handle( _heh ) ) );
569
570 typename MeshType::HalfedgeHandle
571 heh(_heh),
572 n_heh(_m.next_halfedge_handle(heh));
573
574 typename MeshType::VertexHandle
575 to_vh(_m.to_vertex_handle(heh));
576
577 typename MeshType::HalfedgeHandle
578 heh2(_m.new_edge(to_vh,
579 _m.to_vertex_handle(_m.next_halfedge_handle(n_heh)))),
580 heh3(_m.opposite_halfedge_handle(heh2));
581
582 typename MeshType::FaceHandle
583 new_fh(_m.new_face()),
584 fh(_m.face_handle(heh));
585
586 // Relink (half)edges
587 _m.set_face_handle(heh, new_fh);
588 _m.set_face_handle(heh2, new_fh);
589 _m.set_next_halfedge_handle(heh2, _m.next_halfedge_handle(_m.next_halfedge_handle(n_heh)));
590 _m.set_next_halfedge_handle(heh, heh2);
591 _m.set_face_handle( _m.next_halfedge_handle(heh2), new_fh);
592
593 _m.set_next_halfedge_handle(heh3, n_heh);
594 _m.set_next_halfedge_handle(_m.next_halfedge_handle(n_heh), heh3);
595 _m.set_face_handle(heh3, fh);
596
597 _m.set_halfedge_handle( fh, n_heh);
598 _m.set_halfedge_handle(new_fh, heh);
599
600
601 }
602
603private:
604
605 weights_t weights_;
607 OpenMesh::EPropHandleT< std::pair< typename MeshType::VertexHandle,
608 typename MeshType::VertexHandle> > ep_nv_;
610};
611
612
613//=============================================================================
614} // END_NS_UNIFORM
615} // END_NS_SUBDIVIDER
616} // END_NS_OPENMESH
617//=============================================================================
618#endif // OPENMESH_SUBDIVIDER_UNIFORM_SQRT3T_HH
619//=============================================================================
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:64
bool is_valid() const
The handle is valid iff the index is not equal to -1.
Definition Handles.hh:77
Handle representing an edge property.
Definition Property.hh:516
Uniform Interpolating Sqrt3 subdivision algorithm
Definition Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:114
bool subdivide(MeshType &_m, size_t _n, const bool _update_points=true)
Subdivide mesh _m _n times.
Definition Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:201
bool prepare(MeshType &_m)
Prepare mesh, e.g. add properties.
Definition Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:178
bool cleanup(MeshType &_m)
Cleanup mesh after usage, e.g. remove added properties.
Definition Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:191
const char * name() const
Return name of subdivision algorithm.
Definition Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:138
void init_weights(size_t _max_valence=50)
Pre-compute weights.
Definition Sqrt3InterpolatingSubdividerLabsikGreinerT.hh:141
Abstract base class for uniform subdivision algorithms.
Definition SubdividerT.hh:95

Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .