55 #define OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_CC 60 #include <OpenMesh/Core/System/config.h> 61 #include <OpenMesh/Core/IO/MeshIO.hh> 64 #if defined(OM_CC_MIPS) 70 #if defined(OM_CC_MSVC) 71 # pragma warning(disable:4244) 77 namespace Subdivider {
83 #define MOBJ Base::mesh_.data 84 #define FH face_handle 85 #define VH vertex_handle 86 #define EH edge_handle 87 #define HEH halfedge_handle 88 #define NHEH next_halfedge_handle 89 #define PHEH prev_halfedge_handle 90 #define OHEH opposite_halfedge_handle 91 #define TVH to_vertex_handle 92 #define FVH from_vertex_handle 101 if (MOBJ(_fh).state() < _target_state)
103 this->update(_fh, _target_state);
105 typename M::VertexVertexIter vv_it;
106 typename M::FaceVertexIter fv_it;
107 typename M::VertexHandle vh;
108 typename M::Point position(0.0, 0.0, 0.0);
109 typename M::Point face_position;
110 const typename M::Point zero_point(0.0, 0.0, 0.0);
111 std::vector<typename M::VertexHandle> vertex_vector;
115 for (fv_it = Base::mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) {
117 vertex_vector.push_back(*fv_it);
120 while(!vertex_vector.empty()) {
122 vh = vertex_vector.back();
123 vertex_vector.pop_back();
125 if (_target_state > 1)
126 Base::prev_rule()->raise(vh, _target_state - 1);
129 face_position = MOBJ(_fh).position(_target_state - 1);
131 typename M::EdgeHandle eh;
132 std::vector<typename M::EdgeHandle> edge_vector;
135 if (!Base::mesh_.is_boundary(_fh) || MOBJ(_fh).
final()) {
138 vh = Base::mesh_.new_vertex();
140 Base::mesh_.split(_fh, vh);
142 typename M::Scalar valence(0.0);
145 for (vv_it = Base::mesh_.vv_iter(vh); vv_it.is_valid(); ++vv_it)
147 position += Base::mesh_.point(*vv_it);
154 Base::mesh_.set_point(vh, position);
155 MOBJ(vh).set_position(_target_state, zero_point);
156 MOBJ(vh).set_state(_target_state);
157 MOBJ(vh).set_not_final();
159 typename M::VertexOHalfedgeIter voh_it;
161 for (voh_it = Base::mesh_.voh_iter(vh); voh_it.is_valid(); ++voh_it) {
163 if (Base::mesh_.FH(*voh_it).is_valid()) {
165 MOBJ(Base::mesh_.FH(*voh_it)).set_state(_target_state);
166 MOBJ(Base::mesh_.FH(*voh_it)).set_not_final();
167 MOBJ(Base::mesh_.FH(*voh_it)).set_position(_target_state - 1, face_position);
170 for (
state_t j = 0; j < _target_state; ++j) {
171 MOBJ(Base::mesh_.FH(*voh_it)).set_position(j, MOBJ(_fh).position(j));
174 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
176 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it)))).state() == _target_state) {
178 if (Base::mesh_.is_flip_ok(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it)))) {
180 edge_vector.push_back(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it)));
191 typename M::VertexHandle vh1 = Base::mesh_.new_vertex(),
192 vh2 = Base::mesh_.new_vertex();
194 typename M::HalfedgeHandle hh2 = Base::mesh_.HEH(_fh),
197 while (!Base::mesh_.is_boundary(Base::mesh_.OHEH(hh2)))
198 hh2 = Base::mesh_.NHEH(hh2);
200 eh = Base::mesh_.EH(hh2);
202 hh2 = Base::mesh_.NHEH(hh2);
203 hh1 = Base::mesh_.NHEH(hh2);
205 assert(Base::mesh_.is_boundary(eh));
207 Base::mesh_.split(eh, vh1);
209 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh2));
211 assert(Base::mesh_.is_boundary(eh));
213 Base::mesh_.split(eh, vh2);
215 hh3 = Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(hh1)));
217 typename M::VertexHandle vh0(Base::mesh_.TVH(hh1)),
218 vh3(Base::mesh_.FVH(hh2));
221 Base::mesh_.set_point(vh1, (Base::mesh_.point(vh0) * static_cast<typename M::Point::value_type>(2.0) + Base::mesh_.point(vh3)) / static_cast<typename M::Point::value_type>(3.0) );
223 MOBJ(vh1).set_position(_target_state, zero_point);
224 MOBJ(vh1).set_state(_target_state);
225 MOBJ(vh1).set_not_final();
227 MOBJ(vh0).set_position(_target_state, MOBJ(vh0).position(_target_state - 1) * static_cast<typename M::Point::value_type>(3.0));
228 MOBJ(vh0).set_state(_target_state);
229 MOBJ(vh0).set_not_final();
232 Base::mesh_.set_point(vh2, (Base::mesh_.point(vh3) * static_cast<typename M::Point::value_type>(2.0) + Base::mesh_.point(vh0)) / static_cast<typename M::Point::value_type>(3.0) );
233 MOBJ(vh2).set_position(_target_state, zero_point);
234 MOBJ(vh2).set_state(_target_state);
235 MOBJ(vh2).set_not_final();
237 MOBJ(vh3).set_position(_target_state, MOBJ(vh3).position(_target_state - 1) * static_cast<typename M::Point::value_type>(3.0) );
238 MOBJ(vh3).set_state(_target_state);
239 MOBJ(vh3).set_not_final();
242 MOBJ(Base::mesh_.FH(hh1)).set_state(_target_state);
243 MOBJ(Base::mesh_.FH(hh1)).set_not_final();
244 MOBJ(Base::mesh_.FH(hh1)).set_position(_target_state - 1, face_position);
246 MOBJ(Base::mesh_.FH(hh2)).set_state(_target_state);
247 MOBJ(Base::mesh_.FH(hh2)).set_not_final();
248 MOBJ(Base::mesh_.FH(hh2)).set_position(_target_state - 1, face_position);
250 MOBJ(Base::mesh_.FH(hh3)).set_state(_target_state);
251 MOBJ(Base::mesh_.FH(hh3)).set_final();
252 MOBJ(Base::mesh_.FH(hh3)).set_position(_target_state - 1, face_position);
255 for (
state_t j = 0; j < _target_state; ++j) {
256 MOBJ(Base::mesh_.FH(hh1)).set_position(j, MOBJ(_fh).position(j));
259 for (
state_t j = 0; j < _target_state; ++j) {
261 MOBJ(Base::mesh_.FH(hh2)).set_position(j, MOBJ(_fh).position(j));
264 for (
state_t j = 0; j < _target_state; ++j) {
266 MOBJ(Base::mesh_.FH(hh3)).set_position(j, MOBJ(_fh).position(j));
270 if (Base::mesh_.FH(Base::mesh_.OHEH(hh1)).is_valid()) {
272 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(hh1))).state() == _target_state) {
274 if (Base::mesh_.is_flip_ok(Base::mesh_.EH(hh1))) {
276 edge_vector.push_back(Base::mesh_.EH(hh1));
281 if (Base::mesh_.FH(Base::mesh_.OHEH(hh2)).is_valid()) {
283 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(hh2))).state() == _target_state) {
285 if (Base::mesh_.is_flip_ok(Base::mesh_.EH(hh2))) {
287 edge_vector.push_back(Base::mesh_.EH(hh2));
294 while (!edge_vector.empty()) {
296 eh = edge_vector.back();
297 edge_vector.pop_back();
299 assert(Base::mesh_.is_flip_ok(eh));
301 Base::mesh_.flip(eh);
303 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 0))).set_final();
304 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 1))).set_final();
306 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 0))).set_state(_target_state);
307 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 1))).set_state(_target_state);
309 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 0))).set_position(_target_state, face_position);
310 MOBJ(Base::mesh_.FH(Base::mesh_.HEH(eh, 1))).set_position(_target_state, face_position);
319 if (MOBJ(_vh).state() < _target_state) {
321 this->update(_vh, _target_state);
324 MOBJ(_vh).set_position(_target_state, MOBJ(_vh).position(_target_state - 1) * static_cast<typename M::Point::value_type>(3.0) );
326 MOBJ(_vh).inc_state();
328 assert(MOBJ(_vh).state() == _target_state);
341 if (MOBJ(_fh).state() < _target_state) {
343 this->update(_fh, _target_state);
345 typename M::FaceVertexIter fv_it;
346 typename M::VertexHandle temp_vh;
347 typename M::Point face_position;
348 const typename M::Point zero_point(0.0, 0.0, 0.0);
349 std::vector<typename M::VertexHandle> vertex_vector;
350 std::vector<typename M::HalfedgeHandle> halfedge_vector;
353 for (fv_it = Base::mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) {
355 vertex_vector.push_back(*fv_it);
358 while(!vertex_vector.empty()) {
360 temp_vh = vertex_vector.back();
361 vertex_vector.pop_back();
363 if (_target_state > 1) {
364 Base::prev_rule()->raise(temp_vh, _target_state - 1);
368 face_position = MOBJ(_fh).position(_target_state - 1);
370 typename M::HalfedgeHandle hh[3];
371 typename M::VertexHandle vh[3];
372 typename M::VertexHandle new_vh[3];
373 typename M::FaceHandle fh[4];
374 typename M::EdgeHandle eh;
375 typename M::HalfedgeHandle temp_hh;
378 if (MOBJ(_fh).
final()) {
381 hh[0] = Base::mesh_.HEH(_fh);
382 hh[1] = Base::mesh_.NHEH(hh[0]);
383 hh[2] = Base::mesh_.NHEH(hh[1]);
385 assert(hh[0] == Base::mesh_.NHEH(hh[2]));
387 vh[0] = Base::mesh_.TVH(hh[0]);
388 vh[1] = Base::mesh_.TVH(hh[1]);
389 vh[2] = Base::mesh_.TVH(hh[2]);
391 new_vh[0] = Base::mesh_.add_vertex(zero_point);
392 new_vh[1] = Base::mesh_.add_vertex(zero_point);
393 new_vh[2] = Base::mesh_.add_vertex(zero_point);
396 split_edge(hh[0], new_vh[0], _target_state);
397 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh[2]));
398 split_edge(hh[1], new_vh[1], _target_state);
399 split_edge(hh[2], new_vh[2], _target_state);
401 assert(Base::mesh_.FVH(hh[2]) == vh[1]);
402 assert(Base::mesh_.FVH(hh[1]) == vh[0]);
403 assert(Base::mesh_.FVH(hh[0]) == vh[2]);
405 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[0])).is_valid())
407 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[0])));
408 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
409 halfedge_vector.push_back(temp_hh);
412 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[1])).is_valid()) {
414 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[1])));
415 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
416 halfedge_vector.push_back(temp_hh);
419 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[2])).is_valid()) {
421 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[2])));
422 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
423 halfedge_vector.push_back(temp_hh);
431 typename M::HalfedgeHandle red_hh(MOBJ(_fh).red_halfedge());
433 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh))).is_valid()
434 && Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)))).is_valid()
435 && MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)))).red_halfedge() == red_hh
436 && MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh))))).red_halfedge() == red_hh)
440 vh[0] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)))));
441 vh[1] = Base::mesh_.TVH(red_hh);
442 vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh))));
444 new_vh[0] = Base::mesh_.FVH(red_hh);
445 new_vh[1] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)));
446 new_vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(red_hh));
448 hh[0] = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)));
449 hh[1] = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh))));
450 hh[2] = Base::mesh_.NHEH(red_hh);
452 eh = Base::mesh_.EH(red_hh);
458 if ((Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh))).is_valid() &&
459 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)))).red_halfedge()
461 || (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)))).is_valid()
462 && MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh))))).red_halfedge() == red_hh))
466 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)))).red_halfedge() == red_hh)
469 vh[0] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)));
470 vh[1] = Base::mesh_.TVH(red_hh);
471 vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh))));
473 new_vh[0] = Base::mesh_.FVH(red_hh);
474 new_vh[1] = Base::mesh_.add_vertex(zero_point);
475 new_vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(red_hh));
477 hh[0] = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(red_hh)));
478 hh[1] = Base::mesh_.PHEH(Base::mesh_.OHEH(red_hh));
479 hh[2] = Base::mesh_.NHEH(red_hh);
482 eh = Base::mesh_.EH(red_hh);
484 split_edge(hh[1], new_vh[1], _target_state);
486 assert(Base::mesh_.FVH(hh[2]) == vh[1]);
487 assert(Base::mesh_.FVH(hh[1]) == vh[0]);
488 assert(Base::mesh_.FVH(hh[0]) == vh[2]);
490 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[1])).is_valid())
492 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[1])));
493 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
494 halfedge_vector.push_back(temp_hh);
501 vh[0] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)))));
502 vh[1] = Base::mesh_.TVH(red_hh);
503 vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(red_hh));
505 new_vh[0] = Base::mesh_.FVH(red_hh);
506 new_vh[1] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)));
507 new_vh[2] = Base::mesh_.add_vertex(zero_point);
509 hh[0] = Base::mesh_.PHEH(red_hh);
510 hh[1] = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh))));
511 hh[2] = Base::mesh_.NHEH(red_hh);
514 eh = Base::mesh_.EH(red_hh);
516 split_edge(hh[2], new_vh[2], _target_state);
518 assert(Base::mesh_.FVH(hh[2]) == vh[1]);
519 assert(Base::mesh_.FVH(hh[1]) == vh[0]);
520 assert(Base::mesh_.FVH(hh[0]) == vh[2]);
522 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[2])).is_valid()) {
524 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[2])));
525 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
526 halfedge_vector.push_back(temp_hh);
534 vh[0] = Base::mesh_.TVH(Base::mesh_.NHEH(Base::mesh_.OHEH(red_hh)));
535 vh[1] = Base::mesh_.TVH(red_hh);
536 vh[2] = Base::mesh_.TVH(Base::mesh_.NHEH(red_hh));
538 new_vh[0] = Base::mesh_.FVH(red_hh);
539 new_vh[1] = Base::mesh_.add_vertex(zero_point);
540 new_vh[2] = Base::mesh_.add_vertex(zero_point);
542 hh[0] = Base::mesh_.PHEH(red_hh);
543 hh[1] = Base::mesh_.PHEH(Base::mesh_.OHEH(red_hh));
544 hh[2] = Base::mesh_.NHEH(red_hh);
547 eh = Base::mesh_.EH(red_hh);
549 split_edge(hh[1], new_vh[1], _target_state);
550 split_edge(hh[2], new_vh[2], _target_state);
552 assert(Base::mesh_.FVH(hh[2]) == vh[1]);
553 assert(Base::mesh_.FVH(hh[1]) == vh[0]);
554 assert(Base::mesh_.FVH(hh[0]) == vh[2]);
556 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[1])).is_valid()) {
558 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[1])));
559 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
560 halfedge_vector.push_back(temp_hh);
563 if (Base::mesh_.FH(Base::mesh_.OHEH(hh[2])).is_valid()) {
565 temp_hh = Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(hh[2])));
566 if (MOBJ(Base::mesh_.FH(temp_hh)).red_halfedge() != temp_hh)
567 halfedge_vector.push_back(temp_hh);
576 if (Base::mesh_.is_flip_ok(eh)) {
578 Base::mesh_.flip(eh);
582 fh[0] = Base::mesh_.FH(hh[0]);
583 fh[1] = Base::mesh_.FH(hh[1]);
584 fh[2] = Base::mesh_.FH(hh[2]);
585 fh[3] = Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(hh[0])));
587 assert(_fh == fh[0] || _fh == fh[1] || _fh == fh[2] || _fh == fh[3]);
590 for (
int i = 0; i <= 3; ++i) {
592 MOBJ(fh[i]).set_state(_target_state);
593 MOBJ(fh[i]).set_final();
594 MOBJ(fh[i]).set_position(_target_state, face_position);
595 MOBJ(fh[i]).set_red_halfedge(Base::mesh_.InvalidHalfedgeHandle);
599 for (
int i = 0; i <= 2; ++i) {
601 MOBJ(new_vh[i]).set_position(_target_state, zero_point);
602 MOBJ(new_vh[i]).set_state(_target_state);
603 MOBJ(new_vh[i]).set_not_final();
605 Base::mesh_.set_point(new_vh[i], (Base::mesh_.point(vh[i]) + Base::mesh_.point(vh[(i + 2) % 3])) * 0.5);
607 MOBJ(Base::mesh_.EH(hh[i])).set_state(_target_state);
608 MOBJ(Base::mesh_.EH(hh[i])).set_position(_target_state, zero_point);
609 MOBJ(Base::mesh_.EH(hh[i])).set_final();
611 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh[i]))).set_state(_target_state);
612 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh[i]))).set_position(_target_state, zero_point);
613 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh[i]))).set_final();
615 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh[i]))).set_state(_target_state);
616 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh[i]))).set_position(_target_state, zero_point);
617 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh[i]))).set_final();
621 while (!halfedge_vector.empty()) {
623 temp_hh = halfedge_vector.back();
624 halfedge_vector.pop_back();
626 check_edge(temp_hh, _target_state);
629 assert(MOBJ(fh[0]).state() == _target_state);
630 assert(MOBJ(fh[1]).state() == _target_state);
631 assert(MOBJ(fh[2]).state() == _target_state);
632 assert(MOBJ(fh[3]).state() == _target_state);
642 if (MOBJ(_vh).state() < _target_state)
645 this->update(_vh, _target_state);
648 MOBJ(_vh).set_position(_target_state, MOBJ(_vh).position(_target_state - 1) * static_cast<typename M::Point::value_type>(4.0));
650 MOBJ(_vh).inc_state();
659 if (MOBJ(_eh).state() < _target_state)
661 this->update(_eh, _target_state);
663 typename M::FaceHandle fh(Base::mesh_.FH(Base::mesh_.HEH(_eh, 0)));
666 fh=Base::mesh_.FH(Base::mesh_.HEH(_eh, 1));
668 raise(fh, _target_state);
670 assert(MOBJ(_eh).state() == _target_state);
674 #ifndef DOXY_IGNORE_THIS 679 typename M::VertexHandle &_vh,
682 typename M::HalfedgeHandle temp_hh;
684 if (Base::mesh_.FH(Base::mesh_.OHEH(_hh)).is_valid())
686 if (!MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).
final())
688 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).red_halfedge().is_valid())
690 temp_hh = MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).red_halfedge();
695 if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh))))).state()
696 == MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).state())
698 temp_hh = Base::mesh_.PHEH(Base::mesh_.OHEH(_hh));
701 else if (MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(_hh))))).state()
702 == MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).state())
704 temp_hh = Base::mesh_.NHEH(Base::mesh_.OHEH(_hh));
709 temp_hh = Base::mesh_.InvalidHalfedgeHandle;
712 temp_hh = Base::mesh_.InvalidHalfedgeHandle;
715 Base::mesh_.split(Base::mesh_.EH(_hh), _vh);
717 if (Base::mesh_.FVH(_hh) == _vh)
719 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(_hh))))).set_state(MOBJ(Base::mesh_.EH(_hh)).state());
720 _hh = Base::mesh_.PHEH(Base::mesh_.OHEH(Base::mesh_.PHEH(_hh)));
723 if (Base::mesh_.FH(Base::mesh_.OHEH(_hh)).is_valid()) {
725 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh)))).set_not_final();
726 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).set_state(_target_state-1);
727 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh)))))).set_state(_target_state-1);
729 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).set_not_final();
730 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh)))))).set_not_final();
732 MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh)))).set_state(_target_state);
734 if (temp_hh.is_valid()) {
736 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(_hh))).set_red_halfedge(temp_hh);
737 MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh)))))).set_red_halfedge(temp_hh);
741 typename M::FaceHandle
742 fh1(Base::mesh_.FH(Base::mesh_.OHEH(_hh))),
743 fh2(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh))))));
745 MOBJ(fh1).set_red_halfedge(Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh))));
746 MOBJ(fh2).set_red_halfedge(Base::mesh_.OHEH(Base::mesh_.PHEH(Base::mesh_.OHEH(_hh))));
748 const typename M::Point zero_point(0.0, 0.0, 0.0);
750 MOBJ(fh1).set_position(_target_state - 1, zero_point);
751 MOBJ(fh2).set_position(_target_state - 1, zero_point);
756 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh))))).set_state(_target_state - 1);
757 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(Base::mesh_.OHEH(Base::mesh_.NHEH(_hh))))).set_final();
759 MOBJ(Base::mesh_.EH(_hh)).set_state(_target_state - 1);
760 MOBJ(Base::mesh_.EH(_hh)).set_final();
768 typename M::FaceHandle fh1(Base::mesh_.FH(_hh)),
769 fh2(Base::mesh_.FH(Base::mesh_.OHEH(_hh)));
771 assert(fh1.is_valid());
772 assert(fh2.is_valid());
774 typename M::HalfedgeHandle red_hh(MOBJ(fh1).red_halfedge());
776 if (!MOBJ(fh1).
final()) {
778 assert (MOBJ(fh1).
final() == MOBJ(fh2).
final());
779 assert (!MOBJ(fh1).
final());
780 assert (MOBJ(fh1).red_halfedge() == MOBJ(fh2).red_halfedge());
782 const typename M::Point zero_point(0.0, 0.0, 0.0);
784 MOBJ(fh1).set_position(_target_state - 1, zero_point);
785 MOBJ(fh2).set_position(_target_state - 1, zero_point);
787 assert(red_hh.is_valid());
789 if (!red_hh.is_valid()) {
791 MOBJ(fh1).set_state(_target_state - 1);
792 MOBJ(fh2).set_state(_target_state - 1);
794 MOBJ(fh1).set_red_halfedge(_hh);
795 MOBJ(fh2).set_red_halfedge(_hh);
797 MOBJ(Base::mesh_.EH(_hh)).set_not_final();
798 MOBJ(Base::mesh_.EH(_hh)).set_state(_target_state - 1);
803 MOBJ(Base::mesh_.EH(_hh)).set_not_final();
804 MOBJ(Base::mesh_.EH(_hh)).set_state(_target_state - 1);
806 raise(fh1, _target_state);
808 assert(MOBJ(fh1).state() == _target_state);
820 if (MOBJ(_fh).state() < _target_state) {
822 this->update(_fh, _target_state);
825 typename M::FaceVertexIter fv_it;
826 typename M::VertexHandle vh;
827 std::vector<typename M::VertexHandle> vertex_vector;
829 if (_target_state > 1) {
831 for (fv_it = Base::mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) {
833 vertex_vector.push_back(*fv_it);
836 while (!vertex_vector.empty()) {
838 vh = vertex_vector.back();
839 vertex_vector.pop_back();
841 Base::prev_rule()->raise(vh, _target_state - 1);
846 typename M::Point position(0.0, 0.0, 0.0);
847 typename M::Scalar valence(0.0);
849 for (fv_it = Base::mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) {
852 position += Base::mesh_.data(*fv_it).position(_target_state - 1);
858 if (Base::number() == Base::subdiv_rule()->number() + 1 &&
859 Base::mesh_.is_boundary(_fh) &&
861 position *=
static_cast<typename M::Scalar
>(0.5);
863 MOBJ(_fh).set_position(_target_state, position);
864 MOBJ(_fh).inc_state();
866 assert(_target_state == MOBJ(_fh).state());
877 if (MOBJ(_fh).state() < _target_state) {
879 this->update(_fh, _target_state);
882 typename M::FaceFaceIter ff_it;
883 typename M::FaceHandle fh;
884 std::vector<typename M::FaceHandle> face_vector;
886 if (_target_state > 1) {
888 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it) {
890 face_vector.push_back(*ff_it);
893 while (!face_vector.empty()) {
895 fh = face_vector.back();
896 face_vector.pop_back();
898 Base::prev_rule()->raise(fh, _target_state - 1);
901 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it) {
903 face_vector.push_back(*ff_it);
906 while (!face_vector.empty()) {
908 fh = face_vector.back();
909 face_vector.pop_back();
911 while (MOBJ(fh).state() < _target_state - 1)
912 Base::prev_rule()->raise(fh, _target_state - 1);
917 typename M::Point position(0.0, 0.0, 0.0);
918 typename M::Scalar valence(0.0);
920 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it) {
924 position += Base::mesh_.data(*ff_it).position(_target_state - 1);
929 MOBJ(_fh).set_position(_target_state, position);
930 MOBJ(_fh).inc_state();
941 if (MOBJ(_fh).state() < _target_state) {
943 this->update(_fh, _target_state);
946 typename M::FaceFaceIter ff_it(Base::mesh_.ff_iter(_fh));
947 typename M::FaceHandle fh;
948 std::vector<typename M::FaceHandle> face_vector;
950 if (_target_state > 1)
952 for (; ff_it.is_valid(); ++ff_it)
953 face_vector.push_back(*ff_it);
955 while (!face_vector.empty())
957 fh = face_vector.back();
958 face_vector.pop_back();
959 Base::prev_rule()->raise(fh, _target_state - 1);
962 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it)
963 face_vector.push_back(*ff_it);
965 while (!face_vector.empty()) {
967 fh = face_vector.back();
968 face_vector.pop_back();
970 while (MOBJ(fh).state() < _target_state - 1)
971 Base::prev_rule()->raise(fh, _target_state - 1);
976 typename M::Point position(0.0, 0.0, 0.0);
977 typename M::Scalar valence(0.0);
979 for (ff_it = Base::mesh_.ff_iter(_fh); ff_it.is_valid(); ++ff_it)
982 position += Base::mesh_.data(*ff_it).position(_target_state - 1);
988 typename M::Scalar c = Base::coeff();
990 position *= (
static_cast<typename M::Scalar
>(1.0) - c);
991 position += MOBJ(_fh).position(_target_state - 1) * c;
993 MOBJ(_fh).set_position(_target_state, position);
994 MOBJ(_fh).inc_state();
1006 if (MOBJ(_vh).state() < _target_state) {
1008 this->update(_vh, _target_state);
1011 typename M::VertexFaceIter vf_it(Base::mesh_.vf_iter(_vh));
1012 typename M::FaceHandle fh;
1013 std::vector<typename M::FaceHandle> face_vector;
1015 if (_target_state > 1) {
1017 for (; vf_it.is_valid(); ++vf_it) {
1019 face_vector.push_back(*vf_it);
1022 while (!face_vector.empty()) {
1024 fh = face_vector.back();
1025 face_vector.pop_back();
1027 Base::prev_rule()->raise(fh, _target_state - 1);
1030 for (vf_it = Base::mesh_.vf_iter(_vh); vf_it.is_valid(); ++vf_it) {
1032 face_vector.push_back(*vf_it);
1035 while (!face_vector.empty()) {
1037 fh = face_vector.back();
1038 face_vector.pop_back();
1040 while (MOBJ(fh).state() < _target_state - 1)
1041 Base::prev_rule()->raise(fh, _target_state - 1);
1046 typename M::Point position(0.0, 0.0, 0.0);
1047 typename M::Scalar valence(0.0);
1049 for (vf_it = Base::mesh_.vf_iter(_vh); vf_it.is_valid(); ++vf_it) {
1052 position += Base::mesh_.data(*vf_it).position(_target_state - 1);
1055 position /= valence;
1057 MOBJ(_vh).set_position(_target_state, position);
1058 MOBJ(_vh).inc_state();
1060 if (Base::number() == Base::n_rules() - 1) {
1062 Base::mesh_.set_point(_vh, position);
1063 MOBJ(_vh).set_final();
1075 if (MOBJ(_vh).state() < _target_state) {
1077 this->update(_vh, _target_state);
1079 typename M::VertexOHalfedgeIter voh_it;
1080 typename M::FaceHandle fh;
1081 std::vector<typename M::FaceHandle> face_vector;
1084 face_vector.clear();
1087 if (_target_state > 1) {
1089 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1091 if (Base::mesh_.FH(*voh_it).is_valid()) {
1093 face_vector.push_back(Base::mesh_.FH(*voh_it));
1095 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
1097 face_vector.push_back(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))));
1102 while (!face_vector.empty()) {
1104 fh = face_vector.back();
1105 face_vector.pop_back();
1107 Base::prev_rule()->raise(fh, _target_state - 1);
1110 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1112 if (Base::mesh_.FH(*voh_it).is_valid()) {
1114 face_vector.push_back(Base::mesh_.FH(*voh_it));
1116 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
1118 face_vector.push_back(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))));
1123 while (!face_vector.empty()) {
1125 fh = face_vector.back();
1126 face_vector.pop_back();
1128 while (MOBJ(fh).state() < _target_state - 1)
1129 Base::prev_rule()->raise(fh, _target_state - 1);
1132 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1134 if (Base::mesh_.FH(*voh_it).is_valid()) {
1136 face_vector.push_back(Base::mesh_.FH(*voh_it));
1138 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
1140 face_vector.push_back(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))));
1145 while (!face_vector.empty()) {
1147 fh = face_vector.back();
1148 face_vector.pop_back();
1150 while (MOBJ(fh).state() < _target_state - 1)
1151 Base::prev_rule()->raise(fh, _target_state - 1);
1156 typename M::Point position(0.0, 0.0, 0.0);
1157 typename M::Scalar c;
1159 const typename M::Scalar _2pi(2.0*M_PI);
1160 const typename M::Scalar _2over3(2.0/3.0);
1162 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it; ++voh_it)
1168 c = _2over3 * ( cos( _2pi / valence) + 1.0);
1170 valence = Base::mesh_.valence(_vh);
1171 c =
typename M::Scalar(coeff(valence));
1175 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1177 fh = Base::mesh_.FH(*voh_it);
1179 Base::prev_rule()->raise(fh, _target_state - 1);
1181 fh = Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it)));
1183 Base::prev_rule()->raise(fh, _target_state - 1);
1185 if (Base::mesh_.FH(*voh_it).is_valid()) {
1187 if (Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it))).is_valid()) {
1189 position += MOBJ(Base::mesh_.FH(*voh_it)).position(_target_state - 1) * c;
1191 position += MOBJ(Base::mesh_.FH(Base::mesh_.OHEH(Base::mesh_.NHEH(*voh_it)))).position(_target_state - 1) * (
typename M::Scalar(1.0) - c);
1195 position += MOBJ(Base::mesh_.FH(*voh_it)).position(_target_state - 1);
1205 position /=
typename M::Scalar(valence);
1207 MOBJ(_vh).set_position(_target_state, position);
1208 MOBJ(_vh).inc_state();
1210 assert(MOBJ(_vh).state() == _target_state);
1213 if (Base::number() == Base::n_rules() - 1) {
1215 Base::mesh_.set_point(_vh, position);
1216 MOBJ(_vh).set_final();
1227 if ( coeffs_.size() == _max_valence+1 )
1230 if ( coeffs_.size() < _max_valence+1 )
1232 const double _2pi(2.0*M_PI);
1233 const double _2over3(2.0/3.0);
1235 if (coeffs_.empty())
1236 coeffs_.push_back(0.0);
1238 for(
size_t v=coeffs_.size(); v <= _max_valence; ++v)
1239 coeffs_.push_back(_2over3 * ( cos( _2pi / v) + 1.0));
1250 if (MOBJ(_vh).state() < _target_state)
1252 this->update(_vh, _target_state);
1255 typename M::VertexVertexIter vv_it(Base::mesh_.vv_iter(_vh));
1256 typename M::VertexHandle vh;
1257 std::vector<typename M::VertexHandle> vertex_vector;
1259 if (_target_state > 1) {
1261 for (; vv_it.is_valid(); ++vv_it) {
1263 vertex_vector.push_back(*vv_it);
1266 while (!vertex_vector.empty()) {
1268 vh = vertex_vector.back();
1269 vertex_vector.pop_back();
1271 Base::prev_rule()->raise(vh, _target_state - 1);
1274 for (; vv_it.is_valid(); ++vv_it) {
1276 vertex_vector.push_back(*vv_it);
1279 while (!vertex_vector.empty()) {
1281 vh = vertex_vector.back();
1282 vertex_vector.pop_back();
1284 Base::prev_rule()->raise(vh, _target_state - 1);
1289 typename M::Point position(0.0, 0.0, 0.0);
1290 typename M::Scalar valence(0.0);
1292 for (vv_it = Base::mesh_.vv_iter(_vh); vv_it.is_valid(); ++vv_it) {
1295 position += Base::mesh_.data(*vv_it).position(_target_state - 1);
1298 position /= valence;
1300 MOBJ(_vh).set_position(_target_state, position);
1301 MOBJ(_vh).inc_state();
1304 if (Base::number() == Base::n_rules() - 1) {
1306 Base::mesh_.set_point(_vh, position);
1307 MOBJ(_vh).set_final();
1319 if (MOBJ(_vh).state() < _target_state) {
1321 this->update(_vh, _target_state);
1324 typename M::VertexVertexIter vv_it(Base::mesh_.vv_iter(_vh));
1325 typename M::VertexHandle vh;
1326 std::vector<typename M::VertexHandle> vertex_vector;
1328 if (_target_state > 1) {
1330 for (; vv_it.is_valid(); ++vv_it) {
1332 vertex_vector.push_back(*vv_it);
1335 while (!vertex_vector.empty()) {
1337 vh = vertex_vector.back();
1338 vertex_vector.pop_back();
1340 Base::prev_rule()->raise(vh, _target_state - 1);
1343 for (; vv_it.is_valid(); ++vv_it) {
1345 vertex_vector.push_back(*vv_it);
1348 while (!vertex_vector.empty()) {
1350 vh = vertex_vector.back();
1351 vertex_vector.pop_back();
1353 Base::prev_rule()->raise(vh, _target_state - 1);
1358 typename M::Point position(0.0, 0.0, 0.0);
1359 typename M::Scalar valence(0.0);
1360 typename M::Scalar c;
1362 for (vv_it = Base::mesh_.vv_iter(_vh); vv_it.is_valid(); ++vv_it)
1365 position += Base::mesh_.data(*vv_it).position(_target_state - 1);
1368 position /= valence;
1373 position *= (
static_cast<typename M::Scalar
>(1.0) - c);
1374 position += MOBJ(_vh).position(_target_state - 1) * c;
1376 MOBJ(_vh).set_position(_target_state, position);
1377 MOBJ(_vh).inc_state();
1379 if (Base::number() == Base::n_rules() - 1)
1381 Base::mesh_.set_point(_vh, position);
1382 MOBJ(_vh).set_final();
1394 if (MOBJ(_eh).state() < _target_state) {
1396 this->update(_eh, _target_state);
1399 typename M::VertexHandle vh;
1400 typename M::HalfedgeHandle hh1(Base::mesh_.HEH(_eh, 0)),
1401 hh2(Base::mesh_.HEH(_eh, 1));
1403 if (_target_state > 1) {
1405 vh = Base::mesh_.TVH(hh1);
1407 Base::prev_rule()->raise(vh, _target_state - 1);
1409 vh = Base::mesh_.TVH(hh2);
1411 Base::prev_rule()->raise(vh, _target_state - 1);
1415 typename M::Point position(0.0, 0.0, 0.0);
1416 const typename M::Scalar valence(2.0);
1418 position += MOBJ(Base::mesh_.TVH(hh1)).position(_target_state - 1);
1419 position += MOBJ(Base::mesh_.TVH(hh2)).position(_target_state - 1);
1421 position /= valence;
1423 MOBJ(_eh).set_position(_target_state, position);
1424 MOBJ(_eh).inc_state();
1435 if (MOBJ(_eh).state() < _target_state)
1437 this->update(_eh, _target_state);
1440 typename M::VertexHandle vh;
1441 typename M::HalfedgeHandle hh1(Base::mesh_.HEH(_eh, 0)),
1442 hh2(Base::mesh_.HEH(_eh, 1));
1443 typename M::FaceHandle fh1, fh2;
1445 if (_target_state > 1) {
1447 fh1 = Base::mesh_.FH(hh1);
1448 fh2 = Base::mesh_.FH(hh2);
1450 if (fh1.is_valid()) {
1452 Base::prev_rule()->raise(fh1, _target_state - 1);
1454 vh = Base::mesh_.TVH(Base::mesh_.NHEH(hh1));
1455 Base::prev_rule()->raise(vh, _target_state - 1);
1458 if (fh2.is_valid()) {
1460 Base::prev_rule()->raise(fh2, _target_state - 1);
1462 vh = Base::mesh_.TVH(Base::mesh_.NHEH(hh2));
1463 Base::prev_rule()->raise(vh, _target_state - 1);
1466 vh = Base::mesh_.TVH(hh1);
1467 Base::prev_rule()->raise(vh, _target_state - 1);
1469 vh = Base::mesh_.TVH(hh2);
1470 Base::prev_rule()->raise(vh, _target_state - 1);
1474 typename M::Point position(0.0, 0.0, 0.0);
1475 typename M::Scalar valence(2.0);
1477 position += MOBJ(Base::mesh_.TVH(hh1)).position(_target_state - 1);
1478 position += MOBJ(Base::mesh_.TVH(hh2)).position(_target_state - 1);
1480 if (fh1.is_valid()) {
1482 position += MOBJ(Base::mesh_.TVH(Base::mesh_.NHEH(hh1))).position(_target_state - 1);
1486 if (fh2.is_valid()) {
1488 position += MOBJ(Base::mesh_.TVH(Base::mesh_.NHEH(hh2))).position(_target_state - 1);
1492 if (Base::number() == Base::subdiv_rule()->Base::number() + 1)
1495 position /= valence;
1497 MOBJ(_eh).set_position(_target_state, position);
1498 MOBJ(_eh).inc_state();
1510 if (MOBJ(_eh).state() < _target_state)
1512 this->update(_eh, _target_state);
1515 typename M::VertexHandle vh;
1516 typename M::HalfedgeHandle hh1(Base::mesh_.HEH(_eh, 0)),
1517 hh2(Base::mesh_.HEH(_eh, 1));
1518 std::vector<typename M::VertexHandle> vertex_vector;
1519 typename M::FaceHandle fh1, fh2;
1521 if (_target_state > 1) {
1523 fh1 = Base::mesh_.FH(Base::mesh_.HEH(_eh, 0));
1524 fh2 = Base::mesh_.FH(Base::mesh_.HEH(_eh, 1));
1526 Base::prev_rule()->raise(fh1, _target_state - 1);
1527 Base::prev_rule()->raise(fh2, _target_state - 1);
1529 vertex_vector.push_back(Base::mesh_.TVH(hh1));
1530 vertex_vector.push_back(Base::mesh_.TVH(hh2));
1532 vertex_vector.push_back(Base::mesh_.TVH(Base::mesh_.NHEH(hh1)));
1533 vertex_vector.push_back(Base::mesh_.TVH(Base::mesh_.NHEH(hh2)));
1535 while (!vertex_vector.empty()) {
1537 vh = vertex_vector.back();
1538 vertex_vector.pop_back();
1540 Base::prev_rule()->raise(vh, _target_state - 1);
1543 vertex_vector.push_back(Base::mesh_.TVH(hh1));
1544 vertex_vector.push_back(Base::mesh_.TVH(hh2));
1546 vertex_vector.push_back(Base::mesh_.TVH(Base::mesh_.NHEH(hh1)));
1547 vertex_vector.push_back(Base::mesh_.TVH(Base::mesh_.NHEH(hh2)));
1549 while (!vertex_vector.empty()) {
1551 vh = vertex_vector.back();
1552 vertex_vector.pop_back();
1554 Base::prev_rule()->raise(vh, _target_state - 1);
1559 typename M::Point position(0.0, 0.0, 0.0);
1560 const typename M::Scalar valence(4.0);
1561 typename M::Scalar c;
1566 position += MOBJ(Base::mesh_.TVH(hh1)).position(_target_state - 1) * c;
1567 position += MOBJ(Base::mesh_.TVH(hh2)).position(_target_state - 1) * c;
1568 position += MOBJ(Base::mesh_.TVH(Base::mesh_.NHEH(hh1))).position(_target_state - 1) * (0.5 - c);
1569 position += MOBJ(Base::mesh_.TVH(Base::mesh_.NHEH(hh2))).position(_target_state - 1) * (0.5 - c);
1571 position /= valence;
1573 MOBJ(_eh).set_position(_target_state, position);
1574 MOBJ(_eh).inc_state();
1585 if (MOBJ(_vh).state() < _target_state) {
1587 this->update(_vh, _target_state);
1590 typename M::VertexEdgeIter ve_it(Base::mesh_.ve_iter(_vh));
1591 typename M::EdgeHandle eh;
1592 std::vector<typename M::EdgeHandle> edge_vector;
1594 if (_target_state > 1) {
1596 for (; ve_it.is_valid(); ++ve_it) {
1598 edge_vector.push_back(*ve_it);
1601 while (!edge_vector.empty()) {
1603 eh = edge_vector.back();
1604 edge_vector.pop_back();
1606 Base::prev_rule()->raise(eh, _target_state - 1);
1609 for (ve_it = Base::mesh_.ve_iter(_vh); ve_it.is_valid(); ++ve_it) {
1611 edge_vector.push_back(*ve_it);
1614 while (!edge_vector.empty()) {
1616 eh = edge_vector.back();
1617 edge_vector.pop_back();
1619 while (MOBJ(eh).state() < _target_state - 1)
1620 Base::prev_rule()->raise(eh, _target_state - 1);
1625 typename M::Point position(0.0, 0.0, 0.0);
1626 typename M::Scalar valence(0.0);
1628 for (ve_it = Base::mesh_.ve_iter(_vh); ve_it.is_valid(); ++ve_it) {
1630 if (Base::mesh_.data(*ve_it).final()) {
1634 position += Base::mesh_.data(*ve_it).position(_target_state - 1);
1638 position /= valence;
1640 MOBJ(_vh).set_position(_target_state, position);
1641 MOBJ(_vh).inc_state();
1644 if (Base::number() == Base::n_rules() - 1) {
1646 Base::mesh_.set_point(_vh, position);
1647 MOBJ(_vh).set_final();
1661 if (MOBJ(_vh).state() < _target_state)
1663 this->update(_vh, _target_state);
1666 typename M::VertexOHalfedgeIter voh_it;
1667 typename M::EdgeHandle eh;
1668 typename M::FaceHandle fh;
1669 std::vector<typename M::EdgeHandle> edge_vector;
1670 std::vector<typename M::FaceHandle> face_vector;
1672 if (_target_state > 1) {
1674 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1676 face_vector.push_back(Base::mesh_.FH(*voh_it));
1679 while (!face_vector.empty()) {
1681 fh = face_vector.back();
1682 face_vector.pop_back();
1685 Base::prev_rule()->raise(fh, _target_state - 1);
1688 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
1690 edge_vector.push_back(Base::mesh_.EH(*voh_it));
1692 edge_vector.push_back(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it)));
1695 while (!edge_vector.empty()) {
1697 eh = edge_vector.back();
1698 edge_vector.pop_back();
1700 while (MOBJ(eh).state() < _target_state - 1)
1701 Base::prev_rule()->raise(eh, _target_state - 1);
1707 typename M::Point position(0.0, 0.0, 0.0);
1708 typename M::Scalar c;
1709 typename M::Point zero_point(0.0, 0.0, 0.0);
1712 valence = Base::mesh_.valence(_vh);
1713 c =
static_cast<typename M::Scalar
>(coeff( valence ));
1715 for (voh_it = Base::mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it)
1717 if (MOBJ(Base::mesh_.EH(*voh_it)).final())
1719 position += MOBJ(Base::mesh_.EH(*voh_it)).position(_target_state-1)*c;
1721 if ( Base::mesh_.FH(*voh_it).is_valid() &&
1722 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it))).final() &&
1723 MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it))).position(_target_state - 1) != zero_point)
1725 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(*voh_it))).position(_target_state-1) * (1.0-c);
1728 position += MOBJ(Base::mesh_.EH(*voh_it)).position(_target_state - 1) * (1.0 - c);
1736 position /= valence;
1738 MOBJ(_vh).set_position(_target_state, position);
1739 MOBJ(_vh).inc_state();
1742 if (Base::number() == Base::n_rules() - 1) {
1744 Base::mesh_.set_point(_vh, position);
1745 MOBJ(_vh).set_final();
1755 if ( coeffs_.size() == _max_valence+1 )
1758 if (coeffs_.size() < _max_valence+1)
1760 const double _2pi = 2.0*M_PI;
1762 if (coeffs_.empty())
1763 coeffs_.push_back(0.0);
1765 for(
size_t v=coeffs_.size(); v <= _max_valence; ++v)
1768 double c = 1.5 + cos( _2pi / v );
1769 c = c * c * 0.5 - 1.0;
1770 coeffs_.push_back(c);
1782 if (MOBJ(_fh).state() < _target_state) {
1784 this->update(_fh, _target_state);
1787 typename M::FaceEdgeIter fe_it(Base::mesh_.fe_iter(_fh));
1788 typename M::EdgeHandle eh;
1789 std::vector<typename M::EdgeHandle> edge_vector;
1791 if (_target_state > 1) {
1793 for (; fe_it.is_valid(); ++fe_it) {
1795 edge_vector.push_back(*fe_it);
1798 while (!edge_vector.empty()) {
1800 eh = edge_vector.back();
1801 edge_vector.pop_back();
1803 Base::prev_rule()->raise(eh, _target_state - 1);
1806 for (fe_it = Base::mesh_.fe_iter(_fh); fe_it.is_valid(); ++fe_it) {
1808 edge_vector.push_back(*fe_it);
1811 while (!edge_vector.empty()) {
1813 eh = edge_vector.back();
1814 edge_vector.pop_back();
1816 while (MOBJ(eh).state() < _target_state - 1)
1817 Base::prev_rule()->raise(eh, _target_state - 1);
1822 typename M::Point position(0.0, 0.0, 0.0);
1823 typename M::Scalar valence(0.0);
1825 for (fe_it = Base::mesh_.fe_iter(_fh); fe_it.is_valid(); ++fe_it) {
1827 if (Base::mesh_.data(*fe_it).final()) {
1831 position += Base::mesh_.data(*fe_it).position(_target_state - 1);
1835 assert (valence == 3.0);
1837 position /= valence;
1839 MOBJ(_fh).set_position(_target_state, position);
1840 MOBJ(_fh).inc_state();
1852 if (MOBJ(_eh).state() < _target_state) {
1854 this->update(_eh, _target_state);
1857 typename M::FaceHandle fh;
1859 if (_target_state > 1) {
1861 fh = Base::mesh_.FH(Base::mesh_.HEH(_eh, 0));
1862 Base::prev_rule()->raise(fh, _target_state - 1);
1864 fh = Base::mesh_.FH(Base::mesh_.HEH(_eh, 1));
1865 Base::prev_rule()->raise(fh, _target_state - 1);
1867 fh = Base::mesh_.FH(Base::mesh_.HEH(_eh, 0));
1868 Base::prev_rule()->raise(fh, _target_state - 1);
1870 fh = Base::mesh_.FH(Base::mesh_.HEH(_eh, 1));
1871 Base::prev_rule()->raise(fh, _target_state - 1);
1875 typename M::Point position(0.0, 0.0, 0.0);
1876 const typename M::Scalar valence(2.0);
1878 position += MOBJ(Base::mesh_.FH(Base::mesh_.HEH(_eh, 0))).position(_target_state - 1);
1880 position += MOBJ(Base::mesh_.FH(Base::mesh_.HEH(_eh, 1))).position(_target_state - 1);
1882 position /= valence;
1884 MOBJ(_eh).set_position(_target_state, position);
1885 MOBJ(_eh).inc_state();
1897 if (MOBJ(_eh).state() < _target_state) {
1899 this->update(_eh, _target_state);
1902 typename M::HalfedgeHandle hh1, hh2;
1903 typename M::FaceHandle fh;
1904 typename M::EdgeHandle eh;
1906 hh1 = Base::mesh_.HEH(_eh, 0);
1907 hh2 = Base::mesh_.HEH(_eh, 1);
1909 if (_target_state > 1) {
1911 fh = Base::mesh_.FH(hh1);
1912 Base::prev_rule()->raise(fh, _target_state - 1);
1914 fh = Base::mesh_.FH(hh2);
1915 Base::prev_rule()->raise(fh, _target_state - 1);
1917 eh = Base::mesh_.EH(Base::mesh_.NHEH(hh1));
1918 Base::prev_rule()->raise(eh, _target_state - 1);
1920 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh1));
1921 Base::prev_rule()->raise(eh, _target_state - 1);
1923 eh = Base::mesh_.EH(Base::mesh_.NHEH(hh2));
1924 Base::prev_rule()->raise(eh, _target_state - 1);
1926 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh2));
1927 Base::prev_rule()->raise(eh, _target_state - 1);
1931 typename M::Point position(0.0, 0.0, 0.0);
1932 const typename M::Scalar valence(4.0);
1934 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh1))).position(_target_state - 1);
1935 position += MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh1))).position(_target_state - 1);
1936 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh2))).position(_target_state - 1);
1937 position += MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh2))).position(_target_state - 1);
1939 position /= valence;
1941 MOBJ(_eh).set_position(_target_state, position);
1942 MOBJ(_eh).inc_state();
1954 if (MOBJ(_eh).state() < _target_state) {
1956 this->update(_eh, _target_state);
1959 typename M::HalfedgeHandle hh1, hh2;
1960 typename M::FaceHandle fh;
1961 typename M::EdgeHandle eh;
1963 hh1 = Base::mesh_.HEH(_eh, 0);
1964 hh2 = Base::mesh_.HEH(_eh, 1);
1966 if (_target_state > 1) {
1968 fh = Base::mesh_.FH(hh1);
1969 Base::prev_rule()->raise(fh, _target_state - 1);
1971 fh = Base::mesh_.FH(hh2);
1972 Base::prev_rule()->raise(fh, _target_state - 1);
1974 eh = Base::mesh_.EH(Base::mesh_.NHEH(hh1));
1975 Base::prev_rule()->raise(eh, _target_state - 1);
1977 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh1));
1978 Base::prev_rule()->raise(eh, _target_state - 1);
1980 eh = Base::mesh_.EH(Base::mesh_.NHEH(hh2));
1981 Base::prev_rule()->raise(eh, _target_state - 1);
1983 eh = Base::mesh_.EH(Base::mesh_.PHEH(hh2));
1984 Base::prev_rule()->raise(eh, _target_state - 1);
1988 typename M::Point position(0.0, 0.0, 0.0);
1989 const typename M::Scalar valence(4.0);
1990 typename M::Scalar c;
1992 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh1))).position(_target_state - 1);
1993 position += MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh1))).position(_target_state - 1);
1994 position += MOBJ(Base::mesh_.EH(Base::mesh_.NHEH(hh2))).position(_target_state - 1);
1995 position += MOBJ(Base::mesh_.EH(Base::mesh_.PHEH(hh2))).position(_target_state - 1);
1997 position /= valence;
2002 position *= (
static_cast<typename M::Scalar
>(1.0) - c);
2004 position += MOBJ(_eh).position(_target_state - 1) * c;
2006 MOBJ(_eh).set_position(_target_state, position);
2007 MOBJ(_eh).inc_state();
2011 #endif // DOXY_IGNORE_THIS 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.
Topological composite rule Tvv,4 doing a 1-4 split of a face.
Definition: RulesT.hh:115
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.
Definition: RulesT_impl.hh:338
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::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::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.
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
void raise(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
Composite rule FVc.
Definition: RulesT.hh:234
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.
Composite rule EVc.
Definition: RulesT.hh:403
CompositeTraits::state_t state_t
Adaptive Composite Subdivision framework.
Definition: CompositeTraits.hh:250
void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
Definition: RulesT_impl.hh:99
void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.