📄 rulest.cc
字号:
while (!vertex_vector.empty()) { vh = vertex_vector.back(); vertex_vector.pop_back(); Inherited::prev_rule()->raise(vh, _target_state - 1); } for (; vv_it; ++vv_it) { vertex_vector.push_back(vv_it.handle()); } while (!vertex_vector.empty()) { vh = vertex_vector.back(); vertex_vector.pop_back(); Inherited::prev_rule()->raise(vh, _target_state - 1); } } // calculate new position typename M::Point position(0.0, 0.0, 0.0); int valence(0); typename M::Scalar c; for (vv_it = Inherited::mesh_.vv_iter(_vh); vv_it; ++vv_it) { ++valence; position += vv_it->position(_target_state - 1); } position /= valence; // choose coefficcient c c = Inherited::coeff(); position *= (1.0 - c); position += MOBJ(_vh).position(_target_state - 1) * c; MOBJ(_vh).set_position(_target_state, position); MOBJ(_vh).inc_state(); if (Inherited::number() == Inherited::n_rules() - 1) { Inherited::mesh_.set_point(_vh, position); MOBJ(_vh).set_final(); } }}// -------------------------------------------------------------------- VE ----template<class M>void VE<M>::raise(typename M::EdgeHandle& _eh, state_t _target_state) { if (MOBJ(_eh).state() < _target_state) { update(_eh, _target_state); // raise all neighbour vertices to level x-1 typename M::VertexHandle vh; typename M::HalfedgeHandle hh1(Inherited::mesh_.HEH(_eh, 0)), hh2(Inherited::mesh_.HEH(_eh, 1)); if (_target_state > 1) { vh = Inherited::mesh_.TVH(hh1); Inherited::prev_rule()->raise(vh, _target_state - 1); vh = Inherited::mesh_.TVH(hh2); Inherited::prev_rule()->raise(vh, _target_state - 1); } // calculate new position typename M::Point position(0.0, 0.0, 0.0); int valence(0); valence = 2; position += MOBJ(Inherited::mesh_.TVH(hh1)).position(_target_state - 1); position += MOBJ(Inherited::mesh_.TVH(hh2)).position(_target_state - 1); position /= valence; MOBJ(_eh).set_position(_target_state, position); MOBJ(_eh).inc_state(); }}// ------------------------------------------------------------------- VdE ----template<class M>void VdE<M>::raise(typename M::EdgeHandle& _eh, state_t _target_state) { if (MOBJ(_eh).state() < _target_state) { update(_eh, _target_state); // raise all neighbour vertices to level x-1 typename M::VertexHandle vh; typename M::HalfedgeHandle hh1(Inherited::mesh_.HEH(_eh, 0)), hh2(Inherited::mesh_.HEH(_eh, 1)); std::vector<typename M::VertexHandle> vertex_vector; typename M::FaceHandle fh1, fh2; if (_target_state > 1) { fh1 = Inherited::mesh_.FH(hh1); fh2 = Inherited::mesh_.FH(hh2); if (fh1.is_valid()) { Inherited::prev_rule()->raise(fh1, _target_state - 1); vh = Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh1)); Inherited::prev_rule()->raise(vh, _target_state - 1); } if (fh2.is_valid()) { Inherited::prev_rule()->raise(fh2, _target_state - 1); vh = Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh2)); Inherited::prev_rule()->raise(vh, _target_state - 1); } vh = Inherited::mesh_.TVH(hh1); Inherited::prev_rule()->raise(vh, _target_state - 1); vh = Inherited::mesh_.TVH(hh2); Inherited::prev_rule()->raise(vh, _target_state - 1); } // calculate new position typename M::Point position(0.0, 0.0, 0.0); int valence(0); valence = 2; position += MOBJ(Inherited::mesh_.TVH(hh1)).position(_target_state - 1); position += MOBJ(Inherited::mesh_.TVH(hh2)).position(_target_state - 1); if (fh1.is_valid()) { position += MOBJ(Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh1))).position(_target_state - 1); ++valence; } if (fh2.is_valid()) { position += MOBJ(Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh2))).position(_target_state - 1); ++valence; } if (Inherited::number() == Inherited::subdiv_rule()->Inherited::number() + 1) valence = 4; position /= valence; MOBJ(_eh).set_position(_target_state, position); MOBJ(_eh).inc_state(); }}// ------------------------------------------------------------------ VdEc ----template<class M>voidVdEc<M>::raise(typename M::EdgeHandle& _eh, state_t _target_state) { if (MOBJ(_eh).state() < _target_state) { update(_eh, _target_state); // raise all neighbour vertices to level x-1 typename M::VertexHandle vh; typename M::HalfedgeHandle hh1(Inherited::mesh_.HEH(_eh, 0)), hh2(Inherited::mesh_.HEH(_eh, 1)); std::vector<typename M::VertexHandle> vertex_vector; typename M::FaceHandle fh1, fh2; if (_target_state > 1) { fh1 = Inherited::mesh_.FH(Inherited::mesh_.HEH(_eh, 0)); fh2 = Inherited::mesh_.FH(Inherited::mesh_.HEH(_eh, 1)); Inherited::prev_rule()->raise(fh1, _target_state - 1); Inherited::prev_rule()->raise(fh2, _target_state - 1); vertex_vector.push_back(Inherited::mesh_.TVH(hh1)); vertex_vector.push_back(Inherited::mesh_.TVH(hh2)); vertex_vector.push_back(Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh1))); vertex_vector.push_back(Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh2))); while (!vertex_vector.empty()) { vh = vertex_vector.back(); vertex_vector.pop_back(); Inherited::prev_rule()->raise(vh, _target_state - 1); } vertex_vector.push_back(Inherited::mesh_.TVH(hh1)); vertex_vector.push_back(Inherited::mesh_.TVH(hh2)); vertex_vector.push_back(Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh1))); vertex_vector.push_back(Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh2))); while (!vertex_vector.empty()) { vh = vertex_vector.back(); vertex_vector.pop_back(); Inherited::prev_rule()->raise(vh, _target_state - 1); } } // calculate new position typename M::Point position(0.0, 0.0, 0.0); int valence(0); typename M::Scalar c; // choose coefficient c c = Inherited::coeff(); valence = 4; position += MOBJ(Inherited::mesh_.TVH(hh1)).position(_target_state - 1) * c; position += MOBJ(Inherited::mesh_.TVH(hh2)).position(_target_state - 1) * c; position += MOBJ(Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh1))).position(_target_state - 1) * (0.5 - c); position += MOBJ(Inherited::mesh_.TVH(Inherited::mesh_.NHEH(hh2))).position(_target_state - 1) * (0.5 - c); position /= valence; MOBJ(_eh).set_position(_target_state, position); MOBJ(_eh).inc_state(); }}// -------------------------------------------------------------------- EV ----template<class M>void EV<M>::raise(typename M::VertexHandle& _vh, state_t _target_state) { if (MOBJ(_vh).state() < _target_state) { update(_vh, _target_state); // raise all neighbour vertices to level x-1 typename M::VertexEdgeIter ve_it(Inherited::mesh_.ve_iter(_vh)); typename M::EdgeHandle eh; std::vector<typename M::EdgeHandle> edge_vector; if (_target_state > 1) { for (; ve_it; ++ve_it) { edge_vector.push_back(ve_it.handle()); } while (!edge_vector.empty()) { eh = edge_vector.back(); edge_vector.pop_back(); Inherited::prev_rule()->raise(eh, _target_state - 1); } for (ve_it = Inherited::mesh_.ve_iter(_vh); ve_it; ++ve_it) { edge_vector.push_back(ve_it.handle()); } while (!edge_vector.empty()) { eh = edge_vector.back(); edge_vector.pop_back(); while (MOBJ(eh).state() < _target_state - 1) Inherited::prev_rule()->raise(eh, _target_state - 1); } } // calculate new position typename M::Point position(0.0, 0.0, 0.0); int valence(0); for (ve_it = Inherited::mesh_.ve_iter(_vh); ve_it; ++ve_it) { if (ve_it->final()) { ++valence; position += ve_it->position(_target_state - 1); } } position /= valence; MOBJ(_vh).set_position(_target_state, position); MOBJ(_vh).inc_state(); // check if last rule if (Inherited::number() == Inherited::n_rules() - 1) { Inherited::mesh_.set_point(_vh, position); MOBJ(_vh).set_final(); } }}// ------------------------------------------------------------------- EVc ----template<class M>std::vector<double> EVc<M>::coeffs_;template<class M>void EVc<M>::raise(typename M::VertexHandle& _vh, state_t _target_state) { if (MOBJ(_vh).state() < _target_state) { update(_vh, _target_state); // raise all neighbour vertices to level x-1 typename M::VertexOHalfedgeIter voh_it; typename M::EdgeHandle eh; typename M::FaceHandle fh; std::vector<typename M::EdgeHandle> edge_vector; std::vector<typename M::FaceHandle> face_vector; if (_target_state > 1) { for (voh_it = Inherited::mesh_.voh_iter(_vh); voh_it; ++voh_it) { face_vector.push_back(Inherited::mesh_.FH(voh_it.handle())); } while (!face_vector.empty()) { fh = face_vector.back(); face_vector.pop_back(); if (fh.is_valid()) Inherited::prev_rule()->raise(fh, _target_state - 1); } for (voh_it = Inherited::mesh_.voh_iter(_vh); voh_it; ++voh_it) { edge_vector.push_back(Inherited::mesh_.EH(voh_it.handle())); edge_vector.push_back(Inherited::mesh_.EH(Inherited::mesh_.NHEH(voh_it.handle()))); } while (!edge_vector.empty()) { eh = edge_vector.back(); edge_vector.pop_back(); while (MOBJ(eh).state() < _target_state - 1) Inherited::prev_rule()->raise(eh, _target_state - 1); } } // calculate new position typename M::Point position(0.0, 0.0, 0.0); typename M::Scalar c; typename M::Point zero_point(0.0, 0.0, 0.0); int valence(0); valence = Inherited::mesh_.valence(_vh); c = coeff( valence ); for (voh_it = Inherited::mesh_.voh_iter(_vh); voh_it; ++voh_it) { if (MOBJ(Inherited::mesh_.EH(voh_it.handle())).final()) { position += MOBJ(Inherited::mesh_.EH(voh_it.handle())).position(_target_state-1)*c; if ( Inherited::mesh_.FH(voh_it.handle()).is_valid() && MOBJ(Inherited::mesh_.EH(Inherited::mesh_.NHEH(voh_it.handle()))).final() && MOBJ(Inherited::mesh_.EH(Inherited::mesh_.NHEH(voh_it.handle()))).position(_target_state - 1) != zero_point) { position += MOBJ(Inherited::mesh_.EH(Inherited::mesh_.NHEH(voh_it.handle()))).position(_target_state-1) * (1.0-c); } else { position += MOBJ(Inherited::mesh_.EH(voh_it.handle())).position(_target_state - 1) * (1.0 - c); } } else { --valence; } } position /= valence; MOBJ(_vh).set_position(_target_state, position); MOBJ(_vh).inc_state(); // check if last rule if (Inherited::number() == Inherited::n_rules() - 1) { Inherited::mesh_.set_point(_vh, position); MOBJ(_vh).set_final(); } }}template <class M>void EVc<M>::init_coeffs(size_t _max_valence){ if ( coeffs_.size() == _max_valence+1 ) // equal? do nothing return; if (coeffs_.size() < _max_valence+1) // less than? add additional valences { const double _2pi = 2.0*M_PI; double c; if (coeffs_.empty()) coeffs_.push_back(0.0); // dummy for invalid valences 0,1,2 for(size_t v=coeffs_.size(); v <= _max_valence; ++v) { // ( 3/2 + cos ( 2 PI / valence ) )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -