59 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC 60 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC 73 namespace Subdivider {
80 template <
typename MeshType,
typename RealType>
86 typename MeshType::VertexIter v_it(_m.vertices_begin());
88 for (; v_it != _m.vertices_end(); ++v_it)
89 _m.data(*v_it).set_position(_m.point(*v_it));
96 template<
typename MeshType,
typename RealType>
99 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
101 typename MeshType::VertexHandle vh;
102 typename MeshType::FaceIter f_it;
103 typename MeshType::EdgeIter e_it;
104 typename MeshType::VertexIter v_it;
105 typename MeshType::Point zero_point(0.0, 0.0, 0.0);
106 size_t n_edges, n_faces, n_vertices, j;
109 n_faces = mesh_.n_faces();
110 n_edges = mesh_.n_edges();
111 n_vertices = mesh_.n_vertices();
114 mesh_.reserve(n_vertices + n_faces, n_edges + 3 * n_faces, 3 * n_faces);
117 v_it = mesh_.vertices_begin();
118 for (j = 0; j < n_vertices; ++j) {
119 mesh_.data(*v_it).set_position(mesh_.data(*v_it).position() * 3.0);
124 f_it = mesh_.faces_begin();
125 for (j = 0; j < n_faces; ++j) {
127 vh = mesh_.add_vertex(zero_point);
129 mesh_.data(vh).set_position(zero_point);
131 mesh_.split(*f_it, vh);
137 std::vector<typename MeshType::EdgeHandle> edge_vector;
140 e_it = mesh_.edges_begin();
141 for (j = 0; j < n_edges; ++j) {
142 if (mesh_.is_flip_ok(*e_it)) {
145 edge_vector.push_back(*e_it);
151 while (!edge_vector.empty()) {
152 vh = mesh_.add_vertex(zero_point);
153 mesh_.data(vh).set_position(zero_point);
154 mesh_.split(edge_vector.back(), vh);
155 edge_vector.pop_back();
160 template<
typename MeshType,
typename RealType>
163 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
165 typename MeshType::VertexHandle vh;
166 typename MeshType::FaceIter f_it;
167 typename MeshType::EdgeIter e_it;
168 typename MeshType::VertexIter v_it;
169 typename MeshType::Point zero_point(0.0, 0.0, 0.0);
170 size_t n_edges, n_faces, n_vertices, j;
173 n_faces = mesh_.n_faces();
174 n_edges = mesh_.n_edges();
175 n_vertices = mesh_.n_vertices();
178 mesh_.reserve(n_vertices + n_edges, 2 * n_edges + 3 * n_faces, 4 * n_faces);
181 v_it = mesh_.vertices_begin();
182 for (j = 0; j < n_vertices; ++j) {
183 mesh_.data(*v_it).set_position(mesh_.data(*v_it).position() * 4.0);
188 e_it = mesh_.edges_begin();
189 for (j = 0; j < n_edges; ++j) {
191 vh = split_edge(mesh_.halfedge_handle(*e_it, 0));
192 mesh_.data(vh).set_position(zero_point);
198 f_it = mesh_.faces_begin();
199 for (j = 0; j < n_faces; ++j) {
200 typename MeshType::HalfedgeHandle heh1(mesh_.halfedge_handle(*f_it));
201 typename MeshType::HalfedgeHandle heh2(mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh1)));
202 typename MeshType::HalfedgeHandle heh3(mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh2)));
206 corner_cutting(heh1);
207 corner_cutting(heh2);
208 corner_cutting(heh3);
215 template<
typename MeshType,
typename RealType>
218 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
220 typename MeshType::VertexHandle vh;
221 typename MeshType::FaceIter f_it;
222 typename MeshType::EdgeIter e_it;
223 typename MeshType::VertexIter v_it;
224 typename MeshType::VertexFaceIter vf_it;
225 typename MeshType::FaceFaceIter ff_it;
226 typename MeshType::Point cog;
227 const typename MeshType::Point zero_point(0.0, 0.0, 0.0);
228 size_t n_edges, n_faces, n_vertices, j, valence;
231 n_faces = mesh_.n_faces();
232 n_edges = mesh_.n_edges();
233 n_vertices = mesh_.n_vertices();
236 mesh_.reserve(n_vertices + n_faces, n_edges + 3 * n_faces, 3 * n_faces);
239 v_it = mesh_.vertices_begin();
240 for (j = 0; j < n_vertices; ++j) {
243 for (vf_it = mesh_.vf_iter(*v_it); vf_it; ++vf_it) {
245 cog += vf_it->position();
249 v_it->set_position(cog);
254 f_it = mesh_.faces_begin();
255 for (j = 0; j < n_faces; ++j) {
257 vh = mesh_.add_vertex();
261 for (ff_it = mesh_.ff_iter(*f_it); ff_it; ++ff_it) {
263 cog += ff_it->position();
267 mesh_.split(*f_it, vh);
269 for (vf_it = mesh_.vf_iter(vh); vf_it; ++vf_it) {
270 vf_it->set_position(f_it->position());
273 mesh_.deref(vh).set_position(cog);
275 mesh_.set_point(vh, cog);
281 e_it = mesh_.edges_begin();
282 for (j = 0; j < n_edges; ++j) {
283 if (mesh_.is_flip_ok(*e_it))
291 template<
typename MeshType,
typename RealType>
294 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
296 typename MeshType::Point cog,zero_point(0.0, 0.0, 0.0);
297 typename MeshType::FaceVertexIter fv_it;
298 typename MeshType::FaceIter f_it;
300 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
302 unsigned int valence = 0;
305 for (fv_it = mesh_.fv_iter(*f_it); fv_it.is_valid(); ++fv_it) {
306 cog += mesh_.data(*fv_it).position();
310 mesh_.data(*f_it).set_position(cog);
315 template<
typename MeshType,
typename RealType>
318 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
320 unsigned int valence[3], i;
321 typename MeshType::Point cog,zero_point(0.0, 0.0, 0.0);
322 typename MeshType::Scalar alpha;
323 typename MeshType::FaceIter f_it;
324 typename MeshType::HalfedgeHandle heh;
325 typename MeshType::VertexHandle vh[3];
326 typename MeshType::VertexOHalfedgeIter voh_it;
327 typename MeshType::FaceVertexIter fv_it;
329 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
331 heh = mesh_.halfedge_handle(*f_it);
332 for (i = 0; i <= 2; ++i) {
335 vh[i] = mesh_.to_vertex_handle(heh);
337 for (voh_it = mesh_.voh_iter(vh[i]); voh_it; ++voh_it) {
341 heh = mesh_.next_halfedge_handle(heh);
344 if (valence[0] <= valence[1])
345 if (valence[0] <= valence[2])
350 if (valence[1] <= valence[2])
355 alpha = _coeff(valence[i]);
359 for (fv_it = mesh_.fv_iter(*f_it); fv_it.is_valid(); ++fv_it) {
360 if (*fv_it == vh[i]) {
361 cog += fv_it->position() * alpha;
363 cog += fv_it->position() * (1.0 - alpha) / 2.0;
367 f_it->set_position(cog);
372 template<
typename MeshType,
typename RealType>
375 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
377 unsigned int valence[3], i;
378 typename MeshType::Point cog,
379 zero_point(0.0, 0.0, 0.0);
380 typename MeshType::FaceIter f_it;
381 typename MeshType::HalfedgeHandle heh;
382 typename MeshType::VertexHandle vh[3];
383 typename MeshType::VertexOHalfedgeIter voh_it;
384 typename MeshType::FaceVertexIter fv_it;
386 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
388 heh = mesh_.halfedge_handle(*f_it);
389 for (i = 0; i <= 2; ++i) {
392 vh[i] = mesh_.to_vertex_handle(heh);
394 for (voh_it = mesh_.voh_iter(vh[i]); voh_it; ++voh_it) {
398 heh = mesh_.next_halfedge_handle(heh);
401 if (valence[0] <= valence[1])
402 if (valence[0] <= valence[2])
407 if (valence[1] <= valence[2])
414 for (fv_it = mesh_.fv_iter(*f_it); fv_it.is_valid(); ++fv_it) {
415 if (*fv_it == vh[i]) {
416 cog += fv_it->position() * _alpha;
418 cog += fv_it->position() * (1.0 - _alpha) / 2.0;
422 f_it->set_position(cog);
427 template<
typename MeshType,
typename RealType>
430 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
432 typename MeshType::Point cog,
433 zero_point(0.0, 0.0, 0.0);
434 typename MeshType::FaceFaceIter ff_it;
435 typename MeshType::FaceIter f_it;
436 std::vector<typename MeshType::Point> point_vector;
438 point_vector.clear();
440 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it)
442 unsigned int valence = 0;
445 for (ff_it = mesh_.ff_iter(*f_it); ff_it.is_valid(); ++ff_it)
447 cog += mesh_.data(*ff_it).position();
451 point_vector.push_back(cog);
454 for (f_it = mesh_.faces_end(); f_it != mesh_.faces_begin(); )
457 mesh_.data(*f_it).set_position(point_vector.back());
458 point_vector.pop_back();
463 template<
typename MeshType,
typename RealType>
466 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
468 typename MeshType::Point cog,
469 zero_point(0.0, 0.0, 0.0);
470 typename MeshType::FaceFaceIter ff_it;
471 typename MeshType::FaceIter f_it;
472 typename MeshType::Scalar c;
473 std::vector<typename MeshType::Point> point_vector;
475 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
477 unsigned int valence = 0;
480 for (ff_it = mesh_.ff_iter(*f_it); ff_it; ++ff_it) {
481 cog += ff_it->position();
488 cog = cog * (1.0 - c) + f_it->position() * c;
490 point_vector.push_back(cog);
493 for (f_it = mesh_.faces_end(); f_it != mesh_.faces_begin(); ) {
496 f_it->set_position(point_vector.back());
497 point_vector.pop_back();
503 template<
typename MeshType,
typename RealType>
506 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
508 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
509 typename MeshType::FaceFaceIter ff_it;
510 typename MeshType::FaceIter f_it;
511 std::vector<typename MeshType::Point> point_vector;
513 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
515 unsigned int valence = 0;
518 for (ff_it = mesh_.ff_iter(*f_it); ff_it; ++ff_it) {
519 cog += ff_it->position();
524 cog = cog * (1.0 - _c) + f_it->position() * _c;
526 point_vector.push_back(cog);
529 for (f_it = mesh_.faces_end(); f_it != mesh_.faces_begin(); ) {
532 f_it->set_position(point_vector.back());
533 point_vector.pop_back();
538 template<
typename MeshType,
typename RealType>
541 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
543 typename MeshType::Point cog,
544 zero_point(0.0, 0.0, 0.0);
545 typename MeshType::VertexFaceIter vf_it;
546 typename MeshType::VertexIter v_it;
548 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
550 unsigned int valence = 0;
553 for (vf_it = mesh_.vf_iter(*v_it); vf_it; ++vf_it) {
554 cog += vf_it->position();
558 v_it->set_position(cog);
563 template<
typename MeshType,
typename RealType>
566 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
569 typename MeshType::Point cog,
570 zero_point(0.0, 0.0, 0.0);
572 typename MeshType::VertexOHalfedgeIter voh_it;
573 typename MeshType::VertexIter v_it;
575 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
577 unsigned int valence = 0;
580 for (voh_it = mesh_.voh_iter(*v_it); voh_it.is_valid(); ++voh_it) {
586 for (voh_it = mesh_.voh_iter(*v_it); voh_it.is_valid(); ++voh_it) {
588 if (mesh_.face_handle(*voh_it).is_valid()) {
590 if (mesh_.face_handle(mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(*voh_it))).is_valid()) {
591 cog += mesh_.data(mesh_.face_handle(*voh_it)).position() * c;
592 cog += mesh_.data(mesh_.face_handle(mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(*voh_it)))).position() * (1.0 - c);
594 cog += mesh_.data(mesh_.face_handle(*voh_it)).position();
604 mesh_.data(*v_it).set_position(cog);
609 template<
typename MeshType,
typename RealType>
612 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
614 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
615 typename MeshType::VertexOHalfedgeIter voh_it;
616 typename MeshType::VertexIter v_it;
618 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
620 unsigned int valence = 0;
623 for (voh_it = mesh_.voh_iter(*v_it); voh_it; ++voh_it) {
627 for (voh_it = mesh_.voh_iter(*v_it); voh_it; ++voh_it) {
629 if (mesh_.face_handle(*voh_it).is_valid()) {
631 if (mesh_.face_handle(mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(*voh_it))).is_valid()) {
632 cog += mesh_.deref(mesh_.face_handle(*voh_it)).position() * _c;
633 cog += mesh_.deref(mesh_.face_handle(mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(*voh_it)))).position() * (1.0 - _c);
635 cog += mesh_.deref(mesh_.face_handle(*voh_it)).position();
645 v_it->set_position(cog);
650 template<
typename MeshType,
typename RealType>
653 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
655 typename MeshType::EdgeIter e_it;
656 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
657 typename MeshType::HalfedgeHandle heh1, heh2;
659 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
662 unsigned int valence = 2;
664 heh1 = mesh_.halfedge_handle(*e_it, 0);
665 heh2 = mesh_.opposite_halfedge_handle(heh1);
666 cog += mesh_.data(mesh_.to_vertex_handle(heh1)).position();
667 cog += mesh_.data(mesh_.to_vertex_handle(heh2)).position();
669 if (!mesh_.is_boundary(heh1)) {
670 cog += mesh_.data(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh1))).position();
674 if (!mesh_.is_boundary(heh2)) {
675 cog += mesh_.data(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh2))).position();
681 mesh_.data(*e_it).set_position(cog);
686 template<
typename MeshType,
typename RealType>
689 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
691 typename MeshType::EdgeIter e_it;
692 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
693 typename MeshType::HalfedgeHandle heh;
695 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
699 for (
int i = 0; i <= 1; ++i) {
701 heh = mesh_.halfedge_handle(*e_it, i);
702 if (!mesh_.is_boundary(heh))
704 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (0.5 - _c);
705 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * _c;
709 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position();
713 mesh_.data(*e_it).set_position(cog);
718 template<
typename MeshType,
typename RealType>
721 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
723 typename MeshType::EdgeIter e_it;
724 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
725 typename MeshType::HalfedgeHandle heh;
726 typename MeshType::VertexOHalfedgeIter voh_it;
727 unsigned int valence[2], i;
729 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
733 for (i = 0; i <= 1; ++i)
735 heh = mesh_.halfedge_handle(*e_it, i);
739 for (voh_it = mesh_.voh_iter(mesh_.to_vertex_handle(heh)); voh_it; ++voh_it)
745 if (valence[0] < valence[1])
750 heh = mesh_.halfedge_handle(*e_it, i);
752 if (!mesh_.is_boundary(heh)) {
753 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (_gamma);
754 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * (1.0 - 3.0 * _gamma);
756 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * (1.0 - 2.0 * _gamma);
760 heh = mesh_.halfedge_handle(*e_it, 1-i);
762 if (!mesh_.is_boundary(heh))
764 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (_gamma);
765 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * _gamma;
769 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * 2.0 * _gamma;
772 mesh_.data(*e_it).set_position(cog);
777 template<
typename MeshType,
typename RealType>
780 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
782 typename MeshType::EdgeIter e_it;
783 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
784 typename MeshType::HalfedgeHandle heh;
785 typename MeshType::VertexOHalfedgeIter voh_it;
786 unsigned int valence[2], i;
789 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
793 for (i = 0; i <= 1; ++i) {
795 heh = mesh_.halfedge_handle(*e_it, i);
799 for (voh_it = mesh_.voh_iter(mesh_.to_vertex_handle(heh)); voh_it; ++voh_it)
805 if (valence[0] < valence[1])
810 gamma = _coeff(valence[i]);
812 heh = mesh_.halfedge_handle(*e_it, i);
814 if (!mesh_.is_boundary(heh))
816 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (gamma);
817 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * (1.0 - 3.0 * gamma);
821 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * (1.0 - 2.0 * gamma);
825 heh = mesh_.halfedge_handle(*e_it, 1-i);
827 if (!mesh_.is_boundary(heh)) {
828 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (gamma);
829 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * gamma;
831 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * 2.0 * gamma;
834 mesh_.data(*e_it).set_position(cog);
839 template<
typename MeshType,
typename RealType>
842 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
844 typename MeshType::VertexIter v_it;
845 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
846 typename MeshType::VertexEdgeIter ve_it;
848 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it)
850 unsigned int valence = 0;
853 for (ve_it = mesh_.ve_iter(*v_it); ve_it; ++ve_it) {
854 cog += mesh_.data(ve_it).position();
860 mesh_.data(*v_it).set_position(cog);
865 template<
typename MeshType,
typename RealType>
868 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
870 typename MeshType::VertexIter v_it;
871 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
872 typename MeshType::VertexOHalfedgeIter voh_it;
875 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it)
877 unsigned int valence = 0;
880 for (voh_it = mesh_.voh_iter(*v_it); voh_it.is_valid(); ++voh_it)
887 for (voh_it = mesh_.voh_iter(*v_it); voh_it.is_valid(); ++voh_it) {
888 cog += mesh_.data(mesh_.edge_handle(*voh_it)).position() * c;
889 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(*voh_it))).position() * (1.0 - c);
894 mesh_.data(*v_it).set_position(cog);
899 template<
typename MeshType,
typename RealType>
902 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
903 typename MeshType::VertexIter v_it;
904 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
905 typename MeshType::VertexOHalfedgeIter voh_it;
907 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
908 unsigned int valence = 0;
911 for (voh_it = mesh_.voh_iter(*v_it); voh_it; ++voh_it) {
915 for (voh_it = mesh_.voh_iter(*v_it); voh_it; ++voh_it) {
916 cog += mesh_.data(mesh_.edge_handle(*voh_it)).position() * _c;
917 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(*voh_it))).position() * (1.0 - _c);
922 mesh_.data(*v_it).set_position(cog);
927 template<
typename MeshType,
typename RealType>
930 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
932 typename MeshType::FaceIter f_it;
933 typename MeshType::FaceEdgeIter fe_it;
934 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
936 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
937 unsigned int valence = 0;
940 for (fe_it = mesh_.fe_iter(*f_it); fe_it; ++fe_it) {
942 cog += mesh_.data(fe_it).position();
946 mesh_.data(*f_it).set_position(cog);
951 template<
typename MeshType,
typename RealType>
954 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
956 typename MeshType::EdgeIter e_it;
957 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
959 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
960 unsigned int valence = 0;
963 if (mesh_.face_handle(mesh_.halfedge_handle(*e_it, 0)).is_valid()) {
964 cog += mesh_.data(mesh_.face_handle(mesh_.halfedge_handle(*e_it, 0))).position();
968 if (mesh_.face_handle(mesh_.halfedge_handle(*e_it, 1)).is_valid()) {
969 cog += mesh_.data(mesh_.face_handle(mesh_.halfedge_handle(*e_it, 1))).position();
974 mesh_.data(*e_it).set_position(cog);
979 template<
typename MeshType,
typename RealType>
982 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
984 typename MeshType::EdgeIter e_it;
985 typename MeshType::Point cog;
987 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it)
989 cog = mesh_.data(mesh_.to_vertex_handle(mesh_.halfedge_handle(*e_it, 0))).position();
990 cog += mesh_.data(mesh_.to_vertex_handle(mesh_.halfedge_handle(*e_it, 1))).position();
992 mesh_.data(*e_it).set_position(cog);
997 template<
typename MeshType,
typename RealType>
1000 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1002 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
1003 typename MeshType::VertexVertexIter vv_it;
1004 typename MeshType::VertexIter v_it;
1005 std::vector<typename MeshType::Point> point_vector;
1007 point_vector.clear();
1009 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
1011 unsigned int valence = 0;
1014 for (vv_it = mesh_.vv_iter(*v_it); vv_it; ++vv_it) {
1015 cog += vv_it->position();
1019 point_vector.push_back(cog);
1022 for (v_it = mesh_.vertices_end(); v_it != mesh_.vertices_begin(); )
1025 mesh_.data(*v_it).set_position(point_vector.back());
1026 point_vector.pop_back();
1031 template<
typename MeshType,
typename RealType>
1034 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1036 typename MeshType::Point cog,
1037 zero_point(0.0, 0.0, 0.0);
1038 typename MeshType::VertexVertexIter vv_it;
1039 typename MeshType::VertexIter v_it;
1041 std::vector<typename MeshType::Point> point_vector;
1043 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it)
1045 unsigned int valence = 0;
1048 for (vv_it = mesh_.vv_iter(*v_it); vv_it; ++vv_it)
1050 cog += vv_it->position();
1054 c = _coeff(valence);
1055 cog = cog * (1 - c) + mesh_.data(*v_it).position() * c;
1056 point_vector.push_back(cog);
1058 for (v_it = mesh_.vertices_end(); v_it != mesh_.vertices_begin(); )
1061 mesh_.data(*v_it).set_position(point_vector.back());
1062 point_vector.pop_back();
1067 template<
typename MeshType,
typename RealType>
1070 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1072 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
1073 typename MeshType::VertexVertexIter vv_it;
1074 typename MeshType::VertexIter v_it;
1075 std::vector<typename MeshType::Point> point_vector;
1077 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
1079 unsigned int valence = 0;
1082 for (vv_it = mesh_.vv_iter(*v_it); vv_it; ++vv_it) {
1083 cog += mesh_.data(vv_it).position();
1088 cog = cog * (1.0 - _c) + v_it->position() * _c;
1090 point_vector.push_back(cog);
1093 for (v_it = mesh_.vertices_end(); v_it != mesh_.vertices_begin(); ) {
1096 mesh_.data(*v_it).set_position(point_vector.back());
1097 point_vector.pop_back();
1103 template<
typename MeshType,
typename RealType>
1106 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1108 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
1109 typename MeshType::EdgeIter e_it;
1110 typename MeshType::HalfedgeHandle heh;
1111 std::vector<typename MeshType::Point> point_vector;
1113 point_vector.clear();
1115 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
1117 unsigned int valence = 0;
1120 for (
int i = 0; i <= 1; ++i) {
1121 heh = mesh_.halfedge_handle(*e_it, i);
1122 if (mesh_.face_handle(heh).is_valid())
1124 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(heh))).position();
1125 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh)))).position();
1132 point_vector.push_back(cog);
1135 for (e_it = mesh_.edges_end(); e_it != mesh_.edges_begin(); )
1138 mesh_.data(*e_it).set_position(point_vector.back());
1139 point_vector.pop_back();
1144 template<
typename MeshType,
typename RealType>
1147 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1149 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
1150 typename MeshType::EdgeIter e_it;
1151 typename MeshType::HalfedgeHandle heh;
1152 std::vector<typename MeshType::Point> point_vector;
1154 point_vector.clear();
1156 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it)
1158 unsigned int valence = 0;
1161 for (
int i = 0; i <= 1; ++i) {
1162 heh = mesh_.halfedge_handle(*e_it, i);
1163 if (mesh_.face_handle(heh).is_valid())
1165 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(heh))).position() * (1.0 - _c);
1166 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh)))).position() * (1.0 - _c);
1173 cog += mesh_.data(e_it).position() * _c;
1174 point_vector.push_back(cog);
1177 for (e_it = mesh_.edges_end(); e_it != mesh_.edges_begin(); ) {
1180 mesh_.data(*e_it).set_position(point_vector.back());
1181 point_vector.pop_back();
1187 template<
typename MeshType,
typename RealType>
1190 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1193 typename MeshType::HalfedgeHandle heh5(_heh);
1194 typename MeshType::HalfedgeHandle heh6(mesh_.next_halfedge_handle(_heh));
1197 for (; mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh5)) != _heh;
1198 heh5 = mesh_.next_halfedge_handle(heh5)) {};
1200 typename MeshType::HalfedgeHandle heh2(mesh_.next_halfedge_handle(heh5));
1201 typename MeshType::HalfedgeHandle
1202 heh3(mesh_.new_edge(mesh_.to_vertex_handle(_heh),
1203 mesh_.to_vertex_handle(heh5)));
1204 typename MeshType::HalfedgeHandle heh4(mesh_.opposite_halfedge_handle(heh3));
1207 typename MeshType::FaceHandle fh_old(mesh_.face_handle(heh6));
1208 typename MeshType::FaceHandle fh_new(mesh_.new_face());
1211 mesh_.data(fh_new).set_position(mesh_.data(fh_old).position());
1214 mesh_.set_next_halfedge_handle(heh4, heh6);
1215 mesh_.set_next_halfedge_handle(heh5, heh4);
1217 mesh_.set_face_handle(heh4, fh_old);
1218 mesh_.set_face_handle(heh5, fh_old);
1219 mesh_.set_face_handle(heh6, fh_old);
1220 mesh_.set_halfedge_handle(fh_old, heh4);
1223 mesh_.set_next_halfedge_handle(_heh, heh3);
1224 mesh_.set_next_halfedge_handle(heh3, heh2);
1226 mesh_.set_face_handle(_heh, fh_new);
1227 mesh_.set_face_handle(heh2, fh_new);
1228 mesh_.set_face_handle(heh3, fh_new);
1230 mesh_.set_halfedge_handle(fh_new, _heh);
1235 template<
typename MeshType,
typename RealType>
1236 typename MeshType::VertexHandle
1239 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1241 HalfedgeHandle heh1;
1242 HalfedgeHandle heh2;
1243 HalfedgeHandle heh3;
1244 HalfedgeHandle temp_heh;
1248 vh1(mesh_.to_vertex_handle(_heh)),
1249 vh2(mesh_.from_vertex_handle(_heh));
1252 vh = mesh_.
add_vertex((mesh_.point(vh2) + mesh_.point(vh1)) / 2.0);
1254 heh2 = mesh_.opposite_halfedge_handle(_heh);
1256 if (!mesh_.is_boundary(mesh_.edge_handle(_heh))) {
1258 for (temp_heh = mesh_.next_halfedge_handle(heh2);
1259 mesh_.next_halfedge_handle(temp_heh) != heh2;
1260 temp_heh = mesh_.next_halfedge_handle(temp_heh) ) {}
1262 for (temp_heh = _heh;
1263 mesh_.next_halfedge_handle(temp_heh) != heh2;
1264 temp_heh = mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(temp_heh))) {}
1267 heh1 = mesh_.new_edge(vh, vh1);
1268 heh3 = mesh_.opposite_halfedge_handle(heh1);
1269 mesh_.set_vertex_handle(_heh, vh);
1270 mesh_.set_next_halfedge_handle(temp_heh, heh3);
1271 mesh_.set_next_halfedge_handle(heh1, mesh_.next_halfedge_handle(_heh));
1272 mesh_.set_next_halfedge_handle(_heh, heh1);
1273 mesh_.set_next_halfedge_handle(heh3, heh2);
1274 if (mesh_.face_handle(heh2).is_valid()) {
1275 mesh_.set_face_handle(heh3, mesh_.face_handle(heh2));
1276 mesh_.set_halfedge_handle(mesh_.face_handle(heh3), heh3);
1278 mesh_.set_face_handle(heh1, mesh_.face_handle(_heh));
1279 mesh_.set_halfedge_handle(vh, heh1);
1280 mesh_.set_halfedge_handle(mesh_.face_handle(_heh), _heh);
1281 mesh_.set_halfedge_handle(vh1, heh3);
1292 #endif // OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC defined void VFa(Coeff &_coeff)
Vertex to Face Averaging, weighted.
void Tvv3()
Split Face, using Vertex information (1-3 split)
void EVc(Coeff &_coeff)
Weighted edge to vertex averaging.
void EF()
Edge to face averaging.
void VdE()
Vertex to edge averaging, using diamond of edges.
void FE()
Face to edge averaging.
void VE()
VE Step (Vertex to Edge Averaging)
void VdEc(scalar_t _c)
Weighted vertex to edge averaging, using diamond of edges.
VertexHandle split_edge(HalfedgeHandle _heh)
Split Edge.
bool prepare(MeshType &_m)
Prepare mesh, e.g. add properties.
void Tvv4()
Split Face, using Vertex information (1-4 split)
void VVc(Coeff &_coeff)
Vertex to vertex averaging, weighted.
void EdE()
Edge to edge averaging w/ flap rule.
void VF()
Vertex to Face Averaging.
Abstract base class for coefficient functions.
void FF()
Face to face averaging.
void FVc(Coeff &_coeff)
Weighted face to vertex Averaging with flaps.
void FFc(Coeff &_coeff)
Weighted face to face averaging.
void corner_cutting(HalfedgeHandle _heh)
Corner Cutting.
void Tfv()
Split Face, using Face Information.
void EV()
Edge to vertex averaging.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
void EdEc(scalar_t _c)
Weighted edge to edge averaging w/ flap rule.
void FV()
Face to vertex averaging.
void VV()
Vertex to vertex averaging.