54 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC 55 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC 68 namespace Subdivider {
75 template <
typename MeshType,
typename RealType>
81 typename MeshType::VertexIter v_it(_m.vertices_begin());
83 for (; v_it != _m.vertices_end(); ++v_it)
84 _m.data(*v_it).set_position(_m.point(*v_it));
91 template<
typename MeshType,
typename RealType>
94 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
96 typename MeshType::VertexHandle vh;
97 typename MeshType::FaceIter f_it;
98 typename MeshType::EdgeIter e_it;
99 typename MeshType::VertexIter v_it;
100 typename MeshType::Point zero_point(0.0, 0.0, 0.0);
101 size_t n_edges, n_faces, n_vertices, j;
104 n_faces = mesh_.n_faces();
105 n_edges = mesh_.n_edges();
106 n_vertices = mesh_.n_vertices();
109 mesh_.reserve(n_vertices + n_faces, n_edges + 3 * n_faces, 3 * n_faces);
112 v_it = mesh_.vertices_begin();
113 for (j = 0; j < n_vertices; ++j) {
114 mesh_.data(*v_it).set_position(mesh_.data(*v_it).position() *
static_cast<typename MeshType::Point::value_type
>(3.0) );
119 f_it = mesh_.faces_begin();
120 for (j = 0; j < n_faces; ++j) {
122 vh = mesh_.add_vertex(zero_point);
124 mesh_.data(vh).set_position(zero_point);
126 mesh_.split(*f_it, vh);
132 std::vector<typename MeshType::EdgeHandle> edge_vector;
135 e_it = mesh_.edges_begin();
136 for (j = 0; j < n_edges; ++j) {
137 if (mesh_.is_flip_ok(*e_it)) {
140 edge_vector.push_back(*e_it);
146 while (!edge_vector.empty()) {
147 vh = mesh_.add_vertex(zero_point);
148 mesh_.data(vh).set_position(zero_point);
149 mesh_.split(edge_vector.back(), vh);
150 edge_vector.pop_back();
155 template<
typename MeshType,
typename RealType>
158 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
160 typename MeshType::VertexHandle vh;
161 typename MeshType::FaceIter f_it;
162 typename MeshType::EdgeIter e_it;
163 typename MeshType::VertexIter v_it;
164 typename MeshType::Point zero_point(0.0, 0.0, 0.0);
165 size_t n_edges, n_faces, n_vertices, j;
168 n_faces = mesh_.n_faces();
169 n_edges = mesh_.n_edges();
170 n_vertices = mesh_.n_vertices();
173 mesh_.reserve(n_vertices + n_edges, 2 * n_edges + 3 * n_faces, 4 * n_faces);
176 v_it = mesh_.vertices_begin();
177 for (j = 0; j < n_vertices; ++j) {
178 mesh_.data(*v_it).set_position(mesh_.data(*v_it).position() *
static_cast<typename MeshType::Point::value_type
>(4.0) );
183 e_it = mesh_.edges_begin();
184 for (j = 0; j < n_edges; ++j) {
186 vh = split_edge(mesh_.halfedge_handle(*e_it, 0));
187 mesh_.data(vh).set_position(zero_point);
193 f_it = mesh_.faces_begin();
194 for (j = 0; j < n_faces; ++j) {
195 typename MeshType::HalfedgeHandle heh1(mesh_.halfedge_handle(*f_it));
196 typename MeshType::HalfedgeHandle heh2(mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh1)));
197 typename MeshType::HalfedgeHandle heh3(mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh2)));
201 corner_cutting(heh1);
202 corner_cutting(heh2);
203 corner_cutting(heh3);
210 template<
typename MeshType,
typename RealType>
213 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
215 typename MeshType::VertexHandle vh;
216 typename MeshType::FaceIter f_it;
217 typename MeshType::EdgeIter e_it;
218 typename MeshType::VertexIter v_it;
219 typename MeshType::VertexFaceIter vf_it;
220 typename MeshType::FaceFaceIter ff_it;
221 typename MeshType::Point cog;
222 const typename MeshType::Point zero_point(0.0, 0.0, 0.0);
223 size_t n_edges, n_faces, n_vertices, j, valence;
226 n_faces = mesh_.n_faces();
227 n_edges = mesh_.n_edges();
228 n_vertices = mesh_.n_vertices();
231 mesh_.reserve(n_vertices + n_faces, n_edges + 3 * n_faces, 3 * n_faces);
234 v_it = mesh_.vertices_begin();
235 for (j = 0; j < n_vertices; ++j) {
238 for (vf_it = mesh_.vf_iter(*v_it); vf_it; ++vf_it) {
240 cog += vf_it->position();
244 v_it->set_position(cog);
249 f_it = mesh_.faces_begin();
250 for (j = 0; j < n_faces; ++j) {
252 vh = mesh_.add_vertex();
256 for (ff_it = mesh_.ff_iter(*f_it); ff_it; ++ff_it) {
258 cog += ff_it->position();
262 mesh_.split(*f_it, vh);
264 for (vf_it = mesh_.vf_iter(vh); vf_it; ++vf_it) {
265 vf_it->set_position(f_it->position());
268 mesh_.deref(vh).set_position(cog);
270 mesh_.set_point(vh, cog);
276 e_it = mesh_.edges_begin();
277 for (j = 0; j < n_edges; ++j) {
278 if (mesh_.is_flip_ok(*e_it))
286 template<
typename MeshType,
typename RealType>
289 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
291 typename MeshType::Point cog,zero_point(0.0, 0.0, 0.0);
292 typename MeshType::FaceVertexIter fv_it;
293 typename MeshType::FaceIter f_it;
295 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
297 unsigned int valence = 0;
300 for (fv_it = mesh_.fv_iter(*f_it); fv_it.is_valid(); ++fv_it) {
301 cog += mesh_.data(*fv_it).position();
305 mesh_.data(*f_it).set_position(cog);
310 template<
typename MeshType,
typename RealType>
313 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
315 unsigned int valence[3], i;
316 typename MeshType::Point cog,zero_point(0.0, 0.0, 0.0);
317 typename MeshType::Scalar alpha;
318 typename MeshType::FaceIter f_it;
319 typename MeshType::HalfedgeHandle heh;
320 typename MeshType::VertexHandle vh[3];
321 typename MeshType::VertexOHalfedgeIter voh_it;
322 typename MeshType::FaceVertexIter fv_it;
324 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
326 heh = mesh_.halfedge_handle(*f_it);
327 for (i = 0; i <= 2; ++i) {
330 vh[i] = mesh_.to_vertex_handle(heh);
332 for (voh_it = mesh_.voh_iter(vh[i]); voh_it; ++voh_it) {
336 heh = mesh_.next_halfedge_handle(heh);
339 if (valence[0] <= valence[1])
340 if (valence[0] <= valence[2])
345 if (valence[1] <= valence[2])
350 alpha = _coeff(valence[i]);
354 for (fv_it = mesh_.fv_iter(*f_it); fv_it.is_valid(); ++fv_it) {
355 if (*fv_it == vh[i]) {
356 cog += fv_it->position() * alpha;
358 cog += fv_it->position() * (1.0 - alpha) / 2.0;
362 f_it->set_position(cog);
367 template<
typename MeshType,
typename RealType>
370 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
372 unsigned int valence[3], i;
373 typename MeshType::Point cog,
374 zero_point(0.0, 0.0, 0.0);
375 typename MeshType::FaceIter f_it;
376 typename MeshType::HalfedgeHandle heh;
377 typename MeshType::VertexHandle vh[3];
378 typename MeshType::VertexOHalfedgeIter voh_it;
379 typename MeshType::FaceVertexIter fv_it;
381 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
383 heh = mesh_.halfedge_handle(*f_it);
384 for (i = 0; i <= 2; ++i) {
387 vh[i] = mesh_.to_vertex_handle(heh);
389 for (voh_it = mesh_.voh_iter(vh[i]); voh_it; ++voh_it) {
393 heh = mesh_.next_halfedge_handle(heh);
396 if (valence[0] <= valence[1])
397 if (valence[0] <= valence[2])
402 if (valence[1] <= valence[2])
409 for (fv_it = mesh_.fv_iter(*f_it); fv_it.is_valid(); ++fv_it) {
410 if (*fv_it == vh[i]) {
411 cog += fv_it->position() * _alpha;
413 cog += fv_it->position() * (1.0 - _alpha) / 2.0;
417 f_it->set_position(cog);
422 template<
typename MeshType,
typename RealType>
425 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
427 typename MeshType::Point cog,
428 zero_point(0.0, 0.0, 0.0);
429 typename MeshType::FaceFaceIter ff_it;
430 typename MeshType::FaceIter f_it;
431 std::vector<typename MeshType::Point> point_vector;
433 point_vector.clear();
435 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it)
437 unsigned int valence = 0;
440 for (ff_it = mesh_.ff_iter(*f_it); ff_it.is_valid(); ++ff_it)
442 cog += mesh_.data(*ff_it).position();
446 point_vector.push_back(cog);
449 for (f_it = mesh_.faces_end(); f_it != mesh_.faces_begin(); )
452 mesh_.data(*f_it).set_position(point_vector.back());
453 point_vector.pop_back();
458 template<
typename MeshType,
typename RealType>
461 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
463 typename MeshType::Point cog,
464 zero_point(0.0, 0.0, 0.0);
465 typename MeshType::FaceFaceIter ff_it;
466 typename MeshType::FaceIter f_it;
467 typename MeshType::Scalar c;
468 std::vector<typename MeshType::Point> point_vector;
470 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
472 unsigned int valence = 0;
475 for (ff_it = mesh_.ff_iter(*f_it); ff_it; ++ff_it) {
476 cog += ff_it->position();
483 cog = cog * (1.0 - c) + f_it->position() * c;
485 point_vector.push_back(cog);
488 for (f_it = mesh_.faces_end(); f_it != mesh_.faces_begin(); ) {
491 f_it->set_position(point_vector.back());
492 point_vector.pop_back();
498 template<
typename MeshType,
typename RealType>
501 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
503 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
504 typename MeshType::FaceFaceIter ff_it;
505 typename MeshType::FaceIter f_it;
506 std::vector<typename MeshType::Point> point_vector;
508 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
510 unsigned int valence = 0;
513 for (ff_it = mesh_.ff_iter(*f_it); ff_it; ++ff_it) {
514 cog += ff_it->position();
519 cog = cog * (1.0 - _c) + f_it->position() * _c;
521 point_vector.push_back(cog);
524 for (f_it = mesh_.faces_end(); f_it != mesh_.faces_begin(); ) {
527 f_it->set_position(point_vector.back());
528 point_vector.pop_back();
533 template<
typename MeshType,
typename RealType>
536 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
538 typename MeshType::Point cog,
539 zero_point(0.0, 0.0, 0.0);
540 typename MeshType::VertexFaceIter vf_it;
541 typename MeshType::VertexIter v_it;
543 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
545 unsigned int valence = 0;
548 for (vf_it = mesh_.vf_iter(*v_it); vf_it; ++vf_it) {
549 cog += vf_it->position();
553 v_it->set_position(cog);
558 template<
typename MeshType,
typename RealType>
561 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
564 typename MeshType::Point cog,
565 zero_point(0.0, 0.0, 0.0);
567 typename MeshType::VertexOHalfedgeIter voh_it;
568 typename MeshType::VertexIter v_it;
570 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
572 unsigned int valence = 0;
575 for (voh_it = mesh_.voh_iter(*v_it); voh_it.is_valid(); ++voh_it) {
579 c =
static_cast<real_t
>(_coeff(valence));
581 for (voh_it = mesh_.voh_iter(*v_it); voh_it.is_valid(); ++voh_it) {
583 if (mesh_.face_handle(*voh_it).is_valid()) {
585 if (mesh_.face_handle(mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(*voh_it))).is_valid()) {
586 cog += mesh_.data(mesh_.face_handle(*voh_it)).position() * c;
587 cog += mesh_.data(mesh_.face_handle(mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(*voh_it)))).position() * (
static_cast<typename MeshType::Point::value_type
>(1.0) - c);
589 cog += mesh_.data(mesh_.face_handle(*voh_it)).position();
599 mesh_.data(*v_it).set_position(cog);
604 template<
typename MeshType,
typename RealType>
607 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
609 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
610 typename MeshType::VertexOHalfedgeIter voh_it;
611 typename MeshType::VertexIter v_it;
613 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
615 unsigned int valence = 0;
618 for (voh_it = mesh_.voh_iter(*v_it); voh_it; ++voh_it) {
622 for (voh_it = mesh_.voh_iter(*v_it); voh_it; ++voh_it) {
624 if (mesh_.face_handle(*voh_it).is_valid()) {
626 if (mesh_.face_handle(mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(*voh_it))).is_valid()) {
627 cog += mesh_.deref(mesh_.face_handle(*voh_it)).position() * _c;
628 cog += mesh_.deref(mesh_.face_handle(mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(*voh_it)))).position() * (1.0 - _c);
630 cog += mesh_.deref(mesh_.face_handle(*voh_it)).position();
640 v_it->set_position(cog);
645 template<
typename MeshType,
typename RealType>
648 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
650 typename MeshType::EdgeIter e_it;
651 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
652 typename MeshType::HalfedgeHandle heh1, heh2;
654 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
657 unsigned int valence = 2;
659 heh1 = mesh_.halfedge_handle(*e_it, 0);
660 heh2 = mesh_.opposite_halfedge_handle(heh1);
661 cog += mesh_.data(mesh_.to_vertex_handle(heh1)).position();
662 cog += mesh_.data(mesh_.to_vertex_handle(heh2)).position();
664 if (!mesh_.is_boundary(heh1)) {
665 cog += mesh_.data(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh1))).position();
669 if (!mesh_.is_boundary(heh2)) {
670 cog += mesh_.data(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh2))).position();
676 mesh_.data(*e_it).set_position(cog);
681 template<
typename MeshType,
typename RealType>
684 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
686 typename MeshType::EdgeIter e_it;
687 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
688 typename MeshType::HalfedgeHandle heh;
690 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
694 for (
int i = 0; i <= 1; ++i) {
696 heh = mesh_.halfedge_handle(*e_it, i);
697 if (!mesh_.is_boundary(heh))
699 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (0.5 - _c);
700 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * _c;
704 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position();
708 mesh_.data(*e_it).set_position(cog);
713 template<
typename MeshType,
typename RealType>
716 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
718 typename MeshType::EdgeIter e_it;
719 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
720 typename MeshType::HalfedgeHandle heh;
721 typename MeshType::VertexOHalfedgeIter voh_it;
722 unsigned int valence[2], i;
724 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
728 for (i = 0; i <= 1; ++i)
730 heh = mesh_.halfedge_handle(*e_it, i);
734 for (voh_it = mesh_.voh_iter(mesh_.to_vertex_handle(heh)); voh_it; ++voh_it)
740 if (valence[0] < valence[1])
745 heh = mesh_.halfedge_handle(*e_it, i);
747 if (!mesh_.is_boundary(heh)) {
748 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (_gamma);
749 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * (1.0 - 3.0 * _gamma);
751 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * (1.0 - 2.0 * _gamma);
755 heh = mesh_.halfedge_handle(*e_it, 1-i);
757 if (!mesh_.is_boundary(heh))
759 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (_gamma);
760 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * _gamma;
764 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * 2.0 * _gamma;
767 mesh_.data(*e_it).set_position(cog);
772 template<
typename MeshType,
typename RealType>
775 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
777 typename MeshType::EdgeIter e_it;
778 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
779 typename MeshType::HalfedgeHandle heh;
780 typename MeshType::VertexOHalfedgeIter voh_it;
781 unsigned int valence[2], i;
784 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
788 for (i = 0; i <= 1; ++i) {
790 heh = mesh_.halfedge_handle(*e_it, i);
794 for (voh_it = mesh_.voh_iter(mesh_.to_vertex_handle(heh)); voh_it; ++voh_it)
800 if (valence[0] < valence[1])
805 gamma = _coeff(valence[i]);
807 heh = mesh_.halfedge_handle(*e_it, i);
809 if (!mesh_.is_boundary(heh))
811 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (gamma);
812 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * (1.0 - 3.0 * gamma);
816 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * (1.0 - 2.0 * gamma);
820 heh = mesh_.halfedge_handle(*e_it, 1-i);
822 if (!mesh_.is_boundary(heh)) {
823 cog += mesh_.point(mesh_.to_vertex_handle(mesh_.next_halfedge_handle(heh))) * (gamma);
824 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * gamma;
826 cog += mesh_.data(mesh_.to_vertex_handle(heh)).position() * 2.0 * gamma;
829 mesh_.data(*e_it).set_position(cog);
834 template<
typename MeshType,
typename RealType>
837 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
839 typename MeshType::VertexIter v_it;
840 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
841 typename MeshType::VertexEdgeIter ve_it;
843 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it)
845 unsigned int valence = 0;
848 for (ve_it = mesh_.ve_iter(*v_it); ve_it; ++ve_it) {
849 cog += mesh_.data(ve_it).position();
855 mesh_.data(*v_it).set_position(cog);
860 template<
typename MeshType,
typename RealType>
863 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
865 typename MeshType::VertexIter v_it;
866 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
867 typename MeshType::VertexOHalfedgeIter voh_it;
870 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it)
872 unsigned int valence = 0;
875 for (voh_it = mesh_.voh_iter(*v_it); voh_it.is_valid(); ++voh_it)
881 c =
static_cast<scalar_t
>(_coeff(valence));
883 for (voh_it = mesh_.voh_iter(*v_it); voh_it.is_valid(); ++voh_it) {
884 cog += mesh_.data(mesh_.edge_handle(*voh_it)).position() * c;
885 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(*voh_it))).position() * (1.0 - c);
890 mesh_.data(*v_it).set_position(cog);
895 template<
typename MeshType,
typename RealType>
898 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
899 typename MeshType::VertexIter v_it;
900 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
901 typename MeshType::VertexOHalfedgeIter voh_it;
903 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
904 unsigned int valence = 0;
907 for (voh_it = mesh_.voh_iter(*v_it); voh_it; ++voh_it) {
911 for (voh_it = mesh_.voh_iter(*v_it); voh_it; ++voh_it) {
912 cog += mesh_.data(mesh_.edge_handle(*voh_it)).position() * _c;
913 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(*voh_it))).position() * (1.0 - _c);
918 mesh_.data(*v_it).set_position(cog);
923 template<
typename MeshType,
typename RealType>
926 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
928 typename MeshType::FaceIter f_it;
929 typename MeshType::FaceEdgeIter fe_it;
930 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
932 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
933 unsigned int valence = 0;
936 for (fe_it = mesh_.fe_iter(*f_it); fe_it; ++fe_it) {
938 cog += mesh_.data(fe_it).position();
942 mesh_.data(*f_it).set_position(cog);
947 template<
typename MeshType,
typename RealType>
950 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
952 typename MeshType::EdgeIter e_it;
953 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
955 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
956 unsigned int valence = 0;
959 if (mesh_.face_handle(mesh_.halfedge_handle(*e_it, 0)).is_valid()) {
960 cog += mesh_.data(mesh_.face_handle(mesh_.halfedge_handle(*e_it, 0))).position();
964 if (mesh_.face_handle(mesh_.halfedge_handle(*e_it, 1)).is_valid()) {
965 cog += mesh_.data(mesh_.face_handle(mesh_.halfedge_handle(*e_it, 1))).position();
970 mesh_.data(*e_it).set_position(cog);
975 template<
typename MeshType,
typename RealType>
978 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
980 typename MeshType::EdgeIter e_it;
981 typename MeshType::Point cog;
983 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it)
985 cog = mesh_.data(mesh_.to_vertex_handle(mesh_.halfedge_handle(*e_it, 0))).position();
986 cog += mesh_.data(mesh_.to_vertex_handle(mesh_.halfedge_handle(*e_it, 1))).position();
988 mesh_.data(*e_it).set_position(cog);
993 template<
typename MeshType,
typename RealType>
996 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
998 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
999 typename MeshType::VertexVertexIter vv_it;
1000 typename MeshType::VertexIter v_it;
1001 std::vector<typename MeshType::Point> point_vector;
1003 point_vector.clear();
1005 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
1007 unsigned int valence = 0;
1010 for (vv_it = mesh_.vv_iter(*v_it); vv_it; ++vv_it) {
1011 cog += vv_it->position();
1015 point_vector.push_back(cog);
1018 for (v_it = mesh_.vertices_end(); v_it != mesh_.vertices_begin(); )
1021 mesh_.data(*v_it).set_position(point_vector.back());
1022 point_vector.pop_back();
1027 template<
typename MeshType,
typename RealType>
1030 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1032 typename MeshType::Point cog,
1033 zero_point(0.0, 0.0, 0.0);
1034 typename MeshType::VertexVertexIter vv_it;
1035 typename MeshType::VertexIter v_it;
1037 std::vector<typename MeshType::Point> point_vector;
1039 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it)
1041 unsigned int valence = 0;
1044 for (vv_it = mesh_.vv_iter(*v_it); vv_it; ++vv_it)
1046 cog += vv_it->position();
1050 c = _coeff(valence);
1051 cog = cog * (1 - c) + mesh_.data(*v_it).position() * c;
1052 point_vector.push_back(cog);
1054 for (v_it = mesh_.vertices_end(); v_it != mesh_.vertices_begin(); )
1057 mesh_.data(*v_it).set_position(point_vector.back());
1058 point_vector.pop_back();
1063 template<
typename MeshType,
typename RealType>
1066 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1068 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
1069 typename MeshType::VertexVertexIter vv_it;
1070 typename MeshType::VertexIter v_it;
1071 std::vector<typename MeshType::Point> point_vector;
1073 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
1075 unsigned int valence = 0;
1078 for (vv_it = mesh_.vv_iter(*v_it); vv_it; ++vv_it) {
1079 cog += mesh_.data(vv_it).position();
1084 cog = cog * (1.0 - _c) + v_it->position() * _c;
1086 point_vector.push_back(cog);
1089 for (v_it = mesh_.vertices_end(); v_it != mesh_.vertices_begin(); ) {
1092 mesh_.data(*v_it).set_position(point_vector.back());
1093 point_vector.pop_back();
1099 template<
typename MeshType,
typename RealType>
1102 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1104 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
1105 typename MeshType::EdgeIter e_it;
1106 typename MeshType::HalfedgeHandle heh;
1107 std::vector<typename MeshType::Point> point_vector;
1109 point_vector.clear();
1111 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it) {
1113 unsigned int valence = 0;
1116 for (
int i = 0; i <= 1; ++i) {
1117 heh = mesh_.halfedge_handle(*e_it, i);
1118 if (mesh_.face_handle(heh).is_valid())
1120 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(heh))).position();
1121 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh)))).position();
1128 point_vector.push_back(cog);
1131 for (e_it = mesh_.edges_end(); e_it != mesh_.edges_begin(); )
1134 mesh_.data(*e_it).set_position(point_vector.back());
1135 point_vector.pop_back();
1140 template<
typename MeshType,
typename RealType>
1143 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1145 typename MeshType::Point cog, zero_point(0.0, 0.0, 0.0);
1146 typename MeshType::EdgeIter e_it;
1147 typename MeshType::HalfedgeHandle heh;
1148 std::vector<typename MeshType::Point> point_vector;
1150 point_vector.clear();
1152 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it)
1154 unsigned int valence = 0;
1157 for (
int i = 0; i <= 1; ++i) {
1158 heh = mesh_.halfedge_handle(*e_it, i);
1159 if (mesh_.face_handle(heh).is_valid())
1161 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(heh))).position() * (1.0 - _c);
1162 cog += mesh_.data(mesh_.edge_handle(mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh)))).position() * (1.0 - _c);
1169 cog += mesh_.data(e_it).position() * _c;
1170 point_vector.push_back(cog);
1173 for (e_it = mesh_.edges_end(); e_it != mesh_.edges_begin(); ) {
1176 mesh_.data(*e_it).set_position(point_vector.back());
1177 point_vector.pop_back();
1183 template<
typename MeshType,
typename RealType>
1186 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1189 typename MeshType::HalfedgeHandle heh5(_heh);
1190 typename MeshType::HalfedgeHandle heh6(mesh_.next_halfedge_handle(_heh));
1193 for (; mesh_.next_halfedge_handle(mesh_.next_halfedge_handle(heh5)) != _heh;
1194 heh5 = mesh_.next_halfedge_handle(heh5)) {};
1196 typename MeshType::HalfedgeHandle heh2(mesh_.next_halfedge_handle(heh5));
1197 typename MeshType::HalfedgeHandle
1198 heh3(mesh_.new_edge(mesh_.to_vertex_handle(_heh),
1199 mesh_.to_vertex_handle(heh5)));
1200 typename MeshType::HalfedgeHandle heh4(mesh_.opposite_halfedge_handle(heh3));
1203 typename MeshType::FaceHandle fh_old(mesh_.face_handle(heh6));
1204 typename MeshType::FaceHandle fh_new(mesh_.new_face());
1207 mesh_.data(fh_new).set_position(mesh_.data(fh_old).position());
1210 mesh_.set_next_halfedge_handle(heh4, heh6);
1211 mesh_.set_next_halfedge_handle(heh5, heh4);
1213 mesh_.set_face_handle(heh4, fh_old);
1214 mesh_.set_face_handle(heh5, fh_old);
1215 mesh_.set_face_handle(heh6, fh_old);
1216 mesh_.set_halfedge_handle(fh_old, heh4);
1219 mesh_.set_next_halfedge_handle(_heh, heh3);
1220 mesh_.set_next_halfedge_handle(heh3, heh2);
1222 mesh_.set_face_handle(_heh, fh_new);
1223 mesh_.set_face_handle(heh2, fh_new);
1224 mesh_.set_face_handle(heh3, fh_new);
1226 mesh_.set_halfedge_handle(fh_new, _heh);
1231 template<
typename MeshType,
typename RealType>
1232 typename MeshType::VertexHandle
1235 assert(p_mesh_); MeshType& mesh_ = *p_mesh_;
1237 HalfedgeHandle heh1;
1238 HalfedgeHandle heh2;
1239 HalfedgeHandle heh3;
1240 HalfedgeHandle temp_heh;
1244 vh1(mesh_.to_vertex_handle(_heh)),
1245 vh2(mesh_.from_vertex_handle(_heh));
1248 vh = mesh_.
add_vertex((mesh_.point(vh2) + mesh_.point(vh1)) / static_cast<typename MeshType::Point::value_type>(2.0) );
1250 heh2 = mesh_.opposite_halfedge_handle(_heh);
1252 if (!mesh_.is_boundary(mesh_.edge_handle(_heh))) {
1254 for (temp_heh = mesh_.next_halfedge_handle(heh2);
1255 mesh_.next_halfedge_handle(temp_heh) != heh2;
1256 temp_heh = mesh_.next_halfedge_handle(temp_heh) ) {}
1258 for (temp_heh = _heh;
1259 mesh_.next_halfedge_handle(temp_heh) != heh2;
1260 temp_heh = mesh_.opposite_halfedge_handle(mesh_.next_halfedge_handle(temp_heh))) {}
1263 heh1 = mesh_.new_edge(vh, vh1);
1264 heh3 = mesh_.opposite_halfedge_handle(heh1);
1265 mesh_.set_vertex_handle(_heh, vh);
1266 mesh_.set_next_halfedge_handle(temp_heh, heh3);
1267 mesh_.set_next_halfedge_handle(heh1, mesh_.next_halfedge_handle(_heh));
1268 mesh_.set_next_halfedge_handle(_heh, heh1);
1269 mesh_.set_next_halfedge_handle(heh3, heh2);
1270 if (mesh_.face_handle(heh2).is_valid()) {
1271 mesh_.set_face_handle(heh3, mesh_.face_handle(heh2));
1272 mesh_.set_halfedge_handle(mesh_.face_handle(heh3), heh3);
1274 mesh_.set_face_handle(heh1, mesh_.face_handle(_heh));
1275 mesh_.set_halfedge_handle(vh, heh1);
1276 mesh_.set_halfedge_handle(mesh_.face_handle(_heh), _heh);
1277 mesh_.set_halfedge_handle(vh1, heh3);
1288 #endif // OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC defined bool prepare(MeshType &_m)
Prepare mesh, e.g. add properties.
void EV()
Edge to vertex averaging.
void VdE()
Vertex to edge averaging, using diamond of edges.
void FE()
Face to edge averaging.
void VV()
Vertex to vertex averaging.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
void VdEc(scalar_t _c)
Weighted vertex to edge averaging, using diamond of edges.
void corner_cutting(HalfedgeHandle _heh)
Corner Cutting.
void FFc(Coeff &_coeff)
Weighted face to face averaging.
void Tfv()
Split Face, using Face Information.
void VVc(Coeff &_coeff)
Vertex to vertex averaging, weighted.
void FF()
Face to face averaging.
void EVc(Coeff &_coeff)
Weighted edge to vertex averaging.
void EdEc(scalar_t _c)
Weighted edge to edge averaging w/ flap rule.
void EdE()
Edge to edge averaging w/ flap rule.
void Tvv4()
Split Face, using Vertex information (1-4 split)
void VF()
Vertex to Face Averaging.
void FV()
Face to vertex averaging.
VertexHandle split_edge(HalfedgeHandle _heh)
Split Edge.
void Tvv3()
Split Face, using Vertex information (1-3 split)
void EF()
Edge to face averaging.
void VE()
VE Step (Vertex to Edge Averaging)
Abstract base class for coefficient functions.
void VFa(Coeff &_coeff)
Vertex to Face Averaging, weighted.
void FVc(Coeff &_coeff)
Weighted face to vertex Averaging with flaps.