⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rulest.cc

📁 penMesh is a generic and efficient data structure for representing and manipulating polygonal meshes
💻 CC
📖 第 1 页 / 共 4 页
字号:
	face_vector.pop_back();	Inherited::prev_rule()->raise(fh, _target_state - 1);      }      for (ff_it = Inherited::mesh_.ff_iter(_fh); ff_it; ++ff_it) {	face_vector.push_back(ff_it.handle());      }      while (!face_vector.empty()) {	fh = face_vector.back();	face_vector.pop_back();	while (MOBJ(fh).state() < _target_state - 1)	  Inherited::prev_rule()->raise(fh, _target_state - 1);      }    }    // calculate new position    typename M::Point position(0.0, 0.0, 0.0);    int                  valence(0);    for (ff_it = Inherited::mesh_.ff_iter(_fh); ff_it; ++ff_it) {      ++valence;      position += ff_it->position(_target_state - 1);    }    position /= valence;    MOBJ(_fh).set_position(_target_state, position);    MOBJ(_fh).inc_state();  }}// ------------------------------------------------------------------- FFc ----template<class M>void FFc<M>::raise(typename M::FaceHandle& _fh, state_t _target_state) {  if (MOBJ(_fh).state() < _target_state) {    update(_fh, _target_state);    // raise all neighbour faces to level x-1    typename M::FaceFaceIter              ff_it(Inherited::mesh_.ff_iter(_fh));    typename M::FaceHandle                fh;    std::vector<typename M::FaceHandle>   face_vector;    if (_target_state > 1)     {      for (; ff_it; ++ff_it) 	face_vector.push_back(ff_it.handle());      while (!face_vector.empty())       {	fh = face_vector.back();	face_vector.pop_back();	Inherited::prev_rule()->raise(fh, _target_state - 1);      }      for (ff_it = Inherited::mesh_.ff_iter(_fh); ff_it; ++ff_it) 	face_vector.push_back(ff_it.handle());      while (!face_vector.empty()) {	fh = face_vector.back();	face_vector.pop_back();	while (MOBJ(fh).state() < _target_state - 1)	  Inherited::prev_rule()->raise(fh, _target_state - 1);      }    }    // calculate new position    typename M::Point position(0.0, 0.0, 0.0);    int                  valence(0);    for (ff_it = Inherited::mesh_.ff_iter(_fh); ff_it; ++ff_it)     {      ++valence;      position += ff_it->position(_target_state - 1);    }    position /= valence;    // choose coefficient c    typename M::Scalar c = Inherited::coeff();    position *= (1.0 - c);    position += MOBJ(_fh).position(_target_state - 1) * c;    MOBJ(_fh).set_position(_target_state, position);    MOBJ(_fh).inc_state();  }}// -------------------------------------------------------------------- FV ----template<class M>void FV<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::VertexFaceIter            vf_it(Inherited::mesh_.vf_iter(_vh));    typename M::FaceHandle                fh;    std::vector<typename M::FaceHandle>   face_vector;    if (_target_state > 1) {      for (; vf_it; ++vf_it) {	face_vector.push_back(vf_it.handle());      }      while (!face_vector.empty()) {	fh = face_vector.back();	face_vector.pop_back();	Inherited::prev_rule()->raise(fh, _target_state - 1);      }      for (vf_it = Inherited::mesh_.vf_iter(_vh); vf_it; ++vf_it) {	face_vector.push_back(vf_it.handle());      }      while (!face_vector.empty()) {	fh = face_vector.back();	face_vector.pop_back();	while (MOBJ(fh).state() < _target_state - 1)	  Inherited::prev_rule()->raise(fh, _target_state - 1);      }    }    // calculate new position    typename M::Point position(0.0, 0.0, 0.0);    int                  valence(0);    for (vf_it = Inherited::mesh_.vf_iter(_vh); vf_it; ++vf_it) {      ++valence;      position += vf_it->position(_target_state - 1);    }    position /= valence;    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();    }  }}// ------------------------------------------------------------------- FVc ----template<class M>void FVc<M>::raise(typename M::VertexHandle& _vh, state_t _target_state) {  if (MOBJ(_vh).state() < _target_state) {    update(_vh, _target_state);    typename M::VertexOHalfedgeIter       voh_it;    typename M::FaceHandle                fh;    std::vector<typename M::FaceHandle>   face_vector;    int                                      valence(0);    face_vector.clear();    // raise all neighbour faces to level x-1    if (_target_state > 1) {      for (voh_it = Inherited::mesh_.voh_iter(_vh); voh_it; ++voh_it) {	if (Inherited::mesh_.FH(voh_it.handle()).is_valid()) {	  face_vector.push_back(Inherited::mesh_.FH(voh_it.handle()));	  if (Inherited::mesh_.FH(Inherited::mesh_.OHEH(Inherited::mesh_.NHEH(voh_it.handle()))).is_valid()) {	    face_vector.push_back(Inherited::mesh_.FH(Inherited::mesh_.OHEH(Inherited::mesh_.NHEH(voh_it.handle()))));	  }	}      }      while (!face_vector.empty()) {	fh = face_vector.back();	face_vector.pop_back();	Inherited::prev_rule()->raise(fh, _target_state - 1);      }      for (voh_it = Inherited::mesh_.voh_iter(_vh); voh_it; ++voh_it) {	if (Inherited::mesh_.FH(voh_it.handle()).is_valid()) {	  face_vector.push_back(Inherited::mesh_.FH(voh_it.handle()));	  if (Inherited::mesh_.FH(Inherited::mesh_.OHEH(Inherited::mesh_.NHEH(voh_it.handle()))).is_valid()) {	    face_vector.push_back(Inherited::mesh_.FH(Inherited::mesh_.OHEH(Inherited::mesh_.NHEH(voh_it.handle()))));	  }	}      }      while (!face_vector.empty()) {	fh = face_vector.back();	face_vector.pop_back();	while (MOBJ(fh).state() < _target_state - 1)	  Inherited::prev_rule()->raise(fh, _target_state - 1);      }      for (voh_it = Inherited::mesh_.voh_iter(_vh); voh_it; ++voh_it) {	if (Inherited::mesh_.FH(voh_it.handle()).is_valid()) {	  face_vector.push_back(Inherited::mesh_.FH(voh_it.handle()));	  if (Inherited::mesh_.FH(Inherited::mesh_.OHEH(Inherited::mesh_.NHEH(voh_it.handle()))).is_valid()) {	    face_vector.push_back(Inherited::mesh_.FH(Inherited::mesh_.OHEH(Inherited::mesh_.NHEH(voh_it.handle()))));	  }	}      }      while (!face_vector.empty()) {	fh = face_vector.back();	face_vector.pop_back();	while (MOBJ(fh).state() < _target_state - 1)	  Inherited::prev_rule()->raise(fh, _target_state - 1);      }    }    // calculate new position    typename M::Point               position(0.0, 0.0, 0.0);    typename M::Scalar              c;#if 0    const typename M::Scalar        _2pi(2.0*M_PI);    const typename M::Scalar        _2over3(2.0/3.0);    for (voh_it = Inherited::mesh_.voh_iter(_vh); voh_it; ++voh_it)     {           ++valence;    }    // choose coefficient c    c = _2over3 * ( cos( _2pi / valence) + 1.0);#else    valence = Inherited::mesh_.valence(_vh);    c       = coeff(valence);#endif    for (voh_it = Inherited::mesh_.voh_iter(_vh); voh_it; ++voh_it) {      fh = Inherited::mesh_.FH(voh_it.handle());      if (fh.is_valid())	Inherited::prev_rule()->raise(fh, _target_state - 1);      fh = Inherited::mesh_.FH(Inherited::mesh_.OHEH(Inherited::mesh_.NHEH(voh_it.handle())));      if (fh.is_valid())	Inherited::prev_rule()->raise(fh, _target_state - 1);      if (Inherited::mesh_.FH(voh_it.handle()).is_valid()) {	if (Inherited::mesh_.FH(Inherited::mesh_.OHEH(Inherited::mesh_.NHEH(voh_it.handle()))).is_valid()) {	  position += MOBJ(Inherited::mesh_.FH(voh_it.handle())).position(_target_state - 1) * c;	  position += MOBJ(Inherited::mesh_.FH(Inherited::mesh_.OHEH(Inherited::mesh_.NHEH(voh_it.handle())))).position(_target_state - 1) * (1.0 - c);	}	else {	  position += MOBJ(Inherited::mesh_.FH(voh_it.handle())).position(_target_state - 1);	}      }      else {	--valence;      }    }         position /= valence;    MOBJ(_vh).set_position(_target_state, position);    MOBJ(_vh).inc_state();    assert(MOBJ(_vh).state() == _target_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>std::vector<double> FVc<M>::coeffs_;template <class M>void FVc<M>::init_coeffs(size_t _max_valence){  if ( coeffs_.size() == _max_valence+1 )    return;  if ( coeffs_.size() < _max_valence+1 )  {    const double _2pi(2.0*M_PI);    const double _2over3(2.0/3.0);    if (coeffs_.empty())      coeffs_.push_back(0.0); // dummy for valence 0          for(size_t v=coeffs_.size(); v <= _max_valence; ++v)      coeffs_.push_back(_2over3 * ( cos( _2pi / v) + 1.0));      }}// -------------------------------------------------------------------- VV ----template<class M>void VV<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::VertexVertexIter              vv_it(Inherited::mesh_.vv_iter(_vh));    typename M::VertexHandle                  vh;    std::vector<typename M::VertexHandle>     vertex_vector;    if (_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);      }      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);    for (vv_it = Inherited::mesh_.vv_iter(_vh); vv_it; ++vv_it) {      ++valence;      position += vv_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();    }  }}// ------------------------------------------------------------------- VVc ----template<class M>void VVc<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::VertexVertexIter              vv_it(Inherited::mesh_.vv_iter(_vh));    typename M::VertexHandle                  vh;    std::vector<typename M::VertexHandle>     vertex_vector;    if (_target_state > 1) {      for (; vv_it; ++vv_it) {	vertex_vector.push_back(vv_it.handle());      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -