60 #define OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_CC 66 #include <OpenMesh/Core/IO/MeshIO.hh> 69 #if defined(OM_CC_MIPS) 75 #if defined(OM_CC_MSVC) 76 # pragma warning(disable:4244) 82 namespace Subdivider {
88 #define MOBJ Base::mesh_.data 89 #define FH face_handle 90 #define VH vertex_handle 91 #define EH edge_handle 92 #define HEH halfedge_handle 93 #define NHEH next_halfedge_handle 94 #define PHEH prev_halfedge_handle 95 #define OHEH opposite_halfedge_handle 96 #define TVH to_vertex_handle 97 #define FVH from_vertex_handle 106 if (MOBJ(_fh).state() < _target_state)
108 this->update(_fh, _target_state);
110 typename M::VertexVertexIter vv_it;
111 typename M::FaceVertexIter fv_it;
112 typename M::VertexHandle vh;
113 typename M::Point position(0.0, 0.0, 0.0);
114 typename M::Point face_position;
115 const typename M::Point zero_point(0.0, 0.0, 0.0);
116 std::vector<typename M::VertexHandle> vertex_vector;
120 for (fv_it = Base::mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) {
122 vertex_vector.push_back(*fv_it);
125 while(!vertex_vector.empty()) {
127 vh = vertex_vector.back();
128 vertex_vector.pop_back();
130 if (_target_state > 1)
131 Base::prev_rule()->raise(vh, _target_state - 1);
134 face_position = MOBJ(_fh).position(_target_state - 1);
136 typename M::EdgeHandle eh;
137 std::vector<typename M::EdgeHandle> edge_vector;
140 if (!Base::mesh_.is_boundary(_fh) || MOBJ(_fh).
final()) {
143 vh = Base::mesh_.new_vertex();
145 Base::mesh_.split(_fh, vh);
147 typename M::Scalar valence(0.0);
150 for (vv_it = Base::mesh_.vv_iter(vh); vv_it.is_valid(); ++vv_it)
152 position += Base::mesh_.point(*vv_it);
159 Base::mesh_.set_point(vh, position);
160 MOBJ(vh).set_position(_target_state, zero_point);
161 MOBJ(vh).set_state(_target_state);
162 MOBJ(vh).set_not_final();
164 typename M::VertexOHalfedgeIter voh_it;
166 for (voh_it = Base::mesh_.voh_iter(vh); voh_it.is_valid(); ++voh_it) {
168 if (Base::mesh_.FH(*voh_it).is_valid()) {
170 MOBJ(Base::mesh_.FH(*voh_it)).set_state(_target_state);
171 MOBJ(Base::mesh_.FH(*voh_it)).set_not_final();
172 MOBJ(Base::mesh_.FH(*voh_it)).set_position(_target_state - 1, face_position);
175 for (
state_t j = 0; j < _target_state; ++j) {
176 MOBJ(Base::mesh_.FH(*voh_it)).set_position(j, MOBJ(_fh).position(j));
179 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
181 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it)))).state() == _target_state) {
183 if (Base::mesh_.is_flip_ok(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it)))) {
185 edge_vector.push_back(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it)));
196 typename M::VertexHandle vh1 = Base::mesh_.new_vertex(),
197 vh2 = Base::mesh_.new_vertex();
199 typename M::HalfedgeHandle hh2 = Base::mesh_.HEH(_fh),
202 while (!Base::mesh_.is_boundary(Base::mesh_.OHEH(hh2)))
203 hh2 = Base::mesh_.NHEH(hh2);
205 eh = Base::mesh_.EH(hh2);
207 hh2 = Base::mesh_.NHEH(hh2);
208 hh1 = Base::mesh_.NHEH(hh2);
210 assert(Base::mesh_.is_boundary(eh));
212 Base::mesh_.split(eh, vh1);
214 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh2));
216 assert(Base::mesh_.is_boundary(eh));
218 Base::mesh_.split(eh, vh2);
220 hh3 = Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(hh1)));
222 typename M::VertexHandle vh0(Base::mesh_.TVH(hh1)),
223 vh3(Base::mesh_.FVH(hh2));
226 Base::mesh_.set_point(vh1, (Base::mesh_.point(vh0) * 2.0 + Base::mesh_.point(vh3)) / 3.0);
228 MOBJ(vh1).set_position(_target_state, zero_point);
229 MOBJ(vh1).set_state(_target_state);
230 MOBJ(vh1).set_not_final();
232 MOBJ(vh0).set_position(_target_state, MOBJ(vh0).position(_target_state - 1) * 3.0);
233 MOBJ(vh0).set_state(_target_state);
234 MOBJ(vh0).set_not_final();
237 Base::mesh_.set_point(vh2, (Base::mesh_.point(vh3) * 2.0 + Base::mesh_.point(vh0)) / 3.0);
238 MOBJ(vh2).set_position(_target_state, zero_point);
239 MOBJ(vh2).set_state(_target_state);
240 MOBJ(vh2).set_not_final();
242 MOBJ(vh3).set_position(_target_state, MOBJ(vh3).position(_target_state - 1) * 3.0);
243 MOBJ(vh3).set_state(_target_state);
244 MOBJ(vh3).set_not_final();
247 MOBJ(Base::mesh_.FH(hh1)).set_state(_target_state);
248 MOBJ(Base::mesh_.FH(hh1)).set_not_final();
249 MOBJ(Base::mesh_.FH(hh1)).set_position(_target_state - 1, face_position);
251 MOBJ(Base::mesh_.FH(hh2)).set_state(_target_state);
252 MOBJ(Base::mesh_.FH(hh2)).set_not_final();
253 MOBJ(Base::mesh_.FH(hh2)).set_position(_target_state - 1, face_position);
255 MOBJ(Base::mesh_.FH(hh3)).set_state(_target_state);
256 MOBJ(Base::mesh_.FH(hh3)).set_final();
257 MOBJ(Base::mesh_.FH(hh3)).set_position(_target_state - 1, face_position);
260 for (
state_t j = 0; j < _target_state; ++j) {
261 MOBJ(Base::mesh_.FH(hh1)).set_position(j, MOBJ(_fh).position(j));
264 for (
state_t j = 0; j < _target_state; ++j) {
266 MOBJ(Base::mesh_.FH(hh2)).set_position(j, MOBJ(_fh).position(j));
269 for (
state_t j = 0; j < _target_state; ++j) {
271 MOBJ(Base::mesh_.FH(hh3)).set_position(j, MOBJ(_fh).position(j));
275 if (Base::mesh_.FH(Base::mesh_.OHEH(hh1)).is_valid()) {
277 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(hh1))).state() == _target_state) {
279 if (Base::mesh_.is_flip_ok(Base::mesh_.EH(hh1))) {
281 edge_vector.push_back(Base::mesh_.EH(hh1));
286 if (Base::mesh_.FH(Base::mesh_.OHEH(hh2)).is_valid()) {
288 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(hh2))).state() == _target_state) {
290 if (Base::mesh_.is_flip_ok(Base::mesh_.EH(hh2))) {
292 edge_vector.push_back(Base::mesh_.EH(hh2));
299 while (!edge_vector.empty()) {
301 eh = edge_vector.back();
302 edge_vector.pop_back();
304 assert(Base::mesh_.is_flip_ok(eh));
306 Base::mesh_.flip(eh);
308 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 0))).set_final();
309 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 1))).set_final();
311 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 0))).set_state(_target_state);
312 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 1))).set_state(_target_state);
314 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 0))).set_position(_target_state, face_position);
315 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 1))).set_position(_target_state, face_position);
324 if (MOBJ(_vh).state() < _target_state) {
326 this->update(_vh, _target_state);
329 MOBJ(_vh).set_position(_target_state, MOBJ(_vh).position(_target_state - 1) * 3.0);
331 MOBJ(_vh).inc_state();
333 assert(MOBJ(_vh).state() == _target_state);
346 if (MOBJ(_fh).state() < _target_state) {
348 this->update(_fh, _target_state);
350 typename M::FaceVertexIter fv_it;
351 typename M::VertexHandle temp_vh;
352 typename M::Point face_position;
353 const typename M::Point zero_point(0.0, 0.0, 0.0);
354 std::vector<typename M::VertexHandle> vertex_vector;
355 std::vector<typename M::HalfedgeHandle> halfedge_vector;
358 for (fv_it = Base::mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) {
360 vertex_vector.push_back(*fv_it);
363 while(!vertex_vector.empty()) {
365 temp_vh = vertex_vector.back();
366 vertex_vector.pop_back();
368 if (_target_state > 1) {
369 Base::prev_rule()->raise(temp_vh, _target_state - 1);
373 face_position = MOBJ(_fh).position(_target_state - 1);
375 typename M::HalfedgeHandle hh[3];
376 typename M::VertexHandle vh[3];
377 typename M::VertexHandle new_vh[3];
378 typename M::FaceHandle fh[4];
379 typename M::EdgeHandle eh;
380 typename M::HalfedgeHandle temp_hh;
383 if (MOBJ(_fh).
final()) {
386 hh[0] = Base::mesh_.HEH(_fh);
387 hh[1] = Base::mesh_.NHEH(hh[0]);
388 hh[2] = Base::mesh_.NHEH(hh[1]);
390 assert(hh[0] == Base::mesh_.NHEH(hh[2]));
392 vh[0] = Base::mesh_.TVH(hh[0]);
393 vh[1] = Base::mesh_.TVH(hh[1]);
394 vh[2] = Base::mesh_.TVH(hh[2]);
396 new_vh[0] = Base::mesh_.add_vertex(zero_point);
397 new_vh[1] = Base::mesh_.add_vertex(zero_point);
398 new_vh[2] = Base::mesh_.add_vertex(zero_point);
401 split_edge(hh[0], new_vh[0], _target_state);
402 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh[2]));
403 split_edge(hh[1], new_vh[1], _target_state);
404 split_edge(hh[2], new_vh[2], _target_state);
406 assert(Base::mesh_.FVH(hh[2]) == vh[1]);
407 assert(Base::mesh_.FVH(hh[1]) == vh[0]);
408 assert(Base::mesh_.FVH(hh[0]) == vh[2]);
410 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[0])).is_valid())
412 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[0])));
413 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
414 halfedge_vector.push_back(temp_hh);
417 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[1])).is_valid()) {
419 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[1])));
420 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
421 halfedge_vector.push_back(temp_hh);
424 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[2])).is_valid()) {
426 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[2])));
427 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
428 halfedge_vector.push_back(temp_hh);
436 typename M::HalfedgeHandle red_hh(MOBJ(_fh).red_halfedge());
438 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh))).is_valid()
439 && Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)))).is_valid()
440 && MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)))).red_halfedge() == red_hh
441 && MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh))))).red_halfedge() == red_hh)
445 vh[0] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)))));
446 vh[1] = Base::mesh_.TVH(red_hh);
447 vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh))));
449 new_vh[0] = Base::mesh_.FVH(red_hh);
450 new_vh[1] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)));
451 new_vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(red_hh));
453 hh[0] = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)));
454 hh[1] = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh))));
455 hh[2] = Base::mesh_.NHEH(red_hh);
457 eh = Base::mesh_.EH(red_hh);
463 if ((Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh))).is_valid() &&
464 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)))).red_halfedge()
466 || (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)))).is_valid()
467 && MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh))))).red_halfedge() == red_hh))
471 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)))).red_halfedge() == red_hh)
474 vh[0] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)));
475 vh[1] = Base::mesh_.TVH(red_hh);
476 vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh))));
478 new_vh[0] = Base::mesh_.FVH(red_hh);
479 new_vh[1] = Base::mesh_.add_vertex(zero_point);
480 new_vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(red_hh));
482 hh[0] = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)));
483 hh[1] = Base::mesh_.PHEH(Base::mesh_.OHEH(red_hh));
484 hh[2] = Base::mesh_.NHEH(red_hh);
487 eh = Base::mesh_.EH(red_hh);
489 split_edge(hh[1], new_vh[1], _target_state);
491 assert(Base::mesh_.FVH(hh[2]) == vh[1]);
492 assert(Base::mesh_.FVH(hh[1]) == vh[0]);
493 assert(Base::mesh_.FVH(hh[0]) == vh[2]);
495 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[1])).is_valid())
497 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[1])));
498 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
499 halfedge_vector.push_back(temp_hh);
506 vh[0] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)))));
507 vh[1] = Base::mesh_.TVH(red_hh);
508 vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(red_hh));
510 new_vh[0] = Base::mesh_.FVH(red_hh);
511 new_vh[1] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)));
512 new_vh[2] = Base::mesh_.add_vertex(zero_point);
514 hh[0] = Base::mesh_.PHEH(red_hh);
515 hh[1] = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh))));
516 hh[2] = Base::mesh_.NHEH(red_hh);
519 eh = Base::mesh_.EH(red_hh);
521 split_edge(hh[2], new_vh[2], _target_state);
523 assert(Base::mesh_.FVH(hh[2]) == vh[1]);
524 assert(Base::mesh_.FVH(hh[1]) == vh[0]);
525 assert(Base::mesh_.FVH(hh[0]) == vh[2]);
527 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[2])).is_valid()) {
529 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[2])));
530 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
531 halfedge_vector.push_back(temp_hh);
539 vh[0] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)));
540 vh[1] = Base::mesh_.TVH(red_hh);
541 vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(red_hh));
543 new_vh[0] = Base::mesh_.FVH(red_hh);
544 new_vh[1] = Base::mesh_.add_vertex(zero_point);
545 new_vh[2] = Base::mesh_.add_vertex(zero_point);
547 hh[0] = Base::mesh_.PHEH(red_hh);
548 hh[1] = Base::mesh_.PHEH(Base::mesh_.OHEH(red_hh));
549 hh[2] = Base::mesh_.NHEH(red_hh);
552 eh = Base::mesh_.EH(red_hh);
554 split_edge(hh[1], new_vh[1], _target_state);
555 split_edge(hh[2], new_vh[2], _target_state);
557 assert(Base::mesh_.FVH(hh[2]) == vh[1]);
558 assert(Base::mesh_.FVH(hh[1]) == vh[0]);
559 assert(Base::mesh_.FVH(hh[0]) == vh[2]);
561 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[1])).is_valid()) {
563 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[1])));
564 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
565 halfedge_vector.push_back(temp_hh);
568 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[2])).is_valid()) {
570 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[2])));
571 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
572 halfedge_vector.push_back(temp_hh);
581 if (Base::mesh_.is_flip_ok(eh)) {
583 Base::mesh_.flip(eh);
587 fh[0] = Base::mesh_.FH(hh[0]);
588 fh[1] = Base::mesh_.FH(hh[1]);
589 fh[2] = Base::mesh_.FH(hh[2]);
590 fh[3] = Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(hh[0])));
592 assert(_fh == fh[0] || _fh == fh[1] || _fh == fh[2] || _fh == fh[3]);
595 for (
int i = 0; i <= 3; ++i) {
597 MOBJ(fh[i]).set_state(_target_state);
598 MOBJ(fh[i]).set_final();
599 MOBJ(fh[i]).set_position(_target_state, face_position);
600 MOBJ(fh[i]).set_red_halfedge(Base::mesh_.InvalidHalfedgeHandle);
604 for (
int i = 0; i <= 2; ++i) {
606 MOBJ(new_vh[i]).set_position(_target_state, zero_point);
607 MOBJ(new_vh[i]).set_state(_target_state);
608 MOBJ(new_vh[i]).set_not_final();
610 Base::mesh_.set_point(new_vh[i], (Base::mesh_.point(vh[i]) + Base::mesh_.point(vh[(i + 2) % 3])) * 0.5);
612 MOBJ(Base::mesh_.EH(hh[i])).set_state(_target_state);
613 MOBJ(Base::mesh_.EH(hh[i])).set_position(_target_state, zero_point);
614 MOBJ(Base::mesh_.EH(hh[i])).set_final();
616 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh[i]))).set_state(_target_state);
617 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh[i]))).set_position(_target_state, zero_point);
618 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh[i]))).set_final();
620 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh[i]))).set_state(_target_state);
621 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh[i]))).set_position(_target_state, zero_point);
622 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh[i]))).set_final();
626 while (!halfedge_vector.empty()) {
628 temp_hh = halfedge_vector.back();
629 halfedge_vector.pop_back();
631 check_edge(temp_hh, _target_state);
634 assert(MOBJ(fh[0]).state() == _target_state);
635 assert(MOBJ(fh[1]).state() == _target_state);
636 assert(MOBJ(fh[2]).state() == _target_state);
637 assert(MOBJ(fh[3]).state() == _target_state);
647 if (MOBJ(_vh).state() < _target_state)
650 this->update(_vh, _target_state);
653 MOBJ(_vh).set_position(_target_state, MOBJ(_vh).position(_target_state - 1) * 4.0);
655 MOBJ(_vh).inc_state();
664 if (MOBJ(_eh).state() < _target_state)
666 this->update(_eh, _target_state);
668 typename M::FaceHandle fh(Base::mesh_.FH(Base::mesh_.HEH(_eh, 0)));
671 fh=Base::mesh_.FH(Base::mesh_.HEH(_eh, 1));
673 raise(fh, _target_state);
675 assert(MOBJ(_eh).state() == _target_state);
679 #ifndef DOXY_IGNORE_THIS 684 typename M::VertexHandle &_vh,
687 typename M::HalfedgeHandle temp_hh;
689 if (Base::mesh_.FH(Base::mesh_.OHEH(_hh)).is_valid())
691 if (!MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).
final())
693 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).red_halfedge().is_valid())
695 temp_hh = MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).red_halfedge();
700 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh))))).state()
701 == MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).state())
703 temp_hh = Base::mesh_.PHEH(Base::mesh_.OHEH(_hh));
706 else if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(_hh))))).state()
707 == MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).state())
709 temp_hh = Base::mesh_.NHEH(Base::mesh_.OHEH(_hh));
714 temp_hh = Base::mesh_.InvalidHalfedgeHandle;
717 temp_hh = Base::mesh_.InvalidHalfedgeHandle;
720 Base::mesh_.split(Base::mesh_.EH(_hh), _vh);
722 if (Base::mesh_.FVH(_hh) == _vh)
724 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(_hh))))).set_state(MOBJ(Base::mesh_.EH(_hh)).state());
725 _hh = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(_hh)));
728 if (Base::mesh_.FH(Base::mesh_.OHEH(_hh)).is_valid()) {
730 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh)))).set_not_final();
731 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).set_state(_target_state-1);
732 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh)))))).set_state(_target_state-1);
734 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).set_not_final();
735 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh)))))).set_not_final();
737 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh)))).set_state(_target_state);
739 if (temp_hh.is_valid()) {
741 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).set_red_halfedge(temp_hh);
742 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh)))))).set_red_halfedge(temp_hh);
746 typename M::FaceHandle
747 fh1(Base::mesh_.FH(Base::mesh_.OHEH(_hh))),
748 fh2(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh))))));
750 MOBJ(fh1).set_red_halfedge(Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh))));
751 MOBJ(fh2).set_red_halfedge(Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh))));
753 const typename M::Point zero_point(0.0, 0.0, 0.0);
755 MOBJ(fh1).set_position(_target_state - 1, zero_point);
756 MOBJ(fh2).set_position(_target_state - 1, zero_point);
761 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh))))).set_state(_target_state - 1);
762 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh))))).set_final();
764 MOBJ(Base::mesh_.EH(_hh)).set_state(_target_state - 1);
765 MOBJ(Base::mesh_.EH(_hh)).set_final();
773 typename M::FaceHandle fh1(Base::mesh_.FH(_hh)),
774 fh2(Base::mesh_.FH(Base::mesh_.OHEH(_hh)));
776 assert(fh1.is_valid());
777 assert(fh2.is_valid());
779 typename M::HalfedgeHandle red_hh(MOBJ(fh1).red_halfedge());
781 if (!MOBJ(fh1).
final()) {
783 assert (MOBJ(fh1).
final() == MOBJ(fh2).
final());
784 assert (!MOBJ(fh1).
final());
785 assert (MOBJ(fh1).red_halfedge() == MOBJ(fh2).red_halfedge());
787 const typename M::Point zero_point(0.0, 0.0, 0.0);
789 MOBJ(fh1).set_position(_target_state - 1, zero_point);
790 MOBJ(fh2).set_position(_target_state - 1, zero_point);
792 assert(red_hh.is_valid());
794 if (!red_hh.is_valid()) {
796 MOBJ(fh1).set_state(_target_state - 1);
797 MOBJ(fh2).set_state(_target_state - 1);
799 MOBJ(fh1).set_red_halfedge(_hh);
800 MOBJ(fh2).set_red_halfedge(_hh);
802 MOBJ(Base::mesh_.EH(_hh)).set_not_final();
803 MOBJ(Base::mesh_.EH(_hh)).set_state(_target_state - 1);
808 MOBJ(Base::mesh_.EH(_hh)).set_not_final();
809 MOBJ(Base::mesh_.EH(_hh)).set_state(_target_state - 1);
811 raise(fh1, _target_state);
813 assert(MOBJ(fh1).state() == _target_state);
825 if (MOBJ(_fh).state() < _target_state) {
827 this->update(_fh, _target_state);
830 typename M::FaceVertexIter fv_it;
831 typename M::VertexHandle vh;
832 std::vector<typename M::VertexHandle> vertex_vector;
834 if (_target_state > 1) {
836 for (fv_it = Base::mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) {
838 vertex_vector.push_back(*fv_it);
841 while (!vertex_vector.empty()) {
843 vh = vertex_vector.back();
844 vertex_vector.pop_back();
846 Base::prev_rule()->raise(vh, _target_state - 1);
851 typename M::Point position(0.0, 0.0, 0.0);
852 typename M::Scalar valence(0.0);
854 for (fv_it = Base::mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) {
857 position += Base::mesh_.data(*fv_it).position(_target_state - 1);
863 if (Base::number() == Base::subdiv_rule()->number() + 1 &&
864 Base::mesh_.is_boundary(_fh) &&
868 MOBJ(_fh).set_position(_target_state, position);
869 MOBJ(_fh).inc_state();
871 assert(_target_state == MOBJ(_fh).state());
882 if (MOBJ(_fh).state() < _target_state) {
884 this->update(_fh, _target_state);
887 typename M::FaceFaceIter ff_it;
888 typename M::FaceHandle fh;
889 std::vector<typename M::FaceHandle> face_vector;
891 if (_target_state > 1) {
893 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it) {
895 face_vector.push_back(*ff_it);
898 while (!face_vector.empty()) {
900 fh = face_vector.back();
901 face_vector.pop_back();
903 Base::prev_rule()->raise(fh, _target_state - 1);
906 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it) {
908 face_vector.push_back(*ff_it);
911 while (!face_vector.empty()) {
913 fh = face_vector.back();
914 face_vector.pop_back();
916 while (MOBJ(fh).state() < _target_state - 1)
917 Base::prev_rule()->raise(fh, _target_state - 1);
922 typename M::Point position(0.0, 0.0, 0.0);
923 typename M::Scalar valence(0.0);
925 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it) {
929 position += Base::mesh_.data(*ff_it).position(_target_state - 1);
934 MOBJ(_fh).set_position(_target_state, position);
935 MOBJ(_fh).inc_state();
946 if (MOBJ(_fh).state() < _target_state) {
948 this->update(_fh, _target_state);
951 typename M::FaceFaceIter ff_it(Base::mesh_.ff_iter(_fh));
952 typename M::FaceHandle fh;
953 std::vector<typename M::FaceHandle> face_vector;
955 if (_target_state > 1)
957 for (; ff_it.is_valid(); ++ff_it)
958 face_vector.push_back(*ff_it);
960 while (!face_vector.empty())
962 fh = face_vector.back();
963 face_vector.pop_back();
964 Base::prev_rule()->raise(fh, _target_state - 1);
967 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it)
968 face_vector.push_back(*ff_it);
970 while (!face_vector.empty()) {
972 fh = face_vector.back();
973 face_vector.pop_back();
975 while (MOBJ(fh).state() < _target_state - 1)
976 Base::prev_rule()->raise(fh, _target_state - 1);
981 typename M::Point position(0.0, 0.0, 0.0);
982 typename M::Scalar valence(0.0);
984 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it)
987 position += Base::mesh_.data(*ff_it).position(_target_state - 1);
993 typename M::Scalar c = Base::coeff();
995 position *= (1.0 - c);
996 position += MOBJ(_fh).position(_target_state - 1) * c;
998 MOBJ(_fh).set_position(_target_state, position);
999 MOBJ(_fh).inc_state();
1011 if (MOBJ(_vh).state() < _target_state) {
1013 this->update(_vh, _target_state);
1016 typename M::VertexFaceIter vf_it(Base::mesh_.vf_iter(_vh));
1017 typename M::FaceHandle fh;
1018 std::vector<typename M::FaceHandle> face_vector;
1020 if (_target_state > 1) {
1022 for (; vf_it.is_valid(); ++vf_it) {
1024 face_vector.push_back(*vf_it);
1027 while (!face_vector.empty()) {
1029 fh = face_vector.back();
1030 face_vector.pop_back();
1032 Base::prev_rule()->raise(fh, _target_state - 1);
1035 for (vf_it = Base::mesh_.vf_iter(_vh); vf_it.is_valid(); ++vf_it) {
1037 face_vector.push_back(*vf_it);
1040 while (!face_vector.empty()) {
1042 fh = face_vector.back();
1043 face_vector.pop_back();
1045 while (MOBJ(fh).state() < _target_state - 1)
1046 Base::prev_rule()->raise(fh, _target_state - 1);
1051 typename M::Point position(0.0, 0.0, 0.0);
1052 typename M::Scalar valence(0.0);
1054 for (vf_it = Base::mesh_.vf_iter(_vh); vf_it.is_valid(); ++vf_it) {
1057 position += Base::mesh_.data(*vf_it).position(_target_state - 1);
1060 position /= valence;
1062 MOBJ(_vh).set_position(_target_state, position);
1063 MOBJ(_vh).inc_state();
1065 if (Base::number() == Base::n_rules() - 1) {
1067 Base::mesh_.set_point(_vh, position);
1068 MOBJ(_vh).set_final();
1080 if (MOBJ(_vh).state() < _target_state) {
1082 this->update(_vh, _target_state);
1084 typename M::VertexOHalfedgeIter voh_it;
1085 typename M::FaceHandle fh;
1086 std::vector<typename M::FaceHandle> face_vector;
1089 face_vector.clear();
1092 if (_target_state > 1) {
1094 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1096 if (Base::mesh_.FH(*voh_it).is_valid()) {
1098 face_vector.push_back(Base::mesh_.FH(*voh_it));
1100 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
1102 face_vector.push_back(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))));
1107 while (!face_vector.empty()) {
1109 fh = face_vector.back();
1110 face_vector.pop_back();
1112 Base::prev_rule()->raise(fh, _target_state - 1);
1115 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1117 if (Base::mesh_.FH(*voh_it).is_valid()) {
1119 face_vector.push_back(Base::mesh_.FH(*voh_it));
1121 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
1123 face_vector.push_back(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))));
1128 while (!face_vector.empty()) {
1130 fh = face_vector.back();
1131 face_vector.pop_back();
1133 while (MOBJ(fh).state() < _target_state - 1)
1134 Base::prev_rule()->raise(fh, _target_state - 1);
1137 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1139 if (Base::mesh_.FH(*voh_it).is_valid()) {
1141 face_vector.push_back(Base::mesh_.FH(*voh_it));
1143 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
1145 face_vector.push_back(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))));
1150 while (!face_vector.empty()) {
1152 fh = face_vector.back();
1153 face_vector.pop_back();
1155 while (MOBJ(fh).state() < _target_state - 1)
1156 Base::prev_rule()->raise(fh, _target_state - 1);
1161 typename M::Point position(0.0, 0.0, 0.0);
1162 typename M::Scalar c;
1164 const typename M::Scalar _2pi(2.0*M_PI);
1165 const typename M::Scalar _2over3(2.0/3.0);
1167 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it; ++voh_it)
1173 c = _2over3 * ( cos( _2pi / valence) + 1.0);
1175 valence = Base::mesh_.valence(_vh);
1176 c =
typename M::Scalar(coeff(valence));
1180 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1182 fh = Base::mesh_.FH(*voh_it);
1184 Base::prev_rule()->raise(fh, _target_state - 1);
1186 fh = Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it)));
1188 Base::prev_rule()->raise(fh, _target_state - 1);
1190 if (Base::mesh_.FH(*voh_it).is_valid()) {
1192 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
1194 position += MOBJ(Base::mesh_.FH(*voh_it)).position(_target_state - 1) * c;
1196 position += MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it)))).position(_target_state - 1) * (
typename M::Scalar(1.0) - c);
1200 position += MOBJ(Base::mesh_.FH(*voh_it)).position(_target_state - 1);
1210 position /=
typename M::Scalar(valence);
1212 MOBJ(_vh).set_position(_target_state, position);
1213 MOBJ(_vh).inc_state();
1215 assert(MOBJ(_vh).state() == _target_state);
1218 if (Base::number() == Base::n_rules() - 1) {
1220 Base::mesh_.set_point(_vh, position);
1221 MOBJ(_vh).set_final();
1232 if ( coeffs_.size() == _max_valence+1 )
1235 if ( coeffs_.size() < _max_valence+1 )
1237 const double _2pi(2.0*M_PI);
1238 const double _2over3(2.0/3.0);
1240 if (coeffs_.empty())
1241 coeffs_.push_back(0.0);
1243 for(
size_t v=coeffs_.size(); v <= _max_valence; ++v)
1244 coeffs_.push_back(_2over3 * ( cos( _2pi / v) + 1.0));
1255 if (MOBJ(_vh).state() < _target_state)
1257 this->update(_vh, _target_state);
1260 typename M::VertexVertexIter vv_it(Base::mesh_.vv_iter(_vh));
1261 typename M::VertexHandle vh;
1262 std::vector<typename M::VertexHandle> vertex_vector;
1264 if (_target_state > 1) {
1266 for (; vv_it.is_valid(); ++vv_it) {
1268 vertex_vector.push_back(*vv_it);
1271 while (!vertex_vector.empty()) {
1273 vh = vertex_vector.back();
1274 vertex_vector.pop_back();
1276 Base::prev_rule()->raise(vh, _target_state - 1);
1279 for (; vv_it.is_valid(); ++vv_it) {
1281 vertex_vector.push_back(*vv_it);
1284 while (!vertex_vector.empty()) {
1286 vh = vertex_vector.back();
1287 vertex_vector.pop_back();
1289 Base::prev_rule()->raise(vh, _target_state - 1);
1294 typename M::Point position(0.0, 0.0, 0.0);
1295 typename M::Scalar valence(0.0);
1297 for (vv_it = Base::mesh_.vv_iter(_vh); vv_it.is_valid(); ++vv_it) {
1300 position += Base::mesh_.data(*vv_it).position(_target_state - 1);
1303 position /= valence;
1305 MOBJ(_vh).set_position(_target_state, position);
1306 MOBJ(_vh).inc_state();
1309 if (Base::number() == Base::n_rules() - 1) {
1311 Base::mesh_.set_point(_vh, position);
1312 MOBJ(_vh).set_final();
1324 if (MOBJ(_vh).state() < _target_state) {
1326 this->update(_vh, _target_state);
1329 typename M::VertexVertexIter vv_it(Base::mesh_.vv_iter(_vh));
1330 typename M::VertexHandle vh;
1331 std::vector<typename M::VertexHandle> vertex_vector;
1333 if (_target_state > 1) {
1335 for (; vv_it.is_valid(); ++vv_it) {
1337 vertex_vector.push_back(*vv_it);
1340 while (!vertex_vector.empty()) {
1342 vh = vertex_vector.back();
1343 vertex_vector.pop_back();
1345 Base::prev_rule()->raise(vh, _target_state - 1);
1348 for (; vv_it.is_valid(); ++vv_it) {
1350 vertex_vector.push_back(*vv_it);
1353 while (!vertex_vector.empty()) {
1355 vh = vertex_vector.back();
1356 vertex_vector.pop_back();
1358 Base::prev_rule()->raise(vh, _target_state - 1);
1363 typename M::Point position(0.0, 0.0, 0.0);
1364 typename M::Scalar valence(0.0);
1365 typename M::Scalar c;
1367 for (vv_it = Base::mesh_.vv_iter(_vh); vv_it.is_valid(); ++vv_it)
1370 position += Base::mesh_.data(*vv_it).position(_target_state - 1);
1373 position /= valence;
1378 position *= (1.0 - c);
1379 position += MOBJ(_vh).position(_target_state - 1) * c;
1381 MOBJ(_vh).set_position(_target_state, position);
1382 MOBJ(_vh).inc_state();
1384 if (Base::number() == Base::n_rules() - 1)
1386 Base::mesh_.set_point(_vh, position);
1387 MOBJ(_vh).set_final();
1399 if (MOBJ(_eh).state() < _target_state) {
1401 this->update(_eh, _target_state);
1404 typename M::VertexHandle vh;
1405 typename M::HalfedgeHandle hh1(Base::mesh_.HEH(_eh, 0)),
1406 hh2(Base::mesh_.HEH(_eh, 1));
1408 if (_target_state > 1) {
1410 vh = Base::mesh_.TVH(hh1);
1412 Base::prev_rule()->raise(vh, _target_state - 1);
1414 vh = Base::mesh_.TVH(hh2);
1416 Base::prev_rule()->raise(vh, _target_state - 1);
1420 typename M::Point position(0.0, 0.0, 0.0);
1421 const typename M::Scalar valence(2.0);
1423 position += MOBJ(Base::mesh_.TVH(hh1)).position(_target_state - 1);
1424 position += MOBJ(Base::mesh_.TVH(hh2)).position(_target_state - 1);
1426 position /= valence;
1428 MOBJ(_eh).set_position(_target_state, position);
1429 MOBJ(_eh).inc_state();
1440 if (MOBJ(_eh).state() < _target_state)
1442 this->update(_eh, _target_state);
1445 typename M::VertexHandle vh;
1446 typename M::HalfedgeHandle hh1(Base::mesh_.HEH(_eh, 0)),
1447 hh2(Base::mesh_.HEH(_eh, 1));
1448 typename M::FaceHandle fh1, fh2;
1450 if (_target_state > 1) {
1452 fh1 = Base::mesh_.FH(hh1);
1453 fh2 = Base::mesh_.FH(hh2);
1455 if (fh1.is_valid()) {
1457 Base::prev_rule()->raise(fh1, _target_state - 1);
1459 vh = Base::mesh_.TVH(Base::mesh_.NHEH(hh1));
1460 Base::prev_rule()->raise(vh, _target_state - 1);
1463 if (fh2.is_valid()) {
1465 Base::prev_rule()->raise(fh2, _target_state - 1);
1467 vh = Base::mesh_.TVH(Base::mesh_.NHEH(hh2));
1468 Base::prev_rule()->raise(vh, _target_state - 1);
1471 vh = Base::mesh_.TVH(hh1);
1472 Base::prev_rule()->raise(vh, _target_state - 1);
1474 vh = Base::mesh_.TVH(hh2);
1475 Base::prev_rule()->raise(vh, _target_state - 1);
1479 typename M::Point position(0.0, 0.0, 0.0);
1480 typename M::Scalar valence(2.0);
1482 position += MOBJ(Base::mesh_.TVH(hh1)).position(_target_state - 1);
1483 position += MOBJ(Base::mesh_.TVH(hh2)).position(_target_state - 1);
1485 if (fh1.is_valid()) {
1487 position += MOBJ(Base::mesh_.TVH(Base::mesh_.NHEH(hh1))).position(_target_state - 1);
1491 if (fh2.is_valid()) {
1493 position += MOBJ(Base::mesh_.TVH(Base::mesh_.NHEH(hh2))).position(_target_state - 1);
1497 if (Base::number() == Base::subdiv_rule()->Base::number() + 1)
1500 position /= valence;
1502 MOBJ(_eh).set_position(_target_state, position);
1503 MOBJ(_eh).inc_state();
1515 if (MOBJ(_eh).state() < _target_state)
1517 this->update(_eh, _target_state);
1520 typename M::VertexHandle vh;
1521 typename M::HalfedgeHandle hh1(Base::mesh_.HEH(_eh, 0)),
1522 hh2(Base::mesh_.HEH(_eh, 1));
1523 std::vector<typename M::VertexHandle> vertex_vector;
1524 typename M::FaceHandle fh1, fh2;
1526 if (_target_state > 1) {
1528 fh1 = Base::mesh_.FH(Base::mesh_.HEH(_eh, 0));
1529 fh2 = Base::mesh_.FH(Base::mesh_.HEH(_eh, 1));
1531 Base::prev_rule()->raise(fh1, _target_state - 1);
1532 Base::prev_rule()->raise(fh2, _target_state - 1);
1534 vertex_vector.push_back(Base::mesh_.TVH(hh1));
1535 vertex_vector.push_back(Base::mesh_.TVH(hh2));
1537 vertex_vector.push_back(Base::mesh_.TVH(Base::mesh_.NHEH(hh1)));
1538 vertex_vector.push_back(Base::mesh_.TVH(Base::mesh_.NHEH(hh2)));
1540 while (!vertex_vector.empty()) {
1542 vh = vertex_vector.back();
1543 vertex_vector.pop_back();
1545 Base::prev_rule()->raise(vh, _target_state - 1);
1548 vertex_vector.push_back(Base::mesh_.TVH(hh1));
1549 vertex_vector.push_back(Base::mesh_.TVH(hh2));
1551 vertex_vector.push_back(Base::mesh_.TVH(Base::mesh_.NHEH(hh1)));
1552 vertex_vector.push_back(Base::mesh_.TVH(Base::mesh_.NHEH(hh2)));
1554 while (!vertex_vector.empty()) {
1556 vh = vertex_vector.back();
1557 vertex_vector.pop_back();
1559 Base::prev_rule()->raise(vh, _target_state - 1);
1564 typename M::Point position(0.0, 0.0, 0.0);
1565 const typename M::Scalar valence(4.0);
1566 typename M::Scalar c;
1571 position += MOBJ(Base::mesh_.TVH(hh1)).position(_target_state - 1) * c;
1572 position += MOBJ(Base::mesh_.TVH(hh2)).position(_target_state - 1) * c;
1573 position += MOBJ(Base::mesh_.TVH(Base::mesh_.NHEH(hh1))).position(_target_state - 1) * (0.5 - c);
1574 position += MOBJ(Base::mesh_.TVH(Base::mesh_.NHEH(hh2))).position(_target_state - 1) * (0.5 - c);
1576 position /= valence;
1578 MOBJ(_eh).set_position(_target_state, position);
1579 MOBJ(_eh).inc_state();
1590 if (MOBJ(_vh).state() < _target_state) {
1592 this->update(_vh, _target_state);
1595 typename M::VertexEdgeIter ve_it(Base::mesh_.ve_iter(_vh));
1596 typename M::EdgeHandle eh;
1597 std::vector<typename M::EdgeHandle> edge_vector;
1599 if (_target_state > 1) {
1601 for (; ve_it.is_valid(); ++ve_it) {
1603 edge_vector.push_back(*ve_it);
1606 while (!edge_vector.empty()) {
1608 eh = edge_vector.back();
1609 edge_vector.pop_back();
1611 Base::prev_rule()->raise(eh, _target_state - 1);
1614 for (ve_it = Base::mesh_.ve_iter(_vh); ve_it.is_valid(); ++ve_it) {
1616 edge_vector.push_back(*ve_it);
1619 while (!edge_vector.empty()) {
1621 eh = edge_vector.back();
1622 edge_vector.pop_back();
1624 while (MOBJ(eh).state() < _target_state - 1)
1625 Base::prev_rule()->raise(eh, _target_state - 1);
1630 typename M::Point position(0.0, 0.0, 0.0);
1631 typename M::Scalar valence(0.0);
1633 for (ve_it = Base::mesh_.ve_iter(_vh); ve_it.is_valid(); ++ve_it) {
1635 if (Base::mesh_.data(*ve_it).final()) {
1639 position += Base::mesh_.data(*ve_it).position(_target_state - 1);
1643 position /= valence;
1645 MOBJ(_vh).set_position(_target_state, position);
1646 MOBJ(_vh).inc_state();
1649 if (Base::number() == Base::n_rules() - 1) {
1651 Base::mesh_.set_point(_vh, position);
1652 MOBJ(_vh).set_final();
1666 if (MOBJ(_vh).state() < _target_state)
1668 this->update(_vh, _target_state);
1671 typename M::VertexOHalfedgeIter voh_it;
1672 typename M::EdgeHandle eh;
1673 typename M::FaceHandle fh;
1674 std::vector<typename M::EdgeHandle> edge_vector;
1675 std::vector<typename M::FaceHandle> face_vector;
1677 if (_target_state > 1) {
1679 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1681 face_vector.push_back(Base::mesh_.FH(*voh_it));
1684 while (!face_vector.empty()) {
1686 fh = face_vector.back();
1687 face_vector.pop_back();
1690 Base::prev_rule()->raise(fh, _target_state - 1);
1693 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1695 edge_vector.push_back(Base::mesh_.EH(*voh_it));
1697 edge_vector.push_back(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it)));
1700 while (!edge_vector.empty()) {
1702 eh = edge_vector.back();
1703 edge_vector.pop_back();
1705 while (MOBJ(eh).state() < _target_state - 1)
1706 Base::prev_rule()->raise(eh, _target_state - 1);
1712 typename M::Point position(0.0, 0.0, 0.0);
1713 typename M::Scalar c;
1714 typename M::Point zero_point(0.0, 0.0, 0.0);
1717 valence = Base::mesh_.valence(_vh);
1718 c = coeff( valence );
1720 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it)
1722 if (MOBJ(Base::mesh_.EH(*voh_it)).final())
1724 position += MOBJ(Base::mesh_.EH(*voh_it)).position(_target_state-1)*c;
1726 if ( Base::mesh_.FH(*voh_it).is_valid() &&
1727 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it))).final() &&
1728 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it))).position(_target_state - 1) != zero_point)
1730 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it))).position(_target_state-1) * (1.0-c);
1733 position += MOBJ(Base::mesh_.EH(*voh_it)).position(_target_state - 1) * (1.0 - c);
1741 position /= valence;
1743 MOBJ(_vh).set_position(_target_state, position);
1744 MOBJ(_vh).inc_state();
1747 if (Base::number() == Base::n_rules() - 1) {
1749 Base::mesh_.set_point(_vh, position);
1750 MOBJ(_vh).set_final();
1760 if ( coeffs_.size() == _max_valence+1 )
1763 if (coeffs_.size() < _max_valence+1)
1765 const double _2pi = 2.0*M_PI;
1767 if (coeffs_.empty())
1768 coeffs_.push_back(0.0);
1770 for(
size_t v=coeffs_.size(); v <= _max_valence; ++v)
1773 double c = 1.5 + cos( _2pi / v );
1774 c = c * c * 0.5 - 1.0;
1775 coeffs_.push_back(c);
1787 if (MOBJ(_fh).state() < _target_state) {
1789 this->update(_fh, _target_state);
1792 typename M::FaceEdgeIter fe_it(Base::mesh_.fe_iter(_fh));
1793 typename M::EdgeHandle eh;
1794 std::vector<typename M::EdgeHandle> edge_vector;
1796 if (_target_state > 1) {
1798 for (; fe_it.is_valid(); ++fe_it) {
1800 edge_vector.push_back(*fe_it);
1803 while (!edge_vector.empty()) {
1805 eh = edge_vector.back();
1806 edge_vector.pop_back();
1808 Base::prev_rule()->raise(eh, _target_state - 1);
1811 for (fe_it = Base::mesh_.fe_iter(_fh); fe_it.is_valid(); ++fe_it) {
1813 edge_vector.push_back(*fe_it);
1816 while (!edge_vector.empty()) {
1818 eh = edge_vector.back();
1819 edge_vector.pop_back();
1821 while (MOBJ(eh).state() < _target_state - 1)
1822 Base::prev_rule()->raise(eh, _target_state - 1);
1827 typename M::Point position(0.0, 0.0, 0.0);
1828 typename M::Scalar valence(0.0);
1830 for (fe_it = Base::mesh_.fe_iter(_fh); fe_it.is_valid(); ++fe_it) {
1832 if (Base::mesh_.data(*fe_it).final()) {
1836 position += Base::mesh_.data(*fe_it).position(_target_state - 1);
1840 assert (valence == 3.0);
1842 position /= valence;
1844 MOBJ(_fh).set_position(_target_state, position);
1845 MOBJ(_fh).inc_state();
1857 if (MOBJ(_eh).state() < _target_state) {
1859 this->update(_eh, _target_state);
1862 typename M::FaceHandle fh;
1864 if (_target_state > 1) {
1866 fh = Base::mesh_.FH(Base::mesh_.HEH(_eh, 0));
1867 Base::prev_rule()->raise(fh, _target_state - 1);
1869 fh = Base::mesh_.FH(Base::mesh_.HEH(_eh, 1));
1870 Base::prev_rule()->raise(fh, _target_state - 1);
1872 fh = Base::mesh_.FH(Base::mesh_.HEH(_eh, 0));
1873 Base::prev_rule()->raise(fh, _target_state - 1);
1875 fh = Base::mesh_.FH(Base::mesh_.HEH(_eh, 1));
1876 Base::prev_rule()->raise(fh, _target_state - 1);
1880 typename M::Point position(0.0, 0.0, 0.0);
1881 const typename M::Scalar valence(2.0);
1883 position += MOBJ(Base::mesh_.FH(Base::mesh_.HEH(_eh, 0))).position(_target_state - 1);
1885 position += MOBJ(Base::mesh_.FH(Base::mesh_.HEH(_eh, 1))).position(_target_state - 1);
1887 position /= valence;
1889 MOBJ(_eh).set_position(_target_state, position);
1890 MOBJ(_eh).inc_state();
1902 if (MOBJ(_eh).state() < _target_state) {
1904 this->update(_eh, _target_state);
1907 typename M::HalfedgeHandle hh1, hh2;
1908 typename M::FaceHandle fh;
1909 typename M::EdgeHandle eh;
1911 hh1 = Base::mesh_.HEH(_eh, 0);
1912 hh2 = Base::mesh_.HEH(_eh, 1);
1914 if (_target_state > 1) {
1916 fh = Base::mesh_.FH(hh1);
1917 Base::prev_rule()->raise(fh, _target_state - 1);
1919 fh = Base::mesh_.FH(hh2);
1920 Base::prev_rule()->raise(fh, _target_state - 1);
1922 eh = Base::mesh_.EH(Base::mesh_.NHEH(hh1));
1923 Base::prev_rule()->raise(eh, _target_state - 1);
1925 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh1));
1926 Base::prev_rule()->raise(eh, _target_state - 1);
1928 eh = Base::mesh_.EH(Base::mesh_.NHEH(hh2));
1929 Base::prev_rule()->raise(eh, _target_state - 1);
1931 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh2));
1932 Base::prev_rule()->raise(eh, _target_state - 1);
1936 typename M::Point position(0.0, 0.0, 0.0);
1937 const typename M::Scalar valence(4.0);
1939 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh1))).position(_target_state - 1);
1940 position += MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh1))).position(_target_state - 1);
1941 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh2))).position(_target_state - 1);
1942 position += MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh2))).position(_target_state - 1);
1944 position /= valence;
1946 MOBJ(_eh).set_position(_target_state, position);
1947 MOBJ(_eh).inc_state();
1959 if (MOBJ(_eh).state() < _target_state) {
1961 this->update(_eh, _target_state);
1964 typename M::HalfedgeHandle hh1, hh2;
1965 typename M::FaceHandle fh;
1966 typename M::EdgeHandle eh;
1968 hh1 = Base::mesh_.HEH(_eh, 0);
1969 hh2 = Base::mesh_.HEH(_eh, 1);
1971 if (_target_state > 1) {
1973 fh = Base::mesh_.FH(hh1);
1974 Base::prev_rule()->raise(fh, _target_state - 1);
1976 fh = Base::mesh_.FH(hh2);
1977 Base::prev_rule()->raise(fh, _target_state - 1);
1979 eh = Base::mesh_.EH(Base::mesh_.NHEH(hh1));
1980 Base::prev_rule()->raise(eh, _target_state - 1);
1982 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh1));
1983 Base::prev_rule()->raise(eh, _target_state - 1);
1985 eh = Base::mesh_.EH(Base::mesh_.NHEH(hh2));
1986 Base::prev_rule()->raise(eh, _target_state - 1);
1988 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh2));
1989 Base::prev_rule()->raise(eh, _target_state - 1);
1993 typename M::Point position(0.0, 0.0, 0.0);
1994 const typename M::Scalar valence(4.0);
1995 typename M::Scalar c;
1997 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh1))).position(_target_state - 1);
1998 position += MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh1))).position(_target_state - 1);
1999 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh2))).position(_target_state - 1);
2000 position += MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh2))).position(_target_state - 1);
2002 position /= valence;
2007 position *= (1.0 - c);
2009 position += MOBJ(_eh).position(_target_state - 1) * c;
2011 MOBJ(_eh).set_position(_target_state, position);
2012 MOBJ(_eh).inc_state();
2016 #endif // DOXY_IGNORE_THIS void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.
void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
CompositeTraits::state_t state_t
void raise(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.